[webbeans-commits] Webbeans SVN: r2387 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bean/ee and 15 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Fri Apr 10 11:51:47 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-04-10 11:51:47 -0400 (Fri, 10 Apr 2009)
New Revision: 2387
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockWebServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/
ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/
ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/WebServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/helpers/
ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/helpers/ForwardingWebServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebServices.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.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/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java
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/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
Log:
Add bean structures and lifecycle for enterprise resources
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -92,7 +92,7 @@
}
// Logger
- private LogProvider log = Logging.getLogProvider(AbstractBean.class);
+ private final LogProvider log = Logging.getLogProvider(AbstractBean.class);
// The binding types
protected Set<Annotation> bindings;
// The name
@@ -139,6 +139,7 @@
/**
* Initializes the bean and its metadata
*/
+ @Override
public void initialize(BeanDeployerEnvironment environment)
{
mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager);
@@ -372,6 +373,7 @@
*
* @see javax.inject.manager.Bean#getBindings()
*/
+ @Override
public Set<Annotation> getBindings()
{
return bindings;
@@ -384,6 +386,7 @@
*/
protected abstract String getDefaultName();
+ @Override
public abstract AbstractBean<?, ?> getSpecializedBean();
/**
@@ -393,11 +396,13 @@
*
* @see javax.inject.manager.Bean#getDeploymentType()
*/
+ @Override
public Class<? extends Annotation> getDeploymentType()
{
return deploymentType;
}
+ @Override
public Set<AnnotatedInjectionPoint<?, ?>> getInjectionPoints()
{
return injectionPoints;
@@ -420,6 +425,7 @@
*
* @see javax.inject.manager.Bean#getName()
*/
+ @Override
public String getName()
{
return name;
@@ -432,6 +438,7 @@
*
* @see javax.inject.manager.Bean#getScopeType()
*/
+ @Override
public Class<? extends Annotation> getScopeType()
{
return scopeType;
@@ -442,6 +449,7 @@
*
* @return The type
*/
+ @Override
public Class<T> getType()
{
return type;
@@ -490,6 +498,7 @@
*
* @return True if primitive, false otherwise
*/
+ @Override
public boolean isPrimitive()
{
return primitive;
@@ -517,16 +526,19 @@
return "AbstractBean " + getName();
}
+ @Override
public boolean isProxyable()
{
return proxyable;
}
+ @Override
public boolean isDependent()
{
return Dependent.class.equals(getScopeType());
}
+ @Override
public boolean isSpecializing()
{
return getAnnotatedItem().isAnnotationPresent(Specializes.class);
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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -17,7 +17,6 @@
package org.jboss.webbeans.bean;
-import java.beans.BeanDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
@@ -42,14 +41,13 @@
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.DependentStorageRequest;
-import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedMethod;
-import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.util.Proxies;
@@ -62,7 +60,7 @@
*/
public class EnterpriseBean<T> extends AbstractClassBean<T>
{
- private LogProvider log = Logging.getLogProvider(EnterpriseBean.class);
+ private final Log log = Logging.getLog(EnterpriseBean.class);
// The EJB descriptor
private InternalEjbDescriptor<T> ejbDescriptor;
@@ -131,6 +129,7 @@
}
}
+ @Override
protected void initTypes()
{
Set<Type> types = new HashSet<Type>();
@@ -232,8 +231,7 @@
T instance = proxyClass.newInstance();
creationalContext.push(instance);
((ProxyObject) instance).setHandler(new EnterpriseBeanProxyMethodHandler(this));
- if (log.isTraceEnabled())
- log.trace("Enterprise bean instance created for bean " + this);
+ log.trace("Enterprise bean instance created for bean {0}", this);
return instance;
}
catch (InstantiationException e)
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,198 @@
+/*
+ * 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.bean.ee;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+import javassist.util.proxy.ProxyFactory;
+import javassist.util.proxy.ProxyObject;
+
+import javax.context.CreationalContext;
+import javax.context.Dependent;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
+import org.jboss.webbeans.util.Proxies;
+
+/**
+ * Representation of a Java EE Resource bean
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractJavaEEResourceBean<T> extends RIBean<T>
+{
+
+ private final Class<? extends Annotation> deploymentType;
+ private final Set<Annotation> bindings;
+ private final Class<T> type;
+ private final Set<Type> types;
+ private final Class<T> proxyClass;
+
+ /**
+ * @param manager the manager used to create this bean
+ * @param deploymentType the deployment type of the bean
+ * @param bindings the bindings of bean
+ * @param type the concrete type of the bean
+ */
+ public AbstractJavaEEResourceBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, Class<T> type)
+ {
+ super(manager);
+ this.deploymentType = deploymentType;
+ this.bindings = bindings;
+ this.type = type;
+ this.types = new HashSet<Type>();
+ types.add(type);
+
+ ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
+
+ @SuppressWarnings("unchecked")
+ Class<T> proxyClass = proxyFactory.createClass();
+
+ this.proxyClass = proxyClass;
+ }
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return bindings;
+ }
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public Class<? extends Annotation> getDeploymentType()
+ {
+ return deploymentType;
+ }
+
+ @Override
+ public Class<T> getType()
+ {
+ return type;
+ }
+
+ @Override
+ public Set<? extends Type> getTypes()
+ {
+ return types;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
+
+ @Override
+ public RIBean<?> getSpecializedBean()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isDependent()
+ {
+ return true;
+ }
+
+ @Override
+ public Set<AnnotatedInjectionPoint<?, ?>> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isPrimitive()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isProxyable()
+ {
+ return false;
+ }
+
+ protected Class<T> getProxyClass()
+ {
+ return proxyClass;
+ }
+
+ public T create(CreationalContext<T> creationalContext)
+ {
+ T instance;
+ try
+ {
+ instance = getProxyClass().newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException("Error creating proxy for " + this, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException("Error creating proxy for " + this, e);
+ }
+ ((ProxyObject) instance).setHandler(newMethodHandler());
+ return instance;
+ }
+
+ protected abstract MethodHandler newMethodHandler();
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void destroy(T instance)
+ {
+
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,74 @@
+/*
+ * 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.bean.ee;
+
+import java.lang.reflect.Method;
+
+import javassist.util.proxy.MethodHandler;
+
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * Abstract method handler which invokes the a method on a proxied instance
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractJavaEEResourceMethodHandler implements MethodHandler
+{
+
+ private static final transient Log log = Logging.getLog(AbstractJavaEEResourceMethodHandler.class);
+
+ /**
+ *
+ */
+ public AbstractJavaEEResourceMethodHandler()
+ {
+ super();
+ }
+
+ /**
+ * Lookup the execute the method on the proxied instance obtained from the
+ * container
+ *
+ * @param self the proxy instance.
+ * @param method the overridden method declared in the super class or
+ * interface.
+ * @param proceed the forwarder method for invoking the overridden method. It
+ * is null if the overridden method is abstract or declared in the
+ * interface.
+ * @param args an array of objects containing the values of the arguments
+ * passed in the method invocation on the proxy instance. If a
+ * parameter type is a primitive type, the type of the array
+ * element is a wrapper class.
+ * @return the resulting value of the method invocation.
+ *
+ * @throws Throwable if the method invocation fails.
+ */
+ public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
+ {
+ Object proxiedInstance = getProxiedInstance();
+ Object returnValue = Reflections.invokeAndWrap(method, proxiedInstance, args);
+ log.trace("Executed {0} on {1} with parameters {2} and got return value {3}", method, proxiedInstance, args, returnValue);
+ return returnValue;
+ }
+
+ protected abstract Object getProxiedInstance();
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,62 @@
+/*
+ * 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.bean.ee;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.webbeans.ManagerImpl;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class PersistenceContextBean extends AbstractJavaEEResourceBean<EntityManager>
+{
+
+ private final String id;
+ private final String unitName;
+
+ public PersistenceContextBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, String unitName)
+ {
+ super(manager, deploymentType, bindings, EntityManager.class);
+ this.unitName = unitName;
+ this.id = createId("PersistenceContext - " + unitName);
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public String getUnitName()
+ {
+ return unitName;
+ }
+
+ @Override
+ protected MethodHandler newMethodHandler()
+ {
+ return new PersistenceContextMethodHandler(getUnitName());
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,44 @@
+/*
+ * 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.bean.ee;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.persistence.spi.JpaServices;
+
+/**
+ * Proxy for persistence context Java EE resources
+ *
+ * @author Pete Muir
+ *
+ */
+public class PersistenceContextMethodHandler extends AbstractJavaEEResourceMethodHandler
+{
+
+ private final String unitName;
+
+ public PersistenceContextMethodHandler(String unitName)
+ {
+ this.unitName = unitName;
+ }
+
+ @Override
+ protected Object getProxiedInstance()
+ {
+ return CurrentManager.rootManager().getServices().get(JpaServices.class).resolvePersistenceContext(unitName);
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,62 @@
+/*
+ * 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.bean.ee;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.webbeans.ManagerImpl;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class PersistenceUnitBean extends AbstractJavaEEResourceBean<EntityManagerFactory>
+{
+
+ private final String id;
+ private final String unitName;
+
+ public PersistenceUnitBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, String unitName)
+ {
+ super(manager, deploymentType, bindings, EntityManagerFactory.class);
+ this.unitName = unitName;
+ this.id = createId("PersistenceUnit - " + unitName);
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public String getUnitName()
+ {
+ return unitName;
+ }
+
+ @Override
+ protected MethodHandler newMethodHandler()
+ {
+ return new PersistenceUnitMethodHandler(getUnitName());
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -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.bean.ee;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.persistence.spi.JpaServices;
+
+
+/**
+ * Proxy for persistence unit Java EE resources
+ *
+ * @author Pete Muir
+ *
+ */
+public class PersistenceUnitMethodHandler extends AbstractJavaEEResourceMethodHandler
+{
+
+ private final String unitName;
+
+ public PersistenceUnitMethodHandler(String unitName)
+ {
+ this.unitName = unitName;
+ }
+
+ @Override
+ protected Object getProxiedInstance()
+ {
+ return CurrentManager.rootManager().getServices().get(JpaServices.class).resolvePersistenceUnit(unitName);
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,74 @@
+/*
+ * 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.bean.ee;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+
+import org.jboss.webbeans.ManagerImpl;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class RemoteEjbBean<T> extends AbstractJavaEEResourceBean<T>
+{
+
+ private final String id;
+ private final String jndiName;
+ private final String mappedName;
+ private final String ejbLink;
+
+ public RemoteEjbBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, Class<T> type, String jndiName, String mappedName, String ejbLink)
+ {
+ super(manager, deploymentType, bindings, type);
+ this.jndiName = jndiName;
+ this.mappedName = mappedName;
+ this.ejbLink = ejbLink;
+ this.id = createId("RemoteEjb - " );
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public String getMappedName()
+ {
+ return mappedName;
+ }
+
+ public String getEjbLink()
+ {
+ return ejbLink;
+ }
+
+ @Override
+ protected MethodHandler newMethodHandler()
+ {
+ return new RemoteEjbMethodHandler(getMappedName(), getJndiName(), getEjbLink());
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,49 @@
+/*
+ * 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.bean.ee;
+
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ejb.spi.EjbServices;
+
+/**
+ * Proxy for persistence unit Java EE resources
+ *
+ * @author Pete Muir
+ *
+ */
+public class RemoteEjbMethodHandler extends AbstractJavaEEResourceMethodHandler
+{
+
+ private final String mappedName;
+ private final String jndiName;
+ private final String ejbLink;
+
+ public RemoteEjbMethodHandler(String mappedName, String jndiName, String ejbLink)
+ {
+ this.mappedName = mappedName;
+ this.jndiName = jndiName;
+ this.ejbLink = ejbLink;
+ }
+
+ @Override
+ protected Object getProxiedInstance()
+ {
+ return CurrentManager.rootManager().getServices().get(EjbServices.class).resolveRemoteEjb(jndiName, mappedName, ejbLink);
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,67 @@
+/*
+ * 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.bean.ee;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+
+import org.jboss.webbeans.ManagerImpl;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class ResourceBean<T> extends AbstractJavaEEResourceBean<T>
+{
+
+ private final String id;
+ private final String mappedName;
+ private final String jndiName;
+
+ public ResourceBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, Class<T> type, String mappedName, String jndiName)
+ {
+ super(manager, deploymentType, bindings, type);
+ this.mappedName = mappedName;
+ this.jndiName = jndiName;
+ this.id = createId("WebService - " );
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public String getMappedName()
+ {
+ return mappedName;
+ }
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ @Override
+ protected MethodHandler newMethodHandler()
+ {
+ return new ResourceMethodHandler(getMappedName(), getJndiName());
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,47 @@
+/*
+ * 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.bean.ee;
+
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.resources.spi.ResourceServices;
+
+/**
+ * Proxy for persistence unit Java EE resources
+ *
+ * @author Pete Muir
+ *
+ */
+public class ResourceMethodHandler extends AbstractJavaEEResourceMethodHandler
+{
+
+ private final String mappedName;
+ private final String jndiName;
+
+ public ResourceMethodHandler(String mappedName, String jndiName)
+ {
+ this.mappedName = mappedName;
+ this.jndiName = jndiName;
+ }
+
+ @Override
+ protected Object getProxiedInstance()
+ {
+ return CurrentManager.rootManager().getServices().get(ResourceServices.class).resolveResource(jndiName, mappedName);
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,74 @@
+/*
+ * 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.bean.ee;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+
+import org.jboss.webbeans.ManagerImpl;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class WebServiceBean<T> extends AbstractJavaEEResourceBean<T>
+{
+
+ private final String id;
+ private final String mappedName;
+ private final String jndiName;
+ private final String wsdlLocation;
+
+ public WebServiceBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, Class<T> type, String mappedName, String jndiName, String wsdlLocation)
+ {
+ super(manager, deploymentType, bindings, type);
+ this.mappedName = mappedName;
+ this.jndiName = jndiName;
+ this.wsdlLocation = wsdlLocation;
+ this.id = createId("WebService - " );
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public String getMappedName()
+ {
+ return mappedName;
+ }
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public String getWsdlLocation()
+ {
+ return wsdlLocation;
+ }
+
+ @Override
+ protected MethodHandler newMethodHandler()
+ {
+ return new WebServiceMethodHandler(getMappedName(), getJndiName());
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,47 @@
+/*
+ * 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.bean.ee;
+
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ws.spi.WebServices;
+
+/**
+ * Proxy for persistence unit Java EE web services
+ *
+ * @author Pete Muir
+ *
+ */
+public class WebServiceMethodHandler extends AbstractJavaEEResourceMethodHandler
+{
+
+ private final String mappedName;
+ private final String jndiName;
+
+ public WebServiceMethodHandler(String mappedName, String jndiName)
+ {
+ this.mappedName = mappedName;
+ this.jndiName = jndiName;
+ }
+
+ @Override
+ protected Object getProxiedInstance()
+ {
+ return CurrentManager.rootManager().getServices().get(WebServices.class).resolveResource(jndiName, mappedName);
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -48,7 +48,7 @@
*
* @author Nicklas Karlsson
*/
- private ConcurrentCache<Bean<? extends Object>, Object> pool;
+ private final ConcurrentCache<Bean<? extends Object>, Object> pool;
/**
* Constructor
@@ -105,11 +105,8 @@
* the pool if the create argument is true.
*
* @param bean The bean to get a proxy to
- * @param create Flag indicating if the proxy should be created if it does
- * not already exist
* @return the client proxy for the bean
*/
- // TODO: What is this create parameter? Something obsolete?
public <T> T getClientProxy(final ManagerImpl manager, final Bean<T> bean)
{
return pool.putIfAbsent(bean, new Callable<T>()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -17,13 +17,14 @@
package org.jboss.webbeans.bean.proxy;
+
import java.lang.reflect.Method;
import javassist.util.proxy.MethodHandler;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
-import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.util.Reflections;
@@ -37,7 +38,7 @@
public class EnterpriseBeanProxyMethodHandler implements MethodHandler
{
// The log provider
- private static final transient LogProvider log = Logging.getLogProvider(EnterpriseBeanProxyMethodHandler.class);
+ static final transient Log log = Logging.getLog(EnterpriseBeanProxyMethodHandler.class);
private static final ThreadLocal<EnterpriseBean<?>> enterpriseBean;
@@ -57,9 +58,9 @@
enterpriseBean.set(bean);
}
- private final SessionObjectReference reference;
- private final Class<?> objectInterface;
- private boolean destroyed;
+ final SessionObjectReference reference;
+ final Class<?> objectInterface;
+ boolean destroyed;
/**
* Constructor
@@ -83,7 +84,7 @@
}
log.trace("Created enterprise bean proxy method handler for " + bean);
}
-
+
/**
* Lookups the EJB in the container and executes the method on it
*
@@ -139,6 +140,4 @@
}
-
-
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -21,6 +21,7 @@
import org.jboss.webbeans.persistence.spi.JpaServices;
import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
+import org.jboss.webbeans.ws.spi.WebServices;
public class MockEELifecycle extends MockServletLifecycle
{
@@ -34,6 +35,7 @@
getBootstrap().getServices().add(EjbServices.class, new MockEjBServices(getWebBeanDiscovery()));
getBootstrap().getServices().add(JpaServices.class, new MockJpaServices(getWebBeanDiscovery()));
getBootstrap().getServices().add(ResourceServices.class, new MockResourceServices());
+ getBootstrap().getServices().add(WebServices.class, new MockWebServices());
getBootstrap().setEnvironment(Environments.EE);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -33,6 +33,11 @@
// No-op
}
+ public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
+ {
+ return null;
+ }
+
public Iterable<EjbDescriptor<?>> discoverEjbs()
{
return ejbDiscovery.discoverEjbs();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -9,6 +9,8 @@
import javax.inject.manager.InjectionPoint;
import javax.persistence.Entity;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.persistence.spi.JpaServices;
@@ -23,11 +25,21 @@
this.webBeanDiscovery = webBeanDiscovery;
}
- public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+ public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint)
{
return null;
}
+ public EntityManager resolvePersistenceContext(String unitName)
+ {
+ return null;
+ }
+
+ public EntityManagerFactory resolvePersistenceUnit(String unitName)
+ {
+ return null;
+ }
+
public Collection<Class<?>> discoverEntities()
{
Set<Class<?>> classes = new HashSet<Class<?>>();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -32,4 +32,9 @@
return null;
}
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ return null;
+ }
+
}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockWebServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockWebServices.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockWebServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.mock;
+
+import org.jboss.webbeans.ws.spi.WebServices;
+
+public class MockWebServices implements WebServices
+{
+
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ return null;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockWebServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -28,6 +28,7 @@
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
+import org.jboss.webbeans.ws.spi.WebServices;
/**
* Various well known environments.
@@ -41,7 +42,7 @@
/**
* Java EE5 or Java EE6
*/
- EE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class, EntityDiscovery.class, ResourceServices.class, TransactionServices.class, NamingContext.class, ResourceLoader.class),
+ EE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class, WebServices.class, EntityDiscovery.class, ResourceServices.class, TransactionServices.class, NamingContext.class, ResourceLoader.class),
/**
* Java EE6 Web Profile
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -12,6 +12,7 @@
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
+import org.jboss.webbeans.ws.spi.WebServices;
/**
* A bean version of bootstrap that delegates to the underlying bootstrap impl
@@ -104,6 +105,16 @@
return bootstrap.getServices().get(ResourceLoader.class);
}
+ public WebServices getWebServices()
+ {
+ return bootstrap.getServices().get(WebServices.class);
+ }
+
+ public void setWebServices(WebServices webServices)
+ {
+ bootstrap.getServices().add(WebServices.class, webServices);
+ }
+
public void boot()
{
bootstrap.boot();
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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -42,8 +42,7 @@
* if the injection point is not annotated with @EJB, or, if the
* injection point is a method that doesn't follow JavaBean
* conventions
- * @throws IllegalStateException
- * if no EJBs can be resolved for injection
+
*/
public Object resolveEjb(InjectionPoint injectionPoint);
@@ -58,6 +57,21 @@
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor);
/**
+ * Resolve a remote EJB reference. At least one of the parameters will not be
+ * null.
+ *
+ * @param jndiName the JNDI name
+ * @param mappedName the mapped name
+ * @param ejbLink the EJB link name
+ * @return the remote EJB reference
+ * @throws IllegalStateException
+ * if no EJBs can be resolved for injection
+ * @throws IllegalArgumentException
+ * if jndiName, mappedName and ejbLink are null
+ */
+ public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink);
+
+ /**
* Gets a descriptor for each EJB in the application
*
* @return the EJB descriptors
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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -46,6 +46,11 @@
{
return delegate().resolveEjb(ejbDescriptor);
}
+
+ public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
+ {
+ return delegate().resolveRemoteEjb(jndiName, mappedName, ejbLink);
+ }
public Iterable<EjbDescriptor<?>> discoverEjbs()
{
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/jpa/spi/helpers/ForwardingJpaServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -16,9 +16,9 @@
*/
package org.jboss.webbeans.jpa.spi.helpers;
-import java.util.Collection;
-
import javax.inject.manager.InjectionPoint;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
import org.jboss.webbeans.persistence.spi.JpaServices;
@@ -37,11 +37,21 @@
protected abstract JpaServices delegate();
- public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+ public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint)
{
return delegate().resolvePersistenceContext(injectionPoint);
}
+ public EntityManager resolvePersistenceContext(String unitName)
+ {
+ return delegate().resolvePersistenceContext(unitName);
+ }
+
+ public EntityManagerFactory resolvePersistenceUnit(String unitName)
+ {
+ return delegate().resolvePersistenceUnit(unitName);
+ }
+
@Override
public String toString()
{
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -17,6 +17,8 @@
package org.jboss.webbeans.persistence.spi;
import javax.inject.manager.InjectionPoint;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
import org.jboss.webbeans.bootstrap.api.Service;
@@ -35,14 +37,36 @@
*
* @param injectionPoint
* the injection point metadata
- * @return an instance of the persistence unit
+ * @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
+ * if the injection point is not annotated with
+ * @PersistenceContext, or, if the injection point is a method
+ * that doesn't follow JavaBean conventions
* @throws IllegalStateException
* if no suitable persistence units can be resolved for injection
*/
- public Object resolvePersistenceContext(InjectionPoint injectionPoint);
+ public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint);
+ /**
+ * Resolve a persistence context for a given persistence unit name
+ *
+ * @param unitName the unit name
+ * @return an instance of the entity manager
+ * @throws IllegalStateException
+ * if no suitable persistence units can be resolved for injection
+ */
+ public EntityManager resolvePersistenceContext(String unitName);
+
+ /**
+ * Resolve a persistence unit for a given persistence unit name
+ *
+ * @param unitName the unit name
+ * @return an instance of the entity manager factory
+ * @throws IllegalStateException
+ * if no suitable persistence units can be resolved for injection
+ * @throws IllegalArgumentException
+ * if unitName is null
+ */
+ public EntityManagerFactory resolvePersistenceUnit(String unitName);
+
}
Modified: 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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -45,4 +45,17 @@
*/
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
Modified: 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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -11,8 +11,9 @@
import javax.naming.NamingException;
import org.jboss.webbeans.resources.spi.ResourceServices;
+import org.jboss.webbeans.ws.spi.WebServices;
-public abstract class AbstractResourceServices implements ResourceServices
+public abstract class AbstractResourceServices implements ResourceServices, WebServices
{
private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
@@ -41,9 +42,38 @@
}
}
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ String name = getResourceName(jndiName, mappedName);
+ try
+ {
+ return getContext().lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new ExecutionException("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();
- private static String getResourceName(InjectionPoint injectionPoint)
+ protected String getResourceName(InjectionPoint injectionPoint)
{
Resource resource = injectionPoint.getAnnotation(Resource.class);
String mappedName = resource.mappedName();
Added: 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 (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.resources.spi.helpers;
+
+import javax.inject.manager.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);
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/ForwardingResourceServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/WebServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/WebServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/WebServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,27 @@
+package org.jboss.webbeans.ws.spi;
+
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow Web Beans to resolve Web
+ * Services
+ *
+ * @author Pete Muir
+ *
+ */
+public interface WebServices extends Service
+{
+
+ /**
+ * 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
+ */
+ 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/ws/spi/WebServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/helpers/ForwardingWebServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/helpers/ForwardingWebServices.java (rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/helpers/ForwardingWebServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.ws.spi.helpers;
+
+import org.jboss.webbeans.ws.spi.WebServices;
+
+public abstract class ForwardingWebServices implements WebServices
+{
+
+ protected abstract WebServices delegate();
+
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ return delegate().resolveResource(jndiName, mappedName);
+ }
+
+}
Property changes on: ri/trunk/spi/src/main/java/org/jboss/webbeans/ws/spi/helpers/ForwardingWebServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -11,6 +11,7 @@
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
+import org.jboss.webbeans.ws.spi.WebServices;
import org.testng.annotations.Test;
public class BootstrapTest
@@ -40,6 +41,7 @@
bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
bootstrap.getServices().add(EntityDiscovery.class, new MockEntityDiscovery());
bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
+ bootstrap.getServices().add(WebServices.class, new MockWebServices());
bootstrap.initialize();
}
@@ -56,10 +58,28 @@
bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
bootstrap.getServices().add(EntityDiscovery.class, new MockEntityDiscovery());
bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
+ bootstrap.getServices().add(WebServices.class, new MockWebServices());
bootstrap.initialize();
}
@Test(expectedExceptions=IllegalStateException.class)
+ public void testMissingWebServices()
+ {
+ AbstractBootstrap bootstrap = new MockBootstrap();
+ bootstrap.setEnvironment(Environments.EE);
+ bootstrap.setApplicationContext(new ConcurrentHashMapBeanStore());
+ bootstrap.getServices().add(NamingContext.class, new MockNamingContext());
+ bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
+ bootstrap.getServices().add(TransactionServices.class, new MockTransactionServices());
+ bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+ bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+ bootstrap.getServices().add(EntityDiscovery.class, new MockEntityDiscovery());
+ bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
+ bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
+ bootstrap.initialize();
+ }
+
+ @Test(expectedExceptions=IllegalStateException.class)
public void testMissingEntityDiscovery()
{
AbstractBootstrap bootstrap = new MockBootstrap();
@@ -72,6 +92,7 @@
bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
+ bootstrap.getServices().add(WebServices.class, new MockWebServices());
bootstrap.initialize();
}
@@ -90,6 +111,7 @@
bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
bootstrap.getServices().add(EntityDiscovery.class, new MockEntityDiscovery());
bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
+ bootstrap.getServices().add(WebServices.class, new MockWebServices());
bootstrap.initialize();
}
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java 2009-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -24,4 +24,9 @@
return null;
}
+ public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
+ {
+ 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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -3,6 +3,8 @@
import java.util.Collection;
import javax.inject.manager.InjectionPoint;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
import org.jboss.webbeans.persistence.spi.JpaServices;
@@ -14,9 +16,19 @@
return null;
}
- public Object resolvePersistenceContext(InjectionPoint injectionPoint)
+ public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint)
{
return null;
}
+ public EntityManager resolvePersistenceContext(String unitName)
+ {
+ return null;
+ }
+
+ public EntityManagerFactory resolvePersistenceUnit(String unitName)
+ {
+ return null;
+ }
+
}
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-04-10 13:14:38 UTC (rev 2386)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -12,4 +12,9 @@
return null;
}
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ return null;
+ }
+
}
Added: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebServices.java (rev 0)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebServices.java 2009-04-10 15:51:47 UTC (rev 2387)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.bootstrap.api.test;
+
+import org.jboss.webbeans.ws.spi.WebServices;
+
+public class MockWebServices implements WebServices
+{
+
+ public Object resolveResource(String jndiName, String mappedName)
+ {
+ return null;
+ }
+
+}
Property changes on: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list