Interface RuntimeContext
- All Known Implementing Classes:
DefaultRuntimeContext
,OSGiRuntimeContext
Runtime contexts are used to create components. They provides custom methods to load classes and find resources.
Runtime contexts are generally attached to a bundle context (or module deployment context) Note that all undeploy
methods are deprectaed! see DefaultRuntimeContext
for more information
- Author:
- Bogdan Stefanescu
-
Method Summary
Modifier and TypeMethodDescriptionDeploys the component whose XML descriptor is at the given location.Deploys a component XML descriptor given its URL.Same asdeploy(URL)
but using aStreamRef
as argument.void
destroy()
Destroys this context.org.osgi.framework.Bundle
Gets the container bundle or null if we are not running in an OSGi environment.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.boolean
isDeployed
(String location) Checks if the component at the given location is deployed.boolean
isDeployed
(URL url) Checks whether the component XML file at given URL was deployed.boolean
isDeployed
(StreamRef ref) Checks whether the component XML file given by the StreamRef argument was deployed.Class<?>
Loads the class given its name.void
Undeploys the component at the given location if any was deployed.void
Undeploys a component XML descriptor given its URL.void
Same asundeploy(URL)
but using aStreamRef
as stream reference.
-
Method Details
-
getRuntime
RuntimeService getRuntime()Gets the current runtime service.- Returns:
- the runtime service
-
getBundle
org.osgi.framework.Bundle getBundle()Gets the container bundle or null if we are not running in an OSGi environment. -
getComponents
ComponentName[] getComponents()Get the component names deployed by this context- Returns:
- the list of components. Return an empty array if no components where deployed.
- Since:
- 9.2
-
loadClass
Loads the class given its name.- Parameters:
className
- the class name- Returns:
- the class object
- Throws:
ClassNotFoundException
- if no such class were found- See Also:
-
getResource
Finds a resource having the given name.- Parameters:
name
- the resource name- Returns:
- an URL to the resource having that name or null if not was found
- See Also:
-
getLocalResource
Finds a local resource having the given name.Only the current bundle should be searched for the resource.
- Parameters:
name
- the local resource name- Returns:
- an URL to the resource having that name or null if not was found
- See Also:
-
deploy
Deploys 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.
- Parameters:
url
- the url of the XML descriptor- Returns:
- the component registration info or null if registration failed for some reason
- Throws:
IOException
-
deploy
Same asdeploy(URL)
but using aStreamRef
as argument.- Throws:
IOException
-
undeploy
Undeploys a component XML descriptor given its URL.Do nothing if no component was registered for the given URL.
- Parameters:
url
- the URL of the XML descriptor- Throws:
IOException
-
undeploy
Same asundeploy(URL)
but using aStreamRef
as stream reference.- Throws:
IOException
-
isDeployed
Checks whether the component XML file at given URL was deployed.- Parameters:
url
- the URL to check- Returns:
- true it deployed, false otherwise
-
isDeployed
Checks whether the component XML file given by the StreamRef argument was deployed. -
deploy
Deploys 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
getLocalResource(String)
.Returns the registration info of the new deployed component or null if the component was not deployed.
- Parameters:
location
- the location- Returns:
- the component registration info or null if registration failed for some reason
-
undeploy
Undeploys the component at the given location if any was deployed.If the component was not deployed do nothing.
- Parameters:
location
- the location of the component to undeploy
-
isDeployed
Checks if the component at the given location is deployed.- Parameters:
location
- the component location to check- Returns:
- true if deployed, false otherwise
-
destroy
void destroy()Destroys this context.
-