[webbeans-commits] Webbeans SVN: r2218 - in ri/trunk/impl/src/main/java/org/jboss/webbeans/xml: checker and 6 other directories.
by webbeans-commits@lists.jboss.org
Author: vitold
Date: 2009-03-26 13:36:33 -0400 (Thu, 26 Mar 2009)
New Revision: 2218
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/BeanElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/JmsResourceElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/NotSimpleBeanElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/ResourceElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/impl/
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/impl/BeanElementCheckerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/BeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/check/
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
Log:
changes with bean element validation
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-03-26 17:24:45 UTC (rev 2217)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -101,10 +101,6 @@
throw new DefinitionException("There are multiple packages containing a Java type with the same name '" + className + "'");
}
- public static void checkProduces(Element element, AnnotatedClass<?> beanClass)
- {
- }
-
public static void checkRootAttributes(Element root, Map<String, Set<String>> packagesMap, XmlEnvironment environment)
{
Iterator<?> rootAttrIterator = root.attributeIterator();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-03-26 17:24:45 UTC (rev 2217)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -28,12 +28,13 @@
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.xml.check.BeanType;
-import org.jboss.webbeans.xml.check.BeanTypeObtainer;
-import org.jboss.webbeans.xml.check.JmsResourceTypeObtainer;
-import org.jboss.webbeans.xml.check.ResourceTypeObtainer;
-import org.jboss.webbeans.xml.check.SessionBeanTypeObtainer;
-import org.jboss.webbeans.xml.check.SimpleBeanTypeObtainer;
+import org.jboss.webbeans.xml.checker.bean.BeanElementChecker;
+import org.jboss.webbeans.xml.checker.bean.ext.JmsResourceElementChecker;
+import org.jboss.webbeans.xml.checker.bean.ext.ResourceElementChecker;
+import org.jboss.webbeans.xml.checker.bean.ext.SessionBeanElementChecker;
+import org.jboss.webbeans.xml.checker.bean.ext.SimpleBeanElementChecker;
+import org.jboss.webbeans.xml.checker.beanchildren.ext.NotSimpleBeanChildrenChecker;
+import org.jboss.webbeans.xml.checker.beanchildren.ext.SimpleBeanChildrenChecker;
public class XmlParser
{
@@ -41,7 +42,7 @@
private final XmlEnvironment environment;
- private List<BeanTypeObtainer> beanTypeObtainers = new ArrayList<BeanTypeObtainer>();
+ private List<BeanElementChecker> beanElementCheckers = new ArrayList<BeanElementChecker>();
private boolean haveAnyDeployElement = false;
@@ -49,11 +50,7 @@
public XmlParser(XmlEnvironment environment)
{
- this.environment = environment;
- this.beanTypeObtainers.add(new JmsResourceTypeObtainer());
- this.beanTypeObtainers.add(new ResourceTypeObtainer());
- this.beanTypeObtainers.add(new SessionBeanTypeObtainer());
- this.beanTypeObtainers.add(new SimpleBeanTypeObtainer());
+ this.environment = environment;
}
public void parse()
@@ -206,22 +203,29 @@
}
private void checkBeanElement(Element beanElement, AnnotatedClass<?> beanClass)
- {//TODO: not finished
- BeanType beanType = BeanType.SIMPLE_BEAN;
- for(BeanTypeObtainer beanTypeObtainer : beanTypeObtainers)
+ {
+ beanElementCheckers.add(new JmsResourceElementChecker(new NotSimpleBeanChildrenChecker(environment, packagesMap)));
+ beanElementCheckers.add(new ResourceElementChecker(new NotSimpleBeanChildrenChecker(environment, packagesMap)));
+ beanElementCheckers.add(new SessionBeanElementChecker(new NotSimpleBeanChildrenChecker(environment, packagesMap)));
+ beanElementCheckers.add(new SimpleBeanElementChecker(new SimpleBeanChildrenChecker(environment, packagesMap)));
+
+ boolean isValidType = false;
+ for(BeanElementChecker beanElementChecker : beanElementCheckers)
{
- if(beanTypeObtainer.accept(beanElement, beanClass))
+ if(beanElementChecker.accept(beanElement, beanClass))
{
- beanType = beanTypeObtainer.obtainType(beanElement, beanClass);
+ beanElementChecker.checkBeanElement(beanElement, beanClass);
+ isValidType = true;
break;
}
}
-
+ if(!isValidType)
+ throw new DefinitionException("Can't determine type of bean element <" + beanElement.getName() + ">");
}
private void checkProduces(Element beanElement, AnnotatedClass<?> beanClass)
- {
+ {//TODO: will refactor
Iterator<?> beanIterator = beanElement.elementIterator();
while(beanIterator.hasNext())
{
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/BeanElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/BeanElementChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/BeanElementChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.xml.checker.bean;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+
+public interface BeanElementChecker
+{
+ boolean accept(Element beanElement, AnnotatedClass<?> beanClass);
+
+ void checkBeanElement(Element beanElement, AnnotatedClass<?> beanClass);
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/JmsResourceElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/JmsResourceElementChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/JmsResourceElementChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.xml.checker.bean.ext;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.xml.ParseXmlHelper;
+import org.jboss.webbeans.xml.XmlConstants;
+import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
+
+public class JmsResourceElementChecker extends NotSimpleBeanElementChecker
+{
+ public JmsResourceElementChecker(BeanChildrenChecker childrenChecker)
+ {
+ super(childrenChecker);
+ }
+
+ public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
+ {
+ if (ParseXmlHelper.isJavaEeNamespace(beanElement) &&
+ (beanElement.getName().equalsIgnoreCase(XmlConstants.TOPIC) ||
+ beanElement.getName().equalsIgnoreCase(XmlConstants.QUEUE)))
+ return true;
+ return false;
+ }
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/NotSimpleBeanElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/NotSimpleBeanElementChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/NotSimpleBeanElementChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.xml.checker.bean.ext;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.xml.checker.bean.impl.BeanElementCheckerImpl;
+import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
+
+public abstract class NotSimpleBeanElementChecker extends BeanElementCheckerImpl
+{
+ public NotSimpleBeanElementChecker(BeanChildrenChecker childrenChecker)
+ {
+ super(childrenChecker);
+ }
+
+ public void checkElementDeclaration(Element beanElement, AnnotatedClass<?> beanClass)
+ {
+ // There is nothing to validate
+ }
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/ResourceElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/ResourceElementChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/ResourceElementChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,39 @@
+package org.jboss.webbeans.xml.checker.bean.ext;
+
+import java.util.Iterator;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.xml.ParseXmlHelper;
+import org.jboss.webbeans.xml.XmlConstants;
+import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
+
+public class ResourceElementChecker extends NotSimpleBeanElementChecker
+{
+ public ResourceElementChecker(BeanChildrenChecker childrenChecker)
+ {
+ super(childrenChecker);
+ }
+
+ public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
+ {
+ if (ParseXmlHelper.isJavaEeNamespace(beanElement) &&
+ (beanElement.getName().equalsIgnoreCase(XmlConstants.TOPIC) ||
+ beanElement.getName().equalsIgnoreCase(XmlConstants.QUEUE)))
+ return false;
+
+ Iterator<?> elIterator = beanElement.elementIterator();
+ while (elIterator.hasNext())
+ {
+ Element child = (Element) elIterator.next();
+ if (ParseXmlHelper.isJavaEeNamespace(child) &&
+ (child.getName().equalsIgnoreCase(XmlConstants.RESOURCE) ||
+ child.getName().equalsIgnoreCase(XmlConstants.PERSISTENCE_CONTEXT) ||
+ child.getName().equalsIgnoreCase(XmlConstants.PERSISTENCE_UNIT) ||
+ child.getName().equalsIgnoreCase(XmlConstants.EJB) ||
+ child.getName().equalsIgnoreCase(XmlConstants.WEB_SERVICE_REF)))
+ return true;
+ }
+ return false;
+ }
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,25 @@
+package org.jboss.webbeans.xml.checker.bean.ext;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.xml.XmlConstants;
+import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
+
+public class SessionBeanElementChecker extends NotSimpleBeanElementChecker
+{
+ public SessionBeanElementChecker(BeanChildrenChecker childrenChecker)
+ {
+ super(childrenChecker);
+ }
+
+ public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
+ {
+ ManagerImpl manager = CurrentManager.rootManager();
+ if (manager.getEjbDescriptorCache().containsKey(beanElement.getName()) ||
+ beanElement.attribute(XmlConstants.EJB_NAME) != null)
+ return true;
+ return false;
+ }
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,51 @@
+package org.jboss.webbeans.xml.checker.bean.ext;
+
+import javax.decorator.Decorator;
+import javax.inject.DefinitionException;
+import javax.interceptor.Interceptor;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.xml.ParseXmlHelper;
+import org.jboss.webbeans.xml.XmlConstants;
+import org.jboss.webbeans.xml.checker.bean.impl.BeanElementCheckerImpl;
+import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
+
+public class SimpleBeanElementChecker extends BeanElementCheckerImpl
+{
+ public SimpleBeanElementChecker(BeanChildrenChecker childrenChecker)
+ {
+ super(childrenChecker);
+ }
+
+ public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
+ {
+ ManagerImpl manager = CurrentManager.rootManager();
+ boolean isSessionBean = manager.getEjbDescriptorCache().containsKey(beanElement.getName()) ||
+ beanElement.attribute(XmlConstants.EJB_NAME) != null;
+
+ if (!beanClass.isAbstract() && !isSessionBean && !beanClass.isParameterizedType())
+ return true;
+
+ return false;
+ }
+
+ public void checkElementDeclaration(Element beanElement, AnnotatedClass<?> beanClass)
+ {
+ if(beanClass.isNonStaticMemberClass())
+ throw new DefinitionException("Bean class '" + beanClass.getName() + "' of a simple bean <" + beanElement.getName() +
+ "> is a non static member class");
+
+ if(beanClass.getRawType().isAnnotationPresent(Interceptor.class) &&
+ ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() != 1)
+ throw new DefinitionException("A simple bean defined in XML as <" + beanElement.getName() + "> has a bean class '" +
+ beanClass.getName() + "' annotated @Interceptor and is not declared as an interceptor in XML");
+
+ if(beanClass.getRawType().isAnnotationPresent(Decorator.class) &&
+ ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() != 1)
+ throw new DefinitionException("A simple bean defined in XML as <" + beanElement.getName() + "> has a bean class '" +
+ beanClass.getName() + "' annotated @Decorator and is not declared as an decorator in XML");
+ }
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/impl/BeanElementCheckerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/impl/BeanElementCheckerImpl.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/impl/BeanElementCheckerImpl.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,27 @@
+package org.jboss.webbeans.xml.checker.bean.impl;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.xml.checker.bean.BeanElementChecker;
+import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
+
+
+public abstract class BeanElementCheckerImpl implements BeanElementChecker
+{
+ private final BeanChildrenChecker childrenChecker;
+
+ public BeanElementCheckerImpl(BeanChildrenChecker childrenChecker)
+ {
+ this.childrenChecker = childrenChecker;
+ }
+
+ public abstract boolean accept(Element beanElement, AnnotatedClass<?> beanClass);
+
+ public abstract void checkElementDeclaration(Element beanElement, AnnotatedClass<?> beanClass);
+
+ public void checkBeanElement(Element beanElement, AnnotatedClass<?> beanClass)
+ {
+ checkElementDeclaration(beanElement, beanClass);
+ childrenChecker.checkChildren(beanElement, beanClass);
+ }
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/BeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/BeanChildrenChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/BeanChildrenChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.xml.checker.beanchildren;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+
+public interface BeanChildrenChecker
+{
+ void checkChildren(Element beanElement, AnnotatedClass<?> beanClass);
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,46 @@
+package org.jboss.webbeans.xml.checker.beanchildren.ext;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.DefinitionException;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.xml.ParseXmlHelper;
+import org.jboss.webbeans.xml.XmlConstants;
+import org.jboss.webbeans.xml.XmlEnvironment;
+import org.jboss.webbeans.xml.checker.beanchildren.impl.BeanChildrenCheckerImpl;
+
+public class NotSimpleBeanChildrenChecker extends BeanChildrenCheckerImpl
+{
+ public NotSimpleBeanChildrenChecker(XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+ {
+ super(environment, packagesMap);
+ }
+
+ public void checkForInterceptorChild(Element beanElement)
+ {
+ if(ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() > 1)
+ throw new DefinitionException("Not a simple bean '" + beanElement.getName() + "' contains direct child <" +
+ XmlConstants.INTERCEPTOR + ">");
+ }
+
+ public void checkForDecoratorChild(Element beanElement)
+ {
+ if(ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() > 1)
+ throw new DefinitionException("Not a simple bean '" + beanElement.getName() + "' contains direct child <" +
+ XmlConstants.DECORATOR + ">");
+ }
+
+ public void checkChildForInterceptorType(Element beanChildElement)
+ {
+ throw new DefinitionException("Declaration of not a simple bean '" + beanChildElement.getParent().getName() +
+ "' contains a child <" + beanChildElement.getName() + "> which type is javax.interceptor.Interceptor");
+ }
+
+ public void checkChildForDecoratorType(Element beanChildElement)
+ {
+ throw new DefinitionException("Declaration of not a simple bean '" + beanChildElement.getParent().getName() +
+ "' contains a child <" + beanChildElement.getName() + "> which type is javax.decorator.Decorator");
+ }
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,50 @@
+package org.jboss.webbeans.xml.checker.beanchildren.ext;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.DefinitionException;
+
+import org.dom4j.Element;
+import org.jboss.webbeans.xml.ParseXmlHelper;
+import org.jboss.webbeans.xml.XmlConstants;
+import org.jboss.webbeans.xml.XmlEnvironment;
+import org.jboss.webbeans.xml.checker.beanchildren.impl.BeanChildrenCheckerImpl;
+
+public class SimpleBeanChildrenChecker extends BeanChildrenCheckerImpl
+{
+ public SimpleBeanChildrenChecker(XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+ {
+ super(environment, packagesMap);
+ }
+
+ public void checkForDecoratorChild(Element beanElement)
+ {
+ if(ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() > 1)
+ throw new DefinitionException("A simple bean element <" + beanElement.getName() + "> has more than one direct child <" +
+ XmlConstants.INTERCEPTOR + ">");
+ }
+
+ public void checkForInterceptorChild(Element beanElement)
+ {
+ if(ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() > 1)
+ throw new DefinitionException("A simple bean element <" + beanElement.getName() + "> has more than one direct child <" +
+ XmlConstants.DECORATOR + ">");
+ }
+
+ public void checkChildForInterceptorType(Element beanChildElement)
+ {
+ if(haveBeanInterceptorDeclaration)
+ throw new DefinitionException("There is second element of interceptor type <" + beanChildElement.getName() +
+ "> in bean '" + beanChildElement.getParent().getName() + "'");
+ haveBeanInterceptorDeclaration = true;
+ }
+
+ public void checkChildForDecoratorType(Element beanChildElement)
+ {
+ if(haveBeanDecoratorDeclaration)
+ throw new DefinitionException("There is second element of decorator type <" + beanChildElement.getName() +
+ "> in bean '" + beanChildElement.getParent().getName() + "'");
+ haveBeanDecoratorDeclaration = true;
+ }
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java 2009-03-26 17:36:33 UTC (rev 2218)
@@ -0,0 +1,154 @@
+package org.jboss.webbeans.xml.checker.beanchildren.impl;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Named;
+import javax.annotation.Resource;
+import javax.annotation.Stereotype;
+import javax.context.ScopeType;
+import javax.decorator.Decorator;
+import javax.ejb.EJB;
+import javax.inject.BindingType;
+import javax.inject.DefinitionException;
+import javax.inject.DeploymentType;
+import javax.inject.Realizes;
+import javax.inject.Specializes;
+import javax.interceptor.Interceptor;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+import javax.xml.ws.WebServiceRef;
+
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.xml.ParseXmlHelper;
+import org.jboss.webbeans.xml.XmlConstants;
+import org.jboss.webbeans.xml.XmlEnvironment;
+import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
+
+public abstract class BeanChildrenCheckerImpl implements BeanChildrenChecker
+{
+ private final XmlEnvironment environment;
+
+ private final Map<String, Set<String>> packagesMap;
+
+ private boolean haveBeanDeploymentTypeDeclaration = false;
+
+ private boolean haveBeanScopeTypeDeclaration = false;
+
+ protected boolean haveBeanInterceptorDeclaration = false;
+
+ protected boolean haveBeanDecoratorDeclaration = false;
+
+ public abstract void checkForInterceptorChild(Element beanElement);
+
+ public abstract void checkForDecoratorChild(Element beanElement);
+
+ public abstract void checkChildForInterceptorType(Element beanElement);
+
+ public abstract void checkChildForDecoratorType(Element beanElement);
+
+ public BeanChildrenCheckerImpl(XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+ {
+ this.environment = environment;
+ this.packagesMap = packagesMap;
+ }
+
+ public void checkChildren(Element beanElement, AnnotatedClass<?> beanClass)
+ {
+ checkForInterceptorChild(beanElement);
+ checkForDecoratorChild(beanElement);
+
+ haveBeanDeploymentTypeDeclaration = false;
+ haveBeanScopeTypeDeclaration = false;
+ haveBeanInterceptorDeclaration = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() > 0;
+ haveBeanDecoratorDeclaration = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() > 0;
+
+ Iterator<?> beanIterator = beanElement.elementIterator();
+ while(beanIterator.hasNext())
+ {
+ Element beanChildElement = (Element)beanIterator.next();
+ checkBeanChild(beanChildElement);
+ }
+ }
+
+ private void checkBeanChild(Element beanChildElement)
+ {
+ //TODO: not finished
+ try
+ {
+ AnnotatedClass<?> beanChildClass = ParseXmlHelper.loadElementClass(beanChildElement, Object.class, environment, packagesMap);
+ Class<?> beanChildType = beanChildClass.getRawType();
+ boolean isJavaClass = !beanChildType.isEnum() && !beanChildType.isPrimitive() && !beanChildType.isInterface();
+ boolean isInterface = beanChildType.isInterface() && !beanChildType.isAnnotation();
+ if(beanChildType.isAnnotation())
+ {
+ //bean child element declaring type-level metadata
+ checkAnnotationChild(beanChildElement, beanChildClass);
+ return;
+ }
+ if(isJavaClass || isInterface)
+ {
+ //TODO: bean child element declaring a parameter of the bean constructor
+ return;
+ }
+ throw new DefinitionException();//bean child element can't be interpreted as a Java class or interface or Java Annotation type
+ }
+ catch(DefinitionException e)
+ {
+ Element beanElement = beanChildElement.getParent();
+ Namespace beanNamespace = beanElement.getNamespace();
+ Namespace beanChildNamespace = beanChildElement.getNamespace();
+ if(beanChildNamespace.equals(beanNamespace))
+ {
+ //TODO: bean child element declaring a method or field of the bean.
+ return;
+ }
+ throw new DefinitionException("Can't determine type of element <" + beanChildElement.getName() + "> in bean '" +
+ beanElement.getName() + "'");
+ }
+ }
+
+ private void checkAnnotationChild(Element beanChildElement, AnnotatedClass<?> beanChildClass)
+ {
+ if(beanChildClass.isAnnotationPresent(DeploymentType.class))
+ {
+ if(haveBeanDeploymentTypeDeclaration)
+ throw new DefinitionException("Only one deployment type declaration allowed for bean '" +
+ beanChildElement.getParent().getName() + "'");
+ haveBeanDeploymentTypeDeclaration = true;
+ return;
+ }
+ if(beanChildClass.isAnnotationPresent(ScopeType.class))
+ {
+ if(haveBeanScopeTypeDeclaration)
+ throw new DefinitionException("Only one scope type declaration allowed for bean '" +
+ beanChildElement.getParent().getName() + "'");
+ haveBeanScopeTypeDeclaration = true;
+ return;
+ }
+ if(beanChildClass.isAnnotationPresent(Interceptor.class))
+ {
+ checkChildForInterceptorType(beanChildElement);
+ return;
+ }
+ if(beanChildClass.isAnnotationPresent(Decorator.class))
+ {
+ checkChildForDecoratorType(beanChildElement);
+ return;
+ }
+ //TODO: add interceptor binding type
+ if(beanChildClass.isAnnotationPresent(BindingType.class) || beanChildClass.isAnnotationPresent(Stereotype.class) ||
+ beanChildClass.isAnnotationPresent(Named.class) || beanChildClass.isAnnotationPresent(Specializes.class) ||
+ beanChildClass.isAnnotationPresent(Realizes.class) || beanChildClass.isAnnotationPresent(Resource.class) ||
+ beanChildClass.isAnnotationPresent(EJB.class) || beanChildClass.isAnnotationPresent(WebServiceRef.class) ||
+ beanChildClass.isAnnotationPresent(PersistenceContext.class) || beanChildClass.isAnnotationPresent(PersistenceUnit.class))
+ return;
+
+ throw new DefinitionException("Can't determine annotation type of <" + beanChildElement.getName() + "> element in bean '" +
+ beanChildElement.getParent().getName() + "'");
+ }
+
+}
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2217 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/mock and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-26 13:24:45 -0400 (Thu, 26 Mar 2009)
New Revision: 2217
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
Log:
WBRI-172
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-26 17:14:47 UTC (rev 2216)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-26 17:24:45 UTC (rev 2217)
@@ -30,6 +30,7 @@
import org.jboss.webbeans.introspector.WrappedAnnotatedField;
import org.jboss.webbeans.introspector.WrappedAnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.jpa.spi.JpaServices;
import org.jboss.webbeans.jsf.JSFApiAbstraction;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -250,7 +251,17 @@
JSFApiAbstraction jsfApiAbstraction = manager.getServices().get(JSFApiAbstraction.class);
ServletApiAbstraction servletApiAbstraction = manager.getServices().get(ServletApiAbstraction.class);
// TODO: check 3.2.1 for more rules!!!!!!
- return !Reflections.isAbstract(rawType) && !Reflections.isParameterizedType(rawType) && !servletApiAbstraction.SERVLET_CLASS.isAssignableFrom(rawType) && !servletApiAbstraction.FILTER_CLASS.isAssignableFrom(rawType) && !servletApiAbstraction.SERVLET_CONTEXT_LISTENER_CLASS.isAssignableFrom(rawType) && !servletApiAbstraction.HTTP_SESSION_LISTENER_CLASS.isAssignableFrom(rawType) && !servletApiAbstraction.SERVLET_REQUEST_LISTENER_CLASS.isAssignableFrom(rawType) && !ejbApiAbstraction.ENTERPRISE_BEAN_CLASS.isAssignableFrom(rawType) && !jsfApiAbstraction.UICOMPONENT_CLASS.isAssignableFrom(rawType) && hasSimpleWebBeanConstructor(clazz);
+ return !Reflections.isAbstract(rawType) &&
+ !Reflections.isParameterizedType(rawType) &&
+ !servletApiAbstraction.SERVLET_CLASS.isAssignableFrom(rawType) &&
+ !servletApiAbstraction.FILTER_CLASS.isAssignableFrom(rawType) &&
+ !servletApiAbstraction.SERVLET_CONTEXT_LISTENER_CLASS.isAssignableFrom(rawType) &&
+ !servletApiAbstraction.HTTP_SESSION_LISTENER_CLASS.isAssignableFrom(rawType) &&
+ !servletApiAbstraction.SERVLET_REQUEST_LISTENER_CLASS.isAssignableFrom(rawType) &&
+ !ejbApiAbstraction.ENTERPRISE_BEAN_CLASS.isAssignableFrom(rawType) &&
+ !jsfApiAbstraction.UICOMPONENT_CLASS.isAssignableFrom(rawType) &&
+ hasSimpleWebBeanConstructor(clazz)
+ && !manager.getServices().get(JpaServices.class).discoverEntities().contains(clazz.getRawType());
}
private static boolean hasSimpleWebBeanConstructor(AnnotatedClass<?> type)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-03-26 17:14:47 UTC (rev 2216)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-03-26 17:24:45 UTC (rev 2217)
@@ -3,6 +3,7 @@
*/
package org.jboss.webbeans.mock;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -27,7 +28,7 @@
return null;
}
- public Iterable<Class<?>> discoverEntities()
+ public Collection<Class<?>> discoverEntities()
{
Set<Class<?>> classes = new HashSet<Class<?>>();
for (Class<?> clazz : webBeanDiscovery.discoverWebBeanClasses())
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java 2009-03-26 17:14:47 UTC (rev 2216)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java 2009-03-26 17:24:45 UTC (rev 2217)
@@ -16,6 +16,8 @@
*/
package org.jboss.webbeans.jpa.spi;
+import java.util.Collection;
+
import javax.inject.manager.InjectionPoint;
import org.jboss.webbeans.bootstrap.api.Service;
@@ -35,7 +37,7 @@
*
* @return the entity classes
*/
- public Iterable<Class<?>> discoverEntities();
+ public Collection<Class<?>> discoverEntities();
/**
* Resolve the value for the given @PersistenceContext injection point
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java 2009-03-26 17:14:47 UTC (rev 2216)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java 2009-03-26 17:24:45 UTC (rev 2217)
@@ -16,6 +16,8 @@
*/
package org.jboss.webbeans.jpa.spi.helpers;
+import java.util.Collection;
+
import javax.inject.manager.InjectionPoint;
import org.jboss.webbeans.jpa.spi.JpaServices;
@@ -35,7 +37,7 @@
protected abstract JpaServices delegate();
- public Iterable<Class<?>> discoverEntities()
+ public Collection<Class<?>> discoverEntities()
{
return delegate().discoverEntities();
}
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-03-26 17:14:47 UTC (rev 2216)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-03-26 17:24:45 UTC (rev 2217)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.bootstrap.api.test;
+import java.util.Collection;
+
import javax.inject.manager.InjectionPoint;
import org.jboss.webbeans.jpa.spi.JpaServices;
@@ -7,7 +9,7 @@
public class MockJpaServices implements JpaServices
{
- public Iterable<Class<?>> discoverEntities()
+ public Collection<Class<?>> discoverEntities()
{
// TODO Auto-generated method stub
return null;
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2216 - in ri/trunk: spi/src/test/java/org/jboss/webbeans/bootstrap/api/test and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-26 13:14:47 -0400 (Thu, 26 Mar 2009)
New Revision: 2216
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
Log:
oops
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-03-26 17:14:47 UTC (rev 2216)
@@ -0,0 +1,43 @@
+/**
+ *
+ */
+package org.jboss.webbeans.mock;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.inject.manager.InjectionPoint;
+import javax.persistence.Entity;
+
+import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.jpa.spi.JpaServices;
+
+public class MockJpaServices implements JpaServices
+{
+
+ private final WebBeanDiscovery webBeanDiscovery;
+
+ public MockJpaServices(WebBeanDiscovery webBeanDiscovery)
+ {
+ this.webBeanDiscovery = webBeanDiscovery;
+ }
+
+ public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+ {
+ return null;
+ }
+
+ public Iterable<Class<?>> discoverEntities()
+ {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ for (Class<?> clazz : webBeanDiscovery.discoverWebBeanClasses())
+ {
+ if (clazz.isAnnotationPresent(Entity.class))
+ {
+ classes.add(clazz);
+ }
+ }
+ return classes;
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java (rev 0)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-03-26 17:14:47 UTC (rev 2216)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.bootstrap.api.test;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.jpa.spi.JpaServices;
+
+public class MockJpaServices implements JpaServices
+{
+
+ public Iterable<Class<?>> discoverEntities()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2215 - in ri/trunk/spi/src/main/java/org/jboss/webbeans: bootstrap/api/helpers and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-26 13:12:40 -0400 (Thu, 26 Mar 2009)
New Revision: 2215
Added:
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/
ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/
ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/
ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
Log:
add jpa spi, remove deprecated methods
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java 2009-03-26 17:12:40 UTC (rev 2215)
@@ -0,0 +1,126 @@
+package org.jboss.webbeans.bootstrap.api.helpers;
+
+import org.jboss.webbeans.bootstrap.api.Bootstrap;
+import org.jboss.webbeans.bootstrap.api.Environment;
+import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
+import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.jpa.spi.JpaServices;
+import org.jboss.webbeans.manager.api.WebBeansManager;
+import org.jboss.webbeans.resources.spi.NamingContext;
+import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.transaction.spi.TransactionServices;
+
+/**
+ * A bean version of bootstrap that delegates to the underlying bootstrap impl
+ *
+ * @author Pete Muir
+ *
+ */
+public class BootstrapBean implements Bootstrap
+{
+
+ private final Bootstrap bootstrap;
+
+ public BootstrapBean(Bootstrap bootstrap)
+ {
+ this.bootstrap = bootstrap;
+ }
+
+ public void setEjbServices(EjbServices ejbServices)
+ {
+ bootstrap.getServices().add(EjbServices.class, ejbServices);
+ }
+
+ public EjbServices getEjbServices()
+ {
+ return bootstrap.getServices().get(EjbServices.class);
+ }
+
+ public void setJpaServices(JpaServices jpaServices)
+ {
+ bootstrap.getServices().add(JpaServices.class, jpaServices);
+ }
+
+ public JpaServices getJpaServices()
+ {
+ return bootstrap.getServices().get(JpaServices.class);
+ }
+
+ public void setWebBeanDiscovery(WebBeanDiscovery webBeanDiscovery)
+ {
+ bootstrap.getServices().add(WebBeanDiscovery.class, webBeanDiscovery);
+ }
+
+ public WebBeanDiscovery getWebBeanDiscovery()
+ {
+ return bootstrap.getServices().get(WebBeanDiscovery.class);
+ }
+
+ public void setTransactionServices(TransactionServices transactionServices)
+ {
+ bootstrap.getServices().add(TransactionServices.class, transactionServices);
+ }
+
+ public TransactionServices getTransactionServices()
+ {
+ return bootstrap.getServices().get(TransactionServices.class);
+ }
+
+ public void setApplicationContext(BeanStore applicationContext)
+ {
+ bootstrap.setApplicationContext(applicationContext);
+ }
+
+ public void setNamingContext(NamingContext namingContext)
+ {
+ bootstrap.getServices().add(NamingContext.class, namingContext);
+ }
+
+ public NamingContext getNamingContext()
+ {
+ return bootstrap.getServices().get(NamingContext.class);
+ }
+
+ public void setResourceLoader(ResourceLoader resourceLoader)
+ {
+ bootstrap.getServices().add(ResourceLoader.class, resourceLoader);
+ }
+
+ public ResourceLoader getResourceLoader()
+ {
+ return bootstrap.getServices().get(ResourceLoader.class);
+ }
+
+ public void boot()
+ {
+ bootstrap.boot();
+ }
+
+ public WebBeansManager getManager()
+ {
+ return bootstrap.getManager();
+ }
+
+ public ServiceRegistry getServices()
+ {
+ return bootstrap.getServices();
+ }
+
+ public void initialize()
+ {
+ bootstrap.initialize();
+ }
+
+ public void setEnvironment(Environment environment)
+ {
+ bootstrap.setEnvironment(environment);
+ }
+
+ public void shutdown()
+ {
+ bootstrap.shutdown();
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java 2009-03-26 17:12:40 UTC (rev 2215)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.jpa.spi;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow the Web Beans RI to
+ * resolve JPA persistence units and discover entities
+ *
+ * @author Pete Muir
+ *
+ */
+public interface JpaServices extends Service
+{
+
+ /**
+ * Gets the class for each entity in the application
+ *
+ * @return the entity classes
+ */
+ public Iterable<Class<?>> discoverEntities();
+
+ /**
+ * Resolve the value for the given @PersistenceContext injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the persistence unit
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with
+ * @PersistenceContext, or, if the injection point is a method that doesn't
+ * follow JavaBean conventions
+ * @throws IllegalStateException
+ * if no suitable persistence units can be resolved for injection
+ */
+ public Object resolvePersistenceContext(InjectionPoint injectionPoint);
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/JpaServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java 2009-03-26 17:12:40 UTC (rev 2215)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.jpa.spi.helpers;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.jpa.spi.JpaServices;
+
+/**
+ * An implementation of {@link JpaServices} which forwards all its method calls
+ * to another {@link JpaServices}}. Subclasses should override one or more
+ * methods to modify the behavior of the backing {@link JpaServices} as desired
+ * per the <a
+ * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class ForwardingJpaServices implements JpaServices
+{
+
+ protected abstract JpaServices delegate();
+
+ public Iterable<Class<?>> discoverEntities()
+ {
+ return delegate().discoverEntities();
+ }
+
+ public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+ {
+ return delegate().resolvePersistenceContext(injectionPoint);
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate().toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate().equals(obj);
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2214 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/mock and 5 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-26 13:11:03 -0400 (Thu, 26 Mar 2009)
New Revision: 2214
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjbDiscovery.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
Log:
add jpa spi, remove deprecated methods
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -43,6 +43,7 @@
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
+import org.jboss.webbeans.jpa.spi.JpaServices;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.MetaDataCache;
@@ -260,6 +261,7 @@
if (getManager().getServices().contains(EjbServices.class))
{
EjbServices ejbServices = manager.getServices().get(EjbServices.class);
+ JpaServices jpaServices = manager.getServices().get(JpaServices.class);
for (AnnotatedInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
{
Object ejbInstance = ejbServices.resolveEjb(injectionPoint);
@@ -268,7 +270,7 @@
for (AnnotatedInjectionPoint<?, ?> injectionPoint : persistenceUnitInjectionPoints)
{
- Object puInstance = ejbServices.resolvePersistenceContext(injectionPoint);
+ Object puInstance = jpaServices.resolvePersistenceContext(injectionPoint);
injectionPoint.inject(beanInstance, puInstance);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -18,6 +18,7 @@
import org.jboss.webbeans.bootstrap.api.Environments;
import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.jpa.spi.JpaServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
public class MockEELifecycle extends MockServletLifecycle
@@ -30,6 +31,7 @@
super();
getBootstrap().getServices().add(TransactionServices.class, MOCK_TRANSACTION_SERVICES);
getBootstrap().getServices().add(EjbServices.class, new MockEjBServices(getWebBeanDiscovery()));
+ getBootstrap().getServices().add(JpaServices.class, new MockJpaServices(getWebBeanDiscovery()));
getBootstrap().setEnvironment(Environments.EE);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -3,13 +3,9 @@
*/
package org.jboss.webbeans.mock;
-import java.lang.annotation.Annotation;
import java.util.Collection;
-import javax.annotation.Resource;
-import javax.ejb.EJB;
import javax.inject.manager.InjectionPoint;
-import javax.persistence.PersistenceContext;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -26,31 +22,11 @@
this.ejbDiscovery = new MockEjbDiscovery(webBeanDiscovery);
}
- public Class<? extends Annotation> getEJBAnnotation()
- {
- return EJB.class;
- }
-
- public Class<? extends Annotation> getPersistenceContextAnnotation()
- {
- return PersistenceContext.class;
- }
-
public Object resolveEjb(InjectionPoint injectionPoint)
{
return null;
}
- public Object resolvePersistenceContext(InjectionPoint injectionPoint)
- {
- return null;
- }
-
- public Class<? extends Annotation> getResourceAnnotation()
- {
- return Resource.class;
- }
-
public Object resolveResource(InjectionPoint injectionPoint)
{
return null;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjbDiscovery.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjbDiscovery.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjbDiscovery.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -62,4 +62,6 @@
return ejbs;
}
+
+
}
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -16,13 +16,8 @@
*/
package org.jboss.webbeans.bootstrap.api;
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.manager.api.WebBeansManager;
-import org.jboss.webbeans.resources.spi.NamingContext;
-import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.transaction.spi.TransactionServices;
/**
* Bootstrap API for Web Beans.
@@ -34,57 +29,13 @@
{
/**
- * Set the Web Bean Discovery to use
- *
- * @param webBeanDiscovery
- */
- @Deprecated
- public void setWebBeanDiscovery(WebBeanDiscovery webBeanDiscovery);
-
- /**
- * Set the EjbServices to use
- *
- * @param ejbServices
- */
- @Deprecated
- public void setEjbServices(EjbServices ejbServices);
-
- /**
- * Set the NamingContext to use.
- *
- * By default @{link org.jboss.webbeans.resources.DefaultNamingContext} will
- * be used
- *
- * @param namingContext
- */
- @Deprecated
- public void setNamingContext(NamingContext namingContext);
-
- /**
- * Set the ResourceLoader to use. By default @{link
- * org.jboss.webbeans.resources.DefaultResourceLoader} will be used
- *
- * @param resourceLoader
- */
- @Deprecated
- public void setResourceLoader(ResourceLoader resourceLoader);
-
- /**
* Set the bean store to use as backing for the application context
*
* @param beanStore the bean store to use
*/
public void setApplicationContext(BeanStore beanStore);
-
+
/**
- * Set the transaction services provider to use.
- *
- * @param transactionServices An implementation of TransactionService
- */
- @Deprecated
- public void setTransactionServices(TransactionServices transactionServices);
-
- /**
* Set the environment in use, by default {@link Environments.EE}
*
* @param environment the environment to use
@@ -131,7 +82,7 @@
/**
* Get the services available to this bootstrap
*
- * @return the services availabel
+ * @return the services available
*/
public ServiceRegistry getServices();
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -22,6 +22,7 @@
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.jpa.spi.JpaServices;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -38,12 +39,12 @@
/**
* Java EE5 or Java EE6
*/
- EE(WebBeanDiscovery.class, EjbServices.class, TransactionServices.class, NamingContext.class, ResourceLoader.class),
+ EE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class, TransactionServices.class, NamingContext.class, ResourceLoader.class),
/**
* Java EE6 Web Profile
*/
- EE_WEB_PROFILE(WebBeanDiscovery.class, EjbServices.class, TransactionServices.class, NamingContext.class, ResourceLoader.class),
+ EE_WEB_PROFILE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class,TransactionServices.class, NamingContext.class, ResourceLoader.class),
/**
* Servlet container such as Tomcat
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -17,12 +17,8 @@
package org.jboss.webbeans.bootstrap.api.helpers;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.manager.api.WebBeansManager;
-import org.jboss.webbeans.resources.spi.NamingContext;
-import org.jboss.webbeans.resources.spi.ResourceLoader;
/**
* Implementation of {@link Bootstrap} which supports the decorator pattern
@@ -54,30 +50,6 @@
delegate().setApplicationContext(beanStore);
}
- @Deprecated
- public void setEjbServices(EjbServices ejbServices)
- {
- delegate().setEjbServices(ejbServices);
- }
-
- @Deprecated
- public void setNamingContext(NamingContext namingContext)
- {
- delegate().setNamingContext(namingContext);
- }
-
- @Deprecated
- public void setResourceLoader(ResourceLoader resourceLoader)
- {
- delegate().setResourceLoader(resourceLoader);
- }
-
- @Deprecated
- public void setWebBeanDiscovery(WebBeanDiscovery webBeanDiscovery)
- {
- delegate().setWebBeanDiscovery(webBeanDiscovery);
- }
-
public void shutdown()
{
delegate().shutdown();
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -24,7 +24,7 @@
/**
* A container should implement this interface to allow the Web Beans RI to
- * resolve EJBs, Resources and JPA persistence units
+ * resolve EJBs, Resources and JPA persistence units and discover EJBs
*
* @author Pete Muir
*
@@ -48,21 +48,6 @@
public Object resolveEjb(InjectionPoint injectionPoint);
/**
- * Resolve the value for the given @PersistenceContext injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the persistence unit
- * @throws IllegalArgumentException
- * if the injection point is not annotated with
- * @PersistenceContext, or, if the injection point is a method that doesn't
- * follow JavaBean conventions
- * @throws IllegalStateException
- * if no suitable persistence units can be resolved for injection
- */
- public Object resolvePersistenceContext(InjectionPoint injectionPoint);
-
- /**
* Resolve the value for the given @Resource injection point
*
* @param injectionPoint
@@ -90,7 +75,7 @@
/**
* Gets a descriptor for each EJB in the application
*
- * @return The bean class to descriptor map
+ * @return the EJB descriptors
*/
public Iterable<EjbDescriptor<?>> discoverEjbs();
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -1,3 +1,19 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.webbeans.ejb.spi.helpers;
import javax.inject.manager.InjectionPoint;
@@ -31,11 +47,6 @@
return delegate().resolveEjb(ejbDescriptor);
}
- public Object resolvePersistenceContext(InjectionPoint injectionPoint)
- {
- return delegate().resolvePersistenceContext(injectionPoint);
- }
-
public Object resolveResource(InjectionPoint injectionPoint)
{
return delegate().resolveResource(injectionPoint);
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -5,6 +5,7 @@
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.jpa.spi.JpaServices;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -33,10 +34,25 @@
bootstrap.getServices().add(NamingContext.class, new MockNamingContext());
bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
- bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+ bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+ bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
bootstrap.initialize();
}
+ @Test(expectedExceptions=IllegalStateException.class)
+ public void testMissingJpaServices()
+ {
+ AbstractBootstrap bootstrap = new MockBootstrap();
+ bootstrap.setEnvironment(Environments.EE);
+ bootstrap.setApplicationContext(new ConcurrentHashMapBeanStore());
+ bootstrap.getServices().add(NamingContext.class, new MockNamingContext());
+ bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
+ bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
+ bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+ bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+ bootstrap.initialize();
+ }
+
@Test
public void testEEEnv()
{
@@ -47,7 +63,8 @@
bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
- bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+ bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+ bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
bootstrap.initialize();
}
@@ -61,7 +78,8 @@
bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
- bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+ bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+ bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
bootstrap.initialize();
}
@@ -74,7 +92,8 @@
bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
bootstrap.setApplicationContext(new ConcurrentHashMapBeanStore());
bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
- bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+ bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+ bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
bootstrap.initialize();
}
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java 2009-03-26 15:41:23 UTC (rev 2213)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java 2009-03-26 17:11:03 UTC (rev 2214)
@@ -1,7 +1,5 @@
package org.jboss.webbeans.bootstrap.api.test;
-import java.lang.annotation.Annotation;
-
import javax.inject.manager.InjectionPoint;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -17,24 +15,6 @@
return null;
}
- public Class<? extends Annotation> getEJBAnnotation()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Class<? extends Annotation> getPersistenceContextAnnotation()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Class<? extends Annotation> getResourceAnnotation()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
{
// TODO Auto-generated method stub
@@ -47,12 +27,6 @@
return null;
}
- public Object resolvePersistenceContext(InjectionPoint injectionPoint)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
public Object resolveResource(InjectionPoint injectionPoint)
{
// TODO Auto-generated method stub
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2213 - tck/trunk/impl/src/main/resources.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-26 11:41:23 -0400 (Thu, 26 Mar 2009)
New Revision: 2213
Modified:
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
highlighting
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-26 07:45:19 UTC (rev 2212)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-26 15:41:23 UTC (rev 2213)
@@ -895,60 +895,46 @@
<section id="3.2.5" title="Simple beans with the @New binding">
<assertion id="a">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has the same bean class</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _the same bean class_.</text>
</assertion>
<assertion id="ba">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has the same bean constructor defined by annotations</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _the same bean constructor defined by annotations_.</text>
</assertion>
<assertion id="bb">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has the same bean initializer methods defined by annotations</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _the same bean initializer methods defined by annotations_.</text>
</assertion>
<assertion id="bc">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has the same injected fields defined by annotations</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _the same injected fields defined by annotations_.</text>
</assertion>
<assertion id="c">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has the same interceptor bindings defined by annotations</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _the same interceptor bindings defined by annotations_.</text>
</assertion>
<assertion id="d">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has scope @Dependent</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _scope @Dependent_.</text>
</assertion>
<assertion id="e">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has deployment type @Standard</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _deployment type @Standard_.</text>
</assertion>
<assertion id="f">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has @javax.inject.New as the only binding</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _(a)javax.inject.New_ as the only binding.</text>
</assertion>
<assertion id="g">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has no bean name</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _no bean name_.</text>
</assertion>
<assertion id="h">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has no stereotypes</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _no stereotypes_.</text>
</assertion>
<assertion id="i">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has no observer methods</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _no observer methods_.</text>
</assertion>
<assertion id="j">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has no producer methods</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _no producer methods_.</text>
</assertion>
<assertion id="k">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has no producer fields</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _no producer fields_.</text>
</assertion>
<assertion id="l">
- <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations.
-Additionally, for each such simple bean, a second simple bean exists which has no disposal methods</text>
+ <text>Every class that satisfies the requirements of Section 3.2.1, "Which Java classes are beans?" is a bean, with scope, deployment type and bindings defined using annotations. Additionally, for each such simple bean, a second simple bean exists which has _no disposal methods_.</text>
</assertion>
</section>
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2212 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-26 03:45:19 -0400 (Thu, 26 Mar 2009)
New Revision: 2212
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/DeploymentTypeDefinitionTest.java
Log:
tests for 2.5.2.a, 2.5.2.c
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/DeploymentTypeDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/DeploymentTypeDefinitionTest.java 2009-03-26 03:53:58 UTC (rev 2211)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/deployment/DeploymentTypeDefinitionTest.java 2009-03-26 07:45:19 UTC (rev 2212)
@@ -1,6 +1,12 @@
package org.jboss.jsr299.tck.tests.definition.deployment;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.util.Arrays;
+import java.util.List;
+
import javax.inject.DeploymentException;
+import javax.inject.DeploymentType;
import javax.inject.Production;
import javax.inject.UnsatisfiedDependencyException;
import javax.inject.manager.Bean;
@@ -21,27 +27,31 @@
@BeansXml("beans.xml")
public class DeploymentTypeDefinitionTest extends AbstractJSR299Test
{
-
- /**
- *
- * TODO This text is not really a testable assertion
- */
- @Test(groups = { "stub", "annotationDefinition", "deploymentType" })
+ @Test(groups = { "annotationDefinition", "deploymentType" })
@SpecAssertion(section = "2.5.2", id = "a")
public void testDeploymentTypeHasCorrectTarget()
{
- assert false;
+ assert getCurrentManager().resolveByType(BlackWidow.class).size() == 1;
+ Bean<BlackWidow> blackWidowSpiderModel = getCurrentManager().resolveByType(BlackWidow.class).iterator().next();
+
+ Target target = blackWidowSpiderModel.getScopeType().getAnnotation(Target.class);
+ List<ElementType> elements = Arrays.asList(target.value());
+ assert elements.contains(ElementType.TYPE);
+ assert elements.contains(ElementType.METHOD);
+ assert elements.contains(ElementType.FIELD);
}
/**
*
* TODO This text is not really a testable assertion
*/
- @Test(groups = { "stub", "annotationDefinition", "deploymentType" })
+ @Test(groups = { "annotationDefinition", "deploymentType" })
@SpecAssertion(section = "2.5.2", id = "c")
public void testDeploymentTypeDeclaresDeploymentTypeAnnotation()
{
- assert false;
+ assert getCurrentManager().resolveByType(BlackWidow.class).size() == 1;
+ Bean<BlackWidow> blackWidowSpiderModel = getCurrentManager().resolveByType(BlackWidow.class).iterator().next();
+ assert blackWidowSpiderModel.getDeploymentType().getAnnotation(DeploymentType.class) != null;
}
@Test(groups = { "deploymentType" })
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2211 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-25 23:53:58 -0400 (Wed, 25 Mar 2009)
New Revision: 2211
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope/AnotherScopeType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope/ScopeDefinitionTest.java
Log:
implement tests for 2.4.2.aa, 2.4.2.b
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope/AnotherScopeType.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope/AnotherScopeType.java 2009-03-26 03:34:01 UTC (rev 2210)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope/AnotherScopeType.java 2009-03-26 03:53:58 UTC (rev 2211)
@@ -2,6 +2,7 @@
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
@@ -10,7 +11,7 @@
import javax.context.ScopeType;
-@Target( { TYPE, METHOD })
+@Target( { TYPE, METHOD, FIELD })
@Retention(RUNTIME)
@Documented
@ScopeType
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope/ScopeDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope/ScopeDefinitionTest.java 2009-03-26 03:34:01 UTC (rev 2210)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/scope/ScopeDefinitionTest.java 2009-03-26 03:53:58 UTC (rev 2211)
@@ -1,8 +1,15 @@
package org.jboss.jsr299.tck.tests.definition.scope;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
import javax.context.ApplicationScoped;
import javax.context.Dependent;
import javax.context.RequestScoped;
+import javax.context.ScopeType;
import javax.inject.manager.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -28,18 +35,26 @@
assert bean.getScopeType().equals(AnotherScopeType.class);
}
- @Test(groups={"stub", "annotationDefinition"})
+ @Test(groups={"annotationDefinition"})
@SpecAssertion(section="2.4.2", id = "aa")
public void testScopeTypeHasCorrectTarget()
{
- assert false;
+ assert getCurrentManager().resolveByType(Mullet.class).size() == 1;
+ Bean<Mullet> bean = getCurrentManager().resolveByType(Mullet.class).iterator().next();
+ Target target = bean.getScopeType().getAnnotation(Target.class);
+ List<ElementType> elements = Arrays.asList(target.value());
+ assert elements.contains(ElementType.TYPE);
+ assert elements.contains(ElementType.METHOD);
+ assert elements.contains(ElementType.FIELD);
}
- @Test(groups={"stub", "annotationDefinition"})
+ @Test(groups={"annotationDefinition"})
@SpecAssertion(section="2.4.2", id = "b")
public void testScopeTypeDeclaresScopeTypeAnnotation()
{
- assert false;
+ assert getCurrentManager().resolveByType(Mullet.class).size() == 1;
+ Bean<Mullet> bean = getCurrentManager().resolveByType(Mullet.class).iterator().next();
+ assert bean.getScopeType().getAnnotation(ScopeType.class) != null;
}
@Test @SpecAssertion(section="2.4.3", id = "a")
@@ -135,7 +150,6 @@
@SpecAssertion(section = "4.1", id = "bc")
public void testScopeTypeDeclaredInheritedIsIndirectlyInherited()
{
-
assert getCurrentManager().resolveByType(EnglishBorderCollie.class).iterator().next().getScopeType().equals(RequestScoped.class);
}
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2210 - tck/trunk/impl/src/main/resources.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-25 23:34:01 -0400 (Wed, 25 Mar 2009)
New Revision: 2210
Modified:
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
remove generalised assertion
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-26 03:08:41 UTC (rev 2209)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-26 03:34:01 UTC (rev 2210)
@@ -2131,9 +2131,7 @@
</section>
<section id="4" title="Inheritance, specialization and realization">
- <assertion id="a">
- <text>By default, Java implementation reuse is assumed</text>
- </assertion>
+
</section>
<section id="4.1" title="Inheritance of type-level metadata">
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2209 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-25 23:08:41 -0400 (Wed, 25 Mar 2009)
New Revision: 2209
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/LameInfertileChicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/AnotherDeploymentType.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/ChickenLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Foo.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/beans.xml
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/ProducerFieldDefinitionTest.java
Log:
tests for 4.2.eb, 4.2.ed
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/LameInfertileChicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/LameInfertileChicken.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/LameInfertileChicken.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition;
+
+@AnotherDeploymentType
+class LameInfertileChicken extends InfertileChicken
+{
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/ProducerFieldDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/ProducerFieldDefinitionTest.java 2009-03-26 02:53:57 UTC (rev 2208)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/ProducerFieldDefinitionTest.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -219,4 +219,11 @@
{
assert !(getCurrentManager().getInstanceByType(Egg.class, FOO_LITERAL).getMother() instanceof InfertileChicken);
}
+
+ @Test(groups = "producerField")
+ @SpecAssertion(section = "4.2", id = "ec")
+ public void testNonStaticProducerFieldNotIndirectlyInherited()
+ {
+ assert !(getCurrentManager().getInstanceByType(Egg.class, FOO_LITERAL).getMother() instanceof LameInfertileChicken);
+ }
}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/AnotherDeploymentType.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/AnotherDeploymentType.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/AnotherDeploymentType.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.DeploymentType;
+
+@Target( { TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+@DeploymentType
+@interface AnotherDeploymentType
+{
+
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+import javax.ejb.Stateful;
+import javax.inject.Produces;
+
+@Stateful
+public class Chicken implements ChickenLocal
+{
+ @Produces @Foo
+ private Egg egg = new Egg(this);
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/ChickenLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/ChickenLocal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/ChickenLocal.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+import javax.ejb.Local;
+
+@Local
+public interface ChickenLocal
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+public class Egg
+{
+
+ private final Chicken mother;
+
+ public Egg(Chicken mother)
+ {
+ super();
+ this.mother = mother;
+ }
+
+ public Chicken getMother()
+ {
+ return mother;
+ }
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,37 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+import java.lang.annotation.Annotation;
+
+import javax.inject.AnnotationLiteral;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.EAR)
+@BeansXml("beans.xml")
+public class EnterpriseProducerFieldDefinitionTest extends AbstractJSR299Test
+{
+ private static final Annotation FOO_LITERAL = new AnnotationLiteral<Foo>() {};
+
+ @Test(groups = {"producerField", "ri-broken"})
+ @SpecAssertion(section = "4.2", id = "eb")
+ public void testNonStaticProducerFieldNotInherited()
+ {
+ assert !(getCurrentManager().getInstanceByType(Egg.class, FOO_LITERAL).getMother() instanceof InfertileChicken);
+ }
+
+ @Test(groups = {"producerField", "ri-broken"})
+ @SpecAssertion(section = "4.2", id = "ed")
+ public void testNonStaticProducerFieldNotIndirectlyInherited()
+ {
+ assert !(getCurrentManager().getInstanceByType(Egg.class, FOO_LITERAL).getMother() instanceof LameInfertileChicken);
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Foo.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Foo.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Foo.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface Foo
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+@AnotherDeploymentType
+public class InfertileChicken extends Chicken implements InfertileChickenLocal
+{
+
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+import javax.ejb.Local;
+
+@Local
+public interface InfertileChickenLocal
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+import javax.ejb.Stateful;
+
+@Stateful
+public class LameInfertileChicken extends InfertileChicken implements LameInfertileChickenLocal
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
+
+import javax.ejb.Local;
+
+@Local
+public interface LameInfertileChickenLocal
+{
+
+}
Added: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/beans.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/beans.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/beans.xml 2009-03-26 03:08:41 UTC (rev 2209)
@@ -0,0 +1,8 @@
+<Beans xmlns="urn:java:ee"
+ xmlns:test="urn:java:org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise">
+ <Deploy>
+ <Standard />
+ <Production />
+ <test:AnotherDeploymentType />
+ </Deploy>
+</Beans>
15 years, 9 months