Package org.nuxeo.runtime.reload
Class ReloadComponent
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.runtime.reload.ReloadComponent
-
- All Implemented Interfaces:
Adaptable
,Component
,Extensible
,ReloadService
,TimestampedService
public class ReloadComponent extends DefaultComponent implements ReloadService
- Author:
- Bogdan Stefanescu
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.osgi.framework.Bundle
bundle
protected Long
lastFlushed
static String
RELOAD_STRATEGY_PARAMETER
The reload strategy to adopt for hot reload.static String
RELOAD_STRATEGY_VALUE_DEFAULT
static String
RELOAD_STRATEGY_VALUE_RESTART
static String
RELOAD_STRATEGY_VALUE_STANDBY
static String
RELOAD_STRATEGY_VALUE_UNSTASH
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Fields inherited from interface org.nuxeo.runtime.reload.ReloadService
AFTER_RELOAD_EVENT_ID, BEFORE_RELOAD_EVENT_ID, FLUSH_EVENT_ID, FLUSH_SEAM_EVENT_ID, RELOAD_EVENT_ID, RELOAD_SEAM_EVENT_ID, RELOAD_TOPIC, USE_COMPAT_HOT_RELOAD
-
-
Constructor Summary
Constructors Constructor Description ReloadComponent()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected ReloadResult
_deployBundles(List<File> bundlesToDeploy)
protected ReloadResult
_undeployBundles(List<String> bundleNames)
void
activate(ComponentContext context)
Activates the component.protected void
clearJarFileFactoryCache(ReloadResult result)
protected List<File>
copyBundlesToDeploy(ReloadContext context)
protected void
copyFile(File srcFile, File destFile)
Method copied from commons-io:commons-io:2.6 to handle replace if exist on Windows.void
deactivate(ComponentContext context)
Deactivates the component.void
deployBundles(List<File> files, boolean reloadResources)
Deprecated.since 9.3 usereloadBundles(ReloadContext)
instead.void
flush()
Sends a runtime event with idReloadService.FLUSH_EVENT_ID
so that listeners can be notified that a flush is needed (after a reload for instance).void
flushJaasCache()
Sends an event that can trigger reset of JaasCache.void
flushSeamComponents()
Sends a runtime event with idReloadService.FLUSH_SEAM_EVENT_ID
.protected static File
getAppDir()
static org.osgi.framework.Bundle
getBundle()
static org.osgi.framework.BundleContext
getBundleContext()
String
getOSGIBundleName(File file)
Returns the OSGI bundle name if given file can be identified as an OSGI bundle, or null.protected static File
getWarDir()
void
installWebResources(File file)
Deprecated.since 5.6, userunDeploymentPreprocessor()
instead.Long
lastFlushed()
Returns the last time one of the flush commands where called on this service instance (ReloadService.flush()
orReloadService.flushJaasCache()
orReloadService.flushSeamComponents()
, or null if never called.protected void
logComponentManagerStatus()
Logs theComponentManager
status.protected void
refreshComponents()
Deprecated.since 9.3, this method is only used in deployBundles and undeployBundles which are deprecated.void
reload()
Sends a runtime event with idReloadService.RELOAD_EVENT_ID
so that listeners can be notified that a reload has been done.ReloadResult
reloadBundles(ReloadContext context)
Called by ReloadServiceInvoker#hotReloadBundles.void
reloadProperties()
Reloads runtime framework propertiesvoid
reloadSeamComponents()
Sends a runtime event with idReloadService.RELOAD_SEAM_EVENT_ID
void
runDeploymentPreprocessor()
Runs the deployment preprocessor.protected void
setFlushedNow()
Sets the last date date to current date timestampprotected URL
toURL(File file)
protected URL
toURL(org.osgi.framework.Bundle bundle)
This method needs to be called before bundle uninstallation, otherwiseBundle.getLocation()
throw a NPE.protected void
triggerReload(String eventId)
Deprecated.since 9.3 should not be needed anymoreprotected void
triggerReloadWithNewTransaction(String eventId)
Deprecated.since 9.3 should not be needed anymorevoid
undeployBundles(List<String> bundleNames, boolean reloadResources)
Deprecated.since 9.3 usereloadBundles(ReloadContext)
instead.-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterContribution, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
Methods inherited from interface org.nuxeo.runtime.reload.ReloadService
deployBundle, deployBundle, deployBundles, undeployBundle, undeployBundle, undeployBundles
-
Methods inherited from interface org.nuxeo.runtime.service.TimestampedService
getLastModified, setLastModified
-
-
-
-
Field Detail
-
RELOAD_STRATEGY_PARAMETER
public static final String RELOAD_STRATEGY_PARAMETER
The reload strategy to adopt for hot reload. Default value isRELOAD_STRATEGY_VALUE_DEFAULT
.- Since:
- 9.3
- See Also:
- Constant Field Values
-
RELOAD_STRATEGY_VALUE_UNSTASH
public static final String RELOAD_STRATEGY_VALUE_UNSTASH
- See Also:
- Constant Field Values
-
RELOAD_STRATEGY_VALUE_STANDBY
public static final String RELOAD_STRATEGY_VALUE_STANDBY
- See Also:
- Constant Field Values
-
RELOAD_STRATEGY_VALUE_RESTART
public static final String RELOAD_STRATEGY_VALUE_RESTART
- See Also:
- Constant Field Values
-
RELOAD_STRATEGY_VALUE_DEFAULT
public static final String RELOAD_STRATEGY_VALUE_DEFAULT
- See Also:
- Constant Field Values
-
bundle
protected static org.osgi.framework.Bundle bundle
-
lastFlushed
protected Long lastFlushed
-
-
Method Detail
-
getBundleContext
public static org.osgi.framework.BundleContext getBundleContext()
-
getBundle
public static org.osgi.framework.Bundle getBundle()
-
activate
public void activate(ComponentContext context)
Description copied from interface:Component
Activates the component.This method is called by the runtime when a component is activated.
- Specified by:
activate
in interfaceComponent
- Overrides:
activate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
refreshComponents
@Deprecated(since="9.3") protected void refreshComponents()
Deprecated.since 9.3, this method is only used in deployBundles and undeployBundles which are deprecated. Keep it for backward compatibility.
-
reload
public void reload()
Description copied from interface:ReloadService
Sends a runtime event with idReloadService.RELOAD_EVENT_ID
so that listeners can be notified that a reload has been done.Also calls
ReloadService.reloadProperties()
by default, but not other reload methods as they could alter the running application behaviour.- Specified by:
reload
in interfaceReloadService
- See Also:
ReloadService.reloadProperties()
-
reloadProperties
public void reloadProperties() throws IOException
Description copied from interface:ReloadService
Reloads runtime framework properties- Specified by:
reloadProperties
in interfaceReloadService
- Throws:
IOException
-
reloadSeamComponents
public void reloadSeamComponents()
Description copied from interface:ReloadService
Sends a runtime event with idReloadService.RELOAD_SEAM_EVENT_ID
- Specified by:
reloadSeamComponents
in interfaceReloadService
-
flush
public void flush()
Description copied from interface:ReloadService
Sends a runtime event with idReloadService.FLUSH_EVENT_ID
so that listeners can be notified that a flush is needed (after a reload for instance).Also calls
ReloadService.flushJaasCache()
by default, but not other flush methods as they could alter the running application behaviour.- Specified by:
flush
in interfaceReloadService
- See Also:
ReloadService.flushJaasCache()
-
flushJaasCache
public void flushJaasCache()
Description copied from interface:ReloadService
Sends an event that can trigger reset of JaasCache.- Specified by:
flushJaasCache
in interfaceReloadService
-
flushSeamComponents
public void flushSeamComponents()
Description copied from interface:ReloadService
Sends a runtime event with idReloadService.FLUSH_SEAM_EVENT_ID
.- Specified by:
flushSeamComponents
in interfaceReloadService
-
deployBundles
@Deprecated(since="9.3") public void deployBundles(List<File> files, boolean reloadResources) throws org.osgi.framework.BundleException
Deprecated.since 9.3 usereloadBundles(ReloadContext)
instead.Description copied from interface:ReloadService
Deploys bundles to the runtime, gives possibility to control resources reloading.- Specified by:
deployBundles
in interfaceReloadService
- Throws:
org.osgi.framework.BundleException
-
undeployBundles
@Deprecated(since="9.3") public void undeployBundles(List<String> bundleNames, boolean reloadResources) throws org.osgi.framework.BundleException
Deprecated.since 9.3 usereloadBundles(ReloadContext)
instead.Description copied from interface:ReloadService
Undeploys bundles from the runtime, gives possibility to control resources reloading.- Specified by:
undeployBundles
in interfaceReloadService
- Throws:
org.osgi.framework.BundleException
-
reloadBundles
public ReloadResult reloadBundles(ReloadContext context) throws org.osgi.framework.BundleException
Description copied from interface:ReloadService
Called by ReloadServiceInvoker#hotReloadBundles.- Specified by:
reloadBundles
in interfaceReloadService
- Returns:
- the result of hot reload operation
- Throws:
org.osgi.framework.BundleException
-
copyBundlesToDeploy
protected List<File> copyBundlesToDeploy(ReloadContext context) throws org.osgi.framework.BundleException
- Throws:
org.osgi.framework.BundleException
-
copyFile
protected void copyFile(File srcFile, File destFile) throws IOException
Method copied from commons-io:commons-io:2.6 to handle replace if exist on Windows.- Throws:
IOException
- Since:
- 2021.19
-
_deployBundles
protected ReloadResult _deployBundles(List<File> bundlesToDeploy) throws org.osgi.framework.BundleException
- Throws:
org.osgi.framework.BundleException
-
_undeployBundles
protected ReloadResult _undeployBundles(List<String> bundleNames) throws org.osgi.framework.BundleException
- Throws:
org.osgi.framework.BundleException
-
clearJarFileFactoryCache
protected void clearJarFileFactoryCache(ReloadResult result)
-
toURL
protected URL toURL(org.osgi.framework.Bundle bundle)
This method needs to be called before bundle uninstallation, otherwiseBundle.getLocation()
throw a NPE.
-
logComponentManagerStatus
protected void logComponentManagerStatus()
Logs theComponentManager
status.
-
lastFlushed
public Long lastFlushed()
Description copied from interface:ReloadService
Returns the last time one of the flush commands where called on this service instance (ReloadService.flush()
orReloadService.flushJaasCache()
orReloadService.flushSeamComponents()
, or null if never called.- Specified by:
lastFlushed
in interfaceReloadService
-
setFlushedNow
protected void setFlushedNow()
Sets the last date date to current date timestamp- Since:
- 5.6
-
installWebResources
@Deprecated(since="5.6") public void installWebResources(File file) throws IOException
Deprecated.since 5.6, userunDeploymentPreprocessor()
instead. Keep it as compatibility code until NXP-9642 is done.Description copied from interface:ReloadService
Copies the bundle web resources into the nuxeo WAR directory.- Specified by:
installWebResources
in interfaceReloadService
- Throws:
IOException
-
runDeploymentPreprocessor
public void runDeploymentPreprocessor() throws IOException
Description copied from interface:ReloadService
Runs the deployment preprocessor.- Specified by:
runDeploymentPreprocessor
in interfaceReloadService
- Throws:
IOException
- See Also:
DeploymentPreprocessor
-
getAppDir
protected static File getAppDir()
-
getWarDir
protected static File getWarDir()
-
getOSGIBundleName
public String getOSGIBundleName(File file)
Description copied from interface:ReloadService
Returns the OSGI bundle name if given file can be identified as an OSGI bundle, or null. The OSGI bundle can be a jar or an exploded jar on file system.- Specified by:
getOSGIBundleName
in interfaceReloadService
-
triggerReloadWithNewTransaction
@Deprecated(since="9.3") protected void triggerReloadWithNewTransaction(String eventId)
Deprecated.since 9.3 should not be needed anymore
-
triggerReload
@Deprecated(since="9.3") protected void triggerReload(String eventId)
Deprecated.since 9.3 should not be needed anymore
-
-