|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.codehaus.enunciate.modules.BasicDeploymentModule
org.codehaus.enunciate.modules.FreemarkerDeploymentModule
org.codehaus.enunciate.modules.spring_app.SpringAppDeploymentModule
public class SpringAppDeploymentModule
The spring app deployment module produces the configuration files and application extensions needed to apply the Spring container to the Web service application.
The "generate" step generates the Spring configuration file and application extensions. Refer to configuration to learn how to customize these things.
The "generate" step is the only relevant step in the spring app deployment module.
The configuration for the Spring App deployment module is specified by the "spring-app" child element under the "modules" element of the enunciate configuration file.
The following example shows the structure of the configuration elements for this module. Note that this shows only the structure. Some configuration elements don't make sense when used together.
<enunciate>
<modules>
<spring-app contextLoaderListenerClass="..."
applicationContextFilename="..." contextConfigLocation="..."
springVersion="...">
<springImport file="..." uri="..."/>
<springImport file="..." uri="..."/>
...
<globalServiceInterceptor interceptorClass="..." beanName="..."/>
<globalServiceInterceptor interceptorClass="..." beanName="..."/>
...
<handlerInterceptor interceptorClass="..." beanName="..."/>
<handlerInterceptor interceptorClass="..." beanName="..."/>
...
<handlerMapping pattern="..." beanName="..."/>
<handlerMapping pattern="..." beanName="..."/>
...
</spring-app>
</modules>
</enunciate>
The "springImport" element is used to specify a spring configuration file that will be imported by the main spring servlet config. It supports the following attributes:
One use of specifying spring a import file is to wrap your endpoints with spring interceptors. This can be done by simply declaring a bean that is an instance of your endpoint class, which can be advised as needed.
It's important to note that the type on which the bean context will be searched is the type of the endpoint interface, and then only if it exists. If there are more than one beans that are assignable to the endpoint interface, the bean that is named the name of the service will be used. Otherwise, the deployment of your endpoint will fail.
The same procedure can be used to specify the beans to use as REST endpoints. In this case, the bean context will be searched for each REST interface that the endpoint implements. If there is a bean that implements that interface, it will used instead of the default implementation. If there is more than one, the bean that is named the same as the REST endpoint will be used.
There also exists a mechanism to add certain AOP interceptors to all service endpoint beans. Such interceptors are referred to as "global service interceptors." This can be done by using the "globalServiceInterceptor" element (see below), or by simply creating an interceptor that implements org.codehaus.enunciate.modules.spring_app.EnunciateServiceAdvice or org.codehaus.enunciate.modules.spring_app.EnunciateServiceAdvisor and declaring it in your imported spring beans file.
Each global interceptor has an order. The default order is 0 (zero). If a global service interceptor implements org.springframework.core.Ordered, the order will be respected. As global service interceptors are added, it will be assigned a position in the chain according to it's order. Interceptors of the same order will be ordered together according to their position in the config file, with priority to those declared by the "globalServiceInterceptor" element, then to instances of org.codehaus.enunciate.modules.spring_app.EnunciateServiceAdvice, then to instances of org.codehaus.enunciate.modules.spring_app.EnunciateServiceAdvisor.
For more information on spring bean configuration and interceptor advice, see the spring reference documentation.
The "globalServiceInterceptor" element is used to specify a Spring interceptor (instance of org.aopalliance.aop.Advice or org.springframework.aop.Advisor) that is to be injected on all service endpoint beans.
The "handlerInterceptor" element is used to specify a Spring interceptor (instance of org.springframework.web.servlet.HandlerInterceptor) that is to be injected on the handler mapping.
For more information on spring bean configuration and interceptor advice, see the spring reference documentation.
The "handlerMapping" element is used to specify a custom Spring handler mapping.
For more information on spring handler mappings, see the spring reference documentation.
The spring app deployment module exports no artifacts.
| Field Summary |
|---|
| Fields inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule |
|---|
enunciate |
| Constructor Summary | |
|---|---|
SpringAppDeploymentModule()
|
|
| Method Summary | |
|---|---|
void |
addGlobalServiceInterceptor(GlobalServiceInterceptor interceptorConfig)
Add a global service interceptor to the spring configuration. |
void |
addHandlerInterceptor(HandlerInterceptor interceptorConfig)
Add a handler interceptor to the spring configuration. |
void |
addSpringImport(SpringImport springImports)
Add a spring import. |
protected void |
copySpringConfig()
Copy the spring application context and servlet config from the build dir to the WEB-INF directory. |
void |
doFreemarkerGenerate()
Generate using Freemarker. |
java.lang.String |
getApplicationContextFilename()
The name of the application context file. |
protected java.net.URL |
getApplicationContextTemplateURL()
|
org.apache.commons.digester.RuleSet |
getConfigurationRules()
Default implementation returns null. |
java.lang.String |
getContextConfigLocation()
The context config location. |
java.lang.String |
getContextLoaderListenerClass()
The class to use as the context loader listener. |
java.lang.String |
getName()
The name of the deployment module. |
int |
getOrder()
The order of execution for the deployment module. |
java.util.List<SpringImport> |
getSpringImports()
The list of spring imports. |
protected java.util.ArrayList<java.lang.String> |
getSpringImportURIs()
Get the string form of the spring imports that have been configured. |
Validator |
getValidator()
Get the validator for this module, or null if none. |
protected java.io.File |
getWebInfDir()
The directory where the config files are generated. |
void |
init(Enunciate enunciate)
Sets the enunciate mechanism. |
void |
initModel(EnunciateFreemarkerModel model)
Initialize the model. |
boolean |
isDisabled()
Whether this deployment module has been disabled, e.g. |
boolean |
isEnableSecurity()
Whether to enable security. |
void |
onClassesFound(java.util.Set<java.lang.String> classes)
Logic for handling a set of classes that were found on the Enunciate classpath. |
protected java.lang.String |
resolveSpringImportFileName(java.lang.String fileName)
Resolves the application context file name (in case there's a conflict). |
void |
setApplicationContextFilename(java.lang.String applicationContextFilename)
The name of the application context file. |
void |
setContextConfigLocation(java.lang.String contextConfigLocation)
The context config location. |
void |
setContextLoaderListenerClass(java.lang.String contextLoaderListenerClass)
The class to use as the context loader listener. |
void |
setEnableSecurity(boolean enableSecurity)
Whether to enable security. |
void |
setSpringVersion(java.lang.String version)
The spring version to use. |
| Methods inherited from class org.codehaus.enunciate.modules.FreemarkerDeploymentModule |
|---|
close, doGenerate, getConfiguration, getModel, getModelInternal, getObjectWrapper, getTemplateExceptionHandler, getTemplateLoader, processTemplate, processTemplate, processTemplate, processTemplate |
| Methods inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule |
|---|
debug, doBuild, doCompile, doPackage, getAliases, getBuildDir, getCompileDir, getEnunciate, getGenerateDir, getPackageDir, info, setBuildDir, setCompileDir, setDisabled, setGenerateDir, setPackageDir, step, warn |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SpringAppDeploymentModule()
| Method Detail |
|---|
public java.lang.String getName()
DeploymentModule
getName in interface DeploymentModulegetName in class BasicDeploymentModuleprotected java.net.URL getApplicationContextTemplateURL()
public void onClassesFound(java.util.Set<java.lang.String> classes)
EnunciateClasspathListener
onClassesFound in interface EnunciateClasspathListenerclasses - The classes that were found.
public void init(Enunciate enunciate)
throws EnunciateException
BasicDeploymentModule
init in interface DeploymentModuleinit in class BasicDeploymentModuleenunciate - The enunciate mechanism.
EnunciateExceptionpublic void initModel(EnunciateFreemarkerModel model)
EnunciateModelAware
initModel in interface EnunciateModelAwareinitModel in class FreemarkerDeploymentModulemodel - The model to initialize.
public void doFreemarkerGenerate()
throws java.io.IOException,
freemarker.template.TemplateException
FreemarkerDeploymentModuleFreemarkerDeploymentModule.doGenerate() but can throw a TemplateException.
doFreemarkerGenerate in class FreemarkerDeploymentModulejava.io.IOException
freemarker.template.TemplateException
protected void copySpringConfig()
throws java.io.IOException
java.io.IOExceptionprotected java.util.ArrayList<java.lang.String> getSpringImportURIs()
protected java.lang.String resolveSpringImportFileName(java.lang.String fileName)
fileName - The file name.
public boolean isDisabled()
DeploymentModule
isDisabled in interface DeploymentModuleisDisabled in class BasicDeploymentModulepublic java.util.List<SpringImport> getSpringImports()
public void addSpringImport(SpringImport springImports)
springImports - The spring import to add.public void addGlobalServiceInterceptor(GlobalServiceInterceptor interceptorConfig)
interceptorConfig - The interceptor configuration.public void addHandlerInterceptor(HandlerInterceptor interceptorConfig)
interceptorConfig - The interceptor configuration.public java.lang.String getContextLoaderListenerClass()
public void setContextLoaderListenerClass(java.lang.String contextLoaderListenerClass)
contextLoaderListenerClass - The class to use as the context loader listener.public java.lang.String getApplicationContextFilename()
public void setApplicationContextFilename(java.lang.String applicationContextFilename)
applicationContextFilename - The name of the application context file.public java.lang.String getContextConfigLocation()
public void setContextConfigLocation(java.lang.String contextConfigLocation)
contextConfigLocation - The context config location.public boolean isEnableSecurity()
public void setEnableSecurity(boolean enableSecurity)
enableSecurity - Whether to enable security.public void setSpringVersion(java.lang.String version)
version - The spring version to use.public int getOrder()
DeploymentModule
getOrder in interface DeploymentModulegetOrder in class BasicDeploymentModulepublic org.apache.commons.digester.RuleSet getConfigurationRules()
BasicDeploymentModule
getConfigurationRules in interface DeploymentModulegetConfigurationRules in class BasicDeploymentModulepublic Validator getValidator()
DeploymentModule
getValidator in interface DeploymentModulegetValidator in class BasicDeploymentModuleprotected java.io.File getWebInfDir()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||