Author: struberg
Date: Thu Feb 24 13:37:31 2011
New Revision: 1074142
URL: http://svn.apache.org/viewvc?rev=1074142&view=rev
Log:
OWB-393 drop just another bunch of useless stuff...
Removed:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/XMLStereoTypeModel.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.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/WebBeansContext.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.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/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/annotation/AnnotationManager.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java?rev=1074142&r1=1074141&r2=1074142&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
Thu Feb 24 13:37:31 2011
@@ -29,7 +29,6 @@ import org.apache.webbeans.util.ArrayUti
import org.apache.webbeans.util.Asserts;
import org.apache.webbeans.util.SecurityUtil;
import org.apache.webbeans.util.WebBeansUtil;
-import org.apache.webbeans.xml.XMLAnnotationTypeManager;
import javax.enterprise.context.NormalScope;
import javax.enterprise.inject.Default;
@@ -64,11 +63,6 @@ import java.util.Set;
*/
public final class AnnotationManager
{
- public static final Annotation[] EMPTY_ANNOTATION_ARRAY = new
Annotation[0];
-
- public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
-
- private final XMLAnnotationTypeManager manager;
private final BeanManagerImpl beanManagerImpl;
@@ -76,7 +70,6 @@ public final class AnnotationManager
public AnnotationManager(WebBeansContext context)
{
- manager = context.getxMLAnnotationTypeManager();
beanManagerImpl = context.getBeanManagerImpl();
}
@@ -92,11 +85,8 @@ public final class AnnotationManager
public boolean isInterceptorBindingAnnotation(Class<? extends Annotation>
clazz)
{
Asserts.nullCheckForClass(clazz);
- if (manager.hasInterceptorBindingType(clazz))
- {
- return true;
- }
- else if (clazz.isAnnotationPresent(InterceptorBinding.class))
+
+ if (clazz.isAnnotationPresent(InterceptorBinding.class))
{
return true;
}
@@ -181,11 +171,7 @@ public final class AnnotationManager
public boolean isQualifierAnnotation(Class<? extends Annotation> clazz)
{
Asserts.nullCheckForClass(clazz);
- if (manager.hasBindingType(clazz))
- {
- return true;
- }
- else if (clazz.isAnnotationPresent(Qualifier.class))
+ if (clazz.isAnnotationPresent(Qualifier.class))
{
return true;
}
@@ -410,11 +396,8 @@ public final class AnnotationManager
public boolean isStereoTypeAnnotation(Class<? extends Annotation> clazz)
{
Asserts.nullCheckForClass(clazz);
- if (manager.hasStereoType(clazz))
- {
- return true;
- }
- else if (clazz.isAnnotationPresent(Stereotype.class))
+
+ if (clazz.isAnnotationPresent(Stereotype.class))
{
return true;
}
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=1074142&r1=1074141&r2=1074142&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
Thu Feb 24 13:37:31 2011
@@ -640,9 +640,7 @@ public class BeansDeployer
webBeansContext.getWebBeansUtil().configureSpecializations(specialClassList);
}
- // XML Defined Specializations
- checkXMLSpecializations();
-
+
//configure specialized producer beans.
webBeansContext.getWebBeansUtil().configureProducerMethodSpecializations();
}
@@ -657,40 +655,6 @@ public class BeansDeployer
/**
- * Check xml specializations.
- * NOTE : Currently XML is not used in configuration.
- */
- protected void checkXMLSpecializations()
- {
- // Check XML specializations
- Set<Class<?>> clazzes =
webBeansContext.getxMLSpecializesManager().getXMLSpecializationClasses();
- Iterator<Class<?>> it = clazzes.iterator();
- Class<?> superClass = null;
- Class<?> specialClass = null;
- ArrayList<Class<?>> specialClassList = new ArrayList<Class<?>>();
- while (it.hasNext())
- {
- specialClass = it.next();
-
- if (superClass == null)
- {
- superClass = specialClass.getSuperclass();
- }
- else
- {
- if (superClass.equals(specialClass.getSuperclass()))
- {
- throw new
InconsistentSpecializationException(logger.getTokenString(OWBLogConst.EXCEPT_XML)
- +
logger.getTokenString(OWBLogConst.EXCEPT_0005)
- +
superClass.getName());
- }
- }
- specialClassList.add(specialClass);
- }
-
webBeansContext.getWebBeansUtil().configureSpecializations(specialClassList);
- }
-
- /**
* Check passivations.
*/
protected void checkPassivationScope(Bean<?> beanObj)
@@ -751,7 +715,7 @@ public class BeansDeployer
Class<? extends Annotation> stereoClass = (Class<? extends
Annotation>) beanClass;
if (annotationManager.isStereoTypeAnnotation(stereoClass))
{
- if
(!webBeansContext.getxMLAnnotationTypeManager().hasStereoType(stereoClass))
+ if
(!webBeansContext.getXMLAnnotationTypeManager().hasStereoType(stereoClass))
{
webBeansContext.getAnnotationManager().checkStereoTypeClass(stereoClass,
stereoClass.getDeclaredAnnotations());
StereoTypeModel model = new
StereoTypeModel(webBeansContext, stereoClass);
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1074142&r1=1074141&r2=1074142&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
Thu Feb 24 13:37:31 2011
@@ -51,9 +51,7 @@ import org.apache.webbeans.spi.ScannerSe
import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
import org.apache.webbeans.util.ClassUtil;
import org.apache.webbeans.util.WebBeansUtil;
-import org.apache.webbeans.xml.WebBeansNameSpaceContainer;
import org.apache.webbeans.xml.XMLAnnotationTypeManager;
-import org.apache.webbeans.xml.XMLSpecializesManager;
/**
* @version $Rev$ $Date$
@@ -79,8 +77,6 @@ public class WebBeansContext
private StereoTypeManager stereoTypeManager = new StereoTypeManager();
private XMLAnnotationTypeManager xmlAnnotationTypeManager = new
XMLAnnotationTypeManager(this);
private AnnotationManager annotationManager = new AnnotationManager(this);
- private WebBeansNameSpaceContainer webBeansNameSpaceContainer = new
WebBeansNameSpaceContainer();
- private XMLSpecializesManager xmlSpecializesManager = new
XMLSpecializesManager();
private ResolutionUtil resolutionUtil = new ResolutionUtil(this);
private InjectionPointFactory injectionPointFactory = new
InjectionPointFactory(this);
private InterceptorUtil interceptorUtil = new InterceptorUtil(this);
@@ -112,9 +108,6 @@ public class WebBeansContext
managerMap.put(PluginLoader.class, pluginLoader);
managerMap.put(SerializableBeanVault.class, serializableBeanVault);
managerMap.put(StereoTypeManager.class, stereoTypeManager);
- managerMap.put(WebBeansNameSpaceContainer.class,
webBeansNameSpaceContainer);
- managerMap.put(XMLAnnotationTypeManager.class,
xmlAnnotationTypeManager);
- managerMap.put(XMLSpecializesManager.class, xmlSpecializesManager);
}
@Deprecated
@@ -290,21 +283,11 @@ public class WebBeansContext
return javassistProxyFactory;
}
- public WebBeansNameSpaceContainer getWebBeansNameSpaceContainer()
- {
- return webBeansNameSpaceContainer;
- }
-
- public XMLAnnotationTypeManager getxMLAnnotationTypeManager()
+ public XMLAnnotationTypeManager getXMLAnnotationTypeManager()
{
return xmlAnnotationTypeManager;
}
- public XMLSpecializesManager getxMLSpecializesManager()
- {
- return xmlSpecializesManager;
- }
-
//candidates for fields
public ScannerService getScannerService()
{
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=1074142&r1=1074141&r2=1074142&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
Thu Feb 24 13:37:31 2011
@@ -195,9 +195,9 @@ public class WebBeansInterceptor<T> exte
Set<Annotation> declared = null;
Annotation[] anns = null;
- if
(webBeansContext.getxMLAnnotationTypeManager().hasInterceptorBindingType(clazzAnnot))
+ if
(webBeansContext.getXMLAnnotationTypeManager().hasInterceptorBindingType(clazzAnnot))
{
- declared =
webBeansContext.getxMLAnnotationTypeManager().getInterceptorBindingTypeInherites(clazzAnnot);
+ declared =
webBeansContext.getXMLAnnotationTypeManager().getInterceptorBindingTypeInherites(clazzAnnot);
anns = new Annotation[declared.size()];
anns = declared.toArray(anns);
}
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java?rev=1074142&r1=1074141&r2=1074142&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
Thu Feb 24 13:37:31 2011
@@ -71,7 +71,7 @@ public class BeforeBeanDiscoveryImpl imp
@Override
public void addInterceptorBinding(Class<? extends Annotation> binding,
Annotation... bindingDef)
{
-
webBeansContext.getxMLAnnotationTypeManager().addInterceotorBindingTypeInheritAnnotation(binding,
bindingDef);
+
webBeansContext.getXMLAnnotationTypeManager().addInterceotorBindingTypeInheritAnnotation(binding,
bindingDef);
}
/**
@@ -90,7 +90,7 @@ public class BeforeBeanDiscoveryImpl imp
@Override
public void addStereotype(Class<? extends Annotation> stereotype,
Annotation... stereotypeDef)
{
- if
(!webBeansContext.getxMLAnnotationTypeManager().hasStereoType(stereotype))
+ if
(!webBeansContext.getXMLAnnotationTypeManager().hasStereoType(stereotype))
{
webBeansContext.getAnnotationManager().checkStereoTypeClass(stereotype,
stereotypeDef);
StereoTypeModel model = new StereoTypeModel(webBeansContext,
stereotype, stereotypeDef);
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=1074142&r1=1074141&r2=1074142&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
Thu Feb 24 13:37:31 2011
@@ -53,11 +53,6 @@ public final class WebBeansXMLConfigurat
private String CURRENT_SCAN_FILE_NAME = null;
/**
- * Annotation type manager that manages the XML defined annotations
- */
- private XMLAnnotationTypeManager xmlAnnotTypeManager =
WebBeansContext.getInstance().getxMLAnnotationTypeManager();
-
- /**
* Creates a new instance of the <code>WebBeansXMLConfigurator</code>
*/
public WebBeansXMLConfigurator()
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=1074142&r1=1074141&r2=1074142&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
Thu Feb 24 13:37:31 2011
@@ -28,8 +28,6 @@ import java.util.concurrent.CopyOnWriteA
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.deployment.StereoTypeManager;
-import org.apache.webbeans.deployment.XMLStereoTypeModel;
-import org.w3c.dom.Element;
public class XMLAnnotationTypeManager
{
@@ -52,7 +50,7 @@ public class XMLAnnotationTypeManager
public static XMLAnnotationTypeManager getInstance()
{
- return WebBeansContext.getInstance().getxMLAnnotationTypeManager();
+ return WebBeansContext.getInstance().getXMLAnnotationTypeManager();
}
@Deprecated
@@ -86,6 +84,7 @@ public class XMLAnnotationTypeManager
return false;
}
+ /*X TODO REMOVE
public void addStereoType(Class<? extends Annotation> stereoType, Element
decleration, String name, String errorMessage)
{
webBeansContext.getAnnotationManager().checkStereoTypeClass(stereoType,
stereoType.getDeclaredAnnotations());
@@ -95,6 +94,7 @@ public class XMLAnnotationTypeManager
xmlStereoTypes.add(stereoType);
}
+ */
public boolean hasStereoType(Class<? extends Annotation> stereoType)
{
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=1074142&r1=1074141&r2=1074142&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
Thu Feb 24 13:37:31 2011
@@ -26,26 +26,19 @@ import java.util.List;
import org.apache.webbeans.annotation.WebBeansAnnotation;
import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.exception.WebBeansConfigurationException;
import org.apache.webbeans.exception.WebBeansException;
-import org.apache.webbeans.exception.inject.DefinitionException;
import org.apache.webbeans.logger.WebBeansLogger;
import org.apache.webbeans.proxy.JavassistProxyFactory;
-import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.Asserts;
import org.apache.webbeans.util.ClassUtil;
import org.apache.webbeans.util.SecurityUtil;
-import org.apache.webbeans.util.WebBeansConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Attr;
-import org.w3c.dom.NodeList;
@SuppressWarnings("unchecked")
@@ -58,93 +51,6 @@ public class XMLUtil
private static WebBeansLogger log =
WebBeansLogger.getLogger(XMLUtil.class);
- protected static boolean verifyNameSpace(Element element)
- {
- boolean ret;
- if (element.getNamespaceURI() == null)
- {
- return false;
- }
- Node node;
- NodeList ns = element.getChildNodes();
- for (int i = 0; i < ns.getLength(); i++)
- {
- node = ns.item(i);
- if (!(node instanceof Element))
- {
- continue;
- }
- ret = verifyNameSpace((Element) node);
- if (!ret)
- {
- return false;
- }
- }
- return true;
- }
-
- protected static void updateNameSpacePackageMapping(Element root)
- {
- if (!verifyNameSpace(root))
- {
- throw new
WebBeansConfigurationException(log.getTokenString(OWBLogConst.EXCEPT_0012));
- }
- WebBeansContext webBeansContext = WebBeansContext.getInstance();
- if (root.getNamespaceURI() != null)
- {
- webBeansContext.getWebBeansNameSpaceContainer().
- addNewPackageNameSpace(root.getNamespaceURI());
- }
- else
- {
- String attr = root.getAttribute("xmlns");
- if (attr != null)
- {
- webBeansContext.getWebBeansNameSpaceContainer().
- addNewPackageNameSpace(root.getNamespaceURI());
- }
- }
- NamedNodeMap attrs = root.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++)
- {
- // hack the code here, since I did'nt find NameSpace support
- // in Java DOM.
- Attr attr = (Attr) attrs.item(i);
- if (attr.getName().toLowerCase().startsWith("xmlns"))
- {
-
webBeansContext.getWebBeansNameSpaceContainer().addNewPackageNameSpace(attr.getValue());
- }
- }
- }
-
- public static Element getRootElement(InputStream stream) throws
WebBeansException
- {
-
- try
- {
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setCoalescing(false);
- factory.setExpandEntityReferences(true);
- factory.setIgnoringComments(true);
- factory.setIgnoringElementContentWhitespace(true);
- factory.setNamespaceAware(true);
- factory.setValidating(false);
- DocumentBuilder documentBuilder = factory.newDocumentBuilder();
- documentBuilder.setErrorHandler(new WebBeansErrorHandler());
- documentBuilder.setEntityResolver(new WebBeansResolver());
-
- Document doc = documentBuilder.parse(stream);
- Element root = doc.getDocumentElement();
- updateNameSpacePackageMapping(root);
- return root;
- }
- catch (Exception e)
- {
- log.fatal(e, OWBLogConst.FATAL_0002);
- throw new
WebBeansException(log.getTokenString(OWBLogConst.EXCEPT_0013), e);
- }
- }
-
/**
* Gets the root element of the parsed document.
*
@@ -177,307 +83,6 @@ public class XMLUtil
}
}
- public static boolean isElementInNamespace(Element element, String
namespace)
- {
- Asserts.assertNotNull(element, "element parameter can not be null");
- Asserts.assertNotNull(namespace, "namespace parameter can not be
null");
- String nsURI = element.getNamespaceURI();
- return nsURI.equals(namespace);
- }
-
- public static boolean isElementInWebBeansNameSpace(Element element)
- {
- nullCheckForElement(element);
- String ns = getElementNameSpace(element);
-
- if (ns != null && ns.equals(WebBeansConstants.WEB_BEANS_NAMESPACE))
- {
- return true;
- }
-
- return false;
- }
-
- public static boolean isElementInWebBeansNameSpaceWithName(Element
element, String name)
- {
- nullCheckForElement(element);
-
- if (isElementInWebBeansNameSpace(element))
- {
- String txtName = element.getLocalName();
- if (name.equals(txtName))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static String getElementNameSpace(Element element)
- {
- nullCheckForElement(element);
-
- return element.getNamespaceURI();
- }
-
- public static boolean isElementWebBeanDeclaration(Element element)
- {
- nullCheckForElement(element);
-
- if (!isElementInWebBeansNameSpaceWithName(element,
WebBeansConstants.WEB_BEANS_XML_DEPLOY_ELEMENT) &&
- !isElementInWebBeansNameSpaceWithName(element,
WebBeansConstants.WEB_BEANS_XML_INTERCEPTORS_ELEMENT) &&
- !isElementInWebBeansNameSpaceWithName(element,
WebBeansConstants.WEB_BEANS_XML_DECORATORS_ELEMENT) &&
- !hasChildElement(element,
WebBeansConstants.WEB_BEANS_XML_BINDING_TYPE) &&
- !hasChildElement(element,
WebBeansConstants.WEB_BEANS_XML_INTERCEPTOR_BINDING_TYPE) &&
- !hasChildElement(element,
WebBeansConstants.WEB_BEANS_XML_STEREOTYPE))
- {
- return true;
- }
-
- return false;
-
- }
-
- /**
- * Returns true if element has a bindingtype child element in webbeans
- * namespace false otherwise.
- *
- * @param element parent element
- * @return true if element has a bindingtype child element in webbeans
- * namespace
- */
- public static boolean isElementBindingTypeDecleration(Element element)
- {
- nullCheckForElement(element);
-
- if (hasChildElementWithWebBeansNameSpace(element,
WebBeansConstants.WEB_BEANS_XML_BINDING_TYPE))
- {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true if element has a interceptor bindingtype child element in
- * webbeans namespace false otherwise.
- *
- * @param element parent element
- * @return true if element has a interceptor bindingtype child element in
- * webbeans namespace
- */
- public static boolean isElementInterceptorBindingTypeDecleration(Element
element)
- {
- nullCheckForElement(element);
-
- if (hasChildElementWithWebBeansNameSpace(element,
WebBeansConstants.WEB_BEANS_XML_INTERCEPTOR_BINDING_TYPE))
- {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true if element has a stereotype child element in webbeans
- * namespace false otherwise.
- *
- * @param element parent element
- * @return true if element has a stereotype child element in webbeans
- * namespace
- */
- public static boolean isElementStereoTypeDecleration(Element element)
- {
- nullCheckForElement(element);
-
- if (hasChildElementWithWebBeansNameSpace(element,
WebBeansConstants.WEB_BEANS_XML_STEREOTYPE))
- {
- return true;
- }
-
- return false;
- }
-
- public static boolean isElementDeployDeclaration(Element element)
- {
- nullCheckForElement(element);
-
- if (isElementInWebBeansNameSpaceWithName(element,
WebBeansConstants.WEB_BEANS_XML_DEPLOY_ELEMENT))
- {
- return true;
- }
-
- return false;
-
- }
-
- public static boolean isElementInterceptorsDeclaration(Element element)
- {
- nullCheckForElement(element);
-
- if (isElementInWebBeansNameSpaceWithName(element,
WebBeansConstants.WEB_BEANS_XML_INTERCEPTORS_ELEMENT))
- {
- return true;
- }
-
- return false;
-
- }
-
- public static boolean isElementDecoratosDeclaration(Element element)
- {
- nullCheckForElement(element);
-
- if (isElementInWebBeansNameSpaceWithName(element,
WebBeansConstants.WEB_BEANS_XML_DECORATORS_ELEMENT))
- {
- return true;
- }
-
- return false;
-
- }
-
- /**
- * Returns true if this element defines JMS webbeans, false otherwise.
- *
- * @param element webbeans element decleration
- * @return true if this element defines JMS webbeans, false otherwise
- */
- public static boolean isElementJMSDeclaration(Element element)
- {
- nullCheckForElement(element);
-
- if (isElementWebBeanDeclaration(element))
- {
- if (isElementInWebBeansNameSpaceWithName(element,
WebBeansConstants.WEB_BEANS_XML_QUEUE_ELEMENT)
- || isElementInWebBeansNameSpaceWithName(element,
WebBeansConstants.WEB_BEANS_XML_TOPIC_ELEMENT))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static boolean isElementHasDecoratesChild(Element element)
- {
- nullCheckForElement(element);
- if (hasChildElementWithWebBeansNameSpace(element,
WebBeansConstants.WEB_BEANS_XML_DECORATES_ELEMENT))
- {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true if this element defines field, false otherwise.
- *
- * @param element webbeans decleration child element
- * @return true if this element defines field, false otherwise
- */
- public static boolean isElementField(Element element)
- {
- nullCheckForElement(element);
-
- Node node;
- Element child;
- NodeList ns = element.getChildNodes();
- for (int i = 0; i < ns.getLength(); i++)
- {
- node = ns.item(i);
- if (!(node instanceof Element))
- {
- continue;
- }
- child = (Element) node;
- if (!isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_INITIALIZER_ELEMENT) &&
- !isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_DESTRUCTOR_ELEMENT) &&
- !isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_PRODUCES_ELEMENT) &&
- !isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_DISPOSES_ELEMENT) &&
- !isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_OBSERVES_ELEMENT) &&
- !isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_DECORATES_ELEMENT))
- {
-
- Class<?> clazz = getElementJavaType(child);
- if (clazz != null)
- {
- if (clazz.isAnnotation())
- {
- if
(AnnotationUtil.isInterceptorBindingAnnotation((Class<? extends Annotation>)
clazz))
- {
- return false;
- }
- }
-
- }
-
- }
- else
- {
- return false;
- }
-
- }
-
- return true;
-
- }
-
- /**
- * Checks that given element is a webbeans method or not.
- *
- * @param element dom element represents method decleration
- * @return true if the given element is a true element decleration false
- * otherwise
- */
- public static boolean isElementMethod(Element element)
- {
- nullCheckForElement(element);
-
- Node node;
- Element child;
- NodeList ns = element.getChildNodes();
- for (int i = 0; i < ns.getLength(); i++)
- {
- node = ns.item(i);
- if (!(node instanceof Element))
- {
- continue;
- }
- child = (Element) node;
- if (isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_INITIALIZER_ELEMENT) ||
- isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_DESTRUCTOR_ELEMENT) ||
- isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_PRODUCES_ELEMENT) ||
- isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_DISPOSES_ELEMENT) ||
- isElementInWebBeansNameSpaceWithName(child,
WebBeansConstants.WEB_BEANS_XML_OBSERVES_ELEMENT))
- {
- return true;
-
- }
- else
- {
- Class<?> clazz = getElementJavaType(child);
- if (clazz != null)
- {
- if (clazz.isAnnotation())
- {
- if
(AnnotationUtil.isInterceptorBindingAnnotation((Class<? extends Annotation>)
clazz))
- {
- return true;
- }
- }
-
- }
- }
-
- }
-
- return false;
-
- }
-
public static String getName(Element element)
{
nullCheckForElement(element);
@@ -485,116 +90,10 @@ public class XMLUtil
return element.getLocalName();
}
- public static Class<?> getElementJavaType(Element element)
- {
- String ns = getElementNameSpace(element);
- List<String> packageNames =
WebBeansContext.getInstance().getWebBeansNameSpaceContainer().getPackageNameFromNameSpace(ns);
-
- Class<?> clazz = null;
- Class<?> foundClazz = null;
- if (packageNames != null)
- {
- boolean found = false;
-
- for (String packageName : packageNames)
- {
- String className = packageName + XMLUtil.getName(element);
- clazz = ClassUtil.getClassFromName(className);
-
- if (clazz != null)
- {
- if (found)
- {
- throw new
DefinitionException(log.getTokenString(OWBLogConst.EXCEPT_0014) +
clazz.getName());
- }
- else
- {
- foundClazz = clazz;
- found = true;
- }
- }
- }
-
- }
-
- return foundClazz;
- }
-
- public static String getElementJavaClassName(Element element)
- {
- Class<?> clazz = getElementJavaType(element);
-
- if (clazz != null)
- {
- return clazz.getName();
- }
-
- return getName(element);
- }
-
private static void nullCheckForElement(Element element)
{
Asserts.assertNotNull(element, "element argument can not be null");
}
-
-
- public static boolean hasChildElement(Element parent, String childName)
- {
- Node node;
- Asserts.assertNotNull(parent, "parent parameter can not be null");
- Asserts.assertNotNull(childName, "childName parameter can not be
null");
- NodeList nl = parent.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++)
- {
- node = nl.item(i);
- if (node instanceof Element)
- {
- if (node.getNodeName().equals(childName))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Return child element within webbeans namespace with given child name.
- *
- * @param parent parent element
- * @param childName child element name
- * @return if child element exist within webbeans namespace with given
child
- * name
- */
- public static boolean hasChildElementWithWebBeansNameSpace(Element parent,
String childName)
- {
- Asserts.assertNotNull(parent, "parent parameter can not be null");
- Asserts.assertNotNull(childName, "childName parameter can not be
null");
- Node node;
- Element child = null;
- NodeList nl = parent.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++)
- {
- node = nl.item(i);
- if (node instanceof Element)
- {
- if (node.getNodeName().equals(childName))
- {
- child = (Element) node;
- }
- }
- }
-
- if (child == null)
- {
- return false;
- }
- else
- {
- return isElementInWebBeansNameSpace(child);
- }
- }
-
/**
* Creates new annotation with configured members values.
*