geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r500352 - /geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/
Date Fri, 26 Jan 2007 21:18:29 GMT
Author: dims
Date: Fri Jan 26 13:18:28 2007
New Revision: 500352

URL: http://svn.apache.org/viewvc?view=rev&rev=500352
Log:
Fix for GERONIMO-2781 - Improved CXF-based POJO WebService support

Added:
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationException.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationHandler.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationProcessor.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/EJBAnnotationHandler.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectingAnnotationHandler.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectionException.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/ResourceAnnotationHandler.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/WebServiceRefAnnotationHandler.java

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationException.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationException.java?view=auto&rev=500352
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationException.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationException.java Fri Jan 26 13:18:28 2007
@@ -0,0 +1,111 @@
+/**
+ *  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.cxf.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);
+    }
+
+}
+/**
+ *  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.cxf.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);
+    }
+
+}
+/**
+ *  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.cxf.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/cxf/annotations/AnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationHandler.java?view=auto&rev=500352
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationHandler.java Fri Jan 26 13:18:28 2007
@@ -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.cxf.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;
+
+}
+/**
+ *  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.cxf.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;
+
+}
+/**
+ *  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.cxf.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/cxf/annotations/AnnotationProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationProcessor.java?view=auto&rev=500352
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationProcessor.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationProcessor.java Fri Jan 26 13:18:28 2007
@@ -0,0 +1,480 @@
+/**
+ *  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.cxf.annotations;
+
+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;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+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);
+            }
+        }
+    }
+
+}
+/**
+ *  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.cxf.annotations;
+
+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;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+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);
+            }
+        }
+    }
+
+}
+/**
+ *  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.cxf.annotations;
+
+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;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+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/cxf/annotations/EJBAnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/EJBAnnotationHandler.java?view=auto&rev=500352
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/EJBAnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/EJBAnnotationHandler.java Fri Jan 26 13:18:28 2007
@@ -0,0 +1,141 @@
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.ejb.EJB;
+
+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);
+    }
+
+}
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.ejb.EJB;
+
+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);
+    }
+
+}
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.ejb.EJB;
+
+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/cxf/annotations/InjectingAnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectingAnnotationHandler.java?view=auto&rev=500352
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectingAnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectingAnnotationHandler.java Fri Jan 26 13:18:28 2007
@@ -0,0 +1,372 @@
+/**
+ *  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.cxf.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);
+        }
+    }
+
+}
+/**
+ *  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.cxf.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);
+        }
+    }
+
+}
+/**
+ *  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.cxf.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/cxf/annotations/InjectionException.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectionException.java?view=auto&rev=500352
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectionException.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectionException.java Fri Jan 26 13:18:28 2007
@@ -0,0 +1,111 @@
+/**
+ *  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.cxf.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);
+    }
+
+}
+/**
+ *  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.cxf.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);
+    }
+
+}
+/**
+ *  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.cxf.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/cxf/annotations/ResourceAnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/ResourceAnnotationHandler.java?view=auto&rev=500352
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/ResourceAnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/ResourceAnnotationHandler.java Fri Jan 26 13:18:28 2007
@@ -0,0 +1,150 @@
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.annotation.Resource;
+
+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());
+    }
+
+}
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.annotation.Resource;
+
+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());
+    }
+
+}
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.annotation.Resource;
+
+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/cxf/annotations/WebServiceRefAnnotationHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/WebServiceRefAnnotationHandler.java?view=auto&rev=500352
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/WebServiceRefAnnotationHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/WebServiceRefAnnotationHandler.java Fri Jan 26 13:18:28 2007
@@ -0,0 +1,150 @@
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.xml.ws.WebServiceRef;
+
+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());
+    }
+
+}
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.xml.ws.WebServiceRef;
+
+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());
+    }
+
+}
+/**
+ *  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.cxf.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.xml.ws.WebServiceRef;
+
+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