You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2010/06/08 11:45:28 UTC
svn commit: r952591 [1/2] - in
/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans:
component/creation/ config/ util/ xml/
Author: struberg
Date: Tue Jun 8 09:45:27 2010
New Revision: 952591
URL: http://svn.apache.org/viewvc?rev=952591&view=rev
Log:
OWB-275 code cleanup
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InjectedTargetBeanCreator.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreator.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefaultAnnotation.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java Tue Jun 8 09:45:27 2010
@@ -52,7 +52,8 @@ public class AnnotatedTypeBeanCreatorImp
getBean().setConstructor(constructor);
- }catch(Exception e)
+ }
+ catch(Exception e)
{
logger.warn(OWBLogConst.WARN_0012, getAnnotatedType().getJavaClass());
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java Tue Jun 8 09:45:27 2010
@@ -18,12 +18,11 @@
*/
package org.apache.webbeans.component.creation;
-import javax.enterprise.inject.spi.Bean;
import org.apache.webbeans.component.AbstractOwbBean;
/**
- * Contract for {@link Bean} creation.
+ * Contract for {@link javax.enterprise.inject.spi.Bean} creation.
*
* <p>
* Common operations on ManagedBean, ProducerField and ProducerMethods.
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InjectedTargetBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InjectedTargetBeanCreator.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InjectedTargetBeanCreator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InjectedTargetBeanCreator.java Tue Jun 8 09:45:27 2010
@@ -22,12 +22,11 @@ import java.util.Set;
import javax.enterprise.inject.spi.ObserverMethod;
-import org.apache.webbeans.component.InjectionTargetBean;
import org.apache.webbeans.component.ProducerFieldBean;
import org.apache.webbeans.component.ProducerMethodBean;
/**
- * Contract for {@link InjectionTargetBean} creation.
+ * Contract for {@link org.apache.webbeans.component.InjectionTargetBean} creation.
*
* <p>
* Common operations for ManagedBean.
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreator.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreator.java Tue Jun 8 09:45:27 2010
@@ -18,10 +18,8 @@
*/
package org.apache.webbeans.component.creation;
-import org.apache.webbeans.component.ManagedBean;
-
/**
- * Contract for {@link ManagedBean}.
+ * Contract for {@link org.apache.webbeans.component.ManagedBean}.
*
* @version $Rev$ $Date$
*
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Tue Jun 8 09:45:27 2010
@@ -28,7 +28,6 @@ import java.util.Set;
import java.util.ArrayList;
import java.util.Stack;
-import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Model;
import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.spi.AnnotatedType;
@@ -51,7 +50,6 @@ import org.apache.webbeans.component.Owb
import org.apache.webbeans.component.WebBeansType;
import org.apache.webbeans.component.creation.ManagedBeanCreatorImpl;
import org.apache.webbeans.component.creation.BeanCreator.MetaDataProvider;
-import org.apache.webbeans.config.OWBLogConst;
import org.apache.webbeans.container.BeanManagerImpl;
import org.apache.webbeans.container.InjectionResolver;
import org.apache.webbeans.corespi.ServiceLoader;
@@ -88,7 +86,7 @@ import org.apache.webbeans.xml.XMLAnnota
import org.apache.webbeans.xml.XMLSpecializesManager;
/**
- * Deploys the all beans that are defined in the {@link WebBeansScanner} at
+ * Deploys the all beans that are defined in the {@link org.apache.webbeans.spi.ScannerService} at
* the scanner phase.
*/
@SuppressWarnings("unchecked")
@@ -123,7 +121,7 @@ public class BeansDeployer
* Deploys all the defined web beans components in the container startup.
* <p>
* It deploys from the web-beans.xml files and from the class files. It uses
- * the {@link org.apache.webbeans.corespi.ScannerService} to get classes.
+ * the {@link org.apache.webbeans.spi.ScannerService} to get classes.
* </p>
*
* @throws WebBeansDeploymentException if any deployment exception occurs
@@ -376,7 +374,9 @@ public class BeansDeployer
if(!bean.getBeanClass().isAnnotationPresent(javax.decorator.Decorator.class)
&& !BeanManagerImpl.getManager().containsCustomDecoratorClass(bean.getBeanClass()))
{
- throw new WebBeansConfigurationException("Delegate injection points can not defined by beans that are not decorator. Injection point : " + injectionPoint);
+ throw new WebBeansConfigurationException(
+ "Delegate injection points can not defined by beans that are not decorator. Injection point : "
+ + injectionPoint);
}
}
}
@@ -524,9 +524,10 @@ public class BeansDeployer
try
{
fis.close();
- } catch (IOException e)
+ }
+ catch (IOException e)
{
- // all ok, ignore this!
+ ;// all ok, ignore this!
}
}
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefaultAnnotation.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefaultAnnotation.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefaultAnnotation.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefaultAnnotation.java Tue Jun 8 09:45:27 2010
@@ -26,7 +26,8 @@ import java.lang.reflect.Proxy;
/**
* A small helper class to create a Annotation instance of the given annotation class
* via {@link java.lang.reflect.Proxy}.
- * The annotation literal gets filled with the default values.
+ * The annotation literal gets filled with the default values.
+ * TODO implement class caching!
*/
public class DefaultAnnotation implements InvocationHandler{
public static Annotation of(Class<? extends Annotation> annotation)
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java Tue Jun 8 09:45:27 2010
@@ -25,6 +25,7 @@ import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javassist.util.proxy.ProxyFactory;
+import org.apache.webbeans.exception.WebBeansException;
public class SecurityUtil
{
@@ -46,7 +47,10 @@ public class SecurityUtil
{
Object obj = AccessController.doPrivileged(
new PrivilegedActionForClass(clazz, parameterTypes, METHOD_CLASS_GETDECLAREDCONSTRUCTOR));
- if (obj instanceof NoSuchMethodException) throw (NoSuchMethodException)obj;
+ if (obj instanceof NoSuchMethodException)
+ {
+ throw (NoSuchMethodException)obj;
+ }
return (Constructor<T>)obj;
}
@@ -62,7 +66,10 @@ public class SecurityUtil
{
Object obj = AccessController.doPrivileged(
new PrivilegedActionForClass(clazz, new Object[] {name, parameterTypes}, METHOD_CLASS_GETDECLAREDMETHOD));
- if (obj instanceof NoSuchMethodException) throw (NoSuchMethodException)obj;
+ if (obj instanceof NoSuchMethodException)
+ {
+ throw (NoSuchMethodException)obj;
+ }
return (Method)obj;
}
@@ -77,7 +84,10 @@ public class SecurityUtil
{
Object obj = AccessController.doPrivileged(
new PrivilegedActionForClass(clazz, name, METHOD_CLASS_GETDECLAREDFIELD));
- if (obj instanceof NoSuchFieldException) throw (NoSuchFieldException)obj;
+ if (obj instanceof NoSuchFieldException)
+ {
+ throw (NoSuchFieldException)obj;
+ }
return (Field)obj;
}
@@ -123,13 +133,15 @@ public class SecurityUtil
return clazz.getDeclaredField((String)parameters);
case METHOD_CLASS_GETDECLAREDFIELDS:
return clazz.getDeclaredFields();
+
+ default:
+ return new WebBeansException("unknown security method: " + method);
}
}
catch (Exception exception)
{
return exception;
}
- return null;
}
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java Tue Jun 8 09:45:27 2010
@@ -21,7 +21,8 @@ package org.apache.webbeans.util;
import java.util.List;
import java.util.Comparator;
-public class SortedListHelper<E> {
+public class SortedListHelper<E>
+{
List<E> list;
Comparator<E> comparator;
@@ -37,13 +38,15 @@ public class SortedListHelper<E> {
return list;
}
- public boolean add(E object) {
+ public boolean add(E object)
+ {
if (list.isEmpty())
{
list.add(object);
return true;
}
- for(int i=0; i<list.size(); i++) {
+ for(int i=0; i<list.size(); i++)
+ {
E obj = list.get(i);
if (comparator.compare(object, obj) < 0)
{
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java Tue Jun 8 09:45:27 2010
@@ -107,7 +107,8 @@ public final class WebBeansAnnotatedType
{
if (found == true)
{
- throw new WebBeansConfigurationException("There are more than one constructor with @Inject annotation in annotation type : " + type);
+ throw new WebBeansConfigurationException("There are more than one constructor with @Inject annotation in annotation type : "
+ + type);
}
found = true;
@@ -138,7 +139,8 @@ public final class WebBeansAnnotatedType
{
if (parameter.isAnnotationPresent(Disposes.class))
{
- throw new WebBeansConfigurationException("Constructor parameter annotations can not contain @Disposes annotation in annotated constructor : " + result);
+ throw new WebBeansConfigurationException("Constructor parameter annotations can not contain @Disposes annotation in annotated constructor : "
+ + result);
}
if(parameter.isAnnotationPresent(Observes.class))
@@ -267,7 +269,8 @@ public final class WebBeansAnnotatedType
if (foundBean == null || !(foundBean instanceof ProducerMethodBean))
{
- throw new UnsatisfiedResolutionException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : " + annotatedMethod.getDeclaringType().getJavaClass() + "is not found");
+ throw new UnsatisfiedResolutionException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : "
+ + annotatedMethod.getDeclaringType().getJavaClass() + "is not found");
}
pr = (ProducerMethodBean<?>) foundBean;
@@ -281,7 +284,8 @@ public final class WebBeansAnnotatedType
// multiple same producer
if (previous.equals(pr))
{
- throw new WebBeansConfigurationException("There are multiple disposal method for the producer method : " + pr.getCreatorMethod().getName() + " in class : " + annotatedMethod.getDeclaringType().getJavaClass());
+ throw new WebBeansConfigurationException("There are multiple disposal method for the producer method : " + pr.getCreatorMethod().getName() + " in class : "
+ + annotatedMethod.getDeclaringType().getJavaClass());
}
}
@@ -289,7 +293,8 @@ public final class WebBeansAnnotatedType
//Disposer methods and producer methods must be in the same class
if(!producerMethod.getDeclaringClass().getName().equals(declaredMethod.getDeclaringClass().getName()))
{
- throw new WebBeansConfigurationException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : " + annotatedMethod.getDeclaringType().getJavaClass() + " must be in the same class!");
+ throw new WebBeansConfigurationException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : "
+ + annotatedMethod.getDeclaringType().getJavaClass() + " must be in the same class!");
}
pr.setDisposalMethod(declaredMethod);
@@ -362,7 +367,8 @@ public final class WebBeansAnnotatedType
{
if(!bean.getScope().equals(Dependent.class))
{
- throw new WebBeansConfigurationException("Error in annotated field : " + annotatedField +" while definining injected field. If bean has a public modifier injection point, bean scope must be defined as @Dependent");
+ throw new WebBeansConfigurationException("Error in annotated field : " + annotatedField
+ +" while definining injected field. If bean has a public modifier injection point, bean scope must be defined as @Dependent");
}
}
@@ -509,11 +515,15 @@ public final class WebBeansAnnotatedType
Set<Type> types = annotatedMethod.getTypeClosure();
producerMethodBean.getTypes().addAll(types);
- DefinitionUtil.defineScopeType(producerMethodBean, AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()), "Annotated producer method : " + annotatedMethod + "must declare default @Scope annotation");
+ DefinitionUtil.defineScopeType(producerMethodBean,
+ AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()),
+ "Annotated producer method : " + annotatedMethod + "must declare default @Scope annotation");
WebBeansUtil.checkUnproxiableApiType(producerMethodBean, producerMethodBean.getScope());
WebBeansUtil.checkProducerGenericType(producerMethodBean,annotatedMethod.getJavaMember());
DefinitionUtil.defineQualifiers(producerMethodBean, AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()));
- DefinitionUtil.defineName(producerMethodBean, AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()), WebBeansUtil.getProducerDefaultName(annotatedMethod.getJavaMember().getName()));
+ DefinitionUtil.defineName(producerMethodBean,
+ AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()),
+ WebBeansUtil.getProducerDefaultName(annotatedMethod.getJavaMember().getName()));
addMethodInjectionPointMetaData(producerMethodBean, annotatedMethod);
producerBeans.add(producerMethodBean);
@@ -529,8 +539,7 @@ public final class WebBeansAnnotatedType
/**
* Check producer method is ok for deployment.
*
- * @param method producer method
- * @param parentImplClazzName parent class name
+ * @param annotatedMethod producer method
*/
public static <X> void checkProducerMethodForDeployment(AnnotatedMethod<X> annotatedMethod)
{
@@ -540,7 +549,8 @@ public final class WebBeansAnnotatedType
annotatedMethod.isAnnotationPresent(Disposes.class) ||
annotatedMethod.isAnnotationPresent(Observes.class))
{
- throw new WebBeansConfigurationException("Producer annotated method : " + annotatedMethod + " can not be annotated with" + " @Initializer/@Destructor annotation or has a parameter annotated with @Disposes/@Observes");
+ throw new WebBeansConfigurationException("Producer annotated method : " + annotatedMethod + " can not be annotated with"
+ + " @Initializer/@Destructor annotation or has a parameter annotated with @Disposes/@Observes");
}
}
@@ -558,14 +568,16 @@ public final class WebBeansAnnotatedType
annotatedMethod.getJavaMember().getName(), parameters);
if (superMethod == null)
{
- throw new WebBeansConfigurationException("Anontated producer method specialization is failed : " + annotatedMethod.getJavaMember().getName() + " not found in super class : " +
- annotatedMethod.getDeclaringType().getJavaClass().getSuperclass().getName() + " for annotated method : " + annotatedMethod);
+ throw new WebBeansConfigurationException("Anontated producer method specialization is failed : " + annotatedMethod.getJavaMember().getName()
+ + " not found in super class : " + annotatedMethod.getDeclaringType().getJavaClass().getSuperclass().getName()
+ + " for annotated method : " + annotatedMethod);
}
if (!AnnotationUtil.hasAnnotation(superMethod.getAnnotations(), Produces.class))
{
- throw new WebBeansConfigurationException("Anontated producer method specialization is failed : " + annotatedMethod.getJavaMember().getName() + " found in super class : " +
- annotatedMethod.getDeclaringType().getJavaClass().getSuperclass().getName() + " is not annotated with @Produces" + " for annotated method : " + annotatedMethod);
+ throw new WebBeansConfigurationException("Anontated producer method specialization is failed : " + annotatedMethod.getJavaMember().getName()
+ + " found in super class : " + annotatedMethod.getDeclaringType().getJavaClass().getSuperclass().getName()
+ + " is not annotated with @Produces" + " for annotated method : " + annotatedMethod);
}
/* To avoid multiple invocations of setBeanName(), following code is delayed to
@@ -622,8 +634,7 @@ public final class WebBeansAnnotatedType
/**
* CheckProducerMethodDisposal.
- * @param disposalMethod disposal method
- * @param definedBeanClassName bean class name
+ * @param annotatedMethod disposal method
*/
public static <X> void checkProducerMethodDisposal(AnnotatedMethod<X> annotatedMethod)
{
@@ -662,26 +673,29 @@ public final class WebBeansAnnotatedType
if (AnnotationUtil.hasAnnotatedMethodMultipleParameterAnnotation(annotatedMethod, Observes.class))
{
- throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + clazz.getName() + " can not define two parameters with annotated @Observes");
+ throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + clazz.getName()
+ + " can not define two parameters with annotated @Observes");
}
if (annotatedMethod.isAnnotationPresent(Produces.class)
|| annotatedMethod.isAnnotationPresent(Inject.class))
{
- throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + clazz.getName() + " can not annotated with annotation in the list {@Produces, @Initializer, @Destructor}");
+ throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + clazz.getName()
+ + " can not annotated with annotation in the list {@Produces, @Initializer, @Destructor}");
}
if (AnnotationUtil.hasAnnotatedMethodParameterAnnotation(annotatedMethod, Disposes.class))
{
- throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + clazz.getName() + " can not annotated with annotation @Disposes");
+ throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : "
+ + clazz.getName() + " can not annotated with annotation @Disposes");
}
}
/**
* Checks the implementation class for checking conditions.
*
- * @param clazz implementation class
+ * @param type implementation class
* @throws WebBeansConfigurationException if any configuration exception occurs
*/
public static <X> void checkManagedBeanCondition(AnnotatedType<X> type) throws WebBeansConfigurationException
@@ -741,12 +755,14 @@ public final class WebBeansAnnotatedType
{
if (hasClassInterceptors)
{
- throw new WebBeansConfigurationException("Maanged bean class : " + clazz.getName() + " can not define non-static, non-private final methods. Because it is annotated with at least one @InterceptorBinding");
+ throw new WebBeansConfigurationException("Maanged bean class : " + clazz.getName()
+ + " can not define non-static, non-private final methods. Because it is annotated with at least one @InterceptorBinding");
}
if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(AnnotationUtil.getAnnotationsFromSet(methodA.getAnnotations())))
{
- throw new WebBeansConfigurationException("Method : " + method.getName() + "in managed bean class : " + clazz.getName() + " can not be defined as non-static, non-private and final . Because it is annotated with at least one @InterceptorBinding");
+ throw new WebBeansConfigurationException("Method : " + method.getName() + "in managed bean class : " + clazz.getName()
+ + " can not be defined as non-static, non-private and final . Because it is annotated with at least one @InterceptorBinding");
}
}
@@ -858,7 +874,7 @@ public final class WebBeansAnnotatedType
/**
* Define decorator bean.
* @param <T> type info
- * @param clazz decorator class
+ * @param annotatedType decorator class
*/
public static <T> void defineDecorator(AnnotatedType<T> annotatedType)
{
@@ -872,12 +888,14 @@ public final class WebBeansAnnotatedType
Method method = methodA.getJavaMember();
if(AnnotationUtil.hasMethodAnnotation(method, Produces.class))
{
- throw new WebBeansConfigurationException("Decorator class : " + annotatedType.getJavaClass() + " can not have producer methods but it has one with name : " + method.getName());
+ throw new WebBeansConfigurationException("Decorator class : " + annotatedType.getJavaClass() + " can not have producer methods but it has one with name : "
+ + method.getName());
}
if(AnnotationUtil.hasMethodParameterAnnotation(method, Observes.class))
{
- throw new WebBeansConfigurationException("Decorator class : " + annotatedType.getJavaClass() + " can not have observer methods but it has one with name : " + method.getName());
+ throw new WebBeansConfigurationException("Decorator class : " + annotatedType.getJavaClass() + " can not have observer methods but it has one with name : "
+ + method.getName());
}
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java Tue Jun 8 09:45:27 2010
@@ -96,10 +96,10 @@ import org.w3c.dom.Text;
public final class WebBeansXMLConfigurator
{
private static final WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansXMLConfigurator.class);
-
+
/** Current configuration file name */
private String CURRENT_SCAN_FILE_NAME = null;
-
+
/**OWB specific or not*/
private boolean owbSpecificConfiguration = false;
@@ -114,7 +114,7 @@ public final class WebBeansXMLConfigurat
String usage = OpenWebBeansConfiguration.getInstance().getProperty(OpenWebBeansConfiguration.USE_OWB_SPECIFIC_XML_CONFIGURATION);
this.owbSpecificConfiguration = Boolean.parseBoolean(usage);
}
-
+
/**
* Configures XML configuration file.
* @param xmlStream xml configuration file
@@ -128,22 +128,22 @@ public final class WebBeansXMLConfigurat
//Use OWB Specific XML Configuration
if(this.owbSpecificConfiguration)
{
- configureOwbSpecific(xmlStream, "No-name XML Stream");
+ configureOwbSpecific(xmlStream, "No-name XML Stream");
}
else
{
configureSpecSpecific(xmlStream, "No-name XML Stream");
}
-
+
}
}
catch (IOException e)
{
throw new WebBeansConfigurationException(e);
}
-
+
}
-
+
/**
* Configures XML configuration file.
* @param xmlStream xml configuration file
@@ -158,26 +158,26 @@ public final class WebBeansXMLConfigurat
//Use OWB Specific XML Configuration
if(this.owbSpecificConfiguration)
{
- configureOwbSpecific(xmlStream, fileName);
+ configureOwbSpecific(xmlStream, fileName);
}
else
{
configureSpecSpecific(xmlStream, fileName);
}
-
+
}
}
catch (IOException e)
{
throw new WebBeansConfigurationException(e);
}
-
+
}
-
+
/**
* Configures the web beans from the given input stream.
- *
+ *
* @param xmlStream xml file containing the web beans definitions.
* @param fileName name of the configuration file
*/
@@ -189,14 +189,14 @@ public final class WebBeansXMLConfigurat
{
Asserts.assertNotNull(xmlStream,"xmlStream parameter can not be null!");
Asserts.assertNotNull(fileName,"fileName parameter can not be null!");
-
+
CURRENT_SCAN_FILE_NAME = fileName;
-
+
//Get root element of the XML document
Element webBeansRoot = XMLUtil.getRootElement(xmlStream);
-
+
//Start configuration
- configureOwbSpecific(webBeansRoot);
+ configureOwbSpecific(webBeansRoot);
}
}
catch (IOException e)
@@ -204,10 +204,10 @@ public final class WebBeansXMLConfigurat
throw new WebBeansConfigurationException(e);
}
}
-
+
/**
* Configures the web beans from the given input stream.
- *
+ *
* @param xmlStream xml file containing the web beans definitions.
* @param fileName name of the configuration file
*/
@@ -219,14 +219,14 @@ public final class WebBeansXMLConfigurat
{
Asserts.assertNotNull(xmlStream,"xmlStream parameter can not be null!");
Asserts.assertNotNull(fileName,"fileName parameter can not be null!");
-
+
CURRENT_SCAN_FILE_NAME = fileName;
-
+
//Get root element of the XML document
Element webBeansRoot = XMLUtil.getSpecStrictRootElement(xmlStream);
-
+
//Start configuration
- configureSpecSpecific(webBeansRoot);
+ configureSpecSpecific(webBeansRoot);
}
}
catch (IOException e)
@@ -234,11 +234,11 @@ public final class WebBeansXMLConfigurat
throw new WebBeansConfigurationException(e);
}
}
-
+
/**
* Configures the xml file root element.
- *
+ *
* @param webBeansRoot root element of the configuration xml file
*/
private void configureOwbSpecific(Element webBeansRoot)
@@ -249,9 +249,9 @@ public final class WebBeansXMLConfigurat
NodeList ns = webBeansRoot.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
/* WebBean element decleration */
if (XMLUtil.isElementWebBeanDeclaration(child))
@@ -275,16 +275,16 @@ public final class WebBeansXMLConfigurat
addNewBindingType(child);
}
-
+
//X TODO <Resource> annotation element declaration */
-
+
/* <InterceptorBindingType> annotation element decleration */
else if (XMLUtil.isElementInterceptorBindingTypeDecleration(child))
{
addNewInterceptorBindingType(child);
}
-
+
/* <Stereotype> annotation element decleration */
else if (XMLUtil.isElementStereoTypeDecleration(child))
{
@@ -294,7 +294,7 @@ public final class WebBeansXMLConfigurat
{
configureAlternativesElement(child);
}
-
+
}
// Configures the WebBeans components
@@ -304,7 +304,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the xml file root element.
- *
+ *
* @param webBeansRoot root element of the configuration xml file
*/
private void configureSpecSpecific(Element webBeansRoot)
@@ -313,9 +313,9 @@ public final class WebBeansXMLConfigurat
NodeList ns = webBeansRoot.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
/* <Interceptors> element decleration */
if (XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_INTERCEPTORS_ELEMENT))
@@ -334,10 +334,10 @@ public final class WebBeansXMLConfigurat
}
}
-
+
/**
* Configures the webbeans defined in the xml file.
- *
+ *
* @param listOfWebBeanDecleration list of element that specifies new
* webbean decleration
*/
@@ -365,7 +365,7 @@ public final class WebBeansXMLConfigurat
/**
* Configure and add new binding type annotation.
- *
+ *
* @param bindingTypeElement new binding type element
*/
private void addNewBindingType(Element bindingTypeElement)
@@ -396,7 +396,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures and adds new interceptor binding type annotation.
- *
+ *
* @param interceptorBindingTypeElement new interceptor binding type element
*/
private void addNewInterceptorBindingType(Element interceptorBindingTypeElement)
@@ -426,9 +426,9 @@ public final class WebBeansXMLConfigurat
NodeList ns = interceptorBindingTypeElement.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
Class<?> clz = XMLUtil.getElementJavaType(child);
if (clz == null)
{
@@ -448,7 +448,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures and adds new stereotype annotation.
- *
+ *
* @param stereoTypeElement new stereotype annotation element
*/
private void addNewStereoTypeType(Element stereoTypeElement)
@@ -480,21 +480,21 @@ public final class WebBeansXMLConfigurat
/**
* Configures enablements of the interceptors.
- *
+ *
* @param interceptorsElement interceptors element
*/
private void configureInterceptorsElement(Element interceptorsElement)
{
- InterceptorsManager manager = InterceptorsManager.getInstance();
+ InterceptorsManager manager = InterceptorsManager.getInstance();
Node node; Element child;
NodeList ns = interceptorsElement.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
Class<?> clazz = null;
-
+
if(this.owbSpecificConfiguration)
{
clazz = XMLUtil.getElementJavaType(child);
@@ -506,22 +506,22 @@ public final class WebBeansXMLConfigurat
if (clazz == null)
{
- throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Interceptor class : " +
- (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " not found");
+ throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Interceptor class : " +
+ (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " not found");
}
else
{
- if (AnnotationUtil.hasAnnotation(clazz.getDeclaredAnnotations(), Interceptor.class) &&
+ if (AnnotationUtil.hasAnnotation(clazz.getDeclaredAnnotations(), Interceptor.class) &&
!AnnotationUtil.hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
{
- throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Interceptor class : " +
- (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " must have at least one @InterceptorBindingType");
+ throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Interceptor class : " +
+ (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " must have at least one @InterceptorBindingType");
}
if (manager.isInterceptorEnabled(clazz))
{
throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Interceptor class : " +
- (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " is already defined");
+ (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " is already defined");
}
manager.addNewInterceptor(clazz);
@@ -533,7 +533,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures enablements of the decorators.
- *
+ *
* @param decoratorsElement decorators element
*/
private void configureDecoratorsElement(Element decoratorsElement)
@@ -543,11 +543,11 @@ public final class WebBeansXMLConfigurat
NodeList ns = decoratorsElement.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
Class<?> clazz = null;
-
+
if(this.owbSpecificConfiguration)
{
clazz = XMLUtil.getElementJavaType(child);
@@ -559,8 +559,8 @@ public final class WebBeansXMLConfigurat
if (clazz == null)
{
- throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Decorator class : " +
- (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " not found");
+ throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Decorator class : " +
+ (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " not found");
}
else
{
@@ -568,7 +568,7 @@ public final class WebBeansXMLConfigurat
if (manager.isDecoratorEnabled(clazz))
{
throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Decorator class : " +
- (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " is already defined");
+ (this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextContent().trim()) + " is already defined");
}
manager.addNewDecorator(clazz);
@@ -577,10 +577,10 @@ public final class WebBeansXMLConfigurat
}
}
-
+
/**
* Configures enablements of the decorators.
- *
+ *
* @param decoratorsElement decorators element
*/
private void configureAlternativesElement(Element alternativesElement)
@@ -589,9 +589,9 @@ public final class WebBeansXMLConfigurat
NodeList ns = alternativesElement.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
if(XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_STEREOTYPE) ||
XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_OWB_SPECIFIC_STEREOTYPE))
@@ -609,14 +609,14 @@ public final class WebBeansXMLConfigurat
{
logger.warn(OWBLogConst.WARN_0002, XMLUtil.getName(child));
}
- }
+ }
}
}
-
+
private void addAlternative(Element child, boolean isStereoType)
{
Class<?> clazz = null;
-
+
if(this.owbSpecificConfiguration)
{
clazz = XMLUtil.getElementJavaType(child);
@@ -641,12 +641,12 @@ public final class WebBeansXMLConfigurat
{
manager.addClazzAlternative(clazz);
}
- }
+ }
}
-
+
/**
* Configures new webbeans component from the given webbeans element.
- *
+ *
* @param webBeanElement web beans element
*/
private void configureNewWebBeanComponent(Element webBeanElement)
@@ -689,7 +689,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the simple webbean from the class.
- *
+ *
* @param simpleClass concrete java class defined in XML
* @param webBeanDecleration webbeans decleration root element
*/
@@ -732,7 +732,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the childs element of the given webbeans decleration element.
- *
+ *
* @param component xml webbeans element
* @param webBeanDecleration webbeans element
*/
@@ -752,16 +752,16 @@ public final class WebBeansXMLConfigurat
boolean isConstructor = false;
String fieldOrMethodName = null;
-
+
Node node; Element child;
NodeList ns = webBeanDecleration.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
-
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
+
Class<?> type = XMLUtil.getElementJavaType(child);
boolean isElementApplicable = false;
@@ -865,7 +865,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the type level meta data of the webbeans component.
- *
+ *
* @param component xml webbeans component
* @param annotationSet type level annotation set
* @param webBeanDecleration webbeans decleration element
@@ -923,7 +923,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the type level meta data of the webbeans component.
- *
+ *
* @param component xml webbeans component
* @param annotationSet type level annotation set
* @param webBeanDecleration webbeans decleration element
@@ -946,7 +946,7 @@ public final class WebBeansXMLConfigurat
* Configures the component constructor. When resolution dependency of the
* constructor injection points, constructor parameter type defined in the
* xml is used.
- *
+ *
* @param component xml webbeans component
* @param typeList list of the constructor parameter types
* @param constructorParameterListElement parameter list element
@@ -1018,17 +1018,17 @@ public final class WebBeansXMLConfigurat
{
XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(element, createConfigurationFailedMessage());
injectableConstructor.addInjectionPointModel(model);
-
- Annotation[] paramAnnos = constructor.getParameterAnnotations()[i++];
-
+
+ Annotation[] paramAnnos = constructor.getParameterAnnotations()[i++];
+
for(Annotation paramAnno : paramAnnos)
{
model.addAnnotation(paramAnno);
}
-
+
model.setInjectionMember(constructor);
model.setType(XMLInjectionModelType.CONSTRUCTOR);
-
+
component.addInjectionPoint(InjectionPointFactory.getXMLInjectionPointData(component, model));
}
@@ -1038,7 +1038,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the field or method of the xml webbeans component. Checks for
* the field or method definition and call corresponding method.
- *
+ *
* @param component xml webbeans component
* @param child field or method child element
*/
@@ -1057,18 +1057,18 @@ public final class WebBeansXMLConfigurat
private boolean hasTextOnlyChild(Element element)
{
- NodeList ns = element.getChildNodes();
- for(int i=0; i<ns.getLength(); i++)
- {
- if (ns.item(i) instanceof Text) continue;
- return false;
- }
- return true;
+ NodeList ns = element.getChildNodes();
+ for(int i=0; i<ns.getLength(); i++)
+ {
+ if (ns.item(i) instanceof Text) continue;
+ return false;
+ }
+ return true;
}
-
+
/**
* Configures the given child element as field of the webbeans component.
- *
+ *
* @param component xml webbeans component
* @param child field element
* @throws NonexistentFieldException if field not exist
@@ -1110,10 +1110,10 @@ public final class WebBeansXMLConfigurat
NodeList directChilds = child.getChildNodes();
for(int i=0; i<directChilds.getLength(); i++)
{
- node = directChilds.item(i);
- if (!(node instanceof Element)) continue;
- directChild = (Element)node;
- childElementNumber++;
+ node = directChilds.item(i);
+ if (!(node instanceof Element)) continue;
+ directChild = (Element)node;
+ childElementNumber++;
if (XMLUtil.isElementInWebBeansNameSpaceWithName(directChild, WebBeansConstants.WEB_BEANS_XML_VALUE_ELEMENT))
{
if (!isValueElement)
@@ -1134,13 +1134,13 @@ public final class WebBeansXMLConfigurat
{
XMLInjectionPointModel injectionPointModel = XMLUtil.getInjectionPointModel(directChild, createConfigurationFailedMessage());
component.addFieldInjectionPoint(field, injectionPointModel);
-
+
Annotation[] annots = field.getAnnotations();
for(Annotation annotation : annots)
{
injectionPointModel.addAnnotation(annotation);
}
-
+
injectionPointModel.setInjectionMember(field);
injectionPointModel.setType(XMLInjectionModelType.FIELD);
component.addInjectionPoint(InjectionPointFactory.getXMLInjectionPointData(component, injectionPointModel));
@@ -1173,14 +1173,14 @@ public final class WebBeansXMLConfigurat
// configure field values if available.
if (directChild != null)
- configureFieldValues(component, field, directChild, isValueElement);
- else
- configureFieldValues(component, field, child, isValueElement);
+ configureFieldValues(component, field, directChild, isValueElement);
+ else
+ configureFieldValues(component, field, child, isValueElement);
}
/**
* Configures the method of the webbeans component.
- *
+ *
* @param component xml webbeans component
* @param child method element
* @throws NonexistentMethodException if method with name does not exist
@@ -1215,9 +1215,9 @@ public final class WebBeansXMLConfigurat
NodeList mns = child.getChildNodes();
for(int j=0; j<mns.getLength(); j++)
{
- node = mns.item(j);
- if (!(node instanceof Element)) continue;
- methodChild = (Element)node;
+ node = mns.item(j);
+ if (!(node instanceof Element)) continue;
+ methodChild = (Element)node;
Class<?> childClazz = XMLUtil.getElementJavaType(methodChild);
final String moreThanOneChildTypeErrorMesg = createConfigurationFailedMessage() + XMLUtil.getName(methodChild) + "method declaration can not contain more than one <Initializer>, <Destructor>, <Produces>, <Disposes> or <Observes> element";
@@ -1311,7 +1311,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the webbeans component methods that are defines in the xml.
- *
+ *
* @param component xml webbeans component
* @param annotatedMethod annotated method to configure
* @param annotChild element child
@@ -1321,32 +1321,32 @@ public final class WebBeansXMLConfigurat
{
switch (type)
{
- case 0:
+ case 0:
- configureMethodInitializeAnnotation(component, annotatedMethod, methodParameterElements);
- break;
+ configureMethodInitializeAnnotation(component, annotatedMethod, methodParameterElements);
+ break;
- case 1:
- configureMethodProducesAnnotation(component, annotatedMethod, annotChild);
- break;
-
- case 2:
- configureMethodDisposesAnnotation(component, annotatedMethod, annotChild);
- break;
-
- case 3:
- configureMethodObservesAnnotation(component, annotatedMethod, annotChild);
- break;
-
- case 5:
- configureMethodInterceptorBindingTypeAnnotation(component, annotatedMethod, annotChild);
- break;
+ case 1:
+ configureMethodProducesAnnotation(component, annotatedMethod, annotChild);
+ break;
+
+ case 2:
+ configureMethodDisposesAnnotation(component, annotatedMethod, annotChild);
+ break;
+
+ case 3:
+ configureMethodObservesAnnotation(component, annotatedMethod, annotChild);
+ break;
+
+ case 5:
+ configureMethodInterceptorBindingTypeAnnotation(component, annotatedMethod, annotChild);
+ break;
}
}
/**
* Configures the initializor method of the webbeans component.
- *
+ *
* @param component xml webbeans component
* @param initializeMethod initialize method of the webbeans component
* @param annotChild element child
@@ -1363,7 +1363,7 @@ public final class WebBeansXMLConfigurat
{
XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(element, createConfigurationFailedMessage());
component.addMethodInjectionPoint(initializeMethod, model);
-
+
component.addInjectionPoint(XMLDefinitionUtil.getXMLMethodInjectionPoint(component, model, initializeMethod));
}
}
@@ -1393,7 +1393,7 @@ public final class WebBeansXMLConfigurat
/**
* Check method conditions for the webbeans component.
- *
+ *
* @param component xml webbeans component
* @param child method element
* @param methodParameters method parameter types
@@ -1422,7 +1422,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the disposal method of the webbeans component.
- *
+ *
* @param component xml webbeans component
* @param disposes disposes element
* @throws DefinitionException if disposes element can not contain exactly
@@ -1439,10 +1439,10 @@ public final class WebBeansXMLConfigurat
}
-
+
/**
* Configures the observer method of the webbeans component
- *
+ *
* @param component xml webbeans component
* @param observes observes element
* @throws DefinitionException if disposes element can not contain exactly
@@ -1453,11 +1453,11 @@ public final class WebBeansXMLConfigurat
*/
private <T> void checkConfigureObserves(AbstractOwbBean<T> component, Element observes)
{
- int childElementCount = 0;
+ int childElementCount = 0;
NodeList observesChilds = observes.getChildNodes();
for(int i=0; i<observesChilds.getLength(); i++)
{
- if (observesChilds.item(i) instanceof Element) childElementCount++;
+ if (observesChilds.item(i) instanceof Element) childElementCount++;
}
if (childElementCount != 1)
{
@@ -1478,7 +1478,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the webbeans scope type.
- *
+ *
* @param component xml defined web beans component
* @param annotationSet all annotation defined in XML
*/
@@ -1488,11 +1488,11 @@ public final class WebBeansXMLConfigurat
if(scopeType == null)
{
- scopeType = XMLDefinitionUtil.defineXMLTypeMetaData(component, annotationSet, Scope.class, createConfigurationFailedMessage() + "@Scope/@NormalScope annotation is not configured correctly");
+ scopeType = XMLDefinitionUtil.defineXMLTypeMetaData(component, annotationSet, Scope.class, createConfigurationFailedMessage() + "@Scope/@NormalScope annotation is not configured correctly");
}
-
+
if (scopeType == null)
- {
+ {
// From stereotype
DefinitionUtil.defineDefaultScopeType(component, createConfigurationFailedMessage() + "@Scope annotation is not configured correctly");
}
@@ -1505,7 +1505,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the binding types of the web beans component.
- *
+ *
* @param component web beans xml component
* @param anns annotations defined in the xml documents
*/
@@ -1522,7 +1522,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the class level interceptor binding types.
- *
+ *
* @param component web beans xml component
* @param anns annotations defined in the xml documents
*/
@@ -1533,7 +1533,7 @@ public final class WebBeansXMLConfigurat
/**
* Defines the component stereotypes.
- *
+ *
* @param component webbeans component
* @param annotationSet type-level metadata annotation set
*/
@@ -1544,7 +1544,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the webbeans name.
- *
+ *
* @param component webbeans component
* @param annotationSet type-level metadata annotation set
* @param webBeanDecleration webbeans decleration element
@@ -1574,7 +1574,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the webbeans specializations.
- *
+ *
* @param component webbeans component
* @param annotationSet type-level metadata annotation set
*/
@@ -1585,7 +1585,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the interceptors simple webbeans.
- *
+ *
* @param component webbeans component
* @param annotationSet type-level metadata annotation set
*/
@@ -1597,7 +1597,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the decorators simple webbeans.
- *
+ *
* @param component webbeans component
* @param annotationSet type-level metadata annotation set
*/
@@ -1608,7 +1608,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the enterprise web bean from ejb class.
- *
+ *
* @param ejbClass ejb class
*/
private void configureEJBWebBean(Class<?> ejbClass)
@@ -1618,13 +1618,13 @@ public final class WebBeansXMLConfigurat
/**
* Configures JMS endpoint.
- *
+ *
* @param webBeanElement element
*/
private void configureJMSEndpointComponent(Element webBeanElement)
{
Element resource = (Element)webBeanElement.getElementsByTagName(WebBeansConstants.WEB_BEANS_XML_JMS_RESOURCE).item(0);
-
+
if(resource == null)
{
throw new WebBeansConfigurationException("Topic or Queue resource mut be defined in the XML");
@@ -1632,33 +1632,33 @@ public final class WebBeansXMLConfigurat
Element name = (Element)resource.getElementsByTagName(WebBeansConstants.WEB_BEANS_XML_JMS_RESOURCE_NAME).item(0);
Element mappedName = (Element)resource.getElementsByTagName(WebBeansConstants.WEB_BEANS_XML_JMS_RESOURCE_MAPPED_NAME).item(0);
-
+
if(name== null && mappedName == null)
{
throw new WebBeansConfigurationException("Topic or Queue must define name or mapped name for the JNDI");
}
-
+
List<Annotation> bindingTypes = new ArrayList<Annotation>();
Node node; Element child;
NodeList ns = webBeanElement.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
if(child.getLocalName() != WebBeansConstants.WEB_BEANS_XML_JMS_RESOURCE)
{
Class<? extends Annotation> binding = (Class<Annotation>)XMLUtil.getElementJavaType(child);
-
+
if(AnnotationUtil.isQualifierAnnotation(binding))
{
- bindingTypes.add(JavassistProxyFactory.createNewAnnotationProxy(binding));
- }
- }
+ bindingTypes.add(JavassistProxyFactory.createNewAnnotationProxy(binding));
+ }
+ }
}
-
+
JMSType type = null;
-
+
if(webBeanElement.getLocalName().equals(WebBeansConstants.WEB_BEANS_XML_TOPIC_ELEMENT))
{
type = JMSType.TOPIC;
@@ -1667,20 +1667,20 @@ public final class WebBeansXMLConfigurat
{
type = JMSType.QUEUE;
}
-
-
+
+
String jndiName = name == null ? null : name.getTextContent().trim();
String mapName = mappedName== null ? null : mappedName.getTextContent().trim();
-
-
- JMSModel model = new JMSModel(type,jndiName,mapName);
+
+
+ JMSModel model = new JMSModel(type,jndiName,mapName);
JMSManager.getInstance().addJmsModel(model);
-
+
for(Annotation ann : bindingTypes)
{
model.addBinding(ann);
}
-
+
//Adding JMS Beans
OpenWebBeansJmsPlugin plugin = PluginLoader.getInstance().getJmsPlugin();
BeanManagerImpl.getManager().addBean(plugin.getJmsBean(model));
@@ -1688,7 +1688,7 @@ public final class WebBeansXMLConfigurat
/**
* Cofigures the initial value of the given field.
- *
+ *
* @param component webbeans component
* @param field field of the webbean
* @param child child element that declares field
@@ -1712,9 +1712,9 @@ public final class WebBeansXMLConfigurat
{
throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Field type with field name : " + field.getName() + " is not compatible for initial value assignment");
}
-
+
/*Primitive type*/
- if (ClassUtil.isPrimitive(fieldType) || ClassUtil.isPrimitiveWrapper(fieldType))
+ if (ClassUtil.isPrimitive(fieldType) || ClassUtil.isPrimitiveWrapper(fieldType))
{
Object objVal = null;
@@ -1748,12 +1748,12 @@ public final class WebBeansXMLConfigurat
component.addFieldValue(field, value);
}
-
+
/*
- * Date, Time, Sql Date,
- * Time stamp, Calendar
- * value
- */
+ * Date, Time, Sql Date,
+ * Time stamp, Calendar
+ * value
+ */
else if (fieldType.equals(Date.class)
|| fieldType.equals(java.sql.Date.class) || fieldType.equals(Time.class) || fieldType.equals(Timestamp.class))
{
@@ -1787,8 +1787,8 @@ public final class WebBeansXMLConfigurat
* BigDecimal
* or
* BigInteger
- */
- else if (fieldType.equals(BigDecimal.class) || fieldType.equals(BigInteger.class))
+ */
+ else if (fieldType.equals(BigDecimal.class) || fieldType.equals(BigInteger.class))
{
Object bigValue = ClassUtil.isValueOkForBigDecimalOrInteger(fieldType, value);
@@ -1816,17 +1816,17 @@ public final class WebBeansXMLConfigurat
component.addFieldValue(field, clazz);
}
}
-
+
/*
- * List value
- */
- else if (List.class.isAssignableFrom(fieldType))
+ * List value
+ */
+ else if (List.class.isAssignableFrom(fieldType))
{
configureFieldListValue(component, field, child, errorMessage);
}
-
+
/* Set value */
- else if (Set.class.isAssignableFrom(fieldType))
+ else if (Set.class.isAssignableFrom(fieldType))
{
configureFieldSetValue(component, field, child, errorMessage);
}
@@ -1841,7 +1841,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the xml field with {@link List} type.
- *
+ *
* @param component xml component
* @param field list field
* @param child list field xml element
@@ -1859,8 +1859,8 @@ public final class WebBeansXMLConfigurat
/*
* Type must be parametrized type
* to mark type
- */
- if (type instanceof ParameterizedType)
+ */
+ if (type instanceof ParameterizedType)
{
ParameterizedType pt = (ParameterizedType) type;
Type arg = pt.getActualTypeArguments()[0];
@@ -1899,10 +1899,10 @@ public final class WebBeansXMLConfigurat
Node valueNode;Text valueElement;
NodeList valueElements = child.getChildNodes();
for(int i=0; i<valueElements.getLength(); i++)
- {
- valueNode = valueElements.item(i);
- if (!(valueNode instanceof Text)) continue;
- valueElement = (Text)valueNode;
+ {
+ valueNode = valueElements.item(i);
+ if (!(valueNode instanceof Text)) continue;
+ valueElement = (Text)valueNode;
String value = valueElement.getTextContent().trim();
if (isString)
{
@@ -1940,7 +1940,7 @@ public final class WebBeansXMLConfigurat
/**
* Configures the xml field with {@link Set} type.
- *
+ *
* @param component xml component
* @param field list field
* @param child list field xml element
@@ -1958,7 +1958,7 @@ public final class WebBeansXMLConfigurat
/*
* Type must be parametrized type
* to mark type
- */
+ */
if (type instanceof ParameterizedType)
{
ParameterizedType pt = (ParameterizedType) type;
@@ -1998,10 +1998,10 @@ public final class WebBeansXMLConfigurat
Node valueNode;Element valueElement;
NodeList valueElements = child.getChildNodes();
for(int i=0; i<valueElements.getLength(); i++)
- {
- valueNode = valueElements.item(i);
- if (!(valueNode instanceof Element)) continue;
- valueElement = (Element)valueNode;
+ {
+ valueNode = valueElements.item(i);
+ if (!(valueNode instanceof Element)) continue;
+ valueElement = (Element)valueNode;
String value = valueElement.getTextContent().trim();
if (isString)
{
@@ -2039,7 +2039,7 @@ public final class WebBeansXMLConfigurat
/**
* Gets error message for XML parsing of the current XML file.
- *
+ *
* @return the error messages
*/
private String createConfigurationFailedMessage()
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java?rev=952591&r1=952590&r2=952591&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java Tue Jun 8 09:45:27 2010
@@ -81,7 +81,7 @@ public final class XMLDefinitionUtil
/**
* Checks the conditions for simple webbeans class defined in the XML file.
- *
+ *
* @param clazz simple webbeans class declared in XML
* @throws WebBeansConfigurationException if check is fail
*/
@@ -133,14 +133,14 @@ public final class XMLDefinitionUtil
while (it.hasNext())
{
Class<? extends Annotation> clazz = it.next();
- if (clazz.isAnnotationPresent(NormalScope.class)
- || clazz.isAnnotationPresent(Scope.class)
- || AnnotationUtil.isQualifierAnnotation(clazz)
- || AnnotationUtil.isInterceptorBindingAnnotation(clazz)
- || AnnotationUtil.isStereoTypeAnnotation(clazz)
- || clazz.equals(Named.class)
- || clazz.equals(Specializes.class) || clazz.equals(javax.interceptor.Interceptor.class)
- || clazz.equals(Decorator.class))
+ if (clazz.isAnnotationPresent(NormalScope.class)
+ || clazz.isAnnotationPresent(Scope.class)
+ || AnnotationUtil.isQualifierAnnotation(clazz)
+ || AnnotationUtil.isInterceptorBindingAnnotation(clazz)
+ || AnnotationUtil.isStereoTypeAnnotation(clazz)
+ || clazz.equals(Named.class)
+ || clazz.equals(Specializes.class) || clazz.equals(javax.interceptor.Interceptor.class)
+ || clazz.equals(Decorator.class))
{
continue;
}
@@ -156,7 +156,7 @@ public final class XMLDefinitionUtil
/**
* Gets applicable annotation class for given defineType parameter from the
* given annotation set.
- *
+ *
* @param component webbeans component
* @param annotationSet type-level metadata annotation set
* @param defineType annotation type class
@@ -278,11 +278,11 @@ public final class XMLDefinitionUtil
NodeList ns = interceptorMethodElement.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- bindingType = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ bindingType = (Element)node;
- Class<? extends Annotation> annot = (Class<? extends Annotation>) XMLUtil.getElementJavaType(bindingType);
+ Class<? extends Annotation> annot = (Class<? extends Annotation>) XMLUtil.getElementJavaType(bindingType);
Annotation bindingAnnot = XMLUtil.getXMLDefinedAnnotationMember(bindingType, annot, errorMessage);
bindingTypesSet.add(bindingAnnot);
@@ -308,7 +308,7 @@ public final class XMLDefinitionUtil
/**
* Configures the webbeans component stereotype.
- *
+ *
* @param component webbeans component
* @param annotationSet set of type-level metadata annotation set
*/
@@ -423,9 +423,9 @@ public final class XMLDefinitionUtil
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- child = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ child = (Element)node;
if (XMLUtil.getElementNameSpace(child).equals(XMLUtil.getElementNameSpace(decoratorDecleration)) && XMLUtil.isElementHasDecoratesChild(child))
{
Field field = ClassUtil.getFieldWithName(component.getReturnType(), child.getLocalName());
@@ -458,7 +458,7 @@ public final class XMLDefinitionUtil
/**
* Returns newly created and configures xml webbeans producer component.
- *
+ *
* @param component webbeans component that defines producer method
* @param producesMethod producer method
* @param producerMethodElement produce method xml element
@@ -480,9 +480,9 @@ public final class XMLDefinitionUtil
NodeList ns = producerMethodElement.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- childElement = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ childElement = (Element)node;
if (XMLUtil.isElementInWebBeansNameSpaceWithName(childElement, WebBeansConstants.WEB_BEANS_XML_PRODUCES_ELEMENT))
{
if (producesDefined == false)
@@ -500,10 +500,10 @@ public final class XMLDefinitionUtil
NodeList nsProducer = childElement.getChildNodes();
for(int j=0; j<nsProducer.getLength(); j++)
{
- producerNode = nsProducer.item(j);
- if (!(producerNode instanceof Element)) continue;
- producesElementChild= (Element)producerNode;
- if (producesElementChild.getLocalName().equals(WebBeansConstants.WEB_BEANS_XML_ARRAY_ELEMENT))
+ producerNode = nsProducer.item(j);
+ if (!(producerNode instanceof Element)) continue;
+ producesElementChild= (Element)producerNode;
+ if (producesElementChild.getLocalName().equals(WebBeansConstants.WEB_BEANS_XML_ARRAY_ELEMENT))
{
arrayElement = producesElementChild;
definedType = true;
@@ -564,7 +564,7 @@ public final class XMLDefinitionUtil
/**
* Configures and returns the newly created producer method webbeans
* component.
- *
+ *
* @param parentComponent producer method webbeans parent component
* @param producesMethod producer method
* @param injectedParameters injected parameters of the producer method
@@ -612,7 +612,7 @@ public final class XMLDefinitionUtil
/* Configures producer method injected parameters */
for (XMLInjectionPointModel injectionPointModel : injectedParameters)
{
- producerComponentImpl.addProducerMethodInjectionPointModel(injectionPointModel);
+ producerComponentImpl.addProducerMethodInjectionPointModel(injectionPointModel);
producerComponentImpl.addInjectionPoint(getXMLMethodInjectionPoint(producerComponentImpl, injectionPointModel, producesMethod));
}
@@ -622,7 +622,7 @@ public final class XMLDefinitionUtil
/**
* Configures xml defined producer method webbeans type level metadatas.
- *
+ *
* @param producerComponentImpl xml webbeans producer component
* @param producesMethod producer method
* @param producerMethodElement producer method xml element
@@ -652,7 +652,7 @@ public final class XMLDefinitionUtil
/**
* Configures the disposal method of the webbeans component using the xml
* configuration.
- *
+ *
* @param component producer method webbeans component
* @param disposalMethod disposal method defined in the xml
* @param disposalMethodElement disposal method xml element
@@ -678,9 +678,9 @@ public final class XMLDefinitionUtil
NodeList ns = disposalMethodElement.getChildNodes();
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- childElement = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ childElement = (Element)node;
if (XMLUtil.isElementInWebBeansNameSpaceWithName(childElement, WebBeansConstants.WEB_BEANS_XML_DISPOSES_ELEMENT))
{
if (disposalDefined == false)
@@ -697,7 +697,7 @@ public final class XMLDefinitionUtil
/* Find disposal method model */
XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(typeElement, errorMessage);
-
+
component.addInjectionPoint(getXMLMethodInjectionPoint(component, model, disposalMethod));
/* Binding types for disposal method */
@@ -741,7 +741,7 @@ public final class XMLDefinitionUtil
/* Other parameter elements other than @Observes */
List<Element> otherParameterElements = new ArrayList<Element>();
-
+
BeanObserverXMLImpl<K> beanObserver = null;
Class<K> eventType = null;
@@ -752,19 +752,19 @@ public final class XMLDefinitionUtil
for(int i=0; i<ns.getLength(); i++)
{
- node = ns.item(i);
- if (!(node instanceof Element)) continue;
- childElement = (Element)node;
+ node = ns.item(i);
+ if (!(node instanceof Element)) continue;
+ childElement = (Element)node;
if (XMLUtil.isElementInWebBeansNameSpaceWithName(childElement, WebBeansConstants.WEB_BEANS_XML_OBSERVES_ELEMENT))
{
- //TODO: verify the first node is Element.
+ //TODO: verify the first node is Element.
Element typeElement = (Element) childElement.getChildNodes().item(0);
eventType = (Class<K>) XMLUtil.getElementJavaType(typeElement);
/* Find observes method model */
XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(typeElement, errorMessage);
-
+
component.addInjectionPoint(getXMLMethodInjectionPoint(component, model, observesMethod));
/* Binding types for disposal method */
@@ -772,8 +772,8 @@ public final class XMLDefinitionUtil
Annotation[] bindingAnns = new Annotation[bindingTypes.size()];
bindingAnns = bindingTypes.toArray(bindingAnns);
- beanObserver = new BeanObserverXMLImpl<K>(component, observesMethod, false,
- bindingAnns, null /** TODO Type! */);
+ beanObserver = new BeanObserverXMLImpl<K>(component, observesMethod, false,
+ bindingAnns, null /** TODO Type! */);
beanObserver.addXMLInjectionObservesParameter(model);
@@ -797,22 +797,22 @@ public final class XMLDefinitionUtil
}
}
}
-
+
public static InjectionPoint getXMLMethodInjectionPoint(AbstractOwbBean<?> component, XMLInjectionPointModel model, Method method)
{
Asserts.assertNotNull(model,"model parameter can not be null");
Asserts.assertNotNull(method,"method parameter can not be null");
-
+
Annotation[] annots = method.getAnnotations();
for(Annotation annotation : annots)
{
model.addAnnotation(annotation);
}
-
+
model.setInjectionMember(method);
model.setType(XMLInjectionModelType.METHOD);
-
+
return InjectionPointFactory.getXMLInjectionPointData(component, model);
-
+
}
}
\ No newline at end of file