[
https://jira.nuxeo.org/browse/NXP-4804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bogdan Stefanescu updated NXP-4804:
-----------------------------------
Upgrade notes:
1. To upgrade existing WebEngine modules
Replace in your pom.xml the JAX-RS API dependency:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
</dependency>
with the dependency on the latest JAX-RS API:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
That's all.
2. To upgrade existing JAX-RS apps (not web engine modules) you need to create
a real JAX-RS application (as specified by JSR 311) and to deploy it either
using a custom servlet and declaring your application in web.xml in your
servlet init-params (see specs.) either putting a line in your MANIFEST.MF:
Nuxeo-WebModule: org.nuxeo.xxx.MyApplication
where org.nuxeo.xxx.MyApplication is your application class.
This will deploy your application as part of the webengine servlet (under
/nuxeo/site)
Complete description of the modifications:
I've just pushed the changes to switch on jersey JAX-RS engine.
Now all distributions are including jersey.
The nuxeo-webengine-resteasy-adapter will be removed. (The code is still there
but it was already removed from nuxeo-webengine modules build)
I've updated all dependent projects in nuxeo trunk.
*Important* If you have projects having dependencies on JAX-RS you need to
remove the deprecated JAX-RS dependency
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
</dependency>
and put the dependency on the latest JAX-RS API:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
Also, if you have pure JAX-RS applications (not necessarily webengine modules)
you need to change the way of deploying the JAX-RS application.
For example the old and unclean way to register message body writers was:
static {
WebEngine we = Framework.getLocalService(WebEngine.class);
we.getRegistry().addMessageBodyWriter(new RemotePubMessageWriter());
we.getRegistry().addMessageBodyReader(new RemotePubMessageReader());
}
Not to define your application resources and providers you need to use a REST
application configurator as in JAX-RS specification.
You need to define a class derived from javax.ws.rs.core.Application. Example:
public class GadgetsApp extends Application {
@Override
public Set<Class<?>> getClasses() {
HashSet<Class<?>> set = new HashSet<Class<?>>();
set.add(Gadgets.class);
set.add(GadgetStreamWriter.class);
return set;
}
}
In the returned set you need to put all your root resources and providers. If
you have singleton resources/providers you need to override getSingletons()
method.
The MessgeBodyWriters/Readers must be annotated with @Provider and root
resource classes must be annotated with @Path
There are two methods to deploy your JAX-RS app:
1. Create a new servlet in web.xml where you specify your application (you will
have a servlet per application). Example:
<servlet>
<servlet-name>My JAX-RS Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.nuxeo.xxx.MyApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>My JAX-RS Servlet</servlet-name>
<url-pattern>/xxx/*</url-pattern>
</servlet-mapping>
where org.nuxeo.xxx.MyApplication is the application you defined.
This is the deployment described in JAX-RS specs.
2. Use the webengine servlet to deploy your app. This is much more simpler and
can be used if your JAX-RS app is deployed in Nuxeo. (you can use it even if
you don't use webengine in your app.)
In MANIFEST.MF you need to add the line:
Nuxeo-WebModule: org.nuxeo.xxx.MyApplication;
And webengine will deploy your JAX-RS application in the webengine servlet
(under /nuxeo/site/ in jboss or / in jetty base distrib)
The hot reload mechanism changed so I have to change the IDE plugins to use the
new mechanism.
Next, I will remove the Resource Servlet to align existing code with the new
mechanism of resolving resources to be able to correctly use URL rewrites with
webengine.
> Align to JAX-RS deployment model.
> ----------------------------------
>
> Key: NXP-4804
> URL: https://jira.nuxeo.org/browse/NXP-4804
> Project: Nuxeo Enterprise Platform
> Issue Type: Improvement
> Affects Versions: 5.3 GA
> Reporter: Bogdan Stefanescu
> Assignee: Bogdan Stefanescu
> Priority: Major
> Fix For: 5.3.1
>
>
> Use the JAX-RS Application logic to deploy jAX-RS applications.
> This way any pure JAX-RS application can be deployed in Nuxeo.
> Also, it deprecates the resteasy adapter since using the jax-rs deployment
> model you can deploy webengine modules and JAX-RS apps on any jax-rs backend
> without the need of an adapter.
> Specific resteasy adapter feaures like guard and tx annotations on methods
> will be lost (anyway for now these features are not used by WE modules)
> Per resource tx annotation will be possible to be implemented later in a
> portable way using @TransactionAttribute on resource class.
> Also, the hot reloading mechanism will be deprecated (no more usable) since
> it requires full control over the JAX-RS engine which is not portable between
> backends. A new hot reload mechanism will be provided - with less granularity
> on the scope of the reload than the former one - so it will redeploy all
> modules (and not only the one that changed) - but more portable.
> The hot reload will be available only for jersey (at least in a first step)
> The task will be done in several steps:
> 1. cleanup/prepare existing code to the JAX-RS deployment model.
> 2. Implement JAX-RS deployment
> 3. Modify webengine-base to use the JAX-RS application deployment model.
> 3. Deprecate resteasy adapter and switch to jersey which will become the
> default backend (since it is closer to the specs than resteasy, solves some
> important bugs existing on resteasy and also provides nice features like the
> possibility to plug-in IOC engines like guice)
> 4. Update existing JAX-RS code that use the old and dirty way of declaring
> root resources or body message reader/writers (though static blocks) to
> switch to new deployment model.
> 5. As the hot reloading mechanism will be deprecated a new one will be added
> that works with jersey.
> 6. switch to jersey
> 5. Update eclipse plugins to use the new reload mechanism. (notification will
> change)
> Note that regular WebEngine modules are not affected since they are
> completely managed by webengine ...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.nuxeo.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets