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 2011/03/07 16:01:06 UTC
svn commit: r1078801 - in
/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml:
XMLAnnotationTypeManager.java XMLUtil.java
Author: struberg
Date: Mon Mar 7 15:01:05 2011
New Revision: 1078801
URL: http://svn.apache.org/viewvc?rev=1078801&view=rev
Log:
OWB-393 drop unused methods
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.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/xml/XMLAnnotationTypeManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java?rev=1078801&r1=1078800&r2=1078801&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java Mon Mar 7 15:01:05 2011
@@ -27,6 +27,10 @@ import java.util.concurrent.ConcurrentHa
import org.apache.webbeans.config.WebBeansContext;
+/**
+ * TODO This class actually has nothing to do with XML anymore!
+ * @deprecated The addInterceotorBindingTypeInheritAnnotation should get moved to the BeanManagerImpl or similar place.
+ */
public class XMLAnnotationTypeManager
{
private Map<Class<? extends Annotation>, Set<Annotation>> xmlInterceptorBindingTypes = new ConcurrentHashMap<Class<? extends Annotation>, Set<Annotation>>();
@@ -42,21 +46,6 @@ public class XMLAnnotationTypeManager
}
- public void addInterceotorBindingTypeInheritAnnotation(Class<? extends Annotation> bindingType, Annotation inherit)
- {
- Set<Annotation> inherits = xmlInterceptorBindingTypes.get(bindingType);
- if (inherits == null)
- {
- inherits = new HashSet<Annotation>();
- inherits.add(inherit);
- xmlInterceptorBindingTypes.put(bindingType, inherits);
- }
- else
- {
- inherits.add(inherit);
- }
- }
-
public void addInterceotorBindingTypeInheritAnnotation(Class<? extends Annotation> bindingType, Annotation... inheritsArray)
{
Set<Annotation> inherits = xmlInterceptorBindingTypes.get(bindingType);
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java?rev=1078801&r1=1078800&r2=1078801&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java Mon Mar 7 15:01:05 2011
@@ -19,26 +19,15 @@
package org.apache.webbeans.xml;
import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.webbeans.annotation.WebBeansAnnotation;
import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
import org.apache.webbeans.exception.WebBeansException;
import org.apache.webbeans.logger.WebBeansLogger;
-import org.apache.webbeans.proxy.JavassistProxyFactory;
import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.ClassUtil;
-import org.apache.webbeans.util.SecurityUtil;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Attr;
@SuppressWarnings("unchecked")
@@ -94,178 +83,6 @@ public class XMLUtil
{
Asserts.assertNotNull(element, "element argument can not be null");
}
- /**
- * Creates new annotation with configured members values.
- *
- * @param annotationElement annotation element
- * @param annotClazz annotation class
- * @param errorMessage error message
- * @return new annotation with members configures
- */
- public static Annotation getXMLDefinedAnnotationMember(Element annotationElement, Class<? extends Annotation> annotClazz, String errorMessage)
- {
- String value = annotationElement.getTextContent().trim();
- NamedNodeMap attrs = annotationElement.getAttributes();
- List<String> attrsNames = new ArrayList<String>();
-
- for (int i = 0; i < attrs.getLength(); i++)
- {
- Attr attr = (Attr) attrs.item(i);
- attrsNames.add(attr.getName());
- }
-
- /* Default value check */
- if (value != null && !value.equals(""))
- {
- if (attrsNames.contains("value"))
- {
- throw new WebBeansConfigurationException(
- errorMessage + "Annotation with type : " + annotClazz.getName() + " can not have both element 'value' attribute and body text");
- }
- }
- /* Check for attribute "value" */
- else
- {
- if (attrsNames.contains("value"))
- {
- try
- {
- /* Contains value member method */
- SecurityUtil.doPrivilegedGetDeclaredMethod(annotClazz, "value", new Class[]{});
-
- }
- catch (SecurityException e)
- {
- throw new WebBeansException(e);
-
- }
- catch (NoSuchMethodException e)
- {
- throw new WebBeansConfigurationException(errorMessage + "Annotation with type : " + annotClazz.getName() + " must have 'value' method");
- }
- }
- }
-
- /* Check annotation members with name attrs */
- for (String attrName : attrsNames)
- {
- try
- {
- SecurityUtil.doPrivilegedGetDeclaredMethod(annotClazz, attrName, new Class[]{});
- }
- catch (SecurityException e)
- {
- throw new WebBeansException(e);
-
- }
- catch (NoSuchMethodException e)
- {
- throw new WebBeansConfigurationException(errorMessage + "Annotation with type : " + annotClazz.getName() + " does not have member with name : " + attrName);
- }
- }
-
- /* Non-default members must defined in the xml */
- Method[] members = ClassUtil.getDeclaredMethods(annotClazz);
- for (Method member : members)
- {
- if (member.getDefaultValue() == null && value == null)
- {
- if (!attrsNames.contains(member.getName()))
- {
- throw new WebBeansConfigurationException(
- errorMessage + "Annotation with type : " + annotClazz.getName() + " with non-default member method with name : " + member.getName() +
- " has to defined in the xml element attribute.");
- }
- }
- }
-
- return createInjectionPointAnnotation(attrs, annotClazz, value, errorMessage);
- }
-
- /**
- * Creates new annotation with its member values.
- *
- * @param attrs list of annotation element attributes
- * @param annotClazz annotation class
- * @param errorMessage error message
- * @return new annotation
- */
- private static WebBeansAnnotation createInjectionPointAnnotation(NamedNodeMap attrs, Class<? extends Annotation> annotClazz, String valueText, String errorMessage)
- {
- WebBeansAnnotation annotation = JavassistProxyFactory.createNewAnnotationProxy(annotClazz);
- boolean isValueAttrDefined = false;
- for (int i = 0; i < attrs.getLength(); i++)
- {
- Attr attr = (Attr) attrs.item(i);
- String attrName = attr.getName();
- String attrValue = attr.getValue();
-
- if (!isValueAttrDefined)
- {
- if (attrName.equals("value"))
- {
- isValueAttrDefined = true;
- }
- }
-
- Class returnType = null;
- try
- {
- returnType = SecurityUtil.doPrivilegedGetDeclaredMethod(annotClazz, attrName, new Class[]{}).getReturnType();
- Object value = null;
- if (returnType.isPrimitive())
- {
- value = ClassUtil.isValueOkForPrimitiveOrWrapper(returnType, attrValue);
- }
- else if (returnType.equals(String.class))
- {
- value = attrValue;
- }
- else if (returnType.equals(Class.class))
- {
- value = ClassUtil.getClassFromName(attrValue);
-
- }
- else if (returnType.isEnum())
- {
- value = ClassUtil.isValueOkForEnum(returnType, attrValue);
- }
- else
- {
- throw new WebBeansConfigurationException(
- errorMessage + "Annotation with type : " + annotClazz.getName() + " with member : " + attrName + " does not have sutiable member return type");
- }
-
- if (value == null)
- {
- throw new WebBeansConfigurationException(
- errorMessage + "Annotation with type : " + annotClazz.getName() + " with member : " + attrName + " value does not defined correctly");
- }
-
- annotation.setMemberValue(attrName, value);
-
- }
- catch (SecurityException e)
- {
- throw new WebBeansException(e);
-
- }
- catch (NoSuchMethodException e)
- {
- throw new WebBeansConfigurationException(errorMessage + "Annotation with type : " + annotClazz.getName() + " does not have member with name : " + attrName);
- }
- }
-
- if (!isValueAttrDefined)
- {
- if (valueText != null && !valueText.equals(""))
- {
- annotation.setMemberValue("value", valueText);
- }
- }
-
- return annotation;
- }
}