You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2010/01/18 12:18:14 UTC
svn commit: r900344 - in /camel/trunk/components/camel-web: pom.xml
src/main/java/org/apache/camel/web/util/CamelOSGIResourceConfig.java
src/profiles/osgi/webapp/WEB-INF/web.xml
Author: cmoulliard
Date: Mon Jan 18 11:18:14 2010
New Revision: 900344
URL: http://svn.apache.org/viewvc?rev=900344&view=rev
Log:
Solve issue about rendering of jersey REST request for JAXB
Added:
camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelOSGIResourceConfig.java (with props)
Modified:
camel/trunk/components/camel-web/pom.xml
camel/trunk/components/camel-web/src/profiles/osgi/webapp/WEB-INF/web.xml
Modified: camel/trunk/components/camel-web/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/pom.xml?rev=900344&r1=900343&r2=900344&view=diff
==============================================================================
--- camel/trunk/components/camel-web/pom.xml (original)
+++ camel/trunk/components/camel-web/pom.xml Mon Jan 18 11:18:14 2010
@@ -622,7 +622,7 @@
org.apache.camel.spring;version="[2.1, 2.5)",
org.apache.camel.osgi;version="[2.1, 2.5)",
org.apache.camel.util;version="[2.1, 2.5)",
- org.apache.camel.web.resources;version="[2.1, 2.5)",
+ org.apache.camel.web.resources;resolution:=optional,
org.apache.commons.logging;resolution:=optional,
org.osgi.service.http;version="[1.0.0,2.0.0)",
org.ops4j.pax.web.service;resolution:=optional,
Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelOSGIResourceConfig.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelOSGIResourceConfig.java?rev=900344&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelOSGIResourceConfig.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelOSGIResourceConfig.java Mon Jan 18 11:18:14 2010
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.web.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.core.MediaType;
+
+import com.sun.jersey.api.core.ClassNamesResourceConfig;
+import com.sun.jersey.api.core.PackagesResourceConfig;
+import org.apache.camel.web.resources.CamelContextResource;
+import org.apache.camel.web.resources.ComponentResource;
+import org.apache.camel.web.resources.ComponentsResource;
+import org.apache.camel.web.resources.Constants;
+import org.apache.camel.web.resources.ConvertersFromResource;
+import org.apache.camel.web.resources.ConvertersResource;
+import org.apache.camel.web.resources.EndpointResource;
+import org.apache.camel.web.resources.EndpointsResource;
+import org.apache.camel.web.resources.ExchangeResource;
+import org.apache.camel.web.resources.LanguageResource;
+import org.apache.camel.web.resources.LanguagesResource;
+import org.apache.camel.web.resources.RouteResource;
+import org.apache.camel.web.resources.RouteStatusResource;
+import org.apache.camel.web.resources.RoutesResource;
+
+/**
+ * @version $Revision: 899610 $
+ */
+public class CamelOSGIResourceConfig extends ClassNamesResourceConfig {
+
+ public CamelOSGIResourceConfig() {
+ super(createProperties());
+ }
+
+ protected static Map<String, Object> createProperties() {
+ Map<String, Object> properties = new HashMap<String, Object>();
+
+ String[] resources = new String[] {
+ CamelContextResource.class.getName(),
+ ComponentResource.class.getName(),
+ ComponentsResource.class.getName(),
+ ConvertersFromResource.class.getName(),
+ ConvertersResource.class.getName(),
+ EndpointResource.class.getName(),
+ EndpointsResource.class.getName(),
+ ExchangeResource.class.getName(),
+ LanguageResource.class.getName(),
+ LanguagesResource.class.getName(),
+ RouteResource.class.getName(),
+ RoutesResource.class.getName(),
+ RouteStatusResource.class.getName(),
+ JAXBContextResolver.class.getName(),
+ JAXBMarshallerResolver.class.getName()
+ };
+
+ properties.put(ClassNamesResourceConfig.PROPERTY_CLASSNAMES, resources);
+
+ return properties;
+
+ }
+
+ public Map<String, MediaType> getMediaTypeMappings() {
+ Map<String, MediaType> m = new HashMap<String, MediaType>();
+ m.put("html", MediaType.TEXT_HTML_TYPE);
+ m.put("xml", MediaType.APPLICATION_XML_TYPE);
+ m.put("json", MediaType.APPLICATION_JSON_TYPE);
+ m.put("dot", MediaType.valueOf(Constants.DOT_MIMETYPE));
+ return m;
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelOSGIResourceConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: camel/trunk/components/camel-web/src/profiles/osgi/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/profiles/osgi/webapp/WEB-INF/web.xml?rev=900344&r1=900343&r2=900344&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/profiles/osgi/webapp/WEB-INF/web.xml (original)
+++ camel/trunk/components/camel-web/src/profiles/osgi/webapp/WEB-INF/web.xml Mon Jan 18 11:18:14 2010
@@ -54,26 +54,9 @@
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<!-- com.sun.jersey.api.core.PackagesResourceConfig does not work with OSGI -->
- <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
+ <param-value>org.apache.camel.web.util.CamelOSGIResourceConfig</param-value>
</init-param>
<init-param>
- <param-name>com.sun.jersey.config.property.classnames</param-name>
- <param-value>
- org.apache.camel.web.resources.CamelContextResource;
- org.apache.camel.web.resources.ComponentResource;
- org.apache.camel.web.resources.ComponentsResource;
- org.apache.camel.web.resources.ConvertersFromResource;
- org.apache.camel.web.resources.EndpointResource;
- org.apache.camel.web.resources.EndpointsResource;
- org.apache.camel.web.resources.ExchangeResource;
- org.apache.camel.web.resources.LanguageResource;
- org.apache.camel.web.resources.LanguagesResource;
- org.apache.camel.web.resources.RouteResource;
- org.apache.camel.web.resources.RoutesResource;
- org.apache.camel.web.resources.RouteStatusResource
- </param-value>
- </init-param>
- <init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
@@ -81,12 +64,10 @@
<param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
<param-value>true</param-value>
</init-param>
- <!-- NOT REQUIRED WHEN USING ClassNamesResourceConfig
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
- <param-value>org.apache.camel.web.resources</param-value>
+ <param-value>org.apache.camel.web</param-value>
</init-param>
- -->
<init-param>
<param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
<param-value>/(images|css|js)/.*</param-value>