Author: richard.opalka(a)jboss.com
Date: 2009-04-03 15:56:50 -0400 (Fri, 03 Apr 2009)
New Revision: 9728
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java
common/trunk/src/main/java/org/jboss/wsf/common/javax/PreDestroyHolder.java
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
Log:
fixing whitespaces and removing unused imports
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-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/JavaxAnnotationHelper.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -41,13 +41,13 @@
import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
/**
- * A helper class for <b>javax.annotation</b> annotations.
- *
+ * A helper class for <b>javax.annotation</b> annotations.
+ *
* @author ropalka(a)redhat.com
*/
public final class JavaxAnnotationHelper
{
-
+
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();
@@ -56,7 +56,7 @@
private static final ClassProcessor<Field> RESOURCE_FIELD_FINDER = new
ResourceFieldFinder(WebServiceContext.class, false);
private static final ClassProcessor<Method> WEB_SERVICE_CONTEXT_METHOD_FINDER =
new ResourceMethodFinder(WebServiceContext.class, true);
private static final ClassProcessor<Field> WEB_SERVICE_CONTEXT_FIELD_FINDER =
new ResourceFieldFinder(WebServiceContext.class, true);
-
+
/**
* Forbidden constructor.
*/
@@ -64,14 +64,14 @@
{
super();
}
-
+
/**
* 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 injections injections metadata
* @throws Exception if some error occurs
@@ -80,9 +80,9 @@
{
if (instance == null)
throw new IllegalArgumentException("Object instance cannot be null");
-
+
Class<?> instanceClass = instance.getClass();
-
+
InitialContext ctx = new InitialContext();
// inject descriptor driven annotations
@@ -138,7 +138,7 @@
LOG.warn("Cannot inject @Resource annotated method: " + method,
e);
}
}
-
+
// inject @Resource annotated fields
Collection<Field> resourceAnnotatedFields =
RESOURCE_FIELD_FINDER.process(instanceClass);
for (Field field : resourceAnnotatedFields)
@@ -153,11 +153,11 @@
}
}
}
-
+
public static void injectWebServiceContext(final Object instance, final
WebServiceContext ctx)
{
final Class<?> instanceClass = instance.getClass();
-
+
// inject @Resource annotated methods accepting WebServiceContext parameter
Collection<Method> resourceAnnotatedMethods =
WEB_SERVICE_CONTEXT_METHOD_FINDER.process(instanceClass);
for(Method method : resourceAnnotatedMethods)
@@ -171,7 +171,7 @@
LOG.warn("Cannot inject @Resource annotated method: " + method,
e);
}
}
-
+
// inject @Resource annotated fields of WebServiceContext type
Collection<Field> resourceAnnotatedFields =
WEB_SERVICE_CONTEXT_FIELD_FINDER.process(instanceClass);
for (Field field : resourceAnnotatedFields)
@@ -186,10 +186,10 @@
}
}
}
-
+
/**
* 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
@@ -201,7 +201,7 @@
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();
@@ -216,10 +216,10 @@
}
}
}
-
+
/**
* 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
@@ -231,7 +231,7 @@
throw new IllegalArgumentException("Object instance cannot be null");
Collection<Method> methods =
PRE_DESTROY_METHOD_FINDER.process(instance.getClass());
-
+
if (methods.size() > 0)
{
Method method = methods.iterator().next();
@@ -246,10 +246,10 @@
}
}
}
-
+
/**
* Injects @Resource annotated method.
- *
+ *
* @param method to invoke
* @param instance to invoke method on
* @param resourceName resource name
@@ -266,10 +266,10 @@
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
@@ -282,14 +282,14 @@
{
final String beanName = field.getName();
final Object value = ctx.lookup(getName(resourceName, beanName));
-
+
LOG.debug("Injecting field: " + field);
setField(instance, field, value);
}
/**
* Translates "setBeanName" to "beanName" string.
- *
+ *
* @param methodName to translate
* @return bean name
*/
@@ -297,10 +297,10 @@
{
return Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
}
-
+
/**
* Returns full JNDI name.
- *
+ *
* @param resourceName to be used if specified
* @param beanName fallback bean name to be used
* @return JNDI full name
@@ -309,10 +309,10 @@
{
return JNDI_PREFIX + (resourceName.length() > 0 ? resourceName : beanName);
}
-
+
/**
* Invokes method on object with specified arguments.
- *
+ *
* @param instance to invoke method on
* @param method method to invoke
* @param args arguments to pass
@@ -322,7 +322,7 @@
throws Exception
{
boolean accessability = method.isAccessible();
-
+
try
{
method.setAccessible(true);
@@ -333,7 +333,7 @@
method.setAccessible(accessability);
}
}
-
+
/**
* Sets field on object with specified value.
*
@@ -346,7 +346,7 @@
throws Exception
{
boolean accessability = field.isAccessible();
-
+
try
{
field.setAccessible(true);
@@ -357,10 +357,10 @@
field.setAccessible(accessability);
}
}
-
+
/**
* 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
@@ -369,13 +369,13 @@
private static Method getMethod(final InjectionMetaData injectionMD, final
Class<?> clazz)
{
final Collection<Method> result = new
InjectionMethodFinder(injectionMD).process(clazz);
-
+
return result.isEmpty() ? null : result.iterator().next();
}
-
+
/**
* 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
@@ -384,8 +384,8 @@
private static Field getField(final InjectionMetaData injectionMD, final
Class<?> clazz)
{
final Collection<Field> result = new
InjectionFieldFinder(injectionMD).process(clazz);
-
+
return result.isEmpty() ? null : result.iterator().next();
}
-
+
}
Modified: common/trunk/src/main/java/org/jboss/wsf/common/javax/PreDestroyHolder.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/javax/PreDestroyHolder.java 2009-04-03
19:41:08 UTC (rev 9727)
+++ common/trunk/src/main/java/org/jboss/wsf/common/javax/PreDestroyHolder.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -29,31 +29,32 @@
{
private final Object object;
private final int hashCode;
-
+
public PreDestroyHolder(Object object)
{
super();
this.hashCode = System.identityHashCode(object);
this.object = object;
}
-
+
public final Object getObject()
{
return this.object;
}
-
+
public final boolean equals(Object o)
{
if (o instanceof PreDestroyHolder)
{
return ((PreDestroyHolder)o).hashCode == this.hashCode;
}
-
+
return false;
}
-
+
public final int hashCode()
{
return this.hashCode;
}
+
}
\ No newline at end of file
Modified:
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 2009-04-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/AbstractPostConstructPreDestroyAnnotatedMethodFinder.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -38,7 +38,7 @@
/**
* Constructor.
- *
+ *
* @param annotationClass annotation.
*/
AbstractPostConstructPreDestroyAnnotatedMethodFinder(final Class<A>
annotationClass)
@@ -67,5 +67,5 @@
ReflectionUtils.assertNoCheckedExceptionsAreThrown(method, annotation);
ReflectionUtils.assertNotStatic(method, annotation);
}
-
+
}
Modified:
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 2009-04-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionFieldFinder.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -22,7 +22,6 @@
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;
@@ -36,22 +35,22 @@
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;
}
@@ -72,7 +71,7 @@
return true;
}
}
-
+
return false;
}
@@ -80,7 +79,7 @@
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);
@@ -91,10 +90,10 @@
public void validate(final Field field)
{
super.validate(field);
-
+
ReflectionUtils.assertNotVoidType(field);
ReflectionUtils.assertNotStatic(field);
ReflectionUtils.assertNotPrimitiveType(field);
}
-
+
}
Modified:
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 2009-04-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/InjectionMethodFinder.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -35,22 +35,22 @@
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;
}
@@ -77,7 +77,7 @@
}
}
}
-
+
return false;
}
@@ -85,7 +85,7 @@
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);
@@ -96,7 +96,7 @@
public void validate(final Method method)
{
super.validate(method);
-
+
ReflectionUtils.assertVoidReturnType(method);
ReflectionUtils.assertOneParameter(method);
ReflectionUtils.assertNoPrimitiveParameters(method);
@@ -104,5 +104,5 @@
ReflectionUtils.assertNoCheckedExceptionsAreThrown(method);
ReflectionUtils.assertNotStatic(method);
}
-
+
}
Modified:
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 2009-04-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PostConstructMethodFinder.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -46,7 +46,7 @@
public final class PostConstructMethodFinder
extends AbstractPostConstructPreDestroyAnnotatedMethodFinder<PostConstruct>
{
-
+
/**
* Constructor.
*/
@@ -54,5 +54,5 @@
{
super(PostConstruct.class);
}
-
+
}
Modified:
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 2009-04-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/PreDestroyMethodFinder.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -46,7 +46,7 @@
public final class PreDestroyMethodFinder
extends AbstractPostConstructPreDestroyAnnotatedMethodFinder<PreDestroy>
{
-
+
/**
* Constructor.
*/
@@ -54,5 +54,5 @@
{
super(PreDestroy.class);
}
-
+
}
Modified:
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 2009-04-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ReflectionUtils.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -34,7 +34,7 @@
*/
final class ReflectionUtils
{
-
+
/**
* Constructor.
*/
@@ -42,10 +42,10 @@
{
super();
}
-
+
/**
* Asserts method don't declare primitive parameters.
- *
+ *
* @param method to validate
* @param annotation annotation to propagate in exception message
*/
@@ -59,20 +59,20 @@
}
}
}
-
+
/**
* 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
*/
@@ -83,20 +83,20 @@
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
*/
@@ -107,10 +107,10 @@
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)
@@ -120,7 +120,7 @@
/**
* Asserts method return void.
- *
+ *
* @param method to validate
* @param annotation annotation to propagate in exception message
*/
@@ -131,20 +131,20 @@
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
*/
@@ -158,7 +158,7 @@
/**
* Asserts field isn't of void type.
- *
+ *
* @param field to validate
*/
public static void assertNotVoidType(final Field field)
@@ -168,7 +168,7 @@
/**
* Asserts method don't throw checked exceptions.
- *
+ *
* @param method to validate
* @param annotation annotation to propagate in exception message
*/
@@ -187,7 +187,7 @@
/**
* Asserts method don't throw checked exceptions.
- *
+ *
* @param method to validate
*/
public static void assertNoCheckedExceptionsAreThrown(final Method method)
@@ -197,7 +197,7 @@
/**
* Asserts method is not static.
- *
+ *
* @param method to validate
* @param annotation annotation to propagate in exception message
*/
@@ -211,7 +211,7 @@
/**
* Asserts method is not static.
- *
+ *
* @param method to validate
*/
public static void assertNotStatic(final Method method)
@@ -221,7 +221,7 @@
/**
* Asserts field is not static.
- *
+ *
* @param field to validate
* @param annotation annotation to propagate in exception message
*/
@@ -235,7 +235,7 @@
/**
* Asserts field is not static.
- *
+ *
* @param field to validate
*/
public static void assertNotStatic(final Field field)
@@ -245,7 +245,7 @@
/**
* Asserts method have exactly one parameter.
- *
+ *
* @param method to validate
* @param annotation annotation to propagate in exception message
*/
@@ -256,20 +256,20 @@
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
*/
@@ -279,26 +279,26 @@
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
*/
@@ -309,20 +309,20 @@
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
*/
@@ -330,5 +330,5 @@
{
return annotation == null ? "" : "annotated with @" +
annotation + " annotation ";
}
-
+
}
Modified:
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 2009-04-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceFieldFinder.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -46,7 +46,7 @@
public final class ResourceFieldFinder
extends AnnotatedFieldFinder<Resource>
{
-
+
/**
* Parameter type to accept/ignore.
*/
@@ -56,20 +56,20 @@
* <ul>
* <li><b>true</b> means include only methods with
<b>accept</b> parameter,
* <li><b>false</b> means exclude all methods with
<b>accept</b> parameter
- * </ul>
+ * </ul>
*/
private final boolean include;
-
+
/**
* Constructor.
- *
+ *
* @param accept filtering class
* @param include whether include/exclude filtering class
*/
public ResourceFieldFinder(final Class<?> accept, boolean include)
{
super(Resource.class);
-
+
this.accept = accept;
this.include = include;
}
@@ -90,7 +90,7 @@
public boolean matches(Field field)
{
final boolean matches = super.matches(field);
-
+
if (matches)
{
// processing @Resource annotated method
Modified:
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 2009-04-03
19:41:08 UTC (rev 9727)
+++
common/trunk/src/main/java/org/jboss/wsf/common/javax/finders/ResourceMethodFinder.java 2009-04-03
19:56:50 UTC (rev 9728)
@@ -45,7 +45,7 @@
public final class ResourceMethodFinder
extends AnnotatedMethodFinder<Resource>
{
-
+
/**
* Parameter type to accept/ignore.
*/
@@ -55,20 +55,20 @@
* <ul>
* <li><b>true</b> means include only methods with
<b>accept</b> parameter,
* <li><b>false</b> means exclude all methods with
<b>accept</b> parameter
- * </ul>
+ * </ul>
*/
private final boolean include;
-
+
/**
* Constructor.
- *
+ *
* @param accept filtering class
* @param include whether include/exclude filtering class
*/
public ResourceMethodFinder(final Class<?> accept, boolean include)
{
super(Resource.class);
-
+
this.accept = accept;
this.include = include;
}
@@ -92,7 +92,7 @@
public boolean matches(Method method)
{
final boolean matches = super.matches(method);
-
+
if (matches)
{
// processing @Resource annotated method