Interface RuntimeContext
-
- All Known Implementing Classes:
DefaultRuntimeContext
,OSGiRuntimeContext
public interface RuntimeContext
The runtime context.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RegistrationInfo
deploy(String location)
Deploys the component whose XML descriptor is at the given location.RegistrationInfo
deploy(URL url)
Deploys a component XML descriptor given its URL.RegistrationInfo
deploy(StreamRef ref)
Same asdeploy(URL)
but using aStreamRef
as argument.void
destroy()
Destroys this context.org.osgi.framework.Bundle
getBundle()
Gets the container bundle or null if we are not running in an OSGi environment.ComponentName[]
getComponents()
Get the component names deployed by this contextURL
getLocalResource(String name)
Finds a local resource having the given name.URL
getResource(String name)
Finds a resource having the given name.RuntimeService
getRuntime()
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<?>
loadClass(String className)
Loads the class given its name.void
undeploy(String location)
Undeploys the component at the given location if any was deployed.void
undeploy(URL url)
Undeploys a component XML descriptor given its URL.void
undeploy(StreamRef ref)
Same asundeploy(URL)
but using aStreamRef
as stream reference.
-
-
-
Method Detail
-
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
Class<?> loadClass(String className) throws ClassNotFoundException
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:
ClassLoader.loadClass(String)
-
getResource
URL getResource(String name)
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:
ClassLoader.getResource(String)
-
getLocalResource
URL getLocalResource(String name)
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:
ClassLoader.getResource(String)
-
deploy
RegistrationInfo deploy(URL url) throws IOException
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
RegistrationInfo deploy(StreamRef ref) throws IOException
Same asdeploy(URL)
but using aStreamRef
as argument.- Throws:
IOException
-
undeploy
void undeploy(URL url) throws IOException
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
void undeploy(StreamRef ref) throws IOException
Same asundeploy(URL)
but using aStreamRef
as stream reference.- Throws:
IOException
-
isDeployed
boolean isDeployed(URL url)
Checks whether the component XML file at given URL was deployed.- Parameters:
url
- the URL to check- Returns:
- true it deployed, false otherwise
-
isDeployed
boolean isDeployed(StreamRef ref)
Checks whether the component XML file given by the StreamRef argument was deployed.
-
deploy
RegistrationInfo deploy(String location)
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
void undeploy(String location)
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
boolean isDeployed(String location)
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.
-
-