geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r1057102 - in /geronimo/server/trunk: plugingroups/javaee6-tomcat/ plugingroups/javaee6-tomcat/src/main/history/ plugins/tomcat/tomcat7-deployer/src/main/plan/ plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deploy...
Date Mon, 10 Jan 2011 07:54:22 GMT
Author: genspring
Date: Mon Jan 10 07:54:21 2011
New Revision: 1057102

URL: http://svn.apache.org/viewvc?rev=1057102&view=rev
Log:
GERONIMO-5096 adding initial wink integration code. Though tck are 100%  passed locally, we
need add following

1, scan jaxrs resouces based on annotation.
2, exposing EJB as service support.
3, exposing OWB bean as service support.

according to Spec.

Current tck cases only cover pojo with Application configured in web.xml.

Added:
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java
    geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java
Modified:
    geronimo/server/trunk/plugingroups/javaee6-tomcat/pom.xml
    geronimo/server/trunk/plugingroups/javaee6-tomcat/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/tomcat/tomcat7-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
    geronimo/server/trunk/plugins/wink/wink-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/wink/wink-tomcat-server/pom.xml

Modified: geronimo/server/trunk/plugingroups/javaee6-tomcat/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugingroups/javaee6-tomcat/pom.xml?rev=1057102&r1=1057101&r2=1057102&view=diff
==============================================================================
--- geronimo/server/trunk/plugingroups/javaee6-tomcat/pom.xml (original)
+++ geronimo/server/trunk/plugingroups/javaee6-tomcat/pom.xml Mon Jan 10 07:54:21 2011
@@ -108,6 +108,18 @@
             <!--<version>${project.version}</version>-->
             <!--<type>car</type>-->
         <!--</dependency>-->
+    <dependency>
+      <groupId>org.apache.geronimo.configs</groupId>
+      <artifactId>wink</artifactId>
+      <version>${project.version}</version>
+      <type>car</type>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.configs</groupId>
+      <artifactId>wink-deployer</artifactId>
+      <version>${project.version}</version>
+      <type>car</type>
+    </dependency>        
 
     </dependencies>
 

Modified: geronimo/server/trunk/plugingroups/javaee6-tomcat/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugingroups/javaee6-tomcat/src/main/history/dependencies.xml?rev=1057102&r1=1057101&r2=1057102&view=diff
==============================================================================
--- geronimo/server/trunk/plugingroups/javaee6-tomcat/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugingroups/javaee6-tomcat/src/main/history/dependencies.xml Mon
Jan 10 07:54:21 2011
@@ -17,6 +17,16 @@
         <type>car</type>
     </dependency>
     <dependency>
+        <groupId>org.apache.geronimo.configs</groupId>
+        <artifactId>wink</artifactId>
+        <type>car</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.configs</groupId>
+        <artifactId>wink-deployer</artifactId>
+        <type>car</type>
+    </dependency>
+    <dependency>
         <groupId>org.apache.geronimo.plugingroups</groupId>
         <artifactId>client</artifactId>
         <type>car</type>

Modified: geronimo/server/trunk/plugins/tomcat/tomcat7-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/tomcat7-deployer/src/main/plan/plan.xml?rev=1057102&r1=1057101&r2=1057102&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/tomcat7-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/tomcat/tomcat7-deployer/src/main/plan/plan.xml Mon Jan 10
07:54:21 2011
@@ -72,6 +72,10 @@
             <pattern>
                 <name>BValModuleBuilderExtension</name>
             </pattern>
+            <pattern>
+                <name>WinkModuleBuilderExtension</name>
+            </pattern>     
+            
         </references>
         <reference name="ResourceEnvironmentSetter">
             <name>ResourceRefBuilder</name>

Modified: geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java?rev=1057102&r1=1057101&r2=1057102&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
(original)
+++ geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
Mon Jan 10 07:54:21 2011
@@ -20,21 +20,23 @@ package org.apache.geronimo.wink.deploym
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.jar.JarFile;
 
