Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.webengine.model.impl
Class ModuleImpl

java.lang.Object
  extended by org.nuxeo.ecm.webengine.model.impl.ModuleImpl
All Implemented Interfaces:
MessagesProvider, Module

public class ModuleImpl
extends Object
implements Module

The default implementation for a web configuration.

Author:
Bogdan Stefanescu

Constructor Summary
ModuleImpl(WebEngine engine, ModuleImpl superModule, ModuleConfiguration config)
           
 
Method Summary
 TypeRegistry createTypeRegistry()
          TODO There are no more reasons to lazy load the type registry since module are lazy loaded.
 void flushCache()
           
 void flushRootResourcesCache()
          Deprecated. resources are deprecated - you should use a jax-rs application to declare more resources.
 void flushSkinCache()
           
 void flushTypeCache()
           
 List<LinkDescriptor> getActiveLinks(Resource context, String category)
           
 AdapterType getAdapter(Resource ctx, String name)
          Gets the named adapter definition for the given resource.
 List<String> getAdapterNames(Resource ctx)
          Gets the list of adapter names that applies to the given resource.
 AdapterType[] getAdapters()
          Gets the adapters registered within this module.
 List<AdapterType> getAdapters(Resource ctx)
          Gets the list of adapters that applies to the given resource.
 List<String> getEnabledAdapterNames(Resource ctx)
          Gets the list of adapter names that are enabled for the given context.
 List<AdapterType> getEnabledAdapters(Resource ctx)
          Gets the list of adapters that are enabled for the given context.
 WebEngine getEngine()
           
 ScriptFile getFile(String path)
          Gets a file using the configured directory stack.
 LinkRegistry getLinkRegistry()
           
 List<LinkDescriptor> getLinks(String category)
           
 String getMediaTypeId(MediaType mt)
           
 Messages getMessages()
           
 Map<String,String> getMessages(String language)
           
 ModuleConfiguration getModuleConfiguration()
           
 String getName()
           
 Set<String> getNatures()
           
 List<ResourceBinding> getResourceBindings()
           
 File getRoot()
           
 Resource getRootObject(WebContext ctx)
          Deprecated. Use WebApplication to declare modules
 ResourceType getRootType()
          Deprecated. Use WebApplication to declare modules
static File getSkinDir(File moduleDir)
           
 String getSkinPathPrefix()
          Get the path prefix to be used from templates to prepend to links to static resources.
 ScriptFile getSkinResource(String path)
          Gets a skin resource input stream.
 ModuleImpl getSuperModule()
           
 String getTemplateFileExt()
           
 ModuleTracker getTracker()
           
 ResourceType getType(String typeName)
          Gets a ResourceType instance given its name.
 TypeRegistry getTypeRegistry()
           
 ResourceType[] getTypes()
          Gets the types registered within this module.
 Validator getValidator(String docType)
           
 boolean hasNature(String natureId)
           
 boolean isDerivedFrom(String moduleName)
           
 boolean isHeadless()
          Whether or not this module has a GUI and should be listed in available GUI module list.
 Class<?> loadClass(String className)
          Loads a class given its name.
 void loadConfiguration()
           
 void reloadMessages()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModuleImpl

public ModuleImpl(WebEngine engine,
                  ModuleImpl superModule,
                  ModuleConfiguration config)
Method Detail

getTracker

public ModuleTracker getTracker()

isHeadless

public boolean isHeadless()
Whether or not this module has a GUI and should be listed in available GUI module list. For example, REST modules usually don't have a GUI.

Returns:
true if headless (no GUI is provided), false otherwise

getNatures

public Set<String> getNatures()
Returns:
the natures, or null if no natures were specified

hasNature

public boolean hasNature(String natureId)

getEngine

public WebEngine getEngine()
Specified by:
getEngine in interface Module

getName

public String getName()
Specified by:
getName in interface Module

getSuperModule

public ModuleImpl getSuperModule()
Specified by:
getSuperModule in interface Module

getModuleConfiguration

public ModuleConfiguration getModuleConfiguration()

getRootType

@Deprecated
public ResourceType getRootType()
Deprecated. Use WebApplication to declare modules

Returns:

getRootObject

@Deprecated
public Resource getRootObject(WebContext ctx)
Deprecated. Use WebApplication to declare modules

Specified by:
getRootObject in interface Module
Returns:

getSkinPathPrefix

public String getSkinPathPrefix()
Description copied from interface: Module
Get the path prefix to be used from templates to prepend to links to static resources.

This prefix is exposed to templates as ${skinPath}.

Specified by:
getSkinPathPrefix in interface Module
Returns:
the skin path prefix. never null.

getTypeRegistry

public TypeRegistry getTypeRegistry()

loadClass

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

The scripting class loader will be used to load the class.

Specified by:
loadClass in interface Module
Parameters:
className - the class name
Returns:
the class instance
Throws:
ClassNotFoundException

getType

