Class ClassLoaderServiceImpl
- java.lang.Object
-
- org.bonitasoft.engine.classloader.ClassLoaderServiceImpl
-
- All Implemented Interfaces:
ClassLoaderService,LifecycleService,PlatformLifecycleService
@Component("classLoaderService") public class ClassLoaderServiceImpl extends java.lang.Object implements ClassLoaderService- Author:
- Elias Ricken de Medeiros, Baptiste Mesta, Matthieu Chaffotte
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderServiceImpl(ParentClassLoaderResolver parentClassLoaderResolver, EventService eventService, PlatformDependencyService platformDependencyService, SessionAccessor sessionAccessor, UserTransactionService userTransactionService, BroadcastService broadcastService, org.bonitasoft.engine.classloader.ClassLoaderUpdater classLoaderUpdater, java.util.List<PlatformClassLoaderListener> platformClassLoaderListeners)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddListener(ClassLoaderIdentifier identifier, SingleClassLoaderListener singleClassLoaderListener)add listener on a classloaderBonitaClassLoadergetClassLoader(ClassLoaderIdentifier id)Get the local ClassLoader for the given type and id.BonitaClassLoadergetOrInitializeClassloader(ClassLoaderIdentifier id, java.util.function.Function<ClassLoaderIdentifier,BonitaClassLoader> createClassloaderFunction)voidpause()Temporary halt the execution of this service.voidrefreshClassLoaderAfterUpdate(ClassLoaderIdentifier identifier)voidrefreshClassLoaderImmediately(ClassLoaderIdentifier identifier)This method refreshes in the current thread/transaction the classLoader with the given identifier.voidrefreshClassLoaderImmediatelyWithRollback(ClassLoaderIdentifier identifier)This method refreshes in the current thread/transaction the classLoader with the given identifier.voidrefreshClassLoaderOnOtherNodes(ClassLoaderIdentifier identifier)voidregisterDependencyServiceOfTenant(java.lang.Long tenantId, TenantDependencyService tenantDependencyService)booleanremoveListener(ClassLoaderIdentifier identifier, SingleClassLoaderListener singleClassLoaderListener)voidremoveLocalClassloader(ClassLoaderIdentifier identifier)voidremoveRefreshClassLoaderSynchronization()voidresume()resume the execution the servicevoidstart()Start the servicevoidstop()
-
-
-
Constructor Detail
-
ClassLoaderServiceImpl
public ClassLoaderServiceImpl(ParentClassLoaderResolver parentClassLoaderResolver, @Qualifier("platformEventService") EventService eventService, PlatformDependencyService platformDependencyService, SessionAccessor sessionAccessor, UserTransactionService userTransactionService, BroadcastService broadcastService, org.bonitasoft.engine.classloader.ClassLoaderUpdater classLoaderUpdater, java.util.List<PlatformClassLoaderListener> platformClassLoaderListeners)
-
-
Method Detail
-
registerDependencyServiceOfTenant
public void registerDependencyServiceOfTenant(java.lang.Long tenantId, TenantDependencyService tenantDependencyService)- Specified by:
registerDependencyServiceOfTenantin interfaceClassLoaderService
-
getClassLoader
public BonitaClassLoader getClassLoader(ClassLoaderIdentifier id)
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, java.util.function.Function<ClassLoaderIdentifier,BonitaClassLoader> createClassloaderFunction)
-
removeLocalClassloader
public void removeLocalClassloader(ClassLoaderIdentifier identifier) throws SClassLoaderException
- 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
-
pause
public void pause()
Description copied from interface:LifecycleServiceTemporary halt the execution of this service.- Specified by:
pausein interfaceLifecycleService
-
resume
public void resume()
Description copied from interface:LifecycleServiceresume the execution the service- Specified by:
resumein 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
-
-