+import javax.servlet.http.HttpServlet;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamReference;
-import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
@@ -44,15 +46,23 @@ import org.apache.geronimo.j2ee.j2eeobje
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.web.info.WebAppInfo;
+import org.apache.geronimo.wink.GeronimoRestServlet;
+import org.apache.geronimo.wink.GeronimoWinkDeloymentConfiguration;
 import org.apache.openejb.jee.FacesConfig;
 import org.apache.openejb.jee.FacesManagedBean;
+import org.apache.openejb.jee.ParamValue;
 import org.apache.openejb.jee.Servlet;
+import org.apache.openejb.jee.ServletMapping;
 import org.apache.openejb.jee.WebApp;
-import org.apache.wink.server.internal.servlet.RestServlet;
+import org.apache.xbean.finder.BundleAssignableClassFinder;
 import org.apache.xbean.finder.ClassFinder;
-import org.apache.xmlbeans.XmlObject;
+import org.apache.xbean.osgi.bundle.util.BundleClassFinder;
+import org.apache.xbean.osgi.bundle.util.BundleClassLoader;
+import org.apache.xbean.osgi.bundle.util.ClassDiscoveryFilter;
+import org.apache.xbean.osgi.bundle.util.DiscoveryRange;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,93 +79,250 @@ public class WinkModuleBuilderExtension 
 
     private final NamingBuilder namingBuilders;
 
-    //private static final String CONTEXT_LISTENER_NAME = GeronimoStartupServletContextListener.class.getName();
+    private static final String REST_APPLICATION_AS_SERVLET_NAME = Application.class.getName();
 
-    private static final String FACES_SERVLET_NAME = RestServlet.class.getName();
+    private static final String REST_SERVLET_NAME = GeronimoRestServlet.class.getName();
 
-    /*public static final EARContext.Key<Set<ConfigurationResource>> JSF_META_INF_CONFIGURATION_RESOURCES
= new EARContext.Key<Set<ConfigurationResource>>() {
+    public static final EARContext.Key<Set<Class<? extends Application>>>
JAXRS_APPLICATION_SUBCLASSES = new EARContext.Key<Set<Class<? extends Application>>>()
{
 
         @Override
-        public Set<ConfigurationResource> get(Map<EARContext.Key, Object> context)
{
-            return (Set<ConfigurationResource>) context.get(this);
+        public Set<Class<? extends Application>> get(Map<EARContext.Key, Object>
context) {
+            return (Set<Class<? extends Application>>) context.get(this);
         }
-    };*/
+    };
+
+    /*
+     * public static final EARContext.Key<Set<Resource>> JSF_FACELET_CONFIG_RESOURCES
= new
+     * EARContext.Key<Set<ConfigurationResource>>() {
+     * 
+     * @Override public Set<ConfigurationResource> get(Map<EARContext.Key, Object>
context) { return
+     * (Set<ConfigurationResource>) context.get(this); } };
+     */
 
-    public WinkModuleBuilderExtension(@ParamAttribute(name = "defaultEnvironment") Environment
defaultEnvironment,
+    public WinkModuleBuilderExtension(
+            @ParamAttribute(name = "defaultEnvironment") Environment defaultEnvironment,
             @ParamReference(name = "NamingBuilders", namingType = NameFactory.MODULE_BUILDER)
NamingBuilder namingBuilders) {
         this.defaultEnvironment = defaultEnvironment;
         this.namingBuilders = namingBuilders;
     }
 
-    public void createModule(Module module, Bundle bundle, Naming naming, ModuleIDBuilder
idBuilder) throws DeploymentException {
+    public void createModule(Module module, Bundle bundle, Naming naming, ModuleIDBuilder
idBuilder)
+            throws DeploymentException {
         mergeEnvironment(module);
     }
 
-    public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath,
URL specDDUrl, Environment environment, Object moduleContextInfo, AbstractName earName, Naming
naming,
+    public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath,
URL specDDUrl,
+            Environment environment, Object moduleContextInfo, AbstractName earName, Naming
naming,
             ModuleIDBuilder idBuilder) throws DeploymentException {
+
         mergeEnvironment(module);
     }
 
     private void mergeEnvironment(Module module) {
         if (!(module instanceof WebModule)) {
-            //not a web module, nothing to do
+            // not a web module, nothing to do
             return;
         }
         WebModule webModule = (WebModule) module;
         WebApp webApp = webModule.getSpecDD();
-        if (!hasRestServlet(webApp)) {
-            return;
-        }
 
         EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), defaultEnvironment);
     }
 
