@Override
 public void deleteProcessInstance(final SProcessInstance sProcessInstance)
     throws SProcessInstanceModificationException {
   final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
   try {
     final long processDefinitionId = sProcessInstance.getProcessDefinitionId();
     final ClassLoader localClassLoader =
         classLoaderService.getLocalClassLoader("process", processDefinitionId);
     Thread.currentThread().setContextClassLoader(localClassLoader);
     deleteProcessInstanceElements(sProcessInstance);
     final DeleteRecord deleteRecord = new DeleteRecord(sProcessInstance);
     SDeleteEvent deleteEvent = null;
     if (eventService.hasHandlers(PROCESSINSTANCE, EventActionType.DELETED)) {
       deleteEvent =
           (SDeleteEvent)
               BuilderFactory.get(SEventBuilderFactory.class)
                   .createDeleteEvent(PROCESSINSTANCE)
                   .setObject(sProcessInstance)
                   .done();
     }
     recorder.recordDelete(deleteRecord, deleteEvent);
   } catch (final SBonitaException e) {
     throw new SProcessInstanceModificationException(e);
   } finally {
     Thread.currentThread().setContextClassLoader(contextClassLoader);
   }
 }
 @Override
 public void deleteDataInstance(final SDataInstance dataInstance) throws SDataInstanceException {
   NullCheckingUtil.checkArgsNotNull(dataInstance);
   final DeleteRecord deleteRecord = new DeleteRecord(dataInstance);
   final SDeleteEvent deleteEvent = getDeleteEvent(dataInstance);
   try {
     recorder.recordDelete(deleteRecord, deleteEvent);
   } catch (final SRecorderException e) {
     throw new SDeleteDataInstanceException("Impossible to delete data instance", e);
   }
 }
 @Override
 public void deleteArchivedProcessInstance(final SAProcessInstance archivedProcessInstance)
     throws SProcessInstanceModificationException {
   final DeleteRecord deleteRecord = new DeleteRecord(archivedProcessInstance);
   SDeleteEvent deleteEvent = null;
   if (eventService.hasHandlers(PROCESSINSTANCE, EventActionType.DELETED)) {
     deleteEvent =
         (SDeleteEvent)
             BuilderFactory.get(SEventBuilderFactory.class)
                 .createDeleteEvent(PROCESSINSTANCE)
                 .setObject(archivedProcessInstance)
                 .done();
   }
   try {
     recorder.recordDelete(deleteRecord, deleteEvent);
   } catch (final SRecorderException e) {
     throw new SProcessInstanceModificationException(e);
   }
 }