[jbossws-commits] JBossWS SVN: r9707 - in common/trunk/src/main/java/org/jboss/wsf/common: javax and 2 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Apr 2 10:10:28 EDT 2009


Author: richard.opalka at jboss.com
Date: 2009-04-02 10:10:28 -0400 (Thu, 02 Apr 2009)
New Revision: 9707

Added:
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/AbstractPostConstructPreDestroyAnnotatedMethodFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionFieldFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionMethodFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PostConstructMethodFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PreDestroyMethodFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ReflectionUtils.java
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceFieldFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceMethodFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/AbstractAnnotatedClassProcessor.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/AbstractClassProcessor.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/AccessibleObjectProcessor.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/AccessibleObjectProcessorAdapter.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotatedFieldFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotatedMethodFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotationAware.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/ClassProcessor.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/FieldFinder.java
   common/trunk/src/main/java/org/jboss/wsf/common/reflection/MethodFinder.java
Modified:
   common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java
Log:
[JBWS-2074] implementing injection

Modified: common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java	2009-04-02 14:07:44 UTC (rev 9706)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
  * as indicated by the @author tags. See the copyright.txt file in the
  * distribution for a full listing of individual contributors.
  *
@@ -23,307 +23,298 @@
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.Collection;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
+import javax.naming.InitialContext;
 
 import org.jboss.logging.Logger;
