Author: richard.opalka(a)jboss.com
Date: 2009-05-05 08:08:31 -0400 (Tue, 05 May 2009)
New Revision: 9958
Added:
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBBeanReferenceResolver.java
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBBeanReferenceResolver.java
Modified:
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java
container/jboss50/branches/jboss500/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java
container/jboss50/branches/jboss501/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml
Log:
[JBWS-2074][JBWS-2634] refactoring momma
Added:
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBBeanReferenceResolver.java
===================================================================
---
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBBeanReferenceResolver.java
(rev 0)
+++
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBBeanReferenceResolver.java 2009-05-05
12:08:31 UTC (rev 9958)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.container.jboss50.deployment.metadata;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.ejb.EJB;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.resolvers.spi.EjbReference;
+import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
+import org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver;
+
+/**
+ * EJB reference resolver.
+ *
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
+ */
+final class EJBBeanReferenceResolver extends AbstractReferenceResolver<EJB>
+{
+
+ /**
+ * Deployment unit used for resolving process.
+ */
+ private final DeploymentUnit unit;
+ /**
+ * Delegate used to resolve JNDI names.
+ */
+ private final EjbReferenceResolver delegate;
+
+ /**
+ * Constructor.
+ */
+ EJBBeanReferenceResolver(final DeploymentUnit unit, final EjbReferenceResolver
delegate)
+ {
+ super(EJB.class);
+
+ if (unit == null)
+ {
+ throw new IllegalArgumentException("Deployment unit cannot be null");
+ }
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("Ejb reference resolver cannot be
null");
+ }
+
+ this.unit = unit;
+ this.delegate = delegate;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.wsf.common.javax.resolvers.AbstractReferenceResolver#resolveField(java.lang.reflect.Field)
+ */
+ @Override
+ protected String resolveField(final Field field)
+ {
+ final EJB ejbAnnotation = field.getAnnotation(EJB.class);
+ final Class<?> type = field.getType();
+ final EjbReference reference = getEjbReference(ejbAnnotation, type);
+
+ return this.delegate.resolveEjb(unit, reference);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.wsf.common.javax.resolvers.AbstractReferenceResolver#resolveMethod(java.lang.reflect.Method)
+ */
+ @Override
+ protected String resolveMethod(final Method method)
+ {
+ final EJB ejbAnnotation = method.getAnnotation(EJB.class);
+ final Class<?> type = method.getParameterTypes()[0];
+ final EjbReference reference = getEjbReference(ejbAnnotation, type);
+
+ return this.delegate.resolveEjb(unit, reference);
+ }
+
+ /**
+ * Constructs EjbReference.
+ *
+ * @param ejbAnnotation ejb annotation
+ * @param type fall back type
+ * @return ejb reference instance
+ */
+ private EjbReference getEjbReference(EJB ejbAnnotation, Class<?> type)
+ {
+ String beanInterface = ejbAnnotation.beanInterface().getName();
+ if (java.lang.Object.class.getName().equals(beanInterface))
+ {
+ beanInterface = type.getName();
+ }
+ return new EjbReference(ejbAnnotation.beanName(), beanInterface,
ejbAnnotation.mappedName());
+ }
+
+}
Modified:
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java
===================================================================
---
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java 2009-05-05
12:00:18 UTC (rev 9957)
+++
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java 2009-05-05
12:08:31 UTC (rev 9958)
@@ -21,24 +21,31 @@
*/
package org.jboss.wsf.container.jboss50.deployment.metadata;
+import java.lang.annotation.Annotation;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import javax.annotation.Resource;
+import javax.ejb.EJB;
import javax.jws.WebService;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.xml.ws.WebServiceProvider;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.common.injection.resolvers.ResourceReferenceResolver;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -47,46 +54,50 @@
import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
import org.jboss.wsf.spi.metadata.injection.InjectionMetaData;
import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
+import org.jboss.wsf.spi.metadata.injection.ReferenceResolver;
/**
* Deployment aspect that builds injection meta data.
*
- * @author ropalka(a)redhat.com
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
*/
public final class InjectionMetaDataDeploymentAspect extends DeploymentAspect
{
+ private static final ReferenceResolver RESOURCE_REFERENCE_RESOLVER = new
ResourceReferenceResolver();
private static final String EJB3_JNDI_PREFIX = "java:env/";
-
+ private EjbReferenceResolver ejbReferenceResolver;
+
@Override
public void create(Deployment dep)
{
super.create(dep);
+ DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
+ if (unit == null)
+ throw new IllegalStateException("DeploymentUnit not found");
+
+ JBossWebMetaData webMD = dep.getAttachment(JBossWebMetaData.class);
+ if (webMD == null)
+ throw new IllegalStateException("JBossWebMetaData not found");
+
List<InjectionMetaData> injectionMD = new
LinkedList<InjectionMetaData>();
+ Map<Class<? extends Annotation>, ReferenceResolver> resolvers =
createResolvers(unit);
DeploymentType deploymentType = dep.getType();
try
{
if (deploymentType == DeploymentType.JAXWS_JSE)
{
- JBossWebMetaData webMD = dep.getAttachment(JBossWebMetaData.class);
- if (webMD == null)
- throw new IllegalStateException("JBossWebMetaData not found");
-
injectionMD.addAll(buildInjectionMetaData(webMD.getEnvironmentEntries()));
for (Endpoint endpoint : dep.getService().getEndpoints())
{
- InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
null);
+ InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
resolvers, null);
endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
}
}
else if (deploymentType == DeploymentType.JAXWS_EJB3)
{
- DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
- if (unit == null)
- throw new IllegalStateException("DeploymentUnit not found");
-
JBossMetaData jbossMD = unit.getAttachment(JBossMetaData.class);
JBossEnterpriseBeansMetaData jebMDs = jbossMD.getEnterpriseBeans();
@@ -103,7 +114,7 @@
EnvironmentEntriesMetaData ejbEnvEntries =
jebMDs.get(ejbName).getEnvironmentEntries();
injectionMD.addAll(buildInjectionMetaData(ejbEnvEntries));
Endpoint endpoint = dep.getService().getEndpointByName(ejbName);
- InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
ctx);
+ InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
resolvers, ctx);
endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
}
}
@@ -123,6 +134,26 @@
super.destroy(dep);
}
+ /**
+ * Builds reference resolvers container.
+ *
+ * @param unit deployment unit
+ * @return reference resolvers
+ */
+ private Map<Class<? extends Annotation>, ReferenceResolver>
createResolvers(DeploymentUnit unit)
+ {
+ final Map<Class<? extends Annotation>, ReferenceResolver> resolvers =
new HashMap<Class<? extends Annotation>, ReferenceResolver>();
+ resolvers.put(Resource.class, RESOURCE_REFERENCE_RESOLVER);
+ resolvers.put(EJB.class, new EJBBeanReferenceResolver(unit,
getEjbReferenceResolver()));
+ return resolvers;
+ }
+
+ /**
+ * Builds JBossWS specific injection metadata from JBoss metadata.
+ *
+ * @param envEntries environment entries
+ * @return JBossWS specific injection metadata
+ */
private List<InjectionMetaData>
buildInjectionMetaData(EnvironmentEntriesMetaData envEntries)
{
if ((envEntries == null) || (envEntries.size() == 0))
@@ -162,6 +193,12 @@
return retVal;
}
+ /**
+ * Returns true if EJB represents webservice endpoint, false otherwise.
+ *
+ * @param container to analyze
+ * @return true if webservice endpoint, false otherwise
+ */
private boolean isWebServiceBean(WebServiceDeclaration container)
{
boolean isWebService = container.getAnnotation(WebService.class) != null;
@@ -170,4 +207,29 @@
return isWebService || isWebServiceProvider;
}
+ /**
+ * Sets ejb reference resolver. This method is invoked by MC.
+ *
+ * @param resolver ejb reference resolver
+ */
+ public void setEjbReferenceResolver(final EjbReferenceResolver resolver)
+ {
+ this.ejbReferenceResolver = resolver;
+ }
+
+ /**
+ * Gets ejb reference resolver.
+ *
+ * @return ejb reference resolver
+ */
+ public EjbReferenceResolver getEjbReferenceResolver()
+ {
+ if (this.ejbReferenceResolver == null)
+ {
+ throw new IllegalStateException("No EjbReferenceResolver set by MC");
+ }
+
+ return this.ejbReferenceResolver;
+ }
+
}
Modified:
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java
===================================================================
---
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java 2009-05-05
12:00:18 UTC (rev 9957)
+++
container/jboss50/branches/jboss500/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java 2009-05-05
12:08:31 UTC (rev 9958)
@@ -26,8 +26,8 @@
import javax.xml.ws.WebServiceContext;
import org.jboss.wsf.common.JavaUtils;
-import org.jboss.wsf.common.javax.JavaxAnnotationHelper;
-import org.jboss.wsf.common.javax.PreDestroyHolder;
+import org.jboss.wsf.common.injection.InjectionHelper;
+import org.jboss.wsf.common.injection.PreDestroyHolder;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -82,8 +82,8 @@
throw new IllegalStateException("Cannot get target bean instance",
ex);
}
- JavaxAnnotationHelper.injectResources(targetBean,
ep.getAttachment(InjectionsMetaData.class));
- JavaxAnnotationHelper.callPostConstructMethod(targetBean);
+ InjectionHelper.injectResources(targetBean,
ep.getAttachment(InjectionsMetaData.class));
+ InjectionHelper.callPostConstructMethod(targetBean);
ep.addAttachment(PreDestroyHolder.class, new PreDestroyHolder(targetBean));
}
Modified:
container/jboss50/branches/jboss500/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml
===================================================================
---
container/jboss50/branches/jboss500/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml 2009-05-05
12:00:18 UTC (rev 9957)
+++
container/jboss50/branches/jboss500/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml 2009-05-05
12:08:31 UTC (rev 9958)
@@ -200,6 +200,7 @@
<bean name="WSInjectionMetaDataDeploymentAspect"
class="org.jboss.wsf.container.jboss50.deployment.metadata.InjectionMetaDataDeploymentAspect">
<property name="requires">WebMetaData</property>
<property name="provides">InjectionMetaData</property>
+ <property name="ejbReferenceResolver"><inject
bean="org.jboss.ejb3.EjbReferenceResolver"/></property>
</bean>
<bean name="WSContextRootDeploymentAspect"
class="org.jboss.wsf.framework.deployment.BackwardCompatibleContextRootDeploymentAspect">
Added:
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBBeanReferenceResolver.java
===================================================================
---
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBBeanReferenceResolver.java
(rev 0)
+++
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBBeanReferenceResolver.java 2009-05-05
12:08:31 UTC (rev 9958)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.container.jboss50.deployment.metadata;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.ejb.EJB;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.resolvers.spi.EjbReference;
+import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
+import org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver;
+
+/**
+ * EJB reference resolver.
+ *
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
+ */
+final class EJBBeanReferenceResolver extends AbstractReferenceResolver<EJB>
+{
+
+ /**
+ * Deployment unit used for resolving process.
+ */
+ private final DeploymentUnit unit;
+ /**
+ * Delegate used to resolve JNDI names.
+ */
+ private final EjbReferenceResolver delegate;
+
+ /**
+ * Constructor.
+ */
+ EJBBeanReferenceResolver(final DeploymentUnit unit, final EjbReferenceResolver
delegate)
+ {
+ super(EJB.class);
+
+ if (unit == null)
+ {
+ throw new IllegalArgumentException("Deployment unit cannot be null");
+ }
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("Ejb reference resolver cannot be
null");
+ }
+
+ this.unit = unit;
+ this.delegate = delegate;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.wsf.common.javax.resolvers.AbstractReferenceResolver#resolveField(java.lang.reflect.Field)
+ */
+ @Override
+ protected String resolveField(final Field field)
+ {
+ final EJB ejbAnnotation = field.getAnnotation(EJB.class);
+ final Class<?> type = field.getType();
+ final EjbReference reference = getEjbReference(ejbAnnotation, type);
+
+ return this.delegate.resolveEjb(unit, reference);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.wsf.common.javax.resolvers.AbstractReferenceResolver#resolveMethod(java.lang.reflect.Method)
+ */
+ @Override
+ protected String resolveMethod(final Method method)
+ {
+ final EJB ejbAnnotation = method.getAnnotation(EJB.class);
+ final Class<?> type = method.getParameterTypes()[0];
+ final EjbReference reference = getEjbReference(ejbAnnotation, type);
+
+ return this.delegate.resolveEjb(unit, reference);
+ }
+
+ /**
+ * Constructs EjbReference.
+ *
+ * @param ejbAnnotation ejb annotation
+ * @param type fall back type
+ * @return ejb reference instance
+ */
+ private EjbReference getEjbReference(EJB ejbAnnotation, Class<?> type)
+ {
+ String beanInterface = ejbAnnotation.beanInterface().getName();
+ if (java.lang.Object.class.getName().equals(beanInterface))
+ {
+ beanInterface = type.getName();
+ }
+ return new EjbReference(ejbAnnotation.beanName(), beanInterface,
ejbAnnotation.mappedName());
+ }
+
+}
Modified:
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java
===================================================================
---
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java 2009-05-05
12:00:18 UTC (rev 9957)
+++
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java 2009-05-05
12:08:31 UTC (rev 9958)
@@ -21,24 +21,31 @@
*/
package org.jboss.wsf.container.jboss50.deployment.metadata;
+import java.lang.annotation.Annotation;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import javax.annotation.Resource;
+import javax.ejb.EJB;
import javax.jws.WebService;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.xml.ws.WebServiceProvider;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.common.injection.resolvers.ResourceReferenceResolver;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -47,46 +54,50 @@
import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
import org.jboss.wsf.spi.metadata.injection.InjectionMetaData;
import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
+import org.jboss.wsf.spi.metadata.injection.ReferenceResolver;
/**
* Deployment aspect that builds injection meta data.
*
- * @author ropalka(a)redhat.com
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
*/
public final class InjectionMetaDataDeploymentAspect extends DeploymentAspect
{
+ private static final ReferenceResolver RESOURCE_REFERENCE_RESOLVER = new
ResourceReferenceResolver();
private static final String EJB3_JNDI_PREFIX = "java:env/";
-
+ private EjbReferenceResolver ejbReferenceResolver;
+
@Override
public void create(Deployment dep)
{
super.create(dep);
+ DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
+ if (unit == null)
+ throw new IllegalStateException("DeploymentUnit not found");
+
+ JBossWebMetaData webMD = dep.getAttachment(JBossWebMetaData.class);
+ if (webMD == null)
+ throw new IllegalStateException("JBossWebMetaData not found");
+
List<InjectionMetaData> injectionMD = new
LinkedList<InjectionMetaData>();
+ Map<Class<? extends Annotation>, ReferenceResolver> resolvers =
createResolvers(unit);
DeploymentType deploymentType = dep.getType();
try
{
if (deploymentType == DeploymentType.JAXWS_JSE)
{
- JBossWebMetaData webMD = dep.getAttachment(JBossWebMetaData.class);
- if (webMD == null)
- throw new IllegalStateException("JBossWebMetaData not found");
-
injectionMD.addAll(buildInjectionMetaData(webMD.getEnvironmentEntries()));
for (Endpoint endpoint : dep.getService().getEndpoints())
{
- InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
null);
+ InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
resolvers, null);
endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
}
}
else if (deploymentType == DeploymentType.JAXWS_EJB3)
{
- DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
- if (unit == null)
- throw new IllegalStateException("DeploymentUnit not found");
-
JBossMetaData jbossMD = unit.getAttachment(JBossMetaData.class);
JBossEnterpriseBeansMetaData jebMDs = jbossMD.getEnterpriseBeans();
@@ -103,7 +114,7 @@
EnvironmentEntriesMetaData ejbEnvEntries =
jebMDs.get(ejbName).getEnvironmentEntries();
injectionMD.addAll(buildInjectionMetaData(ejbEnvEntries));
Endpoint endpoint = dep.getService().getEndpointByName(ejbName);
- InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
ctx);
+ InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
resolvers, ctx);
endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
}
}
@@ -123,6 +134,26 @@
super.destroy(dep);
}
+ /**
+ * Builds reference resolvers container.
+ *
+ * @param unit deployment unit
+ * @return reference resolvers
+ */
+ private Map<Class<? extends Annotation>, ReferenceResolver>
createResolvers(DeploymentUnit unit)
+ {
+ final Map<Class<? extends Annotation>, ReferenceResolver> resolvers =
new HashMap<Class<? extends Annotation>, ReferenceResolver>();
+ resolvers.put(Resource.class, RESOURCE_REFERENCE_RESOLVER);
+ resolvers.put(EJB.class, new EJBBeanReferenceResolver(unit,
getEjbReferenceResolver()));
+ return resolvers;
+ }
+
+ /**
+ * Builds JBossWS specific injection metadata from JBoss metadata.
+ *
+ * @param envEntries environment entries
+ * @return JBossWS specific injection metadata
+ */
private List<InjectionMetaData>
buildInjectionMetaData(EnvironmentEntriesMetaData envEntries)
{
if ((envEntries == null) || (envEntries.size() == 0))
@@ -162,6 +193,12 @@
return retVal;
}
+ /**
+ * Returns true if EJB represents webservice endpoint, false otherwise.
+ *
+ * @param container to analyze
+ * @return true if webservice endpoint, false otherwise
+ */
private boolean isWebServiceBean(WebServiceDeclaration container)
{
boolean isWebService = container.getAnnotation(WebService.class) != null;
@@ -170,4 +207,29 @@
return isWebService || isWebServiceProvider;
}
+ /**
+ * Sets ejb reference resolver. This method is invoked by MC.
+ *
+ * @param resolver ejb reference resolver
+ */
+ public void setEjbReferenceResolver(final EjbReferenceResolver resolver)
+ {
+ this.ejbReferenceResolver = resolver;
+ }
+
+ /**
+ * Gets ejb reference resolver.
+ *
+ * @return ejb reference resolver
+ */
+ public EjbReferenceResolver getEjbReferenceResolver()
+ {
+ if (this.ejbReferenceResolver == null)
+ {
+ throw new IllegalStateException("No EjbReferenceResolver set by MC");
+ }
+
+ return this.ejbReferenceResolver;
+ }
+
}
Modified:
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java
===================================================================
---
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java 2009-05-05
12:00:18 UTC (rev 9957)
+++
container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java 2009-05-05
12:08:31 UTC (rev 9958)
@@ -26,8 +26,8 @@
import javax.xml.ws.WebServiceContext;
import org.jboss.wsf.common.JavaUtils;
-import org.jboss.wsf.common.javax.JavaxAnnotationHelper;
-import org.jboss.wsf.common.javax.PreDestroyHolder;
+import org.jboss.wsf.common.injection.InjectionHelper;
+import org.jboss.wsf.common.injection.PreDestroyHolder;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -82,8 +82,8 @@
throw new IllegalStateException("Cannot get target bean instance",
ex);
}
- JavaxAnnotationHelper.injectResources(targetBean,
ep.getAttachment(InjectionsMetaData.class));
- JavaxAnnotationHelper.callPostConstructMethod(targetBean);
+ InjectionHelper.injectResources(targetBean,
ep.getAttachment(InjectionsMetaData.class));
+ InjectionHelper.callPostConstructMethod(targetBean);
ep.addAttachment(PreDestroyHolder.class, new PreDestroyHolder(targetBean));
}
Modified:
container/jboss50/branches/jboss501/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml
===================================================================
---
container/jboss50/branches/jboss501/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml 2009-05-05
12:00:18 UTC (rev 9957)
+++
container/jboss50/branches/jboss501/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml 2009-05-05
12:08:31 UTC (rev 9958)
@@ -200,6 +200,7 @@
<bean name="WSInjectionMetaDataDeploymentAspect"
class="org.jboss.wsf.container.jboss50.deployment.metadata.InjectionMetaDataDeploymentAspect">
<property name="requires">WebMetaData</property>
<property name="provides">InjectionMetaData</property>
+ <property name="ejbReferenceResolver"><inject
bean="org.jboss.ejb3.EjbReferenceResolver"/></property>
</bean>
<bean name="WSContextRootDeploymentAspect"
class="org.jboss.wsf.framework.deployment.BackwardCompatibleContextRootDeploymentAspect">