[webbeans-commits] Webbeans SVN: r3606 - ri/trunk/impl/src/main/java/org/jboss/webbeans and 22 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu Aug 27 09:52:39 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-08-27 09:52:38 -0400 (Thu, 27 Aug 2009)
New Revision: 3606
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/jsf/spi/
ri/trunk/spi/src/main/java/org/jboss/webbeans/messaging/spi/
ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/helpers/
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJSFServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockConversationManager.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJSFServices.java
Modified:
doc/trunk/reference/en-US/ri-spi.xml
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansApplication.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsp/JspInitialization.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.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/MockJpaServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
Log:
WBRI-373, WBRI-352
Modified: doc/trunk/reference/en-US/ri-spi.xml
===================================================================
--- doc/trunk/reference/en-US/ri-spi.xml 2009-08-27 12:43:59 UTC (rev 3605)
+++ doc/trunk/reference/en-US/ri-spi.xml 2009-08-27 13:52:38 UTC (rev 3606)
@@ -384,16 +384,6 @@
</para>
</listitem>
</varlistentry>
- <varlistentry>
- <term><literal>JSFServices.getBeanDeploymentArchive(Application application)</literal></term>
- <listitem>
- <para>
- Identify the WAR in use. The
- <literal>Application</literal> is provided for
- additional context.
- </para>
- </listitem>
- </varlistentry>
</variablelist>
</section>
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -70,7 +70,7 @@
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.context.WBCreationalContext;
import org.jboss.webbeans.el.Namespace;
-import org.jboss.webbeans.el.WebBeansELResolverImpl;
+import org.jboss.webbeans.el.WebBeansELResolver;
import org.jboss.webbeans.introspector.WBAnnotated;
import org.jboss.webbeans.literal.AnyLiteral;
import org.jboss.webbeans.literal.CurrentLiteral;
@@ -405,7 +405,7 @@
this.decoratorResolver = new TypeSafeDecoratorResolver(this, createDynamicAccessibleIterable(Transform.DECORATOR_BEAN));
this.observerResolver = new TypeSafeObserverResolver(this, createDynamicAccessibleIterable(Transform.EVENT_OBSERVER));
this.nameBasedResolver = new NameBasedResolver(this, createDynamicAccessibleIterable(Transform.BEAN));
- this.webbeansELResolver = new WebBeansELResolverImpl(this);
+ this.webbeansELResolver = new WebBeansELResolver(this);
this.childActivities = new CopyOnWriteArraySet<BeanManagerImpl>();
this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -20,13 +20,14 @@
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
import org.jboss.webbeans.injection.FieldInjectionPoint;
+import org.jboss.webbeans.injection.InjectionContextImpl;
import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.util.Beans;
@@ -46,6 +47,10 @@
private final WBMethod<?, ?> postConstruct;
private final WBMethod<?, ?> preDestroy;
private final Set<InjectionPoint> injectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
public SimpleInjectionTarget(WBClass<T> type, BeanManagerImpl beanManager)
{
@@ -62,6 +67,10 @@
this.injectionPoints.addAll(Beans.getParameterInjectionPoints(null, initializerMethods));
this.postConstruct = Beans.getPostConstruct(type);
this.preDestroy = Beans.getPreDestroy(type);
+ this.ejbInjectionPoints = Beans.getEjbInjectionPoints(null, type, beanManager);
+ this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(null, type, beanManager);
+ this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(null, type, beanManager);
+ this.resourceInjectionPoints = Beans.getResourceInjectionPoints(null, type, beanManager);
}
public T produce(CreationalContext<T> ctx)
@@ -69,16 +78,20 @@
return constructor.newInstance(beanManager, ctx);
}
- public void inject(T instance, CreationalContext<T> ctx)
+ public void inject(final T instance, final CreationalContext<T> ctx)
{
- for (FieldInjectionPoint<?, ?> injectionPoint : injectableFields)
+ new InjectionContextImpl<T>(beanManager, this, instance)
{
- injectionPoint.inject(instance, beanManager, ctx);
- }
- for (MethodInjectionPoint<?, ?> injectionPoint : initializerMethods)
- {
- injectionPoint.invoke(instance, beanManager, ctx, CreationException.class);
- }
+
+ public void proceed()
+ {
+ Beans.injectEEFields(instance, beanManager, ejbInjectionPoints, persistenceContextInjectionPoints, persistenceUnitInjectionPoints, resourceInjectionPoints);
+ Beans.injectBoundFields(instance, ctx, beanManager, injectableFields);
+ Beans.callInitializers(instance, ctx, beanManager, initializerMethods);
+ }
+
+ }.run();
+
}
public void postConstruct(T instance)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -31,7 +31,6 @@
import javax.enterprise.context.Dependent;
import javax.enterprise.context.ScopeType;
import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
@@ -200,33 +199,7 @@
{
return Collections.unmodifiableList(decorators);
}
-
- /**
- * Injects bound fields
- *
- * @param instance The instance to inject into
- */
- protected void injectBoundFields(T instance, CreationalContext<T> creationalContext)
- {
- for (FieldInjectionPoint<?, ?> injectableField : injectableFields)
- {
- injectableField.inject(instance, manager, creationalContext);
- }
- }
- /**
- * Calls all initializers of the bean
- *
- * @param instance The bean instance
- */
- protected void callInitializers(T instance, CreationalContext<T> creationalContext)
- {
- for (MethodInjectionPoint<?, ?> initializer : getInitializerMethods())
- {
- initializer.invoke(instance, manager, creationalContext, CreationException.class);
- }
- }
-
public void dispose(T instance)
{
// No-op for class beans
@@ -345,9 +318,17 @@
*/
public Set<? extends MethodInjectionPoint<?, ?>> getInitializerMethods()
{
- return initializerMethods;
+ return Collections.unmodifiableSet(initializerMethods);
}
+ /**
+ * @return the injectableFields
+ */
+ public Set<FieldInjectionPoint<?, ?>> getInjectableFields()
+ {
+ return Collections.unmodifiableSet(injectableFields);
+ }
+
// TODO maybe a better way to expose this?
public Set<String> getSuperclasses()
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -50,6 +50,7 @@
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Proxies;
/**
@@ -332,8 +333,8 @@
public void postConstruct(T instance, CreationalContext<T> creationalContext)
{
- injectBoundFields(instance, creationalContext);
- callInitializers(instance, creationalContext);
+ Beans.injectBoundFields(instance, creationalContext, getManager(), getInjectableFields());
+ Beans.callInitializers(instance, creationalContext, getManager(), getInitializerMethods());
}
public void preDestroy(CreationalContext<T> creationalContext)
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-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -16,8 +16,6 @@
*/
package org.jboss.webbeans.bean;
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
@@ -29,10 +27,8 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.ejb.EJBApiAbstraction;
-import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
-import org.jboss.webbeans.injection.FieldInjectionPoint;
+import org.jboss.webbeans.injection.InjectionContextImpl;
import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBConstructor;
@@ -41,9 +37,6 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
-import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
-import org.jboss.webbeans.persistence.spi.JpaServices;
-import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
@@ -69,7 +62,7 @@
private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
- private HashSet<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
private SimpleBean<?> specializedBean;
@@ -137,11 +130,20 @@
return instance;
}
- public void inject(T instance, CreationalContext<T> ctx)
+ public void inject(final T instance, final CreationalContext<T> ctx)
{
- injectEjbAndCommonFields(instance);
- injectBoundFields(instance, ctx);
- callInitializers(instance, ctx);
+ new InjectionContextImpl<T>(getManager(), this, instance)
+ {
+
+ public void proceed()
+ {
+ Beans.injectEEFields(instance, getManager(), ejbInjectionPoints, persistenceContextInjectionPoints, persistenceUnitInjectionPoints, resourceInjectionPoints);
+ Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
+ Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
+ }
+
+ }.run();
+
}
public void postConstruct(T instance)
@@ -212,87 +214,7 @@
}
}
- protected void initEjbInjectionPoints()
- {
- Class<? extends Annotation> ejbAnnotationType = manager.getServices().get(EJBApiAbstraction.class).EJB_ANNOTATION_CLASS;
- this.ejbInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
- for (WBField<?, ?> field : annotatedItem.getAnnotatedWBFields(ejbAnnotationType))
- {
- this.ejbInjectionPoints.add(FieldInjectionPoint.of(this, field));
- }
- }
-
- protected void initJpaInjectionPoints()
- {
- this.persistenceContextInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
- this.persistenceUnitInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
-
- Class<? extends Annotation> persistenceContextAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_CONTEXT_ANNOTATION_CLASS;
- for (WBField<?, ?> field : annotatedItem.getAnnotatedWBFields(persistenceContextAnnotationType))
- {
- this.persistenceContextInjectionPoints.add(FieldInjectionPoint.of(this, field));
- }
-
- Class<? extends Annotation> persistenceUnitAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_UNIT_ANNOTATION_CLASS;
- for (WBField<?, ?> field : annotatedItem.getAnnotatedWBFields(persistenceUnitAnnotationType))
- {
- this.persistenceUnitInjectionPoints.add(FieldInjectionPoint.of(this, field));
- }
- }
-
- protected void initResourceInjectionPoints()
- {
- Class<? extends Annotation> resourceAnnotationType = manager.getServices().get(EJBApiAbstraction.class).RESOURCE_ANNOTATION_CLASS;
- this.resourceInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
- for (WBField<?, ?> field : annotatedItem.getAnnotatedWBFields(resourceAnnotationType))
- {
- this.resourceInjectionPoints.add(FieldInjectionPoint.of(this, field));
- }
- }
-
/**
- * Injects EJBs and common fields
- */
- protected void injectEjbAndCommonFields(T beanInstance)
- {
- EjbServices ejbServices = manager.getServices().get(EjbServices.class);
- JpaServices jpaServices = manager.getServices().get(JpaServices.class);
- ResourceServices resourceServices = manager.getServices().get(ResourceServices.class);
-
- if (ejbServices != null)
- {
- for (WBInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
- {
- Object ejbInstance = ejbServices.resolveEjb(injectionPoint);
- injectionPoint.inject(beanInstance, ejbInstance);
- }
- }
-
- if (jpaServices != null)
- {
- for (WBInjectionPoint<?, ?> injectionPoint : persistenceContextInjectionPoints)
- {
- Object pcInstance = jpaServices.resolvePersistenceContext(injectionPoint);
- injectionPoint.inject(beanInstance, pcInstance);
- }
- for (WBInjectionPoint<?, ?> injectionPoint : persistenceUnitInjectionPoints)
- {
- Object puInstance = jpaServices.resolvePersistenceUnit(injectionPoint);
- injectionPoint.inject(beanInstance, puInstance);
- }
- }
-
- if (resourceServices != null)
- {
- for (WBInjectionPoint<?, ?> injectionPoint : resourceInjectionPoints)
- {
- Object resourceInstance = resourceServices.resolveResource(injectionPoint);
- injectionPoint.inject(beanInstance, resourceInstance);
- }
- }
- }
-
- /**
* Initializes the bean and its metadata
*/
@Override
@@ -305,21 +227,18 @@
super.initialize(environment);
initPostConstruct();
initPreDestroy();
- if (getManager().getServices().contains(EjbServices.class))
- {
- initEjbInjectionPoints();
- }
- if (getManager().getServices().contains(JpaServices.class))
- {
- initJpaInjectionPoints();
- }
- if (getManager().getServices().contains(ResourceServices.class))
- {
- initResourceInjectionPoints();
- }
+ initEEInjectionPoints();
}
}
+ private void initEEInjectionPoints()
+ {
+ this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
+ }
+
/**
* Validates the type
*/
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -49,17 +49,17 @@
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.jsf.JsfApiAbstraction;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.TypeStore;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
-import org.jboss.webbeans.persistence.spi.JpaServices;
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.DefaultResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.servlet.ServletApiAbstraction;
import org.jboss.webbeans.transaction.spi.TransactionServices;
import org.jboss.webbeans.util.serviceProvider.ServiceLoader;
@@ -166,11 +166,11 @@
{
log.info("EJB services not available. Session beans will be simple beans, CDI-style injection into non-contextual EJBs, injection of remote EJBs and injection of @EJB in simple beans will not be available");
}
- if (!deployment.getServices().contains(JpaServices.class))
+ if (!deployment.getServices().contains(JpaInjectionServices.class))
{
log.info("JPA services not available. Injection of @PersistenceContext will not occur. Entity beans will be discovered as simple beans.");
}
- if (!deployment.getServices().contains(ResourceServices.class))
+ if (!deployment.getServices().contains(ResourceInjectionServices.class))
{
log.info("@Resource injection not available.");
}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java (from rev 3567, ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+import java.util.concurrent.Callable;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.CurrentManager;
+
+/**
+ * An EL-resolver against the named beans
+ *
+ * @author Pete Muir
+ */
+public abstract class AbstractWebBeansELResolver extends ELResolver
+{
+
+ private static final Contextual<?> CONTEXTUAL = new Contextual<Object>()
+ {
+
+ public Object create(CreationalContext<Object> creationalContext)
+ {
+ return null;
+ }
+
+ public void destroy(Object instance, CreationalContext<Object> creationalContext) {}
+
+ };
+
+ protected abstract BeanManagerImpl getManager(ELContext context);
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property)
+ {
+ return null;
+ }
+
+ @Override
+ public Object getValue(final ELContext context, Object base, Object property)
+ {
+ if (property != null)
+ {
+ String propertyString = property.toString();
+ Namespace namespace = null;
+ if (base == null)
+ {
+ if (getManager(context).getRootNamespace().contains(propertyString))
+ {
+ context.setPropertyResolved(true);
+ return getManager(context).getRootNamespace().get(propertyString);
+ }
+ }
+ else if (base instanceof Namespace)
+ {
+ namespace = (Namespace) base;
+ // We're definitely the responsible party
+ context.setPropertyResolved(true);
+ if (namespace.contains(propertyString))
+ {
+ // There is a child namespace
+ return namespace.get(propertyString);
+ }
+ }
+ else
+ {
+ // let the standard EL resolver chain handle the property
+ return null;
+ }
+ final String name;
+ if (namespace != null)
+ {
+ // Try looking in the manager for a bean
+ name = namespace.qualifyName(propertyString);
+ }
+ else
+ {
+ name = propertyString;
+ }
+ Object value = null;
+ try
+ {
+ final Bean<?> bean = getManager(context).resolve(getManager(context).getBeans(name));
+ final ELCreationalContext<?> creationalContext = getCreationalContextStore(context).peek();
+ if (bean != null)
+ {
+ value = creationalContext.putIfAbsent(bean, new Callable<Object>()
+ {
+
+ public Object call() throws Exception
+ {
+ return getManager(context).getReference(bean, creationalContext);
+ }
+
+ });
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error resolving property " + propertyString + " against base " + base, e);
+ }
+ if (value != null)
+ {
+ context.setPropertyResolved(true);
+ return value;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ {
+ return false;
+ }
+
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object value)
+ {
+ }
+
+ private static ELCreationalContextStack getCreationalContextStore(ELContext context)
+ {
+ Object o = context.getContext(ELCreationalContextStack.class);
+
+ if (!(o instanceof ELCreationalContextStack))
+ {
+ ELCreationalContextStack store = ELCreationalContextStack.addToContext(context);
+ o = store;
+ }
+ ELCreationalContextStack store = (ELCreationalContextStack) o;
+ if (store.isEmpty())
+ {
+ // TODO need to use correct manager for module
+ ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
+ store.push(creationalContext);
+ }
+ return (ELCreationalContextStack) o;
+ }
+
+}
+
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.el;
+
+import javax.el.ELContext;
+
+import org.jboss.webbeans.BeanManagerImpl;
+
+/**
+ * @author pmuir
+ *
+ */
+public class WebBeansELResolver extends AbstractWebBeansELResolver
+{
+
+ private final BeanManagerImpl beanManager;
+
+ public WebBeansELResolver(BeanManagerImpl beanManager)
+ {
+ this.beanManager = beanManager;
+ }
+
+ @Override
+ protected BeanManagerImpl getManager(ELContext context)
+ {
+ return beanManager;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,180 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.el;
-
-import java.beans.FeatureDescriptor;
-import java.util.Iterator;
-import java.util.concurrent.Callable;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.CurrentManager;
-
-/**
- * An EL-resolver against the named beans
- *
- * @author Pete Muir
- */
-public class WebBeansELResolverImpl extends ELResolver
-{
-
- private static final Contextual<?> CONTEXTUAL = new Contextual<Object>()
- {
-
- public Object create(CreationalContext<Object> creationalContext)
- {
- return null;
- }
-
- public void destroy(Object instance, CreationalContext<Object> creationalContext) {}
-
- };
-
- private final BeanManagerImpl manager;
-
- public WebBeansELResolverImpl(BeanManagerImpl manager)
- {
- this.manager = manager;
- }
-
- @Override
- public Class<?> getCommonPropertyType(ELContext context, Object base)
- {
- return null;
- }
-
- @Override
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
- {
- return null;
- }
-
- @Override
- public Class<?> getType(ELContext context, Object base, Object property)
- {
- return null;
- }
-
- @Override
- public Object getValue(ELContext context, Object base, Object property)
- {
- if (property != null)
- {
- String propertyString = property.toString();
- Namespace namespace = null;
- if (base == null)
- {
- if (manager.getRootNamespace().contains(propertyString))
- {
- context.setPropertyResolved(true);
- return manager.getRootNamespace().get(propertyString);
- }
- }
- else if (base instanceof Namespace)
- {
- namespace = (Namespace) base;
- // We're definitely the responsible party
- context.setPropertyResolved(true);
- if (namespace.contains(propertyString))
- {
- // There is a child namespace
- return namespace.get(propertyString);
- }
- }
- else
- {
- // let the standard EL resolver chain handle the property
- return null;
- }
- final String name;
- if (namespace != null)
- {
- // Try looking in the manager for a bean
- name = namespace.qualifyName(propertyString);
- }
- else
- {
- name = propertyString;
- }
- Object value = null;
- try
- {
- final Bean<?> bean = manager.resolve(manager.getBeans(name));
- final ELCreationalContext<?> creationalContext = getCreationalContextStore(context).peek();
- if (bean != null)
- {
- value = creationalContext.putIfAbsent(bean, new Callable<Object>()
- {
-
- public Object call() throws Exception
- {
- return manager.getReference(bean, creationalContext);
- }
-
- });
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error resolving property " + propertyString + " against base " + base, e);
- }
- if (value != null)
- {
- context.setPropertyResolved(true);
- return value;
- }
- }
- return null;
- }
-
- @Override
- public boolean isReadOnly(ELContext context, Object base, Object property)
- {
- return false;
- }
-
- @Override
- public void setValue(ELContext context, Object base, Object property, Object value)
- {
- }
-
- private static ELCreationalContextStack getCreationalContextStore(ELContext context)
- {
- Object o = context.getContext(ELCreationalContextStack.class);
-
- if (!(o instanceof ELCreationalContextStack))
- {
- ELCreationalContextStack store = ELCreationalContextStack.addToContext(context);
- o = store;
- }
- ELCreationalContextStack store = (ELCreationalContextStack) o;
- if (store.isEmpty())
- {
- // TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
- store.push(creationalContext);
- }
- return (ELCreationalContextStack) o;
- }
-
-}
-
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,65 @@
+/*
+ * 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.injection;
+
+import javax.enterprise.inject.spi.InjectionTarget;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.injection.spi.InjectionContext;
+import org.jboss.webbeans.injection.spi.InjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class InjectionContextImpl<T> implements InjectionContext<T>
+{
+
+ private final BeanManagerImpl beanManager;
+ private final InjectionTarget<T> injectionTarget;
+ private final T target;
+
+ public InjectionContextImpl(BeanManagerImpl beanManager, InjectionTarget<T> injectionTarget, T target)
+ {
+ this.beanManager = beanManager;
+ this.injectionTarget = injectionTarget;
+ this.target = target;
+ }
+
+ public void run()
+ {
+ if (beanManager.getServices().contains(InjectionServices.class))
+ {
+ beanManager.getServices().get(InjectionServices.class).aroundInject(this);
+ }
+ else
+ {
+ proceed();
+ }
+ }
+
+ public InjectionTarget<T> getInjectionTarget()
+ {
+ return injectionTarget;
+ }
+
+ public T getTarget()
+ {
+ return target;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/InjectionContextImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -17,17 +17,16 @@
package org.jboss.webbeans.jsf;
import javax.enterprise.inject.AnnotationLiteral;
-import javax.faces.application.Application;
import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.conversation.ConversationIdName;
-import org.jboss.webbeans.jsf.spi.JSFServices;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.servlet.ServletHelper;
import org.jboss.webbeans.util.Reflections;
/**
@@ -107,17 +106,14 @@
public static BeanManagerImpl getModuleBeanManager(FacesContext facesContext)
{
- return getModuleBeanManager(facesContext.getApplication());
- }
-
- public static BeanManagerImpl getModuleBeanManager(Application application)
- {
- if (application == null)
+ if (facesContext.getExternalContext().getContext() instanceof ServletContext)
{
- throw new IllegalArgumentException("Must provide the JSF Application");
+ return ServletHelper.getModuleBeanManager((ServletContext) facesContext.getExternalContext().getContext());
}
- BeanDeploymentArchive beanDeploymentArchive = CurrentManager.rootManager().getServices().get(JSFServices.class).getBeanDeploymentArchive(application);
- return CurrentManager.getBeanDeploymentArchives().get(beanDeploymentArchive).getCurrent();
+ else
+ {
+ throw new IllegalStateException("Web Beans doesn not support using JSF in an non-servlet environment");
+ }
}
}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,45 @@
+/*
+ * 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.jsf;
+
+import javax.el.ELContext;
+import javax.faces.context.FacesContext;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.el.AbstractWebBeansELResolver;
+
+/**
+ * @author pmuir
+ *
+ */
+public class JsfWebBeansELResolver extends AbstractWebBeansELResolver
+{
+
+ @Override
+ protected BeanManagerImpl getManager(ELContext context)
+ {
+ if (context.getContext(FacesContext.class) == null)
+ {
+ throw new IllegalStateException("Cannot use " + getClass().getSimpleName() + " outside JSF");
+ }
+ else
+ {
+ return JsfHelper.getModuleBeanManager((FacesContext) context.getContext(FacesContext.class));
+ }
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfWebBeansELResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansApplication.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansApplication.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansApplication.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -23,12 +23,8 @@
import javax.el.ExpressionFactory;
import javax.faces.application.Application;
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.el.WebBeansELContextListener;
-import org.jboss.webbeans.el.WebBeansELResolverImpl;
import org.jboss.webbeans.el.WebBeansExpressionFactory;
-import org.jboss.webbeans.jsf.spi.JSFServices;
/**
* @author pmuir
@@ -47,8 +43,7 @@
this.application = application;
this.elContextListeners = new ArrayList<ELContextListener>();
this.elContextListeners.add(new WebBeansELContextListener());
- BeanDeploymentArchive beanDeploymentArchive = CurrentManager.rootManager().getServices().get(JSFServices.class).getBeanDeploymentArchive(application);
- application.addELResolver(new WebBeansELResolverImpl(CurrentManager.getBeanDeploymentArchives().get(beanDeploymentArchive).getCurrent()));
+ application.addELResolver(new JsfWebBeansELResolver());
}
@Override
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsp/JspInitialization.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsp/JspInitialization.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsp/JspInitialization.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -20,7 +20,6 @@
import javax.servlet.jsp.JspApplicationContext;
import javax.servlet.jsp.JspFactory;
-import org.jboss.webbeans.el.WebBeansELResolverImpl;
import org.jboss.webbeans.servlet.ServletHelper;
/**
@@ -42,7 +41,7 @@
JspApplicationContext jspAppContext = JspFactory.getDefaultFactory().getJspApplicationContext(context);
// register compositeELResolver with JSP
- jspAppContext.addELResolver(new WebBeansELResolverImpl(ServletHelper.getModuleBeanManager(context)));
+ jspAppContext.addELResolver(ServletHelper.getModuleBeanManager(context).getELResolver());
// DOesn't really achieve much :-(
//jspAppContext.addELContextListener(new WebBeansELContextListener());
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -18,6 +18,7 @@
import java.lang.annotation.Annotation;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -26,8 +27,10 @@
import javax.annotation.PreDestroy;
import javax.decorator.Decorates;
import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.BindingType;
+import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.Produces;
@@ -38,10 +41,15 @@
import org.jboss.webbeans.bean.AbstractProducerBean;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
import org.jboss.webbeans.injection.FieldInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBConstructor;
import org.jboss.webbeans.introspector.WBField;
@@ -51,6 +59,7 @@
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.cache.BindingTypeModel;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
/**
* Helper class for bean inspection
@@ -179,6 +188,79 @@
}
}
+
+ public static Set<WBInjectionPoint<?, ?>> getEjbInjectionPoints(Bean<?> declaringBean, WBClass<?> type, BeanManagerImpl manager)
+ {
+ if (manager.getServices().contains(EjbInjectionServices.class))
+ {
+ Class<? extends Annotation> ejbAnnotationType = manager.getServices().get(EJBApiAbstraction.class).EJB_ANNOTATION_CLASS;
+ Set<WBInjectionPoint<?, ?>> ejbInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ for (WBField<?, ?> field : type.getAnnotatedWBFields(ejbAnnotationType))
+ {
+ ejbInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
+ }
+ return ejbInjectionPoints;
+ }
+ else
+ {
+ return Collections.emptySet();
+ }
+ }
+
+ public static Set<WBInjectionPoint<?, ?>> getPersistenceContextInjectionPoints(Bean<?> declaringBean, WBClass<?> type, BeanManagerImpl manager)
+ {
+ if (manager.getServices().contains(JpaInjectionServices.class))
+ {
+ Set<WBInjectionPoint<?, ?>> jpaInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ Class<? extends Annotation> persistenceContextAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_CONTEXT_ANNOTATION_CLASS;
+ for (WBField<?, ?> field : type.getAnnotatedWBFields(persistenceContextAnnotationType))
+ {
+ jpaInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
+ }
+ return jpaInjectionPoints;
+ }
+ else
+ {
+ return Collections.emptySet();
+ }
+ }
+
+ public static Set<WBInjectionPoint<?, ?>> getPersistenceUnitInjectionPoints(Bean<?> declaringBean, WBClass<?> type, BeanManagerImpl manager)
+ {
+ if (manager.getServices().contains(JpaInjectionServices.class))
+ {
+ Set<WBInjectionPoint<?, ?>> jpaInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ Class<? extends Annotation> persistenceUnitAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_UNIT_ANNOTATION_CLASS;
+ for (WBField<?, ?> field : type.getAnnotatedWBFields(persistenceUnitAnnotationType))
+ {
+ jpaInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
+ }
+ return jpaInjectionPoints;
+ }
+ else
+ {
+ return Collections.emptySet();
+ }
+ }
+
+ public static Set<WBInjectionPoint<?, ?>> getResourceInjectionPoints(Bean<?> declaringBean, WBClass<?> type, BeanManagerImpl manager)
+ {
+ if (manager.getServices().contains(ResourceInjectionServices.class))
+ {
+ Class<? extends Annotation> resourceAnnotationType = manager.getServices().get(EJBApiAbstraction.class).RESOURCE_ANNOTATION_CLASS;
+ Set<WBInjectionPoint<?, ?>> resourceInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ for (WBField<?, ?> field : type.getAnnotatedWBFields(resourceAnnotationType))
+ {
+ resourceInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
+ }
+ return resourceInjectionPoints;
+ }
+ else
+ {
+ return Collections.emptySet();
+ }
+ }
+
public static Set<MethodInjectionPoint<?, ?>> getInitializerMethods(Bean<?> declaringBean, WBClass<?> type)
{
Set<MethodInjectionPoint<?, ?>> initializerMethods = new HashSet<MethodInjectionPoint<?, ?>>();
@@ -407,4 +489,73 @@
}
}
+ /**
+ * Injects EJBs and common fields
+ */
+ public static <T> void injectEEFields(T beanInstance, BeanManagerImpl manager, Iterable<WBInjectionPoint<?, ?>> ejbInjectionPoints, Iterable<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints, Iterable<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints, Iterable<WBInjectionPoint<?, ?>> resourceInjectionPoints)
+ {
+ EjbInjectionServices ejbServices = manager.getServices().get(EjbInjectionServices.class);
+ JpaInjectionServices jpaServices = manager.getServices().get(JpaInjectionServices.class);
+ ResourceInjectionServices resourceServices = manager.getServices().get(ResourceInjectionServices.class);
+
+ if (ejbServices != null)
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
+ {
+ Object ejbInstance = ejbServices.resolveEjb(injectionPoint);
+ injectionPoint.inject(beanInstance, ejbInstance);
+ }
+ }
+
+ if (jpaServices != null)
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : persistenceContextInjectionPoints)
+ {
+ Object pcInstance = jpaServices.resolvePersistenceContext(injectionPoint);
+ injectionPoint.inject(beanInstance, pcInstance);
+ }
+ for (WBInjectionPoint<?, ?> injectionPoint : persistenceUnitInjectionPoints)
+ {
+ Object puInstance = jpaServices.resolvePersistenceUnit(injectionPoint);
+ injectionPoint.inject(beanInstance, puInstance);
+ }
+ }
+
+ if (resourceServices != null)
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : resourceInjectionPoints)
+ {
+ Object resourceInstance = resourceServices.resolveResource(injectionPoint);
+ injectionPoint.inject(beanInstance, resourceInstance);
+ }
+ }
+ }
+
+
+ /**
+ * Injects bound fields
+ *
+ * @param instance The instance to inject into
+ */
+ public static <T> void injectBoundFields(T instance, CreationalContext<T> creationalContext, BeanManagerImpl manager, Iterable<FieldInjectionPoint<?, ?>> injectableFields)
+ {
+ for (FieldInjectionPoint<?, ?> injectableField : injectableFields)
+ {
+ injectableField.inject(instance, manager, creationalContext);
+ }
+ }
+
+ /**
+ * Calls all initializers of the bean
+ *
+ * @param instance The bean instance
+ */
+ public static <T> void callInitializers(T instance, CreationalContext<T> creationalContext, BeanManagerImpl manager, Iterable<? extends MethodInjectionPoint<?, ?>> initializerMethods)
+ {
+ for (MethodInjectionPoint<?, ?> initializer : initializerMethods)
+ {
+ initializer.invoke(instance, manager, creationalContext, CreationException.class);
+ }
+ }
+
}
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-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -20,10 +20,11 @@
import java.util.Set;
import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-import org.jboss.webbeans.persistence.spi.JpaServices;
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+import org.jboss.webbeans.injection.spi.InjectionServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.security.spi.SecurityServices;
import org.jboss.webbeans.servlet.api.ServletServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -40,19 +41,44 @@
/**
* Java EE5 or Java EE6
+ *
+ * In this environment, Web Beans requires that {@link JpaInjectionServices},
+ * {@link ResourceInjectionServices} and {@link EjbInjectionServices} are
+ * present, and so will perform EE-style field injection on managed beans
+ * itself
*/
+ EE_INJECT(new EnvironmentBuilder()
+ .addRequiredDeploymentService(TransactionServices.class)
+ .addRequiredDeploymentService(ResourceLoader.class)
+ .addRequiredDeploymentService(SecurityServices.class)
+ .addRequiredDeploymentService(ValidationServices.class)
+ .addRequiredDeploymentService(ServletServices.class)
+ .addRequiredDeploymentService(EjbServices.class)
+ .addRequiredBeanDeploymentArchiveService(JpaInjectionServices.class)
+ .addRequiredBeanDeploymentArchiveService(ResourceInjectionServices.class)
+ .addRequiredBeanDeploymentArchiveService(EjbInjectionServices.class)
+ ),
+
+ /**
+ * Java EE5 or Java EE6
+ *
+ * In this environment, Web Beans requires that {@link InjectionServices} are
+ * present, and expects the container to use this callback to perform EE-style
+ * injection
+ *
+ */
EE(new EnvironmentBuilder()
.addRequiredDeploymentService(TransactionServices.class)
.addRequiredDeploymentService(ResourceLoader.class)
.addRequiredDeploymentService(SecurityServices.class)
.addRequiredDeploymentService(ValidationServices.class)
.addRequiredDeploymentService(ServletServices.class)
- .addRequiredDeploymentService(JSFServices.class)
- .addRequiredBeanDeploymentArchiveService(JpaServices.class)
- .addRequiredBeanDeploymentArchiveService(ResourceServices.class)
- .addRequiredBeanDeploymentArchiveService(EjbServices.class)
+ .addRequiredDeploymentService(EjbServices.class)
+ .addRequiredBeanDeploymentArchiveService(InjectionServices.class)
),
+
+
/**
* Servlet container such as Tomcat
*/
@@ -94,29 +120,29 @@
private final Set<Class<? extends Service>> requiredBeanDeploymentArchiveServices;
- public EnvironmentBuilder()
+ private EnvironmentBuilder()
{
this.requiredBeanDeploymentArchiveServices = new HashSet<Class<? extends Service>>();
this.requiredDeploymentServices = new HashSet<Class<? extends Service>>();
}
- public Set<Class<? extends Service>> getRequiredBeanDeploymentArchiveServices()
+ private Set<Class<? extends Service>> getRequiredBeanDeploymentArchiveServices()
{
return requiredBeanDeploymentArchiveServices;
}
- public Set<Class<? extends Service>> getRequiredDeploymentServices()
+ private Set<Class<? extends Service>> getRequiredDeploymentServices()
{
return requiredDeploymentServices;
}
- public EnvironmentBuilder addRequiredDeploymentService(Class<? extends Service> service)
+ private EnvironmentBuilder addRequiredDeploymentService(Class<? extends Service> service)
{
this.requiredDeploymentServices.add(service);
return this;
}
- public EnvironmentBuilder addRequiredBeanDeploymentArchiveService(Class<? extends Service> service)
+ private EnvironmentBuilder addRequiredBeanDeploymentArchiveService(Class<? extends Service> service)
{
this.requiredBeanDeploymentArchiveServices.add(service);
return this;
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-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -17,8 +17,6 @@
package org.jboss.webbeans.ejb.spi;
-import javax.enterprise.inject.spi.InjectionPoint;
-
import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -33,20 +31,6 @@
{
/**
- * Resolve the value for the given @EJB injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the EJB
- * @throws IllegalArgumentException
- * if the injection point is not annotated with @EJB, or, if the
- * injection point is a method that doesn't follow JavaBean
- * conventions
-
- */
- public Object resolveEjb(InjectionPoint injectionPoint);
-
- /**
* Request a reference to an EJB session object from the container. If the
* EJB being resolved is a stateful session bean, the container should ensure
* the session bean is created before this method returns.
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-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -16,8 +16,6 @@
*/
package org.jboss.webbeans.ejb.spi.helpers;
-import javax.enterprise.inject.spi.InjectionPoint;
-
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
@@ -37,11 +35,6 @@
public abstract EjbServices delegate();
- public Object resolveEjb(InjectionPoint injectionPoint)
- {
- return delegate().resolveEjb(injectionPoint);
- }
-
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
{
return delegate().resolveEjb(ejbDescriptor);
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,48 @@
+/*
+ * 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.injection.spi;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow Web Beans to
+ * resolve EJB
+ *
+ * @author Pete Muir
+ *
+ */
+public interface EjbInjectionServices extends Service
+{
+
+ /**
+ * Resolve the value for the given @EJB injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the EJB
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with @EJB, or, if the
+ * injection point is a method that doesn't follow JavaBean
+ * conventions
+
+ */
+ public Object resolveEjb(InjectionPoint injectionPoint);
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,34 @@
+/*
+ * 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.injection.spi;
+
+import javax.enterprise.inject.spi.InjectionTarget;
+
+/**
+ * @author pmuir
+ *
+ */
+public interface InjectionContext<T>
+{
+
+ public void proceed();
+
+ public T getTarget();
+
+ public InjectionTarget<T> getInjectionTarget();
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.injection.spi;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * Provides callbacks to the container when Web Beans performs injection on an
+ * InjectionTarget, managed bean or session bean
+ *
+ * This service may be used to provide EE-style injection.
+ *
+ * @author pmuir
+ *
+ */
+public interface InjectionServices extends Service
+{
+
+ /**
+ * Callback for injection.
+ *
+ * Call {@link InjectionContext#proceed()} to cause CDI-style injection to
+ * occur.
+ *
+ * @param injectionContext
+ */
+ public <T> void aroundInject(InjectionContext<T> injectionContext);
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java (from rev 3593, ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,65 @@
+/*
+ * 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.injection.spi;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+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 JpaInjectionServices extends Service
+{
+
+ /**
+ * Resolve the value for the given @PersistenceContext injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the entity manager
+ * @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 EntityManager resolvePersistenceContext(InjectionPoint injectionPoint);
+
+ /**
+ * Resolve the value for the given @PersistenceUnit injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the entity manager
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with
+ * @PersistenceUnit, 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 EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint);
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java (from rev 3593, ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,61 @@
+/*
+ * 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.injection.spi;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow the Web Beans RI to
+ * resolve Resources
+ *
+ * @author Pete Muir
+ *
+ */
+public interface ResourceInjectionServices extends Service
+{
+
+ /**
+ * Resolve the value for the given @Resource injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the resource
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with @Resource, or, if
+ * the injection point is a method that doesn't follow JavaBean
+ * conventions
+ * @throws IllegalStateException
+ * if no resource can be resolved for injection
+ */
+ public Object resolveResource(InjectionPoint injectionPoint);
+
+ /**
+ * Resolve the value for the given JNDI name and mapped name
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the resource
+ * @throws IllegalStateException
+ * if no resource can be resolved for injection
+ * @throws IllegalArgumentException
+ * if both jndiName and mappedName are null
+ */
+ public Object resolveResource(String jndiName, String mappedName);
+
+}
\ No newline at end of file
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java (from rev 3567, ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,124 @@
+package org.jboss.webbeans.injection.spi.helpers;
+
+import java.beans.Introspector;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+public abstract class AbstractResourceServices
+{
+
+ private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
+
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.resources.spi.helpers.ResourceServices#resolveResource(javax.inject.manager.InjectionPoint)
+ */
+ public Object resolveResource(InjectionPoint injectionPoint)
+ {
+ if (!injectionPoint.getAnnotated().isAnnotationPresent(Resource.class))
+ {
+ throw new IllegalArgumentException("No @Resource annotation found on injection point " + injectionPoint);
+ }
+ if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1)
+ {
+ throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (must have exactly one parameter) " + injectionPoint);
+ }
+ String name = getResourceName(injectionPoint);
+ try
+ {
+ return getContext().lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Error looking up " + name + " in JNDI", e);
+ }
+ }
+
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ String name = getResourceName(jndiName, mappedName);
+ try
+ {
+ return getContext().lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Error looking up " + name + " in JNDI", e);
+ }
+ }
+
+ protected String getResourceName(String jndiName, String mappedName)
+ {
+ if (mappedName != null)
+ {
+ return mappedName;
+ }
+ else if (jndiName != null)
+ {
+ return jndiName;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Both jndiName and mappedName are null");
+ }
+ }
+
+ protected abstract Context getContext();
+
+ protected String getResourceName(InjectionPoint injectionPoint)
+ {
+ Resource resource = injectionPoint.getAnnotated().getAnnotation(Resource.class);
+ String mappedName = resource.mappedName();
+ if (!mappedName.equals(""))
+ {
+ return mappedName;
+ }
+ String name = resource.name();
+ if (!name.equals(""))
+ {
+ return RESOURCE_LOOKUP_PREFIX + "/" + name;
+ }
+ String propertyName;
+ if (injectionPoint.getMember() instanceof Field)
+ {
+ propertyName = injectionPoint.getMember().getName();
+ }
+ else if (injectionPoint.getMember() instanceof Method)
+ {
+ propertyName = getPropertyName((Method) injectionPoint.getMember());
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (unable to determine property name) " + injectionPoint);
+ }
+ }
+ else
+ {
+ throw new AssertionError("Unable to inject into " + injectionPoint);
+ }
+ String className = injectionPoint.getMember().getDeclaringClass().getName();
+ return RESOURCE_LOOKUP_PREFIX + "/" + className + "/" + propertyName;
+ }
+
+ public static String getPropertyName(Method method)
+ {
+ String methodName = method.getName();
+ if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0)
+ {
+ return Introspector.decapitalize(methodName.substring(3));
+ }
+ else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0)
+ {
+ return Introspector.decapitalize(methodName.substring(2));
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java (from rev 3593, ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/helpers/ForwardingJpaServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingJpaInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.injection.spi.helpers;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+
+/**
+ * An implementation of {@link JpaInjectionServices} which forwards all its method calls
+ * to another {@link JpaInjectionServices}}. Subclasses should override one or more
+ * methods to modify the behavior of the backing {@link JpaInjectionServices} as desired
+ * per the <a
+ * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class ForwardingJpaInjectionServices implements JpaInjectionServices
+{
+
+ protected abstract JpaInjectionServices delegate();
+
+ public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint)
+ {
+ return delegate().resolvePersistenceContext(injectionPoint);
+ }
+
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint)
+ {
+ return delegate().resolvePersistenceUnit(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/injection/spi/helpers/ForwardingJpaInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java (from rev 3593, ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java)
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.injection.spi.helpers;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
+
+public abstract class ForwardingResourceInjectionServices implements ResourceInjectionServices
+{
+
+ protected abstract ResourceInjectionServices delegate();
+
+ public Object resolveResource(InjectionPoint injectionPoint)
+ {
+ return delegate().resolveResource(injectionPoint);
+ }
+
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ return delegate().resolveResource(jndiName, mappedName);
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/ForwardingResourceInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,61 +0,0 @@
-/*
- * 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.resources.spi;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.webbeans.bootstrap.api.Service;
-
-/**
- * A container should implement this interface to allow the Web Beans RI to
- * resolve Resources
- *
- * @author Pete Muir
- *
- */
-public interface ResourceServices extends Service
-{
-
- /**
- * Resolve the value for the given @Resource injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the resource
- * @throws IllegalArgumentException
- * if the injection point is not annotated with @Resource, or, if
- * the injection point is a method that doesn't follow JavaBean
- * conventions
- * @throws IllegalStateException
- * if no resource can be resolved for injection
- */
- public Object resolveResource(InjectionPoint injectionPoint);
-
- /**
- * Resolve the value for the given JNDI name and mapped name
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the resource
- * @throws IllegalStateException
- * if no resource can be resolved for injection
- * @throws IllegalArgumentException
- * if both jndiName and mappedName are null
- */
- public Object resolveResource(String jndiName, String mappedName);
-
-}
\ No newline at end of file
Deleted: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,124 +0,0 @@
-package org.jboss.webbeans.resources.spi.helpers;
-
-import java.beans.Introspector;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import javax.annotation.Resource;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-public abstract class AbstractResourceServices
-{
-
- private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
-
- /* (non-Javadoc)
- * @see org.jboss.webbeans.resources.spi.helpers.ResourceServices#resolveResource(javax.inject.manager.InjectionPoint)
- */
- public Object resolveResource(InjectionPoint injectionPoint)
- {
- if (!injectionPoint.getAnnotated().isAnnotationPresent(Resource.class))
- {
- throw new IllegalArgumentException("No @Resource annotation found on injection point " + injectionPoint);
- }
- if (injectionPoint.getMember() instanceof Method && ((Method) injectionPoint.getMember()).getParameterTypes().length != 1)
- {
- throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (must have exactly one parameter) " + injectionPoint);
- }
- String name = getResourceName(injectionPoint);
- try
- {
- return getContext().lookup(name);
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Error looking up " + name + " in JNDI", e);
- }
- }
-
- public Object resolveResource(String jndiName, String mappedName)
- {
- String name = getResourceName(jndiName, mappedName);
- try
- {
- return getContext().lookup(name);
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Error looking up " + name + " in JNDI", e);
- }
- }
-
- protected String getResourceName(String jndiName, String mappedName)
- {
- if (mappedName != null)
- {
- return mappedName;
- }
- else if (jndiName != null)
- {
- return jndiName;
- }
- else
- {
- throw new IllegalArgumentException("Both jndiName and mappedName are null");
- }
- }
-
- protected abstract Context getContext();
-
- protected String getResourceName(InjectionPoint injectionPoint)
- {
- Resource resource = injectionPoint.getAnnotated().getAnnotation(Resource.class);
- String mappedName = resource.mappedName();
- if (!mappedName.equals(""))
- {
- return mappedName;
- }
- String name = resource.name();
- if (!name.equals(""))
- {
- return RESOURCE_LOOKUP_PREFIX + "/" + name;
- }
- String propertyName;
- if (injectionPoint.getMember() instanceof Field)
- {
- propertyName = injectionPoint.getMember().getName();
- }
- else if (injectionPoint.getMember() instanceof Method)
- {
- propertyName = getPropertyName((Method) injectionPoint.getMember());
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Injection point represents a method which doesn't follow JavaBean conventions (unable to determine property name) " + injectionPoint);
- }
- }
- else
- {
- throw new AssertionError("Unable to inject into " + injectionPoint);
- }
- String className = injectionPoint.getMember().getDeclaringClass().getName();
- return RESOURCE_LOOKUP_PREFIX + "/" + className + "/" + propertyName;
- }
-
- public static String getPropertyName(Method method)
- {
- String methodName = method.getName();
- if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0)
- {
- return Introspector.decapitalize(methodName.substring(3));
- }
- else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0)
- {
- return Introspector.decapitalize(methodName.substring(2));
- }
- else
- {
- return null;
- }
-
- }
-
-}
Deleted: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,22 +0,0 @@
-package org.jboss.webbeans.resources.spi.helpers;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.webbeans.resources.spi.ResourceServices;
-
-public abstract class ForwardingResourceServices implements ResourceServices
-{
-
- protected abstract ResourceServices delegate();
-
- public Object resolveResource(InjectionPoint injectionPoint)
- {
- return delegate().resolveResource(injectionPoint);
- }
-
- public Object resolveResource(String jndiName, String mappedName)
- {
- return delegate().resolveResource(jndiName, mappedName);
- }
-
-}
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-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -7,10 +7,10 @@
import org.jboss.webbeans.bootstrap.api.test.MockDeployment.MockBeanDeploymentArchive;
import org.jboss.webbeans.bootstrap.spi.Deployment;
import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-import org.jboss.webbeans.persistence.spi.JpaServices;
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.security.spi.SecurityServices;
import org.jboss.webbeans.servlet.api.ServletServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -31,138 +31,140 @@
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
-
+
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingJpaServices()
+ public void testMissingEjbInjectionServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
+ ServiceRegistry bdaServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
- ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingSecurityServices()
+ public void testMissingJpaServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
+ deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingValidationServices()
+ public void testMissingSecurityServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
- deploymentServices.add(SecurityServices.class, new MockSecurityServices());
+ deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
- @Test
- public void testEEEnv()
+ @Test(expectedExceptions = IllegalStateException.class)
+ public void testMissingValidationServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
- deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
- @Test(expectedExceptions = IllegalStateException.class)
- public void testMissingTxServices()
+ @Test
+ public void testEEEnv()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
+ deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingResourceServices()
+ public void testMissingTxServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
deploymentServices.add(ResourceLoader.class, new MockResourceLoader());
- deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
- public void testMissingJSFServices()
+ public void testMissingResourceServices()
{
Bootstrap bootstrap = new MockBootstrap();
ServiceRegistry deploymentServices = new SimpleServiceRegistry();
@@ -171,14 +173,14 @@
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
deploymentServices.add(ServletServices.class, new MockServletServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test(expectedExceptions = IllegalStateException.class)
@@ -190,15 +192,15 @@
deploymentServices.add(TransactionServices.class, new MockTransactionServices());
deploymentServices.add(SecurityServices.class, new MockSecurityServices());
deploymentServices.add(ValidationServices.class, new MockValidationServices());
- deploymentServices.add(JSFServices.class, new MockJSFServices());
+ deploymentServices.add(EjbServices.class, new MockEjbServices());
ServiceRegistry bdaServices = new SimpleServiceRegistry();
- bdaServices.add(EjbServices.class, new MockEjbServices());
- bdaServices.add(JpaServices.class, new MockJpaServices());
- bdaServices.add(ResourceServices.class, new MockResourceServices());
+ bdaServices.add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ bdaServices.add(JpaInjectionServices.class, new MockJpaServices());
+ bdaServices.add(ResourceInjectionServices.class, new MockResourceServices());
Deployment deployment = new MockDeployment(deploymentServices, new MockBeanDeploymentArchive(bdaServices));
- bootstrap.startContainer(Environments.EE, deployment, null);
+ bootstrap.startContainer(Environments.EE_INJECT, deployment, null);
}
@Test
Added: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java (rev 0)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bootstrap.api.test;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockEjbInjectionServices implements EjbInjectionServices
+{
+
+ public Object resolveEjb(InjectionPoint injectionPoint)
+ {
+ return null;
+ }
+
+}
Property changes on: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJSFServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJSFServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJSFServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bootstrap.api.test;
-
-import javax.faces.application.Application;
-
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-
-/**
- * @author pmuir
- *
- */
-public class MockJSFServices implements JSFServices
-{
-
- public BeanDeploymentArchive getBeanDeploymentArchive(Application application)
- {
- return null;
- }
-
-}
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-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -6,9 +6,9 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import org.jboss.webbeans.persistence.spi.JpaServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
-public class MockJpaServices implements JpaServices
+public class MockJpaServices implements JpaInjectionServices
{
public Collection<Class<?>> discoverEntities()
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -2,9 +2,9 @@
import javax.enterprise.inject.spi.InjectionPoint;
-import org.jboss.webbeans.resources.spi.ResourceServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
-public class MockResourceServices implements ResourceServices
+public class MockResourceServices implements ResourceInjectionServices
{
public Object resolveResource(InjectionPoint injectionPoint)
Deleted: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockConversationManager.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockConversationManager.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockConversationManager.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,31 +0,0 @@
-/*
- * 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.mock;
-
-import org.jboss.webbeans.conversation.ServletConversationManager;
-
-/**
- * Mock of a conversation manager without servlet dependencies
- *
- * @author Nicklas Karlsson
- *
- */
-// TODO dummy
-public class MockConversationManager extends ServletConversationManager
-{
-
-}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -19,9 +19,9 @@
import org.jboss.webbeans.bootstrap.api.Environment;
import org.jboss.webbeans.bootstrap.api.Environments;
import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-import org.jboss.webbeans.persistence.spi.JpaServices;
-import org.jboss.webbeans.resources.spi.ResourceServices;
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
import org.jboss.webbeans.security.spi.SecurityServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
import org.jboss.webbeans.validation.spi.ValidationServices;
@@ -37,15 +37,15 @@
getDeployment().getServices().add(TransactionServices.class, MOCK_TRANSACTION_SERVICES);
getDeployment().getServices().add(SecurityServices.class, new MockSecurityServices());
getDeployment().getServices().add(ValidationServices.class, new MockValidationServices());
- getDeployment().getServices().add(JSFServices.class, new MockJSFServices());
- getDeployment().getArchive().getServices().add(EjbServices.class, new MockEjBServices());
- getDeployment().getArchive().getServices().add(JpaServices.class, new MockJpaServices(getDeployment()));
- getDeployment().getArchive().getServices().add(ResourceServices.class, new MockResourceServices());
+ getDeployment().getServices().add(EjbServices.class, new MockEjBServices());
+ getDeployment().getArchive().getServices().add(EjbInjectionServices.class, new MockEjbInjectionServices());
+ getDeployment().getArchive().getServices().add(JpaInjectionServices.class, new MockJpaServices(getDeployment()));
+ getDeployment().getArchive().getServices().add(ResourceInjectionServices.class, new MockResourceServices());
}
public Environment getEnvironment()
{
- return Environments.EE;
+ return Environments.EE_INJECT;
}
}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -3,8 +3,6 @@
*/
package org.jboss.webbeans.mock;
-import java.util.Collection;
-
import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -14,20 +12,7 @@
public class MockEjBServices implements EjbServices
{
- public Object resolveEjb(InjectionPoint injectionPoint)
- {
- return null;
- }
- public void removeEjb(Collection<Object> instance)
- {
- // No-op
- }
-
- public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
- {
- return null;
- }
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
{
Added: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java (rev 0)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,35 @@
+/*
+ * 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.mock;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.injection.spi.EjbInjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockEjbInjectionServices implements EjbInjectionServices
+{
+
+ public Object resolveEjb(InjectionPoint injectionPoint)
+ {
+ return null;
+ }
+
+}
Property changes on: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJSFServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJSFServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJSFServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -1,36 +0,0 @@
-/*
- * 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.mock;
-
-import javax.faces.application.Application;
-
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.webbeans.jsf.spi.JSFServices;
-
-/**
- * @author pmuir
- *
- */
-public class MockJSFServices implements JSFServices
-{
-
- public BeanDeploymentArchive getBeanDeploymentArchive(Application application)
- {
- return null;
- }
-
-}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -14,9 +14,9 @@
import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.bootstrap.spi.Deployment;
-import org.jboss.webbeans.persistence.spi.JpaServices;
+import org.jboss.webbeans.injection.spi.JpaInjectionServices;
-public class MockJpaServices implements JpaServices
+public class MockJpaServices implements JpaInjectionServices
{
private final Deployment deployment;
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-08-27 12:43:59 UTC (rev 3605)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -18,13 +18,13 @@
import javax.enterprise.inject.spi.InjectionPoint;
-import org.jboss.webbeans.resources.spi.ResourceServices;
+import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
/**
* @author Pete Muir
*
*/
-public class MockResourceServices implements ResourceServices
+public class MockResourceServices implements ResourceInjectionServices
{
public Object resolveResource(InjectionPoint injectionPoint)
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,82 @@
+/*
+ * 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.test.unit.bootstrap;
+
+import org.jboss.webbeans.injection.spi.InjectionContext;
+import org.jboss.webbeans.injection.spi.InjectionServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class CheckableInjectionServices implements InjectionServices
+{
+
+ private boolean before = false;
+ private boolean after = false;
+ private boolean injectedAfter = false;
+ private boolean injectionTargetCorrect = false;
+
+ public <T> void aroundInject(InjectionContext<T> injectionContext)
+ {
+ before = true;
+ if (injectionContext.getTarget() instanceof Foo)
+ {
+ ((Foo) injectionContext.getTarget()).message = "hi!";
+ if (injectionContext.getInjectionTarget().getInjectionPoints().size() == 1)
+ {
+ injectionTargetCorrect = injectionContext.getInjectionTarget().getInjectionPoints().iterator().next().getType().equals(Bar.class);
+ }
+ }
+ injectionContext.proceed();
+ after = true;
+ if (injectionContext.getTarget() instanceof Foo)
+ {
+ Foo foo = (Foo) injectionContext.getTarget();
+ injectedAfter = foo.getBar() instanceof Bar && foo.getMessage().equals("hi!");
+ }
+ }
+
+ public void reset()
+ {
+ before = false;
+ after = false;
+ injectedAfter = false;
+ injectionTargetCorrect = false;
+ }
+
+ public boolean isBefore()
+ {
+ return before;
+ }
+
+ public boolean isAfter()
+ {
+ return after;
+ }
+
+ public boolean isInjectedAfter()
+ {
+ return injectedAfter;
+ }
+
+ public boolean isInjectionTargetCorrect()
+ {
+ return injectionTargetCorrect;
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java 2009-08-27 13:52:38 UTC (rev 3606)
@@ -0,0 +1,47 @@
+package org.jboss.webbeans.test.unit.bootstrap;
+
+import java.util.Arrays;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.webbeans.injection.spi.InjectionServices;
+import org.jboss.webbeans.mock.MockEELifecycle;
+import org.testng.annotations.Test;
+
+public class InjectionServicesTest
+{
+
+ @Test
+ public void testDiscoverFails()
+ {
+ MockEELifecycle lifecycle = new MockEELifecycle();
+ lifecycle.getDeployment().getArchive().setBeanClasses(Arrays.asList(Foo.class, Bar.class));
+ CheckableInjectionServices ijs = new CheckableInjectionServices();
+ lifecycle.getDeployment().getArchive().getServices().add(InjectionServices.class, ijs);
+ lifecycle.initialize();
+ lifecycle.beginApplication();
+ lifecycle.beginSession();
+ lifecycle.beginRequest();
+
+ BeanManager manager = lifecycle.getBootstrap().getManager(lifecycle.getDeployment().getArchive());
+
+ Bean<? extends Object> bean = manager.resolve(manager.getBeans(Foo.class));
+ ijs.reset();
+ Foo foo = (Foo) manager.getReference(bean, Foo.class, manager.createCreationalContext(bean));
+
+ assert ijs.isBefore();
+ assert ijs.isAfter();
+ assert ijs.isInjectedAfter();
+ assert ijs.isInjectionTargetCorrect();
+
+ assert foo.getBar() != null;
+ assert foo.getMessage().equals("hi!");
+
+
+ lifecycle.endRequest();
+ lifecycle.endSession();
+ lifecycle.endApplication();
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list