public ResourceType getType(String typeName)
Description copied from interface: Module
Gets a ResourceType instance given its name.

The web type lookup is performed in the following order:

  1. First the annotated Groovy classes are checked. (web/ directory)
  2. Then the configuration type registry corresponding

Specified by:
getType in interface Module
Parameters:
typeName - the type name
Returns:
the web type instance

getTypes

public ResourceType[] getTypes()
Description copied from interface: Module
Gets the types registered within this module.

Specified by:
getTypes in interface Module
Returns:
the types. Cannot be null.

getAdapters

public AdapterType[] getAdapters()
Description copied from interface: Module
Gets the adapters registered within this module.

Specified by:
getAdapters in interface Module
Returns:
the adapters. Cannot be null.

getAdapter

public AdapterType getAdapter(Resource ctx,
                              String name)
Description copied from interface: Module
Gets the named adapter definition for the given resource.

Specified by:
getAdapter in interface Module
Parameters:
ctx - the target resource
name - the adapter name
Returns:
the adapter if any adapter with that name applies for that resource otherwise throws an exception

getAdapterNames

public List<String> getAdapterNames(Resource ctx)
Description copied from interface: Module
Gets the list of adapter names that applies to the given resource.

Specified by:
getAdapterNames in interface Module
Parameters:
ctx - the context resource
Returns:
the list of adapters Cannot be null.

getAdapters

public List<AdapterType> getAdapters(Resource ctx)
Description copied from interface: Module
Gets the list of adapters that applies to the given resource.

Specified by:
getAdapters in interface Module
Parameters:
ctx - the context resource
Returns:
the list of adapters Cannot be null.

getEnabledAdapterNames

public List<String> getEnabledAdapterNames(Resource ctx)
Description copied from interface: Module
Gets the list of adapter names that are enabled for the given context.

Enabled services are those adapters which can be accessed in the current security context.

Specified by:
getEnabledAdapterNames in interface Module
Parameters:
ctx - the context resource
Returns:
the list of adapters. Cannot be null.

getEnabledAdapters

public List<AdapterType> getEnabledAdapters(Resource ctx)
Description copied from interface: Module
Gets the list of adapters that are enabled for the given context.

Enabled adapters are those adapters which can be accessed in the current security context.

Specified by:
getEnabledAdapters in interface Module
Parameters:
ctx - the context resource
Returns:
the list of adapter.s Cannot be null.

getMediaTypeId

public String getMediaTypeId(MediaType mt)
Specified by:
getMediaTypeId in interface Module

getResourceBindings

public List<ResourceBinding> getResourceBindings()
Specified by:
getResourceBindings in interface Module

isDerivedFrom

public boolean isDerivedFrom(String moduleName)
Specified by:
isDerivedFrom in interface Module

getValidator

public Validator getValidator(String docType)
Specified by:
getValidator in interface Module

loadConfiguration

public void loadConfiguration()

getLinks

public List<LinkDescriptor> getLinks(String category)
Specified by:
getLinks in interface Module

getActiveLinks

public List<LinkDescriptor> getActiveLinks(Resource context,
                                           String category)
Specified by:
getActiveLinks in interface Module

getLinkRegistry

public LinkRegistry getLinkRegistry()

getTemplateFileExt

public String getTemplateFileExt()
Specified by:
getTemplateFileExt in interface Module

flushSkinCache

public void flushSkinCache()

flushTypeCache

public void flushTypeCache()

flushRootResourcesCache

public void flushRootResourcesCache()
Deprecated. resources are deprecated - you should use a jax-rs application to declare more resources.


flushCache

public void flushCache()
Specified by:
flushCache in interface Module

getSkinDir

public static File getSkinDir(File moduleDir)

getFile

public ScriptFile getFile(String path)
Description copied from interface: Module
Gets a file using the configured directory stack. Each directory in the stack is asked for the file until a file is found. If no file is found, returns null.

Note that the implementation may cache the results. To clear any cached data, you should call the Module.flushCache() method.

Specified by:
getFile in interface Module
Parameters:
path - the file path
Returns:
null if no file found otherwise the file

getSkinResource

public ScriptFile getSkinResource(String path)
                           throws IOException
Description copied from interface: Module
Gets a skin resource input stream. This must not cache resources. This method is using the module stacking directory to find the resource.

Specified by:
getSkinResource in interface Module
Throws:
IOException

createTypeRegistry

public TypeRegistry createTypeRegistry()
TODO There are no more reasons to lazy load the type registry since module are lazy loaded. Type registry must be loaded at module creation


getRoot

public File getRoot()
Specified by:
getRoot in interface Module

reloadMessages

public void reloadMessages()

getMessages

public Messages getMessages()
Specified by:
getMessages in interface Module

getMessages

public Map<String,String> getMessages(String language)
Specified by:
getMessages in interface MessagesProvider
Specified by:
getMessages in interface Module

toString

public String toString()
Overrides:
toString in class Object

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.