Class DefaultRuntimeContext
- All Implemented Interfaces:
RuntimeContext
- Direct Known Subclasses:
OSGiRuntimeContext
The component registry is either reset to a clean state or shutdown.
So methods like unregister by location used in tests make no sense. These methods are preserved yet for compatibility with some tests but may be removed in future.
Also when a context is destroyed we unregister all the components the context deployed.
This is also deprecated since the unregister component is deprecated too.
The code inside destroy method was removed too since the deployedFiles map was removed.
This map posed problems with the registry snapshot approaches since it was not kept in sync with the registry.
Features like studio or IDE which needs unregistering components must use their own mechanism.
- Author:
- Bogdan Stefanescu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<ComponentName>The list of component names deployed by this context.protected final ComponentDescriptorReaderprotected RuntimeService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeploys the component whose XML descriptor is at the given location.Deploys a component XML descriptor given its URL.Same asRuntimeContext.deploy(URL)but using aStreamRefas argument.voiddestroy()Destroys this context.org.osgi.framework.BundleGets the container bundle or null if we are not running in an OSGi environment.protected Optional<RegistrationInfo>getComponentFromSourceId(String sourceId) Get the component names deployed by this contextgetLocalResource(String name) Finds a local resource having the given name.getResource(String name) Finds a resource having the given name.Gets the current runtime service.booleanisDeployed(String location) Checks if the component at the given location is deployed.booleanisDeployed(URL url) Checks whether the component XML file at given URL was deployed.booleanisDeployed(StreamRef ref) Checks whether the component XML file given by the StreamRef argument was deployed.Class<?>Loads the class given its name.voidsetRuntime(RuntimeService runtime) voidUndeploys the component at the given location if any was deployed.voidUndeploys a component XML descriptor given its URL.voidSame asRuntimeContext.undeploy(URL)but using aStreamRefas stream reference.
-
Field Details
-
runtime
-
components
The list of component names deployed by this context.- Since:
- 9.2
-
reader
-
-
Constructor Details
-
DefaultRuntimeContext
public DefaultRuntimeContext() -
DefaultRuntimeContext
-
-
Method Details
-
setRuntime
-
getRuntime
Description copied from interface:RuntimeContextGets the current runtime service.- Specified by:
getRuntimein interfaceRuntimeContext- Returns:
- the runtime service
-
getComponents
Description copied from interface:RuntimeContextGet the component names deployed by this context- Specified by:
getComponentsin interfaceRuntimeContext- Returns:
- the list of components. Return an empty array if no components where deployed.
-
getResource
Description copied from interface:RuntimeContextFinds a resource having the given name.- Specified by:
getResourcein interfaceRuntimeContext- Parameters:
name- the resource name- Returns:
- an URL to the resource having that name or null if not was found
- See Also:
-
getLocalResource
Description copied from interface:RuntimeContextFinds a local resource having the given name.Only the current bundle should be searched for the resource.
- Specified by:
getLocalResourcein interfaceRuntimeContext- Parameters:
name- the local resource name- Returns:
- an URL to the resource having that name or null if not was found
- See Also:
-
loadClass
Description copied from interface:RuntimeContextLoads the class given its name.- Specified by:
loadClassin interfaceRuntimeContext- Parameters:
className- the class name- Returns:
- the class object
- Throws:
ClassNotFoundException- if no such class were found- See Also:
-
deploy
Description copied from interface:RuntimeContextDeploys a component XML descriptor given its URL.Do nothing if component is already deployed.
Returns the registration info of the new deployed component or null if the component was not deployed.
- Specified by:
deployin interfaceRuntimeContext- Parameters:
url- the url of the XML descriptor- Returns:
- the component registration info or null if registration failed for some reason
- Throws:
IOException
-
deploy
Description copied from interface:RuntimeContextSame asRuntimeContext.deploy(URL)but using aStreamRefas argument.- Specified by:
deployin interfaceRuntimeContext- Throws:
IOException
-
undeploy
Description copied from interface:RuntimeContextUndeploys a component XML descriptor given its URL.Do nothing if no component was registered for the given URL.
- Specified by:
undeployin interfaceRuntimeContext- Parameters:
url- the URL of the XML descriptor
-
undeploy
Description copied from interface:RuntimeContextSame asRuntimeContext.undeploy(URL)but using aStreamRefas stream reference.- Specified by:
undeployin interfaceRuntimeContext
-
isDeployed
Description copied from interface:RuntimeContextChecks whether the component XML file at given URL was deployed.- Specified by:
isDeployedin interfaceRuntimeContext- Parameters:
url- the URL to check- Returns:
- true it deployed, false otherwise
-
isDeployed
Description copied from interface:RuntimeContextChecks whether the component XML file given by the StreamRef argument was deployed.- Specified by:
isDeployedin interfaceRuntimeContext
-
getComponentFromSourceId
-
deploy
Description copied from interface:RuntimeContextDeploys the component whose XML descriptor is at the given location.If the component is already deployed do nothing.
The location is interpreted as a relative path inside the bundle (jar) containing the component - and will be loaded using
RuntimeContext.getLocalResource(String).Returns the registration info of the new deployed component or null if the component was not deployed.
- Specified by:
deployin interfaceRuntimeContext- Parameters:
location- the location- Returns:
- the component registration info or null if registration failed for some reason
-
undeploy
Description copied from interface:RuntimeContextUndeploys the component at the given location if any was deployed.If the component was not deployed do nothing.
- Specified by:
undeployin interfaceRuntimeContext- Parameters:
location- the location of the component to undeploy
-
isDeployed
Description copied from interface:RuntimeContextChecks if the component at the given location is deployed.- Specified by:
isDeployedin interfaceRuntimeContext- Parameters:
location- the component location to check- Returns:
- true if deployed, false otherwise
-
destroy
public void destroy()Description copied from interface:RuntimeContextDestroys this context.- Specified by:
destroyin interfaceRuntimeContext
-
getBundle
public org.osgi.framework.Bundle getBundle()Description copied from interface:RuntimeContextGets the container bundle or null if we are not running in an OSGi environment.- Specified by:
getBundlein interfaceRuntimeContext
-
createRegistrationInfo
- Throws:
IOException
-
createRegistrationInfo
- Throws:
IOException
-