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.Bundlebundleprotected LonglastFlushedstatic StringRELOAD_STRATEGY_PARAMETERThe reload strategy to adopt for hot reload.static StringRELOAD_STRATEGY_VALUE_DEFAULTstatic StringRELOAD_STRATEGY_VALUE_RESTARTstatic StringRELOAD_STRATEGY_VALUE_STANDBYstatic StringRELOAD_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)voidactivate(ComponentContext context)Activates the component.protected voidclearJarFileFactoryCache(ReloadResult result)protected List<File>copyBundlesToDeploy(ReloadContext context)protected voidcopyFile(File srcFile, File destFile)Method copied from commons-io:commons-io:2.6 to handle replace if exist on Windows.voiddeactivate(ComponentContext context)Deactivates the component.voiddeployBundles(List<File> files, boolean reloadResources)Deprecated.since 9.3 usereloadBundles(ReloadContext)instead.voidflush()Sends a runtime event with idReloadService.FLUSH_EVENT_IDso that listeners can be notified that a flush is needed (after a reload for instance).voidflushJaasCache()Sends an event that can trigger reset of JaasCache.voidflushSeamComponents()Sends a runtime event with idReloadService.FLUSH_SEAM_EVENT_ID.protected static FilegetAppDir()static org.osgi.framework.BundlegetBundle()static org.osgi.framework.BundleContextgetBundleContext()StringgetOSGIBundleName(File file)Returns the OSGI bundle name if given file can be identified as an OSGI bundle, or null.protected static FilegetWarDir()voidinstallWebResources(File file)Deprecated.since 5.6, userunDeploymentPreprocessor()instead.LonglastFlushed()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 voidlogComponentManagerStatus()Logs theComponentManagerstatus.protected voidrefreshComponents()Deprecated.since 9.3, this method is only used in deployBundles and undeployBundles which are deprecated.voidreload()Sends a runtime event with idReloadService.RELOAD_EVENT_IDso that listeners can be notified that a reload has been done.ReloadResultreloadBundles(ReloadContext context)Called by ReloadServiceInvoker#hotReloadBundles.voidreloadProperties()Reloads runtime framework propertiesvoidreloadSeamComponents()Sends a runtime event with idReloadService.RELOAD_SEAM_EVENT_IDvoidrunDeploymentPreprocessor()Runs the deployment preprocessor.protected voidsetFlushedNow()Sets the last date date to current date timestampprotected URLtoURL(File file)protected URLtoURL(org.osgi.framework.Bundle bundle)This method needs to be called before bundle uninstallation, otherwiseBundle.getLocation()throw a NPE.protected voidtriggerReload(String eventId)Deprecated.since 9.3 should not be needed anymoreprotected voidtriggerReloadWithNewTransaction(String eventId)Deprecated.since 9.3 should not be needed anymorevoidundeployBundles(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:ComponentActivates the component.This method is called by the runtime when a component is activated.
- Specified by:
activatein interfaceComponent- Overrides:
activatein classDefaultComponent- Parameters:
context- the runtime context
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:ComponentDeactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivatein interfaceComponent- Overrides:
deactivatein 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:ReloadServiceSends a runtime event with idReloadService.RELOAD_EVENT_IDso 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:
reloadin interfaceReloadService- See Also:
ReloadService.reloadProperties()
-
reloadProperties
public void reloadProperties() throws IOExceptionDescription copied from interface:ReloadServiceReloads runtime framework properties- Specified by:
reloadPropertiesin interfaceReloadService- Throws:
IOException
-
reloadSeamComponents
public void reloadSeamComponents()
Description copied from interface:ReloadServiceSends a runtime event with idReloadService.RELOAD_SEAM_EVENT_ID- Specified by:
reloadSeamComponentsin interfaceReloadService
-
flush
public void flush()
Description copied from interface:ReloadServiceSends a runtime event with idReloadService.FLUSH_EVENT_IDso 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:
flushin interfaceReloadService- See Also:
ReloadService.flushJaasCache()
-
flushJaasCache
public void flushJaasCache()
Description copied from interface:ReloadServiceSends an event that can trigger reset of JaasCache.- Specified by:
flushJaasCachein interfaceReloadService
-
flushSeamComponents
public void flushSeamComponents()
Description copied from interface:ReloadServiceSends a runtime event with idReloadService.FLUSH_SEAM_EVENT_ID.- Specified by:
flushSeamComponentsin 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:ReloadServiceDeploys bundles to the runtime, gives possibility to control resources reloading.- Specified by:
deployBundlesin 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:ReloadServiceUndeploys bundles from the runtime, gives possibility to control resources reloading.- Specified by:
undeployBundlesin interfaceReloadService- Throws:
org.osgi.framework.BundleException
-
reloadBundles
public ReloadResult reloadBundles(ReloadContext context) throws org.osgi.framework.BundleException
Description copied from interface:ReloadServiceCalled by ReloadServiceInvoker#hotReloadBundles.- Specified by:
reloadBundlesin 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 theComponentManagerstatus.
-
lastFlushed
public Long lastFlushed()
Description copied from interface:ReloadServiceReturns 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:
lastFlushedin 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:ReloadServiceCopies the bundle web resources into the nuxeo WAR directory.- Specified by:
installWebResourcesin interfaceReloadService- Throws:
IOException
-
runDeploymentPreprocessor
public void runDeploymentPreprocessor() throws IOExceptionDescription copied from interface:ReloadServiceRuns the deployment preprocessor.- Specified by:
runDeploymentPreprocessorin 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:ReloadServiceReturns 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:
getOSGIBundleNamein 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
-
-