Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 14722 invoked from network); 26 Jan 2007 21:49:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jan 2007 21:49:09 -0000 Received: (qmail 81521 invoked by uid 500); 26 Jan 2007 21:49:14 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 81489 invoked by uid 500); 26 Jan 2007 21:49:14 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 81478 invoked by uid 99); 26 Jan 2007 21:49:14 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jan 2007 13:49:14 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jan 2007 13:49:06 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id BA20F1A981A; Fri, 26 Jan 2007 13:48:46 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r500369 - /geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/ Date: Fri, 26 Jan 2007 21:48:46 -0000 To: scm@geronimo.apache.org From: dims@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070126214846.BA20F1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dims Date: Fri Jan 26 13:48:45 2007 New Revision: 500369 URL: http://svn.apache.org/viewvc?view=rev&rev=500369 Log: remove duplicates Modified: 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 Modified: 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=diff&rev=500369&r1=500368&r2=500369 ============================================================================== --- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationException.java (original) +++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationException.java Fri Jan 26 13:48:45 2007 @@ -35,77 +35,3 @@ } } -/** - * 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); - } - -} Modified: 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=diff&rev=500369&r1=500368&r2=500369 ============================================================================== --- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationHandler.java (original) +++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationHandler.java Fri Jan 26 13:48:45 2007 @@ -40,87 +40,3 @@ 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 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 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; - -} Modified: 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=diff&rev=500369&r1=500368&r2=500369 ============================================================================== --- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationProcessor.java (original) +++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/AnnotationProcessor.java Fri Jan 26 13:48:45 2007 @@ -158,323 +158,3 @@ } } -/** - * 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, AnnotationHandler> handlers; - - public AnnotationProcessor() { - this.handlers = new HashMap, 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 getMethods(Class target, - Class annotationType) { - Collection methods = new HashSet(); - addMethods(target.getMethods(), annotationType, methods); - addMethods(target.getDeclaredMethods(), annotationType, methods); - return methods; - } - - private void addMethods(Method[] methods, - Class annotationType, - Collection 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, AnnotationHandler> handlers; - - public AnnotationProcessor() { - this.handlers = new HashMap, 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 getMethods(Class target, - Class annotationType) { - Collection methods = new HashSet(); - addMethods(target.getMethods(), annotationType, methods); - addMethods(target.getDeclaredMethods(), annotationType, methods); - return methods; - } - - private void addMethods(Method[] methods, - Class annotationType, - Collection methodsCol) { - for (Method method : methods) { - if (method.isAnnotationPresent(annotationType)) { - methodsCol.add(method); - } - } - } - -} Modified: 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=diff&rev=500369&r1=500368&r2=500369 ============================================================================== --- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/EJBAnnotationHandler.java (original) +++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/EJBAnnotationHandler.java Fri Jan 26 13:48:45 2007 @@ -45,97 +45,3 @@ } } -/** - * 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 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 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); - } - -} Modified: 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=diff&rev=500369&r1=500368&r2=500369 ============================================================================== --- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectingAnnotationHandler.java (original) +++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectingAnnotationHandler.java Fri Jan 26 13:48:45 2007 @@ -122,251 +122,3 @@ } } -/** - * 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); - } - } - -} Modified: 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=diff&rev=500369&r1=500368&r2=500369 ============================================================================== --- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectionException.java (original) +++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/InjectionException.java Fri Jan 26 13:48:45 2007 @@ -35,77 +35,3 @@ } } -/** - * 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); - } - -} Modified: 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=diff&rev=500369&r1=500368&r2=500369 ============================================================================== --- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/ResourceAnnotationHandler.java (original) +++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/ResourceAnnotationHandler.java Fri Jan 26 13:48:45 2007 @@ -48,103 +48,3 @@ } } -/** - * 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 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 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()); - } - -} Modified: 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=diff&rev=500369&r1=500368&r2=500369 ============================================================================== --- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/WebServiceRefAnnotationHandler.java (original) +++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/annotations/WebServiceRefAnnotationHandler.java Fri Jan 26 13:48:45 2007 @@ -48,103 +48,3 @@ } } -/** - * 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 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 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()); - } - -}