-import org.jboss.util.NotImplementedException;
+import org.jboss.wsf.common.javax.finders.InjectionFieldFinder;
+import org.jboss.wsf.common.javax.finders.InjectionMethodFinder;
+import org.jboss.wsf.common.javax.finders.PostConstructMethodFinder;
+import org.jboss.wsf.common.javax.finders.PreDestroyMethodFinder;
+import org.jboss.wsf.common.javax.finders.ResourceFieldFinder;
+import org.jboss.wsf.common.javax.finders.ResourceMethodFinder;
+import org.jboss.wsf.common.reflection.ClassProcessor;
+import org.jboss.wsf.spi.metadata.injection.InjectionMetaData;
+import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
 
 /**
  * A helper class for <b>javax.annotation</b> annotations. 
- * @author richard.opalka at jboss.com
+ * 
+ * @author ropalka at redhat.com
  */
 public final class JavaxAnnotationHelper
 {
    
-   private static Logger log = Logger.getLogger(JavaxAnnotationHelper.class);
-   private static final Object[] noArgs = new Object[] {};
+   private static final Logger LOG = Logger.getLogger(JavaxAnnotationHelper.class);
+   private static final String JNDI_PREFIX = "java:comp/env/";
+   private static final ClassProcessor<Method> POST_CONSTRUCT_METHOD_FINDER = new PostConstructMethodFinder();
+   private static final ClassProcessor<Method> PRE_DESTROY_METHOD_FINDER = new PreDestroyMethodFinder();
+   private static final ClassProcessor<Method> RESOURCE_METHOD_FINDER = new ResourceMethodFinder();
+   private static final ClassProcessor<Field> RESOURCE_FIELD_FINDER = new ResourceFieldFinder();
    
    /**
-    * Constructor
+    * Forbidden constructor.
     */
    private JavaxAnnotationHelper()
    {
-      // forbidden inheritance
+      super();
    }
    
    /**
-    * @see JavaxAnnotationHelper#callPreDestroyMethod(Object, ClassLoader)
-    * @param instance to inject resource on
-    * @throws Exception if some error occurs
-    */
-   public static void injectResources(Object instance) throws Exception
-   {
-      injectResources(instance, Thread.currentThread().getContextClassLoader());
-   }
-   
-   /**
     * The Resource annotation marks a resource that is needed by the application. This annotation may be applied
     * to an application component class, or to fields or methods of the component class. When the annotation is
     * applied to a field or method, the container will inject an instance of the requested resource into the
     * application component when the component is initialized. If the annotation is applied to the component class,
     * the annotation declares a resource that the application will look up at runtime.
+    * 
     * @param instance to inject resource on
-    * @param classLoader to check whether javax.annotation annotations are available
+    * @param injections injections metadata
     * @throws Exception if some error occurs
     */
-   public static void injectResources(Object instance, ClassLoader classLoader) throws Exception
+   public static void injectResources(Object instance, InjectionsMetaData injections) throws Exception
    {
       if (instance == null)
          throw new IllegalArgumentException("Object instance cannot be null");
-      if (classLoader == null)
-         throw new IllegalArgumentException("ClassLoader cannot be null");
+      if (injections == null)
+         throw new IllegalArgumentException("Injections metadata cannot be null");
       
-      try
+      Class<?> instanceClass = instance.getClass();
+      
+      InitialContext ctx = new InitialContext();
+
+      // inject descriptor driven annotations
+      Collection<InjectionMetaData> injectionMDs = injections.getInjectionsMetaData(instanceClass);
+      for (InjectionMetaData injectionMD : injectionMDs)
       {
-         classLoader.loadClass("javax.annotation.Resource");
+         Method method = getMethod(injectionMD, instanceClass);
+         if (method != null)
+         {
+            // inject descriptor driven annotated method
+            inject(instance, method, injectionMD.getEnvEntryName(), ctx);
+         }
+         else
+         {
+            Field field = getField(injectionMD, instanceClass);
+            if (field != null)
+            {
+               // inject descriptor driven annotated field
+               inject(instance, field, injectionMD.getEnvEntryName(), ctx);
+            }
+            else
+            {
+               throw new RuntimeException("Cannot find injection target for: " + injectionMD);
+            }
+         }
       }
-      catch (Throwable th)
-      {
-         log.debug("Cannot inject resources: " + th.toString());
-         return;
-      }
 
-      Class<?> instanceClass = instance.getClass();
-      
-      // handle Resource injection on types
-      if (instanceClass.isAnnotationPresent(Resource.class))
-         throw new NotImplementedException("@Resource not implemented for: " + instanceClass.getName());
-      
-      // handle Resource injection on fields
-      for (Field field : getAllDeclaredFields(instanceClass))
+      // inject @Resource annotated methods
+      Collection<Method> resourceAnnotatedMethods = RESOURCE_METHOD_FINDER.process(instanceClass);
+      for(Method method : resourceAnnotatedMethods)
       {
-         if (field.isAnnotationPresent(Resource.class))
-            throw new NotImplementedException("@Resource not implemented for: " + instanceClass.getName());
+         inject(instance, method, method.getAnnotation(Resource.class).name(), ctx);
       }
       
-      // handle Resource injection on methods
-      for (Method method : getAllDeclaredMethods(instanceClass))
+      // inject @Resource annotated fields
+      Collection<Field> resourceAnnotatedFields = RESOURCE_FIELD_FINDER.process(instanceClass);
+      for (Field field : resourceAnnotatedFields)
       {
-         if (method.isAnnotationPresent(Resource.class))
-            throw new NotImplementedException("@Resource not implemented for: " + instanceClass.getName());
+         inject(instance, field, field.getAnnotation(Resource.class).name(), ctx);
       }
    }
    
    /**
-    * @see JavaxAnnotationHelper#callPreDestroyMethod(Object, ClassLoader)
-    * @param instance to invoke pre destroy method on
+    * Calls @PostConstruct annotated method if exists.
+    * 
+    * @param instance to invoke @PostConstruct annotated method on
     * @throws Exception if some error occurs
+    * @see org.jboss.wsf.common.javax.finders.PostConstructMethodFinder
+    * @see javax.annotation.PostConstruct
     */
-   public static void callPreDestroyMethod(Object instance) throws Exception
+   public static void callPostConstructMethod(Object instance) throws Exception
    {
-      callPreDestroyMethod(instance, Thread.currentThread().getContextClassLoader());
+      if (instance == null)
+         throw new IllegalArgumentException("Object instance cannot be null");
+
+      Collection<Method> methods = POST_CONSTRUCT_METHOD_FINDER.process(instance.getClass());
+      
+      if (methods.size() > 0)
+      {
+         Method method = methods.iterator().next();
+         LOG.debug("Calling @PostConstruct annotated method: " + method);
+         invokeMethod(instance, method, null);
+      }
    }
    
    /**
-    * The PreDestroy annotation is used on methods as a callback notification to signal that the instance
-    * is in the process of being removed by the container. The method annotated with PreDestroy is typically
-    * used to release resources that it has been holding. This annotation MUST be supported by all container
-    * managed objects that support PostConstruct except the application client container in Java EE 5.
-    * The method on which the PreDestroy annotation is applied MUST fulfill all of the following criteria:
-    * <ul>
-    *   <li>The method MUST NOT have any parameters.
-    *   <li>The return type of the method MUST be void.
-    *   <li>The method MUST NOT throw a checked exception.
-    *   <li>The method on which PreDestroy is applied MAY be public, protected, package private or private.
-    *   <li>The method MUST NOT be static.
-    *   <li>The method MAY be final.
-    *   <li>If the method throws an unchecked exception it is ignored.
-    * </ul>
-    * @param instance to invoke pre destroy method on
-    * @param classLoader to check whether javax.annotation annotations are available
+    * Calls @PreDestroy annotated method if exists.
+    * 
+    * @param instance to invoke @PreDestroy annotated method on
     * @throws Exception if some error occurs
+    * @see org.jboss.wsf.common.javax.finders.PreDestroyMethodFinder
+    * @see javax.annotation.PreDestroy
     */
-   public static void callPreDestroyMethod(Object instance, ClassLoader classLoader) throws Exception
+   public static void callPreDestroyMethod(Object instance) throws Exception
    {
       if (instance == null)
          throw new IllegalArgumentException("Object instance cannot be null");
-      if (classLoader == null)
-         throw new IllegalArgumentException("ClassLoader cannot be null");
+
+      Collection<Method> methods = PRE_DESTROY_METHOD_FINDER.process(instance.getClass());
       
-      try
+      if (methods.size() > 0)
       {
-         classLoader.loadClass("javax.annotation.PreDestroy");
+         Method method = methods.iterator().next();
+         LOG.debug("Calling @PreDestroy annotated method: " + method);
+         invokeMethod(instance, method, null);
       }
-      catch (Throwable th)
-      {
-         log.debug("Cannot call pre destroy: " + th.toString());
-         return;
-      }
+   }
+   
+   /**
+    * Injects @Resource annotated method.
+    * 
+    * @param method to invoke
+    * @param instance to invoke method on
+    * @param resourceName resource name
+    * @param cxt JNDI context
+    * @throws Exception if any error occurs
+    * @see org.jboss.wsf.common.javax.finders.ResourceMethodFinder
+    */
+   private static void inject(final Object instance, final Method method, String resourceName, InitialContext ctx) throws Exception
+   {
+      final String beanName = convertToBeanName(method.getName()); 
+      final Object value = ctx.lookup(getName(resourceName, beanName));
 
-      Method targetMethod = null;
-      for (Method method : getAllDeclaredMethods(instance.getClass()))
-      {
-         if (method.isAnnotationPresent(PreDestroy.class))
-         {
-            if (targetMethod == null)
-            {
-               targetMethod = method;
-            }
-            else
-            {
-               throw new RuntimeException("Only one method can be annotated with javax.annotation.PreDestroy annotation");
-            }
-         }
-      }
+      LOG.debug("Injecting method: " + method);
+      invokeMethod(instance, method, new Object[] {value});
+   }
+   
+   /**
+    * Injects @Resource annotated field.
+    * 
+    * @param field to set
+    * @param instance to modify field on
+    * @param resourceName resource name
+    * @param cxt JNDI context
+    * @throws Exception if any error occurs
+    * @see org.jboss.wsf.common.javax.finders.ResourceFieldFinder
+    */
+   private static void inject(final Object instance, final Field field, String resourceName, InitialContext ctx) throws Exception
+   {
+      final String beanName = field.getName();
+      final Object value = ctx.lookup(getName(resourceName, beanName));
       
-      if (targetMethod != null)
-      {
-         // Ensure all method preconditions
-         assertNoParameters(targetMethod);
-         assertVoidReturnType(targetMethod);
-         assertNoCheckedExceptionsAreThrown(targetMethod);
-         assertNotStatic(targetMethod);
+      LOG.debug("Injecting field: " + field);
+      setField(instance, field, value);
+   }
 
-         // Finally call annotated method
-         invokeMethod(targetMethod, instance);
-      }
+   /**
+    * Translates "setBeanName" to "beanName" string.
+    * 
+    * @param methodName to translate
+    * @return bean name
+    */
+   private static String convertToBeanName(final String methodName)
+   {
+      return Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
    }
    
    /**
-    * @see JavaxAnnotationHelper#callPostConstructMethod(Object, ClassLoader)
-    * @param instance to invoke post construct method on
-    * @throws Exception if some error occurs
+    * Returns full JNDI name.
+    * 
+    * @param resourceName to be used if specified
+    * @param beanName fallback bean name to be used
+    * @return JNDI full name
     */
-   public static void callPostConstructMethod(Object instance) throws Exception
+   private static String getName(final String resourceName, final String beanName)
    {
-      callPostConstructMethod(instance, Thread.currentThread().getContextClassLoader());
+      return JNDI_PREFIX + (resourceName.length() > 0 ? resourceName : beanName);
    }
    
    /**
-    * The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done
-    * to perform any initialization. This method MUST be invoked before the class is put into service. This annotation
-    * MUST be supported on all classes that support dependency injection. The method annotated with PostConstruct MUST
-    * be invoked even if the class does not request any resources to be injected. Only one method can be annotated with
-    * this annotation. The method on which the PostConstruct annotation is applied MUST fulfill all of the following criteria:
-    * <ul>
-    *   <li>The method MUST NOT have any parameters.
-    *   <li>The return type of the method MUST be void.
-    *   <li>The method MUST NOT throw a checked exception.
-    *   <li>The method on which PostConstruct is applied MAY be public, protected, package private or private.
-    *   <li>The method MUST NOT be static.
-    *   <li>The method MAY be final.
-    *   <li>If the method throws an unchecked exception the class MUST NOT be put into service.
-    * </ul> 
-    * @param instance to invoke post construct method on
-    * @param classLoader to check whether javax.annotation annotations are available
-    * @throws Exception if some error occurs
+    * Invokes method on object with specified arguments.
+    * 
+    * @param instance to invoke method on
+    * @param method method to invoke
+    * @param args arguments to pass
+    * @throws Exception if any error occurs
     */
-   public static void callPostConstructMethod(Object instance, ClassLoader classLoader) throws Exception
+   private static void invokeMethod(final Object instance, final Method method, final Object[] args) throws Exception
    {
-      if (instance == null)
-         throw new IllegalArgumentException("Object instance cannot be null");
-      if (classLoader == null)
-         throw new IllegalArgumentException("ClassLoader cannot be null");
+      boolean accessability = method.isAccessible();
       
       try
       {
-         classLoader.loadClass("javax.annotation.PostConstruct");
+         method.setAccessible(true);
+         method.invoke(instance, args);
       }
-      catch (Throwable th)
+      catch (Exception e)
       {
-         log.debug("Cannot call post construct: " + th.toString());
-         return;
+         LOG.error(e.getMessage(), e);
+         throw e; // propagate
       }
-
-      Method targetMethod = null;
-      for (Method method : getAllDeclaredMethods(instance.getClass()))
+      finally
       {
-         if (method.isAnnotationPresent(PostConstruct.class))
-         {
-            if (targetMethod == null)
-            {
-               targetMethod = method;
-            }
-            else
-            {
-               throw new RuntimeException("Only one method can be annotated with javax.annotation.PostConstruct annotation");
-            }
-         }
+         method.setAccessible(accessability);
       }
-      
-      if (targetMethod != null)
-      {
-         // Ensure all method preconditions
-         assertNoParameters(targetMethod);
-         assertVoidReturnType(targetMethod);
-         assertNoCheckedExceptionsAreThrown(targetMethod);
-         assertNotStatic(targetMethod);
-
-         // Finally call annotated method
-         invokeMethod(targetMethod, instance);
-      }
    }
    
-   private static List<Method> getAllDeclaredMethods(Class<?> clazz)
+   /**
+    * Sets field on object with specified value.
+    * 
+    * @param instance to set field on
+    * @param field to set
+    * @param value to be set
+    * @throws Exception if any error occurs
+    */
+   private static void setField(final Object instance, final Field field, final Object value) throws Exception
    {
-      List<Method> retVal = new LinkedList<Method>();
-      while (clazz != null)
+      boolean accessability = field.isAccessible();
+      
+      try
       {
-         for (Method m : clazz.getDeclaredMethods())
-         {
-            retVal.add(m);
-         }
-         clazz = clazz.getSuperclass();
+         field.setAccessible(true);
+         field.set(instance, value);
       }
-      return retVal;
-   }
-   
-   private static List<Field> getAllDeclaredFields(Class<?> clazz)
-   {
-      List<Field> retVal = new LinkedList<Field>();
-      while (clazz != null)
+      catch (Exception e)
       {
-         for (Field f : clazz.getDeclaredFields())
-         {
-            retVal.add(f);
-         }
-         clazz = clazz.getSuperclass();
+         LOG.error(e.getMessage(), e);
+         throw e; // propagate
       }
-      return retVal;
-   }
-   
-   private static void invokeMethod(Method m, Object instance) throws Exception
-   {
-      if (!m.isAccessible())
+      finally
       {
-         m.setAccessible(true);
+         field.setAccessible(accessability);
       }
-      m.invoke(instance, noArgs);
    }
    
-   private static void assertNoParameters(Method m) 
+   /**
+    * Returns method that matches the descriptor injection metadata or null if not found.
+    * 
+    * @param injectionMD descriptor injection metadata
+    * @param clazz to process
+    * @return method that matches the criteria or null if not found
+    * @see org.jboss.wsf.common.javax.finders.InjectionMethodFinder
+    */
+   private static Method getMethod(InjectionMetaData injectionMD, Class<?> clazz)
    {
-      if (m.getParameterTypes().length != 0)
-         throw new RuntimeException("Method annotated with javax.annotation annotations have to be parameterless");
+      Collection<Method> result = new InjectionMethodFinder(injectionMD).process(clazz);
+      
+      return result.isEmpty() ? null : result.iterator().next();
    }
-
-   private static void assertVoidReturnType(Method m) 
+   
+   /**
+    * Returns field that matches the descriptor injection metadata or null if not found.
+    * 
+    * @param injectionMD descriptor injection metadata
+    * @param clazz to process
+    * @return field that matches the criteria or null if not found
+    * @see org.jboss.wsf.common.javax.finders.InjectionFieldFinder
+    */
+   private static Field getField(InjectionMetaData injectionMD, Class<?> clazz)
    {
-      if ((!m.getReturnType().equals(Void.class)) && (!m.getReturnType().equals(Void.TYPE)))
-         throw new RuntimeException("Method annotated with javax.annotation annotations have to return void");
+      Collection<Field> result = new InjectionFieldFinder(injectionMD).process(clazz);
+      
+      return result.isEmpty() ? null : result.iterator().next();
    }
-
-   private static void assertNoCheckedExceptionsAreThrown(Method m) 
-   {
-      Class<?>[] declaredExceptions = m.getExceptionTypes();
-      for (int i = 0; i < declaredExceptions.length; i++)
-      {
-         Class<?> exception = declaredExceptions[i];
-         if (!exception.isAssignableFrom(RuntimeException.class))
-            throw new RuntimeException("Method annotated with javax.annotation annotations cannot throw checked exceptions");
-      }
-   }
-
-   private static void assertNotStatic(Method m) 
-   {
-      if (Modifier.isStatic(m.getModifiers()))
-         throw new RuntimeException("Method annotated with javax.annotation annotations cannot be static");
-   }
    
 }

