[webbeans-commits] Webbeans SVN: r382 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: util and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-29 17:34:31 -0500 (Sat, 29 Nov 2008)
New Revision: 382
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/Location.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NameResolutionLocation.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NotAScopeException.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Types.java
Log:
javadocs/comments
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/Location.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/Location.java 2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/Location.java 2008-11-29 22:34:31 UTC (rev 382)
@@ -1,14 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.exceptions;
+/**
+ * Helper superclass for exception information
+ *
+ * @author Pete Muir
+ */
public class Location
{
-
+ // The category of the exception
private String type;
-
+ // The bean the exception occurred in
private String bean;
-
+ // The element the exception occurred in
private String element;
+ /**
+ * Constructor
+ *
+ * @param type The category
+ * @param bean The bean
+ * @param element The element
+ */
public Location(String type, String bean, String element)
{
super();
@@ -17,36 +46,71 @@
this.element = element;
}
+ /**
+ * Gets the type of the exception
+ *
+ * @return The type
+ */
public String getType()
{
return type;
}
+ /**
+ * Sets the type of the exception
+ *
+ * @param type The type
+ */
public void setType(String type)
{
this.type = type;
}
+ /**
+ * Gets the bean the exception occurred in
+ *
+ * @return The bean
+ */
public String getBean()
{
return bean;
}
+ /**
+ * Sets the bean the exception occurred in
+ *
+ * @param bean The bean
+ */
public void setBean(String bean)
{
this.bean = bean;
}
+ /**
+ * Gets the element the exception occurred in
+ *
+ * @return The element
+ */
public String getElement()
{
return element;
}
+ /**
+ * Sets the element the exception occurred in
+ *
+ * @param element The element
+ */
public void setElement(String element)
{
this.element = element;
}
+ /**
+ * Gets the summarizing message
+ *
+ * @return The message
+ */
protected String getMessage()
{
String location = "";
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NameResolutionLocation.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NameResolutionLocation.java 2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NameResolutionLocation.java 2008-11-29 22:34:31 UTC (rev 382)
@@ -1,26 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.exceptions;
+/**
+ * Exception location info for name resolution exceptions
+ *
+ * @author Pete Muir
+ */
public class NameResolutionLocation extends Location
{
-
+ // The target of the failure
private String target;
+ /**
+ * Constructor
+ *
+ * @param target The target of the failure
+ */
public NameResolutionLocation(String target)
{
super("Named Based Resolution", null, null);
}
+ /**
+ * Gets the target
+ *
+ * @return The target
+ */
public String getTarget()
{
return target;
}
+ /**
+ * Sets the target
+ *
+ * @param target The target
+ */
public void setTarget(String target)
{
this.target = target;
}
+ /**
+ * Gets the exception message
+ *
+ * @return The message
+ */
@Override
protected String getMessage()
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NotAScopeException.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NotAScopeException.java 2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/exceptions/NotAScopeException.java 2008-11-29 22:34:31 UTC (rev 382)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.exceptions;
import javax.webbeans.DefinitionException;
@@ -2,5 +19,14 @@
+/**
+ * Exception for incorrect scope usage
+ *
+ * @author Pete Muir
+ */
public class NotAScopeException extends DefinitionException
{
+ private static final long serialVersionUID = 1L;
+ /**
+ * Constructor
+ */
public NotAScopeException()
@@ -10,19 +36,35 @@
super();
}
+ /**
+ * Constructor
+ *
+ * @param message The exception message
+ * @param throwable The root exception
+ */
public NotAScopeException(String message, Throwable throwable)
{
super(message, throwable);
}
+ /**
+ * Constructor
+ *
+ * @param message The exception message
+ */
public NotAScopeException(String message)
{
super(message);
}
+ /**
+ * Constructor
+ *
+ * @param throwable The root exception
+ */
public NotAScopeException(Throwable throwable)
{
super(throwable);
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-11-29 22:34:31 UTC (rev 382)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.util;
import java.lang.reflect.Method;
@@ -11,33 +28,90 @@
import org.jboss.webbeans.bean.XmlSimpleBean;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+/**
+ * Utility class for creating Web Beans
+ *
+ * @author Pete Muir
+ */
public class BeanFactory
{
+ /**
+ * Creates a simple, annotation defined Web Bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager The Web Beans manager
+ * @return A Web Bean
+ */
public static <T> SimpleBean<T> createSimpleBean(Class<T> clazz, ManagerImpl manager)
{
return new SimpleBean<T>(clazz, manager);
}
+ /**
+ * Creates a simple, XML defined Web Bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager The Web Beans manager
+ * @return A Web Bean
+ */
public static <T> XmlSimpleBean<T> createXmlSimpleBean(Class<T> clazz, ManagerImpl manager)
{
return new XmlSimpleBean<T>(clazz, manager);
}
+ /**
+ * Creates a simple, annotation defined Enterprise Web Bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager The Web Beans manager
+ * @return An Enterprise Web Bean
+ */
public static <T> EnterpriseBean<T> createEnterpriseBean(Class<T> clazz, ManagerImpl manager)
{
return new EnterpriseBean<T>(clazz, manager);
}
+ /**
+ * Creates a simple, XML defined Enterprise Web Bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager The Web Beans manager
+ * @return An Enterprise Web Bean
+ */
public static <T> XmlEnterpriseBean<T> createXmlEnterpriseBean(Class<T> clazz, ManagerImpl manager)
{
return new XmlEnterpriseBean<T>(clazz, manager);
}
+ /**
+ * Creates a producer method Web Bean
+ *
+ * @param <T> The type
+ * @param type The class
+ * @param method The underlying method
+ * @param manager The Web Beans manager
+ * @param declaringBean The declaring bean abstraction
+ * @return A producer Web Bean
+ */
public static <T> ProducerMethodBean<T> createProducerMethodBean(Class<T> type, Method method, ManagerImpl manager, AbstractClassBean<?> declaringBean)
{
return new ProducerMethodBean<T>(method, declaringBean, manager);
}
-
+
+ /**
+ * Creates a producer method Web Bean
+ *
+ * @param <T> The type
+ * @param type The class
+ * @param method The underlying method
+ * @param manager The Web Beans manager
+ * @param declaringBean The declaring bean abstraction
+ * @return A producer Web Bean
+ */
public static <T> ProducerMethodBean<T> createProducerMethodBean(Class<T> type, AnnotatedMethod<T> method, ManagerImpl manager, AbstractClassBean<?> declaringBean)
{
return new ProducerMethodBean<T>(method, declaringBean, manager);
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java 2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java 2008-11-29 22:34:31 UTC (rev 382)
@@ -1,14 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.util;
-
+/**
+ * Provides JNDI access abstraction
+ *
+ * @author Pete Muir
+ */
public class JNDI
{
+ /**
+ * Looks up a object in JNDI
+ *
+ * @param name The JNDI name
+ * @return The object
+ */
public static Object lookup(String name)
{
return lookup(name, Object.class);
}
+ /**
+ * Typed JNDI lookup
+ *
+ * @param <T> The type
+ * @param name The JNDI name
+ * @param expectedType The excpected type
+ * @return The object
+ */
public static <T> T lookup(String name, Class<? extends T> expectedType)
{
return null;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-11-29 22:34:31 UTC (rev 382)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.util;
import java.beans.Introspector;
@@ -18,9 +35,22 @@
import javax.webbeans.ExecutionException;
+/**
+ * Utility class for static reflection-type operations
+ *
+ * @author Pete Muir
+ *
+ */
public class Reflections
{
+ /**
+ * Creates an instance from a class name
+ *
+ * @param name The class name
+ * @return The instance
+ * @throws ClassNotFoundException If the class if not found
+ */
public static Class<?> classForName(String name) throws ClassNotFoundException
{
try
@@ -33,6 +63,13 @@
}
}
+ /**
+ * Gets the property name from a getter method
+ *
+ * @param method The getter method
+ * @return The name of the property. Returns null if method wasn't JavaBean
+ * getter-styled
+ */
public static String getPropertyName(Method method)
{
String methodName = method.getName();
@@ -51,16 +88,34 @@
}
+ /**
+ * Checks if class is final
+ *
+ * @param clazz The class to check
+ * @return True if final, false otherwise
+ */
public static boolean isFinal(Class<?> clazz)
{
return Modifier.isFinal(clazz.getModifiers());
}
+ /**
+ * Checks if member is final
+ *
+ * @param member The member to check
+ * @return True if final, false otherwise
+ */
public static boolean isFinal(Member member)
{
return Modifier.isFinal(member.getModifiers());
}
+ /**
+ * Checks if type or member is final
+ *
+ * @param type Type or member
+ * @return True if final, false otherwise
+ */
public static boolean isTypeOrAnyMethodFinal(Class<?> type)
{
if (isFinal(type))
@@ -77,36 +132,80 @@
return false;
}
+ /**
+ * Checks if type is primitive
+ *
+ * @param type Type to check
+ * @return True if primitive, false otherwise
+ */
public static boolean isPrimitive(Class<?> type)
{
return type.isPrimitive();
}
+ /**
+ * Checks if type is static
+ *
+ * @param type Type to check
+ * @return True if static, false otherwise
+ */
public static boolean isStatic(Class<?> type)
{
return Modifier.isStatic(type.getModifiers());
}
+ /**
+ * Checks if member is static
+ *
+ * @param member Member to check
+ * @return True if static, false otherwise
+ */
public static boolean isStatic(Member member)
{
return Modifier.isStatic(member.getModifiers());
}
+ /**
+ * Checks if clazz is abstract
+ *
+ * @param clazz Class to check
+ * @return True if abstract, false otherwise
+ */
public static boolean isAbstract(Class<?> clazz)
{
return Modifier.isAbstract(clazz.getModifiers());
}
+ /**
+ * Checks if class is a static inner one
+ *
+ * @param clazz Class to check
+ * @return True if static, false otherwise
+ */
public static boolean isStaticInnerClass(Class<?> clazz)
{
return clazz.isMemberClass() && isStatic(clazz);
}
+ /**
+ * Checks if class is a non-static inner one
+ *
+ * @param clazz Class to Check
+ * @return True if static, false otherwise
+ */
public static boolean isNonStaticInnerClass(Class<?> clazz)
{
return clazz.isMemberClass() && !isStatic(clazz);
}
+ /**
+ * Gets a constructor with matching parameter types
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param parameterTypes The parameter types
+ * @return The matching constructor. Null is returned if none is found
+ */
public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... parameterTypes)
{
try
@@ -123,6 +222,14 @@
}
}
+ /**
+ * Gets all methods with a given annotation
+ *
+ * @param clazz The class the examine
+ * @param annotationType The annotation type to search for
+ * @return A list of matching methods. An empty list is returned if no
+ * matches are found
+ */
public static List<Method> getMethods(Class<?> clazz, Class<? extends Annotation> annotationType)
{
List<Method> methods = new ArrayList<Method>();
@@ -136,6 +243,15 @@
return methods;
}
+ /**
+ * Gets all constructors with a given annotation
+ *
+ * @param <T> The type of the class
+ * @param clazz The class
+ * @param annotationType The annotation type
+ * @return A list of matching constructors. An empty list is returned if no
+ * matches are found
+ */
@SuppressWarnings("unchecked")
public static <T> List<Constructor<T>> getAnnotatedConstructors(Class<? extends T> clazz, Class<? extends Annotation> annotationType)
{
@@ -150,6 +266,15 @@
return constructors;
}
+ /**
+ * Gets constructors with a given annotated parameter
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param parameterAnnotationType The parameter annotation type
+ * @return A list of matching constructors. An empty list is returned if no
+ * matches are found
+ */
@SuppressWarnings("unchecked")
public static <T> List<Constructor<T>> getConstructorsForAnnotatedParameter(Class<? extends T> clazz, Class<? extends Annotation> parameterAnnotationType)
{
@@ -170,6 +295,15 @@
return constructors;
}
+ /**
+ * Gets constructors with a given meta-annotated parameter
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param metaAnnotationType The parameter meta-annotation type
+ * @return A list of matching constructors. An empty list is returned if no
+ * matches are found
+ */
@SuppressWarnings("unchecked")
public static <T> List<Constructor<T>> getConstructorsForMetaAnnotatedParameter(Class<? extends T> clazz, Class<? extends Annotation> metaAnnotationType)
{
@@ -190,6 +324,13 @@
return constructors;
}
+ /**
+ * Checks if all annotations types are in a given set of annotations
+ *
+ * @param annotations The annotation set
+ * @param annotationTypes The annotation types to match
+ * @return True if match, false otherwise
+ */
public static boolean annotationTypeSetMatches(Set<Class<? extends Annotation>> annotations, Class<? extends Annotation>... annotationTypes)
{
List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
@@ -208,6 +349,13 @@
return annotationTypeList.size() == 0;
}
+ /**
+ * Checks if all annotations are in a given set of annotations
+ *
+ * @param annotations The annotation set
+ * @param annotationTypes The annotations to match
+ * @return True if match, false otherwise
+ */
public static boolean annotationSetMatches(Set<Annotation> annotations, Class<? extends Annotation>... annotationTypes)
{
List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
@@ -226,6 +374,12 @@
return annotationTypeList.size() == 0;
}
+ /**
+ * Gets the actual type arguments of a class
+ *
+ * @param clazz The class to examine
+ * @return The type arguments
+ */
public static Type[] getActualTypeArguments(Class<?> clazz)
{
if (clazz.getGenericSuperclass() instanceof ParameterizedType)
@@ -238,16 +392,36 @@
}
}
+ /**
+ * Checks if raw type is array type
+ *
+ * @param rawType The raw type to check
+ * @return True if array, false otherwise
+ */
public static boolean isArrayType(Class<?> rawType)
{
return rawType.isArray();
}
+ /**
+ * Checks if type is parameterized type
+ *
+ * @param type The type to check
+ * @return True if parameterized, false otherwise
+ */
public static boolean isParameterizedType(Class<?> type)
{
return type.getTypeParameters().length > 0;
}
+ /**
+ * Invokes a method and wraps exceptions
+ *
+ * @param method The method to invoke
+ * @param instance The instance to invoke on
+ * @param parameters The parameters
+ * @return The return value
+ */
public static Object invokeAndWrap(Method method, Object instance, Object... parameters)
{
try
@@ -268,6 +442,13 @@
}
}
+ /**
+ * Sets value of a field and wraps exceptions
+ *
+ * @param field The field to set on
+ * @param target The instance to set on
+ * @param value The value to set
+ */
public static void setAndWrap(Field field, Object target, Object value)
{
try
@@ -284,6 +465,13 @@
}
}
+ /**
+ * Looks up a method in the type hierarchy of an instance
+ *
+ * @param method The method to look for
+ * @param instance The instance to start from
+ * @return The method found, or an NoSuchMethodException if it is not found
+ */
public static Method lookupMethod(Method method, Object instance)
{
for (Class<? extends Object> clazz = instance.getClass(); clazz != Object.class; clazz = clazz.getSuperclass())
@@ -305,6 +493,12 @@
throw new IllegalArgumentException("Method " + method.getName() + " not implemented by instance");
}
+ /**
+ * Indicates if an instance is a Javassist proxy
+ *
+ * @param instance The instance to examine
+ * @return True if proxy, false otherwise
+ */
public static boolean isProxy(Object instance)
{
return instance.getClass().getName().indexOf("_$$_javassist_") > 0;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java 2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java 2008-11-29 22:34:31 UTC (rev 382)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.util;
import java.beans.Introspector;
@@ -7,14 +24,33 @@
import java.util.Map;
import java.util.StringTokenizer;
+/**
+ * String utilities
+ *
+ * @author Pete Muir
+ *
+ */
public class Strings
{
+ /**
+ * Decapitalizes a String
+ *
+ * @param camelCase The String
+ * @return The decapitalized result
+ */
public static String decapitalize(String camelCase)
{
return Introspector.decapitalize(camelCase);
}
+ /**
+ * Split a string into parts
+ *
+ * @param strings The sources
+ * @param delims The delimeter
+ * @return The parts
+ */
public static String[] split(String strings, String delims)
{
if (strings == null)
@@ -34,6 +70,13 @@
}
}
+ /**
+ * Returns a textual representation of a map for debug purposes
+ *
+ * @param header The description of the map
+ * @param map The map
+ * @return A textual representation
+ */
public static String mapToString(String header, Map<?, ?> map)
{
StringBuffer buffer = new StringBuffer();
@@ -48,7 +91,7 @@
buffer.append("\n");
for (Object subValue : (Iterable<?>) value)
{
- buffer.append(" " + subValue.toString() + "\n");
+ buffer.append(" " + subValue.toString() + "\n");
}
}
else
@@ -59,15 +102,18 @@
return buffer.toString();
}
- public static void main(String[] args) {
- Map map = new HashMap<String, Collection<?>>();
- Collection a = new ArrayList<String>();
- a.add("1"); a.add("2");
- map.put("foo", a);
- Collection b = new ArrayList<String>();
- b.add("3"); b.add("4");
- map.put("bar", b);
- System.out.println(mapToString("Header: ", map));
+ public static void main(String[] args)
+ {
+ Map map = new HashMap<String, Collection<?>>();
+ Collection a = new ArrayList<String>();
+ a.add("1");
+ a.add("2");
+ map.put("foo", a);
+ Collection b = new ArrayList<String>();
+ b.add("3");
+ b.add("4");
+ map.put("bar", b);
+ System.out.println(mapToString("Header: ", map));
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Types.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Types.java 2008-11-29 21:17:54 UTC (rev 381)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Types.java 2008-11-29 22:34:31 UTC (rev 382)
@@ -1,8 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.util;
+/**
+ * Utility class for Types
+ *
+ * @author Pete Muir
+ */
public class Types
{
-
+
+ /**
+ * Gets the boxed type of a class
+ *
+ * @param type The type
+ * @return The boxed type
+ */
public static Class<?> boxedType(Class<?> type)
{
if (type.isPrimitive())
@@ -39,7 +67,7 @@
{
return Double.class;
}
- else
+ else
{
throw new IllegalStateException("Some weird type!!!");
}
@@ -49,5 +77,5 @@
return type;
}
}
-
+
}
15 years, 12 months
[webbeans-commits] Webbeans SVN: r381 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: bootstrap and 4 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-29 16:17:54 -0500 (Sat, 29 Nov 2008)
New Revision: 381
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ApplicationScopedAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ConversationScopedAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/CurrentAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/DependentAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/NamedAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ProductionAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/RequestScopedAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/StandardAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/DeploymentProperties.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/TransactionObservationPhase.java
Log:
javadocs/comments
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ApplicationScopedAnnotationLiteral.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ApplicationScopedAnnotationLiteral.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ApplicationScopedAnnotationLiteral.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.ApplicationScoped;
+/**
+ * Annotation literal for @ApplicationScoped
+ *
+ * @author Pete Muir
+ */
public class ApplicationScopedAnnotationLiteral extends AnnotationLiteral<ApplicationScoped> implements ApplicationScoped
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ConversationScopedAnnotationLiteral.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ConversationScopedAnnotationLiteral.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ConversationScopedAnnotationLiteral.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.ConversationScoped;
+/**
+ * Annotation literal for @ConversationScoped
+ *
+ * @author Pete Muir
+ */
public class ConversationScopedAnnotationLiteral extends AnnotationLiteral<ConversationScoped> implements ConversationScoped
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/CurrentAnnotationLiteral.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/CurrentAnnotationLiteral.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/CurrentAnnotationLiteral.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,3 +20,8 @@
import javax.webbeans.Current;
+/**
+ * Annotation literal for @Current
+ *
+ * @author Pete Muir
+ */
public class CurrentAnnotationLiteral extends AnnotationLiteral<Current> implements Current {}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/DependentAnnotationLiteral.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/DependentAnnotationLiteral.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/DependentAnnotationLiteral.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.Dependent;
+/**
+ * Annotation literal for @Dependent
+ *
+ * @author Pete Muir
+ */
public class DependentAnnotationLiteral extends AnnotationLiteral<Dependent> implements Dependent
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/NamedAnnotationLiteral.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/NamedAnnotationLiteral.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/NamedAnnotationLiteral.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,3 +20,10 @@
import javax.webbeans.Named;
-public abstract class NamedAnnotationLiteral extends AnnotationLiteral<Named> implements Named {}
\ No newline at end of file
+/**
+ * Annotation literal for @Named
+ *
+ * @author Pete Muir
+ */
+public abstract class NamedAnnotationLiteral extends AnnotationLiteral<Named> implements Named
+{
+}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ProductionAnnotationLiteral.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ProductionAnnotationLiteral.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ProductionAnnotationLiteral.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.Production;
+/**
+ * Annotation literal for @Production
+ *
+ * @author Pete Muir
+ */
public class ProductionAnnotationLiteral extends AnnotationLiteral<Production> implements Production
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/RequestScopedAnnotationLiteral.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/RequestScopedAnnotationLiteral.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/RequestScopedAnnotationLiteral.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.RequestScoped;
+/**
+ * Annotation literal for @RequestScoped
+ *
+ * @author Pete Muir
+ */
public class RequestScopedAnnotationLiteral extends AnnotationLiteral<RequestScoped> implements RequestScoped
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/StandardAnnotationLiteral.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/StandardAnnotationLiteral.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/StandardAnnotationLiteral.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.Standard;
+/**
+ * Annotation literal for @Standard
+ *
+ * @author Pete Muir
+ */
public class StandardAnnotationLiteral extends AnnotationLiteral<Standard> implements Standard
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bootstrap;
import static org.jboss.webbeans.util.BeanFactory.createEnterpriseBean;
@@ -17,49 +34,89 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+/**
+ * Bootstrapping functionality that is run at application startup and detects
+ * and register beans
+ *
+ * @author Pete Muir
+ */
public class Bootstrap
{
-
+ // The property name of the discovery class
public static String WEB_BEAN_DISCOVERY_PROPERTY_NAME = "org.jboss.webbeans.bootstrap.webBeanDiscovery";
-
+
private static LogProvider log = Logging.getLogProvider(Bootstrap.class);
-
+
+ // The Web Beans manager
private ManagerImpl manager;
-
+
+ /**
+ * Constructor
+ *
+ * Starts up with a fresh manager
+ */
public Bootstrap()
{
this(new ManagerImpl());
}
-
+
+ /**
+ * Constructor
+ *
+ * @param manager The Web Beans manager
+ */
protected Bootstrap(ManagerImpl manager)
{
this.manager = manager;
}
-
+
/**
* Register any beans defined by the provided classes with the manager
+ *
+ * @param classes The classes to register
*/
- public void registerBeans(Class<?>...classes)
+ public void registerBeans(Class<?>... classes)
{
registerBeans(new HashSet<Class<?>>(Arrays.asList(classes)));
}
-
+
+ /**
+ * Register the bean with the manager
+ *
+ * Creates the beans first and then sets them in the manager
+ *
+ * @param classes The classes to register as Web Beans
+ */
public void registerBeans(Iterable<Class<?>> classes)
{
Set<AbstractBean<?, ?>> beans = createBeans(classes);
manager.setBeans(beans);
}
-
+
/**
* Discover any beans defined by the provided classes
*
* Beans discovered are not registered with the manager
+ *
+ * @param classes The classes to create Web Beans from
+ * @return A set of Web Beans that represents the classes
*/
public Set<AbstractBean<?, ?>> createBeans(Class<?>... classes)
{
return createBeans(new HashSet<Class<?>>(Arrays.asList(classes)));
}
-
+
+ /**
+ * Creates Web Beans from a set of classes
+ *
+ * Iterates over the classes and creates a Web Bean of the corresponding
+ * type. Also register the beans injection points with the resolver. If the
+ * bean has producer methods, producer beans are created for these and those
+ * injection points are also registered.
+ *
+ * @param classes The classes to adapt
+ * @return A set of adapted Web Beans
+ */
public Set<AbstractBean<?, ?>> createBeans(Iterable<Class<?>> classes)
{
Set<AbstractBean<?, ?>> beans = new HashSet<AbstractBean<?, ?>>();
@@ -87,6 +144,14 @@
return beans;
}
+ /**
+ * Starts the boot process.
+ *
+ * Discovers the beans and registers them with the manager. Also resolves the
+ * injection points.
+ *
+ * @param webBeanDiscovery The discovery implementation
+ */
public void boot(WebBeanDiscovery webBeanDiscovery)
{
log.info("Starting Web Beans RI " + getVersion());
@@ -98,35 +163,47 @@
log.info("Validing Web Bean injection points");
manager.getResolver().resolveInjectionPoints();
}
-
+
+ /**
+ * Gets version information
+ *
+ * @return The implementation version from the Bootstrap class package.
+ */
public static String getVersion()
{
Package pkg = Bootstrap.class.getPackage();
- return pkg != null ? pkg.getImplementationVersion() : null;
+ return pkg != null ? pkg.getImplementationVersion() : null;
}
-
-
+
+ /**
+ * Gets the available discovery implementations
+ *
+ * Parses the web-beans-ri.properties file and for each row describing a
+ * discover class, instantiate that class and add it to the set
+ *
+ * @return A set of discovery implementations
+ * @see org.jboss.webbeans.bootstrap.DeploymentProperties
+ */
+ @SuppressWarnings("unchecked")
public static Set<Class<? extends WebBeanDiscovery>> getWebBeanDiscoveryClasses()
{
Set<Class<? extends WebBeanDiscovery>> webBeanDiscoveryClasses = new HashSet<Class<? extends WebBeanDiscovery>>();
for (String className : new DeploymentProperties(Thread.currentThread().getContextClassLoader()).getPropertyValues(WEB_BEAN_DISCOVERY_PROPERTY_NAME))
{
- Class<WebBeanDiscovery> webBeanDiscoveryClass = null;
try
{
webBeanDiscoveryClasses.add((Class<WebBeanDiscovery>) Class.forName(className));
}
- catch (ClassNotFoundException e)
+ catch (ClassNotFoundException e)
{
log.debug("Unable to load WebBeanDiscovery provider " + className, e);
}
- catch (NoClassDefFoundError e) {
+ catch (NoClassDefFoundError e)
+ {
log.warn("Unable to load WebBeanDiscovery provider " + className + " due classDependencyProblem", e);
}
}
return webBeanDiscoveryClasses;
}
-
-
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/DeploymentProperties.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/DeploymentProperties.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/DeploymentProperties.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bootstrap;
import static org.jboss.webbeans.util.Strings.split;
@@ -10,52 +27,74 @@
import java.util.List;
import java.util.Properties;
-/*
+/**
* Utility class to load deployment properties
+ *
+ * @author Pete Muir
*/
public class DeploymentProperties
{
-
+ // The resource bundle used to control Web Beans RI deployment
+ public static final String RESOURCE_BUNDLE = "META-INF/web-beans-ri.properties";
+
+ // The class to work from
private ClassLoader classLoader;
+ // An enumeration of URLs to work on
private Enumeration<URL> urlEnum;
-
+
+ /**
+ * Constructor
+ *
+ * @param classLoader The classloader to work on
+ */
public DeploymentProperties(ClassLoader classLoader)
{
this.classLoader = classLoader;
}
/**
- * The resource bundle used to control Web Beans RI deployment
- */
- public static final String RESOURCE_BUNDLE = "META-INF/web-beans-ri.properties";
-
- /**
* Get a list of possible values for a given key.
*
* First, System properties are tried, followed by the specified resource
* bundle (first in classpath only).
*
- * Colon (:) deliminated lists are split out.
+ * Colon (:) deliminated lists are split out. (gotta love Petes choice of
+ * ASCII art for that one ;-)
*
+ * @param key The key to search for
+ * @return A list of possible values. An empty list is returned if there are
+ * no matches.
*/
public List<String> getPropertyValues(String key)
{
- List<String>values = new ArrayList<String>();
+ List<String> values = new ArrayList<String>();
addPropertiesFromSystem(key, values);
addPropertiesFromResourceBundle(key, values);
return values;
}
-
+
+ /**
+ * Adds matches from system properties
+ *
+ * @param key The key to match
+ * @param values The currently found values
+ */
private void addPropertiesFromSystem(String key, List<String> values)
{
addProperty(key, System.getProperty(key), values);
}
-
+
+ /**
+ * Adds matches from detected resource bundles
+ *
+ * @param key The key to match
+ * @param values The currently found values
+ */
private void addPropertiesFromResourceBundle(String key, List<String> values)
{
try
- {
- while ( getResources().hasMoreElements() )
+ {
+ while (getResources().hasMoreElements())
{
URL url = getResources().nextElement();
Properties properties = new Properties();
@@ -74,14 +113,21 @@
}
}
}
- catch (IOException e)
+ catch (IOException e)
{
// No - op, file is optional
+ // TODO: Isn't this more of a open/read/close error? If the file wasn't
+ // there in the first place you wouldn't be in the loop?
}
}
-
- /*
- * Add the property to the set of properties only if it hasn't already been added
+
+ /**
+ * Add the property to the set of properties only if it hasn't already been
+ * added
+ *
+ * @param key The key searched for
+ * @param value The value of the property
+ * @param values The currently found values
*/
private void addProperty(String key, String value, List<String> values)
{
@@ -92,18 +138,24 @@
{
values.add(property);
}
-
+
}
}
-
+
+ /**
+ * Gets all Web Beans property files relative to the provided classloader
+ *
+ * @return An enumeration of URLs to the property files
+ * @throws IOException If the resource files could not be loaded
+ */
private Enumeration<URL> getResources() throws IOException
{
-
+
if (urlEnum == null)
{
urlEnum = classLoader.getResources(RESOURCE_BUNDLE);
}
return urlEnum;
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bootstrap.spi;
import java.lang.reflect.Method;
@@ -3,23 +20,38 @@
import java.util.Iterator;
+/**
+ * EJB metadata from the EJB descriptor
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
public interface EjbDescriptor<T>
{
/**
+ * Gets the EJB type
+ *
* @return The EJB Bean class
*/
public Class<T> getType();
/**
- * @return The JNDI name under which the EJB is registered
+ * Gets the JNDI name under which the EJB is registered
+ *
+ * @return The JNDI name
*/
public String getJndiName();
/**
- * @return The local interfaces of the EJB
+ * Gets the local interfaces of the EJB
+ *
+ * @return An iterator to the local interfaces
*/
public Iterator<Class<?>> getLocalInterfaces();
/**
- * @return The remove methods of the EJB
+ * Get the remove methods of the EJB
+ *
+ * @return An iterator the remove methods
*/
public Iterator<Method> getRemoveMethods();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.bootstrap.spi;
import java.net.URL;
@@ -13,17 +30,23 @@
public interface WebBeanDiscovery
{
/**
- * @return A list of all classes in classpath archives with web-beans.xml files
+ * Gets list of all classes in classpath archives with web-beans.xml files
+ *
+ * @return An iterable over the classes
*/
public Iterable<Class<?>> discoverWebBeanClasses();
/**
- * @return A list of all web-beans.xml files in the app classpath
+ * Gets a list of all web-beans.xml files in the app classpath
+ *
+ * @return An iterable over the web-beans.xml files
*/
public Iterable<URL> discoverWebBeansXml();
/**
- * @return A Map of EJB descriptors, keyed by the EJB bean class
+ * Gets a Map of EJB descriptors, keyed by the EJB bean class
+ *
+ * @return The bean class to descriptor map
*/
public Map<Class<?>, EjbDescriptor<?>> discoverEjbs();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,44 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.ejb;
-import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import javax.webbeans.CreationException;
import javax.webbeans.Standard;
import javax.webbeans.manager.EnterpriseBeanLookup;
import org.jboss.webbeans.util.JNDI;
+import org.jboss.webbeans.util.Strings;
+import com.google.common.collect.ForwardingMap;
+
+/**
+ * Provides lookup and metadata registration services for EJBs
+ *
+ * @author Pete Muir
+ * @see java.webbeans.manager.EnterpriseBeanLookup
+ */
@Standard
public class DefaultEnterpriseBeanLookup implements EnterpriseBeanLookup
{
- private Map<String, EjbMetaData<?>> ejbMetaDataMap = new HashMap<String, EjbMetaData<?>>();
-
+ /**
+ * An EJB name -> metadata map
+ */
+ private class EjbMetaDataMap extends ForwardingMap<String, EjbMetaData<?>>
+ {
+ private Map<String, EjbMetaData<?>> delegate;
+
+ public EjbMetaDataMap()
+ {
+ delegate = new ConcurrentHashMap<String, EjbMetaData<?>>();
+ }
+
+ @Override
+ protected Map<String, EjbMetaData<?>> delegate()
+ {
+ return delegate;
+ }
+
+ @Override
+ public String toString()
+ {
+ return Strings.mapToString("EjbMetaDataMap (EJB name -> metadata): ", delegate);
+ }
+ }
+
+ // A map from EJB name to EJB metadata
+ private EjbMetaDataMap ejbMetaDataMap = new EjbMetaDataMap();
+
+ /**
+ * Looks up and EJB based on the name
+ *
+ * Gets the EJB metadata and calls helper method
+ *
+ * @param ejbName The EJB name
+ * @return The EJB local home interface
+ * @see javax.webbeans.manager.EnterpriseBeanLookup#lookup(String)
+ */
public Object lookup(String ejbName)
{
- return lookup( ejbMetaDataMap.get(ejbName) );
+ return lookup(ejbMetaDataMap.get(ejbName));
}
-
- public static <T> T lookup(EjbMetaData<T> ejb)
+
+ /**
+ * Looks up an EJB
+ *
+ * First tried the EJB link JNDI name, if available, then the default JNDI
+ * name. Throws an CreationException if it isn't found.
+ *
+ * @param <T> The type of the EJB
+ * @param ejbMetaData The EJB metadata
+ * @return The EJB local interface
+ */
+ public static <T> T lookup(EjbMetaData<T> ejbMetaData)
{
- if (ejb.getEjbLinkJndiName() != null)
- {
- return JNDI.lookup(ejb.getEjbLinkJndiName(), ejb.getType());
- }
try
{
- return JNDI.lookup(ejb.getDefaultJndiName(), ejb.getType());
+ if (ejbMetaData.getEjbLinkJndiName() != null)
+ {
+ return JNDI.lookup(ejbMetaData.getEjbLinkJndiName(), ejbMetaData.getType());
+ }
+ return JNDI.lookup(ejbMetaData.getDefaultJndiName(), ejbMetaData.getType());
}
- catch (Exception e)
+ catch (Exception e)
{
throw new CreationException("could not find the EJB in JNDI", e);
}
}
-
- //TODO: this method needs to get called at startup
+
+ // TODO: this method needs to get called at startup
+ /**
+ * Creates and registers EJB metadata for a class
+ *
+ * @param clazz The EJB class
+ * @return the EJB metadata
+ */
public <T> EjbMetaData<T> registerEjbMetaData(Class<T> clazz)
{
- EjbMetaData<T> ejbMetaData = new EjbMetaData<T>(clazz);
+ EjbMetaData<T> ejbMetaData = new EjbMetaData<T>(clazz);
ejbMetaDataMap.put(ejbMetaData.getEjbName(), ejbMetaData);
return ejbMetaData;
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.ejb;
import java.lang.annotation.Annotation;
@@ -4,29 +21,46 @@
import org.jboss.webbeans.util.Reflections;
-
+/**
+ * Utility class for EJB annotations etc
+ *
+ * @author Pete Muir
+ */
public class EJB
{
-
- public @interface Dummy {}
-
+
+ public @interface Dummy
+ {
+ }
+
+ // Annotation instances
public static final Class<? extends Annotation> STATELESS_ANNOTATION;
public static final Class<? extends Annotation> STATEFUL_ANNOTATION;
public static final Class<? extends Annotation> MESSAGE_DRIVEN_ANNOTATION;
public static final Class<? extends Annotation> SINGLETON_ANNOTATION;
public static final Class<? extends Annotation> REMOVE_ANNOTATION;
-
- static
+
+ /**
+ * Static initialization block
+ */
+ static
{
STATELESS_ANNOTATION = classForName("javax.ejb.Stateless");
STATEFUL_ANNOTATION = classForName("javax.ejb.Stateful");
MESSAGE_DRIVEN_ANNOTATION = classForName("javax.ejb.MessageDriven");
-// FIXME Faking singleton
+ // FIXME Faking singleton
SINGLETON_ANNOTATION = classForName("org.jboss.webbeans.test.annotations.Singleton");
-// SINGLETON_ANNOTATION = classForName("javax.ejb.Singleton");
+ // SINGLETON_ANNOTATION = classForName("javax.ejb.Singleton");
REMOVE_ANNOTATION = classForName("javax.ejb.Remove");
}
-
+
+ /**
+ * Initializes an annotation class
+ *
+ * @param name The name of the annotation class
+ * @return The instance of the annotation. Returns a dummy if the class was
+ * not found
+ */
@SuppressWarnings("unchecked")
private static Class<? extends Annotation> classForName(String name)
{
@@ -39,5 +73,5 @@
return Dummy.class;
}
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.ejb;
import static org.jboss.webbeans.ejb.EJB.MESSAGE_DRIVEN_ANNOTATION;
@@ -20,35 +37,65 @@
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+/**
+ * EJB metadata
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
public class EjbMetaData<T>
{
-
+ // The known EJB types
public enum EjbType
{
STATELESS, STATEFUL, SINGLETON, MESSAGE_DRIVEN;
}
+ // The type of the EJB
private EjbType ejbType;
+ // The remove methods
private List<AnnotatedMethod<Object>> removeMethods = new ArrayList<AnnotatedMethod<Object>>();
+ // The destructor methods
private List<AnnotatedMethod<Object>> destructorMethods = new ArrayList<AnnotatedMethod<Object>>();
+ // The remove methods with no arguments
private List<AnnotatedMethod<Object>> noArgsRemoveMethods = new ArrayList<AnnotatedMethod<Object>>();
// TODO Populate this from web.xml
+ // The EJB link jndi name
private String ejbLinkJndiName;
// TODO Initialize this based on the EJB 3.1 spec
+ // The default JNDI name
private String defaultJndiName;
// TODO Initialize the ejb name
+ // The EJB name
private String ejbName;
+ // The abstracted type
private AnnotatedClass<T> type;
+ /**
+ * Constrcutor
+ *
+ * Creates a new abstracted class and delegates to another constructor
+ *
+ * @param type The type
+ */
public EjbMetaData(Class<T> type)
{
this(new AnnotatedClassImpl<T>(type));
}
+ /**
+ * Constructor
+ *
+ * Initializes the class based on information from the abstracted class.
+ * Detects the EJB type and remove/destructor methods
+ *
+ * @param type The abstracted class
+ */
public EjbMetaData(AnnotatedClass<T> type)
{
// TODO Merge in ejb-jar.xml
@@ -89,46 +136,82 @@
}
}
+ /**
+ * Indicates if the EJB is a stateless one
+ *
+ * @return True if stateless, false otherwise
+ */
public boolean isStateless()
{
return STATELESS.equals(ejbType);
}
+ /**
+ * Indicates if the EJB is a stateful one
+ *
+ * @return True if stateful, false otherwise
+ */
public boolean isStateful()
{
return STATEFUL.equals(ejbType);
}
+ /**
+ * Indicates if the EJB is a MDB
+ *
+ * @return True if MDB, false otherwise
+ */
public boolean isMessageDriven()
{
return MESSAGE_DRIVEN.equals(ejbType);
}
+ /**
+ * Indicates if the EJB is a singleton
+ *
+ * @return True if singleton, false otherwise
+ */
public boolean isSingleton()
{
return SINGLETON.equals(ejbType);
}
+ /**
+ * Indicates if class really is of a know EJB type
+ *
+ * @return True if EJB, false otherwise
+ */
+
public boolean isEjb()
{
return ejbType != null;
}
- public List<AnnotatedMethod<Object>> getRemoveMethods()
- {
- return removeMethods;
- }
-
+ /**
+ * Gets the EJB link JNDI name
+ *
+ * @return The name
+ */
public String getEjbLinkJndiName()
{
return ejbLinkJndiName;
}
+ /**
+ * Gets the default JNDI name
+ *
+ * @return The name
+ */
public String getDefaultJndiName()
{
return defaultJndiName;
}
+ /**
+ * Gets the EJB name
+ *
+ * @return The name
+ */
public String getEjbName()
{
return ejbName;
@@ -139,11 +222,34 @@
return type.getType();
}
+ /**
+ * Gets the list of remove method abstractions
+ *
+ * @return The list of remove methods. An empty list is returned if there are
+ * none.
+ */
+ public List<AnnotatedMethod<Object>> getRemoveMethods()
+ {
+ return removeMethods;
+ }
+
+ /**
+ * Gets a list of destructor method abstractions
+ *
+ * @return The list of destructor methods. An empty list is returned if there
+ * are none.
+ */
public List<AnnotatedMethod<Object>> getDestructorMethods()
{
return destructorMethods;
}
+ /**
+ * Gets the list of remove method abstractions that take no arguments
+ *
+ * @return The list of remove methods without arguments. An empty list is
+ * returned if there are none.
+ */
public List<AnnotatedMethod<Object>> getNoArgsRemoveMethods()
{
return noArgsRemoveMethods;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.el;
import java.beans.FeatureDescriptor;
@@ -9,6 +26,9 @@
public class WebBeansELResolver extends ELResolver
{
+ /**
+ * @see javax.el.ELResolver#getCommonPropertyType(ELContext, Object)
+ */
@Override
public Class<?> getCommonPropertyType(ELContext context, Object base)
{
@@ -16,6 +36,9 @@
return null;
}
+ /**
+ * @see javax.el.ELResolver#getFeatureDescriptors(ELContext, Object)
+ */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
{
@@ -23,6 +46,9 @@
return null;
}
+ /**
+ * @see javax.el.ELResolver#getType(ELContext, Object, Object)
+ */
@Override
public Class<?> getType(ELContext context, Object base, Object property)
{
@@ -30,6 +56,9 @@
return null;
}
+ /**
+ * @see javax.el.ELResolver#getValue(ELContext, Object, Object)
+ */
@Override
public Object getValue(ELContext context, Object base, Object property)
{
@@ -37,6 +66,9 @@
return null;
}
+ /**
+ * @see javax.el.ELResolver#isReadOnly(ELContext, Object, Object)
+ */
@Override
public boolean isReadOnly(ELContext context, Object base, Object property)
{
@@ -44,6 +76,9 @@
return false;
}
+ /**
+ * @see javax.el.ELResolver#setValue(ELContext, Object, Object, Object)
+ */
@Override
public void setValue(ELContext context, Object base, Object property, Object value)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.event;
import javax.transaction.Status;
@@ -9,11 +26,13 @@
* the JTA transaction currently in effect is committed.
*
* @author David Allen
- *
+ * @see javax.transaction.Synchronization
*/
public class DeferredEventNotification<T> implements Synchronization
{
+ // The observer
private ObserverImpl<T> observer;
+ // The event object
private T event;
/**
@@ -30,6 +49,8 @@
}
/**
+ * Gets the observer
+ *
* @return the observer
*/
public final Observer<T> getObserver()
@@ -37,6 +58,15 @@
return observer;
}
+ /**
+ * Called after completion of a transaction
+ *
+ * Checks if the observer is interested in this particular transaction phase
+ * and if so, notifies the observer.
+ *
+ * @param status The status of the transaction
+ * @see javax.transaction.Status
+ */
public void afterCompletion(int status)
{
if (observer.isInterestedInTransactionPhase(TransactionObservationPhase.AFTER_COMPLETION))
@@ -60,6 +90,12 @@
}
}
+ /**
+ * Called before completion of a transaction
+ *
+ * Checks if the observer is interested in this particular transaction phase
+ * and if so, notifies the observer.
+ */
public void beforeCompletion()
{
if (observer.isInterestedInTransactionPhase(TransactionObservationPhase.BEFORE_COMPLETION))
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.event;
import java.lang.annotation.Annotation;
@@ -28,7 +45,7 @@
public class EventImpl<T> implements Event<T>
{
private Collection<? extends Annotation> eventBindings;
- private Class<T> eventType;
+ private Class<T> eventType;
// The current WB manager
@Current
@@ -38,8 +55,7 @@
* Used to set the event bindings for this type of event after it is
* constructed with the default constructor.
*
- * @param eventBindings
- * Annotations that are bindings for the event
+ * @param eventBindings Annotations that are bindings for the event
*/
public void setEventBindings(Annotation... eventBindings)
{
@@ -66,14 +82,13 @@
addAnnotationBindings(eventBindings, bindings);
// Invoke the container method to fire the event per 7.2
- webBeansManager
- .fireEvent(event, eventBindings.toArray(new Annotation[0]));
+ webBeansManager.fireEvent(event, eventBindings.toArray(new Annotation[0]));
}
public void observe(Observer<T> observer, Annotation... bindings)
{
// Register the observer with the web beans manager
-
+
Set<Annotation> eventBindings = new HashSet<Annotation>();
eventBindings.addAll(this.getBindingTypes());
addAnnotationBindings(eventBindings, bindings);
@@ -85,35 +100,32 @@
* already exists in the set, a {@link DuplicateBindingTypeException} is
* thrown.
*
- * @param bindingsSet
- * The set of annotation binding objects
- * @param bindings
- * An array of annotation bindings to add to the set
- * @throws DuplicateBindingTypeException
- * if any of bindings are duplicates
- * @throws IllegalArgumentException
- * if any annotation is not a binding type
+ * @param bindingsSet The set of annotation binding objects
+ * @param bindings An array of annotation bindings to add to the set
+ * @throws DuplicateBindingTypeException if any of bindings are duplicates
+ * @throws IllegalArgumentException if any annotation is not a binding type
*/
- private void addAnnotationBindings(Set<Annotation> bindingsSet,
- Annotation[] bindings)
+ private void addAnnotationBindings(Set<Annotation> bindingsSet, Annotation[] bindings)
{
if (bindings != null)
{
Set<Class<? extends Annotation>> bindingTypes = new HashSet<Class<? extends Annotation>>();
- // Add the bindings types that are already in the set being added to. This will
- // provide detection of duplicates across construction and later invocations.
+ // Add the bindings types that are already in the set being added to.
+ // This will
+ // provide detection of duplicates across construction and later
+ // invocations.
for (Annotation annotation : bindingsSet)
{
bindingTypes.add(annotation.annotationType());
}
-
- // Now go through the new annotations being added to make sure these are binding
+
+ // Now go through the new annotations being added to make sure these
+ // are binding
// types and are not duplicates
for (Annotation annotation : bindings)
{
// Check that the binding type is indeed a binding type
- Annotation[] bindingAnnotations = annotation.annotationType()
- .getAnnotations();
+ Annotation[] bindingAnnotations = annotation.annotationType().getAnnotations();
boolean isBindingType = false;
for (Annotation bindingAnnotation : bindingAnnotations)
{
@@ -123,15 +135,15 @@
}
}
if (!isBindingType)
- throw new IllegalArgumentException("Annotation " + annotation
- + " is not a binding type");
+ throw new IllegalArgumentException("Annotation " + annotation + " is not a binding type");
// Check that no binding type was specified more than once in the
// annotations
if (bindingTypes.contains(annotation.annotationType()))
{
throw new DuplicateBindingTypeException();
- } else
+ }
+ else
{
bindingTypes.add(annotation.annotationType());
}
@@ -152,7 +164,7 @@
{
this.webBeansManager = manager;
}
-
+
// TODO Use constructor injection
public void setEventType(Class<T> eventType)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.event;
import java.lang.annotation.Annotation;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.event;
import java.lang.annotation.Annotation;
@@ -123,7 +140,7 @@
* Uses the container to retrieve the most specialized instance of this
* observer.
*
- * @param conditional
+ * @param conditional T
*
* @return the most specialized instance
*/
@@ -133,16 +150,32 @@
return manager.getInstanceByType(eventBean.getType(), eventBean.getBindingTypes().toArray(new Annotation[0]));
}
+ /**
+ * Indicates if the observer is transactional
+ *
+ * @return True if transactional, false otherwise
+ */
public boolean isTransactional()
{
return !TransactionObservationPhase.NONE.equals(transactionObservationPhase);
}
+ /**
+ * Indicates if the observer is conditional
+ *
+ * @return True if conditional, false otherwise
+ */
public boolean isConditional()
{
return conditional;
}
+ /**
+ * Checks if the observer is interested in a particular transactional phase
+ *
+ * @param currentPhase The phase to check
+ * @return True if interested, false otherwise
+ */
public boolean isInterestedInTransactionPhase(TransactionObservationPhase currentPhase)
{
return transactionObservationPhase.equals(currentPhase);
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/TransactionObservationPhase.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/TransactionObservationPhase.java 2008-11-28 11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/TransactionObservationPhase.java 2008-11-29 21:17:54 UTC (rev 381)
@@ -1,5 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.event;
+/**
+ * The known transactional phases a transactional event observer can be
+ * interested in
+ *
+ * @author Nicklas Karlsson
+ */
public enum TransactionObservationPhase
{
NONE, BEFORE_COMPLETION, AFTER_COMPLETION, AFTER_FAILURE, AFTER_SUCCESS
15 years, 12 months
[webbeans-commits] Webbeans SVN: r380 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: transaction and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-28 06:26:26 -0500 (Fri, 28 Nov 2008)
New Revision: 380
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/LocalTransactionListener.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/TransactionListener.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
Log:
javadocs/comments/toStrings
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.servlet;
import java.lang.reflect.Constructor;
@@ -17,15 +34,27 @@
import org.jboss.webbeans.util.JNDI;
import org.jboss.webbeans.util.Reflections;
+/**
+ * Reacts to phases of the servlet life cycles
+ *
+ * @author Pete Muir
+ * @author Nicklas Karlsson
+ */
public class ServletLifecycle
{
-
private static LogProvider log = Logging.getLogProvider(ServletLifecycle.class);
-
+ // Where to find the manager in JNDI
private static final String MANAGER_JNDI_KEY = "java:comp/Manager";
-
+ // The servlet context
private static ServletContext servletContext;
+ /**
+ * Starts the application
+ *
+ * Runs the bootstrapper for bean discover and initialization
+ *
+ * @param context The servlet context
+ */
public static void beginApplication(ServletContext context)
{
servletContext = context;
@@ -33,31 +62,66 @@
bootstrap.boot(getWebBeanDiscovery());
}
+ /**
+ * Ends the application
+ */
public static void endApplication() {
servletContext = null;
}
+ /**
+ * Begins a session
+ *
+ * @param session The HTTP session
+ */
public static void beginSession(HttpSession session)
{
}
+ /**
+ * Ends a session
+ *
+ * @param session The HTTP session
+ */
public static void endSession(HttpSession session) {
}
+ /**
+ * Begins a HTTP request
+ *
+ * Sets the session into the session context
+ *
+ * @param request The request
+ */
public static void beginRequest(HttpServletRequest request) {
ManagerImpl manager = (ManagerImpl) JNDI.lookup(MANAGER_JNDI_KEY);
SessionContext sessionContext = (SessionContext) manager.getContext(SessionScoped.class);
sessionContext.setSession(request.getSession(true));
}
+ /**
+ * Ends a HTTP request
+ *
+ * @param request The request
+ */
public static void endRequest(HttpServletRequest request) {
}
+ /**
+ * Gets the servlet context
+ *
+ * @return The servlet context
+ */
public static ServletContext getServletContext()
{
return servletContext;
}
+ /**
+ * Gets the Web Beans discovery class
+ *
+ * @return The discoverer
+ */
// TODO move some of this bootstrap for reuse outside Servlet
private static WebBeanDiscovery getWebBeanDiscovery()
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.servlet;
import java.io.IOException;
@@ -11,17 +28,35 @@
import javax.servlet.http.HttpServletRequest;
/**
+ * Filter for handling request-level events
*
- * @author Shane Bryzak
+ * Delegates work to the ServletLifecycle
*
+ * @author Pete Muir
+ * @author Nicklas Karlsson
*/
public class WebBeansFilter implements Filter
{
+ /**
+ * Called when the filter is initializes
+ *
+ * @param filterConfig The filter configuration
+ * @throws ServletException When things go Wrong(tm)
+ */
public void init(FilterConfig filterConfig) throws ServletException
{
-
}
+ /**
+ * Executes the filter
+ *
+ * @param request The request
+ * @param response The response
+ * @param chain The filter chain
+ *
+ * @throws IOException When things go Wrong(tm)
+ * @throws ServletException When things go Wrong(tm)
+ */
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
try
@@ -35,6 +70,9 @@
}
}
+ /**
+ * Called when the filter is destroyed
+ */
public void destroy()
{
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java 2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java 2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.servlet;
import javax.servlet.ServletContextEvent;
@@ -5,24 +22,54 @@
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
+/**
+ * The Web Beans listener
+ *
+ * Listens for context/session creation/destruction.
+ *
+ * Delegates work to the ServletLifeCycle.
+ *
+ * @author Nicklas Karlsson
+ *
+ */
public class WebBeansListener implements ServletContextListener, HttpSessionListener
{
+ /**
+ * Called when the context is initialized (application started)
+ *
+ * @param event The context event
+ */
public void contextInitialized(ServletContextEvent event)
{
ServletLifecycle.beginApplication(event.getServletContext());
}
+ /**
+ * Called when the session is created
+ *
+ * @param event The session event
+ */
public void sessionCreated(HttpSessionEvent event)
{
ServletLifecycle.beginSession(event.getSession());
}
+ /**
+ * Called when the session is destroyed
+ *
+ * @param event The session event
+ */
public void sessionDestroyed(HttpSessionEvent event)
{
ServletLifecycle.endSession(event.getSession());
}
+ /**
+ * Called when the context is destroyed (application sopped)
+ *
+ * @param event The context event
+ */
public void contextDestroyed(ServletContextEvent event)
{
ServletLifecycle.endApplication();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/LocalTransactionListener.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/LocalTransactionListener.java 2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/LocalTransactionListener.java 2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.transaction;
import javax.ejb.Local;
@@ -2,5 +19,14 @@
+/**
+ * The local EJB interface for the TransactionListener
+ *
+ * @author Nicklas Karlsson
+ *
+ */
@Local
-public interface LocalTransactionListener
+public interface LocalTransactionListener
{
+ /**
+ * The destroy method
+ */
public void destroy();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/TransactionListener.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/TransactionListener.java 2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/TransactionListener.java 2008-11-28 11:26:26 UTC (rev 380)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.transaction;
import java.rmi.RemoteException;
@@ -14,18 +31,38 @@
import javax.transaction.Synchronization;
import javax.webbeans.RequestScoped;
+/**
+ * An EJB used for transaction synchronization (e.g. transactional observers)
+ *
+ * @author Nicklas Karlsson
+ *
+ */
@Stateful
@RequestScoped
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class TransactionListener implements LocalTransactionListener, SessionSynchronization
{
-
+ // The registered synchronizations
private List<Synchronization> synchronizations = new CopyOnWriteArrayList<Synchronization>();
+ /**
+ * Fired after the current transaction have begun
+ *
+ * @see javax.ejb.SessionSynchronization
+ */
public void afterBegin() throws EJBException, RemoteException
{
}
+ /**
+ * Fired after the transaction has completed
+ *
+ * Notifies any registered synchronizations
+ *
+ * @param success Did the transaction succeed?
+ *
+ * @see javax.ejb.SessionSynchronization
+ */
public void afterCompletion(boolean success) throws EJBException, RemoteException
{
for (Synchronization synchronization : synchronizations)
@@ -35,6 +72,13 @@
synchronizations.clear();
}
+ /**
+ * Fired before the transaction completed
+ *
+ * Notifies any registered synchronizations
+ *
+ * @see javax.ejb.SessionSynchronization
+ */
public void beforeCompletion() throws EJBException, RemoteException
{
for (Synchronization synchronization : synchronizations)
@@ -43,13 +87,23 @@
}
}
+ /**
+ * Registers a synchronization
+ *
+ * @param synchronization The synchronization to register
+ */
public void registerSynhronization(Synchronization synchronization)
{
synchronizations.add(synchronization);
}
+ /**
+ * The remove method
+ */
@Remove
public void destroy()
- {
+ {
+ synchronizations.clear();
+ synchronizations = null;
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java 2008-11-28 10:38:13 UTC (rev 379)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java 2008-11-28 11:26:26 UTC (rev 380)
@@ -1,15 +1,12 @@
package org.jboss.webbeans.util;
import java.beans.Introspector;
-import java.lang.annotation.Annotation;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import java.util.StringTokenizer;
-import java.util.Map.Entry;
-import org.jboss.webbeans.introspector.AnnotatedField;
-
public class Strings
{
@@ -40,24 +37,37 @@
public static String mapToString(String header, Map<?, ?> map)
{
StringBuffer buffer = new StringBuffer();
- buffer.append(header + map.size() + "\n");
+ buffer.append(header + "[" + map.size() + " entries]\n");
int i = 0;
for (Object key : map.keySet())
{
Object value = map.get(key);
+ buffer.append(" #" + ++i + ": " + key.toString() + "->");
if (value instanceof Iterable)
{
+ buffer.append("\n");
for (Object subValue : (Iterable<?>) value)
{
- buffer.append(++i + " - " + key.toString() + ": " + subValue.toString() + "\n");
+ buffer.append(" " + subValue.toString() + "\n");
}
}
else
{
- buffer.append(++i + " - " + key.toString() + ": " + value.toString() + "\n");
+ buffer.append(value.toString() + "\n");
}
}
return buffer.toString();
}
+ public static void main(String[] args) {
+ Map map = new HashMap<String, Collection<?>>();
+ Collection a = new ArrayList<String>();
+ a.add("1"); a.add("2");
+ map.put("foo", a);
+ Collection b = new ArrayList<String>();
+ b.add("3"); b.add("4");
+ map.put("bar", b);
+ System.out.println(mapToString("Header: ", map));
+ }
+
}
15 years, 12 months
[webbeans-commits] Webbeans SVN: r379 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: bean/proxy and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-28 05:38:13 -0500 (Fri, 28 Nov 2008)
New Revision: 379
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
Log:
toString simplifications, forwardingmap refactorings/renamings
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -44,7 +44,6 @@
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.bean.AbstractBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.bean.proxy.ProxyPool;
import org.jboss.webbeans.contexts.ApplicationContext;
@@ -58,7 +57,6 @@
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
-import org.jboss.webbeans.transaction.TransactionListener;
import org.jboss.webbeans.util.Reflections;
/**
@@ -103,8 +101,6 @@
protected void initStandardBeans()
{
addBean(new SimpleBean<DefaultEnterpriseBeanLookup>(DefaultEnterpriseBeanLookup.class, this));
-// TODO: Fix tests that rely that there are a specific number of beans registered/present/matched etc.
-// addBean(new EnterpriseBean<TransactionListener>(TransactionListener.class, this));
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -27,6 +27,7 @@
import org.jboss.webbeans.model.BindingTypeModel;
import org.jboss.webbeans.model.ScopeModel;
import org.jboss.webbeans.model.StereotypeModel;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -65,32 +66,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Binding types: " + bindingTypes.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, BindingTypeModel<?>> entry : bindingTypes.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ": " + entry.getValue().toString() + "\n");
- }
- buffer.append("EJB metadata: " + ejbMetaDataMap.size() + "\n");
- i = 0;
- for (Entry<Class<?>, EjbMetaData<?>> entry : ejbMetaDataMap.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ": " + entry.getValue().toString() + "\n");
- }
- buffer.append("Scopes: " + scopes.size() + "\n");
- i = 0;
- for (Entry<Class<? extends Annotation>, ScopeModel<?>> entry : scopes.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ": " + entry.getValue().toString() + "\n");
- }
- buffer.append("Stereotypes: " + stereotypes.size() + "\n");
- i = 0;
- for (Entry<Class<? extends Annotation>, StereotypeModel<?>> entry : stereotypes.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ": " + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotationModelMap (annotation -> ?): ", delegate);
}
}
@@ -114,11 +90,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Scope model map\n");
- buffer.append("--------------------\n");
- buffer.append(super.toString() + "\n");
- return buffer.toString();
+ return Strings.mapToString("ScopeModelMap (annotation -> ScopeModel): ", delegate);
}
}
@@ -142,11 +114,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Binding type model map\n");
- buffer.append("--------------------\n");
- buffer.append(super.toString() + "\n");
- return buffer.toString();
+ return Strings.mapToString("BindingTypeModelMap (annotation -> BindingTypeModel): ", delegate);
}
}
@@ -181,15 +149,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("EJB metadata: " + delegate.size() + "\n");
- buffer.append("--------------------\n");
- int i = 0;
- for (Entry<Class<?>, EjbMetaData<?>> entry : delegate.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ": " + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("EJBMetadataMap (class -> EJBMetaData): ", delegate);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -39,6 +39,7 @@
import org.jboss.webbeans.introspector.ForwardingAnnotatedItem;
import org.jboss.webbeans.model.BindingTypeModel;
import org.jboss.webbeans.util.ListComparator;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -119,10 +120,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotated item\n");
- buffer.append(delegate().toString() + "\n");
- return buffer.toString();
+ return Strings.mapToString("AnnotatedItemMap (annotated item -> bean set): ", delegate);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -31,6 +31,7 @@
import javax.webbeans.manager.Bean;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -73,14 +74,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Proxy pool holding " + delegate.size() + " proxies\n");
- int i = 0;
- for (Entry<Bean<?>, Object> entry : delegate.entrySet())
- {
- buffer.append(i + " - " + entry.getKey().toString() + ": " + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("ProxyPool (bean -> proxy): ", delegate);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -24,6 +24,8 @@
import javax.webbeans.manager.Context;
+import org.jboss.webbeans.util.Strings;
+
import com.google.common.collect.ForwardingMap;
/**
@@ -79,16 +81,6 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Scope type -> context list mappings: " + delegate.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, List<Context>> entry : delegate.entrySet())
- {
- for (Context context : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().getName() + ": " + context.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("ContextMAp (scope type -> context list): ", delegate);
}
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -25,6 +25,7 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -131,14 +132,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Bean -> bean instance mappings: " + delegate.size() + "\n");
- int i = 0;
- for (Entry<Bean<? extends Object>, Object> entry : delegate.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("SimpleBeanMap (bean -> instance): ", delegate);
}
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -35,6 +35,7 @@
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.Strings;
import org.jboss.webbeans.util.Types;
import com.google.common.collect.ForwardingMap;
@@ -81,14 +82,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> annotation mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Annotation> entry : delegate.entrySet())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + entry.getValue().toString() + "\n");
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotationMap (annotation type -> annotation): ", delegate);
}
}
@@ -144,17 +138,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> meta annotation mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Set<Annotation>> entry : delegate.entrySet())
- {
- for (Annotation annotation : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + annotation.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("MetaAnnotationMap (annotation type -> annotation set: ", delegate);
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -17,13 +17,21 @@
package org.jboss.webbeans.introspector.jlr;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.webbeans.BindingType;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.Strings;
+import com.google.common.collect.ForwardingMap;
+
/**
* Represents an abstract annotated memeber (field, method or constructor)
*
@@ -34,6 +42,31 @@
*/
public abstract class AbstractAnnotatedMember<T, S extends Member> extends AbstractAnnotatedItem<T, S>
{
+ /**
+ * An annotation type -> list of annotations map
+ */
+ protected class AnnotatedParameterMap extends ForwardingMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>
+ {
+ private Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate;
+
+ public AnnotatedParameterMap()
+ {
+ delegate = new HashMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>();
+ }
+
+ @Override
+ protected Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate()
+ {
+ return delegate;
+ }
+
+ @Override
+ public String toString()
+ {
+ return Strings.mapToString("AnnotatedParameterMap (annotation type -> parameter abstraction list): ", delegate);
+ }
+ }
+
// The name of the member
private String name;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -27,6 +27,7 @@
import org.jboss.webbeans.introspector.AnnotatedAnnotation;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -43,11 +44,11 @@
/**
* A (annotation type -> set of method abstractions with annotation) map
*/
- private class AnnotatedMembers extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>
+ private class AnnotatedMemberMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>
{
private Map<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> delegate;
- public AnnotatedMembers()
+ public AnnotatedMemberMap()
{
delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>();
}
@@ -61,22 +62,12 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> member abstraction mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> entry : delegate.entrySet())
- {
- for (AnnotatedMethod<?> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotatedMemberMap (annotation type -> set of member abstractions: ", delegate);
}
}
// The annotated members map (annotation -> member with annotation)
- private AnnotatedMembers annotatedMembers;
+ private AnnotatedMemberMap annotatedMembers;
// The implementation class of the annotation
private Class<T> clazz;
// The set of abstracted members
@@ -170,7 +161,7 @@
* @param annotationType The annotation type to match
* @return The set of abstracted members with the given annotation type
* present. An empty set is returned if no matches are found
- *
+ *
* @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getAnnotatedMembers(Class)
*/
public Set<AnnotatedMethod<?>> getAnnotatedMembers(Class<? extends Annotation> annotationType)
@@ -205,7 +196,7 @@
{
initMembers();
}
- annotatedMembers = new AnnotatedMembers();
+ annotatedMembers = new AnnotatedMemberMap();
for (AnnotatedMethod<?> member : members)
{
for (Annotation annotation : member.getAnnotations())
@@ -227,17 +218,18 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
-// buffer.append("AnnotatedConstructorImpl:\n");
-// buffer.append(super.toString() + "\n");
-// buffer.append("Class: " + clazz.toString() + "\n");
-//
-// buffer.append("Members: " + getMembers().size() + "\n");
-// int i = 0;
-// for (AnnotatedMethod<?> member : getMembers())
-// {
-// buffer.append(++i + " - " + member.toString());
-// }
-// buffer.append(annotatedMembers == null ? "" : (annotatedMembers.toString() + "\n"));
+ // buffer.append("AnnotatedConstructorImpl:\n");
+ // buffer.append(super.toString() + "\n");
+ // buffer.append("Class: " + clazz.toString() + "\n");
+ //
+ // buffer.append("Members: " + getMembers().size() + "\n");
+ // int i = 0;
+ // for (AnnotatedMethod<?> member : getMembers())
+ // {
+ // buffer.append(++i + " - " + member.toString());
+ // }
+ // buffer.append(annotatedMembers == null ? "" :
+ // (annotatedMembers.toString() + "\n"));
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -35,6 +35,7 @@
import org.jboss.webbeans.introspector.AnnotatedConstructor;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -49,13 +50,13 @@
{
/**
- * A (annotation type -> set of field abstractions with annotation) map
+ * A (annotation type -> set of field abstractions with annotation/meta annotation) map
*/
- private static class AnnotatedFields extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>
+ private static class AnnotatedFieldMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>
{
private Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> delegate;
- public AnnotatedFields()
+ public AnnotatedFieldMap()
{
delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>();
}
@@ -69,64 +70,19 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> field abstraction mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Set<AnnotatedField<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedField<Object> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotatedFieldMap (annotation type -> field abstraction set): ", delegate);
}
}
/**
- * A (annotation type -> set of field abstractions with meta-annotation) map
- */
- private static class MetaAnnotatedFields extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>
- {
- private Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> delegate;
-
- public MetaAnnotatedFields()
- {
- delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, Set<AnnotatedField<Object>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Meta-annotation type -> method abstraction mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Set<AnnotatedField<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedField<Object> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
- }
- }
-
- /**
* A (annotation type -> set of method abstractions with annotation) map
*/
- private class AnnotatedMethods extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>>
+ private class AnnotatedMethodMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>>
{
private Map<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>> delegate;
- public AnnotatedMethods()
+ public AnnotatedMethodMap()
{
delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>>();
}
@@ -140,28 +96,18 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> method abstraction mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedMethod<Object> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotatedMethodMap (annotation type -> method abstraction set): ", delegate);
}
}
/**
* A (annotation type -> set of constructor abstractions with annotation) map
*/
- private class AnnotatedConstructors extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>>
+ private class AnnotatedConstructorMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>>
{
private Map<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>> delegate;
- public AnnotatedConstructors()
+ public AnnotatedConstructorMap()
{
delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>>();
}
@@ -175,17 +121,7 @@
@Override
public String toString()
{
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> constructor abstraction mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>> entry : delegate.entrySet())
- {
- for (AnnotatedConstructor<T> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
+ return Strings.mapToString("AnnotatedConstructorMap (annotation type -> constructor abstraction set): ", delegate);
}
}
@@ -193,11 +129,11 @@
* A (class list -> set of constructor abstractions with matching parameters)
* map
*/
- private class ConstructorsByArgument extends ForwardingMap<List<Class<?>>, AnnotatedConstructor<T>>
+ private class ConstructorsByArgumentMap extends ForwardingMap<List<Class<?>>, AnnotatedConstructor<T>>
{
private Map<List<Class<?>>, AnnotatedConstructor<T>> delegate;
- public ConstructorsByArgument()
+ public ConstructorsByArgumentMap()
{
delegate = new HashMap<List<Class<?>>, AnnotatedConstructor<T>>();
}
@@ -230,21 +166,21 @@
// The set of abstracted fields
private Set<AnnotatedField<Object>> fields;
// The map from annotation type to abstracted field with annotation
- private AnnotatedFields annotatedFields;
+ private AnnotatedFieldMap annotatedFields;
// The map from annotation type to abstracted field with meta-annotation
- private MetaAnnotatedFields metaAnnotatedFields;
+ private AnnotatedFieldMap metaAnnotatedFields;
// The set of abstracted methods
private Set<AnnotatedMethod<Object>> methods;
// The map from annotation type to abstracted method with annotation
- private AnnotatedMethods annotatedMethods;
+ private AnnotatedMethodMap annotatedMethods;
// The set of abstracted constructors
private Set<AnnotatedConstructor<T>> constructors;
// The map from annotation type to abstracted constructor with annotation
- private AnnotatedConstructors annotatedConstructors;
+ private AnnotatedConstructorMap annotatedConstructors;
// The map from class list to abstracted constructor
- private ConstructorsByArgument constructorsByArgumentMap;
+ private ConstructorsByArgumentMap constructorsByArgumentMap;
/**
* Constructor
@@ -373,7 +309,7 @@
{
if (metaAnnotatedFields == null)
{
- metaAnnotatedFields = new MetaAnnotatedFields();
+ metaAnnotatedFields = new AnnotatedFieldMap();
}
if (annotatedFields == null)
{
@@ -392,7 +328,7 @@
* @param metaAnnotatedFields The meta-annotated fields
* @return The meta-annotated fields map
*/
- protected static <T extends Annotation> MetaAnnotatedFields populateMetaAnnotatedFieldMap(Class<T> metaAnnotationType, AnnotatedFields annotatedFields, MetaAnnotatedFields metaAnnotatedFields)
+ protected static <T extends Annotation> AnnotatedFieldMap populateMetaAnnotatedFieldMap(Class<T> metaAnnotationType, AnnotatedFieldMap annotatedFields, AnnotatedFieldMap metaAnnotatedFields)
{
if (!metaAnnotatedFields.containsKey(metaAnnotationType))
{
@@ -440,7 +376,7 @@
{
initFields();
}
- annotatedFields = new AnnotatedFields();
+ annotatedFields = new AnnotatedFieldMap();
for (AnnotatedField<Object> field : fields)
{
for (Annotation annotation : field.getAnnotations())
@@ -539,7 +475,7 @@
{
initMethods();
}
- annotatedMethods = new AnnotatedMethods();
+ annotatedMethods = new AnnotatedMethodMap();
for (AnnotatedMethod<Object> member : methods)
{
for (Annotation annotation : member.getAnnotations())
@@ -564,7 +500,7 @@
private void initConstructors()
{
this.constructors = new HashSet<AnnotatedConstructor<T>>();
- this.constructorsByArgumentMap = new ConstructorsByArgument();
+ this.constructorsByArgumentMap = new ConstructorsByArgumentMap();
for (Constructor<?> constructor : clazz.getDeclaredConstructors())
{
AnnotatedConstructor<T> annotatedConstructor = new AnnotatedConstructorImpl<T>((Constructor<T>) constructor, this);
@@ -617,7 +553,7 @@
{
initConstructors();
}
- annotatedConstructors = new AnnotatedConstructors();
+ annotatedConstructors = new AnnotatedConstructorMap();
for (AnnotatedConstructor<T> constructor : constructors)
{
for (Annotation annotation : constructor.getAnnotations())
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -22,9 +22,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.webbeans.ExecutionException;
@@ -33,8 +31,6 @@
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.AnnotatedType;
-import com.google.common.collect.ForwardingMap;
-
/**
* Represents an annotated constructor
*
@@ -44,42 +40,6 @@
*/
public class AnnotatedConstructorImpl<T> extends AbstractAnnotatedMember<T, Constructor<T>> implements AnnotatedConstructor<T>
{
-
- /**
- * An annotation type -> list of annotations map
- */
- private class AnnotatedParameters extends ForwardingMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>
- {
- private Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate;
-
- public AnnotatedParameters()
- {
- delegate = new HashMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> parameter abstraction mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedParameter<?> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
- }
- }
-
// The type arguments
private static final Type[] actualTypeArguments = new Type[0];
// The underlying constructor
@@ -88,7 +48,7 @@
// The list of parameter abstractions
private List<AnnotatedParameter<Object>> parameters;
// The mapping of annotation -> parameter abstraction
- private AnnotatedParameters annotatedParameters;
+ private AnnotatedParameterMap annotatedParameters;
// The declaring class abstraction
private AnnotatedType<T> declaringClass;
@@ -234,7 +194,7 @@
{
initParameters();
}
- annotatedParameters = new AnnotatedParameters();
+ annotatedParameters = new AnnotatedParameterMap();
for (AnnotatedParameter<Object> parameter : parameters)
{
for (Annotation annotation : parameter.getAnnotations())
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -22,9 +22,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -32,8 +30,6 @@
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.Reflections;
-import com.google.common.collect.ForwardingMap;
-
/**
* Represents an annotated method
*
@@ -43,42 +39,6 @@
*/
public class AnnotatedMethodImpl<T> extends AbstractAnnotatedMember<T, Method> implements AnnotatedMethod<T>
{
- /**
- * A annotation type -> list of parameter abstractions with given annotations
- * present mapping
- */
- private class AnnotatedParameters extends ForwardingMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>
- {
- private Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate;
-
- public AnnotatedParameters()
- {
- delegate = new HashMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation type -> parameter abstraction mappings: " + super.size() + "\n");
- int i = 0;
- for (Entry<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> entry : delegate.entrySet())
- {
- for (AnnotatedParameter<?> parameter : entry.getValue())
- {
- buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
- }
- }
- return buffer.toString();
- }
- }
-
// The actual type arguments
private Type[] actualTypeArguments = new Type[0];
// The underlying method
@@ -88,7 +48,7 @@
private List<AnnotatedParameter<Object>> parameters;
// A mapping from annotation type to parameter abstraction with that
// annotation present
- private AnnotatedParameters annotatedParameters;
+ private AnnotatedParameterMap annotatedParameters;
// The property name
private String propertyName;
@@ -236,7 +196,7 @@
{
initParameters();
}
- annotatedParameters = new AnnotatedParameters();
+ annotatedParameters = new AnnotatedParameterMap();
for (AnnotatedParameter<Object> parameter : parameters)
{
for (Annotation annotation : parameter.getAnnotations())
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java 2008-11-28 09:44:49 UTC (rev 378)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Strings.java 2008-11-28 10:38:13 UTC (rev 379)
@@ -1,8 +1,15 @@
package org.jboss.webbeans.util;
import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
+import java.util.Map.Entry;
+import org.jboss.webbeans.introspector.AnnotatedField;
+
public class Strings
{
@@ -10,23 +17,47 @@
{
return Introspector.decapitalize(camelCase);
}
-
+
public static String[] split(String strings, String delims)
{
- if (strings==null)
+ if (strings == null)
{
return new String[0];
}
else
- {
+ {
StringTokenizer tokens = new StringTokenizer(strings, delims);
- String[] result = new String[ tokens.countTokens() ];
- int i=0;
- while ( tokens.hasMoreTokens() )
+ String[] result = new String[tokens.countTokens()];
+ int i = 0;
+ while (tokens.hasMoreTokens())
{
result[i++] = tokens.nextToken();
}
return result;
}
- }
+ }
+
+ public static String mapToString(String header, Map<?, ?> map)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(header + map.size() + "\n");
+ int i = 0;
+ for (Object key : map.keySet())
+ {
+ Object value = map.get(key);
+ if (value instanceof Iterable)
+ {
+ for (Object subValue : (Iterable<?>) value)
+ {
+ buffer.append(++i + " - " + key.toString() + ": " + subValue.toString() + "\n");
+ }
+ }
+ else
+ {
+ buffer.append(++i + " - " + key.toString() + ": " + value.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
+
}
15 years, 12 months
[webbeans-commits] Webbeans SVN: r378 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: model and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-28 04:44:49 -0500 (Fri, 28 Nov 2008)
New Revision: 378
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
Log:
javadocs/comments/toStrings
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-11-28 09:44:49 UTC (rev 378)
@@ -29,15 +29,19 @@
/**
* Meta model for the merged stereotype for a bean
*
- * @author pmuir
- *
+ * @author Pete Muir
*/
public class MergedStereotypes<T, E>
{
+ // The possible deployment types
private AnnotationMap possibleDeploymentTypes;
+ // The possible scope types
private Set<Annotation> possibleScopeTypes;
+ // Is the bean name defaulted?
private boolean beanNameDefaulted;
+ // The required types
private Set<Class<?>> requiredTypes;
+ // The supported scopes
private Set<Class<? extends Annotation>> supportedScopes;
/**
@@ -148,6 +152,11 @@
return false;
}
+ /**
+ * Gets a string representation of the merged stereotypes
+ *
+ * @return The string representation
+ */
@Override
public String toString()
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java 2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AnnotationModel.java 2008-11-28 09:44:49 UTC (rev 378)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.model;
import java.lang.annotation.Annotation;
@@ -7,24 +24,41 @@
import org.jboss.webbeans.introspector.AnnotatedAnnotation;
import org.jboss.webbeans.introspector.jlr.AnnotatedAnnotationImpl;
+/**
+ * Abstract representation of an annotation model
+ *
+ * @author Pete Muir
+ */
public abstract class AnnotationModel<T extends Annotation>
{
-
+ // The underlying annotation
private AnnotatedAnnotation<T> annotatedAnnotation;
+ // Is the data valid?
private boolean valid;
-
+
+ /**
+ * Constructor
+ *
+ * @param type The annotation type
+ */
public AnnotationModel(Class<T> type)
{
this.annotatedAnnotation = new AnnotatedAnnotationImpl<T>(type);
init();
}
-
+
+ /**
+ * Initializes the type and validates it
+ */
protected void init()
{
initType();
initValid();
}
-
+
+ /**
+ * Initializes the type
+ */
protected void initType()
{
if (!Annotation.class.isAssignableFrom(getType()))
@@ -32,33 +66,64 @@
throw new DefinitionException(getMetaAnnotation().toString() + " can only be applied to an annotation, it was applied to " + getType());
}
}
-
+
+ /**
+ * Validates the data for correct annotation
+ */
protected void initValid()
{
this.valid = annotatedAnnotation.isAnnotationPresent(getMetaAnnotation());
}
+ /**
+ * Gets the type of the annotation
+ *
+ * @return The type
+ */
public Class<T> getType()
{
return annotatedAnnotation.getType();
}
-
+
+ /**
+ * Gets the meta-annotation that should be present
+ *
+ * @return
+ */
protected abstract Class<? extends Annotation> getMetaAnnotation();
-
+
+ /**
+ * Indicates if the annotation is valid
+ *
+ * @return True if valid, false otherwise
+ */
public boolean isValid()
{
return valid;
}
-
+
+ /**
+ * Gets the annotated annotation
+ *
+ * @return The annotation
+ */
protected AnnotatedAnnotation<T> getAnnotatedAnnotation()
{
return annotatedAnnotation;
}
-
+
+ /**
+ * Gets a string representation of the annotation
+ *
+ * @return The string representation
+ */
@Override
public String toString()
{
- return getClass().getSimpleName() + "[" + getAnnotatedAnnotation().toString() + "]";
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AnnotationModel:\n");
+ buffer.append("Annotated annotation: " + getAnnotatedAnnotation().toString());
+ buffer.append("Valid: " + isValid());
+ return buffer.toString();
}
-
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java 2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java 2008-11-28 09:44:49 UTC (rev 378)
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
package org.jboss.webbeans.model;
import java.lang.annotation.Annotation;
@@ -33,19 +32,28 @@
* Model of a binding type
*
* @author Pete Muir
- *
+ *
*/
public class BindingTypeModel<T extends Annotation> extends AnnotationModel<T>
{
-
+ // The non-binding types
private Set<AnnotatedMethod<?>> nonBindingTypes;
+ // The hash code
private Integer hashCode;
-
+
+ /**
+ * Constructor
+ *
+ * @param type The type
+ */
public BindingTypeModel(Class<T> type)
{
super(type);
}
-
+
+ /**
+ * Initializes the non-binding types and validates the members
+ */
@Override
protected void init()
{
@@ -53,7 +61,10 @@
initNonBindingTypes();
checkArrayAndAnnotationValuedMembers();
}
-
+
+ /**
+ * Validates the members
+ */
private void checkArrayAndAnnotationValuedMembers()
{
for (AnnotatedMethod<?> annotatedMethod : getAnnotatedAnnotation().getMembers())
@@ -63,30 +74,56 @@
throw new DefinitionException("Member of array type or annotation type must be annotated @NonBinding " + annotatedMethod);
}
}
-
+
}
+ /**
+ * Gets the meta-annotation type
+ *
+ * @return The BindingType class
+ */
@Override
protected Class<? extends Annotation> getMetaAnnotation()
{
return BindingType.class;
}
-
+
+ /**
+ * Indicates if there are non-binding types present
+ *
+ * @return True if present, false otherwise
+ */
public boolean hasNonBindingTypes()
{
return nonBindingTypes.size() > 0;
}
-
+
+ /**
+ * Gets the non-binding types
+ *
+ * @return A set of non-binding types, or an empty set if there are none
+ * present
+ */
public Set<AnnotatedMethod<?>> getNonBindingTypes()
{
return nonBindingTypes;
}
-
+
+ /**
+ * Initializes the non-binding types
+ */
protected void initNonBindingTypes()
{
nonBindingTypes = getAnnotatedAnnotation().getAnnotatedMembers(NonBinding.class);
}
-
+
+ /**
+ * Comparator for checking equality
+ *
+ * @param instance The instance to check against
+ * @param other The other binding type
+ * @return True if equal, false otherwise
+ */
public boolean isEqual(Annotation instance, Annotation other)
{
if (instance.annotationType().equals(getType()) && other.annotationType().equals(getType()))
@@ -107,19 +144,26 @@
}
return false;
}
-
+
+ /**
+ * Gets a string representation of the stereotype
+ *
+ * @return The string representation
+ */
@Override
- public String toString() {
+ public String toString()
+ {
StringBuffer buffer = new StringBuffer();
- buffer.append("Binding type model\n");
- buffer.append("Hash code : " + hashCode() + "\n");
- buffer.append("Valid : " + isValid() + "\n");
- buffer.append("Non-binding types\n");
- for (AnnotatedMethod<?> method : nonBindingTypes) {
- method.toString();
+ buffer.append("BindingTypeModel:\n");
+ buffer.append(super.toString());
+ buffer.append("Hash code: " + hashCode);
+ buffer.append("Non-binding types: " + nonBindingTypes.size());
+ int i = 0;
+ for (AnnotatedMethod<?> nonBindingType : getNonBindingTypes())
+ {
+ buffer.append(++i + " - " + nonBindingType.toString());
}
- buffer.append("Annotated type " + getAnnotatedAnnotation().getName() + "\n");
return buffer.toString();
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java 2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java 2008-11-28 09:44:49 UTC (rev 378)
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-
package org.jboss.webbeans.model;
import java.lang.annotation.Annotation;
@@ -27,39 +26,66 @@
* Model of a scope
*
* @author Pete Muir
- *
+ *
*/
public class ScopeModel<T extends Annotation> extends AnnotationModel<T>
{
-
+ /**
+ * Constrctor
+ *
+ * @param scope The scope type
+ */
public ScopeModel(Class<T> scope)
{
super(scope);
}
-
+
+ /**
+ * Indicates if the scope is "normal"
+ *
+ * @return True if normal, false otherwise
+ */
public boolean isNormal()
{
return getAnnotatedAnnotation().getAnnotation(ScopeType.class).normal();
}
-
+
+ /**
+ * Indicates if the scope is "passivating"
+ *
+ * @return True if passivating, false otherwise
+ */
public boolean isPassivating()
{
return getAnnotatedAnnotation().getAnnotation(ScopeType.class).passivating();
}
-
+
+ /**
+ * Gets the corresponding meta-annotation type class
+ *
+ * @return The ScopeType class
+ */
@Override
protected Class<? extends Annotation> getMetaAnnotation()
{
return ScopeType.class;
}
-
+
+ /**
+ * Gets a string representation of the stereotype
+ *
+ * @return The string representation
+ */
@Override
- public String toString() {
+ public String toString()
+ {
StringBuffer buffer = new StringBuffer();
- buffer.append("Scope model\n");
- buffer.append("Valid : " + isValid() + "\n");
- buffer.append("Annotated type " + getAnnotatedAnnotation().toString() + "\n");
+ buffer.append("ScopeModel:\n");
+ buffer.append(super.toString());
+ buffer.append("Normal: " + isNormal());
+ buffer.append("Passivating: " + isPassivating());
+ buffer.append("Meta-annotation: " + getMetaAnnotation().toString());
return buffer.toString();
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java 2008-11-28 08:20:56 UTC (rev 377)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java 2008-11-28 09:44:49 UTC (rev 378)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.jboss.webbeans.model;
import java.lang.annotation.Annotation;
@@ -14,20 +31,32 @@
import javax.webbeans.Stereotype;
/**
- * A meta model for a stereotype, allows us to cache a stereotype and to validate it
+ * A meta model for a stereotype, allows us to cache a stereotype and to
+ * validate it
*
- * @author pmuir
- *
+ * @author Pete Muir
+ *
*/
public class StereotypeModel<T extends Annotation> extends AnnotationModel<T>
{
+ // The default deployment type
private Annotation defaultDeploymentType;
+ // The default scope type
private Annotation defaultScopeType;
+ // Is the bean name defaulted
private boolean beanNameDefaulted;
+ // The supported scopes
private Set<Class<? extends Annotation>> supportedScopes;
+ // The required types
private Set<Class<?>> requiredTypes;
+ // The interceptor bindings
private Set<Annotation> interceptorBindings;
-
+
+ /**
+ * Constructor
+ *
+ * @param sterotype The stereotype
+ */
public StereotypeModel(Class<T> sterotype)
{
super(sterotype);
@@ -39,7 +68,10 @@
initInterceptorBindings();
checkBindingTypes();
}
-
+
+ /**
+ * Validates the binding types
+ */
private void checkBindingTypes()
{
Set<Annotation> bindingTypes = getAnnotatedAnnotation().getMetaAnnotations(BindingType.class);
@@ -49,11 +81,17 @@
}
}
+ /**
+ * Initializes the interceptor bindings
+ */
private void initInterceptorBindings()
{
interceptorBindings = getAnnotatedAnnotation().getMetaAnnotations(InterceptorBindingType.class);
}
+ /**
+ * Initializes the supported scopes
+ */
private void initSupportedScopes()
{
this.supportedScopes = new HashSet<Class<? extends Annotation>>();
@@ -63,7 +101,10 @@
this.supportedScopes.addAll(Arrays.asList(supportedScopes));
}
}
-
+
+ /**
+ * Initializes the required types
+ */
private void initRequiredTypes()
{
this.requiredTypes = new HashSet<Class<?>>();
@@ -74,6 +115,9 @@
}
}
+ /**
+ * Initializes the bean name defaulted
+ */
private void initBeanNameDefaulted()
{
if (getAnnotatedAnnotation().isAnnotationPresent(Named.class))
@@ -86,6 +130,9 @@
}
}
+ /**
+ * Initializes the default scope type
+ */
private void initDefaultScopeType()
{
Set<Annotation> scopeTypes = getAnnotatedAnnotation().getMetaAnnotations(ScopeType.class);
@@ -99,6 +146,9 @@
}
}
+ /**
+ * Initializes the default deployment type
+ */
private void initDefaultDeploymentType()
{
Set<Annotation> deploymentTypes = getAnnotatedAnnotation().getMetaAnnotations(DeploymentType.class);
@@ -111,77 +161,123 @@
this.defaultDeploymentType = deploymentTypes.iterator().next();
}
}
-
+
/**
- * Get the default deployment type the stereotype specifies, or null if none
- * is specified
+ * Get the default deployment type the stereotype specifies
+ *
+ * @return The default deployment type, or null if none is specified
*/
public Annotation getDefaultDeploymentType()
{
return defaultDeploymentType;
}
-
+
/**
- * Get the default scope type the stereotype specifies, or null if none is
- * specified
+ * Get the default scope type the stereotype specifies
+ *
+ * @return The default scope type, or null if none is specified
*/
public Annotation getDefaultScopeType()
{
return defaultScopeType;
}
-
+
/**
- * Get any interceptor bindings the the stereotype specifies, or an empty set
- * if none are specified
+ * Get any interceptor bindings the the stereotype specifies
+ *
+ * @return The interceptor bindings, or an empty set if none are specified.
*/
public Set<Annotation> getInterceptorBindings()
{
return interceptorBindings;
}
-
+
/**
- * Returns true if the stereotype specifies the bean name should be
- * defaulted
+ * Indicates if the bean name is defaulted
+ *
+ * @return True if defaulted, false otherwise
*/
public boolean isBeanNameDefaulted()
{
return beanNameDefaulted;
}
-
+
/**
- * Returns the scopes this stereotype allows, or an empty set if none are
- * specified
+ * Gets the supported scopes
+ *
+ * @return A set of supported scopes, or an empty set if none are specified
*/
public Set<Class<? extends Annotation>> getSupportedScopes()
{
return supportedScopes;
}
-
+
/**
- * Returns the types this stereotype requires, or an empty set if none are
- * specified
+ * Gets the required types
+ *
+ * @return A set of required types, or an empty set if none are specified
*/
public Set<Class<?>> getRequiredTypes()
{
return requiredTypes;
}
-
+
+ /**
+ * Gets the type
+ *
+ * @return The type
+ */
@Deprecated
public Class<? extends Annotation> getStereotypeClass()
{
return getType();
}
-
+
+ /**
+ * Gets a string representation of the stereotype
+ *
+ * @return The string representation
+ */
@Override
public String toString()
{
- return "StereotypeModel[" + getType() + "]";
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("StereotypeModel:\n");
+ buffer.append(super.toString());
+ buffer.append("Bean name defaulted: " + isBeanNameDefaulted());
+ buffer.append("Default deployment type: " + getDefaultDeploymentType());
+ buffer.append("Default scope type: " + getDefaultScopeType());
+ buffer.append("Meta-annotation: " + getMetaAnnotation().toString());
+ buffer.append("Interceptor bindings: " + getInterceptorBindings().size());
+ int i = 0;
+ for (Annotation annotation : getInterceptorBindings())
+ {
+ buffer.append(++i + " - " + annotation.toString());
+ }
+ buffer.append("Required types: " + getRequiredTypes().size());
+ i = 0;
+ for (Class<?> requiredType : getRequiredTypes())
+ {
+ buffer.append(++i + " - " + requiredType.toString());
+ }
+ buffer.append("Supported scopes: " + getSupportedScopes().size());
+ i = 0;
+ for (Class<?> supportedScope : getSupportedScopes())
+ {
+ buffer.append(++i + " - " + supportedScope.toString());
+ }
+ return buffer.toString();
}
+ /**
+ * Gets the meta-annotation type
+ *
+ * @return The Stereotype class
+ */
@Override
protected Class<? extends Annotation> getMetaAnnotation()
{
return Stereotype.class;
}
-
+
}
15 years, 12 months
[webbeans-commits] Webbeans SVN: r377 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-28 03:20:56 -0500 (Fri, 28 Nov 2008)
New Revision: 377
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
Log:
Umm. Commenting out the toStrings until checked which can call super.toString etc without looping.
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -445,15 +445,15 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AbstractAnnotatedItem:\n");
- buffer.append("Annotations: " + getAnnotations().size() + "\n");
- int i = 0;
- for (Annotation annotation : getAnnotations())
- {
- buffer.append(++i + " - " + annotation.toString() + "\n");
- }
- buffer.append(annotationMap == null ? "" : (annotationMap.toString() + "\n"));
- buffer.append(metaAnnotationMap == null ? "" : (metaAnnotationMap.toString()) + "\n");
+// buffer.append("AbstractAnnotatedItem:\n");
+// buffer.append("Annotations: " + getAnnotations().size() + "\n");
+// int i = 0;
+// for (Annotation annotation : getAnnotations())
+// {
+// buffer.append(++i + " - " + annotation.toString() + "\n");
+// }
+// buffer.append(annotationMap == null ? "" : (annotationMap.toString() + "\n"));
+// buffer.append(metaAnnotationMap == null ? "" : (metaAnnotationMap.toString()) + "\n");
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -106,11 +106,11 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AbstractAnnotatedMember:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Final: " + isFinal() + "\n");
- buffer.append("Static: " + isStatic() + "\n");
- buffer.append("Name: " + getName() + "\n");
+// buffer.append("AbstractAnnotatedMember:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Final: " + isFinal() + "\n");
+// buffer.append("Static: " + isStatic() + "\n");
+// buffer.append("Name: " + getName() + "\n");
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -102,12 +102,12 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AbstractAnnotatedType:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Superclass: " + superclass.toString() + "\n");
- buffer.append("Name: " + getName() + "\n");
- buffer.append("Final: " + isFinal() + "\n");
- buffer.append("Static: " + isStatic() + "\n");
+// buffer.append("AbstractAnnotatedType:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Superclass: " + (superclass == null ? "" : superclass.toString()) + "\n");
+// buffer.append("Name: " + getName() + "\n");
+// buffer.append("Final: " + isFinal() + "\n");
+// buffer.append("Static: " + isStatic() + "\n");
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -227,17 +227,17 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AnnotatedConstructorImpl:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Class: " + clazz.toString() + "\n");
-
- buffer.append("Members: " + getMembers().size() + "\n");
- int i = 0;
- for (AnnotatedMethod<?> member : getMembers())
- {
- buffer.append(++i + " - " + member.toString());
- }
- buffer.append(annotatedMembers == null ? "" : (annotatedMembers.toString() + "\n"));
+// buffer.append("AnnotatedConstructorImpl:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Class: " + clazz.toString() + "\n");
+//
+// buffer.append("Members: " + getMembers().size() + "\n");
+// int i = 0;
+// for (AnnotatedMethod<?> member : getMembers())
+// {
+// buffer.append(++i + " - " + member.toString());
+// }
+// buffer.append(annotatedMembers == null ? "" : (annotatedMembers.toString() + "\n"));
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -653,38 +653,38 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AnnotatedConstructorImpl:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
- int i = 0;
- for (Type actualTypeArgument : actualTypeArguments)
- {
- buffer.append(++i + " - " + actualTypeArgument.toString());
- }
- buffer.append("Class: " + clazz.toString() + "\n");
- buffer.append("Fields: " + getFields().size() + "\n");
- i = 0;
- for (AnnotatedField<Object> field : getFields())
- {
- buffer.append(++i + " - " + field.toString());
- }
- buffer.append("Methods: " + methods.size() + "\n");
- i = 0;
- for (AnnotatedMethod<Object> method : methods)
- {
- buffer.append(++i + " - " + method.toString());
- }
- buffer.append("Constructors: " + methods.size() + "\n");
- i = 0;
- for (AnnotatedConstructor<T> constructor : getConstructors())
- {
- buffer.append(++i + " - " + constructor.toString());
- }
- buffer.append(annotatedConstructors == null ? "" : (annotatedConstructors.toString() + "\n"));
- buffer.append(annotatedFields == null ? "" : (annotatedFields.toString() + "\n"));
- buffer.append(annotatedMethods == null ? "" : (annotatedMethods.toString() + "\n"));
- buffer.append(constructorsByArgumentMap == null ? "" : (constructorsByArgumentMap.toString() + "\n"));
- buffer.append(metaAnnotatedFields == null ? "" : (metaAnnotatedFields.toString() + "\n"));
+// buffer.append("AnnotatedConstructorImpl:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+// int i = 0;
+// for (Type actualTypeArgument : actualTypeArguments)
+// {
+// buffer.append(++i + " - " + actualTypeArgument.toString());
+// }
+// buffer.append("Class: " + clazz.toString() + "\n");
+// buffer.append("Fields: " + getFields().size() + "\n");
+// i = 0;
+// for (AnnotatedField<Object> field : getFields())
+// {
+// buffer.append(++i + " - " + field.toString());
+// }
+// buffer.append("Methods: " + methods.size() + "\n");
+// i = 0;
+// for (AnnotatedMethod<Object> method : methods)
+// {
+// buffer.append(++i + " - " + method.toString());
+// }
+// buffer.append("Constructors: " + methods.size() + "\n");
+// i = 0;
+// for (AnnotatedConstructor<T> constructor : getConstructors())
+// {
+// buffer.append(++i + " - " + constructor.toString());
+// }
+// buffer.append(annotatedConstructors == null ? "" : (annotatedConstructors.toString() + "\n"));
+// buffer.append(annotatedFields == null ? "" : (annotatedFields.toString() + "\n"));
+// buffer.append(annotatedMethods == null ? "" : (annotatedMethods.toString() + "\n"));
+// buffer.append(constructorsByArgumentMap == null ? "" : (constructorsByArgumentMap.toString() + "\n"));
+// buffer.append(metaAnnotatedFields == null ? "" : (metaAnnotatedFields.toString() + "\n"));
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -354,25 +354,25 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AnnotatedConstructorImpl:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
- int i = 0;
- for (Type actualTypeArgument : actualTypeArguments)
- {
- buffer.append(++i + " - " + actualTypeArgument.toString());
- }
- buffer.append("Declaring class:\n");
- buffer.append(declaringClass.toString() + "\n");
- buffer.append("Constructor:\n");
- buffer.append(constructor.toString() + "\n");
- buffer.append("Parameters: " + getParameters().size() + "\n");
- i = 0;
- for (AnnotatedParameter<?> parameter : getParameters())
- {
- buffer.append(++i + " - " + parameter.toString());
- }
- buffer.append(annotatedParameters.toString() + "\n");
+// buffer.append("AnnotatedConstructorImpl:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+// int i = 0;
+// for (Type actualTypeArgument : actualTypeArguments)
+// {
+// buffer.append(++i + " - " + actualTypeArgument.toString());
+// }
+// buffer.append("Declaring class:\n");
+// buffer.append(declaringClass.toString() + "\n");
+// buffer.append("Constructor:\n");
+// buffer.append(constructor.toString() + "\n");
+// buffer.append("Parameters: " + getParameters().size() + "\n");
+// i = 0;
+// for (AnnotatedParameter<?> parameter : getParameters())
+// {
+// buffer.append(++i + " - " + parameter.toString());
+// }
+// buffer.append(annotatedParameters.toString() + "\n");
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -146,17 +146,17 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AnnotatedFieldImpl:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
- int i = 0;
- for (Type actualTypeArgument : actualTypeArguments)
- {
- buffer.append(++i + " - " + actualTypeArgument.toString());
- }
- buffer.append("Declaring class:\n");
- buffer.append(declaringClass.toString() + "\n");
- buffer.append("Field: " + field + "\n");
+// buffer.append("AnnotatedFieldImpl:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+// int i = 0;
+// for (Type actualTypeArgument : actualTypeArguments)
+// {
+// buffer.append(++i + " - " + actualTypeArgument.toString());
+// }
+// buffer.append("Declaring class:\n");
+// buffer.append(declaringClass.toString() + "\n");
+// buffer.append("Field: " + field + "\n");
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -236,20 +236,20 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AnnotatedItemImpl:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
- int i = 0;
- for (Type actualTypeArgument : actualTypeArguments)
- {
- buffer.append(++i + " - " + actualTypeArgument.toString());
- }
- buffer.append("Actual annotations: " + actualAnnotations.length + "\n");
- i = 0;
- for (Annotation actualAnnotation : actualAnnotations)
- {
- buffer.append(++i + " - " + actualAnnotation.toString());
- }
+// buffer.append("AnnotatedItemImpl:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+// int i = 0;
+// for (Type actualTypeArgument : actualTypeArguments)
+// {
+// buffer.append(++i + " - " + actualTypeArgument.toString());
+// }
+// buffer.append("Actual annotations: " + actualAnnotations.length + "\n");
+// i = 0;
+// for (Annotation actualAnnotation : actualAnnotations)
+// {
+// buffer.append(++i + " - " + actualAnnotation.toString());
+// }
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -372,26 +372,26 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AnnotatedMethodImpl:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
- int i = 0;
- for (Type actualTypeArgument : actualTypeArguments)
- {
- buffer.append(++i + " - " + actualTypeArgument.toString());
- }
- buffer.append(annotatedParameters == null ? "" : (annotatedParameters.toString() + "\n"));
- buffer.append("Declaring class:\n");
- buffer.append(declaringClass.toString());
- buffer.append("Method:\n");
- buffer.append(method.toString());
- buffer.append("Property name: " + propertyName + "\n");
- i = 0;
- buffer.append("Parameters: " + getParameters().size() + "\n");
- for (AnnotatedParameter<?> parameter : parameters)
- {
- buffer.append(++i + " - " + parameter.toString() + "\n");
- }
+// buffer.append("AnnotatedMethodImpl:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+// int i = 0;
+// for (Type actualTypeArgument : actualTypeArguments)
+// {
+// buffer.append(++i + " - " + actualTypeArgument.toString());
+// }
+// buffer.append(annotatedParameters == null ? "" : (annotatedParameters.toString() + "\n"));
+// buffer.append("Declaring class:\n");
+// buffer.append(declaringClass.toString());
+// buffer.append("Method:\n");
+// buffer.append(method.toString());
+// buffer.append("Property name: " + propertyName + "\n");
+// i = 0;
+// buffer.append("Parameters: " + getParameters().size() + "\n");
+// for (AnnotatedParameter<?> parameter : parameters)
+// {
+// buffer.append(++i + " - " + parameter.toString() + "\n");
+// }
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2008-11-28 08:11:35 UTC (rev 376)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2008-11-28 08:20:56 UTC (rev 377)
@@ -148,18 +148,17 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("AnnotatedParameterImpl:\n");
- buffer.append(super.toString() + "\n");
- buffer.append("Type: " + type.toString() + "\n");
- buffer.append("Final: " + _final + "\n");
- buffer.append("Static: " + _static + "\n");
- buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
- int i = 0;
- for (Type actualTypeArgument : actualTypeArguments)
- {
- buffer.append(++i + " - " + actualTypeArgument.toString() + "\n");
- }
-
+// buffer.append("AnnotatedParameterImpl:\n");
+// buffer.append(super.toString() + "\n");
+// buffer.append("Type: " + type.toString() + "\n");
+// buffer.append("Final: " + _final + "\n");
+// buffer.append("Static: " + _static + "\n");
+// buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+// int i = 0;
+// for (Type actualTypeArgument : actualTypeArguments)
+// {
+// buffer.append(++i + " - " + actualTypeArgument.toString() + "\n");
+// }
return buffer.toString();
}
15 years, 12 months
[webbeans-commits] Webbeans SVN: r376 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-28 03:11:35 -0500 (Fri, 28 Nov 2008)
New Revision: 376
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java
Log:
javadocs/comments/toStrings
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java 2008-11-28 07:51:44 UTC (rev 375)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java 2008-11-28 08:11:35 UTC (rev 376)
@@ -38,9 +38,14 @@
*/
public abstract class AbstractContext implements Context
{
-
+ // The scope type
private Class<? extends Annotation> scopeType;
+ /**
+ * Constructor
+ *
+ * @param scopeType The scope type
+ */
public AbstractContext(Class<? extends Annotation> scopeType)
{
this.scopeType = scopeType;
@@ -53,6 +58,8 @@
* exists
* @return An instance of the bean
* @throws ContextNotActiveException if the context is not active
+ *
+ * @see javax.webbeans.manager.Context#get(Bean, boolean)
*/
public <T> T get(Bean<T> bean, boolean create)
{
@@ -80,6 +87,8 @@
* Get the scope the context is for
*
* @return The scope type
+ *
+ * @see javax.webbeans.manager.Context#getScopeType()
*/
public Class<? extends Annotation> getScopeType()
{
@@ -90,6 +99,8 @@
* Return true if the context is active
*
* @return The active state
+ *
+ * @see javax.webbeans.manager.Context#isActive()
*/
public boolean isActive()
{
@@ -128,7 +139,7 @@
* @return The actual bean map
*/
protected abstract BeanMap getBeanMap();
-
+
/**
* A method that should return the actual atomic boolean instance
*
@@ -139,10 +150,12 @@
@Override
public String toString()
{
- return
- "Context type: " + getScopeType().getName() +
- "\nActive: " + getActive().toString() +
- "\nBeans: " + getBeanMap().toString();
- }
-
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AbstractContext:\n");
+ buffer.append("Scope type: " + getScopeType().toString() + "\n");
+ buffer.append("Active: " + getActive().toString() + "\n");
+ buffer.append(getBeanMap().toString() + "\n");
+ return buffer.toString();
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-11-28 07:51:44 UTC (rev 375)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-11-28 08:11:35 UTC (rev 376)
@@ -80,8 +80,7 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("Context map\n");
- buffer.append("Known scope types: " + delegate.size() + "\n");
+ buffer.append("Scope type -> context list mappings: " + delegate.size() + "\n");
int i = 0;
for (Entry<Class<? extends Annotation>, List<Context>> entry : delegate.entrySet())
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-11-28 07:51:44 UTC (rev 375)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-11-28 08:11:35 UTC (rev 376)
@@ -37,7 +37,7 @@
}
/**
- * Overriden method always creating a new instance
+ * Overridden method always creating a new instance
*
* @param bean The bean to create
* @param create Should a new one be created
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java 2008-11-28 07:51:44 UTC (rev 375)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java 2008-11-28 08:11:35 UTC (rev 376)
@@ -39,10 +39,19 @@
{
private static LogProvider log = Logging.getLogProvider(SessionBeanMap.class);
+ // The HTTP session to use as backing map
private HttpSession session;
+ // The Web Beans manager
private ManagerImpl manager;
+ // The storage prefix to put before names
private String keyPrefix;
+ /**
+ * Constructor
+ *
+ * @param manager The Web Beans manager
+ * @param keyPrefix The storage names prefix
+ */
public SessionBeanMap(ManagerImpl manager, String keyPrefix)
{
super();
@@ -96,6 +105,8 @@
*
* @param bean The bean to get from the session
* @return An instance of the bean
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#get(Bean)
*/
@SuppressWarnings("unchecked")
public <T> T get(Bean<? extends T> bean)
@@ -116,6 +127,8 @@
*
* @param bean The bean whose instance to remove.
* @return The instance removed
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#remove(Bean)
*/
public <T> T remove(Bean<? extends T> bean)
{
@@ -133,6 +146,8 @@
* First, checks that the session is present. Then, iterates over the
* attribute names in the session and removes them if they start with the
* know prefix.
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#clear()
*/
@SuppressWarnings("unchecked")
public void clear()
@@ -156,6 +171,8 @@
* Finally, returns the list.
*
* @return An Iterable to the beans in the storage
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#keySet()
*/
@SuppressWarnings("unchecked")
public Iterable<Bean<? extends Object>> keySet()
@@ -187,13 +204,15 @@
*
* @param bean The bean to use as key
* @param instance The bean instance to add
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#put(Bean, Object)
*/
public <T> void put(Bean<? extends T> bean, T instance)
{
checkSession();
String key = getBeanKey(bean);
session.setAttribute(key, instance);
- log.trace("Stored bean " + bean + " under key " + key + " in session");
+ log.trace("Stored instance " + instance + " for bean " + bean + " under key " + key + " in session");
}
@SuppressWarnings("unchecked")
@@ -202,11 +221,12 @@
{
StringBuffer buffer = new StringBuffer();
List<Bean<?>> beans = (List) keySet();
- buffer.append(beans.size() + " found in session\n");
+ buffer.append("Bean -> bean instance mappings in HTTP session: " + beans.size() + "\n");
+ int i = 0;
for (Bean<?> bean : beans)
{
Object instance = get(bean);
- buffer.append(getBeanKey(bean) + ": " + instance + "\n");
+ buffer.append(++i + " - " + getBeanKey(bean) + ": " + instance + "\n");
}
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java 2008-11-28 07:51:44 UTC (rev 375)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SimpleBeanMap.java 2008-11-28 08:11:35 UTC (rev 376)
@@ -17,14 +17,15 @@
package org.jboss.webbeans.contexts;
-import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import javax.webbeans.manager.Bean;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
import com.google.common.collect.ForwardingMap;
/**
@@ -34,8 +35,14 @@
*/
public class SimpleBeanMap extends ForwardingMap<Bean<? extends Object>, Object> implements BeanMap
{
+ private static LogProvider log = Logging.getLogProvider(SimpleBeanMap.class);
+
+ // The backing map
protected Map<Bean<? extends Object>, Object> delegate;
+ /**
+ * Constructor
+ */
public SimpleBeanMap()
{
delegate = new ConcurrentHashMap<Bean<? extends Object>, Object>();
@@ -46,11 +53,15 @@
*
* @param The bean to look for
* @return An instance, if found
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#get(Bean)
*/
@SuppressWarnings("unchecked")
public <T extends Object> T get(Bean<? extends T> bean)
{
- return (T) super.get(bean);
+ T instance = (T) super.get(bean);
+ log.trace("Searched bean map for " + bean + " and got " + instance);
+ return instance;
}
/**
@@ -63,31 +74,40 @@
{
return delegate;
}
-
+
/**
* Removed a instance from the map
*
- * @param bean the bean to remove
- * @return The instance removed
+ * @param bean the bean to remove
+ * @return The instance removed
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#remove(Bean)
*/
@SuppressWarnings("unchecked")
public <T extends Object> T remove(Bean<? extends T> bean)
{
- return (T) super.remove(bean);
+ T instance = (T) super.remove(bean);
+ log.trace("Removed instace " + instance + " for bean " + bean + " from the bean map");
+ return instance;
}
/**
* Clears the map
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#clear()
*/
public void clear()
{
delegate.clear();
+ log.trace("Bean map cleared");
}
/**
* Returns the beans contained in the map
*
* @return The beans present
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#keySet()
*/
public Set<Bean<? extends Object>> keySet()
{
@@ -99,20 +119,24 @@
*
* @param bean The bean
* @param instance the instance
+ *
+ * @see org.jboss.webbeans.contexts.BeanMap#put(Bean, Object)
*/
public <T> void put(Bean<? extends T> bean, T instance)
{
delegate.put(bean, instance);
+ log.trace("Stored instance " + instance + " for bean " + bean + " in bean map");
}
- @SuppressWarnings("unchecked")
@Override
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append(delegate.size() + " found in session\n");
- for (Entry<Bean<? extends Object>, Object> entry : delegate.entrySet()) {
- buffer.append(entry.getKey().toString() + ": " + entry.getValue().toString() + "\n");
+ buffer.append("Bean -> bean instance mappings: " + delegate.size() + "\n");
+ int i = 0;
+ for (Entry<Bean<? extends Object>, Object> entry : delegate.entrySet())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + entry.getValue().toString() + "\n");
}
return buffer.toString();
}
15 years, 12 months
[webbeans-commits] Webbeans SVN: r375 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: introspector/jlr and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-28 02:51:44 -0500 (Fri, 28 Nov 2008)
New Revision: 375
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
Log:
javadocs/comments/toString
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -395,6 +395,8 @@
* Destroys a bean instance
*
* @param instance The instance to destroy
+ *
+ * @see javax.webbeans.manager.Bean#destroy(Object)
*/
@Override
public void destroy(T instance)
@@ -429,6 +431,8 @@
* Returns the binding types
*
* @return The set of binding types
+ *
+ * @see javax.webbeans.manager.Bean#getBindingTypes()
*/
public Set<Annotation> getBindingTypes()
{
@@ -468,6 +472,8 @@
* Returns the deployment type of the bean
*
* @return The deployment type
+ *
+ * @see javax.webbeans.manager.Bean#getDeploymentType()
*/
public Class<? extends Annotation> getDeploymentType()
{
@@ -509,6 +515,8 @@
* Returns the name of the bean
*
* @return The name
+ *
+ * @see javax.webbeans.manager.Bean#getName()
*/
public String getName()
{
@@ -529,6 +537,8 @@
* Returns the scope type of the bean
*
* @return The scope type
+ *
+ * @see javax.webbeans.manager.Bean#getScopeType()
*/
public Class<? extends Annotation> getScopeType()
{
@@ -559,6 +569,8 @@
* Returns the API types of the bean
*
* @return The set of API types
+ *
+ * @see javax.webbeans.manager.Bean#getTypes()
*/
@Override
public Set<Class<?>> getTypes()
@@ -592,6 +604,8 @@
* Inicates if bean is nullable
*
* @return True if nullable, false otherwise
+ *
+ * @see javax.webbeans.manager.Bean#isNullable()
*/
@Override
public boolean isNullable()
@@ -613,6 +627,8 @@
* Indicates if bean is serializable
*
* @return True if serializable, false otherwise
+ *
+ * @see @see javax.webbeans.manager.Bean#isSerializable()
*/
@Override
public boolean isSerializable()
@@ -625,10 +641,11 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
+ buffer.append("AbstractBean:\n");
buffer.append("Name: " + name + "\n");
buffer.append("Type: " + type + "\n");
- buffer.append("Scope type " + scopeType.getName() + "\n");
- buffer.append("Deployment type: " + deploymentType.getName() + "\n");
+ buffer.append("Scope type " + scopeType.toString() + "\n");
+ buffer.append("Deployment type: " + deploymentType.toString() + "\n");
buffer.append("Primitive : " + primitive + "\n");
buffer.append("Declared bean type: " + (declaredBeanType == null ? "null" : declaredBeanType.toString()) + "\n");
buffer.append("Remove method: " + (removeMethod == null ? "null" : removeMethod.toString()) + "\n");
@@ -644,7 +661,6 @@
{
buffer.append(++i + " - " + apiType.getName() + "\n");
}
- buffer.append("Merged stereotype\n");
buffer.append(mergedStereotypes.toString() + "\n");
buffer.append("Injection points: " + injectionPoints.size() + "\n");
i = 0;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -262,7 +262,8 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append(super.toString());
+ buffer.append("AbstractClassBean:\n");
+ buffer.append(super.toString() + "\n");
buffer.append("Annotated item: " + annotatedItem.toString() + "\n");
buffer.append("Initializer methods: " + initializerMethods.size() + "\n");
int i = 0;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -339,7 +339,8 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("EnterpriseBean[" + getType().getName() + "]\n");
+ buffer.append("EnterpriseBean:\n");
+ buffer.append(super.toString() + "\n");
buffer.append(ejbMetaData.toString() + "\n");
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -152,7 +152,7 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("Merged stereotype\n");
+ buffer.append("Merged stereotypes:\n");
buffer.append("Bean name defaulted: " + beanNameDefaulted + "\n");
buffer.append("Possible deployment types: " + possibleDeploymentTypes.size() + "\n");
int i = 0;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -292,7 +292,7 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("ProducerMethodBean[" + getType().getName() + "]\n");
+ buffer.append("ProducerMethodBean:\n");
buffer.append(super.toString() + "\n");
buffer.append("Location: " + location + "\n");
buffer.append("Declaring bean: " + declaringBean.toString() + "\n");
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -360,7 +360,7 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("SimpleWebBean[" + getAnnotatedItem().toString() + "]\n");
+ buffer.append("SimpleBean\n");
buffer.append(super.toString() + "\n");
buffer.append("Location: " + location + "\n");
buffer.append("Constructor: " + constructor.toString() + "\n");
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -52,7 +52,7 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("XML-defined enterprise bean\n");
+ buffer.append("XmlEnterpriseBean\n");
buffer.append(super.toString() + "\n");
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -52,7 +52,7 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("XML-defined simple bean\n");
+ buffer.append("XmlLSimpleBean\n");
buffer.append(super.toString() + "\n");
return buffer.toString();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28 07:37:21 UTC (rev 374)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28 07:51:44 UTC (rev 375)
@@ -31,7 +31,6 @@
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
15 years, 12 months
[webbeans-commits] Webbeans SVN: r374 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-28 02:37:21 -0500 (Fri, 28 Nov 2008)
New Revision: 374
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
Log:
javadocs/comments/toStrings
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-27 22:49:18 UTC (rev 373)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-28 07:37:21 UTC (rev 374)
@@ -257,6 +257,7 @@
* @param parameters The list of annotated parameter to look up
* @param manager The Web Beans manager
* @return The object array of looked up values
+ *
*/
protected static Object[] getParameterValues(List<AnnotatedParameter<Object>> parameters, ManagerImpl manager)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2008-11-27 22:49:18 UTC (rev 373)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2008-11-28 07:37:21 UTC (rev 374)
@@ -24,7 +24,7 @@
* Represents an abstract annotated type
*
* @author Pete Muir
- *
+ *
* @param <T>
*/
public abstract class AbstractAnnotatedType<T> extends AbstractAnnotatedItem<T, Class<T>>
@@ -41,40 +41,46 @@
{
super(annotationMap);
}
-
+
/**
* Indicates if the type is static (through the delegate)
*
* @return True if static, false otherwise
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isStatic()
*/
public boolean isStatic()
{
return Reflections.isStatic(getDelegate());
}
-
+
/**
* Indicates if the type if final (through the delegate)
*
* @return True if final, false otherwise
- */
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isFinal()
+ */
public boolean isFinal()
{
return Reflections.isFinal(getDelegate());
}
-
+
/**
* Gets the name of the type
*
* @returns The name (through the delegate)
- */
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getName()
+ */
public String getName()
{
return getDelegate().getName();
}
-
+
/**
* Gets the superclass abstraction of the type
- *
+ *
* @return The superclass abstraction
*/
@SuppressWarnings("unchecked")
@@ -87,5 +93,22 @@
}
return superclass;
}
-
+
+ /**
+ * Gets a string representation of the annotated type
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AbstractAnnotatedType:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Superclass: " + superclass.toString() + "\n");
+ buffer.append("Name: " + getName() + "\n");
+ buffer.append("Final: " + isFinal() + "\n");
+ buffer.append("Static: " + isStatic() + "\n");
+ return buffer.toString();
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2008-11-27 22:49:18 UTC (rev 373)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2008-11-28 07:37:21 UTC (rev 374)
@@ -28,6 +28,8 @@
import org.jboss.webbeans.introspector.AnnotatedAnnotation;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import com.google.common.collect.ForwardingMap;
+
/**
* Represents an annotated annotation
*
@@ -37,8 +39,44 @@
*/
public class AnnotatedAnnotationImpl<T extends Annotation> extends AbstractAnnotatedType<T> implements AnnotatedAnnotation<T>
{
+
+ /**
+ * A (annotation type -> set of method abstractions with annotation) map
+ */
+ private class AnnotatedMembers extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>
+ {
+ private Map<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> delegate;
+
+ public AnnotatedMembers()
+ {
+ delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>();
+ }
+
+ @Override
+ protected Map<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> delegate()
+ {
+ return delegate;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation type -> member abstraction mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> entry : delegate.entrySet())
+ {
+ for (AnnotatedMethod<?> parameter : entry.getValue())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
// The annotated members map (annotation -> member with annotation)
- private Map<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> annotatedMembers;
+ private AnnotatedMembers annotatedMembers;
// The implementation class of the annotation
private Class<T> clazz;
// The set of abstracted members
@@ -61,6 +99,8 @@
* Gets the actual type arguments
*
* @return The type arguments
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getActualTypeArguments()
*/
public Type[] getActualTypeArguments()
{
@@ -73,6 +113,8 @@
* Initializes the members first if they are null
*
* @return The set of abstracted members
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getMembers()
*/
public Set<AnnotatedMethod<?>> getMembers()
{
@@ -87,6 +129,8 @@
* Gets the delegate
*
* @return The delegate
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getDelegate()
*/
public Class<T> getDelegate()
{
@@ -95,6 +139,8 @@
/**
* Gets the type of the annotation
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getType()
*/
public Class<T> getType()
{
@@ -124,6 +170,8 @@
* @param annotationType The annotation type to match
* @return The set of abstracted members with the given annotation type
* present. An empty set is returned if no matches are found
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getAnnotatedMembers(Class)
*/
public Set<AnnotatedMethod<?>> getAnnotatedMembers(Class<? extends Annotation> annotationType)
{
@@ -157,7 +205,7 @@
{
initMembers();
}
- annotatedMembers = new HashMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>();
+ annotatedMembers = new AnnotatedMembers();
for (AnnotatedMethod<?> member : members)
{
for (Annotation annotation : member.getAnnotations())
@@ -171,4 +219,26 @@
}
}
+ /**
+ * Gets a string representation of the constructor
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AnnotatedConstructorImpl:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Class: " + clazz.toString() + "\n");
+
+ buffer.append("Members: " + getMembers().size() + "\n");
+ int i = 0;
+ for (AnnotatedMethod<?> member : getMembers())
+ {
+ buffer.append(++i + " - " + member.toString());
+ }
+ buffer.append(annotatedMembers == null ? "" : (annotatedMembers.toString() + "\n"));
+ return buffer.toString();
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-11-27 22:49:18 UTC (rev 373)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2008-11-28 07:37:21 UTC (rev 374)
@@ -65,6 +65,23 @@
{
return delegate;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation type -> field abstraction mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, Set<AnnotatedField<Object>>> entry : delegate.entrySet())
+ {
+ for (AnnotatedField<Object> parameter : entry.getValue())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
+
}
/**
@@ -84,11 +101,27 @@
{
return delegate;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Meta-annotation type -> method abstraction mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, Set<AnnotatedField<Object>>> entry : delegate.entrySet())
+ {
+ for (AnnotatedField<Object> parameter : entry.getValue())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
}
/**
* A (annotation type -> set of method abstractions with annotation) map
- */
+ */
private class AnnotatedMethods extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>>
{
private Map<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>> delegate;
@@ -103,6 +136,22 @@
{
return delegate;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation type -> method abstraction mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, Set<AnnotatedMethod<Object>>> entry : delegate.entrySet())
+ {
+ for (AnnotatedMethod<Object> parameter : entry.getValue())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
}
/**
@@ -122,10 +171,27 @@
{
return delegate;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation type -> constructor abstraction mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>> entry : delegate.entrySet())
+ {
+ for (AnnotatedConstructor<T> parameter : entry.getValue())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
}
/**
- * A (class list -> set of constructor abstractions with matching parameters) map
+ * A (class list -> set of constructor abstractions with matching parameters)
+ * map
*/
private class ConstructorsByArgument extends ForwardingMap<List<Class<?>>, AnnotatedConstructor<T>>
{
@@ -141,6 +207,19 @@
{
return delegate;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation type -> constructor by arguments mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<List<Class<?>>, AnnotatedConstructor<T>> entry : delegate.entrySet())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + entry.getValue().toString() + "\n");
+ }
+ return buffer.toString();
+ }
}
// The implementing class
@@ -389,6 +468,8 @@
* Gets the actual type arguments
*
* @return The type arguments
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedClass#getActualTypeArguments()
*/
public Type[] getActualTypeArguments()
{
@@ -425,6 +506,8 @@
* @param annotationType The annotation type to match
* @return A set of matching method abstractions. Returns an empty set if no
* matches are found.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedClass#getAnnotatedMethods(Class)
*/
public Set<AnnotatedMethod<Object>> getAnnotatedMethods(Class<? extends Annotation> annotationType)
{
@@ -501,6 +584,8 @@
* @return A set of abstracted constructors with given annotation type. If
* the constructors set is empty, initialize it first .Returns an
* empty set if there are no matches.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedClass#getAnnotatedConstructors(Class)
*/
public Set<AnnotatedConstructor<T>> getAnnotatedConstructors(Class<? extends Annotation> annotationType)
{
@@ -546,9 +631,61 @@
}
}
+ /**
+ * Gets a constructor with given arguments
+ *
+ * @param arguments The arguments to match
+ * @return A constructor which takes given arguments. Null is returned if
+ * there are no matches.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedClass#getConstructor(List)
+ */
public AnnotatedConstructor<T> getConstructor(List<Class<?>> arguments)
{
return constructorsByArgumentMap.get(arguments);
}
+ /**
+ * Gets a string representation of the constructor
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AnnotatedConstructorImpl:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+ int i = 0;
+ for (Type actualTypeArgument : actualTypeArguments)
+ {
+ buffer.append(++i + " - " + actualTypeArgument.toString());
+ }
+ buffer.append("Class: " + clazz.toString() + "\n");
+ buffer.append("Fields: " + getFields().size() + "\n");
+ i = 0;
+ for (AnnotatedField<Object> field : getFields())
+ {
+ buffer.append(++i + " - " + field.toString());
+ }
+ buffer.append("Methods: " + methods.size() + "\n");
+ i = 0;
+ for (AnnotatedMethod<Object> method : methods)
+ {
+ buffer.append(++i + " - " + method.toString());
+ }
+ buffer.append("Constructors: " + methods.size() + "\n");
+ i = 0;
+ for (AnnotatedConstructor<T> constructor : getConstructors())
+ {
+ buffer.append(++i + " - " + constructor.toString());
+ }
+ buffer.append(annotatedConstructors == null ? "" : (annotatedConstructors.toString() + "\n"));
+ buffer.append(annotatedFields == null ? "" : (annotatedFields.toString() + "\n"));
+ buffer.append(annotatedMethods == null ? "" : (annotatedMethods.toString() + "\n"));
+ buffer.append(constructorsByArgumentMap == null ? "" : (constructorsByArgumentMap.toString() + "\n"));
+ buffer.append(metaAnnotatedFields == null ? "" : (metaAnnotatedFields.toString() + "\n"));
+ return buffer.toString();
+ }
+
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-27 22:49:18 UTC (rev 373)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-28 07:37:21 UTC (rev 374)
@@ -46,7 +46,7 @@
{
/**
- * An annotation type -> list of annotations map
+ * An annotation type -> list of annotations map
*/
private class AnnotatedParameters extends ForwardingMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>
{
@@ -62,6 +62,22 @@
{
return delegate;
}
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation type -> parameter abstraction mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> entry : delegate.entrySet())
+ {
+ for (AnnotatedParameter<?> parameter : entry.getValue())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
}
// The type arguments
@@ -126,6 +142,8 @@
* Gets the actual type arguments
*
* @return The type arguments
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedConstructor#getActualTypeArguments()
*/
public Type[] getActualTypeArguments()
{
@@ -138,6 +156,8 @@
* If the parameters are null, initalize them first
*
* @return A list of annotated parameter abstractions
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedConstructor#getParameters()
*/
public List<AnnotatedParameter<Object>> getParameters()
{
@@ -236,6 +256,8 @@
* @param annotationType The annotation type to match
* @return A list of matching parameter abstractions. An empty list is
* returned if there are no matches.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedConstructor#getAnnotatedParameters(Class)
*/
public List<AnnotatedParameter<Object>> getAnnotatedParameters(Class<? extends Annotation> annotationType)
{
@@ -255,6 +277,8 @@
*
* @param manager The Web Beans manager
* @return An instance
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedConstructor#newInstance(ManagerImpl)
*/
public T newInstance(ManagerImpl manager)
{
@@ -321,7 +345,7 @@
{
return declaringClass;
}
-
+
/**
* Gets a string representation of the constructor
*
@@ -330,8 +354,26 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
+ buffer.append("AnnotatedConstructorImpl:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+ int i = 0;
+ for (Type actualTypeArgument : actualTypeArguments)
+ {
+ buffer.append(++i + " - " + actualTypeArgument.toString());
+ }
+ buffer.append("Declaring class:\n");
+ buffer.append(declaringClass.toString() + "\n");
+ buffer.append("Constructor:\n");
+ buffer.append(constructor.toString() + "\n");
+ buffer.append("Parameters: " + getParameters().size() + "\n");
+ i = 0;
+ for (AnnotatedParameter<?> parameter : getParameters())
+ {
+ buffer.append(++i + " - " + parameter.toString());
+ }
+ buffer.append(annotatedParameters.toString() + "\n");
return buffer.toString();
}
-
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-27 22:49:18 UTC (rev 373)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-28 07:37:21 UTC (rev 374)
@@ -31,6 +31,7 @@
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.Strings;
import com.google.common.collect.ForwardingMap;
@@ -66,7 +67,7 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("Annotation -> parameter mappings: " + super.size() + "\n");
+ buffer.append("Annotation type -> parameter abstraction mappings: " + super.size() + "\n");
int i = 0;
for (Entry<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> entry : delegate.entrySet())
{
@@ -152,7 +153,7 @@
*
* @return The actual type arguments
*
- * @see org.jboss.webbeans.introspector.AnnotatedItem#getActualTypeArguments()
+ * @see org.jboss.webbeans.introspector.AnnotatedMethod#getActualTypeArguments()
*/
public Type[] getActualTypeArguments()
{
15 years, 12 months
[webbeans-commits] Webbeans SVN: r373 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: introspector and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2008-11-27 17:49:18 -0500 (Thu, 27 Nov 2008)
New Revision: 373
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
Log:
javadocs/comments/toStrings
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -21,7 +21,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import javax.webbeans.manager.Context;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -30,7 +30,7 @@
{
/**
- * Gets the value of the parameter
+ * Gets the actual value of the parameter from the manager
*
* @param manager The Web Beans Manager
* @return The value
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -73,6 +73,24 @@
return delegate;
}
+ /**
+ * Gets a string representation of the Map
+ *
+ * @return A string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation type -> annotation mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, Annotation> entry : delegate.entrySet())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + entry.getValue().toString() + "\n");
+ }
+ return buffer.toString();
+ }
+
}
/**
@@ -118,6 +136,27 @@
return annotations;
}
+ /**
+ * Gets a string representation of the Map
+ *
+ * @return A string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation type -> meta annotation mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, Set<Annotation>> entry : delegate.entrySet())
+ {
+ for (Annotation annotation : entry.getValue())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + annotation.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
+
}
// The array of default binding types
@@ -131,7 +170,8 @@
// The annotation map (annotation type -> annotation) of the item
private AnnotationMap annotationMap;
- // The meta-annotation map (annotation type -> set of annotations containing meta-annotation) of the item
+ // The meta-annotation map (annotation type -> set of annotations containing
+ // meta-annotation) of the item
private MetaAnnotationMap metaAnnotationMap;
// The set of all annotations on the item
private Set<Annotation> annotationSet;
@@ -234,6 +274,8 @@
*
* @param annotationType the annotation type to match
* @return The annotation if found, null if no match was found
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getAnnotation(Class)
*/
@SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<? extends A> annotationType)
@@ -247,6 +289,8 @@
* @param metaAnnotationType The meta-annotation type to match
* @return The set of annotations containing this meta-annotation. An empty
* set is returned if no match is found.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getMetaAnnotations(Class)
*/
public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
{
@@ -262,6 +306,8 @@
* @param metaAnnotationType meta-annotation type to match
* @return The array of annotations to match. An empty array is returned if
* no match is found.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getMetaAnnotationsAsArray(Class)
*/
public Annotation[] getMetaAnnotationsAsArray(Class<? extends Annotation> metaAnnotationType)
{
@@ -279,6 +325,8 @@
* Populates the annotationSet if it was empty
*
* @return The set of annotations on this item.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getAnnotations()
*/
public Set<Annotation> getAnnotations()
{
@@ -295,6 +343,8 @@
*
* @param annotatedType The annotation type to check for
* @return True if present, false otherwise.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isAnnotationPresent(Class)
*/
public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
{
@@ -334,6 +384,8 @@
*
* @param that The other annotated item to check against
* @return True if assignable, false otherwise
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isAssignableFrom(AnnotatedItem)
*/
public boolean isAssignableFrom(AnnotatedItem<?, ?> that)
{
@@ -345,6 +397,8 @@
*
* @param types The set of types to check against
* @return True if assignable, false otherwise
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isAssignableFrom(Set)
*/
public boolean isAssignableFrom(Set<Class<?>> types)
{
@@ -389,22 +443,17 @@
@Override
public String toString()
{
- String string = getType().toString();
- if (getActualTypeArguments().length > 0)
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AbstractAnnotatedItem:\n");
+ buffer.append("Annotations: " + getAnnotations().size() + "\n");
+ int i = 0;
+ for (Annotation annotation : getAnnotations())
{
- string += "<";
- for (int i = 0; i < getActualTypeArguments().length; i++)
- {
- string += getActualTypeArguments()[i].toString();
- if (i < getActualTypeArguments().length - 1)
- {
- string += ",";
- }
- }
- string += ">";
+ buffer.append(++i + " - " + annotation.toString() + "\n");
}
- string += getAnnotations();
- return string;
+ buffer.append(annotationMap == null ? "" : (annotationMap.toString() + "\n"));
+ buffer.append(metaAnnotationMap == null ? "" : (metaAnnotationMap.toString()) + "\n");
+ return buffer.toString();
}
/**
@@ -414,6 +463,8 @@
* meta-annotation. Returns default binding (current) if none specified.
*
* @return A set of (binding type) annotations
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getBindingTypes()
*/
public Set<Annotation> getBindingTypes()
{
@@ -434,6 +485,8 @@
* meta-annotation. Returns default binding (current) if none specified.
*
* @return An array of (binding type) annotations
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getBindingTypesAsArray()
*/
public Annotation[] getBindingTypesAsArray()
{
@@ -451,6 +504,8 @@
* Indicates if the type is proxyable to a set of pre-defined rules
*
* @return True if proxyable, false otherwise.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isProxyable()
*/
public boolean isProxyable()
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -51,6 +51,8 @@
* Indicates if the member is static (through the delegate)
*
* @return True if static, false otherwise
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isStatic()
*/
public boolean isStatic()
{
@@ -61,6 +63,8 @@
* Indicates if the member if final (through the delegate)
*
* @return True if final, false otherwise
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isFinal()
*/
public boolean isFinal()
{
@@ -82,6 +86,8 @@
* Gets the name of the member
*
* @returns The name (or the name of the delegate if none is defined)
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getName()
*/
public String getName()
{
@@ -92,4 +98,21 @@
return name;
}
+ /**
+ * Gets a string representation of the member
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AbstractAnnotatedMember:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Final: " + isFinal() + "\n");
+ buffer.append("Static: " + isStatic() + "\n");
+ buffer.append("Name: " + getName() + "\n");
+ return buffer.toString();
+ }
+
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -321,5 +321,17 @@
{
return declaringClass;
}
+
+ /**
+ * Gets a string representation of the constructor
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ return buffer.toString();
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -26,14 +26,31 @@
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.Reflections;
+/**
+ * Represents an annotated field
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
public class AnnotatedFieldImpl<T> extends AbstractAnnotatedMember<T, Field> implements AnnotatedField<T>
{
-
+ // The actual type arguments
private Type[] actualTypeArguments = new Type[0];
-
+ // The underlying field
private Field field;
+ // The abstraction of the declaring class
private AnnotatedType<?> declaringClass;
-
+
+ /**
+ * Constructor
+ *
+ * Initializes the superclass with the built annotation map and detects the
+ * type arguments
+ *
+ * @param field The actual field
+ * @param declaringClass The abstraction of the declaring class
+ */
public AnnotatedFieldImpl(Field field, AnnotatedType<?> declaringClass)
{
super(buildAnnotationMap(field));
@@ -46,6 +63,11 @@
}
}
+ /**
+ * Gets the underlying field
+ *
+ * @return The fields
+ */
public Field getAnnotatedField()
{
return field;
@@ -55,30 +77,87 @@
{
return field;
}
-
+
+ /**
+ * Gets the type
+ *
+ * @return The type
+ */
+ @SuppressWarnings("unchecked")
public Class<T> getType()
{
return (Class<T>) field.getType();
}
-
+
+ /**
+ * Gets the actual type arguments
+ *
+ * @return The type arguments
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedField#getActualTypeArguments()
+ */
public Type[] getActualTypeArguments()
{
return actualTypeArguments;
}
+ /**
+ * Gets the current value and injects this instance into an instance
+ *
+ * @param instance The instance to inject into
+ * @param manager The Web Beans manager
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedField#inject(Object, ManagerImpl)
+ */
public void inject(Object instance, ManagerImpl manager)
{
Reflections.setAndWrap(getDelegate(), instance, getValue(manager));
}
-
+
+ /**
+ * Gets the property name
+ *
+ * @return The property name
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedField#getName()
+ */
public String getPropertyName()
{
return getName();
}
-
+
+ /**
+ * Gets the abstracted declaring class
+ *
+ * @return The declaring class
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedField#getDeclaringClass()
+ */
public AnnotatedType<?> getDeclaringClass()
{
return declaringClass;
}
+ /**
+ * Gets a string representation of the field
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AnnotatedFieldImpl:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+ int i = 0;
+ for (Type actualTypeArgument : actualTypeArguments)
+ {
+ buffer.append(++i + " - " + actualTypeArgument.toString());
+ }
+ buffer.append("Declaring class:\n");
+ buffer.append(declaringClass.toString() + "\n");
+ buffer.append("Field: " + field + "\n");
+ return buffer.toString();
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -23,24 +23,58 @@
import javax.webbeans.TypeLiteral;
+/**
+ * Represents an annotated item
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ * @param <S>
+ */
public class AnnotatedItemImpl<T, S> extends AbstractAnnotatedItem<T, S>
{
-
+ // The actual type arguments
private Type[] actualTypeArguments = new Type[0];
+ // The type of the item
private Class<T> type;
+ // The actual annotations
private Annotation[] actualAnnotations;
-
+
+ /**
+ * Constructor
+ *
+ * Initializes the superclass with the annotation map
+ *
+ * @param annotationMap The annotated map
+ */
private AnnotatedItemImpl(AnnotationMap annotationMap)
{
super(annotationMap);
}
-
+
+ /**
+ * Constructor
+ *
+ * Initializes the superclass with the annotation map and sets the type
+ *
+ * @param annotationMap The annotation map
+ * @param type The type of the item
+ */
private AnnotatedItemImpl(AnnotationMap annotationMap, Class<T> type)
{
super(annotationMap);
this.type = type;
}
-
+
+ /**
+ * Constructor
+ *
+ * Initializes the superclass with the annotation map, sets the api type and
+ * determines the type arguments
+ *
+ * @param annotationMap The annotation map
+ * @param apiType The api type
+ */
private AnnotatedItemImpl(AnnotationMap annotationMap, TypeLiteral<T> apiType)
{
super(annotationMap);
@@ -50,70 +84,173 @@
actualTypeArguments = ((ParameterizedType) apiType.getType()).getActualTypeArguments();
}
}
-
+
+ /**
+ * Constructor
+ *
+ * @param annotationMap The annotation map
+ * @param type The type
+ * @param actualTypeArguments The actual type arguments
+ */
private AnnotatedItemImpl(AnnotationMap annotationMap, Class<T> type, Type[] actualTypeArguments)
{
this(annotationMap, type);
this.actualTypeArguments = actualTypeArguments;
}
-
+
+ /**
+ * Constructor
+ *
+ * @param annotations The annotations array of the type
+ */
public AnnotatedItemImpl(Annotation[] annotations)
{
this(buildAnnotationMap(annotations));
this.actualAnnotations = annotations;
}
-
+
+ /**
+ * Constructor
+ *
+ * @param annotations The annotations array of the type
+ * @param type The type
+ */
public AnnotatedItemImpl(Annotation[] annotations, Class<T> type)
{
this(buildAnnotationMap(annotations), type);
this.actualAnnotations = annotations;
}
-
+
+ /**
+ * Constructor
+ *
+ * @param annotations The annotations array of the type
+ * @param apiType The API typeliteral
+ */
public AnnotatedItemImpl(Annotation[] annotations, TypeLiteral<T> apiType)
{
this(buildAnnotationMap(annotations), apiType);
this.actualAnnotations = annotations;
}
-
+
+ /**
+ * Constructor
+ *
+ * @param annotations The annotations array of the type
+ * @param type The type of the item
+ * @param actualTypeArguments The actual type arguments array
+ */
public AnnotatedItemImpl(Annotation[] annotations, Class<T> type, Type[] actualTypeArguments)
{
this(buildAnnotationMap(annotations), type, actualTypeArguments);
this.actualAnnotations = annotations;
}
+ /**
+ * Gets the delegate (null)
+ *
+ * @return null
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getDelegate()
+ */
public S getDelegate()
{
return null;
}
-
+
+ /**
+ * Gets the item type
+ *
+ * @return The type
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getType()
+ */
public Class<T> getType()
{
return type;
}
+ /**
+ * Gets the actual type arguments
+ *
+ * @return The actual type arguments array
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getActualTypeArguments()
+ */
public Type[] getActualTypeArguments()
{
return actualTypeArguments;
}
-
+
+ /**
+ * Gets the actual annotations
+ *
+ * @return The annotations array
+ */
public Annotation[] getActualAnnotations()
{
return actualAnnotations;
}
-
+
+ /**
+ * Indicates if the item is static
+ *
+ * @return false
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isStatic()
+ */
public boolean isStatic()
{
return false;
}
-
+
+ /**
+ * Indicates if the item is final
+ *
+ * @return false
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isFinal()
+ */
public boolean isFinal()
{
return false;
}
+ /**
+ * Gets the name. Should be overridden
+ *
+ * @throws IllegalArgumentException.
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getName()
+ */
public String getName()
{
throw new IllegalArgumentException("Unable to determine name");
}
-
+
+ /**
+ * Gets a string representation of the item
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AnnotatedItemImpl:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+ int i = 0;
+ for (Type actualTypeArgument : actualTypeArguments)
+ {
+ buffer.append(++i + " - " + actualTypeArgument.toString());
+ }
+ buffer.append("Actual annotations: " + actualAnnotations.length + "\n");
+ i = 0;
+ for (Annotation actualAnnotation : actualAnnotations)
+ {
+ buffer.append(++i + " - " + actualAnnotation.toString());
+ }
+ return buffer.toString();
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -32,20 +32,79 @@
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.Reflections;
+import com.google.common.collect.ForwardingMap;
+
+/**
+ * Represents an annotated method
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
public class AnnotatedMethodImpl<T> extends AbstractAnnotatedMember<T, Method> implements AnnotatedMethod<T>
{
-
+ /**
+ * A annotation type -> list of parameter abstractions with given annotations
+ * present mapping
+ */
+ private class AnnotatedParameters extends ForwardingMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>
+ {
+ private Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate;
+
+ public AnnotatedParameters()
+ {
+ delegate = new HashMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>();
+ }
+
+ @Override
+ protected Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> delegate()
+ {
+ return delegate;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Annotation -> parameter mappings: " + super.size() + "\n");
+ int i = 0;
+ for (Entry<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> entry : delegate.entrySet())
+ {
+ for (AnnotatedParameter<?> parameter : entry.getValue())
+ {
+ buffer.append(++i + " - " + entry.getKey().toString() + ": " + parameter.toString() + "\n");
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
+ // The actual type arguments
private Type[] actualTypeArguments = new Type[0];
-
+ // The underlying method
private Method method;
-
+
+ // The abstracted parameters
private List<AnnotatedParameter<Object>> parameters;
- private Map<Class<? extends Annotation>, List<AnnotatedParameter<Object>>> annotatedParameters;
+ // A mapping from annotation type to parameter abstraction with that
+ // annotation present
+ private AnnotatedParameters annotatedParameters;
+ // The property name
private String propertyName;
+ // The abstracted declaring class
private AnnotatedType<?> declaringClass;
-
+
+ /**
+ * Constructor
+ *
+ * Initializes the superclass with the built annotation map, sets the method
+ * and declaring class abstraction and detects the actual type arguments
+ *
+ * @param method The underlying method
+ * @param declaringClass The declaring class abstraction
+ */
public AnnotatedMethodImpl(Method method, AnnotatedType<?> declaringClass)
{
super(buildAnnotationMap(method));
@@ -57,26 +116,58 @@
}
}
+ /**
+ * Gets the annotated method
+ *
+ * @return The method
+ */
public Method getAnnotatedMethod()
{
return method;
}
+ /**
+ * Gets the delegate
+ *
+ * @return The delegate
+ */
public Method getDelegate()
{
return method;
}
-
+
+ /**
+ * Gets the type of the method
+ *
+ * @return The return type of the method
+ */
+ @SuppressWarnings("unchecked")
public Class<T> getType()
{
return (Class<T>) method.getReturnType();
}
-
+
+ /**
+ * Gets the actual type arguments
+ *
+ * @return The actual type arguments
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getActualTypeArguments()
+ */
public Type[] getActualTypeArguments()
{
return actualTypeArguments;
}
-
+
+ /**
+ * Gets the annotated parameters
+ *
+ * If the parameters are null, they are initialized first
+ *
+ * @return The annotated parameters
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedMethod#getParameters()
+ */
public List<AnnotatedParameter<Object>> getParameters()
{
if (parameters == null)
@@ -85,7 +176,14 @@
}
return parameters;
}
-
+
+ /**
+ * Initializes the parameter abstractions
+ *
+ * Iterates over the method abstraction parameters and creates an abstraction
+ * of the parameter
+ */
+ @SuppressWarnings("unchecked")
private void initParameters()
{
this.parameters = new ArrayList<AnnotatedParameter<Object>>();
@@ -105,31 +203,40 @@
}
}
}
-
- public List<AnnotatedParameter<Object>> getAnnotatedMethods(Class<? extends Annotation> annotationType)
- {
- if (annotatedParameters == null)
- {
- initAnnotatedParameters();
- }
-
- if (!annotatedParameters.containsKey(annotationType))
- {
- return new ArrayList<AnnotatedParameter<Object>>();
- }
- else
- {
- return annotatedParameters.get(annotationType);
- }
- }
+ // TODO: Don't get this one - NIK
+ // public List<AnnotatedParameter<Object>> getAnnotatedMethods(Class<?
+ // extends Annotation> annotationType)
+ // {
+ // if (annotatedParameters == null)
+ // {
+ // initAnnotatedParameters();
+ // }
+ //
+ // if (!annotatedParameters.containsKey(annotationType))
+ // {
+ // return new ArrayList<AnnotatedParameter<Object>>();
+ // }
+ // else
+ // {
+ // return annotatedParameters.get(annotationType);
+ // }
+ // }
+
+ /**
+ * Initializes the annotated parameters
+ *
+ * If the parameters are null, they are initialized first. Iterates over the
+ * parameter abstractions and for each annotation present, maps the parameter
+ * abstraction under that annotation type key.
+ */
private void initAnnotatedParameters()
{
if (parameters == null)
{
initParameters();
}
- annotatedParameters = new HashMap<Class<? extends Annotation>, List<AnnotatedParameter<Object>>>();
+ annotatedParameters = new AnnotatedParameters();
for (AnnotatedParameter<Object> parameter : parameters)
{
for (Annotation annotation : parameter.getAnnotations())
@@ -143,6 +250,15 @@
}
}
+ /**
+ * Gets the parameter abstractions with a given annotation type
+ *
+ * If the parameter abstractions are null, they are initialized first
+ *
+ * @param annotationType The annotation type to match
+ * @return The list of abstracted parameters with given annotation type
+ * present. An empty list is returned if there are no matches
+ */
public List<AnnotatedParameter<Object>> getAnnotatedParameters(Class<? extends Annotation> annotationType)
{
if (annotatedParameters == null)
@@ -155,7 +271,12 @@
}
return annotatedParameters.get(annotationType);
}
-
+
+ /**
+ * Compares two annotated methods (delegates)
+ *
+ * @return True if equals, false otherwise
+ */
@Override
public boolean equals(Object other)
{
@@ -169,23 +290,55 @@
return false;
}
}
-
+
+ /**
+ * Gets the hash code (of the delegate)
+ *
+ * @return The hash code
+ */
@Override
public int hashCode()
{
return getDelegate().hashCode();
}
+ /**
+ * Invokes the method on an instance with current parameters from manager
+ *
+ * @param mananger The Web Beans manager
+ * @param instance The instance to invoke on
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedMethod#invoke(ManagerImpl,
+ * Object)
+ */
+ @SuppressWarnings("unchecked")
public T invoke(ManagerImpl manager, Object instance)
{
return (T) Reflections.invokeAndWrap(getDelegate(), instance, getParameterValues(parameters, manager));
}
-
+
+ /**
+ * Invokes the method on an instance with given parameters
+ *
+ * @param instance The instance to invoke on
+ * @param parameters The parameters
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedMethod#invoke(Object,
+ * Object...)
+ */
+ @SuppressWarnings("unchecked")
public T invoke(Object instance, Object... parameters)
{
return (T) Reflections.invokeAndWrap(getDelegate(), instance, parameters);
}
-
+
+ /**
+ * Gets the name of the property
+ *
+ * @return The name
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedMethod#getPropertyName()
+ */
public String getPropertyName()
{
if (propertyName == null)
@@ -199,9 +352,47 @@
return propertyName;
}
+ /**
+ * Gets the declaring class
+ *
+ * @return The declaring class
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedMethod#getDeclaringClass()
+ */
public AnnotatedType<?> getDeclaringClass()
{
return declaringClass;
}
+ /**
+ * Gets a string representation of the method
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AnnotatedMethodImpl:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+ int i = 0;
+ for (Type actualTypeArgument : actualTypeArguments)
+ {
+ buffer.append(++i + " - " + actualTypeArgument.toString());
+ }
+ buffer.append(annotatedParameters == null ? "" : (annotatedParameters.toString() + "\n"));
+ buffer.append("Declaring class:\n");
+ buffer.append(declaringClass.toString());
+ buffer.append("Method:\n");
+ buffer.append(method.toString());
+ buffer.append("Property name: " + propertyName + "\n");
+ i = 0;
+ buffer.append("Parameters: " + getParameters().size() + "\n");
+ for (AnnotatedParameter<?> parameter : parameters)
+ {
+ buffer.append(++i + " - " + parameter.toString() + "\n");
+ }
+ return buffer.toString();
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2008-11-27 14:19:40 UTC (rev 372)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2008-11-27 22:49:18 UTC (rev 373)
@@ -25,53 +25,142 @@
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedParameter;
+/**
+ * Represents a parameter
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
public class AnnotatedParameterImpl<T> extends AbstractAnnotatedItem<T, Object> implements AnnotatedParameter<T>
{
-
+ // The type
private Class<T> type;
+ // The actual type arguments
private Type[] actualTypeArguments = new Type[0];
+ // The final state
private boolean _final;
+ // The static state
private boolean _static;
+ /**
+ * Constructor
+ *
+ * @param annotations The annotations array
+ * @param type The type of the parameter
+ */
public AnnotatedParameterImpl(Annotation[] annotations, Class<T> type)
{
super(buildAnnotationMap(annotations));
this.type = type;
}
+ /**
+ * Gets the actual type arguments
+ *
+ * @return The type arguments
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getActualTypeArguments()
+ */
public Type[] getActualTypeArguments()
{
return actualTypeArguments;
}
+ /**
+ * Gets the delegate
+ *
+ * @return The delegate (null)
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getDelegate()
+ */
public Object getDelegate()
{
return null;
}
+ /**
+ * Gets the type of the parameter
+ *
+ * @return The type
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getType()
+ */
public Class<T> getType()
{
return type;
}
+ /**
+ * Indicates if the parameter is final
+ *
+ * @return True if final, false otherwise
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isFinal()
+ */
public boolean isFinal()
{
return _final;
}
+ /**
+ * Indicates if the parameter is static
+ *
+ * @return True if static, false otherwise
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#isStatic()
+ */
public boolean isStatic()
{
return _static;
}
-
+
+ /**
+ * Gets the current value
+ *
+ * @param manager The Web Beans manager
+ * @return the value
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedParameter
+ */
public T getValue(ManagerImpl manager)
{
return manager.getInstanceByType(getType(), getMetaAnnotationsAsArray(BindingType.class));
}
+ /**
+ * Gets the name of the parameter
+ *
+ * @throws IllegalArgumentException (not supported)
+ *
+ * @see org.jboss.webbeans.introspector.AnnotatedItem#getName()
+ */
public String getName()
{
throw new IllegalArgumentException("Unable to determine name of parameter");
}
-
+
+ /**
+ * Gets a string representation of the parameter
+ *
+ * @return A string representation
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("AnnotatedParameterImpl:\n");
+ buffer.append(super.toString() + "\n");
+ buffer.append("Type: " + type.toString() + "\n");
+ buffer.append("Final: " + _final + "\n");
+ buffer.append("Static: " + _static + "\n");
+ buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
+ int i = 0;
+ for (Type actualTypeArgument : actualTypeArguments)
+ {
+ buffer.append(++i + " - " + actualTypeArgument.toString() + "\n");
+ }
+
+ return buffer.toString();
+ }
+
}
15 years, 12 months