Skip to content

Commit

Permalink
WELD-1328 Define SPI for @WebServiceRef injection
Browse files Browse the repository at this point in the history
  • Loading branch information
jharting committed Feb 22, 2013
1 parent 2a583ec commit 3a55b84
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
13 changes: 12 additions & 1 deletion docs/reference/src/main/docbook/en-US/ri-spi.xml
Expand Up @@ -250,7 +250,7 @@
</tip>

<para>
Weld registers resource injection points with <literal>EjbInjectionServices</literal>, <literal>JpaInjectionServices</literal> and <literal>ResourceInjectionServices</literal> implementations
Weld registers resource injection points with <literal>EjbInjectionServices</literal>, <literal>JpaInjectionServices</literal>, <literal>ResourceInjectionServices</literal> and <literal>JaxwsInjectionServices</literal> implementations
upfront (at bootstrap). This allows validation of resource injection points to be performed at boot time rather than runtime. For each resource injection point Weld obtains a <literal>ResourceReferenceFactory</literal>
which it then uses at runtime for creating resource references.
</para>
Expand Down Expand Up @@ -397,6 +397,17 @@
</itemizedlist>
</note>
</section>

<section id="jaxws.services">
<title>Web Service Injection Services</title>

<para>
The resolution of <literal>@WebServiceRef</literal> (for injection into managed beans) is delegated to the
container. An integrator must provide an implementation of <literal>JaxwsInjectionServices</literal>.
This service is not required if the implementation of <xref linkend="injection.services"/>
takes care of <literal>@WebServiceRef</literal> injection.
</para>
</section>

<section id="injection.services">
<title>Injection Services</title>
Expand Down
Expand Up @@ -32,10 +32,12 @@
import org.jboss.weld.injection.InjectionPointFactory;
import org.jboss.weld.injection.ResourceInjectionPoint;
import org.jboss.weld.injection.spi.EjbInjectionServices;
import org.jboss.weld.injection.spi.JaxwsInjectionServices;
import org.jboss.weld.injection.spi.JpaInjectionServices;
import org.jboss.weld.injection.spi.ResourceInjectionServices;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.persistence.PersistenceApiAbstraction;
import org.jboss.weld.ws.WSApiAbstraction;