Added: common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/AbstractPostConstructPreDestroyAnnotatedMethodFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/AbstractPostConstructPreDestroyAnnotatedMethodFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/AbstractPostConstructPreDestroyAnnotatedMethodFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.javax.finders;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Collection;
+
+import org.jboss.wsf.common.reflection.AnnotatedMethodFinder;
+
+/**
+ * Abstract @PostConstruct and @PreDestroy annotations method finder. 
+ *
+ * @author ropalka at redhat.com
+ */
+abstract class AbstractPostConstructPreDestroyAnnotatedMethodFinder<A extends Annotation>
+extends AnnotatedMethodFinder<A>
+{
+
+   /**
+    * Constructor.
+    * 
+    * @param annotationClass annotation.
+    */
+   AbstractPostConstructPreDestroyAnnotatedMethodFinder(final Class<A> annotationClass)
+   {
+      super(annotationClass);
+   }
+
+   @Override
+   public void validate(final Collection<Method> methods)
+   {
+      super.validate(methods);
+
+      // Ensure all methods preconditions
+      ReflectionUtils.assertOnlyOneMethod(methods, getAnnotation());
+   }
+
+   @Override
+   public void validate(final Method method)
+   {
+      super.validate(method);
+
+      // Ensure all method preconditions
+      Class<A> annotation = getAnnotation();
+      ReflectionUtils.assertNoParameters(method, annotation);
+      ReflectionUtils.assertVoidReturnType(method, annotation);
+      ReflectionUtils.assertNoCheckedExceptionsAreThrown(method, annotation);
+      ReflectionUtils.assertNotStatic(method, annotation);
+   }
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionFieldFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionFieldFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionFieldFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.javax.finders;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+
+import org.jboss.wsf.common.reflection.FieldFinder;
+import org.jboss.wsf.spi.metadata.injection.InjectionMetaData;
+
+/**
+ * Lookups field that matches descriptor specified injection metadata.
+ *
+ * @author ropalka at redhat.com
+ */
+public final class InjectionFieldFinder
+extends FieldFinder
+{
+   
+   /**
+    * Descriptor injection metadata.
+    */
+   private final InjectionMetaData injectionMD;
+   
+   /**
+    * Constructor.
+    * 
+    * @param injectionMD descriptor injection metadata
+    */
+   public InjectionFieldFinder(final InjectionMetaData injectionMD)
+   {
+      if (injectionMD == null)
+         throw new IllegalArgumentException("Injection metadata cannot be null");
+      
+      this.injectionMD = injectionMD;
+   }
+
+   @Override
+   public boolean matches(final Field field)
+   {
+      if (field.getName().equals(injectionMD.getTargetName()))
+      {
+         if (injectionMD.getValueClass() != null)
+         {
+            final Class<?> expectedClass = injectionMD.getValueClass();
+            final Class<?> fieldClass = field.getType();
+
+            return expectedClass.equals(fieldClass);
+         }
+         else
+         {
+            return true;
+         }
+      }
+      
+      return false;
+   }
+
+   @Override
+   public void validate(final Collection<Field> fields)
+   {
+      super.validate(fields);
+      
+      if (fields.size() > 2)
+      {
+         throw new RuntimeException("More than one field found matching the criteria: " + injectionMD);
+      }
+   }
+
+   @Override
+   public void validate(final Field field)
+   {
+      super.validate(field);
+      
+      ReflectionUtils.assertNotVoidType(field);
+      ReflectionUtils.assertNotStatic(field);
+      ReflectionUtils.assertNotPrimitiveType(field);
+   }
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionMethodFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionMethodFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionMethodFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.javax.finders;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+
+import org.jboss.wsf.common.reflection.MethodFinder;
+import org.jboss.wsf.spi.metadata.injection.InjectionMetaData;
+
+/**
+ * Lookups method that matches descriptor specified injection metadata.
+ *
+ * @author ropalka at redhat.com
+ */
+public final class InjectionMethodFinder
+extends MethodFinder
+{
+   
+   /**
+    * Descriptor injection metadata.
+    */
+   private final InjectionMetaData injectionMD;
+   
+   /**
+    * Constructor.
+    * 
+    * @param injectionMD descriptor injection metadata
+    */
+   public InjectionMethodFinder(final InjectionMetaData injectionMD)
+   {
+      if (injectionMD == null)
+         throw new IllegalArgumentException("Injection metadata cannot be null");
+      
+      this.injectionMD = injectionMD;
+   }
+
+   @Override
+   public boolean matches(final Method method)
+   {
+      if (method.getName().equals(injectionMD.getTargetName()))
+      {
+         if (injectionMD.getValueClass() != null)
+         {
+            if (method.getParameterTypes().length == 1)
+            {
+               final Class<?> expectedClass = injectionMD.getValueClass();
+               final Class<?> parameterClass = method.getParameterTypes()[0];
+
+               return expectedClass.equals(parameterClass);
+            }
+         }
+         else
+         {
+            if (method.getParameterTypes().length == 1)
+            {
+               return true;
+            }
+         }
+      }
+      
+      return false;
+   }
+
+   @Override
+   public void validate(final Collection<Method> methods)
+   {
+      super.validate(methods);
+      
+      if (methods.size() > 2)
+      {
+         throw new RuntimeException("More than one method found matching the criteria: " + injectionMD);
+      }
+   }
+
+   @Override
+   public void validate(final Method method)
+   {
+      super.validate(method);
+      
+      ReflectionUtils.assertVoidReturnType(method);
+      ReflectionUtils.assertOneParameter(method);
+      ReflectionUtils.assertNoPrimitiveParameters(method);
+      ReflectionUtils.assertValidSetterName(method);
+      ReflectionUtils.assertNoCheckedExceptionsAreThrown(method);
+      ReflectionUtils.assertNotStatic(method);
+   }
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PostConstructMethodFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PostConstructMethodFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PostConstructMethodFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.javax.finders;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @PostConstruct method finder.
+ *
+ * The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done
+ * to perform any initialization. This method MUST be invoked before the class is put into service. This annotation
+ * MUST be supported on all classes that support dependency injection. The method annotated with PostConstruct MUST
+ * be invoked even if the class does not request any resources to be injected. Only one method can be annotated with
+ * this annotation. The method on which the PostConstruct annotation is applied MUST fulfill all of the following criteria:
+ * <ul>
+ *   <li>The method MUST NOT have any parameters.
+ *   <li>The return type of the method MUST be void.
+ *   <li>The method MUST NOT throw a checked exception.
+ *   <li>The method on which PostConstruct is applied MAY be public, protected, package private or private.
+ *   <li>The method MUST NOT be static.
+ *   <li>The method MAY be final.
+ *   <li>If the method throws an unchecked exception the class MUST NOT be put into service.
+ * </ul>
+ *
+ * @author ropalka at redhat.com
+ */
+public final class PostConstructMethodFinder
+extends AbstractPostConstructPreDestroyAnnotatedMethodFinder<PostConstruct>
+{
+   
+   /**
+    * Constructor.
+    */
+   public PostConstructMethodFinder()
+   {
+      super(PostConstruct.class);
+   }
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PreDestroyMethodFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PreDestroyMethodFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PreDestroyMethodFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.javax.finders;
+
+import javax.annotation.PreDestroy;
+
+/**
+ * @PreDestroy method finder.
+ * 
+ * The PreDestroy annotation is used on methods as a callback notification to signal that the instance
+ * is in the process of being removed by the container. The method annotated with PreDestroy is typically
+ * used to release resources that it has been holding. This annotation MUST be supported by all container
+ * managed objects that support PostConstruct except the application client container in Java EE 5.
+ * The method on which the PreDestroy annotation is applied MUST fulfill all of the following criteria:
+ * <ul>
+ *   <li>The method MUST NOT have any parameters.
+ *   <li>The return type of the method MUST be void.
+ *   <li>The method MUST NOT throw a checked exception.
+ *   <li>The method on which PreDestroy is applied MAY be public, protected, package private or private.
+ *   <li>The method MUST NOT be static.
+ *   <li>The method MAY be final.
+ *   <li>If the method throws an unchecked exception it is ignored.
+ * </ul>
+ *
+ * @author ropalka at redhat.com
+ */
+public final class PreDestroyMethodFinder
+extends AbstractPostConstructPreDestroyAnnotatedMethodFinder<PreDestroy>
+{
+   
+   /**
+    * Constructor.
+    */
+   public PreDestroyMethodFinder()
+   {
+      super(PreDestroy.class);
+   }
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ReflectionUtils.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ReflectionUtils.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ReflectionUtils.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,334 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.javax.finders;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collection;
+
+/**
+ * Reflection utility class.
+ *
+ * @author ropalka at redhat.com
+ */
+final class ReflectionUtils
+{
+   
+   /**
+    * Constructor.
+    */
+   private ReflectionUtils()
+   {
+      super();
+   }
+   
+   /**
+    * Asserts method don't declare primitive parameters.
+    * 
+    * @param method to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertNoPrimitiveParameters(final Method method, Class<? extends Annotation> annotation)
+   {
+      for (Class<?> type : method.getParameterTypes())
+      {
+         if (type.isPrimitive())
+         {
+            throw new RuntimeException("Method " + getAnnotationMessage(annotation) + "can't declare primitive parameters: " + method);
+         }
+      }
+   }
+   
+   /**
+    * Asserts method don't declare primitive parameters.
+    * 
+    * @param method to validate
+    */
+   public static void assertNoPrimitiveParameters(final Method method)
+   {
+      assertNoPrimitiveParameters(method, null);
+   }
+   
+   /**
+    * Asserts field is not of primitive type.
+    * 
+    * @param method to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertNotPrimitiveType(final Field field, Class<? extends Annotation> annotation)
+   {
+      if (field.getType().isPrimitive())
+      {
+         throw new RuntimeException("Field " + getAnnotationMessage(annotation) + "can't be of primitive type: " + field);
+      }
+   }
+   
+   /**
+    * Asserts field is not of primitive type.
+    * 
+    * @param method to validate
+    */
+   public static void assertNotPrimitiveType(final Field field)
+   {
+      assertNotPrimitiveType(field, null);
+   }
+   
+   /**
+    * Asserts method have no parameters.
+    * 
+    * @param method to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertNoParameters(final Method method, Class<? extends Annotation> annotation) 
+   {
+      if (method.getParameterTypes().length != 0)
+      {
+         throw new RuntimeException("Method " + getAnnotationMessage(annotation) + "have to have no parameters: " + method);
+      }
+   }
+   
+   /**
+    * Asserts method have no parameters.
+    * 
+    * @param method to validate
+    */
+   public static void assertNoParameters(final Method method)
+   {
+      assertNoParameters(method, null);
+   }
+
+   /**
+    * Asserts method return void.
+    * 
+    * @param method to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertVoidReturnType(final Method method, Class<? extends Annotation> annotation) 
+   {
+      if ((!method.getReturnType().equals(Void.class)) && (!method.getReturnType().equals(Void.TYPE)))
+      {
+         throw new RuntimeException("Method " + getAnnotationMessage(annotation) + "have to return void: " + method);
+      }
+   }
+   
+   /**
+    * Asserts method return void.
+    * 
+    * @param method to validate
+    */
+   public static void assertVoidReturnType(final Method method) 
+   {
+      assertVoidReturnType(method, null);
+   }
+   
+   /**
+    * Asserts field isn't of void type.
+    * 
+    * @param field to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertNotVoidType(final Field field, Class<? extends Annotation> annotation)
+   {
+      if ((field.getClass().equals(Void.class)) && (field.getClass().equals(Void.TYPE)))
+      {
+         throw new RuntimeException("Field " + getAnnotationMessage(annotation) + "cannot be of void type: " + field);
+      }
+   }
+
+   /**
+    * Asserts field isn't of void type.
+    * 
+    * @param field to validate
+    */
+   public static void assertNotVoidType(final Field field)
+   {
+      assertNotVoidType(field, null);
+   }
+
+   /**
+    * Asserts method don't throw checked exceptions.
+    * 
+    * @param method to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertNoCheckedExceptionsAreThrown(final Method method, Class<? extends Annotation> annotation) 
+   {
+      Class<?>[] declaredExceptions = method.getExceptionTypes();
+      for (int i = 0; i < declaredExceptions.length; i++)
+      {
+         Class<?> exception = declaredExceptions[i];
+         if (!exception.isAssignableFrom(RuntimeException.class))
+         {
+            throw new RuntimeException("Method " + getAnnotationMessage(annotation) + "cannot throw checked exceptions: " + method);
+         }
+      }
+   }
+
+   /**
+    * Asserts method don't throw checked exceptions.
+    * 
+    * @param method to validate
+    */
+   public static void assertNoCheckedExceptionsAreThrown(final Method method) 
+   {
+      assertNoCheckedExceptionsAreThrown(method, null);
+   }
+
+   /**
+    * Asserts method is not static.
+    * 
+    * @param method to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertNotStatic(final Method method, Class<? extends Annotation> annotation) 
+   {
+      if (Modifier.isStatic(method.getModifiers()))
+      {
+         throw new RuntimeException("Method " + getAnnotationMessage(annotation) + "cannot be static: " + method);
+      }
+   }
+
+   /**
+    * Asserts method is not static.
+    * 
+    * @param method to validate
+    */
+   public static void assertNotStatic(final Method method) 
+   {
+      assertNotStatic(method, null);
+   }
+
+   /**
+    * Asserts field is not static.
+    * 
+    * @param field to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertNotStatic(final Field field, Class<? extends Annotation> annotation) 
+   {
+      if (Modifier.isStatic(field.getModifiers()))
+      {
+         throw new RuntimeException("Field " + getAnnotationMessage(annotation) + "cannot be static: " + field);
+      }
+   }
+
+   /**
+    * Asserts field is not static.
+    * 
+    * @param field to validate
+    */
+   public static void assertNotStatic(final Field field) 
+   {
+      assertNotStatic(field, null);
+   }
+
+   /**
+    * Asserts method have exactly one parameter.
+    * 
+    * @param method to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertOneParameter(final Method method, Class<? extends Annotation> annotation)
+   {
+      if (method.getParameterTypes().length != 1)
+      {
+         throw new RuntimeException("Method " + getAnnotationMessage(annotation) + "have to declare exactly one parameter: " + method);
+      }
+   }
+   
+   /**
+    * Asserts method have exactly one parameter.
+    * 
+    * @param method to validate
+    */
+   public static void assertOneParameter(final Method method)
+   {
+      assertOneParameter(method, null);
+   }
+   
+   /**
+    * Asserts valid Java Beans setter method name.
+    * 
+    * @param method to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertValidSetterName(final Method method, Class<? extends Annotation> annotation)
+   {
+      final String methodName = method.getName();
+      final boolean correctMethodNameLength = methodName.length() > 3;
+      final boolean isSetterMethodName = methodName.startsWith("set");
+      final boolean isUpperCasedPropertyName = correctMethodNameLength ? Character.isUpperCase(methodName.charAt(3)) : false;
+      
+      if (!correctMethodNameLength || !isSetterMethodName || !isUpperCasedPropertyName)
+      {
+         throw new RuntimeException("Method " + getAnnotationMessage(annotation) + "doesn't follow Java Beans setter method name: " + method);
+      }
+   }
+   
+   /**
+    * Asserts valid Java Beans setter method name.
+    * 
+    * @param method to validate
+    */
+   public static void assertValidSetterName(final Method method)
+   {
+      assertValidSetterName(method, null);
+   }
+   
+   /**
+    * Asserts only one method is annotated with annotation.
+    * 
+    * @param method collection of methods to validate
+    * @param annotation annotation to propagate in exception message
+    */
+   public static void assertOnlyOneMethod(final Collection<Method> methods, Class<? extends Annotation> annotation)
+   {
+      if (methods.size() > 1)
+      {
+         throw new RuntimeException("Only one method " + getAnnotationMessage(annotation) + "can exist");
+      }
+   }
+   
+   /**
+    * Asserts only one method is annotated with annotation.
+    * 
+    * @param method collection of methods to validate
+    */
+   public static void assertOnlyOneMethod(final Collection<Method> methods)
+   {
+      assertOnlyOneMethod(methods, null);
+   }
+   
+   /**
+    * Constructs annotation message. If annotation class is null it returns empty string.
+    * 
+    * @param annotation to construct message for
+    * @return annotation message or empty string
+    */
+   private static String getAnnotationMessage(Class<? extends Annotation> annotation)
+   {
+      return annotation == null ? "" : "annotated with @" + annotation + " annotation "; 
+   }
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceFieldFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceFieldFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceFieldFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.javax.finders;
+
+import java.lang.reflect.Field;
+
+import javax.annotation.Resource;
+
+import org.jboss.wsf.common.reflection.AnnotatedFieldFinder;
+
+/**
+ * Field based injection.
+ *
+ * To access a resource a developer declares a setter method and annotates it as being a
+ * resource reference. The name and type of resource maybe inferred by inspecting the
+ * method declaration if necessary. The name of the resource, if not declared, is the
+ * name of the JavaBeans property as determined starting from the name of the setter
+ * method in question. The setter method must follow the standard JavaBeans
+ * convention - name starts with a “set”, void return type and only one parameter.
+ * Additionally, the type of the parameter must be compatible with the type specified
+ * as a property of the Resource if present.
+ *
+ * @author ropalka at redhat.com
+ */
+public final class ResourceFieldFinder
+extends AnnotatedFieldFinder<Resource>
+{
+   
+   /**
+    * Constructor.
+    */
+   public ResourceFieldFinder()
+   {
+      super(Resource.class);
+   }
+
+   @Override
+   public void validate(Field field)
+   {
+      super.validate(field);
+
+      // Ensure all method preconditions
+      Class<Resource> annotation = getAnnotation();
+      ReflectionUtils.assertNotVoidType(field, annotation);
+      ReflectionUtils.assertNotStatic(field, annotation);
+      ReflectionUtils.assertNotPrimitiveType(field, annotation);
+   }
+
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceMethodFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceMethodFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceMethodFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.javax.finders;
+
+import java.lang.reflect.Method;
+
+import javax.annotation.Resource;
+
+import org.jboss.wsf.common.reflection.AnnotatedMethodFinder;
+
+/**
+ * Setter based injection.
+ *
+ * To access a resource a developer declares a setter method and annotates it as being a
+ * resource reference. The name and type of resource maybe inferred by inspecting the
+ * method declaration if necessary. The name of the resource, if not declared, is the
+ * name of the JavaBeans property as determined starting from the name of the setter
+ * method in question. The setter method must follow the standard JavaBeans
+ * convention - name starts with a “set”, void return type and only one parameter.
+ * Additionally, the type of the parameter must be compatible with the type specified
+ * as a property of the Resource if present.
+ *
+ * @author ropalka at redhat.com
+ */
+public final class ResourceMethodFinder
+extends AnnotatedMethodFinder<Resource>
+{
+   
+   /**
+    * Constructor.
+    */
+   public ResourceMethodFinder()
+   {
+      super(Resource.class);
+   }
+
+   @Override
+   public void validate(Method method)
+   {
+      super.validate(method);
+
+      // Ensure all method preconditions
+      Class<Resource> annotation = getAnnotation();
+      ReflectionUtils.assertVoidReturnType(method, annotation);
+      ReflectionUtils.assertOneParameter(method, annotation);
+      ReflectionUtils.assertNoPrimitiveParameters(method, annotation);
+      ReflectionUtils.assertValidSetterName(method, annotation);
+      ReflectionUtils.assertNoCheckedExceptionsAreThrown(method, annotation);
+      ReflectionUtils.assertNotStatic(method, annotation);
+   }
+
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/AbstractAnnotatedClassProcessor.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/AbstractAnnotatedClassProcessor.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/AbstractAnnotatedClassProcessor.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+
+/**
+ * All annotation aware class processors should extend this class.
+ *
+ * @author ropalka at redhat.com
+ */
+public abstract class AbstractAnnotatedClassProcessor<AO extends AccessibleObject, A extends Annotation>
+extends AbstractClassProcessor<AO>
+implements AnnotationAware<A>
+{
+
+   /**
+    * Annotation class.
+    */
+   private final Class<A> annotationClass;
+   
+   /**
+    * Constructor.
+    * 
+    * @param annotationClass annotation class
+    */
+   public AbstractAnnotatedClassProcessor(final Class<A> annotationClass)
+   {
+      if (annotationClass == null)
+         throw new IllegalArgumentException("annotation class cannot be null");
+      
+      this.annotationClass = annotationClass;
+   }
+   
+   @Override
+   public boolean matches(final AO accessibleObject)
+   {
+      return accessibleObject.isAnnotationPresent(getAnnotation());
+   }
+   
+   /**
+    * @see org.jboss.wsf.common.reflection.AnnotationAware#getAnnotation()
+    */
+   public Class<A> getAnnotation()
+   {
+      return this.annotationClass;
+   }
+
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/AbstractClassProcessor.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/AbstractClassProcessor.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/AbstractClassProcessor.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.reflect.AccessibleObject;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+
+/**
+ * All class processors should extend this class.
+ *
+ * @author ropalka at redhat.com
+ */
+public abstract class AbstractClassProcessor<A extends AccessibleObject>
+extends AccessibleObjectProcessorAdapter<A>
+implements ClassProcessor<A>
+{
+
+   /**
+    * @see org.jboss.wsf.common.reflection.ClassProcessor#process(Class)
+    */
+   public Collection<A> process(final Class<?> clazz)
+   {
+      if (clazz == null)
+         return Collections.emptyList();
+      
+      final Collection<A> retVal = new LinkedList<A>();
+      
+      final A[] accessibleObjects = this.getAccessibleObjects(clazz);
+      for(A accessibleObject : accessibleObjects)
+      {
+         if (this.matches(accessibleObject))
+         {
+            this.validate(accessibleObject);
+            retVal.add(accessibleObject);
+         }
+      }
+      
+      retVal.addAll(this.process(clazz.getSuperclass()));
+      
+      this.validate(retVal);
+      
+      return retVal;
+   }
+   
+   /**
+    * All subclasses have to implement this method.
+    * 
+    * @param clazz to get accessible objects from.
+    * @return array of accessible objects
+    */
+   public abstract A[] getAccessibleObjects(final Class<?> clazz);
+
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/AccessibleObjectProcessor.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/AccessibleObjectProcessor.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/AccessibleObjectProcessor.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.reflect.AccessibleObject;
+import java.util.Collection;
+
+/**
+ * Accessible object processor.
+ *
+ * @author ropalka at redhat.com
+ */
+public interface AccessibleObjectProcessor<A extends AccessibleObject>
+{
+   
+   /**
+    * Validates accessible object.
+    * 
+    * @param accessibleObject object to validate
+    * @return RuntimeException if validation failed
+    */
+   void validate(A accessibleObject);
+   
+   /**
+    * Validates collection of accessible objects.
+    * 
+    * @param accessibleObjects collection of accessible objects to validate
+    * @return RuntimeException if validation failed
+    */
+   void validate(Collection<A> accessibleObjects);
+   
+   /**
+    * Indicates whether particular accessible object matches the criteria.
+    * 
+    * @param accessibleObject to check
+    * @return true if accessible object matches the criteria, false otherwise
+    */
+   boolean matches(A accessibleObject);
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/AccessibleObjectProcessorAdapter.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/AccessibleObjectProcessorAdapter.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/AccessibleObjectProcessorAdapter.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.reflect.AccessibleObject;
+import java.util.Collection;
+
+/**
+ * Accessible object processor adapter that does nothing.
+ *
+ * @author ropalka at redhat.com
+ */
+public class AccessibleObjectProcessorAdapter<T extends AccessibleObject> 
+implements AccessibleObjectProcessor<T>
+{
+
+   /**
+    * By default validation of accessible object passes.
+    */
+   public void validate(final T accessibleObject)
+   {
+      // do nothing
+   }
+
+   /**
+    * By default validation of collection of accessible objects passes.
+    */
+   public void validate(final Collection<T> accessibleObjects)
+   {
+      // do nothing
+   }
+
+   /**
+    * By default accessible object always matches all criteria.
+    */
+   public boolean matches(final T accessibleObject)
+   {
+      return true;
+   }
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotatedFieldFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotatedFieldFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotatedFieldFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+/**
+ * Finder that looks for fields annotated with specified annotation.
+ * The matching fields and collection of matching fields can be
+ * validated in subclasses.
+ *
+ * @author ropalka at redhat.com
+ */
+public class AnnotatedFieldFinder<A extends Annotation>
+extends AbstractAnnotatedClassProcessor<Field, A>
+{
+   
+   /**
+    * Constructor.
+    * 
+    * @param annotationClass annotation class
+    */
+   public AnnotatedFieldFinder(final Class<A> annotationClass)
+   {
+      super(annotationClass);
+   }
+   
+   @Override
+   public final Field[] getAccessibleObjects(final Class<?> clazz)
+   {
+      return clazz.getDeclaredFields();
+   }
+
+}
\ No newline at end of file

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotatedMethodFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotatedMethodFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotatedMethodFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * Finder that looks for methods annotated with specified annotation.
+ * The matching methods and collection of matching methods can be
+ * validated in subclasses.
+ * 
+ * @author ropalka at redhat.com
+ */
+public class AnnotatedMethodFinder<A extends Annotation>
+extends AbstractAnnotatedClassProcessor<Method, A>
+{
+   
+   /**
+    * Constructor.
+    * 
+    * @param annotationClass annotation class
+    */
+   public AnnotatedMethodFinder(final Class<A> annotationClass)
+   {
+      super(annotationClass);
+   }
+   
+   @Override
+   public final Method[] getAccessibleObjects(final Class<?> clazz)
+   {
+      return clazz.getDeclaredMethods();
+   }
+
+}
\ No newline at end of file

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotationAware.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotationAware.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/AnnotationAware.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * This interface allows to obtain annotation
+ * from annotation aware objects.
+ *
+ * @author ropalka at redhat.com
+ */
+public interface AnnotationAware<A extends Annotation>
+{
+
+   /**
+    * Returns annotation class associated with object.
+    * 
+    * @return annotation
+    */
+   public Class<A> getAnnotation();
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/ClassProcessor.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/ClassProcessor.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/ClassProcessor.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.reflect.AccessibleObject;
+import java.util.Collection;
+
+/**
+ * Generic accessible object processor.
+ *
+ * @author ropalka at redhat.com
+ */
+public interface ClassProcessor<A extends AccessibleObject>
+{
+   
+   /**
+    * Process a class to produce collection of accessible objects.
+    * 
+    * @param class the class to work on
+    * @return collection of accessible objects
+    */
+   Collection<A> process(Class<?> clazz);
+   
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/FieldFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/FieldFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/FieldFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.reflect.Field;
+
+/**
+ * A finder that looks for fields matching the criteria.
+ * The matching fields and collection of matching fields
+ * can be validated in subclasses.
+ * 
+ * @author ropalka at redhat.com
+ */
+public class FieldFinder
+extends AbstractClassProcessor<Field>
+{
+   
+   @Override
+   public final Field[] getAccessibleObjects(final Class<?> clazz)
+   {
+      return clazz.getDeclaredFields();
+   }
+
+}

Added: common/trunk/src/main/java/org/jboss/wsf/common/reflection/MethodFinder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/reflection/MethodFinder.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/reflection/MethodFinder.java	2009-04-02 14:10:28 UTC (rev 9707)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.reflection;
+
+import java.lang.reflect.Method;
+
+/**
+ * A finder that looks for methods matching the criteria.
+ * The matching methods and collection of matching methods
+ * can be validated in subclasses.
+ * 
+ * @author ropalka at redhat.com
+ */
+public class MethodFinder
+extends AbstractClassProcessor<Method>
+{
+   
+   @Override
+   public final Method[] getAccessibleObjects(final Class<?> clazz)
+   {
+      return clazz.getDeclaredMethods();
+   }
+
+}




More information about the jbossws-commits mailing list