Index: src/main/java/org/jboss/injection/WebServiceRefEncInjector.java =================================================================== --- src/main/java/org/jboss/injection/WebServiceRefEncInjector.java (revision 0) +++ src/main/java/org/jboss/injection/WebServiceRefEncInjector.java (revision 0) @@ -0,0 +1,68 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2010, 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.injection; + +import javax.naming.Context; +import javax.naming.NamingException; + +import org.jboss.ejb3.vfs.spi.UnifiedVirtualFileFactory; +import org.jboss.ejb3.vfs.spi.VirtualFile; +import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData; +import org.jboss.metadata.serviceref.ServiceReferenceHandler; +import org.jboss.wsf.spi.deployment.UnifiedVirtualFile; + +/** + * An injector that just publishes webservice reference to JNDI registry. + * + * @author Richard Opalka + */ +final class WebServiceRefEncInjector extends ValueEncInjector +{ + final String encName; + final ServiceReferenceMetaData serviceRef; + final ServiceReferenceHandler serviceRefHandler; + + public WebServiceRefEncInjector(final String name, final ServiceReferenceMetaData serviceRef) + { + super(name, null, ""); + + this.encName = name; + this.serviceRef = serviceRef; + this.serviceRefHandler = new ServiceReferenceHandler(); + } + + public void inject(final InjectionContainer container) + { + final VirtualFile rootFile = container.getRootFile(); + final UnifiedVirtualFile vfsRoot = UnifiedVirtualFileFactory.getInstance().create(rootFile); + final ClassLoader classLoader = container.getClassloader(); + final Context enc = container.getEnc(); + try + { + this.serviceRefHandler.bindServiceRef(enc, this.encName, vfsRoot, classLoader, this.serviceRef); + } + catch (final NamingException e) + { + throw new RuntimeException("Unable to publish serviceref: " + serviceRef, e); + } + } +} Index: src/main/java/org/jboss/injection/WebServiceRefHandler.java =================================================================== --- src/main/java/org/jboss/injection/WebServiceRefHandler.java (revision 108237) +++ src/main/java/org/jboss/injection/WebServiceRefHandler.java (working copy) @@ -40,9 +40,10 @@ import org.jboss.metadata.javaee.spec.*; /** - * Handle @WebServiceRef annotations + * Handles @WebServiceRef annotations and DD declarations. * * @author Thomas.Diesler@jboss.com + * @author Richard Opalka */ public class WebServiceRefHandler implements InjectionHandler { @@ -75,7 +76,24 @@ } } else - log.warn("No injection target for service-ref: " + sref.getServiceRefName()); + { + log.warn("No injection target for service-ref: " + sref.getServiceRefName() + ". It will be just bound to JNDI registry."); + + Map encInjectors = null; + try { + encInjectors = container.getEncInjectors(); + } + catch (Exception e) + { + // I didn't find the way in the EJB API how to detect if container is + // client side container or server side container. + // Client side container throws RuntimeException when getEncInjectors() method is called. + } + if (encInjectors != null) + { + encInjectors.put(encName, new WebServiceRefEncInjector(encName, sref)); + } + } } // annotated classes do not specify injection target else if(!(annotatedElement instanceof java.lang.reflect.Type))