/**
* A resource producer field that is static (not injected).
Expand Down Expand Up @@ -94,7 +96,15 @@ protected ResourceInjectionPoint<T, X> getInjectionPoint(EnhancedAnnotatedField<
if (resourceServices != null) {
Class<? extends Annotation> resourceAnnotationType = manager.getServices().get(EJBApiAbstraction.class).RESOURCE_ANNOTATION_CLASS;
if (injectionPoint.getAnnotated().isAnnotationPresent(resourceAnnotationType)) {
ResourceInjectionPoint.forResource(injectionPoint, resourceServices);
return ResourceInjectionPoint.forResource(injectionPoint, resourceServices);
}
}

JaxwsInjectionServices jaxwsInjectionServices = manager.getServices().get(JaxwsInjectionServices.class);
if (jaxwsInjectionServices != null) {
Class<? extends Annotation> webServiceRefAnnotationType = manager.getServices().get(WSApiAbstraction.class).WEB_SERVICE_REF_ANNOTATION_CLASS;
if (injectionPoint.getAnnotated().isAnnotationPresent(webServiceRefAnnotationType)) {
return ResourceInjectionPoint.forWebServiceRef(injectionPoint, jaxwsInjectionServices);
}
}
return null;
Expand Down
Expand Up @@ -52,13 +52,15 @@
import org.jboss.weld.injection.attributes.SpecialParameterInjectionPoint;
import org.jboss.weld.injection.spi.EjbInjectionServices;
import org.jboss.weld.injection.spi.InjectionServices;
import org.jboss.weld.injection.spi.JaxwsInjectionServices;
import org.jboss.weld.injection.spi.JpaInjectionServices;
import org.jboss.weld.injection.spi.ResourceInjectionServices;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.persistence.PersistenceApiAbstraction;
import org.jboss.weld.util.ApiAbstraction;
import org.jboss.weld.util.Beans;
import org.jboss.weld.util.collections.ArraySet;
import org.jboss.weld.ws.WSApiAbstraction;

/**
* Factory class that producer {@link InjectionPoint} instances for fields, parameters, methods and constructors. The
Expand Down Expand Up @@ -307,6 +309,20 @@ protected Class<? extends Annotation> getMarkerAnnotation(EJBApiAbstraction api)
}.proceed(declaringBean, type, manager, manager.getServices().get(EJBApiAbstraction.class), manager.getServices().get(ResourceInjectionServices.class));
}

public Set<ResourceInjectionPoint<?, ?>> getWebServiceRefInjectionPoints(Bean<?> declaringBean, EnhancedAnnotatedType<?> type, BeanManagerImpl manager) {
return new ResourceInjectionPointDiscovery<JaxwsInjectionServices, WSApiAbstraction>() {
@Override
protected ResourceInjectionPoint<?, ?> createResourceInjectionPoint(FieldInjectionPoint<?, ?> ip, Class<? extends Annotation> annotation, JaxwsInjectionServices specializedInjectionServices, WSApiAbstraction api) {
return ResourceInjectionPoint.forWebServiceRef(ip, specializedInjectionServices);
}

@Override
protected Class<? extends Annotation> getMarkerAnnotation(WSApiAbstraction api) {
return api.WEB_SERVICE_REF_ANNOTATION_CLASS;
}
}.proceed(declaringBean, type, manager, manager.getServices().get(WSApiAbstraction.class), manager.getServices().get(JaxwsInjectionServices.class));
}

/*
* Utility methods for parameter InjectionPoints
*/
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.jboss.weld.exceptions.DefinitionException;
import org.jboss.weld.injection.attributes.FieldInjectionPointAttributes;
import org.jboss.weld.injection.spi.EjbInjectionServices;
import org.jboss.weld.injection.spi.JaxwsInjectionServices;
import org.jboss.weld.injection.spi.JpaInjectionServices;
import org.jboss.weld.injection.spi.ResourceInjectionServices;
import org.jboss.weld.injection.spi.ResourceReference;
Expand Down Expand Up @@ -63,6 +64,10 @@ public static <T, X> ResourceInjectionPoint<T, X> forResource(FieldInjectionPoin
return new ResourceInjectionPoint<T, X>(delegate, Reflections.<ResourceReferenceFactory<T>>cast(injectionServices.registerResourceInjectionPoint(delegate)));
}

public static <T, X> ResourceInjectionPoint<T, X> forWebServiceRef(FieldInjectionPoint<T, X> delegate, JaxwsInjectionServices injectionServices) {
return new ResourceInjectionPoint<T, X>(delegate, Reflections.<ResourceReferenceFactory<T>>cast(injectionServices.registerWebServiceRefInjectionPoint(delegate)));
}

private final FieldInjectionPoint<T, X> delegate;
private final ResourceReferenceFactory<T> factory;

Expand Down
Expand Up @@ -50,6 +50,7 @@ public DefaultInjectionTarget(EnhancedAnnotatedType<T> type, Bean<T> bean, BeanM
resourceInjectionPoints.addAll(InjectionPointFactory.silentInstance().getPersistenceContextInjectionPoints(bean, type, beanManager));
resourceInjectionPoints.addAll(InjectionPointFactory.silentInstance().getPersistenceUnitInjectionPoints(bean, type, beanManager));
resourceInjectionPoints.addAll(InjectionPointFactory.silentInstance().getResourceInjectionPoints(bean, type, beanManager));
resourceInjectionPoints.addAll(InjectionPointFactory.silentInstance().getWebServiceRefInjectionPoints(bean, type, beanManager));
this.resourceInjectionPoints = immutableSet(resourceInjectionPoints);
}

Expand Down

0 comments on commit 3a55b84

Please sign in to comment.