Class ModuleImpl
- java.lang.Object
-
- 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
-
-
Field Summary
Fields Modifier and Type Field Description protected ModuleConfigurationconfigurationprotected DirectoryStackdirStackprotected WebEngineengineprotected ConcurrentMap<String,ScriptFile>fileCacheprotected LinkRegistrylinkRegprotected Messagesmessagesprotected ResourceTyperootTypeDeprecated.UseWebApplicationto declare modules - modules may have multiple rootsprotected com.sun.jersey.server.impl.inject.ServerInjectableProviderContextsicprotected StringskinPathPrefixprotected ModuleImplsuperModuleprotected ObjecttypeLockprotected TypeRegistrytypeReg
-
Constructor Summary
Constructors Constructor Description ModuleImpl(WebEngine engine, ModuleImpl superModule, ModuleConfiguration config, com.sun.jersey.server.impl.inject.ServerInjectableProviderContext sic)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TypeRegistrycreateTypeRegistry()TODO There are no more reasons to lazy load the type registry since module are lazy loaded.protected ScriptFilefindFile(String path)voidflushCache()voidflushRootResourcesCache()Deprecated.resources are deprecated - you should use a jax-rs application to declare more resources.voidflushSkinCache()voidflushTypeCache()List<LinkDescriptor>getActiveLinks(Resource context, String category)AdapterTypegetAdapter(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.WebEnginegetEngine()ScriptFilegetFile(String path)Gets a file using the configured directory stack.LinkRegistrygetLinkRegistry()List<LinkDescriptor>getLinks(String category)StringgetMediaTypeId(javax.ws.rs.core.MediaType mt)MessagesgetMessages()Map<String,String>getMessages(String language)ModuleConfigurationgetModuleConfiguration()StringgetName()Set<String>getNatures()List<ResourceBinding>getResourceBindings()FilegetRoot()ResourcegetRootObject(WebContext ctx)Deprecated.UseWebApplicationto declare modulesResourceTypegetRootType()Deprecated.UseWebApplicationto declare modulesstatic FilegetSkinDir(File moduleDir)StringgetSkinPathPrefix()Get the path prefix to be used from templates to prepend to links to static resources.ScriptFilegetSkinResource(String path)Gets a skin resource input stream.ModuleImplgetSuperModule()StringgetTemplateFileExt()ResourceTypegetType(String typeName)Gets aResourceTypeinstance given its name.TypeRegistrygetTypeRegistry()ResourceType[]getTypes()Gets the types registered within this module.booleanhasNature(String natureId)booleanisDerivedFrom(String moduleName)booleanisHeadless()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.voidloadConfiguration()protected voidloadDirectoryStack()voidreloadMessages()StringtoString()
-
-
-
Field Detail
-
typeReg
protected volatile TypeRegistry typeReg
-
configuration
protected final ModuleConfiguration configuration
-
sic
protected final com.sun.jersey.server.impl.inject.ServerInjectableProviderContext sic
-
superModule
protected final ModuleImpl superModule
-
linkReg
protected LinkRegistry linkReg
-
skinPathPrefix
protected final String skinPathPrefix
-
rootType
@Deprecated protected ResourceType rootType
Deprecated.UseWebApplicationto declare modules - modules may have multiple roots
-
dirStack
protected DirectoryStack dirStack
-
fileCache
protected ConcurrentMap<String,ScriptFile> fileCache
-
-
Constructor Detail
-
ModuleImpl
public ModuleImpl(WebEngine engine, ModuleImpl superModule, ModuleConfiguration config, com.sun.jersey.server.impl.inject.ServerInjectableProviderContext sic)
-
-
Method Detail
-
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
-
getSuperModule
public ModuleImpl getSuperModule()
- Specified by:
getSuperModulein interfaceModule
-
getModuleConfiguration
public ModuleConfiguration getModuleConfiguration()
-
getRootType
@Deprecated public ResourceType getRootType()
Deprecated.UseWebApplicationto declare modules
-
getRootObject
@Deprecated public Resource getRootObject(WebContext ctx)
Deprecated.UseWebApplicationto declare modules- Specified by:
getRootObjectin interfaceModule
-
getSkinPathPrefix
public String getSkinPathPrefix()
Description copied from interface:ModuleGet 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:
getSkinPathPrefixin interfaceModule- Returns:
- the skin path prefix. never null.
-
getTypeRegistry
public TypeRegistry getTypeRegistry()
-
loadClass
public Class<?> loadClass(String className) throws ClassNotFoundException
Description copied from interface:ModuleLoads a class given its name.The scripting class loader will be used to load the class.
- Specified by:
loadClassin interfaceModule- Parameters:
className- the class name- Returns:
- the class instance
- Throws:
ClassNotFoundException
-
getType
public ResourceType getType(String typeName)
Description copied from interface:ModuleGets aResourceTypeinstance given its name.The web type lookup is performed in the following order:
- First the annotated Groovy classes are checked. (web/ directory)
- Then the configuration type registry corresponding
-
getTypes
public ResourceType[] getTypes()
Description copied from interface:ModuleGets the types registered within this module.
-
getAdapters
public AdapterType[] getAdapters()
Description copied from interface:ModuleGets the adapters registered within this module.- Specified by:
getAdaptersin interfaceModule- Returns:
- the adapters. Cannot be null.
-
getAdapter
public AdapterType getAdapter(Resource ctx, String name)
Description copied from interface:ModuleGets the named adapter definition for the given resource.- Specified by:
getAdapterin interfaceModule- Parameters:
ctx- the target resourcename- 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:ModuleGets the list of adapter names that applies to the given resource.- Specified by:
getAdapterNamesin interfaceModule- Parameters:
ctx- the context resource- Returns:
- the list of adapters Cannot be null.
-
getAdapters
public List<AdapterType> getAdapters(Resource ctx)
Description copied from interface:ModuleGets the list of adapters that applies to the given resource.- Specified by:
getAdaptersin interfaceModule- Parameters:
ctx- the context resource- Returns:
- the list of adapters Cannot be null.
-
getEnabledAdapterNames
public List<String> getEnabledAdapterNames(Resource ctx)
Description copied from interface:ModuleGets 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:
getEnabledAdapterNamesin interfaceModule- Parameters:
ctx- the context resource- Returns:
- the list of adapters. Cannot be null.
-
getEnabledAdapters
public List<AdapterType> getEnabledAdapters(Resource ctx)
Description copied from interface:ModuleGets 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:
getEnabledAdaptersin interfaceModule- Parameters:
ctx- the context resource- Returns:
- the list of adapter.s Cannot be null.
-
getMediaTypeId
public String getMediaTypeId(javax.ws.rs.core.MediaType mt)
- Specified by:
getMediaTypeIdin interfaceModule
-
getResourceBindings
public List<ResourceBinding> getResourceBindings()
- Specified by:
getResourceBindingsin interfaceModule
-
isDerivedFrom
public boolean isDerivedFrom(String moduleName)
- Specified by:
isDerivedFromin interfaceModule
-
loadConfiguration
public void loadConfiguration()
-
getLinks
public List<LinkDescriptor> getLinks(String category)
-
getActiveLinks
public List<LinkDescriptor> getActiveLinks(Resource context, String category)
- Specified by:
getActiveLinksin interfaceModule
-
getLinkRegistry
public LinkRegistry getLinkRegistry()
-
getTemplateFileExt
public String getTemplateFileExt()
- Specified by:
getTemplateFileExtin interfaceModule
-
flushSkinCache
public void flushSkinCache()
-
flushTypeCache
public void flushTypeCache()
-
flushRootResourcesCache
@Deprecated public void flushRootResourcesCache()
Deprecated.resources are deprecated - you should use a jax-rs application to declare more resources.
-
flushCache
public void flushCache()
- Specified by:
flushCachein interfaceModule
-
getSkinDir
public static File getSkinDir(File moduleDir)
-
loadDirectoryStack
protected void loadDirectoryStack()
-
getFile
public ScriptFile getFile(String path)
Description copied from interface:ModuleGets 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.
-
findFile
protected ScriptFile findFile(String path) throws IOException
- Parameters:
path- a normalized path (absolute path)- Throws:
IOException
-
getSkinResource
public ScriptFile getSkinResource(String path) throws IOException
Description copied from interface:ModuleGets a skin resource input stream. This must not cache resources. This method is using the module stacking directory to find the resource.- Specified by:
getSkinResourcein interfaceModule- 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
-
reloadMessages
public void reloadMessages()
-
getMessages
public Messages getMessages()
- Specified by:
getMessagesin interfaceModule
-
getMessages
public Map<String,String> getMessages(String language)
- Specified by:
getMessagesin interfaceMessagesProvider- Specified by:
getMessagesin interfaceModule
-
-