-    public void installModule(JarFile earFile, EARContext earContext, Module module, Collection
configurationStores, ConfigurationStore targetConfigurationStore, Collection repository)
-            throws DeploymentException {
+    public void installModule(JarFile earFile, EARContext earContext, Module module, Collection
configurationStores,
+            ConfigurationStore targetConfigurationStore, Collection repository) throws DeploymentException
{
         if (!(module instanceof WebModule)) {
             return;
         }
-        
-        //module.getEarContext().getGeneralData().put(JSF_META_INF_CONFIGURATION_RESOURCES,
findMetaInfConfigurationResources(earContext, module));
     }
 
+    @SuppressWarnings("unchecked")
     public void initContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException
{
-    }
 
-    public void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection
repository) throws DeploymentException {
         if (!(module instanceof WebModule)) {
-            //not a web module, nothing to do
+            // not a web module, nothing to do
             return;
         }
+
         WebModule webModule = (WebModule) module;
         WebApp webApp = webModule.getSpecDD();
-        if (!hasRestServlet(webApp)) {
+
+        ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
+
+        Set<Class<? extends Application>> applicationClasses = new HashSet<Class<?
extends Application>>();
+
+        try {
+            PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
+
+            BundleClassFinder bundleClassFinder = new BundleAssignableClassFinder(packageAdmin,
bundle,
+                    new Class<?>[] { Application.class }, new ClassDiscoveryFilter()
{
+
+                        @Override
+                        public boolean directoryDiscoveryRequired(String directory) {
+                            return true;
+                        }
+
+                        @Override
+                        public boolean jarFileDiscoveryRequired(String jarUrl) {
+                            return true;
+                        }
+
+                        @Override
+                        public boolean packageDiscoveryRequired(String packageName) {
+                            return true;
+                        }
+
+                        @Override
+                        public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange)
{
+                            return discoveryRange.equals(DiscoveryRange.BUNDLE_CLASSPATH);
+                        }
+                    });
+
+            Set<String> classes = bundleClassFinder.find();
+
+            for (String clazz : classes) {
+                applicationClasses.add((Class<Application>) bundle.loadClass(clazz));
+            }
+
+        } catch (Exception e) {
+            throw new DeploymentException("Fail to scan javax.ws.rs.core.Application sub
classes in application", e);
+        } finally {
+            bundle.getBundleContext().ungetService(reference);
+        }
+
+        // JAX-RS specific code here to initialize the runtime and setup the mapping etc.
+
+        // there's no Application sub classes found
+        if (applicationClasses == null || applicationClasses.size() == 0) {
+
+            /*
+             * TODO jaxrs 1.1 spec section 2.3.2 If no Application subclass is present the
added servlet MUST be named ...
+             */
+
+
             return;
         }
 
-        EARContext moduleContext = module.getEarContext();
-        Map sharedContext = module.getSharedContext();
-        //add the ServletContextListener to the web app context
-        GBeanData webAppData = (GBeanData) sharedContext.get(WebModule.WEB_APP_DATA);
-        // add myfaces listener
-        WebAppInfo webAppInfo = (WebAppInfo) webAppData.getAttribute("webAppInfo");
+        /*
+         *  jaxrs 1.1 spec section 2.3.2 If an Application subclass is present and there
is already a servlet defined that has a servlet initialization
+         * ...
+         */
+        Class<? extends Application> applicationClass;
+
+        BundleClassLoader bundleClassLoader = new BundleClassLoader(bundle);
+
+        for (Servlet servlet : webApp.getServlet()) {
+
+            List<ParamValue> params = servlet.getInitParam();
+
+            for (ParamValue parm : params) {
+
+                if (parm.getParamName().trim().equals("javax.ws.rs.Application")) {
+
+                    for (Class<? extends Application> clazz : applicationClasses) {
+
+                        if (clazz.getName().equalsIgnoreCase(parm.getParamValue().trim()))
{
+
+                            applicationClass = clazz;
+                            
+                            Class servletClass=null;
+                            
+                            try {
+                                bundleClassLoader.loadClass(servlet.getServletClass());
+                            } catch (ClassNotFoundException e) {
+                                log.warn("failed to load servlet class:"+servlet.getServletClass());
+                            }
+                            
+                            if ((servletClass==null)||!servletClass.isAssignableFrom(HttpServlet.class)){
+                                
+                                servlet.setServletClass(REST_SERVLET_NAME);
+                            }
+                            
+
+                            ParamValue paramDeploymentConfig = new ParamValue();
+                            paramDeploymentConfig.setParamName("deploymentConfiguration");
+                            paramDeploymentConfig.setParamValue(GeronimoWinkDeloymentConfiguration.class.getName());
+                            servlet.getInitParam().add(paramDeploymentConfig);
+
+                            return;
+                        }
+                    }
+
+                }
+
+            }
+
+        }
+
+
+
+        /*
+         * jaxrs 1.1 spec section 2.3.2 If an Application subclass is present ...
+         *  
+         *  
+         * TODO It is an error for more than one application to be deployed at the same effective
servlet mapping
+         */
+
         
+       
+
+        applicationClass = applicationClasses.iterator().next();
+
+        Servlet restServletInfo = new Servlet();
+        restServletInfo.setServletClass(REST_SERVLET_NAME);
+        restServletInfo.setServletName(REST_SERVLET_NAME);
+
+        ParamValue paramApplication = new ParamValue();
+        paramApplication.setParamName("javax.ws.rs.Application");
+        paramApplication.setParamValue(applicationClass.getName());
+        restServletInfo.getInitParam().add(paramApplication);
 
-        AbstractName moduleName = moduleContext.getModuleName();
-        Map<EARContext.Key, Object> buildingContext = new HashMap<EARContext.Key,
Object>();
-        buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);
+        ParamValue paramDeploymentConfig = new ParamValue();
+        paramDeploymentConfig.setParamName("deploymentConfiguration");
+        paramDeploymentConfig.setParamValue(GeronimoWinkDeloymentConfiguration.class.getName());
 
-        //use the same holder object as the web app.
-        Holder holder = NamingBuilder.INJECTION_KEY.get(sharedContext);
-        buildingContext.put(NamingBuilder.INJECTION_KEY, holder);
+        restServletInfo.getInitParam().add(paramDeploymentConfig);
+
+        if (applicationClass.isAnnotationPresent(ApplicationPath.class)) {
+
+            ApplicationPath ap = applicationClass.getAnnotation(ApplicationPath.class);
+
+            String mapping = ap.value();
+
+            if (!mapping.startsWith("/") || !mapping.startsWith("*.")) {
+
+                mapping = "/" + mapping;
+            }
+
+            if (!mapping.endsWith("/*")) {
+
+                if (mapping.endsWith("/"))
+                    mapping = mapping + "*";
+                else {
+                    mapping = mapping + "/*";
+                }
+            }
+            
+            ServletMapping restServletMapping=new ServletMapping();
+            restServletMapping.setServletName(REST_SERVLET_NAME);
+            restServletMapping.getUrlPattern().add(mapping);
+            webApp.getServletMapping().add(restServletMapping);
+
+
+        } 
+        
+        webApp.getServlet().add(restServletInfo);
 
-        XmlObject jettyWebApp = webModule.getVendorDD();
 
     }
 
