You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2013/02/07 18:59:54 UTC
svn commit: r1443632 - in /tomee/tomee/trunk/server:
openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/
openejb-rest/src/main/java/org/apache/openejb/server/rest/
Author: rmannibucau
Date: Thu Feb 7 17:59:53 2013
New Revision: 1443632
URL: http://svn.apache.org/r1443632
Log:
propagating the contextRoot for all rest deployment
Modified:
tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java
Modified: tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java?rev=1443632&r1=1443631&r2=1443632&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java (original)
+++ tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java Thu Feb 7 17:59:53 2013
@@ -116,7 +116,14 @@ public class CxfRsHttpListener implement
if (httpRequest instanceof HttpRequestImpl) {
((HttpRequestImpl) httpRequest).initPathFromContext(context);
}
- httpRequest.setAttribute("org.apache.cxf.transport.endpoint.address", BaseUrlHelper.getBaseURL(httpRequest) + "/");
+
+
+ String baseURL = BaseUrlHelper.getBaseURL(httpRequest);
+ if (!baseURL.endsWith("/")) {
+ baseURL += "/";
+ }
+
+ httpRequest.setAttribute("org.apache.cxf.transport.endpoint.address", baseURL);
// delegate invocation
destination.invoke(null, httpRequest.getServletContext(), new HttpServletRequestWrapper(httpRequest) {
@@ -184,31 +191,38 @@ public class CxfRsHttpListener implement
}
@Override
- public void deploySingleton(String fullContext, Object o, Application appInstance,
+ public void deploySingleton(String contextRoot, String fullContext, Object o, Application appInstance,
Collection<Object> additionalProviders, ServiceConfiguration configuration) {
- deploy(o.getClass(), fullContext, new SingletonResourceProvider(o), o, appInstance, null, additionalProviders, configuration);
+ deploy(contextRoot, o.getClass(), fullContext, new SingletonResourceProvider(o), o, appInstance, null, additionalProviders, configuration);
}
@Override
- public void deployPojo(String fullContext, Class<?> loadedClazz, Application app, Collection<Injection> injections,
+ public void deployPojo(String contextRoot, String fullContext, Class<?> loadedClazz, Application app, Collection<Injection> injections,
Context context, WebBeansContext owbCtx, Collection<Object> additionalProviders, ServiceConfiguration configuration) {
- deploy(loadedClazz, fullContext, new OpenEJBPerRequestPojoResourceProvider(loadedClazz, injections, context, owbCtx),
+ deploy(contextRoot, loadedClazz, fullContext, new OpenEJBPerRequestPojoResourceProvider(loadedClazz, injections, context, owbCtx),
null, app, null, additionalProviders, configuration);
}
@Override
- public void deployEJB(String fullContext, BeanContext beanContext, Collection<Object> additionalProviders, ServiceConfiguration configuration) {
+ public void deployEJB(String contextRoot, String fullContext, BeanContext beanContext, Collection<Object> additionalProviders, ServiceConfiguration configuration) {
final Object proxy = ProxyEJB.subclassProxy(beanContext);
- deploy(beanContext.getBeanClass(), fullContext, new NoopResourceProvider(beanContext.getBeanClass(), proxy),
+ deploy(contextRoot, beanContext.getBeanClass(), fullContext, new NoopResourceProvider(beanContext.getBeanClass(), proxy),
proxy, null, new OpenEJBEJBInvoker(Collections.singleton(beanContext)), additionalProviders, configuration);
}
- private void deploy(Class<?> clazz, String address, ResourceProvider rp, Object serviceBean, Application app, Invoker invoker,
- Collection<Object> additionalProviders, ServiceConfiguration configuration) {
+ private void deploy(String contextRoot, Class<?> clazz, String address, ResourceProvider rp, Object serviceBean,
+ Application app, Invoker invoker, Collection<Object> additionalProviders, ServiceConfiguration configuration) {
final JAXRSServerFactoryBean factory = newFactory(address);
configureFactory(additionalProviders, configuration, factory);
factory.setResourceClasses(clazz);
+ context = contextRoot;
+ if (context == null) {
+ context = "";
+ }
+ if (!context.startsWith("/")) {
+ context = "/" + context;
+ }
if (rp != null) {
factory.setResourceProvider(rp);
Modified: tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java?rev=1443632&r1=1443631&r2=1443632&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java (original)
+++ tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java Thu Feb 7 17:59:53 2013
@@ -629,7 +629,7 @@ public abstract class RESTService implem
final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(web, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost);
services.add(new DeployedService(address.complete, web, o.getClass().getName()));
- listener.deploySingleton(getFullContext(address.base, contextRoot), o, appInstance, additionalProviders, configuration);
+ listener.deploySingleton(contextRoot, getFullContext(address.base, contextRoot), o, appInstance, additionalProviders, configuration);
LOGGER.info("deployed REST singleton: " + o);
}
@@ -645,7 +645,7 @@ public abstract class RESTService implem
final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(web, listener, classLoader, nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost);
services.add(new DeployedService(address.complete, contextRoot, loadedClazz.getName()));
- listener.deployPojo(getFullContext(address.base, contextRoot), loadedClazz, app, injections, context, owbCtx,
+ listener.deployPojo(contextRoot, getFullContext(address.base, contextRoot), loadedClazz, app, injections, context, owbCtx,
additionalProviders, config);
LOGGER.info("REST Service: " + address.complete + " -> Pojo " + loadedClazz.getName());
@@ -657,7 +657,7 @@ public abstract class RESTService implem
final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(web, listener, beanContext.getClassLoader(), nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost);
services.add(new DeployedService(address.complete, context, beanContext.getBeanClass().getName()));
- listener.deployEJB(getFullContext(address.base, context), beanContext,
+ listener.deployEJB(context, getFullContext(address.base, context), beanContext,
additionalProviders, new ServiceConfiguration(beanContext.getProperties(), serviceInfos));
LOGGER.info("REST Service: " + address.complete + " -> EJB " + beanContext.getEjbName());
Modified: tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java?rev=1443632&r1=1443631&r2=1443632&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java (original)
+++ tomee/tomee/trunk/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RsHttpListener.java Thu Feb 7 17:59:53 2013
@@ -29,13 +29,13 @@ import java.util.Collection;
import java.util.Map;
public interface RsHttpListener extends HttpListener {
- void deploySingleton(String fullContext, Object o, Application appInstance,
+ void deploySingleton(String webContext, String fullContext, Object o, Application appInstance,
Collection<Object> additionalProviders, ServiceConfiguration serviceInfos);
- void deployPojo(String fullContext, Class<?> loadedClazz, Application app, Collection<Injection> injections,
+ void deployPojo(String webContext, String fullContext, Class<?> loadedClazz, Application app, Collection<Injection> injections,
Context context, WebBeansContext owbCtx, Collection<Object> additionalProviders, ServiceConfiguration serviceInfos);
- void deployEJB(String fullContext, BeanContext beanContext, Collection<Object> additionalProviders, ServiceConfiguration serviceInfos);
+ void deployEJB(String webContext, String fullContext, BeanContext beanContext, Collection<Object> additionalProviders, ServiceConfiguration serviceInfos);
void undeploy();