geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r501187 - in /geronimo/server/trunk/modules: geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/ geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/ geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/buil...
Date Mon, 29 Jan 2007 21:40:41 GMT
Author: dims
Date: Mon Jan 29 13:40:39 2007
New Revision: 501187

URL: http://svn.apache.org/viewvc?view=rev&rev=501187
Log:
Move common code out to a jaxws package. Looks like we need a new maven2 module for all the common jaxws code. That will be the next step

Added:
    geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/
    geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/builder/
    geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JAXWSAnnotationProcessor.java
      - copied, changed from r501062, geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFAnnotationProcessor.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JNDIResolver.java
      - copied, changed from r501062, geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResolver.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/PortInfo.java   (contents, props changed)
      - copied, changed from r501062, geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationException.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationHandler.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationProcessor.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/EJBAnnotationHandler.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectingAnnotationHandler.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectionException.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/ResourceAnnotationHandler.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/WebServiceRefAnnotationHandler.java
Removed:
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFAnnotationProcessor.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResolver.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/
Modified:
    geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFServiceConfiguration.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java

Modified: geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java?view=diff&rev=501187&r1=501186&r2=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java Mon Jan 29 13:40:39 2007
@@ -16,207 +16,52 @@
  */
 package org.apache.geronimo.cxf.builder;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.FileNotFoundException;
-import java.lang.reflect.Modifier;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Collections;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import javax.jws.WebService;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.ws.WebServiceProvider;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.cxf.jaxws.javaee.PortComponentType;
 import org.apache.cxf.jaxws.javaee.ServiceImplBeanType;
 import org.apache.cxf.jaxws.javaee.WebserviceDescriptionType;
 import org.apache.cxf.jaxws.javaee.WebservicesType;
-
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
-import org.apache.geronimo.j2ee.deployment.WebModule;
-import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.cxf.PortInfo;
-import org.apache.geronimo.cxf.CXFWebServiceContainerFactoryGBean;
-import org.apache.geronimo.kernel.classloader.JarFileClassLoader;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.deployment.DeploymentContext;
-import org.apache.geronimo.deployment.service.EnvironmentBuilder;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
-import org.apache.xbean.finder.ClassFinder;
+import org.apache.geronimo.jaxws.builder.JAXWSServiceBuilder;
+import org.apache.geronimo.cxf.CXFWebServiceContainerFactoryGBean;
 