-   
+    public void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection
repository)
+            throws DeploymentException {
+
+    }
 
-    protected ClassFinder createWinkClassFinder(List<FacesConfig> facesConfigs, Set<Class>
annotatedManagedBeanClasses, Bundle bundle) throws DeploymentException {
+    protected ClassFinder createWinkClassFinder(List<FacesConfig> facesConfigs, Set<Class>
annotatedJAXRSClasses,
+            Bundle bundle) throws DeploymentException {
         List<Class> managedBeanClasses = new ArrayList<Class>();
         for (FacesConfig facesConfig : facesConfigs) {
             for (FacesManagedBean managedBean : facesConfig.getManagedBean()) {
@@ -172,8 +339,8 @@ public class WinkModuleBuilderExtension 
                 }
             }
         }
-        if (annotatedManagedBeanClasses != null) {
-            for (Class<?> clas : annotatedManagedBeanClasses) {
+        if (annotatedJAXRSClasses != null) {
+            for (Class<?> clas : annotatedJAXRSClasses) {
                 while (clas != null) {
                     managedBeanClasses.add(clas);
                     clas = clas.getSuperclass();
@@ -183,10 +350,10 @@ public class WinkModuleBuilderExtension 
         return new ClassFinder(managedBeanClasses);
     }
 
-
-    private boolean hasRestServlet(WebApp webApp) {
+    private boolean hasRestApplicationAsServlet(WebApp webApp) {
         for (Servlet servlet : webApp.getServlet()) {
-            if (servlet.getServletClass() != null && FACES_SERVLET_NAME.equals(servlet.getServletClass().trim()))
{
+            if (servlet.getServletClass() != null
+                    && REST_APPLICATION_AS_SERVLET_NAME.equals(servlet.getServletClass().trim()))
{
                 return true;
             }
         }

Added: geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java?rev=1057102&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java
(added)
+++ geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoRestServlet.java
Mon Jan 10 07:54:21 2011
@@ -0,0 +1,126 @@
+/*
+ * 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.geronimo.wink;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.Application;
+
+import org.apache.wink.common.internal.i18n.Messages;
+import org.apache.wink.common.internal.lifecycle.ObjectFactory;
+import org.apache.wink.common.internal.utils.ClassUtils;
+import org.apache.wink.server.internal.DeploymentConfiguration;
+import org.apache.wink.server.internal.RequestProcessor;
+import org.apache.wink.server.internal.servlet.RestServlet;
+import org.apache.xbean.osgi.bundle.util.BundleClassLoader;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GeronimoRestServlet extends RestServlet {
+    
+
+    private static final String DEPLOYMENT_CONF_PARAM = "deploymentConfiguration";
+
+    private static final Logger logger               =
+                                                         LoggerFactory
+                                                             .getLogger(GeronimoRestServlet.class);
+
+    private static final long   serialVersionUID     = -1920970727031271538L;
+
+    @Override
+    protected DeploymentConfiguration createDeploymentConfiguration()
+        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+       
+        DeploymentConfiguration deploymentConfiguration=null;
+        BundleContext bundleContext = (BundleContext) this.getServletContext().getAttribute("osgi-bundlecontext");
+        ClassLoader deploymentClassLoader = new BundleClassLoader(bundleContext.getBundle());
+        ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(deploymentClassLoader);
+            deploymentConfiguration=super.createDeploymentConfiguration();
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldContextClassLoader);
+        }
+
+        return deploymentConfiguration;
+        
+    }
+    
+    @Override
+    protected RequestProcessor createRequestProcessor() throws ClassNotFoundException,
+    InstantiationException, IllegalAccessException, IOException {
+    
+        RequestProcessor requestProcessor=null;
+        BundleContext bundleContext = (BundleContext) this.getServletContext().getAttribute("osgi-bundlecontext");
+        ClassLoader deploymentClassLoader = new BundleClassLoader(bundleContext.getBundle());
+        ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(deploymentClassLoader);
+            requestProcessor=super.createRequestProcessor();
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldContextClassLoader);
+        }
+
+        return requestProcessor;
+    }
+    
+    
+    
+    @SuppressWarnings("unchecked")
+    @Override
+    protected Application getApplication(DeploymentConfiguration configuration) throws ClassNotFoundException,
+            InstantiationException, IllegalAccessException {
+        
+        Class<? extends Application> appClass = null;
+        String initParameter = getInitParameter(APPLICATION_INIT_PARAM);
+        if (initParameter != null) {
+            if (logger.isInfoEnabled()) {
+                logger.info(Messages.getMessage("restServletJAXRSApplicationInitParam", //$NON-NLS-1$
+                        initParameter, APPLICATION_INIT_PARAM));
+            }
+            
+            BundleContext bundleContext = (BundleContext) this.getServletContext().getAttribute("osgi-bundlecontext");
+            ClassLoader deploymentClassLoader = new BundleClassLoader(bundleContext.getBundle());
+            ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
+            try {
+                Thread.currentThread().setContextClassLoader(deploymentClassLoader);
+                appClass = (Class<? extends Application>) ClassUtils.loadClass(initParameter);
+            } finally {
+                Thread.currentThread().setContextClassLoader(oldContextClassLoader);
+            }
+
+            // let the lifecycle manager create the instance and process fields
+            // for injection
+            ObjectFactory<? extends Application> of = configuration.getOfFactoryRegistry().getObjectFactory(appClass);
+            configuration.addApplicationObjectFactory(of);
+
+            return of.getInstance(null);
+            
+        } else {
+
+            throw new IllegalAccessException("Can find init parameter: " + APPLICATION_INIT_PARAM
+ " for rest servelt");
+
+        }
+
+        
+    }
+
+}

Added: geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java?rev=1057102&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java
(added)
+++ geronimo/server/trunk/plugins/wink/geronimo-wink/src/main/java/org/apache/geronimo/wink/GeronimoWinkDeloymentConfiguration.java
Mon Jan 10 07:54:21 2011
@@ -0,0 +1,12 @@
+package org.apache.geronimo.wink;
+
+
+
+import org.apache.wink.server.internal.DeploymentConfiguration;
+
+public class GeronimoWinkDeloymentConfiguration extends DeploymentConfiguration {
+    
+    
+    /* TODO: add EJB,OWB beans support for wink integration*/
+
+}

Modified: geronimo/server/trunk/plugins/wink/wink-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wink/wink-deployer/src/main/plan/plan.xml?rev=1057102&r1=1057101&r2=1057102&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wink/wink-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/wink/wink-deployer/src/main/plan/plan.xml Mon Jan 10 07:54:21
2011
@@ -21,7 +21,6 @@
 <module xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
 
     <gbean name="WinkModuleBuilderExtension" class="org.apache.geronimo.wink.deployment.WinkModuleBuilderExtension">
-        <attribute name="providerFactoryNameQuery">?name=WinkLifecycleProviderFactory#org.apache.geronimo.wink.LifecycleProviderFactoryGBean</attribute>
         <reference name="NamingBuilders">
             <name>NamingBuilders</name>
         </reference>
@@ -35,8 +34,13 @@
                         <type>car</type>
                     </dependency>
                 </dependencies>
-                <!-- This is a workaround for wired bundle cache in the BundleClassloader,
add the import package explicitly to make sure the myface-core-impl is wired immediately the
application bundle is resolved -->
-                <import-package>org.apache.Wink.ee6</import-package>
+                <!--
+                This is a workaround for wired bundle cache in the BundleClassloader,
+                add the import package explicitly to make sure the wink-common and wink-server
+                are wired immediately the application bundle is resolved
+                -->
+                <import-package>org.apache.wink.server.internal.resources</import-package>
+                <import-package>org.apache.wink.common.internal.runtime</import-package>
                 
             </environment>
         </xml-attribute>
     </gbean>

Modified: geronimo/server/trunk/plugins/wink/wink-tomcat-server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wink/wink-tomcat-server/pom.xml?rev=1057102&r1=1057101&r2=1057102&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wink/wink-tomcat-server/pom.xml (original)
+++ geronimo/server/trunk/plugins/wink/wink-tomcat-server/pom.xml Mon Jan 10 07:54:21 2011
@@ -79,12 +79,12 @@
     </plugins>
   </build>
   <dependencies>
-    <dependency>
-      <groupId>org.apache.geronimo.framework</groupId>
-      <artifactId>karaf-framework</artifactId>
-      <version>${project.version}</version>
-      <type>car</type>
-    </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.framework.plugingroups</groupId>
+            <artifactId>framework</artifactId>
+            <version>${project.version}</version>
+            <type>car</type>
+        </dependency>
     <dependency>
       <groupId>org.apache.geronimo.configs</groupId>
       <artifactId>tomcat7</artifactId>



Mime
View raw message