summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-08-29 08:53:31 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-08-29 08:53:31 +0000
commit79a0f89332ada0decd2caaee77e9102218462d6a (patch)
tree8c867d012b6ed72435f51b569abd1856e677bb7e
parent7f61ec586a9dc1bbd71b68331c610fcc0148c999 (diff)
TUSCANY-3595 - Setting up proper classloader to find resources under OSGi environment
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@990512 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF1
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java33
2 files changed, 29 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF
index 6eaa93f2c7..9dfec81d37 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF
@@ -27,6 +27,7 @@ Import-Package: javax.jws,
org.apache.tuscany.sca.databinding;version="2.0.0",
org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
org.apache.tuscany.sca.databinding.xml;version="2.0.0",
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
org.apache.tuscany.sca.host.http;version="2.0.0",
org.apache.tuscany.sca.interfacedef;version="2.0.0",
org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
index 23b951c88a..3d3c4048fa 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
@@ -6,15 +6,15 @@
* 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.
+ * under the License.
*/
package org.apache.tuscany.sca.binding.rest.provider;
@@ -26,8 +26,13 @@ import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.validation.SchemaFactory;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
import org.apache.wink.common.internal.registry.ProvidersRegistry;
import org.apache.wink.common.internal.registry.metadata.MethodMetadata;
import org.apache.wink.server.internal.DeploymentConfiguration;
@@ -36,7 +41,7 @@ import org.apache.wink.server.internal.registry.ResourceRecord;
import org.apache.wink.server.internal.servlet.RestServlet;
/**
- *
+ *
*/
public class TuscanyRESTServlet extends RestServlet {
private static final long serialVersionUID = 89997233133964915L;
@@ -53,7 +58,25 @@ public class TuscanyRESTServlet extends RestServlet {
@Override
public DeploymentConfiguration getDeploymentConfiguration() throws ClassNotFoundException, InstantiationException,
IllegalAccessException, IOException {
- DeploymentConfiguration config = super.getDeploymentConfiguration();
+
+
+ // setup proper classLoader to work on OSGi environment
+ ClassLoader cl =
+ ClassLoaderContext.setContextClassLoader(Thread.currentThread().getContextClassLoader(),
+ registry.getServiceDiscovery(),
+ "javax.ws.rs.ext.RuntimeDelegate",
+ "META-INF/wink-alternate-shortcuts.properties",
+ "META-INF/server/wink-providers");
+
+ DeploymentConfiguration config = null;
+ try {
+ config = super.getDeploymentConfiguration();
+ } finally {
+ if (cl != null) {
+ // return previous classLoader
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
// [rfeng] FIXME: This is a hack to fool Apache wink to not remove the servlet path
config.setFilterConfig(new FilterConfig() {