org.jvnet.hk2.osgiadapter
Class OSGiObrModuleImpl

java.lang.Object
  extended by org.jvnet.hk2.osgiadapter.OSGiModuleImpl
      extended by org.jvnet.hk2.osgiadapter.OSGiObrModuleImpl
All Implemented Interfaces:
Module

public class OSGiObrModuleImpl
extends OSGiModuleImpl

Author:
Sanjeeb.Sahoo@Sun.COM

Constructor Summary
OSGiObrModuleImpl(OSGiObrModulesRegistryImpl registry, org.osgi.framework.Bundle bundle, ModuleDefinition moduleDef)
           
OSGiObrModuleImpl(OSGiObrModulesRegistryImpl registry, File file)
           
OSGiObrModuleImpl(OSGiObrModulesRegistryImpl registry, ModuleDefinition moduleDef)
           
 
Method Summary
 void detach()
          Detach this module from its registry.
 void dumpState(PrintStream writer)
           
 ClassLoader getClassLoader()
          Return the ClassLoader instance associated with this module.
 List<Module> getImports()
          Returns the list of imported modules.
 OSGiObrModulesRegistryImpl getRegistry()
          Returns the registry owning this module
 ModuleState getState()
          Returns the module's state
 void refresh()
          Trigger manual refresh mechanism, the module will check all its URLs and generate change events if any of them has changed.
 void resolve()
          Ensure that this module is resolved.
 void start()
          Forces module startup.
 boolean stop()
          Forces module stop.
 String toString()
           
 void uninstall()
          Removes the module from the registry backing store, the module will need be reinstalled to be loaded.
 
Methods inherited from class org.jvnet.hk2.osgiadapter.OSGiModuleImpl
addImport, addImport, addListener, equals, getBundle, getMetadata, getModuleDefinition, getName, getProvidersClass, getProvidersClass, hashCode, hasProvider, isShared, isSticky, isTransientlyActive, removeListener, setBundle, setSticky
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OSGiObrModuleImpl

public OSGiObrModuleImpl(OSGiObrModulesRegistryImpl registry,
                         File file)
                  throws IOException
Throws:
IOException

OSGiObrModuleImpl

public OSGiObrModuleImpl(OSGiObrModulesRegistryImpl registry,
                         ModuleDefinition moduleDef)

OSGiObrModuleImpl

public OSGiObrModuleImpl(OSGiObrModulesRegistryImpl registry,
                         org.osgi.framework.Bundle bundle,
                         ModuleDefinition moduleDef)
Method Detail

getRegistry

public OSGiObrModulesRegistryImpl getRegistry()
Description copied from interface: Module
Returns the registry owning this module

Specified by:
getRegistry in interface Module
Overrides:
getRegistry in class OSGiModuleImpl
Returns:
the registry owning the module

getState

public ModuleState getState()
Description copied from interface: Module
Returns the module's state

Specified by:
getState in interface Module
Overrides:
getState in class OSGiModuleImpl
Returns:
the module's state

resolve

public void resolve()
             throws ResolveError
Description copied from interface: Module
Ensure that this module is resolved.

If the module is already resolved, this method does nothing. Otherwise, iterate over all declared ModuleDependency instances and use the associated ModuleRegistry to resolve it. After successful completion of this method, the module state is ModuleState.RESOLVED.

Specified by:
resolve in interface Module
Overrides:
resolve in class OSGiModuleImpl
Throws:
ResolveError - if any of the declared dependency of this module cannot be satisfied

start

public void start()
           throws ResolveError
Description copied from interface: Module
Forces module startup. In most cases, the runtime will take care of starting modules when they are first used. There could be cases where code need to manually start a sub module. Invoking this method will move the module to the ModuleState.READY, the Lifecycle.start method will be invoked.

Specified by:
start in interface Module
Overrides:
start in class OSGiModuleImpl
Throws:
ResolveError

stop

public boolean stop()
Description copied from interface: Module
Forces module stop. In most cases, the runtime will take care of stopping modules when the last module user released its interest. However, in certain cases, it may be interesting to manually stop the module. Stopping the module means that the module is removed from the registry, the class loader references are released (note : the class loaders will only be released if all instances of any class loaded by them are gc'ed). If a LifecyclePolicy for this module is defined, the Lifecycle.stop(Module) method will be called and finally the module state will be returned to ModuleState.NEW.

Specified by:
stop in interface Module
Overrides:
stop in class OSGiModuleImpl
Returns:
true if unloading was successful

detach

public void detach()
Description copied from interface: Module
Detach this module from its registry. This does not free any of the loaded resources. Only proper release of all references to the public class loader will ensure module being garbage collected. Detached modules are orphan and will be garbage collected if resources are properly disposed.

Specified by:
detach in interface Module
Overrides:
detach in class OSGiModuleImpl

uninstall

public void uninstall()
Description copied from interface: Module
Removes the module from the registry backing store, the module will need be reinstalled to be loaded.

Specified by:
uninstall in interface Module
Overrides:
uninstall in class OSGiModuleImpl

refresh

public void refresh()
Description copied from interface: Module
Trigger manual refresh mechanism, the module will check all its URLs and generate change events if any of them has changed. This will allow the owning registry to force a module upgrade at next module request.

Specified by:
refresh in interface Module
Overrides:
refresh in class OSGiModuleImpl

dumpState

public void dumpState(PrintStream writer)
Specified by:
dumpState in interface Module
Overrides:
dumpState in class OSGiModuleImpl

getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: Module
Return the ClassLoader instance associated with this module. Only designated public interfaces will be loaded and returned by this classloader

Specified by:
getClassLoader in interface Module
Overrides:
getClassLoader in class OSGiModuleImpl
Returns:
the public ClassLoader

getImports

public List<Module> getImports()
Description copied from interface: Module
Returns the list of imported modules.

This is the module version of ModuleDefinition.getDependencies(), but after fully resolved.

To enforce the stable class visibility, once Module is created, dependencies cannot be changed — that is, we don't want "a.b.C" to suddenly mean something different once the code starts running.

Specified by:
getImports in interface Module
Overrides:
getImports in class OSGiModuleImpl
Returns:
Can be empty but never null. Read-only.

toString

public String toString()
Overrides:
toString in class OSGiModuleImpl


Copyright © 2013 Oracle Corporation. All Rights Reserved.