Class ClassLoaderServiceImpl
java.lang.Object
org.bonitasoft.engine.classloader.ClassLoaderServiceImpl
- All Implemented Interfaces:
ClassLoaderService,LifecycleService,PlatformLifecycleService
@Component("classLoaderService")
public class ClassLoaderServiceImpl
extends Object
implements ClassLoaderService
- Author:
- Elias Ricken de Medeiros, Baptiste Mesta, Matthieu Chaffotte
-
Constructor Summary
ConstructorsConstructorDescriptionClassLoaderServiceImpl(ParentClassLoaderResolver parentClassLoaderResolver, EventService eventService, PlatformDependencyService platformDependencyService, UserTransactionService userTransactionService, BroadcastService broadcastService, org.bonitasoft.engine.classloader.ClassLoaderUpdater classLoaderUpdater, List<PlatformClassLoaderListener> platformClassLoaderListeners) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddListener(ClassLoaderIdentifier identifier, SingleClassLoaderListener singleClassLoaderListener) add listener on a classloaderGet the local ClassLoader for the given type and id.getOrInitializeClassloader(ClassLoaderIdentifier id, Function<ClassLoaderIdentifier, BonitaClassLoader> createClassloaderFunction) voidrefreshClassLoaderAfterUpdate(ClassLoaderIdentifier identifier) voidrefreshClassLoaderImmediately(ClassLoaderIdentifier identifier) This method refreshes in the current thread/transaction the classLoader with the given identifier.voidThis method refreshes in the current thread/transaction the classLoader with the given identifier.voidrefreshClassLoaderOnOtherNodes(ClassLoaderIdentifier identifier) voidregisterDependencyService(TenantDependencyService tenantDependencyService) booleanremoveListener(ClassLoaderIdentifier identifier, SingleClassLoaderListener singleClassLoaderListener) voidremoveLocalClassloader(ClassLoaderIdentifier identifier) voidvoidstart()Start the servicevoidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bonitasoft.engine.commons.LifecycleService
pause, resume
-
Constructor Details
-
ClassLoaderServiceImpl
public ClassLoaderServiceImpl(ParentClassLoaderResolver parentClassLoaderResolver, @Qualifier("platformEventService") EventService eventService, PlatformDependencyService platformDependencyService, UserTransactionService userTransactionService, BroadcastService broadcastService, org.bonitasoft.engine.classloader.ClassLoaderUpdater classLoaderUpdater, List<PlatformClassLoaderListener> platformClassLoaderListeners)
-
-
Method Details
-
registerDependencyService
- Specified by:
registerDependencyServicein interfaceClassLoaderService
-
getClassLoader
Description copied from interface:ClassLoaderServiceGet the local ClassLoader for the given type and id. If no ClassLoader already exists, a new one is created and initialized. This initialization is executed in a different thread/transaction. It eagerly initialize parent classloaders.- Specified by:
getClassLoaderin interfaceClassLoaderService- Parameters:
id- of the classloader to refresh- Returns:
- the local ClassLoader for the given type and id
-
getOrInitializeClassloader
public BonitaClassLoader getOrInitializeClassloader(ClassLoaderIdentifier id, Function<ClassLoaderIdentifier, BonitaClassLoader> createClassloaderFunction) -
removeLocalClassloader
- Specified by:
removeLocalClassloaderin interfaceClassLoaderService- Throws:
SClassLoaderException
-
start
public void start()Description copied from interface:LifecycleServiceStart the service- Specified by:
startin interfaceLifecycleService
-
stop
public void stop()- Specified by:
stopin interfaceLifecycleService
-
addListener
public boolean addListener(ClassLoaderIdentifier identifier, SingleClassLoaderListener singleClassLoaderListener) Description copied from interface:ClassLoaderServiceadd listener on a classloader- Specified by:
addListenerin interfaceClassLoaderService- Parameters:
identifier- the classloader idsingleClassLoaderListener- the listener to add- Returns:
- true if the listener was added
-
removeListener
public boolean removeListener(ClassLoaderIdentifier identifier, SingleClassLoaderListener singleClassLoaderListener) - Specified by:
removeListenerin interfaceClassLoaderService- Parameters:
identifier- the classloader idsingleClassLoaderListener- classloader listener to remove- Returns:
- true if the listener was removed
-
refreshClassLoaderImmediatelyWithRollback
public void refreshClassLoaderImmediatelyWithRollback(ClassLoaderIdentifier identifier) throws SClassLoaderException Description copied from interface:ClassLoaderServiceThis method refreshes in the current thread/transaction the classLoader with the given identifier. Contrary to refreshClassLoaderImmediately, it creates a synchronization that triggers a reload of the classloader in case the transaction was rolled back, insuring there is no new loaded class in the classloader after the rollback.e.g. If the classloader was set as the current context classloader, it should be reset like this
Thread.currentThread().setContextClassLoader(classLoaderService.getLocalClassLoader(identifier));- Specified by:
refreshClassLoaderImmediatelyWithRollbackin interfaceClassLoaderService- Parameters:
identifier- of the classloader to refresh- Throws:
SClassLoaderException
-
refreshClassLoaderImmediately
public void refreshClassLoaderImmediately(ClassLoaderIdentifier identifier) throws SClassLoaderException Description copied from interface:ClassLoaderServiceThis method refreshes in the current thread/transaction the classLoader with the given identifier. It eagerly initializes parents classloaders.A new classloader will be created. In order to use the new classloader, references to the old one should be updated.
e.g. If the classloader was set as the current context classloader, it should be reset like this
Thread.currentThread().setContextClassLoader(classLoaderService.getLocalClassLoader(identifier));- Specified by:
refreshClassLoaderImmediatelyin interfaceClassLoaderService- Parameters:
identifier- of the classloader to refresh- Throws:
SClassLoaderException
-
refreshClassLoaderAfterUpdate
public void refreshClassLoaderAfterUpdate(ClassLoaderIdentifier identifier) throws SClassLoaderException - Specified by:
refreshClassLoaderAfterUpdatein interfaceClassLoaderService- Throws:
SClassLoaderException
-
refreshClassLoaderOnOtherNodes
public void refreshClassLoaderOnOtherNodes(ClassLoaderIdentifier identifier) throws SClassLoaderException - Specified by:
refreshClassLoaderOnOtherNodesin interfaceClassLoaderService- Throws:
SClassLoaderException
-
removeRefreshClassLoaderSynchronization
public void removeRefreshClassLoaderSynchronization()- Specified by:
removeRefreshClassLoaderSynchronizationin interfaceClassLoaderService
-