|
|||||||||
| 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.jersey.JerseyDeploymentModule
public class JerseyDeploymentModule
The Jersey module generates and compiles the support files and classes necessary to support a REST application according to JSR-311, using Jersey.
We direct you do the documentation for JAX-RS and Jersey to learn how to build a REST application using these technologies. However, it is important to note a few idiosyncrasies of the Enunciate-supported Jersey application.
Because the Jersey application is presumably deployed along with other Enunciate-supported applications (JAX-WS for SOAP, API documentation, etc.), it will, by default, be mounted at a specific subcontext as defined in the Enunciate configuration (attribute "defaultRestSubcontext" of the "enunciate/services/rest" element). This means that a JAX-RS resource applied at path "mypath" will actually be mounted at "rest/mypath", assuming that "rest" is the subcontext (which it is by default).
While is it recommended that the subcontext be preserved, you can disable it in the configuration for this module. Note, however, that this increases the chance of the paths of your REST resources conflicting with the paths of your documentation, SOAP endpoints, etc. Enunciate provides an additional check to see if a REST resource is too greedy because it has a path parameter in the first path segment. This can also be disabled in configuration, but doing so will effectively disable the Enunciate-generated documentation and other web service endpoints.
Enuncite provides content type negotiation (conneg) to Jersey that conforms to the content type negotiation of the Enunciate REST module. This means that each resource is mounted from the REST subcontext (see above) but ALSO from a subcontext that conforms to the id of each content type that the resource supports. So, if the content type id of the "application/xml" content type is "xml" then the resource at path "mypath" will be mounted at both "/rest/mypath" and "/xml/mypath".
The content types for each JAX-RS resource are declared by the @Produces annotation. The content type ids are customized with the "enunciate/services/rest/content-types" element in the Enunciate configuration. Enunciate supplies providers for the "application/xml" and "application/json" content types by default.
The generate step of the Jersey module generates the configuration files for a servlet-based Jersey application.
The Jersey module supports the following attributes:
The Jersey module also supports an arbitrary number of "init-param" child elements that can be used to specify the init parameters (e.g. container request filters, etc.) of the Jersey servlet. The "init-param" element supports a "name" attribute and a "value" attribute.
The Jersey deployment module exports no artifacts.
| Field Summary |
|---|
| Fields inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule |
|---|
enunciate |
| Constructor Summary | |
|---|---|
JerseyDeploymentModule()
|
|
| Method Summary | |
|---|---|
void |
addServletInitParam(java.lang.String name,
java.lang.String value)
Add a servlet init param. |
protected void |
doBuild()
Default implementation is a no-op. |
void |
doFreemarkerGenerate()
Generate using Freemarker. |
java.lang.String |
getApplicationClass()
The fully-qualified classname of an instance of the implementation of javax.ws.rs.core.Application that jersey will use. |
org.apache.commons.digester.RuleSet |
getConfigurationRules()
Default implementation returns null. |
java.lang.String |
getDefaultNamespace()
The default namespace. |
java.net.URL |
getJaxbTypesTemplateURL()
The jaxb types template URL. |
java.lang.String |
getName()
The name of the deployment module. |
java.net.URL |
getProvidersListTemplateURL()
The providers template URL. |
java.lang.String |
getResourceProviderFactory()
The fully-qualified classname of an instance of com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory that jersey will use. |
protected java.lang.String |
getRestSubcontext()
|
java.net.URL |
getRootResourceListTemplateURL()
The root resources template URL. |
java.util.Map<java.lang.String,java.lang.String> |
getServletInitParams()
Get the servlet init params. |
Validator |
getValidator()
Get the validator for this module, or null if none. |
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 |
isDisableWildcardServletError()
Whether to disable the greedy servlet pattern error. |
boolean |
isJaxrsProvider()
Whether this module is a JAX-RS provider module. |
boolean |
isJaxwsProvider()
Whether this module is a JAX-WS provider module. |
protected boolean |
isUpToDate()
Whether the generated sources are up-to-date. |
boolean |
isUsePathBasedConneg()
Whether to use path-based conneg. |
boolean |
isUseSubcontext()
Whether to use the REST subcontext. |
void |
onClassesFound(java.util.Set<java.lang.String> classes)
Logic for handling a set of classes that were found on the Enunciate classpath. |
void |
setApplicationClass(java.lang.String applicationClass)
The fully-qualified classname of an instance of the implementation of javax.ws.rs.core.Application that jersey will use.' |
void |
setDefaultNamespace(java.lang.String defaultNamespace)
The default namespace. |
void |
setDisableWildcardServletError(boolean disableWildcardServletError)
Whether to disable the wildcard servlet pattern error. |
void |
setResourceProviderFactory(java.lang.String resourceProviderFactory)
The fully-qualified classname of an instance of com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory that jersey will use. |
void |
setUsePathBasedConneg(boolean usePathBasedConneg)
Whether to use path-based conneg. |
void |
setUseSubcontext(boolean useSubcontext)
Whether to use the REST subcontext. |
| 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, doCompile, doPackage, getAliases, getBuildDir, getCompileDir, getEnunciate, getGenerateDir, getOrder, 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 JerseyDeploymentModule()
| Method Detail |
|---|
public java.lang.String getName()
DeploymentModule
getName in interface DeploymentModulegetName in class BasicDeploymentModulepublic java.net.URL getRootResourceListTemplateURL()
public java.net.URL getProvidersListTemplateURL()
public java.net.URL getJaxbTypesTemplateURL()
public Validator getValidator()
DeploymentModule
getValidator in interface DeploymentModulegetValidator in class BasicDeploymentModuleJerseyValidator.
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 onClassesFound(java.util.Set<java.lang.String> classes)
EnunciateClasspathListener
onClassesFound in interface EnunciateClasspathListenerclasses - The classes that were found.
public void doFreemarkerGenerate()
throws EnunciateException,
java.io.IOException,
freemarker.template.TemplateException
FreemarkerDeploymentModuleFreemarkerDeploymentModule.doGenerate() but can throw a TemplateException.
doFreemarkerGenerate in class FreemarkerDeploymentModuleEnunciateException
java.io.IOException
freemarker.template.TemplateException
protected void doBuild()
throws EnunciateException,
java.io.IOException
BasicDeploymentModule
doBuild in class BasicDeploymentModuleEnunciateException
java.io.IOExceptionprotected java.lang.String getRestSubcontext()
public org.apache.commons.digester.RuleSet getConfigurationRules()
BasicDeploymentModule
getConfigurationRules in interface DeploymentModulegetConfigurationRules in class BasicDeploymentModuleprotected boolean isUpToDate()
public boolean isJaxwsProvider()
SpecProviderModule
isJaxwsProvider in interface SpecProviderModulepublic boolean isJaxrsProvider()
SpecProviderModule
isJaxrsProvider in interface SpecProviderModulepublic boolean isUseSubcontext()
public void setUseSubcontext(boolean useSubcontext)
useSubcontext - Whether to use the REST subcontext.public boolean isUsePathBasedConneg()
public void setUsePathBasedConneg(boolean usePathBasedConneg)
usePathBasedConneg - Whether to use path-based conneg.public java.lang.String getResourceProviderFactory()
public void setResourceProviderFactory(java.lang.String resourceProviderFactory)
resourceProviderFactory - The fully-qualified classname of an instance of com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory that jersey will use.public java.lang.String getApplicationClass()
public void setApplicationClass(java.lang.String applicationClass)
applicationClass - The fully-qualified classname of an instance of the implementation of javax.ws.rs.core.Application that jersey will use.public boolean isDisableWildcardServletError()
public void setDisableWildcardServletError(boolean disableWildcardServletError)
disableWildcardServletError - Whether to disable the wildcard servlet pattern error.public java.lang.String getDefaultNamespace()
public void setDefaultNamespace(java.lang.String defaultNamespace)
defaultNamespace - The default namespace.public java.util.Map<java.lang.String,java.lang.String> getServletInitParams()
public void addServletInitParam(java.lang.String name,
java.lang.String value)
name - The name of the init param.value - The value of the init param.public boolean isDisabled()
DeploymentModule
isDisabled in interface DeploymentModuleisDisabled in class BasicDeploymentModule
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||