-public class CXFBuilder implements WebServiceBuilder {
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.jar.JarFile;
 
+public class CXFBuilder extends JAXWSServiceBuilder {
     private static final Log LOG = LogFactory.getLog(CXFBuilder.class);
 
-    private final Environment defaultEnvironment;
-
-    private static final String KEY = CXFBuilder.class.getName();
-
     public CXFBuilder(Environment defaultEnvironment) {
-        this.defaultEnvironment = defaultEnvironment;
-    }
-
-    public void findWebServices(JarFile moduleFile,
-                                boolean isEJB,
-                                Map servletLocations,
-                                Environment environment,
-                                Map sharedContext) throws DeploymentException {
-        Map portMap = null;
-        String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml";
-        try {
-            URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, path);
-            InputStream in = wsDDUrl.openStream();
-            portMap = parseWebServiceDescriptor(in, wsDDUrl, moduleFile, isEJB, servletLocations);
-        } catch (IOException e) {
-            // webservices.xml does not exist, search classes for annotations
-            portMap = discoverWebServices(moduleFile, isEJB, servletLocations);
-        }
-
-        if (portMap != null) {
-            EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
-            sharedContext.put(KEY, portMap);
-        }
-
-    }
-
-    private Map<String, PortInfo> discoverWebServices(JarFile moduleFile,
-                                                      boolean isEJB,
-                                                      Map correctedPortLocations)
-            throws DeploymentException {
-        LOG.debug("Discovering web service classes");
-
-        File tmpDir = null;
-        List<URL> urlList = new ArrayList<URL>();
-        if (isEJB) {
-            File jarFile = new File(moduleFile.getName());
-            try {
-                urlList.add(jarFile.toURL());
-            } catch (MalformedURLException e) {
-                // this should not happen
-                throw new DeploymentException();
-            }
-        } else {
-            /*
-             * Can't get ClassLoader to load nested Jar files, so
-             * unpack the module Jar file and discover all nested Jar files
-             * within it and the classes/ directory.
-             */
-            try {
-                tmpDir = DeploymentUtil.createTempDir();
-                /*
-                 * This is needed becuase DeploymentUtil.unzipToDirectory() 
-                 * always closes the passed JarFile.
-                 */
-                JarFile module = new JarFile(moduleFile.getName());
-                DeploymentUtil.unzipToDirectory(module, tmpDir);
-            } catch (IOException e) {
-                if (tmpDir != null) {
-                    DeploymentUtil.recursiveDelete(tmpDir);
-                }
-                throw new DeploymentException("Failed to expand the module archive", e);
-            }
-            
-            // create URL list 
-            Enumeration<JarEntry> jarEnum = moduleFile.entries();
-            while (jarEnum.hasMoreElements()) {
-                JarEntry entry = jarEnum.nextElement();
-                String name = entry.getName();
-                if (name.equals("WEB-INF/classes/")) {
-                    // ensure it is first
-                    File classesDir = new File(tmpDir, "WEB-INF/classes/");
-                    try {
-                        urlList.add(0, classesDir.toURL());
-                    } catch (MalformedURLException e) {
-                        // this should not happen, ignore
-                    }
-                } else if (name.startsWith("WEB-INF/lib/")
-                        && name.endsWith(".jar")) {
-                    File jarFile = new File(tmpDir, name);                    
-                    try {
-                        urlList.add(jarFile.toURL());
-                    } catch (MalformedURLException e) {
-                        // this should not happen, ignore
-                    }
-                }
-            }               
-        }
-
-        URL[] urls = urlList.toArray(new URL[] {});
-        JarFileClassLoader tempClassLoader = new JarFileClassLoader(null, urls, this.getClass().getClassLoader());       
-        ClassFinder classFinder = new ClassFinder(tempClassLoader, urlList);
-
-        Map<String, PortInfo> map = null;
-        List<Class> classes = null;
-        
-        classes = classFinder.findAnnotatedClasses(WebService.class);        
-        map = updatePortMap(classes, map, correctedPortLocations);
-        classes = classFinder.findAnnotatedClasses(WebServiceProvider.class);
-        map = updatePortMap(classes, map, correctedPortLocations);
-               
-        tempClassLoader.destroy();
-        
-        if (tmpDir != null) {
-            DeploymentUtil.recursiveDelete(tmpDir);
-        }
-        
-        return map;
+        super(defaultEnvironment);
     }
 
-    private static Map<String, PortInfo> updatePortMap(List<Class> classes,
-                                                       Map<String, PortInfo> map,
-                                                       Map correctedPortLocations) {
-        for (Class clazz : classes) {
-            if (isProperWebService(clazz)) {
-                LOG.debug("Found web service class: " + clazz.getName());
-                if (map == null) {
-                    map = new HashMap<String, PortInfo>();
-                }
-                PortInfo portInfo = new PortInfo();
-                String location = (String) correctedPortLocations.get(clazz.getName());
-                portInfo.setLocation(location);
-                map.put(clazz.getName(), portInfo);
-            }
-        }
-        return map;
+    protected GBeanInfo getContainerFactoryGBeanInfo() {
+        return CXFWebServiceContainerFactoryGBean.GBEAN_INFO;
     }
 
-    private static boolean isProperWebService(Class clazz) {
-        int modifiers = clazz.getModifiers();
-        return (Modifier.isPublic(modifiers) && 
-                !Modifier.isFinal(modifiers) && 
-                !Modifier.isAbstract(modifiers));
-    }
-
-    private Map<String, PortInfo> parseWebServiceDescriptor(InputStream in,
-                                                            URL wsDDUrl,
-                                                            JarFile moduleFile,
-                                                            boolean isEJB,
-                                                            Map correctedPortLocations)
+    protected Map<String, PortInfo> parseWebServiceDescriptor(InputStream in,
+                                                              URL wsDDUrl,
+                                                              JarFile moduleFile,
+                                                              boolean isEJB,
+                                                              Map correctedPortLocations)
             throws DeploymentException {
 
         LOG.debug("Parsing descriptor " + wsDDUrl);
@@ -229,7 +74,7 @@
             Object obj = unmarshaller.unmarshal(new StreamSource(in), WebservicesType.class);
 
             if (obj instanceof JAXBElement) {
-                obj = ((JAXBElement)obj).getValue();
+                obj = ((JAXBElement) obj).getValue();
             }
 
             if (!(obj instanceof WebservicesType)) {
@@ -284,7 +129,7 @@
                         portInfo.setWsdlService(port.getWsdlService().getValue());
                     }
 
-                    String location = (String)correctedPortLocations.get(serviceLink);
+                    String location = (String) correctedPortLocations.get(serviceLink);
                     portInfo.setLocation(location);
 
                     if (map == null) {
@@ -320,78 +165,6 @@
             }
         }
         return in;
-    }
-
-    public boolean configurePOJO(GBeanData targetGBean,
-                                 String servletName,
-                                 Module module,
-                                 String seiClassName,
-                                 DeploymentContext context)
-            throws DeploymentException {
-        Map sharedContext = ((WebModule) module).getSharedContext();
-        Map portInfoMap = (Map) sharedContext.get(KEY);
-        if (portInfoMap == null) {
-            // not ours
-            return false;
-        }
-        PortInfo portInfo = (PortInfo) portInfoMap.get(servletName);
-        if (portInfo == null) {
-            // not ours
-            return false;
-        }
-
-        Map componentContext = null;
-        try {
-            GBeanData moduleGBean = context.getGBeanInstance(context.getModuleName());
-            componentContext = (Map)moduleGBean.getAttribute("componentContext");
-        } catch (GBeanNotFoundException e) {
-            LOG.warn("ModuleGBean not found. JNDI resource injection will not work.");
-        }
-
-        LOG.info("configuring POJO webservice: " + servletName + " sei: " + seiClassName);
-
-        // verify that the class is loadable
-        ClassLoader classLoader = context.getClassLoader();
-        loadSEI(seiClassName, classLoader);
-
-        AbstractName containerFactoryName = context.getNaming().createChildName(targetGBean.getAbstractName(), "cxfWebServiceContainerFactory", NameFactory.GERONIMO_SERVICE);
-        GBeanData containerFactoryData = new GBeanData(containerFactoryName, CXFWebServiceContainerFactoryGBean.GBEAN_INFO);
-        containerFactoryData.setAttribute("portInfo", portInfo);
-        containerFactoryData.setAttribute("endpointClassName", seiClassName);
-        containerFactoryData.setAttribute("componentContext", componentContext);
-        try {
-            context.addGBean(containerFactoryData);
-        } catch (GBeanAlreadyExistsException e) {
-            throw new DeploymentException("Could not add web service container factory gbean", e);
-        }
-
-        targetGBean.setReferencePattern("WebServiceContainerFactory", containerFactoryName);
-        // our web container does not use that property
-        targetGBean.setAttribute("pojoClassName", "java.lang.Object");
-
-        if (context instanceof EARContext) {
-            containerFactoryData.setReferencePattern("TransactionManager",
-                                                     ((EARContext)context).getTransactionManagerName());
-        }
-
-        return true;
-    }
-
-    public boolean configureEJB(GBeanData targetGBean,
-                                String ejbName,
-                                JarFile moduleFile,
-                                Map sharedContext,
-                                ClassLoader classLoader)
-            throws DeploymentException {
-        throw new DeploymentException("configureEJB NYI");
-    }
-
-    Class<?> loadSEI(String className, ClassLoader loader) throws DeploymentException {
-        try {
-            return loader.loadClass(className);
-        } catch (ClassNotFoundException ex) {
-            throw new DeploymentException("unable to load Service Endpoint Interface: " + className, ex);
-        }
     }
 
     public static final GBeanInfo GBEAN_INFO;

Added: geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,277 @@
+/**
+ *  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.jaxws.builder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.j2ee.deployment.EARContext;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.WebModule;
+import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.jaxws.PortInfo;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.classloader.JarFileClassLoader;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.xbean.finder.ClassFinder;
+
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceProvider;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+public abstract class JAXWSServiceBuilder implements WebServiceBuilder {
+    private static final Log LOG = LogFactory.getLog(JAXWSServiceBuilder.class);
+    protected final Environment defaultEnvironment;
+    private static final String KEY = JAXWSServiceBuilder.class.getName();
+
+    public JAXWSServiceBuilder(Environment defaultEnvironment) {
+        this.defaultEnvironment = defaultEnvironment;
+    }
+
+    public void findWebServices(JarFile moduleFile,
+                                boolean isEJB,
+                                Map servletLocations,
+                                Environment environment,
+                                Map sharedContext) throws DeploymentException {
+        Map portMap = null;
+        String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml";
+        try {
+            URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, path);
+            InputStream in = wsDDUrl.openStream();
+            portMap = parseWebServiceDescriptor(in, wsDDUrl, moduleFile, isEJB, servletLocations);
+        } catch (IOException e) {
+            // webservices.xml does not exist, search classes for annotations
+            portMap = discoverWebServices(moduleFile, isEJB, servletLocations);
+        }
+
+        if (portMap != null) {
+            EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+            sharedContext.put(KEY, portMap);
+        }
+
+    }
+
+    private Map<String, PortInfo> discoverWebServices(JarFile moduleFile,
+                                                      boolean isEJB,
+                                                      Map correctedPortLocations)
+            throws DeploymentException {
+        LOG.debug("Discovering web service classes");
+
+        File tmpDir = null;
+        List<URL> urlList = new ArrayList<URL>();
+        if (isEJB) {
+            File jarFile = new File(moduleFile.getName());
+            try {
+                urlList.add(jarFile.toURL());
+            } catch (MalformedURLException e) {
+                // this should not happen
+                throw new DeploymentException();
+            }
+        } else {
+            /*
+             * Can't get ClassLoader to load nested Jar files, so
+             * unpack the module Jar file and discover all nested Jar files
+             * within it and the classes/ directory.
+             */
+            try {
+                tmpDir = DeploymentUtil.createTempDir();
+                /*
+                 * This is needed becuase DeploymentUtil.unzipToDirectory()
+                 * always closes the passed JarFile.
+                 */
+                JarFile module = new JarFile(moduleFile.getName());
+                DeploymentUtil.unzipToDirectory(module, tmpDir);
+            } catch (IOException e) {
+                if (tmpDir != null) {
+                    DeploymentUtil.recursiveDelete(tmpDir);
+                }
+                throw new DeploymentException("Failed to expand the module archive", e);
+            }
+
+            // create URL list
+            Enumeration<JarEntry> jarEnum = moduleFile.entries();
+            while (jarEnum.hasMoreElements()) {
+                JarEntry entry = jarEnum.nextElement();
+                String name = entry.getName();
+                if (name.equals("WEB-INF/classes/")) {
+                    // ensure it is first
+                    File classesDir = new File(tmpDir, "WEB-INF/classes/");
+                    try {
+                        urlList.add(0, classesDir.toURL());
+                    } catch (MalformedURLException e) {
+                        // this should not happen, ignore
+                    }
+                } else if (name.startsWith("WEB-INF/lib/")
+                        && name.endsWith(".jar")) {
+                    File jarFile = new File(tmpDir, name);
+                    try {
+                        urlList.add(jarFile.toURL());
+                    } catch (MalformedURLException e) {
+                        // this should not happen, ignore
+                    }
+                }
+            }
+        }
+
+        URL[] urls = urlList.toArray(new URL[] {});
+        JarFileClassLoader tempClassLoader = new JarFileClassLoader(null, urls, this.getClass().getClassLoader());
+        ClassFinder classFinder = new ClassFinder(tempClassLoader, urlList);
+
+        Map<String, PortInfo> map = null;
+        List<Class> classes = null;
+
+        classes = classFinder.findAnnotatedClasses(WebService.class);
+        map = updatePortMap(classes, map, correctedPortLocations);
+        classes = classFinder.findAnnotatedClasses(WebServiceProvider.class);
+        map = updatePortMap(classes, map, correctedPortLocations);
+
+        tempClassLoader.destroy();
+
+        if (tmpDir != null) {
+            DeploymentUtil.recursiveDelete(tmpDir);
+        }
+
+        return map;
+    }
+
+    private static Map<String, PortInfo> updatePortMap(List<Class> classes,
+                                                       Map<String, PortInfo> map,
+                                                       Map correctedPortLocations) {
+        for (Class clazz : classes) {
+            if (isProperWebService(clazz)) {
+                LOG.debug("Found web service class: " + clazz.getName());
+                if (map == null) {
+                    map = new HashMap<String, PortInfo>();
+                }
+                PortInfo portInfo = new PortInfo();
+                String location = (String) correctedPortLocations.get(clazz.getName());
+                portInfo.setLocation(location);
+                map.put(clazz.getName(), portInfo);
+            }
+        }
+        return map;
+    }
+
+    private static boolean isProperWebService(Class clazz) {
+        int modifiers = clazz.getModifiers();
+        return (Modifier.isPublic(modifiers) &&
+                !Modifier.isFinal(modifiers) &&
+                !Modifier.isAbstract(modifiers));
+    }
+
+    protected abstract Map<String, PortInfo> parseWebServiceDescriptor(InputStream in,
+                                                            URL wsDDUrl,
+                                                            JarFile moduleFile,
+                                                            boolean isEJB,
+                                                            Map correctedPortLocations)
+            throws DeploymentException;
+
+    public boolean configurePOJO(GBeanData targetGBean,
+                                 String servletName,
+                                 Module module,
+                                 String seiClassName,
+                                 DeploymentContext context)
+            throws DeploymentException {
+        Map sharedContext = ((WebModule) module).getSharedContext();
+        Map portInfoMap = (Map) sharedContext.get(KEY);
+        if (portInfoMap == null) {
+            // not ours
+            return false;
+        }
+        PortInfo portInfo = (PortInfo) portInfoMap.get(servletName);
+        if (portInfo == null) {
+            // not ours
+            return false;
+        }
+
+        Map componentContext = null;
+        try {
+            GBeanData moduleGBean = context.getGBeanInstance(context.getModuleName());
+            componentContext = (Map)moduleGBean.getAttribute("componentContext");
+        } catch (GBeanNotFoundException e) {
+            LOG.warn("ModuleGBean not found. JNDI resource injection will not work.");
+        }
+
+        LOG.info("configuring POJO webservice: " + servletName + " sei: " + seiClassName);
+
+        // verify that the class is loadable
+        ClassLoader classLoader = context.getClassLoader();
+        loadSEI(seiClassName, classLoader);
+
+        AbstractName containerFactoryName = context.getNaming().createChildName(targetGBean.getAbstractName(), "cxfWebServiceContainerFactory", NameFactory.GERONIMO_SERVICE);
+        GBeanData containerFactoryData = new GBeanData(containerFactoryName, getContainerFactoryGBeanInfo());
+        containerFactoryData.setAttribute("portInfo", portInfo);
+        containerFactoryData.setAttribute("endpointClassName", seiClassName);
+        containerFactoryData.setAttribute("componentContext", componentContext);
+        try {
+            context.addGBean(containerFactoryData);
+        } catch (GBeanAlreadyExistsException e) {
+            throw new DeploymentException("Could not add web service container factory gbean", e);
+        }
+
+        targetGBean.setReferencePattern("WebServiceContainerFactory", containerFactoryName);
+        // our web container does not use that property
+        targetGBean.setAttribute("pojoClassName", "java.lang.Object");
+
+        if (context instanceof EARContext) {
+            containerFactoryData.setReferencePattern("TransactionManager",
+                                                     ((EARContext)context).getTransactionManagerName());
+        }
+
+        return true;
+    }
+
+    protected abstract GBeanInfo getContainerFactoryGBeanInfo();
+
+    public boolean configureEJB(GBeanData targetGBean,
+                                String ejbName,
+                                JarFile moduleFile,
+                                Map sharedContext,
+                                ClassLoader classLoader)
+            throws DeploymentException {
+        throw new DeploymentException("configureEJB NYI");
+    }
+
+    Class<?> loadSEI(String className, ClassLoader loader) throws DeploymentException {
+        try {
+            return loader.loadClass(className);
+        } catch (ClassNotFoundException ex) {
+            throw new DeploymentException("unable to load Service Endpoint Interface: " + className, ex);
+        }
+    }
+}

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java?view=diff&rev=501187&r1=501186&r2=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java Mon Jan 29 13:40:39 2007
@@ -53,8 +53,11 @@
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.AbstractBindingInfoFactoryBean;
-import org.apache.geronimo.cxf.annotations.AnnotationException;
-import org.apache.geronimo.cxf.annotations.AnnotationProcessor;
+import org.apache.geronimo.jaxws.annotations.AnnotationException;
+import org.apache.geronimo.jaxws.annotations.AnnotationProcessor;
+import org.apache.geronimo.jaxws.JNDIResolver;
+import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
+import org.apache.geronimo.jaxws.PortInfo;
 
 /*
  * This class somewhat replicates CXF Endpoint functionality but it is necessary
@@ -122,7 +125,7 @@
 
         JNDIResolver jndiResolver = (JNDIResolver) bus
                 .getExtension(JNDIResolver.class);
-        this.annotationProcessor = new CXFAnnotationProcessor(jndiResolver);
+        this.annotationProcessor = new JAXWSAnnotationProcessor(jndiResolver, new CXFWebServiceContext());
     }
 
     private URL getWsdlURL(URL configurationBaseUrl, String wsdlFile) {

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFServiceConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFServiceConfiguration.java?view=diff&rev=501187&r1=501186&r2=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFServiceConfiguration.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFServiceConfiguration.java Mon Jan 29 13:40:39 2007
@@ -23,6 +23,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.service.factory.AbstractServiceConfiguration;
+import org.apache.geronimo.jaxws.PortInfo;
 
 /**
  * Used to overwrite serviceName and portName values of WebService annotation.

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java?view=diff&rev=501187&r1=501186&r2=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java Mon Jan 29 13:40:39 2007
@@ -29,6 +29,8 @@
 import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
 
 import org.apache.geronimo.webservices.WebServiceContainer;
+import org.apache.geronimo.jaxws.JNDIResolver;
+import org.apache.geronimo.jaxws.PortInfo;
 import org.xmlsoap.schemas.wsdl.http.AddressType;
 
 import javax.wsdl.Definition;

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java?view=diff&rev=501187&r1=501186&r2=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java Mon Jan 29 13:40:39 2007
@@ -36,6 +36,7 @@
 import org.apache.geronimo.transaction.GeronimoUserTransaction;
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.WebServiceContainerFactory;
+import org.apache.geronimo.jaxws.PortInfo;
 
 /**
  * @version $Rev$ $Date$

Copied: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JAXWSAnnotationProcessor.java (from r501062, geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFAnnotationProcessor.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JAXWSAnnotationProcessor.java?view=diff&rev=501187&p1=geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFAnnotationProcessor.java&r1=501062&p2=geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JAXWSAnnotationProcessor.java&r2=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFAnnotationProcessor.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JAXWSAnnotationProcessor.java Mon Jan 29 13:40:39 2007
@@ -14,32 +14,33 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.geronimo.cxf;
+package org.apache.geronimo.jaxws;
 
-import java.lang.annotation.Annotation;
+import org.apache.geronimo.jaxws.annotations.AnnotationProcessor;
+import org.apache.geronimo.jaxws.annotations.EJBAnnotationHandler;
+import org.apache.geronimo.jaxws.annotations.InjectionException;
+import org.apache.geronimo.jaxws.annotations.ResourceAnnotationHandler;
+import org.apache.geronimo.jaxws.annotations.WebServiceRefAnnotationHandler;
 
 import javax.naming.NamingException;
 import javax.xml.ws.WebServiceContext;
+import java.lang.annotation.Annotation;
 
-import org.apache.geronimo.cxf.annotations.AnnotationProcessor;
-import org.apache.geronimo.cxf.annotations.EJBAnnotationHandler;
-import org.apache.geronimo.cxf.annotations.InjectionException;
-import org.apache.geronimo.cxf.annotations.ResourceAnnotationHandler;
-import org.apache.geronimo.cxf.annotations.WebServiceRefAnnotationHandler;
-
-public class CXFAnnotationProcessor extends AnnotationProcessor {
+public class JAXWSAnnotationProcessor extends AnnotationProcessor {
 
     private JNDIResolver jndiResolver;
+    private WebServiceContext context;
     
-    public CXFAnnotationProcessor(JNDIResolver jndiResolver) {
+    public JAXWSAnnotationProcessor(JNDIResolver jndiResolver, WebServiceContext context) {
         this.jndiResolver = jndiResolver;
+        this.context = context;
         
         // register @Resource annotation handler
-        registerHandler(new CXFResourceAnnotationHandler());
+        registerHandler(new JAXWSResourceAnnotationHandler());
         // register @EJB annotation handler
-        registerHandler(new CXFEJBAnnotationHandler());
+        registerHandler(new JAXWSEJBAnnotationHandler());
         // register @WebServiceRef annotation handler
-        registerHandler(new CXFWebServiceRefAnnotationHandler());
+        registerHandler(new JAXWSWebServiceRefAnnotationHandler());
     }
 
     private Object lookupJNDI(String name, Class<?> type)
@@ -51,21 +52,21 @@
         }
     }
 
-    private class CXFResourceAnnotationHandler extends
+    private class JAXWSResourceAnnotationHandler extends
             ResourceAnnotationHandler {
         public Object getAnnotationValue(Annotation annotation,
                                          String name,
                                          Class<?> type)
                 throws InjectionException {
             if (WebServiceContext.class.isAssignableFrom(type)) {
-                return type.cast(new CXFWebServiceContext());
+                return type.cast(context);
             } else {
                 return lookupJNDI(name, type);
             }
         }
     }
 
-    private class CXFEJBAnnotationHandler extends EJBAnnotationHandler {
+    private class JAXWSEJBAnnotationHandler extends EJBAnnotationHandler {
         public Object getAnnotationValue(Annotation annotation,
                                          String name,
                                          Class<?> type)
@@ -74,7 +75,7 @@
         }
     }
 
-    private class CXFWebServiceRefAnnotationHandler extends
+    private class JAXWSWebServiceRefAnnotationHandler extends
             WebServiceRefAnnotationHandler {
         public Object getAnnotationValue(Annotation annotation,
                                          String name,

Copied: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JNDIResolver.java (from r501062, geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResolver.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JNDIResolver.java?view=diff&rev=501187&p1=geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResolver.java&r1=501062&p2=geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JNDIResolver.java&r2=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResolver.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/JNDIResolver.java Mon Jan 29 13:40:39 2007
@@ -14,16 +14,15 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.geronimo.cxf;
+package org.apache.geronimo.jaxws;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.naming.java.RootContext;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-
-import org.apache.geronimo.naming.java.RootContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 public class JNDIResolver {
 

Copied: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/PortInfo.java (from r501062, geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/PortInfo.java?view=diff&rev=501187&p1=geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java&r1=501062&p2=geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/PortInfo.java&r2=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/PortInfo.java Mon Jan 29 13:40:39 2007
@@ -14,7 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.geronimo.cxf;
+package org.apache.geronimo.jaxws;
 
 import java.io.Serializable;
 import java.io.StringReader;

Propchange: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/PortInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationException.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationException.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationException.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationException.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,37 @@
+/**
+ *  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.jaxws.annotations;
+
+public class AnnotationException extends Exception {
+
+    public AnnotationException() {
+        super();
+    }
+
+    public AnnotationException(String message) {
+        super(message);
+    }
+
+    public AnnotationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public AnnotationException(Throwable cause) {
+        super(cause);
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationHandler.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationHandler.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,42 @@
+/**
+ *  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.jaxws.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public interface AnnotationHandler {
+
+    Class<? extends Annotation> getAnnotationType();
+
+    void processFieldAnnotation(Object instance,
+                                Field field,
+                                Annotation annotation)
+            throws AnnotationException;
+
+    void processMethodAnnotation(Object instance,
+                                 Method method,
+                                 Annotation annotation)
+            throws AnnotationException;
+
+    void processClassAnnotation(Object instance,
+                                Class clazz,
+                                Annotation annotation)
+            throws AnnotationException;
+
+}

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationProcessor.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationProcessor.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/AnnotationProcessor.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,159 @@
+/**
+ *  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.jaxws.annotations;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+public class AnnotationProcessor {
+
+    private static final Log LOG = LogFactory.getLog(AnnotationProcessor.class);
+
+    private Map<Class<? extends Annotation>, AnnotationHandler> handlers;
+
+    public AnnotationProcessor() {
+        this.handlers = new HashMap<Class<? extends Annotation>, AnnotationHandler>();
+    }
+
+    public void registerHandler(AnnotationHandler handler) {
+        this.handlers.put(handler.getAnnotationType(), handler);
+    }
+
+    public void processAnnotations(Object instance) throws AnnotationException {
+        // process class annotations
+        Class clazz = instance.getClass();
+        Iterator iter = this.handlers.entrySet().iterator();
+        while (iter.hasNext()) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            Class annotationType = (Class) entry.getKey();
+            AnnotationHandler handler = (AnnotationHandler) entry.getValue();
+
+            if (clazz.isAnnotationPresent(annotationType)) {
+                Annotation annotation = clazz.getAnnotation(annotationType);
+                handler.processClassAnnotation(instance, clazz, annotation);
+            }
+        }
+
+        // process fields annotations
+        Field[] fields = clazz.getDeclaredFields();
+        for (int i = 0; i < fields.length; i++) {
+            iter = this.handlers.entrySet().iterator();
+            while (iter.hasNext()) {
+                Map.Entry entry = (Map.Entry) iter.next();
+                Class annotationType = (Class) entry.getKey();
+                AnnotationHandler handler = (AnnotationHandler) entry
+                        .getValue();
+
+                if (fields[i].isAnnotationPresent(annotationType)) {
+                    Annotation annotation = fields[i]
+                            .getAnnotation(annotationType);
+                    handler.processFieldAnnotation(instance, fields[i],
+                            annotation);
+                }
+            }
+        }
+
+        // process method annotations
+        Method[] methods = clazz.getDeclaredMethods();
+        for (int i = 0; i < methods.length; i++) {
+            iter = this.handlers.entrySet().iterator();
+            while (iter.hasNext()) {
+                Map.Entry entry = (Map.Entry) iter.next();
+                Class annotationType = (Class) entry.getKey();
+                AnnotationHandler handler = (AnnotationHandler) entry
+                        .getValue();
+
+                if (methods[i].isAnnotationPresent(annotationType)) {
+                    Annotation annotation = methods[i]
+                            .getAnnotation(annotationType);
+                    handler.processMethodAnnotation(instance, methods[i],
+                            annotation);
+                }
+            }
+        }
+    }
+
+    public void invokePostConstruct(Object instance) {
+        for (Method method : getMethods(instance.getClass(),
+                PostConstruct.class)) {
+            PostConstruct pc = method.getAnnotation(PostConstruct.class);
+            if (pc != null) {
+                boolean accessible = method.isAccessible();
+                try {
+                    method.setAccessible(true);
+                    method.invoke(instance);
+                } catch (IllegalAccessException e) {
+                    LOG.warn("@PostConstruct method is not visible: " + method);
+                } catch (InvocationTargetException e) {
+                    LOG.warn("@PostConstruct method threw exception", e);
+                } finally {
+                    method.setAccessible(accessible);
+                }
+            }
+        }
+    }
+
+    public void invokePreDestroy(Object instance) {
+        for (Method method : getMethods(instance.getClass(), PreDestroy.class)) {
+            PreDestroy pc = method.getAnnotation(PreDestroy.class);
+            if (pc != null) {
+                boolean accessible = method.isAccessible();
+                try {
+                    method.setAccessible(true);
+                    method.invoke(instance);
+                } catch (IllegalAccessException e) {
+                    LOG.warn("@PreDestroy method is not visible: " + method);
+                } catch (InvocationTargetException e) {
+                    LOG.warn("@PreDestroy method threw exception", e);
+                } finally {
+                    method.setAccessible(accessible);
+                }
+            }
+        }
+    }
+
+    private Collection<Method> getMethods(Class target,
+                                          Class<? extends Annotation> annotationType) {
+        Collection<Method> methods = new HashSet<Method>();
+        addMethods(target.getMethods(), annotationType, methods);
+        addMethods(target.getDeclaredMethods(), annotationType, methods);
+        return methods;
+    }
+
+    private void addMethods(Method[] methods,
+                            Class<? extends Annotation> annotationType,
+                            Collection<Method> methodsCol) {
+        for (Method method : methods) {
+            if (method.isAnnotationPresent(annotationType)) {
+                methodsCol.add(method);
+            }
+        }
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/EJBAnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/EJBAnnotationHandler.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/EJBAnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/EJBAnnotationHandler.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,46 @@
+/**
+ *  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.jaxws.annotations;
+
+import javax.ejb.EJB;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public abstract class EJBAnnotationHandler extends InjectingAnnotationHandler {
+
+    public Class<? extends Annotation> getAnnotationType() {
+        return EJB.class;
+    }
+
+    public void processFieldAnnotation(Object instance,
+                                       Field field,
+                                       Annotation annotation)
+            throws InjectionException {
+        EJB resource = (EJB) annotation;
+        injectField(instance, field, annotation, resource.name(), null);
+    }
+
+    public void processMethodAnnotation(Object instance,
+                                        Method method,
+                                        Annotation annotation)
+            throws InjectionException {
+        EJB resource = (EJB) annotation;
+        injectMethod(instance, method, annotation, resource.name(), null);
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectingAnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectingAnnotationHandler.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectingAnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectingAnnotationHandler.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,124 @@
+/**
+ *  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.jaxws.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+// TODO: Check for static methods and fields. They are only allowed for client apps.
+public abstract class InjectingAnnotationHandler implements AnnotationHandler {
+
+    abstract public Object getAnnotationValue(Annotation annotation,
+                                              String name,
+                                              Class<?> type)
+            throws InjectionException;
+
+    public void processClassAnnotation(Object instance,
+                                       Class clazz,
+                                       Annotation annotation) {
+        // injection is not done for annotations at class level
+    }
+
+    public String getJNDIName(Object instance, String name, Field field) {
+        if (name != null && name.length() > 0) {
+            return name;
+        } else {
+            return instance.getClass().getName() + "/" + field.getName();
+        }
+    }
+
+    public String getJNDIName(Object instance, String name, Method method) {
+        if (name != null && name.length() > 0) {
+            return name;
+        } else {
+            String propName = method.getName();
+            propName = propName.substring(3);
+            propName = Character.toLowerCase(propName.charAt(0))
+                    + propName.substring(1);
+            return instance.getClass().getName() + "/" + propName;
+        }
+    }
+
+    public Class<?> getType(Class<?> type, Field field) {
+        return (type == null || Object.class == type) ? field.getType() : type;
+    }
+
+    public Class<?> getType(Class<?> type, Method method) {
+        return (type == null || Object.class == type) ? method
+                .getParameterTypes()[0] : type;
+    }
+
+    protected void injectField(Object instance,
+                               Field field,
+                               Annotation annotation,
+                               String name,
+                               Class<?> type) throws InjectionException {
+
+        String jndiName = getJNDIName(instance, name, field);
+
+        Object lookedupResource = getAnnotationValue(annotation, jndiName,
+                getType(type, field));
+
+        boolean accessibility = field.isAccessible();
+        try {
+            field.setAccessible(true);
+            field.set(instance, lookedupResource);
+        } catch (IllegalArgumentException e) {
+            throw new InjectionException("Field injection failed", e);
+        } catch (IllegalAccessException e) {
+            throw new InjectionException("Field injection failed", e);
+        } finally {
+            field.setAccessible(accessibility);
+        }
+    }
+
+    protected void injectMethod(Object instance,
+                                Method method,
+                                Annotation annotation,
+                                String name,
+                                Class<?> type) throws InjectionException {
+
+        if (!method.getName().startsWith("set")
+                || method.getParameterTypes().length != 1
+                || !method.getReturnType().equals(Void.class)) {
+            throw new IllegalArgumentException(
+                    "Invalid method resource injection annotation");
+        }
+
+        String jndiName = getJNDIName(instance, name, method);
+
+        Object lookedupResource = getAnnotationValue(annotation, jndiName,
+                getType(type, method));
+
+        boolean accessibility = method.isAccessible();
+        try {
+            method.setAccessible(true);
+            method.invoke(instance, lookedupResource);
+        } catch (IllegalArgumentException e) {
+            throw new InjectionException("Method injection failed", e);
+        } catch (IllegalAccessException e) {
+            throw new InjectionException("Method injection failed", e);
+        } catch (InvocationTargetException e) {
+            throw new InjectionException("Method injection failed", e);
+        } finally {
+            method.setAccessible(accessibility);
+        }
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectionException.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectionException.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectionException.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/InjectionException.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,37 @@
+/**
+ *  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.jaxws.annotations;
+
+public class InjectionException extends AnnotationException {
+
+    public InjectionException() {
+        super();
+    }
+
+    public InjectionException(String message) {
+        super(message);
+    }
+
+    public InjectionException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public InjectionException(Throwable cause) {
+        super(cause);
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/ResourceAnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/ResourceAnnotationHandler.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/ResourceAnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/ResourceAnnotationHandler.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,49 @@
+/**
+ *  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.jaxws.annotations;
+
+import javax.annotation.Resource;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public abstract class ResourceAnnotationHandler extends
+        InjectingAnnotationHandler {
+
+    public Class<? extends Annotation> getAnnotationType() {
+        return Resource.class;
+    }
+
+    public void processFieldAnnotation(Object instance,
+                                       Field field,
+                                       Annotation annotation)
+            throws InjectionException {
+        Resource resource = (Resource) annotation;
+        injectField(instance, field, annotation, resource.name(), resource
+                .type());
+    }
+
+    public void processMethodAnnotation(Object instance,
+                                        Method method,
+                                        Annotation annotation)
+            throws InjectionException {
+        Resource resource = (Resource) annotation;
+        injectMethod(instance, method, annotation, resource.name(), resource
+                .type());
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/WebServiceRefAnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/WebServiceRefAnnotationHandler.java?view=auto&rev=501187
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/WebServiceRefAnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/jaxws/annotations/WebServiceRefAnnotationHandler.java Mon Jan 29 13:40:39 2007
@@ -0,0 +1,49 @@
+/**
+ *  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.jaxws.annotations;
+
+import javax.xml.ws.WebServiceRef;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public abstract class WebServiceRefAnnotationHandler extends
+        InjectingAnnotationHandler {
+
+    public Class<? extends Annotation> getAnnotationType() {
+        return WebServiceRef.class;
+    }
+
+    public void processFieldAnnotation(Object instance,
+                                       Field field,
+                                       Annotation annotation)
+            throws InjectionException {
+        WebServiceRef resource = (WebServiceRef) annotation;
+        injectField(instance, field, annotation, resource.name(), resource
+                .type());
+    }
+
+    public void processMethodAnnotation(Object instance,
+                                        Method method,
+                                        Annotation annotation)
+            throws InjectionException {
+        WebServiceRef resource = (WebServiceRef) annotation;
+        injectMethod(instance, method, annotation, resource.name(), resource
+                .type());
+    }
+
+}



Mime
View raw message