Class ProxyModule

java.lang.Object
com.sun.enterprise.module.single.ProxyModule
All Implemented Interfaces:
Module

public class ProxyModule extends Object implements Module
Creates a Module implementation based on a single class loader
  • Field Details

  • Constructor Details

  • Method Details

    • getModuleDefinition

      public ModuleDefinition getModuleDefinition()
      Description copied from interface: Module
      Returns the module definition for this module instance
      Specified by:
      getModuleDefinition in interface Module
      Returns:
      the module definition
    • getName

      public String getName()
      Description copied from interface: Module
      Short-cut for getModuleDefinition().getName().
      Specified by:
      getName in interface Module
    • getRegistry

      public ModulesRegistry getRegistry()
      Description copied from interface: Module
      Returns the registry owning this module
      Specified by:
      getRegistry in interface Module
      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
      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
      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
      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
      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
    • 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
    • getMetadata

      public ModuleMetadata getMetadata()
      Description copied from interface: Module
      Gets the metadata of this module.
      Specified by:
      getMetadata in interface Module
    • addListener

      public void addListener(ModuleChangeListener listener)
      Description copied from interface: Module
      Add a new module change listener
      Specified by:
      addListener in interface Module
      Parameters:
      listener - the listener
    • removeListener

      public void removeListener(ModuleChangeListener listener)
      Description copied from interface: Module
      Unregister a module change listener
      Specified by:
      removeListener in interface Module
      Parameters:
      listener - the listener to unregister
    • 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
      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
      Returns:
      Can be empty but never null. Read-only.
    • addImport

      public void addImport(Module module)
      Specified by:
      addImport in interface Module
    • addImport

      public Module addImport(ModuleDependency dependency)
      Description copied from interface: Module
      Create and add a new module to this module's list of imports.
      Specified by:
      addImport in interface Module
      Parameters:
      dependency - new module's definition
    • isShared

      public boolean isShared()
      Description copied from interface: Module
      Returns true if this module is sharable. A sharable module means that onlu one instance of the module classloader will be used by all users.
      Specified by:
      isShared in interface Module
      Returns:
      true if this module is sharable.
    • isSticky

      public boolean isSticky()
      Description copied from interface: Module
      Returns true if the module is sticky. A sticky module cannot be stopped or unloaded. Once a sticky module is loaded or started, it will stay in the JVM until it exists.
      Specified by:
      isSticky in interface Module
      Returns:
      true is the module is sticky
    • setSticky

      public void setSticky(boolean sticky)
      Description copied from interface: Module
      Sets the sticky flag.
      Specified by:
      setSticky in interface Module
      Parameters:
      sticky - true if the module should stick around
    • getProvidersClass

      public <T> Iterable<Class<? extends T>> getProvidersClass(Class<T> serviceClass)
      Specified by:
      getProvidersClass in interface Module
    • getProvidersClass

      public Iterable<Class> getProvidersClass(String name)
      Specified by:
      getProvidersClass in interface Module
    • hasProvider

      public boolean hasProvider(Class serviceClass)
      Description copied from interface: Module
      Returns true if this module has any provider for the given service class.
      Specified by:
      hasProvider in interface Module
    • dumpState

      public void dumpState(PrintStream writer)
      Specified by:
      dumpState in interface Module
    • 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