Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.runtime.model.impl
Class DefaultRuntimeContext

java.lang.Object
  extended by org.nuxeo.runtime.model.impl.DefaultRuntimeContext
All Implemented Interfaces:
RuntimeContext
Direct Known Subclasses:
OSGiRuntimeContext

public class DefaultRuntimeContext
extends Object
implements RuntimeContext

Author:
Bogdan Stefanescu

Constructor Summary
DefaultRuntimeContext()
           
DefaultRuntimeContext(RuntimeService runtime)
           
 
Method Summary
 RegistrationInfoImpl createRegistrationInfo(InputStream in)
           
 RegistrationInfoImpl createRegistrationInfo(StreamRef ref)
           
 RegistrationInfo deploy(StreamRef ref)
          Same as RuntimeContext.deploy(URL) but using a StreamRef as argument.
 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.
 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.
 Map<String,ComponentName> getDeployedFiles()
           
 URL 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(StreamRef ref)
          Checks whether the component XML file given by the StreamRef argument was deployed.
 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.
 Class<?> loadClass(String className)
          Loads the class given its name.
 void setRuntime(RuntimeService runtime)
           
 void undeploy(StreamRef ref)
          Same as RuntimeContext.undeploy(URL) but using a StreamRef as stream reference.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRuntimeContext

public DefaultRuntimeContext()

DefaultRuntimeContext

public DefaultRuntimeContext(RuntimeService runtime)
Method Detail

setRuntime

public void setRuntime(RuntimeService runtime)

getRuntime

public RuntimeService getRuntime()
Description copied from interface: RuntimeContext
Gets the current runtime service.

Specified by:
getRuntime in interface RuntimeContext
Returns:
the runtime service

getDeployedFiles

public Map<String,ComponentName> getDeployedFiles()

getResource

public URL getResource(String name)
Description copied from interface: RuntimeContext
Finds a resource having the given name.

Specified by:
getResource in interface RuntimeContext
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

public URL getLocalResource(String name)
Description copied from interface: RuntimeContext
Finds a local resource having the given name.

Only the current bundle should be searched for the resource.

Specified by:
getLocalResource in interface RuntimeContext
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)

loadClass

public Class<?> loadClass(String className)
                   throws ClassNotFoundException
Description copied from interface: RuntimeContext
Loads the class given its name.

Specified by:
loadClass in interface RuntimeContext
Parameters:
className - the class name
Returns:
the class object
Throws:
ClassNotFoundException - if no such class were found
See Also:
ClassLoader.loadClass(String)

deploy

public RegistrationInfo deploy(URL url)
                        throws Exception
Description copied from interface: RuntimeContext
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.

Specified by:
deploy in interface RuntimeContext
Parameters:
url - the url of the XML descriptor
Returns:
the component registration info or null if registration failed for some reason
Throws:
Exception - if any error occurs

deploy

public RegistrationInfo deploy(StreamRef ref)
                        throws Exception
Description copied from interface: RuntimeContext
Same as RuntimeContext.deploy(URL) but using a StreamRef as argument.

Specified by:
deploy in interface RuntimeContext
Returns:
Throws:
Exception

undeploy

public void undeploy(URL url)
              throws Exception
Description copied from interface: RuntimeContext
Undeploys a component XML descriptor given its URL.

Do nothing if no component was registered for the given URL.

Specified by:
undeploy in interface RuntimeContext
Parameters:
url - the URL of the XML descriptor
Throws:
Exception - if any error occurs

undeploy

public void undeploy(StreamRef ref)
              throws Exception
Description copied from interface: RuntimeContext
Same as RuntimeContext.undeploy(URL) but using a StreamRef as stream reference.

Specified by:
undeploy in interface RuntimeContext
Throws:
Exception

isDeployed

public boolean isDeployed(URL url)
Description copied from interface: RuntimeContext
Checks whether the component XML file at given URL was deployed.

Specified by:
isDeployed in interface RuntimeContext
Parameters:
url - the URL to check
Returns:
true it deployed, false otherwise

isDeployed

public boolean isDeployed(StreamRef ref)
Description copied from interface: RuntimeContext
Checks whether the component XML file given by the StreamRef argument was deployed.

Specified by:
isDeployed in interface RuntimeContext
Returns:

deploy

public RegistrationInfo deploy(String location)
                        throws Exception
Description copied from interface: RuntimeContext
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 RuntimeContext.getLocalResource(String).

Returns the registration info of the new deployed component or null if the component was not deployed.

Specified by:
deploy in interface RuntimeContext
Parameters:
location - the location
Returns:
the component registration info or null if registration failed for some reason
Throws:
Exception

undeploy

public void undeploy(String location)
              throws Exception
Description copied from interface: RuntimeContext
Undeploys the component at the given location if any was deployed.

If the component was not deployed do nothing.

Specified by:
undeploy in interface RuntimeContext
Parameters:
location - the location of the component to undeploy
Throws:
Exception - if any error occurs

isDeployed

public boolean isDeployed(String location)
Description copied from interface: RuntimeContext
Checks if the component at the given location is deployed.

Specified by:
isDeployed in interface RuntimeContext
Parameters:
location - the component location to check
Returns:
true if deployed, false otherwise

destroy

public void destroy()
Description copied from interface: RuntimeContext
Destroys this context.

Specified by:
destroy in interface RuntimeContext

getBundle

public org.osgi.framework.Bundle getBundle()
Description copied from interface: RuntimeContext
Gets the container bundle or null if we are not running in an OSGi environment.

Specified by:
getBundle in interface RuntimeContext

createRegistrationInfo

public RegistrationInfoImpl createRegistrationInfo(StreamRef ref)
                                            throws Exception
Throws:
Exception

createRegistrationInfo

public RegistrationInfoImpl createRegistrationInfo(InputStream in)
                                            throws Exception
Throws:
Exception

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.