[jboss-cvs] JBossAS SVN: r61189 - in trunk: ejb3/src/main/org/jboss/injection and 12 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 7 09:03:33 EST 2007


Author: thomas.diesler at jboss.com
Date: 2007-03-07 09:03:32 -0500 (Wed, 07 Mar 2007)
New Revision: 61189

Added:
   trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java
   trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
   trunk/server/src/main/org/jboss/metadata/serviceref/CallPropertyMetaData.java
   trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainMetaData.java
   trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainsMetaData.java
   trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java
   trunk/server/src/main/org/jboss/metadata/serviceref/StubPropertyMetaData.java
   trunk/server/src/resources/dtd/service-ref_5_0.dtd
Removed:
   trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
   trunk/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java
   trunk/server/src/main/org/jboss/metamodel/descriptor/PortInfo.java
   trunk/server/src/main/org/jboss/metamodel/descriptor/WebServiceRefMetaData.java
   trunk/server/src/resources/dtd/webservice-ref_5_0.dtd
Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
   trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java
   trunk/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java
   trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
   trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
   trunk/server/.classpath
   trunk/server/build.xml
   trunk/server/src/main/org/jboss/deployment/ClientDeployer.java
   trunk/server/src/main/org/jboss/deployment/JBossEjbObjectFactory.java
   trunk/server/src/main/org/jboss/ejb/Container.java
   trunk/server/src/main/org/jboss/metadata/BeanMetaData.java
   trunk/server/src/main/org/jboss/metadata/ClientMetaData.java
   trunk/server/src/main/org/jboss/metadata/DDObjectFactory.java
   trunk/server/src/main/org/jboss/metadata/WebMetaData.java
   trunk/server/src/main/org/jboss/metadata/serviceref/HandlerMetaData.java
   trunk/server/src/main/org/jboss/metadata/serviceref/InitParamMetaData.java
   trunk/server/src/main/org/jboss/metadata/serviceref/PortComponentRefMetaData.java
   trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefHandler.java
   trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefMetaData.java
   trunk/server/src/main/org/jboss/metadata/web/JBossWebMetaDataObjectFactory.java
   trunk/server/src/main/org/jboss/metamodel/descriptor/DDObjectFactory.java
   trunk/server/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
   trunk/server/src/main/org/jboss/web/AbstractWebDeployer.java
   trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
   trunk/server/src/resources/dtd/jboss-client_5_0.dtd
   trunk/server/src/resources/dtd/jboss-web_5_0.dtd
   trunk/server/src/resources/dtd/jboss_5_0.dtd
   trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/JBossWebDDObjectFactory.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment2.java
Log:
consolidate <service-ref> handling

Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EjbJarDDObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -29,28 +29,27 @@
 import org.jboss.ejb3.KernelAbstraction;
 import org.jboss.ejb3.KernelAbstractionFactory;
 import org.jboss.logging.Logger;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
 import org.jboss.metadata.SecurityRoleRefMetaData;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.metamodel.descriptor.DDObjectFactory;
 import org.jboss.metamodel.descriptor.EjbLocalRef;
 import org.jboss.metamodel.descriptor.EjbRef;
 import org.jboss.metamodel.descriptor.EnvEntry;
 import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.PersistenceUnitRef;
 import org.jboss.metamodel.descriptor.NameValuePair;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.metamodel.descriptor.PersistenceUnitRef;
 import org.jboss.metamodel.descriptor.ResourceEnvRef;
 import org.jboss.metamodel.descriptor.ResourceRef;
 import org.jboss.metamodel.descriptor.RunAs;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
 import org.jboss.metamodel.descriptor.SecurityRole;
-import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
 
 /**
  * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data
@@ -670,7 +669,7 @@
       parent.addResourceRef(envRef);
    }
 
-   public void addChild(MessageDrivenBean parent, WebServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(MessageDrivenBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addServiceRef(envRef);
    }
@@ -771,7 +770,7 @@
    /**
     * Called when parsing character is complete.
     */
-   public void addChild(SessionEnterpriseBean parent, WebServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(SessionEnterpriseBean parent, ServiceRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addServiceRef(envRef);
    }
@@ -1037,7 +1036,7 @@
    /**
     * Called when parsing character is complete.
     */
-   public void addChild(Interceptor parent, WebServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(Interceptor parent, ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addServiceRef(ref);
    }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/EnterpriseBeans.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -26,8 +26,9 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+
 import org.jboss.logging.Logger;
-
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.metamodel.descriptor.EjbLocalRef;
 import org.jboss.metamodel.descriptor.EjbRef;
 import org.jboss.metamodel.descriptor.InjectionTarget;
@@ -35,7 +36,6 @@
 import org.jboss.metamodel.descriptor.MessageDestinationRef;
 import org.jboss.metamodel.descriptor.ResourceEnvRef;
 import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
 
 /**
  * Represents EJB elements of the ejb-jar.xml deployment descriptor for the 1.4
@@ -114,11 +114,16 @@
       currentEjb.mergeMessageDestinationRef(ref);
    }
    
-   public void addServiceRef(WebServiceRefMetaData ref)
+   public void addServiceRef(ServiceRefMetaData ref)
    {
       currentEjb.addServiceRef(ref);
    }
    
+   public ServiceRefMetaData getServiceRef(String name)
+   {
+      return currentEjb.getServiceRef(name);
+   }
+   
    public void setMethodAttributes(MethodAttributes attributes)
    {
       currentEjb.setMethodAttributes(attributes);

Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/Injectable.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -24,15 +24,15 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.metamodel.descriptor.EjbLocalRef;
 import org.jboss.metamodel.descriptor.EjbRef;
 import org.jboss.metamodel.descriptor.JndiRef;
 import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
 import org.jboss.metamodel.descriptor.PersistenceUnitRef;
 import org.jboss.metamodel.descriptor.ResourceEnvRef;
 import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
-import org.jboss.metamodel.descriptor.PersistenceContextRef;
 
 /**
  * 
@@ -50,7 +50,7 @@
 
    Collection<ResourceRef> getResourceRefs();
 
-   Collection<WebServiceRefMetaData> getServiceRefs();
+   Collection<ServiceRefMetaData> getServiceRefs();
 
    Collection<MessageDestinationRef> getMessageDestinationRefs();
 

Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -25,12 +25,12 @@
 import java.net.URL;
 
 import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.metamodel.descriptor.DDObjectFactory;
 import org.jboss.metamodel.descriptor.EjbRef;
 import org.jboss.metamodel.descriptor.MessageDestinationRef;
 import org.jboss.metamodel.descriptor.ResourceEnvRef;
 import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
 import org.jboss.util.xml.JBossEntityResolver;
 import org.jboss.xb.binding.JBossXBException;
 import org.jboss.xb.binding.Unmarshaller;
@@ -95,9 +95,22 @@
       dd.updateMessageDestinationRef(ref);
    }
 
-   public void addChild(ApplicationClientDD parent, WebServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(ApplicationClientDD parent, ServiceRefMetaData sref, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
-      dd.addServiceRef(ref);
+      String refName = sref.getServiceRefName();
+      if (refName == null)
+         throw new IllegalStateException("Invalid service-ref-name: " + refName);
+
+      ServiceRefMetaData targetRef = parent.getServiceRef(refName);
+      if (targetRef == null)
+      {
+         log.debug("Cannot find <service-ref> with name: " + refName);
+         parent.addServiceRef(sref);
+      }
+      else
+      {
+         targetRef.merge(sref);
+      }
    }
 
    public void addChild(ApplicationClientDD dd, ResourceEnvRef envRef, UnmarshallingContext navigator, String namespaceURI, String localName)

Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossDDObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -29,15 +29,8 @@
 import org.jboss.ejb3.KernelAbstraction;
 import org.jboss.ejb3.KernelAbstractionFactory;
 import org.jboss.logging.Logger;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
 import org.jboss.metadata.SecurityRoleMetaData;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.metamodel.descriptor.DDObjectFactory;
 import org.jboss.metamodel.descriptor.EjbLocalRef;
 import org.jboss.metamodel.descriptor.EjbRef;
@@ -47,8 +40,13 @@
 import org.jboss.metamodel.descriptor.NameValuePair;
 import org.jboss.metamodel.descriptor.ResourceEnvRef;
 import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
 
 /**
  * Represents the jboss.xml deployment descriptor for the 2.1 schema
@@ -664,9 +662,22 @@
    /**
     * Called when parsing character is complete.
     */
-   public void addChild(EnterpriseBeans parent, WebServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(EnterpriseBeans parent, ServiceRefMetaData sref, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
-      parent.addServiceRef(ref);
+      String refName = sref.getServiceRefName();
+      if (refName == null)
+         throw new IllegalStateException("Invalid service-ref-name: " + refName);
+
+      ServiceRefMetaData targetRef = parent.getServiceRef(refName);
+      if (targetRef == null)
+      {
+         log.debug("Cannot find <service-ref> with name: " + refName);
+         parent.addServiceRef(sref);
+      }
+      else
+      {
+         targetRef.merge(sref);
+      }
    }
 
    /**

Copied: trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java (from rev 61183, branches/tdiesler/trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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;
+
+// $Id$
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceException;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefHandler;
+import org.jboss.metadata.serviceref.ServiceRefHandlerFactory;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Inject a web service ref.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @version $Revision$
+ */
+public class ServiceRefInjector implements EncInjector
+{
+   private static final Logger log = Logger.getLogger(ServiceRefInjector.class);
+
+   private String name;
+   private AnnotatedElement anElement;
+
+   private ServiceRefMetaData sref;
+
+   public ServiceRefInjector(String name, AnnotatedElement anElement, ServiceRefMetaData sref)
+   {
+      this.name = name;
+      this.anElement = anElement;
+      this.sref = sref;
+   }
+
+   public void inject(InjectionContainer container)
+   {
+      try
+      {
+         Context encCtx = container.getEnc();
+         VirtualFile vfsRoot = container.getRootFile();
+
+         ServiceRefHandler factory = ServiceRefHandlerFactory.newInstance();
+         factory.setupServiceRef(encCtx, name, anElement, vfsRoot, sref.toXMLFragmet());
+
+         log.debug("ServiceRef bound [env=" + name + "]");
+      }
+      catch (Exception e)
+      {
+         throw new WebServiceException("Unable to bind ServiceRef [enc=" + name + "]", e);
+      }
+   }
+
+   public String toString()
+   {
+      return super.toString() + "{enc=" + name + "}";
+   }
+}

Deleted: trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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;
-
-// $Id$
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.naming.Context;
-import javax.xml.ws.WebServiceRef;
-import javax.xml.ws.WebServiceRefs;
-
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
-
-/**
- * Handle @WebServiceRef annotations
- * 
- * @author Thomas.Diesler at jboss.com
- */
-public class WebServiceRefHandler implements InjectionHandler
-{
-   private static final Logger log = Logger.getLogger(WebServiceRefHandler.class);
-   private Map<String, WebServiceRefMetaData> srefMap = new HashMap<String, WebServiceRefMetaData>();
-
-   public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
-   {
-      if (xml == null) return;
-      if (xml.getServiceRefs() == null) return;
-      for (WebServiceRefMetaData sref : xml.getServiceRefs())
-      {
-         log.debug("@WebServiceRef override: " + sref);
-         if (srefMap.get(sref.getServiceRefName()) != null)
-               throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
-         
-         srefMap.put(sref.getServiceRefName(), sref);
-      }
-   }
-
-   public void handleClassAnnotations(Class type, InjectionContainer container)
-   {
-      WebServiceRef wsref = container.getAnnotation(WebServiceRef.class, type);
-      if (wsref != null)
-      {
-         bindRefOnType(type, container, wsref);
-      }
-
-      WebServiceRefs refs = container.getAnnotation(WebServiceRefs.class, type);
-      if (refs != null)
-      {
-         for (WebServiceRef refItem : refs.value())
-         {
-            bindRefOnType(type, container, refItem);
-         }
-      }
-   }
-
-   private void bindRefOnType(Class type, InjectionContainer container, WebServiceRef wsref)
-   {
-      String name = wsref.name();
-      if (name.equals(""))
-         name = InjectionUtil.getEncName(type).substring(4);
-      
-      if (!container.getEncInjectors().containsKey(name))
-      {
-         String encName = "env/" + name;
-         WebServiceRefMetaData sref = getServiceRef(name);
-         container.getEncInjectors().put(name, new WebServiceRefInjector(encName, type, sref));
-      }
-   }
-
-   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
-   {
-      WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
-      if (wsref == null) return;
-
-      if (!method.getName().startsWith("set"))
-         throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);
-
-      String name = wsref.name();
-      if (name.equals(""))
-         name = InjectionUtil.getEncName(method).substring(4);
-      
-      String encName = "env/" + name;
-      Context encCtx = container.getEnc();
-      if (!container.getEncInjectors().containsKey(name))
-      {
-         WebServiceRefMetaData sref = getServiceRef(name);
-         container.getEncInjectors().put(name, new WebServiceRefInjector(encName, method, sref));
-      }
-
-      injectors.put(method, new JndiMethodInjector(method, encName, encCtx));
-   }
-
-   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
-   {
-      WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
-      if (wsref == null) return;
-
-      String name = wsref.name();
-      if (name.equals(""))
-         name = InjectionUtil.getEncName(field).substring(4);
-
-      String encName = "env/" + name;
-      Context encCtx = container.getEnc();
-      if (!container.getEncInjectors().containsKey(name))
-      {
-         WebServiceRefMetaData sref = getServiceRef(name);
-         container.getEncInjectors().put(name, new WebServiceRefInjector(encName, field, sref));
-      }
-
-      injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
-   }
-
-   private WebServiceRefMetaData getServiceRef(String name)
-   {
-      WebServiceRefMetaData sref = srefMap.get(name);
-      if (sref == null)
-      {
-         log.debug("No override for @WebServiceRef.name: " + name);
-         sref = new WebServiceRefMetaData();
-         sref.setServiceRefName(name);
-      }
-      return sref;
-   }
-}

Copied: trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java (from rev 61183, branches/tdiesler/trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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;
+
+// $Id$
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+
+/**
+ * Handle @WebServiceRef annotations
+ * 
+ * @author Thomas.Diesler at jboss.com
+ */
+public class WebServiceRefHandler implements InjectionHandler
+{
+   private static final Logger log = Logger.getLogger(WebServiceRefHandler.class);
+   private Map<String, ServiceRefMetaData> srefMap = new HashMap<String, ServiceRefMetaData>();
+
+   public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+   {
+      if (xml == null) return;
+      if (xml.getServiceRefs() == null) return;
+      for (ServiceRefMetaData sref : xml.getServiceRefs())
+      {
+         log.debug("service-ref: " + sref);
+         if (srefMap.get(sref.getServiceRefName()) != null)
+               throw new IllegalStateException ("Duplicate <service-ref-name> in " + sref);
+         
+         srefMap.put(sref.getServiceRefName(), sref);
+      }
+   }
+
+   public void handleClassAnnotations(Class type, InjectionContainer container)
+   {
+      WebServiceRef wsref = container.getAnnotation(WebServiceRef.class, type);
+      if (wsref != null)
+      {
+         bindRefOnType(type, container, wsref);
+      }
+
+      WebServiceRefs refs = container.getAnnotation(WebServiceRefs.class, type);
+      if (refs != null)
+      {
+         for (WebServiceRef refItem : refs.value())
+         {
+            bindRefOnType(type, container, refItem);
+         }
+      }
+   }
+
+   private void bindRefOnType(Class type, InjectionContainer container, WebServiceRef wsref)
+   {
+      String name = wsref.name();
+      if (name.equals(""))
+         name = InjectionUtil.getEncName(type).substring(4);
+      
+      if (!container.getEncInjectors().containsKey(name))
+      {
+         String encName = "env/" + name;
+         ServiceRefMetaData sref = getServiceRef(name);
+         container.getEncInjectors().put(name, new ServiceRefInjector(encName, type, sref));
+      }
+   }
+
+   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      WebServiceRef wsref = method.getAnnotation(WebServiceRef.class);
+      if (wsref == null) return;
+
+      if (!method.getName().startsWith("set"))
+         throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);
+
+      String name = wsref.name();
+      if (name.equals(""))
+         name = InjectionUtil.getEncName(method).substring(4);
+      
+      String encName = "env/" + name;
+      Context encCtx = container.getEnc();
+      if (!container.getEncInjectors().containsKey(name))
+      {
+         ServiceRefMetaData sref = getServiceRef(name);
+         container.getEncInjectors().put(name, new ServiceRefInjector(encName, method, sref));
+      }
+
+      injectors.put(method, new JndiMethodInjector(method, encName, encCtx));
+   }
+
+   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+   {
+      WebServiceRef wsref = field.getAnnotation(WebServiceRef.class);
+      if (wsref == null) return;
+
+      String name = wsref.name();
+      if (name.equals(""))
+         name = InjectionUtil.getEncName(field).substring(4);
+
+      String encName = "env/" + name;
+      Context encCtx = container.getEnc();
+      if (!container.getEncInjectors().containsKey(name))
+      {
+         ServiceRefMetaData sref = getServiceRef(name);
+         container.getEncInjectors().put(name, new ServiceRefInjector(encName, field, sref));
+      }
+
+      injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
+   }
+
+   private ServiceRefMetaData getServiceRef(String name)
+   {
+      ServiceRefMetaData sref = srefMap.get(name);
+      if (sref == null)
+      {
+         log.debug("No override for @WebServiceRef.name: " + name);
+         sref = new ServiceRefMetaData();
+         sref.setServiceRefName(name);
+      }
+      return sref;
+   }
+}

Deleted: trunk/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/ejb3/src/main/org/jboss/injection/WebServiceRefInjector.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -1,108 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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;
-
-// $Id$
-
-import java.io.IOException;
-import java.lang.reflect.AnnotatedElement;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.ws.WebServiceException;
-
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
-import org.jboss.mx.util.MBeanProxy;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.util.xml.DOMUtils;
-import org.jboss.virtual.VirtualFile;
-import org.w3c.dom.Element;
-
-/**
- * Inject a jaxws web service ref.
- *
- * @author Thomas.Diesler at jboss.com
- * @version $Revision$
- */
-public class WebServiceRefInjector implements EncInjector
-{
-   private static final Logger log = Logger.getLogger(WebServiceRefInjector.class);
-
-   private String name;
-   private AnnotatedElement anElement;
-
-   private WebServiceRefMetaData sref;
-
-   // The @WebServiceRef handler MBean interface
-   // is duplicated here to avoid a binary dependency on JBossWS
-   public interface WebServiceRefHandlerMBean
-   {
-      ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.ws:service=WebServiceRefHandler");
-      void setupWebServiceRef(Context encCtx, String encName, AnnotatedElement anElement, VirtualFile vfsRoot, Source metadata) throws NamingException;
-   }
-
-   public WebServiceRefInjector(String name, AnnotatedElement anElement, WebServiceRefMetaData sref)
-   {
-      this.name = name;
-      this.anElement = anElement;
-      this.sref = sref;
-   }
-
-   public void inject(InjectionContainer container)
-   {
-      try
-      {
-         Context encCtx = container.getEnc();
-         VirtualFile vfsRoot = container.getRootFile();
-
-         // Decoupled invocation to JBossWS 
-         MBeanServer server = MBeanServerLocator.locateJBoss();
-         ObjectName oname = WebServiceRefHandlerMBean.OBJECT_NAME;
-         WebServiceRefHandlerMBean handler = (WebServiceRefHandlerMBean)MBeanProxy.get(WebServiceRefHandlerMBean.class, oname, server);
-         handler.setupWebServiceRef(encCtx, name, anElement, vfsRoot, getMetaData());
-         
-         log.debug("@WebServiceRef bound [env=" + name + "]");
-      }
-      catch (Exception e)
-      {
-         throw new WebServiceException("Unable to bind @WebServiceRef [enc=" + name + "]", e);
-      }
-   }
-
-   private Source getMetaData() throws IOException
-   {
-      String xmlFragment = sref.toXMLFragment();
-      Element root = DOMUtils.parse(xmlFragment);
-      return new DOMSource(root);
-   }
-
-   public String toString()
-   {
-      return super.toString() + "{enc=" + name + "}";
-   }
-}

Modified: trunk/server/.classpath
===================================================================
--- trunk/server/.classpath	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/.classpath	2007-03-07 14:03:32 UTC (rev 61189)
@@ -35,5 +35,6 @@
 	<classpathentry kind="lib" path="/thirdparty/jboss/jbossws/lib/jboss-jaxrpc.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jbossws/lib/jboss-saaj.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/dom4j/lib/dom4j.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: trunk/server/build.xml
===================================================================
--- trunk/server/build.xml	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/build.xml	2007-03-07 14:03:32 UTC (rev 61189)
@@ -78,6 +78,7 @@
       <path refid="apache.commons.classpath"/>
       <path refid="apache.log4j.classpath"/>
       <path refid="apache.xerces.classpath"/>
+      <path refid="dom4j.dom4j.classpath"/>
       <path refid="gjt.jpl-util.classpath"/>
       <path refid="gnu.getopt.classpath"/>
       <path refid="ibm.wsdl4j.classpath"/>

Modified: trunk/server/src/main/org/jboss/deployment/ClientDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/ClientDeployer.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/deployment/ClientDeployer.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -50,6 +50,7 @@
 import org.jboss.metadata.XmlFileLoader;
 import org.jboss.metadata.serviceref.ServiceRefHandler;
 import org.jboss.metadata.serviceref.ServiceRefHandlerFactory;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.naming.Util;
 import org.jboss.util.xml.DOMUtils;
 import org.jboss.virtual.VirtualFile;
@@ -269,10 +270,16 @@
       }
 
       // Bind <service-ref> elements
-      Iterator serviceRefs = metaData.getServiceReferences().values().iterator();
       ServiceRefHandler refHandler = ServiceRefHandlerFactory.newInstance();
-      if (refHandler != null && serviceRefs.hasNext())
-         refHandler.bindServiceRefs(envCtx, serviceRefs, unit);
+      if (refHandler != null)
+      {
+         for (ServiceRefMetaData sref : metaData.getServiceRefs().values())
+         {
+            String encName = sref.getServiceRefName();
+            VirtualFile vfsRoot = unit.getDeploymentContext().getRoot();
+            refHandler.setupServiceRef(envCtx, encName, null, vfsRoot, sref.toXMLFragmet());
+         }
+      }
 
       // Bind resource references
       HashMap resRefs = metaData.getResourceReferences();

Modified: trunk/server/src/main/org/jboss/deployment/JBossEjbObjectFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossEjbObjectFactory.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/deployment/JBossEjbObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -576,18 +576,22 @@
       ref.setJndiName(child.getJndiName());
    }
 
-   public void addChild(BeanHolder parent, ServiceRefMetaData sourceRef,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(BeanHolder parent, ServiceRefMetaData sref, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
-      String refName = sourceRef.getServiceRefName();
+      String refName = sref.getServiceRefName();
       if (refName == null)
          throw new IllegalStateException("Invalid service-ref-name: " + refName);
-      
+
       ServiceRefMetaData targetRef = parent.metaData.getServiceRef(refName);
       if (targetRef == null)
-         throw new IllegalStateException("Cannot find service-ref: " + refName);
-      
-      targetRef.merge(sourceRef);
+      {
+         log.debug("Cannot find <service-ref> with name: " + refName);
+         parent.metaData.addServiceRef(sref);
+      }
+      else
+      {
+         targetRef.merge(sref);
+      }
    }
 
    public void addChild(InvokerMetaData parent, InvokerMetaData.EjbRef child,

Modified: trunk/server/src/main/org/jboss/ejb/Container.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/Container.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/ejb/Container.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -75,6 +75,7 @@
 import org.jboss.metadata.ResourceRefMetaData;
 import org.jboss.metadata.serviceref.ServiceRefHandler;
 import org.jboss.metadata.serviceref.ServiceRefHandlerFactory;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.mx.util.ObjectNameConverter;
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.naming.ENCThreadLocalKey;
@@ -88,6 +89,7 @@
 import org.jboss.system.ServiceMBeanSupport;
 import org.jboss.util.NestedError;
 import org.jboss.util.NestedRuntimeException;
+import org.jboss.virtual.VirtualFile;
 import org.omg.CORBA.ORB;
 
 /**
@@ -115,19 +117,16 @@
  *
  * @jmx.mbean extends="org.jboss.system.ServiceMBean"
  */
-public abstract class Container extends ServiceMBeanSupport
-   implements ContainerMBean, AllowedOperationsFlags
+public abstract class Container extends ServiceMBeanSupport implements ContainerMBean, AllowedOperationsFlags
 {
-   public final static String BASE_EJB_CONTAINER_NAME =
-           "jboss.j2ee:service=EJB";
+   public final static String BASE_EJB_CONTAINER_NAME = "jboss.j2ee:service=EJB";
 
    public final static ObjectName ORB_NAME = ObjectNameFactory.create("jboss:service=CorbaORB");
-   
-   public final static ObjectName EJB_CONTAINER_QUERY_NAME =
-           ObjectNameFactory.create(BASE_EJB_CONTAINER_NAME + ",*");
 
+   public final static ObjectName EJB_CONTAINER_QUERY_NAME = ObjectNameFactory.create(BASE_EJB_CONTAINER_NAME + ",*");
+
    protected static final Method EJBOBJECT_REMOVE;
-   
+
    /** A reference to {@link javax.ejb.TimedObject#ejbTimeout}. */
    protected static final Method EJB_TIMEOUT;
 
@@ -147,7 +146,7 @@
    /**
     * Externally supplied configuration data
     */
-   private DeploymentUnit di;
+   private DeploymentUnit unit;
 
    /**
     * This is the new metadata. it includes information from both ejb-jar and
@@ -176,7 +175,7 @@
 
    /** This is the SecurityManager */
    protected AuthenticationManager sm;
-   
+
    /** Authorization Manager */
    protected AuthorizationManager authorizationManager;
 
@@ -190,8 +189,7 @@
    protected BeanLockManager lockManager;
 
    /** ??? */
-   protected LocalProxyFactory localProxyFactory =
-           new BaseLocalProxyFactory();
+   protected LocalProxyFactory localProxyFactory = new BaseLocalProxyFactory();
 
    /** This is a cache for method permissions */
    private HashMap methodPermissionsCache = new HashMap();
@@ -201,10 +199,10 @@
 
    /** ObjectName of Container */
    private ObjectName jmxName;
-   
+
    /** HashMap<String, EJBProxyFactory> for the invoker bindings */
    protected HashMap proxyFactories = new HashMap();
-   
+
    /** A priviledged actions for MBeanServer.invoke when running with sec mgr */
    private MBeanServerAction serverAction = new MBeanServerAction();
 
@@ -216,27 +214,27 @@
 
    /** The number of create invocations that have been made */
    protected long createCount;
-   
+
    /** The number of create invocations that have been made */
    protected long removeCount;
-   
+
    /** Time statistics for the invoke(Invocation) methods */
    protected InvocationStatistics invokeStats = new InvocationStatistics();
 
    /** The JACC context id for the container */
    protected String jaccContextID;
-   
+
    /** 
     * Flag to denote whether a JACC configuration has been fitted for authorization 
-    */ 
-   protected boolean isJaccEnabled = false; 
+    */
+   protected boolean isJaccEnabled = false;
 
    static
    {
       try
       {
          EJBOBJECT_REMOVE = EJBObject.class.getMethod("remove", new Class[0]);
-         EJB_TIMEOUT = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class});
+         EJB_TIMEOUT = TimedObject.class.getMethod("ejbTimeout", new Class[] { Timer.class });
       }
       catch (Throwable t)
       {
@@ -281,7 +279,7 @@
          return true;
       return metaData.isCallByValue();
    }
-   
+
    /**
     * Sets a transaction manager for this container.
     *
@@ -312,7 +310,7 @@
    public AuthenticationManager getSecurityManager()
    {
       return sm;
-   }  
+   }
 
    /**
     * Get the authorizationManager.
@@ -383,7 +381,7 @@
       {
          Iterator i = proxyFactories.values().iterator();
          if (i.hasNext())
-            factory = (EJBProxyFactory) i.next();
+            factory = (EJBProxyFactory)i.next();
       }
       return factory;
    }
@@ -395,7 +393,7 @@
 
    public EJBProxyFactory lookupProxyFactory(String binding)
    {
-      return (EJBProxyFactory) proxyFactories.get(binding);
+      return (EJBProxyFactory)proxyFactories.get(binding);
    }
 
    /**
@@ -407,6 +405,7 @@
    {
       return null;
    }
+
    /**
     * Sets the DeploymentInfo of this Container
     * @deprecated use DeploymentUnit accessors
@@ -418,12 +417,12 @@
 
    public final DeploymentUnit getDeploymentUnit()
    {
-      return di;
+      return unit;
    }
-   
+
    public final void setDeploymentUnit(DeploymentUnit di)
    {
-      this.di = di;
+      this.unit = di;
    }
 
    /**
@@ -441,30 +440,30 @@
    {
       return jaccContextID;
    }
-   
+
    public void setJaccContextID(String id)
    {
       jaccContextID = id;
-   } 
-   
+   }
+
    /** 
     * Get the flag whether JACC is enabled  
     * @return 
-    */ 
-   public boolean isJaccEnabled() 
-   { 
-      return isJaccEnabled; 
+    */
+   public boolean isJaccEnabled()
+   {
+      return isJaccEnabled;
    }
-   
+
    /**
     * Set the flag that JACC is enabled 
     *  
     * @param isJaccEnabled 
-    */ 
-   public void setJaccEnabled(boolean isJaccEnabled) 
-   { 
-      this.isJaccEnabled = isJaccEnabled; 
-   } 
+    */
+   public void setJaccEnabled(boolean isJaccEnabled)
+   {
+      this.isJaccEnabled = isJaccEnabled;
+   }
 
    /**
     * Gets the application deployment unit for this container. All the bean
@@ -568,7 +567,7 @@
     */
    public void cleanENC()
    {
-      ENCFactory.getEncById().remove(getJmxName());   
+      ENCFactory.getEncById().remove(getJmxName());
    }
 
    /** Get the components environment context
@@ -610,9 +609,9 @@
 
       if (methodPermissionsCache.containsKey(m))
       {
-         permissions = (Set) methodPermissionsCache.get(m);
+         permissions = (Set)methodPermissionsCache.get(m);
       }
-      else if( m.equals(EJB_TIMEOUT) )
+      else if (m.equals(EJB_TIMEOUT))
       {
          // No role is required to access the ejbTimeout as this is 
          permissions = new HashSet();
@@ -679,7 +678,7 @@
     return codebase;
     }
     */
-   
+
    /** Build a JMX name using the pattern jboss.j2ee:service=EJB,jndiName=[jndiName]
     where the [jndiName] is either the bean remote home JNDI binding, or
     the local home JNDI binding if the bean has no remote interfaces.
@@ -726,14 +725,13 @@
     *
     * @jmx.managed-operation
     **/
-   public TimerService getTimerService(Object pKey)
-           throws IllegalStateException
+   public TimerService getTimerService(Object pKey) throws IllegalStateException
    {
       if (this instanceof StatefulSessionContainer)
          throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService");
 
       // Validate that the bean implements the TimedObject interface
-      if( TimedObject.class.isAssignableFrom(beanClass) == false )
+      if (TimedObject.class.isAssignableFrom(beanClass) == false)
       {
          // jbcts-381
          return EJBTimerServiceImpl.FOR_NON_TIMED_OBJECT;
@@ -760,8 +758,7 @@
     *
     * @jmx.managed-operation
     **/
-   public void removeTimerService(Object pKey)
-           throws IllegalStateException
+   public void removeTimerService(Object pKey) throws IllegalStateException
    {
       try
       {
@@ -793,18 +790,15 @@
       {
          // TODO: this name needs to be externalized
          // pass to the ejb timer service the container ObjectName
-         server.invoke(
-               EJBTimerService.OBJECT_NAME,
-               "restoreTimers",
-               new Object[] { getServiceName(), getClassLoader() },
-               new String[] { "javax.management.ObjectName" , "java.lang.ClassLoader" } );
+         server.invoke(EJBTimerService.OBJECT_NAME, "restoreTimers", new Object[] { getServiceName(), getClassLoader() }, new String[] { "javax.management.ObjectName",
+               "java.lang.ClassLoader" });
       }
       catch (Exception e)
       {
          log.warn("Could not restore ejb timers", e);
       }
    }
-   
+
    /**
     * The EJBDeployer calls this method.  The EJBDeployer has set
     * all the plugins and interceptors that this bean requires and now proceeds
@@ -852,7 +846,7 @@
    {
       // Setup "java:comp/env" namespace
       setupEnvironment();
-      
+
       localProxyFactory.start();
    }
 
@@ -931,7 +925,7 @@
       try
       {
          pushENC();
-         
+
          // JBAS-3732 - Remove classloader.equals optimization
          SecurityActions.setContextClassLoader(this.classLoader);
 
@@ -939,13 +933,13 @@
          mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID);
          contextID = SecurityActions.setContextID(contextID);
          // Set the standard JACC policy context handler data is not a SEI msg
-         if( mi.getType() != InvocationType.SERVICE_ENDPOINT )
+         if (mi.getType() != InvocationType.SERVICE_ENDPOINT)
          {
             EJBArgsPolicyContextHandler.setArgs(mi.getArguments());
          }
          else
          {
-            SOAPMessage msg = (SOAPMessage) mi.getValue(InvocationKey.SOAP_MESSAGE);
+            SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE);
             SOAPMsgPolicyContextHandler.setMessage(msg);
          }
          // Set custom JACC policy handlers
@@ -958,21 +952,17 @@
          // stat gathering: concurrent calls
          this.invokeStats.callIn();
 
-         if (type == InvocationType.REMOTE ||
-                 type == InvocationType.LOCAL ||
-                 // web service calls come in as "ordinary" application invocations
-                 type == InvocationType.SERVICE_ENDPOINT)
+         if (type == InvocationType.REMOTE || type == InvocationType.LOCAL ||
+         // web service calls come in as "ordinary" application invocations
+               type == InvocationType.SERVICE_ENDPOINT)
          {
             if (mi instanceof MarshalledInvocation)
             {
-               ((MarshalledInvocation) mi).setMethodMap(
-                       marshalledInvocationMapping);
+               ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping);
 
                if (log.isTraceEnabled())
                {
-                  log.trace("METHOD REMOTE INVOKE " +
-                          mi.getObjectName() + "||" +
-                          mi.getMethod().getName() + "||");
+                  log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||");
                }
             }
 
@@ -981,21 +971,16 @@
             Object obj = internalInvoke(mi);
             return obj;
          }
-         else if (type == InvocationType.HOME ||
-                 type == InvocationType.LOCALHOME)
+         else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME)
          {
             if (mi instanceof MarshalledInvocation)
             {
 
-               ((MarshalledInvocation) mi).setMethodMap(
-                       marshalledInvocationMapping);
+               ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping);
 
                if (log.isTraceEnabled())
                {
-                  log.trace("METHOD HOME INVOKE " +
-                          mi.getObjectName() + "||" +
-                          mi.getMethod().getName() + "||" +
-                          mi.getArguments().toString());
+                  log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString());
                }
             }
             m = mi.getMethod();
@@ -1005,8 +990,7 @@
          }
          else
          {
-            throw new MBeanException(new IllegalArgumentException(
-                    "Unknown invocation type: " + type));
+            throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type));
          }
       }
       /**
@@ -1017,9 +1001,7 @@
       catch (JBossLazyUnmarshallingException e)
       {
          InvocationType calltype = mi.getType();
-         boolean isLocal =
-               calltype == InvocationType.LOCAL ||
-               calltype == InvocationType.LOCALHOME;
+         boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME;
 
          // handle unmarshalling exception which should only come if problem unmarshalling
          // invocation payload, arguments, or value on remote end.
@@ -1062,7 +1044,7 @@
             // Remove args from ThreadLocal to prevent leakage into the thread pool
             EJBArgsPolicyContextHandler.setArgs(null);
          }
-         
+
          // Remove metadata from ThreadLocal to prevent leakage into the thread pool
          BeanMetaDataPolicyContextHandler.setMetaData(null);
       }
@@ -1088,17 +1070,17 @@
       HandleDelegate hd = null;
       try
       {
-         orb = (ORB) server.getAttribute(ORB_NAME, "ORB");
-         hd =  (HandleDelegate) server.getAttribute(ORB_NAME, "HandleDelegate");
+         orb = (ORB)server.getAttribute(ORB_NAME, "ORB");
+         hd = (HandleDelegate)server.getAttribute(ORB_NAME, "HandleDelegate");
       }
       catch (Throwable t)
       {
          log.debug("Unable to retrieve orb" + t.toString());
       }
-      
+
       // Since the BCL is already associated with this thread we can start
       // using the java: namespace directly
-      Context ctx = (Context) new InitialContext().lookup("java:comp");
+      Context ctx = (Context)new InitialContext().lookup("java:comp");
 
       // Bind the orb
       if (orb != null)
@@ -1109,7 +1091,7 @@
          NonSerializableFactory.rebind(ctx, "HandleDelegate", hd);
          log.debug("Bound java:comp:/HandleDelegate for EJB: " + getBeanMetaData().getEjbName());
       }
-      
+
       Context envCtx = ctx.createSubcontext("env");
 
       // Bind environment properties
@@ -1117,9 +1099,8 @@
          Iterator i = beanMetaData.getEnvironmentEntries();
          while (i.hasNext())
          {
-            EnvEntryMetaData entry = (EnvEntryMetaData) i.next();
-            log.debug("Binding env-entry: " + entry.getName() + " of type: " +
-                  entry.getType() + " to value:" + entry.getValue());
+            EnvEntryMetaData entry = (EnvEntryMetaData)i.next();
+            log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue());
 
             EnvEntryMetaData.bindEnvEntry(envCtx, entry);
          }
@@ -1130,27 +1111,23 @@
          Iterator i = beanMetaData.getEjbReferences();
          while (i.hasNext())
          {
-            EjbRefMetaData ref = (EjbRefMetaData) i.next();
+            EjbRefMetaData ref = (EjbRefMetaData)i.next();
             log.debug("Binding an EJBReference " + ref.getName());
 
             if (ref.getLink() != null)
             {
                // Internal link
                String linkName = ref.getLink();
-               String jndiName = EjbUtil.findEjbLink(server, di, linkName);
-               log.debug("Binding " + ref.getName() +
-                     " to ejb-link: " + linkName + " -> " + jndiName);
-               
+               String jndiName = EjbUtil.findEjbLink(server, unit, linkName);
+               log.debug("Binding " + ref.getName() + " to ejb-link: " + linkName + " -> " + jndiName);
+
                if (jndiName == null)
                {
-                  String msg = "Failed to resolve ejb-link: " + linkName
-                          + " make by ejb-name: " + ref.getName();
+                  String msg = "Failed to resolve ejb-link: " + linkName + " make by ejb-name: " + ref.getName();
                   throw new DeploymentException(msg);
                }
 
-               Util.bind(envCtx,
-                       ref.getName(),
-                       new LinkRef(jndiName));
+               Util.bind(envCtx, ref.getName(), new LinkRef(jndiName));
 
             }
             else
@@ -1160,7 +1137,7 @@
                Reference reference = null;
                while (it.hasNext())
                {
-                  String invokerBinding = (String) it.next();
+                  String invokerBinding = (String)it.next();
                   // Check for an invoker level jndi-name
                   String name = ref.getInvokerBinding(invokerBinding);
                   // Check for an global jndi-name
@@ -1168,21 +1145,15 @@
                      name = ref.getJndiName();
                   if (name == null)
                   {
-                     throw new DeploymentException
-                             ("ejb-ref " + ref.getName() +
-                             ", expected either ejb-link in ejb-jar.xml or " +
-                             "jndi-name in jboss.xml");
+                     throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml or " + "jndi-name in jboss.xml");
                   }
 
                   StringRefAddr addr = new StringRefAddr(invokerBinding, name);
-                  log.debug("adding " + invokerBinding + ":" + name +
-                          " to Reference");
+                  log.debug("adding " + invokerBinding + ":" + name + " to Reference");
 
                   if (reference == null)
                   {
-                     reference = new Reference("javax.naming.LinkRef",
-                             ENCThreadLocalKey.class.getName(),
-                             null);
+                     reference = new Reference("javax.naming.LinkRef", ENCThreadLocalKey.class.getName(), null);
                   }
                   reference.add(addr);
                }
@@ -1193,18 +1164,17 @@
                   if (ref.getJndiName() != null)
                   {
                      // Add default for the bean level ejb-ref/jndi-name
-                     StringRefAddr addr =
-                             new StringRefAddr("default", ref.getJndiName());
+                     StringRefAddr addr = new StringRefAddr("default", ref.getJndiName());
                      reference.add(addr);
                   }
                   if (reference.size() == 1 && reference.get("default") == null)
                   {
                      /* There is only one invoker binding and its not default so
-                     create a default binding to allow the link to have a value
-                     when accessed without an invoker active.
-                     */
-                     StringRefAddr addr = (StringRefAddr) reference.get(0);
-                     String target = (String) addr.getContent();
+                      create a default binding to allow the link to have a value
+                      when accessed without an invoker active.
+                      */
+                     StringRefAddr addr = (StringRefAddr)reference.get(0);
+                     String target = (String)addr.getContent();
                      StringRefAddr addr1 = new StringRefAddr("default", target);
                      reference.add(addr1);
                   }
@@ -1215,13 +1185,9 @@
                   // Bind the bean level ejb-ref/jndi-name
                   if (ref.getJndiName() == null)
                   {
-                     throw new DeploymentException("ejb-ref " + ref.getName() +
-                             ", expected either ejb-link in ejb-jar.xml " +
-                             "or jndi-name in jboss.xml");
+                     throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or jndi-name in jboss.xml");
                   }
-                  Util.bind(envCtx,
-                          ref.getName(),
-                          new LinkRef(ref.getJndiName()));
+                  Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName()));
                }
             }
          }
@@ -1232,7 +1198,7 @@
          Iterator i = beanMetaData.getEjbLocalReferences();
          while (i.hasNext())
          {
-            EjbLocalRefMetaData ref = (EjbLocalRefMetaData) i.next();
+            EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next();
             String refName = ref.getName();
             log.debug("Binding an EJBLocalReference " + ref.getName());
 
@@ -1241,46 +1207,44 @@
                // Internal link
                log.debug("Binding " + refName + " to bean source: " + ref.getLink());
 
-               String jndiName = EjbUtil.findLocalEjbLink(server, di,
-                       ref.getLink());
+               String jndiName = EjbUtil.findLocalEjbLink(server, unit, ref.getLink());
 
-               Util.bind(envCtx,
-                       ref.getName(),
-                       new LinkRef(jndiName));
+               Util.bind(envCtx, ref.getName(), new LinkRef(jndiName));
             }
             else
             {
                // Bind the bean level ejb-local-ref/local-jndi-name
                if (ref.getJndiName() == null)
                {
-                  throw new DeploymentException("ejb-local-ref " + ref.getName() +
-                          ", expected either ejb-link in ejb-jar.xml " +
-                          "or local-jndi-name in jboss.xml");
+                  throw new DeploymentException("ejb-local-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or local-jndi-name in jboss.xml");
                }
-               Util.bind(envCtx,
-                       ref.getName(),
-                       new LinkRef(ref.getJndiName()));
+               Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName()));
             }
          }
       }
 
       // Bind service references
-      Iterator serviceRefs = metaData.getServiceRefs().values().iterator();
       ServiceRefHandler refHandler = ServiceRefHandlerFactory.newInstance();
-      if (refHandler != null && serviceRefs.hasNext())
-         refHandler.bindServiceRefs(envCtx, serviceRefs, di);
+      if (refHandler != null)
+      {
+         for (ServiceRefMetaData sref : metaData.getServiceRefs().values())
+         {
+            String encName = sref.getServiceRefName();
+            VirtualFile vfsRoot = unit.getDeploymentContext().getRoot();
+            refHandler.setupServiceRef(envCtx, encName, null, vfsRoot, sref.toXMLFragmet());
+         }
+      }
 
       // Bind resource references
       {
          Iterator i = beanMetaData.getResourceReferences();
 
          // let's play guess the cast game ;)  New metadata should fix this.
-         ApplicationMetaData application =
-                 beanMetaData.getApplicationMetaData();
+         ApplicationMetaData application = beanMetaData.getApplicationMetaData();
 
          while (i.hasNext())
          {
-            ResourceRefMetaData ref = (ResourceRefMetaData) i.next();
+            ResourceRefMetaData ref = (ResourceRefMetaData)i.next();
 
             String resourceName = ref.getResourceName();
             String finalName = application.getResourceByName(resourceName);
@@ -1319,8 +1283,7 @@
                // POTENTIALLY DANGEROUS: should this be a critical error?
                if (finalName == null)
                {
-                  log.warn("No resource manager found for " +
-                          ref.getResourceName());
+                  log.warn("No resource manager found for " + ref.getResourceName());
                   continue;
                }
             }
@@ -1328,11 +1291,10 @@
             if (resType.equals("java.net.URL"))
             {
                // URL bindings
-               if( ref.getResURL() != null )
+               if (ref.getResURL() != null)
                {
                   // The URL string was given by the res-url
-                  log.debug("Binding URL: " + ref.getRefName() +
-                          " to JDNI ENC as: " + ref.getResURL());
+                  log.debug("Binding URL: " + ref.getRefName() + " to JDNI ENC as: " + ref.getResURL());
                   URL resURL = new URL(ref.getResURL());
                   Util.bind(envCtx, ref.getRefName(), resURL);
                }
@@ -1340,7 +1302,7 @@
                {
                   log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName);
                   Object bind = null;
-                  if( ref.getJndiName() != null )
+                  if (ref.getJndiName() != null)
                   {
                      // Was the url given as a jndi-name reference to link to it
                      bind = new LinkRef(finalName);
@@ -1356,8 +1318,7 @@
             else
             {
                // Resource Manager bindings, should validate the type...
-               log.debug("Binding resource manager: " + ref.getRefName() +
-                     " to JDNI ENC as: " + finalName);
+               log.debug("Binding resource manager: " + ref.getRefName() + " to JDNI ENC as: " + finalName);
                Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName));
             }
          }
@@ -1368,13 +1329,11 @@
          Iterator i = beanMetaData.getResourceEnvReferences();
          while (i.hasNext())
          {
-            ResourceEnvRefMetaData resRef =
-                    (ResourceEnvRefMetaData) i.next();
+            ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData)i.next();
             String encName = resRef.getRefName();
             String jndiName = resRef.getJndiName();
             // Should validate the type...
-            log.debug("Binding env resource: " + encName +
-                  " to JDNI ENC as: " + jndiName);
+            log.debug("Binding env resource: " + encName + " to JDNI ENC as: " + jndiName);
             Util.bind(envCtx, encName, new LinkRef(jndiName));
          }
       }
@@ -1385,7 +1344,7 @@
 
          while (i.hasNext())
          {
-            MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData) i.next();
+            MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next();
 
             String refName = ref.getRefName();
             String jndiName = ref.getJNDIName();
@@ -1396,24 +1355,20 @@
                {
                   MessageDestinationMetaData messageDestination = getMessageDestination(link);
                   if (messageDestination == null)
-                     throw new DeploymentException("message-destination-ref '" + refName + 
-                        "' message-destination-link '" + link + "' not found and no jndi-name in jboss.xml");
+                     throw new DeploymentException("message-destination-ref '" + refName + "' message-destination-link '" + link
+                           + "' not found and no jndi-name in jboss.xml");
                   else
                   {
                      String linkJNDIName = messageDestination.getJNDIName();
                      if (linkJNDIName == null)
                         log.warn("message-destination '" + link + "' has no jndi-name in jboss.xml");
-                     else
-                        jndiName = linkJNDIName;
+                     else jndiName = linkJNDIName;
                   }
                }
-               else
-                  log.warn("message-destination-ref '" + refName + 
-                     "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml");
+               else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml");
             }
             else if (jndiName == null)
-               throw new DeploymentException("message-destination-ref '" + refName + 
-                     "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml");
+               throw new DeploymentException("message-destination-ref '" + refName + "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml");
             Util.bind(envCtx, refName, new LinkRef(jndiName));
          }
       }
@@ -1422,27 +1377,25 @@
       // or application security-domain if one exists so that access to the
       // security manager can be made without knowing the global jndi name.
 
-      String securityDomain =
-              metaData.getContainerConfiguration().getSecurityDomain();
+      String securityDomain = metaData.getContainerConfiguration().getSecurityDomain();
       if (securityDomain == null)
          securityDomain = metaData.getApplicationMetaData().getSecurityDomain();
       if (securityDomain != null)
       {
-         log.debug("Binding securityDomain: " + securityDomain +
-            " to JDNI ENC as: security/security-domain");
+         log.debug("Binding securityDomain: " + securityDomain + " to JDNI ENC as: security/security-domain");
 
-         Util.bind( envCtx, "security/security-domain", new LinkRef(securityDomain));
-         Util.bind( envCtx, "security/subject", new LinkRef(securityDomain + "/subject"));
+         Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain));
+         Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject"));
          Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain + "/realmMapping"));
-         Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain+"/authorizationMgr"));
+         Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr"));
       }
 
       log.debug("End java:comp/env for EJB: " + beanMetaData.getEjbName());
    }
-   
+
    public MessageDestinationMetaData getMessageDestination(String link)
    {
-      return EjbUtil.findMessageDestination(server, di, link);
+      return EjbUtil.findMessageDestination(server, unit, link);
    }
 
    /**
@@ -1454,7 +1407,7 @@
     */
    private void teardownEnvironment() throws Exception
    {
-      Context ctx = (Context) new InitialContext().lookup("java:comp");
+      Context ctx = (Context)new InitialContext().lookup("java:comp");
       ctx.unbind("env");
       log.debug("Removed bindings from java:comp/env for EJB: " + getBeanMetaData().getEjbName());
       try
@@ -1477,8 +1430,7 @@
     * All container interceptors perform the same basic functionality
     * and only differ slightly.
     */
-   protected abstract class AbstractContainerInterceptor
-           implements Interceptor
+   protected abstract class AbstractContainerInterceptor implements Interceptor
    {
       protected final Logger log = Logger.getLogger(this.getClass());
 
@@ -1511,8 +1463,7 @@
       {
       }
 
-      protected void rethrow(Exception e)
-              throws Exception
+      protected void rethrow(Exception e) throws Exception
       {
          if (e instanceof IllegalAccessException)
          {
@@ -1521,19 +1472,19 @@
          }
          else if (e instanceof InvocationTargetException)
          {
-            Throwable t = ((InvocationTargetException) e).getTargetException();
+            Throwable t = ((InvocationTargetException)e).getTargetException();
 
             if (t instanceof EJBException)
             {
-               throw (EJBException) t;
+               throw (EJBException)t;
             }
             else if (t instanceof Exception)
             {
-               throw (Exception) t;
+               throw (Exception)t;
             }
             else if (t instanceof Error)
             {
-               throw (Error) t;
+               throw (Error)t;
             }
             else
             {
@@ -1563,7 +1514,7 @@
 
    /** Perform the MBeanServer.invoke op in a PrivilegedExceptionAction if
     * running with a security manager.
-    */ 
+    */
    class MBeanServerAction implements PrivilegedExceptionAction
    {
       private ObjectName target;
@@ -1572,8 +1523,9 @@
       String[] sig;
 
       MBeanServerAction()
-      {  
+      {
       }
+
       MBeanServerAction(ObjectName target, String method, Object[] args, String[] sig)
       {
          this.target = target;
@@ -1587,12 +1539,12 @@
          Object rtnValue = server.invoke(target, method, args, sig);
          return rtnValue;
       }
-      Object invoke(ObjectName target, String method, Object[] args, String[] sig)
-         throws Exception
+
+      Object invoke(ObjectName target, String method, Object[] args, String[] sig) throws Exception
       {
          SecurityManager sm = System.getSecurityManager();
          Object rtnValue = null;
-         if( sm == null )
+         if (sm == null)
          {
             // Direct invocation on MBeanServer
             rtnValue = server.invoke(target, method, args, sig);

Modified: trunk/server/src/main/org/jboss/metadata/BeanMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/BeanMetaData.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/BeanMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -1118,7 +1118,7 @@
       while (iterator.hasNext())
       {
          Element serviceRef = (Element)iterator.next();
-         if (ServiceRefMetaData.isValidDoctype(serviceRef))
+         if (ServiceRefMetaData.isJ2EE14Descriptor(serviceRef))
          {
             ServiceRefMetaData refMetaData = new ServiceRefMetaData();
             refMetaData.importStandardXml(serviceRef);
@@ -1296,7 +1296,7 @@
          Element serviceRef = (Element)iterator.next();
          String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
          ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceRefs.get(serviceRefName);
-         if (refMetaData == null && ServiceRefMetaData.isValidDoctype(serviceRef))
+         if (refMetaData == null && ServiceRefMetaData.isJ2EE14Descriptor(serviceRef))
          {
             throw new DeploymentException("service-ref " + serviceRefName + " found in jboss.xml but not in ejb-jar.xml");
          }

Modified: trunk/server/src/main/org/jboss/metadata/ClientMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/ClientMetaData.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/ClientMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.metadata;
 
 // $Id$
@@ -27,6 +27,8 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 import org.jboss.deployment.DeploymentException;
 import org.jboss.logging.Logger;
@@ -39,8 +41,7 @@
  * @author Thomas.Diesler at jboss.org
  * @version $Revision$
  */
-public class ClientMetaData
-   implements Serializable
+public class ClientMetaData implements Serializable
 {
    private static final long serialVersionUID = 1;
 
@@ -56,7 +57,7 @@
    /** A HashMap<String, EjbRefMetaData> for the ejb-ref element(s) */
    private HashMap ejbReferences = new HashMap();
    /** The HashMap<String, ServiceRefMetaData> service-ref element(s) info */
-   private HashMap serviceReferences = new HashMap();
+   private Map<String, ServiceRefMetaData> serviceRefs = new LinkedHashMap<String, ServiceRefMetaData>();
    /** A  HashMap<String, ResourceRefMetaData> resource-ref element(s) info */
    private HashMap resourceReferences = new HashMap();
    /** A  HashMap<String, ResourceEnvRefMetaData> resource-env-ref element(s) info */
@@ -71,7 +72,7 @@
 
    /** The application-client/display-name
     * @return application-client/display-name value
-    */ 
+    */
    public String getDisplayName()
    {
       return displayName;
@@ -81,36 +82,39 @@
     * @return the JNDI name for the server side client context ENC bindings. This
     * is either the jboss-client/jndi-name or the application-client/display-name
     * value.
-    */ 
+    */
    public String getJndiName()
    {
       String name = jndiName;
-      if( name == null )
+      if (name == null)
          name = displayName;
       return name;
    }
 
    /**
     * @return ArrayList<EnvEntryMetaData>
-    */ 
+    */
    public ArrayList getEnvironmentEntries()
    {
       return environmentEntries;
    }
+
    /**
     * @return HashMap<EjbRefMetaData>
-    */ 
+    */
    public HashMap getEjbReferences()
    {
       return ejbReferences;
    }
+
    /**
     * @return HashMap<ResourceRefMetaData>
-    */ 
+    */
    public HashMap getResourceReferences()
    {
       return resourceReferences;
    }
+
    /**
     * @return HashMap<ResourceEnvRefMetaData>
     */
@@ -118,23 +122,24 @@
    {
       return resourceEnvReferences;
    }
+
    /** 
     * @return The CallbackHandler if defined, null otherwise
-    */ 
+    */
    public String getCallbackHandler()
    {
       return callbackHandler;
    }
+
    /**
     * @return HashMap<ServiceRefMetaData>
     */
-   public HashMap getServiceReferences()
+   public Map<String, ServiceRefMetaData> getServiceRefs()
    {
-      return serviceReferences;
+      return serviceRefs;
    }
 
-   public void importClientXml(Element element)
-      throws DeploymentException
+   public void importClientXml(Element element) throws DeploymentException
    {
       displayName = MetaData.getOptionalChildContent(element, "display-name");
 
@@ -143,7 +148,7 @@
 
       while (iterator.hasNext())
       {
-         Element envEntry = (Element) iterator.next();
+         Element envEntry = (Element)iterator.next();
 
          EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData();
          envEntryMetaData.importEjbJarXml(envEntry);
@@ -156,7 +161,7 @@
 
       while (iterator.hasNext())
       {
-         Element ejbRef = (Element) iterator.next();
+         Element ejbRef = (Element)iterator.next();
 
          EjbRefMetaData ejbRefMetaData = new EjbRefMetaData();
          ejbRefMetaData.importEjbJarXml(ejbRef);
@@ -168,18 +173,17 @@
       iterator = MetaData.getChildrenByTagName(element, "service-ref");
       while (iterator.hasNext())
       {
-         Element serviceRef = (Element) iterator.next();
-         if (ServiceRefMetaData.isValidDoctype(serviceRef))
+         Element serviceRef = (Element)iterator.next();
+         if (ServiceRefMetaData.isJ2EE14Descriptor(serviceRef))
          {
             ServiceRefMetaData refMetaData = new ServiceRefMetaData();
             refMetaData.importStandardXml(serviceRef);
-            serviceReferences.put(refMetaData.getServiceRefName(), refMetaData);
+            serviceRefs.put(refMetaData.getServiceRefName(), refMetaData);
          }
       }
 
       // The callback-handler element
-      Element callbackElement = MetaData.getOptionalChild(element,
-         "callback-handler");
+      Element callbackElement = MetaData.getOptionalChild(element, "callback-handler");
       if (callbackElement != null)
       {
          callbackHandler = MetaData.getElementContent(callbackElement);
@@ -189,20 +193,19 @@
       iterator = MetaData.getChildrenByTagName(element, "resource-ref");
       while (iterator.hasNext())
       {
-         Element resourceRef = (Element) iterator.next();
+         Element resourceRef = (Element)iterator.next();
 
          ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData();
          resourceRefMetaData.importEjbJarXml(resourceRef);
 
-         resourceReferences.put(resourceRefMetaData.getRefName(),
-            resourceRefMetaData);
+         resourceReferences.put(resourceRefMetaData.getRefName(), resourceRefMetaData);
       }
 
       // Parse the resource-env-ref elements
       iterator = MetaData.getChildrenByTagName(element, "resource-env-ref");
       while (iterator.hasNext())
       {
-         Element resourceRef = (Element) iterator.next();
+         Element resourceRef = (Element)iterator.next();
          ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
          refMetaData.importEjbJarXml(resourceRef);
          resourceEnvReferences.put(refMetaData.getRefName(), refMetaData);
@@ -212,29 +215,29 @@
       iterator = MetaData.getChildrenByTagName(element, "message-destination-ref");
       while (iterator.hasNext())
       {
-         Element resourceRef = (Element) iterator.next();
+         Element resourceRef = (Element)iterator.next();
          ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData();
          refMetaData.importEjbJarXml(resourceRef);
          /* A message-destination-ref is linked to a jndi-name either via
-         the message-destination-ref/message-destination-ref-name mapping to
-         a jboss resource-env-ref/resource-env-ref-name if there is no
-         message-destination-link, or by the message-destination-link ->
-         message-destination/message-destination-name mapping to a jboss
-         resource-env-ref/resource-env-ref-name.
-         */
+          the message-destination-ref/message-destination-ref-name mapping to
+          a jboss resource-env-ref/resource-env-ref-name if there is no
+          message-destination-link, or by the message-destination-link ->
+          message-destination/message-destination-name mapping to a jboss
+          resource-env-ref/resource-env-ref-name.
+          */
          String refName = refMetaData.getRefName();
          String link = refMetaData.getLink();
-         if( link != null )
+         if (link != null)
          {
-            ArrayList linkedRefs = (ArrayList) resourceEnvReferenceLinks.get(link);
-            if( linkedRefs == null )
+            ArrayList linkedRefs = (ArrayList)resourceEnvReferenceLinks.get(link);
+            if (linkedRefs == null)
             {
                linkedRefs = new ArrayList();
                resourceEnvReferenceLinks.put(link, linkedRefs);
             }
             linkedRefs.add(refMetaData);
          }
-         resourceEnvReferences.put(refName, refMetaData);            
+         resourceEnvReferences.put(refName, refMetaData);
       }
    }
 
@@ -246,14 +249,12 @@
       Iterator iterator = MetaData.getChildrenByTagName(element, "ejb-ref");
       while (iterator.hasNext())
       {
-         Element ejbRef = (Element) iterator.next();
-         String ejbRefName = MetaData.getElementContent(
-            MetaData.getUniqueChild(ejbRef, "ejb-ref-name"));
-         EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName);
+         Element ejbRef = (Element)iterator.next();
+         String ejbRefName = MetaData.getElementContent(MetaData.getUniqueChild(ejbRef, "ejb-ref-name"));
+         EjbRefMetaData ejbRefMetaData = (EjbRefMetaData)ejbReferences.get(ejbRefName);
          if (ejbRefMetaData == null)
          {
-            throw new DeploymentException("ejb-ref " + ejbRefName
-               + " found in jboss-client.xml but not in application-client.xml");
+            throw new DeploymentException("ejb-ref " + ejbRefName + " found in jboss-client.xml but not in application-client.xml");
          }
          ejbRefMetaData.importJbossXml(ejbRef);
       }
@@ -262,30 +263,29 @@
       iterator = MetaData.getChildrenByTagName(element, "service-ref");
       while (iterator.hasNext())
       {
-         Element serviceRef = (Element) iterator.next();
+         Element serviceRef = (Element)iterator.next();
          String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
-         ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName);
-         if (refMetaData == null && ServiceRefMetaData.isValidDoctype(serviceRef))
+         ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceRefs.get(serviceRefName);
+         if (refMetaData == null)
          {
-            throw new DeploymentException("service-ref " + serviceRefName + " found in jboss-client.xml but not in application-client.xml");
+            log.warn("service-ref " + serviceRefName + " found in jboss-web.xml but not in web.xml");
+            refMetaData = new ServiceRefMetaData();
+            refMetaData.setServiceRefName(serviceRefName);
+            serviceRefs.put(serviceRefName, refMetaData);
          }
-         if (refMetaData != null)
-            refMetaData.importJBossXml(serviceRef);
+         refMetaData.importJBossXml(serviceRef);
       }
 
       // Get the JNDI name binding for resource-refs
       iterator = MetaData.getChildrenByTagName(element, "resource-ref");
       while (iterator.hasNext())
       {
-         Element resourceRef = (Element) iterator.next();
-         String resRefName = MetaData.getElementContent(
-            MetaData.getUniqueChild(resourceRef, "res-ref-name"));
-         ResourceRefMetaData resourceRefMetaData =
-            (ResourceRefMetaData) resourceReferences.get(resRefName);
+         Element resourceRef = (Element)iterator.next();
+         String resRefName = MetaData.getElementContent(MetaData.getUniqueChild(resourceRef, "res-ref-name"));
+         ResourceRefMetaData resourceRefMetaData = (ResourceRefMetaData)resourceReferences.get(resRefName);
          if (resourceRefMetaData == null)
          {
-            throw new DeploymentException("resource-ref " + resRefName
-               + " found in jboss-client.xml but not in application-client.xml");
+            throw new DeploymentException("resource-ref " + resRefName + " found in jboss-client.xml but not in application-client.xml");
          }
          resourceRefMetaData.importJbossXml(resourceRef);
       }
@@ -294,27 +294,24 @@
       iterator = MetaData.getChildrenByTagName(element, "resource-env-ref");
       while (iterator.hasNext())
       {
-         Element resourceRef = (Element) iterator.next();
-         String resRefName = MetaData.getElementContent(
-            MetaData.getUniqueChild(resourceRef, "resource-env-ref-name"));
-         ResourceEnvRefMetaData refMetaData =
-            (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName);
+         Element resourceRef = (Element)iterator.next();
+         String resRefName = MetaData.getElementContent(MetaData.getUniqueChild(resourceRef, "resource-env-ref-name"));
+         ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData)resourceEnvReferences.get(resRefName);
          if (refMetaData == null)
          {
             // Try the resourceEnvReferenceLinks
-            ArrayList linkedRefs = (ArrayList) resourceEnvReferenceLinks.get(resRefName);
-            if( linkedRefs != null )
+            ArrayList linkedRefs = (ArrayList)resourceEnvReferenceLinks.get(resRefName);
+            if (linkedRefs != null)
             {
-               for(int n = 0; n < linkedRefs.size(); n ++)
+               for (int n = 0; n < linkedRefs.size(); n++)
                {
-                  refMetaData = (ResourceEnvRefMetaData) linkedRefs.get(n);
+                  refMetaData = (ResourceEnvRefMetaData)linkedRefs.get(n);
                   refMetaData.importJbossXml(resourceRef);
                }
             }
             else
             {
-               throw new DeploymentException("resource-env-ref " + resRefName
-                  + " found in jboss-client.xml but not in application-client.xml");
+               throw new DeploymentException("resource-env-ref " + resRefName + " found in jboss-client.xml but not in application-client.xml");
             }
          }
          else

Modified: trunk/server/src/main/org/jboss/metadata/DDObjectFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/DDObjectFactory.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/DDObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -1,32 +1,31 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.
-*/ 
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.metadata;
 
 import javax.persistence.PersistenceContextType;
 
-import org.jboss.metadata.serviceref.HandlerMetaData;
-import org.jboss.metadata.serviceref.InitParamMetaData;
-import org.jboss.metadata.serviceref.PortComponentRefMetaData;
+import org.jboss.logging.Logger;
 import org.jboss.metadata.serviceref.ServiceRefMetaData;
+import org.jboss.metadata.serviceref.ServiceRefObjectFactory;
 import org.jboss.xb.binding.ObjectModelFactory;
 import org.jboss.xb.binding.UnmarshallingContext;
 import org.xml.sax.Attributes;
@@ -37,147 +36,103 @@
  * @author Thomas.Diesler at jboss.org
  * @version <tt>$Revision: 56531 $</tt>
  */
-public abstract class DDObjectFactory implements ObjectModelFactory
+public abstract class DDObjectFactory extends ServiceRefObjectFactory implements ObjectModelFactory
 {
-   public Object newChild(PersistenceUnitRef ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   // provide logging
+   protected Logger log = Logger.getLogger(getClass());
+
+   public Object newChild(PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(PersistenceContextRef ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   public Object newChild(PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(EnvEntryMetaData ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   public Object newChild(EnvEntryMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(EjbRefMetaData ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   public Object newChild(EjbRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(EjbLocalRefMetaData ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   public Object newChild(EjbLocalRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(ResourceRefMetaData ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   public Object newChild(ResourceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(ResourceEnvRefMetaData ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   public Object newChild(ResourceEnvRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(MessageDestinationRefMetaData ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   public Object newChild(MessageDestinationRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(ServiceRefMetaData ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
+   public Object newChild(JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
-      Object child = newRefChild(ref, localName);
-      if (localName.equals("port-component-ref"))
-         child = new PortComponentRefMetaData(ref);
-      else if (localName.equals("handler"))
-         child = new HandlerMetaData();
-
-      return child;
-   }
-
-   public Object newChild(JndiRef ref,
-                          UnmarshallingContext navigator, String namespaceURI, String localName,
-                          Attributes attrs)
-   {
       return newRefChild(ref, localName);
    }
 
-   public void addChild(PersistenceUnitRef parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(PersistenceUnitRef parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(PersistenceContextRef parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(PersistenceContextRef parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(EnvEntryMetaData parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(EnvEntryMetaData parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(EjbRefMetaData parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(EjbRefMetaData parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(EjbLocalRefMetaData parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(EjbLocalRefMetaData parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(ResourceRefMetaData parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(ResourceRefMetaData parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(ResourceEnvRefMetaData parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(ResourceEnvRefMetaData parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(MessageDestinationRefMetaData parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(MessageDestinationRefMetaData parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(ServiceRefMetaData parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(JndiRef parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(JndiRef parent, InjectionTarget target,
-                        UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void setValue(EjbLocalRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
-      parent.setInjectionTarget(target);
-   }
-
-   public void setValue(EjbLocalRefMetaData ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
-   {
       if (localName.equals("ejb-ref-name"))
       {
          ref.setName(getValue(localName, value));
@@ -208,8 +163,7 @@
       }
    }
 
-   public void setValue(EjbRefMetaData ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(EjbRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("ejb-ref-name"))
       {
@@ -244,8 +198,7 @@
    /**
     * Called when a child element with simple content is read for DD.
     */
-   public void setValue(InjectionTarget target, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("injection-target-class"))
       {
@@ -260,8 +213,7 @@
    /**
     * Called when a child element with simple content is read for DD.
     */
-   public void setValue(MessageDestinationRefMetaData ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(MessageDestinationRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("description"))
       {
@@ -289,8 +241,7 @@
       }
    }
 
-   public void setValue(EnvEntryMetaData entry, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(EnvEntryMetaData entry, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("description"))
       {
@@ -310,16 +261,13 @@
       }
    }
 
-   public void setValue(ResourceEnvRefMetaData envRef, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(ResourceEnvRefMetaData envRef, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
-      if (localName.equals("res-ref-name")
-              || localName.equals("resource-env-ref-name"))
+      if (localName.equals("res-ref-name") || localName.equals("resource-env-ref-name"))
       {
          envRef.setRefName(getValue(localName, value));
       }
-      else if (localName.equals("res-type")
-              || localName.equals("resource-env-ref-type"))
+      else if (localName.equals("res-type") || localName.equals("resource-env-ref-type"))
       {
          envRef.setType(getValue(localName, value));
       }
@@ -337,16 +285,13 @@
       }
    }
 
-   public void setValue(ResourceRefMetaData ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(ResourceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
-      if (localName.equals("res-ref-name")
-              || localName.equals("resource-env-ref-name"))
+      if (localName.equals("res-ref-name") || localName.equals("resource-env-ref-name"))
       {
          ref.setRefName(getValue(localName, value));
       }
-      else if (localName.equals("res-type")
-              || localName.equals("resource-env-ref-type"))
+      else if (localName.equals("res-type") || localName.equals("resource-env-ref-type"))
       {
          ref.setType(getValue(localName, value));
       }
@@ -372,81 +317,6 @@
       }
    }
 
-   public void setValue(ServiceRefMetaData ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
-   {
-      /* Standard properties */
-      if (localName.equals("service-ref-name"))
-      {
-         ref.setServiceRefName(getValue(localName, value));
-      }
-      else if (localName.equals("service-res-type"))
-      {
-         ref.setServiceResType(getValue(localName, value));
-      }
-      else if (localName.equals("service-interface"))
-      {
-         ref.setServiceInterface(getValue(localName, value));
-      }
-      else if (localName.equals("service-qname"))
-      {
-         ref.setServiceQName(navigator.resolveQName(value));
-      }
-      else if (localName.equals("wsdl-file"))
-      {
-         ref.setWsdlFile(getValue(localName, value));
-      }
-      else if (localName.equals("jaxrpc-mapping-file"))
-      {
-         ref.setMappingFile(getValue(localName, value));
-      }
-      
-      /* JBoss properties */
-      else if (localName.equals("config-name"))
-      {
-         ref.setConfigName(value);
-      }
-      else if (localName.equals("config-file"))
-      {
-         ref.setConfigFile(value);
-      }
-      else if (localName.equals("wsdl-override"))
-      {
-         ref.setWsdlOverride(value);
-      }
-   }
-
-   public void addChild(ServiceRefMetaData parent, PortComponentRefMetaData pcRef, UnmarshallingContext navigator, String namespaceURI, String localName)
-   {
-      parent.addPortComponentRef(pcRef);
-   }
-
-   public void addChild(ServiceRefMetaData parent, HandlerMetaData handler, UnmarshallingContext navigator, String namespaceURI, String localName)
-   {
-      parent.addHandler(handler);
-   }
-
-   public void setValue(PortComponentRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
-   {
-      if (localName.equals("service-endpoint-interface"))
-      {
-         ref.setServiceEndpointInterface(value);
-      }
-      else if (localName.equals("port-component-link"))
-      {
-         ref.setPortComponentLink(value);
-      }
-   }
-   
-   public Object newChild(PortComponentRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
-   {
-      Object child = null;
-      if (localName.equals("call-property"))
-         child = new NameValuePair();
-      
-      return child;
-   }
-
    public void setValue(NameValuePair ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("prop-name"))
@@ -458,73 +328,16 @@
          ref.setValue(value);
       }
    }
-   
-   public void addChild(PortComponentRefMetaData parent, NameValuePair property, UnmarshallingContext navigator, String namespaceURI, String localName)
-   {
-      parent.addCallProperty(property.getName(), property.getValue());
-   }
-   
-   public void setValue(HandlerMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
-   {
-      if (localName.equals("handler-name"))
-      {
-         ref.setHandlerName(value);
-      }
-      else if (localName.equals("handler-class"))
-      {
-         ref.setHandlerClass(value);
-      }
-      else if (localName.equals("soap-header"))
-      {
-         ref.addSoapHeader(navigator.resolveQName(value));
-      }
-      else if (localName.equals("soap-role"))
-      {
-         ref.addSoapRole(value);
-      }
-      else if (localName.equals("port-name"))
-      {
-         ref.addPortName(value);
-      }
-   }
-   
-   public Object newChild(HandlerMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
-   {
-      Object child = null;
-      if (localName.equals("init-param"))
-         child = new InitParamMetaData();
-      
-      return child;
-   }
 
-   public void addChild(HandlerMetaData parent, InitParamMetaData param, UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void setValue(SecurityRoleMetaData role, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
-      parent.addInitParam(param);
-   }
-   
-   public void setValue(InitParamMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
-   {
-      if (localName.equals("param-name"))
-      {
-         ref.setParamName(value);
-      }
-      else if (localName.equals("param-value"))
-      {
-         ref.setParamValue(value);
-      }
-   }
-   
-   public void setValue(SecurityRoleMetaData role, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
-   {
       if (localName.equals("role-name"))
       {
          role.setRoleName(getValue(localName, value));
       }
    }
 
-   public void setValue(JndiRef ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("mapped-name"))
       {
@@ -536,8 +349,7 @@
       }
    }
 
-   public void setValue(RunAs runAs, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(RunAs runAs, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("role-name"))
       {
@@ -545,8 +357,7 @@
       }
    }
 
-   public void setValue(SecurityRoleRefMetaData ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(SecurityRoleRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("role-name"))
       {
@@ -558,8 +369,7 @@
       }
    }
 
-   public void setValue(Listener listener, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(Listener listener, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("listener-class"))
       {
@@ -567,8 +377,7 @@
       }
    }
 
-   public void setValue(MessageDestinationMetaData destination, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(MessageDestinationMetaData destination, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("message-destination-name"))
       {
@@ -580,8 +389,7 @@
       }
    }
 
-   public void setValue(PersistenceUnitRef ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("persistence-unit-ref-name"))
       {
@@ -662,8 +470,7 @@
       return child;
    }
 
-   public void setValue(PersistenceContextRef ref, UnmarshallingContext navigator,
-                        String namespaceURI, String localName, String value)
+   public void setValue(PersistenceContextRef ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("persistence-context-ref-name"))
       {
@@ -673,7 +480,7 @@
       {
          ref.setUnitName(getValue(localName, value));
       }
-      else if(localName.equals("persistence-context-type"))
+      else if (localName.equals("persistence-context-type"))
       {
          if (value.toLowerCase().equals("transaction"))
          {
@@ -685,7 +492,7 @@
          }
       }
    }
-   
+
    protected String getValue(String name, String value)
    {
       return value;

Modified: trunk/server/src/main/org/jboss/metadata/WebMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/WebMetaData.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/WebMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -28,6 +28,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -123,7 +124,7 @@
    /** web.xml ejb-local-refs */
    private HashMap<String, EjbLocalRefMetaData> ejbLocalReferences = new HashMap<String, EjbLocalRefMetaData>();
    /** The web.xml service-refs */
-   private HashMap<String, ServiceRefMetaData> serviceRefs = new HashMap<String, ServiceRefMetaData>();
+   private Map<String, ServiceRefMetaData> serviceRefs = new LinkedHashMap<String, ServiceRefMetaData>();
    /** web.xml security-role-refs <String servlet-name, ArrayList<SecurityRoleRefMetaData>> */
    private HashMap securityRoleReferences = new HashMap();
    /** The web.xml servlet/run-as <String servlet-name, String role> */
@@ -691,9 +692,9 @@
    /** Return an iterator of the service-ref mappings.
     * @return Iterator of ServiceRefMetaData objects
     */
-   public Iterator getServiceRefs()
+   public Map<String, ServiceRefMetaData> getServiceRefs()
    {
-      return serviceRefs.values().iterator();
+      return serviceRefs;
    }
    
    public ServiceRefMetaData getServiceRef(String name)
@@ -1314,7 +1315,8 @@
          if (refMetaData == null)
          {
             log.warn("service-ref " + serviceRefName + " found in jboss-web.xml but not in web.xml");
-            refMetaData = new ServiceRefMetaData(serviceRefName);
+            refMetaData = new ServiceRefMetaData();
+            refMetaData.setServiceRefName(serviceRefName);
             serviceRefs.put(serviceRefName, refMetaData);
          }
          refMetaData.importJBossXml(serviceRef);

Copied: trunk/server/src/main/org/jboss/metadata/serviceref/CallPropertyMetaData.java (from rev 61183, branches/tdiesler/trunk/server/src/main/org/jboss/metadata/serviceref/CallPropertyMetaData.java)
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/CallPropertyMetaData.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/CallPropertyMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.metadata.serviceref;
+
+// $Id$
+
+import java.io.Serializable;
+
+/**
+ * @author Thomas.Diesler at jboss.org
+ * @since 06-May-2004
+ */
+public class CallPropertyMetaData implements Serializable
+{
+   // The required <prop-name> element
+   private String propName;
+   // The required <prop-value> element
+   private String propValue;
+
+   public CallPropertyMetaData()
+   {
+   }
+
+   public CallPropertyMetaData(String propName, String propValue)
+   {
+      this.propName = propName;
+      this.propValue = propValue;
+   }
+
+   public String getPropName()
+   {
+      return propName;
+   }
+
+   public void setPropName(String paramName)
+   {
+      this.propName = paramName;
+   }
+
+   public String getPropValue()
+   {
+      return propValue;
+   }
+
+   public void setPropValue(String paramValue)
+   {
+      this.propValue = paramValue;
+   }
+
+   public String toString()
+   {
+      return "[name=" + propName + ",value=" + propValue + "]";
+   }
+}

Copied: trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainMetaData.java (from rev 61183, branches/tdiesler/trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainMetaData.java)
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainMetaData.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.metadata.serviceref;
+
+// $Id$
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+/** The unified metdata data for a handler chain element
+ * 
+ * @author Thomas.Diesler at jboss.org
+ */
+public class HandlerChainMetaData implements Serializable
+{
+   private QName serviceNamePattern;
+   private QName portNamePattern;
+   private String protocolBindings;
+   private List<HandlerMetaData> handlers = new ArrayList<HandlerMetaData>();
+   
+   public QName getPortNamePattern()
+   {
+      return portNamePattern;
+   }
+
+   public void setPortNamePattern(QName portNamePattern)
+   {
+      this.portNamePattern = portNamePattern;
+   }
+
+   public QName getServiceNamePattern()
+   {
+      return serviceNamePattern;
+   }
+
+   public void setServiceNamePattern(QName serviceNamePattern)
+   {
+      this.serviceNamePattern = serviceNamePattern;
+   }
+
+   public String getProtocolBindings()
+   {
+      return protocolBindings;
+   }
+   
+   public void setProtocolBindings(String protocolBindings)
+   {
+      this.protocolBindings = protocolBindings;
+   }
+   
+   public List<HandlerMetaData> getHandlers()
+   {
+      return handlers;
+   }
+   
+   public void addHandler(HandlerMetaData handler)
+   {
+      handlers.add(handler);
+   }
+   
+   Element toXMLFragment()
+   {
+      Element root = DocumentHelper.createElement("handler-chain");
+      if (serviceNamePattern != null)
+         root.addElement("service-name-pattern").addText(serviceNamePattern.toString());
+      if (portNamePattern != null)
+         root.addElement("port-name-pattern").addText(portNamePattern.toString());
+      if (protocolBindings != null)
+         root.addElement("protocol-bindings").addText(protocolBindings);
+      for (HandlerMetaData handler : getHandlers())
+         root.add(handler.toXMLFragment());
+      return root;
+   }
+}

Copied: trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainsMetaData.java (from rev 61183, branches/tdiesler/trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainsMetaData.java)
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainsMetaData.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/HandlerChainsMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.metadata.serviceref;
+
+// $Id$
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+/** The unified metdata data for a handler chains element
+ * 
+ * @author Thomas.Diesler at jboss.org
+ */
+public class HandlerChainsMetaData implements Serializable
+{
+   private List<HandlerChainMetaData> handlerChains = new ArrayList<HandlerChainMetaData>();
+
+   public List<HandlerChainMetaData> getHandlerChains()
+   {
+      return handlerChains;
+   }
+
+   public void addHandlerChain(HandlerChainMetaData handlerChain)
+   {
+      handlerChains.add(handlerChain);
+   }
+
+   Element toXMLFragment()
+   {
+      Element root = DocumentHelper.createElement("handler-chains");
+      for (HandlerChainMetaData handlerChain : getHandlerChains())
+         root.add(handlerChain.toXMLFragment());
+      return root;
+   }
+}

Modified: trunk/server/src/main/org/jboss/metadata/serviceref/HandlerMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/HandlerMetaData.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/HandlerMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -23,15 +23,18 @@
 
 // $Id$
 
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
 import org.jboss.metadata.MetaData;
 import org.jboss.xb.QNameBuilder;
-import org.w3c.dom.Element;
 
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.io.Serializable;
-
 /** The unified metdata data for a handler element
  * 
  * @author Thomas.Diesler at jboss.org
@@ -39,20 +42,18 @@
  */
 public class HandlerMetaData implements Serializable
 {
-   static final long serialVersionUID = 8749727542255024909L;
-
    // The required <handler-name> element
    private String handlerName;
    // The required <handler-class> element
    private String handlerClass;
    // The optional <init-param> elements
-   private ArrayList initParams = new ArrayList();
+   private List<InitParamMetaData> initParams = new ArrayList<InitParamMetaData>();
    // The optional <soap-header> elements
-   private ArrayList soapHeaders = new ArrayList();
+   private List<QName> soapHeaders = new ArrayList<QName>();
    // The optional <soap-role> elements
-   private ArrayList soapRoles = new ArrayList();
+   private List<String> soapRoles = new ArrayList<String>();
    // The optional <port-name> elements, these only apply to webserve clients
-   private ArrayList portNames = new ArrayList();
+   private List<String> portNames = new ArrayList<String>();
 
    public void setHandlerName(String value)
    {
@@ -79,11 +80,9 @@
       initParams.add(param);
    }
 
-   public InitParamMetaData[] getInitParams()
+   public List<InitParamMetaData> getInitParams()
    {
-      InitParamMetaData[] array = new InitParamMetaData[initParams.size()];
-      initParams.toArray(array);
-      return array;
+      return initParams;
    }
 
    public void addSoapHeader(QName qName)
@@ -91,11 +90,9 @@
       soapHeaders.add(qName);
    }
 
-   public QName[] getSoapHeaders()
+   public List<QName> getSoapHeaders()
    {
-      QName[] array = new QName[soapHeaders.size()];
-      soapHeaders.toArray(array);
-      return array;
+      return soapHeaders;
    }
 
    public void addSoapRole(String value)
@@ -103,18 +100,14 @@
       soapRoles.add(value);
    }
 
-   public String[] getSoapRoles()
+   public List<String> getSoapRoles()
    {
-      String[] array = new String[soapRoles.size()];
-      soapRoles.toArray(array);
-      return array;
+      return soapRoles;
    }
 
-   public String[] getPortNames()
+   public List<String> getPortNames()
    {
-      String[] array = new String[portNames.size()];
-      portNames.toArray(array);
-      return array;
+      return portNames;
    }
 
    public void addPortName(String value)
@@ -122,7 +115,8 @@
       portNames.add(value);
    }
 
-   public void importStandardXml(Element element)
+   /** @deprecated */
+   public void importStandardXml(org.w3c.dom.Element element)
    {
       handlerName = MetaData.getUniqueChildContent(element, "handler-name");
 
@@ -132,7 +126,7 @@
       Iterator iterator = MetaData.getChildrenByTagName(element, "init-param");
       while (iterator.hasNext())
       {
-         Element paramElement = (Element)iterator.next();
+         org.w3c.dom.Element paramElement = (org.w3c.dom.Element)iterator.next();
          InitParamMetaData param = new InitParamMetaData();
          param.setParamName(MetaData.getUniqueChildContent(paramElement, "param-name"));
          param.setParamValue(MetaData.getUniqueChildContent(paramElement, "param-value"));
@@ -143,7 +137,7 @@
       iterator = MetaData.getChildrenByTagName(element, "soap-header");
       while (iterator.hasNext())
       {
-         Element headerElement = (Element)iterator.next();
+         org.w3c.dom.Element headerElement = (org.w3c.dom.Element)iterator.next();
          String content = MetaData.getElementContent(headerElement);
          QName qname = QNameBuilder.buildQName(headerElement, content);
          soapHeaders.add(qname);
@@ -153,7 +147,7 @@
       iterator = MetaData.getChildrenByTagName(element, "soap-role");
       while (iterator.hasNext())
       {
-         Element roleElement = (Element)iterator.next();
+         org.w3c.dom.Element roleElement = (org.w3c.dom.Element)iterator.next();
          String content = MetaData.getElementContent(roleElement);
          soapRoles.add(content);
       }
@@ -162,21 +156,29 @@
       iterator = MetaData.getChildrenByTagName(element, "port-name");
       while (iterator.hasNext())
       {
-         Element portElement = (Element)iterator.next();
+         org.w3c.dom.Element portElement = (org.w3c.dom.Element)iterator.next();
          String content = MetaData.getElementContent(portElement);
          portNames.add(content);
       }
    }
-
-   public String toString()
+   
+   Element toXMLFragment()
    {
-      StringBuffer buffer = new StringBuffer("\nHandlerMetaData:");
-      buffer.append("\n name=" + handlerName);
-      buffer.append("\n class=" + handlerClass);
-      buffer.append("\n params=" + initParams);
-      buffer.append("\n headers=" + soapHeaders);
-      buffer.append("\n roles=" + soapRoles);
-      buffer.append("\n ports=" + portNames);
-      return buffer.toString();
+      Element root = DocumentHelper.createElement("handler");
+      root.addElement("handler-name").addText(handlerName);
+      root.addElement("handler-class").addText(handlerClass);
+      for (InitParamMetaData param : getInitParams())
+      {
+         Element paramEl = root.addElement("init-param");
+         paramEl.addElement("param-name").addText(param.getParamName());
+         paramEl.addElement("param-value").addText(param.getParamValue());
+      }
+      for (QName soapHeader : getSoapHeaders())
+         root.addElement("soap-header").addText(soapHeader.toString());
+      for (String soapRole : getSoapRoles())
+         root.addElement("soap-role").addText(soapRole);
+      for (String portName : getPortNames())
+         root.addElement("port-name").addText(portName);
+      return root;
    }
 }

Modified: trunk/server/src/main/org/jboss/metadata/serviceref/InitParamMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/InitParamMetaData.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/InitParamMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -26,19 +26,14 @@
 import java.io.Serializable;
 
 /**
- * XML Binding and ws4ee meta-data element for
- * <code>webservices/webservice-description/port-component/handler/init-param</code>
- *
  * @author Thomas.Diesler at jboss.org
  * @since 06-May-2004
  */
 public class InitParamMetaData implements Serializable
 {
-   static final long serialVersionUID = 849652901282654531L;
-   
-   // The required <handler-name> element
+   // The required <param-name> element
    private String paramName;
-   // The required <handler-class> element
+   // The required <param-value> element
    private String paramValue;
 
    public String getParamName()

Modified: trunk/server/src/main/org/jboss/metadata/serviceref/PortComponentRefMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/PortComponentRefMetaData.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/PortComponentRefMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -24,29 +24,46 @@
 // $Id$
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.Properties;
+import java.util.List;
 
+import javax.xml.namespace.QName;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
 import org.jboss.metadata.MetaData;
-import org.w3c.dom.Element;
 
 /** The metdata data from service-ref/port-component-ref element in web.xml, ejb-jar.xml, and application-client.xml.
  *
  * @author Thomas.Diesler at jboss.org
- * @version $Revision$
  */
 public class PortComponentRefMetaData implements Serializable
 {
-   static final long serialVersionUID = 3856598615591044263L;
    // The parent service-ref
    private ServiceRefMetaData serviceRefMetaData;
 
+   // Standard properties
+   
    // The required <service-endpoint-interface> element
    private String serviceEndpointInterface;
+   // The optional <enable-mtom> element
+   private Boolean enableMTOM;
    // The optional <port-component-link> element
    private String portComponentLink;
+   
+   // JBoss properties 
+   
+   // The optional <port-qname> element
+   private QName portQName;
+   // The optional JBossWS config-name
+   private String configName;
+   // The optional JBossWS config-file
+   private String configFile;
    // Arbitrary proxy properties given by <call-property> 
-   private Properties callProperties = new Properties();
+   private List<CallPropertyMetaData> callProperties = new ArrayList<CallPropertyMetaData>();
+   // Arbitrary proxy properties given by <stub-property> 
+   private List<StubPropertyMetaData> stubProperties = new ArrayList<StubPropertyMetaData>();
 
    public PortComponentRefMetaData(ServiceRefMetaData serviceRefMetaData)
    {
@@ -58,6 +75,25 @@
       return serviceRefMetaData;
    }
 
+   public void merge(PortComponentRefMetaData pcref)
+   {
+      portQName = pcref.portQName;
+      configName = pcref.configName;
+      configFile = pcref.configFile;
+      callProperties = pcref.callProperties;
+      stubProperties = pcref.stubProperties;
+   }
+   
+   public Boolean getEnableMTOM()
+   {
+      return enableMTOM;
+   }
+
+   public void setEnableMTOM(Boolean enableMTOM)
+   {
+      this.enableMTOM = enableMTOM;
+   }
+
    /** 
     * The port-component-link element links a port-component-ref
     * to a specific port-component required to be made available
@@ -83,44 +119,122 @@
    {
       return serviceEndpointInterface;
    }
-   
+
    public void setServiceEndpointInterface(String serviceEndpointInterface)
    {
       this.serviceEndpointInterface = serviceEndpointInterface;
    }
 
-   public Properties getCallProperties()
+   public QName getPortQName()
    {
+      return portQName;
+   }
+
+   public void setPortQName(QName portQName)
+   {
+      this.portQName = portQName;
+   }
+
+   public List<CallPropertyMetaData> getCallProperties()
+   {
       return callProperties;
    }
+
+   public void setCallProperties(List<CallPropertyMetaData> callProps)
+   {
+      callProperties = callProps;
+   }
+
+   public void addCallProperty(CallPropertyMetaData callProp)
+   {
+      callProperties.add(callProp);
+   }
    
-   public void setCallProperties(Properties props)
+   public List<StubPropertyMetaData> getStubProperties()
    {
-      callProperties = props;
+      return stubProperties;
    }
 
-   public void addCallProperty(String name, String value)
+   public void setStubProperties(List<StubPropertyMetaData> stubProps)
    {
-      callProperties.setProperty(name, value);
+      stubProperties = stubProps;
    }
 
-   public void importStandardXml(Element element)
+   public void addStubProperty(StubPropertyMetaData stubProp)
    {
+      stubProperties.add(stubProp);
+   }
+   
+   public String getConfigFile()
+   {
+      return configFile;
+   }
+
+   public void setConfigFile(String configFile)
+   {
+      this.configFile = configFile;
+   }
+
+   public String getConfigName()
+   {
+      return configName;
+   }
+
+   public void setConfigName(String configName)
+   {
+      this.configName = configName;
+   }
+
+   /** @deprecated */
+   public void importStandardXml(org.w3c.dom.Element element)
+   {
       serviceEndpointInterface = MetaData.getUniqueChildContent(element, "service-endpoint-interface");
       portComponentLink = MetaData.getOptionalChildContent(element, "port-component-link");
    }
 
-   public void importJBossXml(Element element)
+   /** @deprecated */
+   public void importJBossXml(org.w3c.dom.Element element)
    {
       // Look for call-property elements
       Iterator iterator = MetaData.getChildrenByTagName(element, "call-property");
       while (iterator.hasNext())
       {
-         Element propElement = (Element)iterator.next();
+         org.w3c.dom.Element propElement = (org.w3c.dom.Element)iterator.next();
          String name = MetaData.getUniqueChildContent(propElement, "prop-name");
          String value = MetaData.getUniqueChildContent(propElement, "prop-value");
-         callProperties.setProperty(name, value);
+         callProperties.add(new CallPropertyMetaData(name, value));
       }
-
    }
+   
+   Element toXMLFragment()
+   {
+      Element root = DocumentHelper.createElement("port-component-ref");
+      if (serviceEndpointInterface != null)
+         root.addElement("service-endpoint-interface").addText(serviceEndpointInterface);
+      if (enableMTOM != null)
+         root.addElement("enable-mtom").addText(enableMTOM.toString());
+      if (portComponentLink != null)
+         root.addElement("port-component-link").addText(portComponentLink);
+      if (portQName != null)
+         root.addElement("port-qname").addText(portQName.toString());
+      if (configName != null)
+         root.addElement("config-name").addText(configName);
+      if (configFile != null)
+         root.addElement("config-file").addText(configFile);
+      
+      for (CallPropertyMetaData prop : getCallProperties())
+      {
+         Element propEl = root.addElement("call-property");
+         propEl.addElement("prop-name").addText(prop.getPropName());
+         propEl.addElement("prop-value").addText(prop.getPropValue());
+      }
+      for (StubPropertyMetaData prop : getStubProperties())
+      {
+         Element propEl = root.addElement("stub-property");
+         propEl.addElement("prop-name").addText(prop.getPropName());
+         propEl.addElement("prop-value").addText(prop.getPropValue());
+      }
+      
+      return root;
+   }
 }

Modified: trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefHandler.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefHandler.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefHandler.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -23,15 +23,15 @@
 
 // $Id$
 
-import java.util.Iterator;
+import java.lang.reflect.AnnotatedElement;
 
 import javax.naming.Context;
+import javax.naming.NamingException;
 
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.virtual.VirtualFile;
 
 /**
- * Implemtent to bind JAXRPC ServiceRefs
+ * Implemtent to bind web service ref
  * 
  * @author Thomas.Diesler at jboss.org
  * @since 05-May-2004
@@ -39,12 +39,7 @@
 public interface ServiceRefHandler
 {
    /**
-    * Binds a JAXRPC Service into the callers ENC for every service-ref element
-    *
-    * @param envCtx      ENC to bind the javax.rpc.xml.Service object to
-    * @param serviceRefs An iterator of the service-ref elements in the client deployment descriptor
-    * @param unit  The client's deployment unit
-    * @throws DeploymentException if it goes wrong
+    * Binds a Service into the callers ENC for every service-ref element
     */
-   void bindServiceRefs(Context envCtx, Iterator serviceRefs, DeploymentUnit unit);
+   void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, VirtualFile vfsRoot, String xmlFragment) throws NamingException;
 }

Modified: trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefMetaData.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -24,42 +24,42 @@
 // $Id$
 
 import java.io.Serializable;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 
 import javax.xml.namespace.QName;
 
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.MetaData;
 import org.jboss.metadata.Ref;
 import org.jboss.xb.QNameBuilder;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
 
-/** The metdata data from service-ref element in web.xml, ejb-jar.xml, and
+/**
+ * The metdata data from service-ref element in web.xml, ejb-jar.xml, and
  * application-client.xml.
- *
+ * 
  * @author Thomas.Diesler at jboss.org
  * @version $Revision$
  */
 public class ServiceRefMetaData extends Ref implements Serializable
 {
-   private static final long serialVersionUID = -3723577995017108437L;
-
    // provide logging
    private static Logger log = Logger.getLogger(ServiceRefMetaData.class);
 
+   // Standard properties 
+
    // The required <service-ref-name> element
    private String serviceRefName;
-   // The required <service-interface> element
+   // The JAXRPC required <service-interface> element
    private String serviceInterface;
    // service-res-type
-   private String serviceResType;
+   private String serviceRefType;
    // The optional <wsdl-file> element
    private String wsdlFile;
    // The optional <jaxrpc-mapping-file> element
@@ -68,59 +68,66 @@
    private QName serviceQName;
    // The LinkedHashMap<String, PortComponentRefMetaData> for <port-component-ref> elements
    private Map<String, PortComponentRefMetaData> portComponentRefs = new LinkedHashMap<String, PortComponentRefMetaData>();
-   // The optional <handler> elements
-   private ArrayList handlers = new ArrayList();
+   // The optional <handler> elements. JAX-RPC handlers declared in the standard J2EE1.4 descriptor
+   private List<HandlerMetaData> handlers = new ArrayList<HandlerMetaData>();
+   // The optional <handler-chains> elements. JAX-WS handlers declared in the standard JavaEE5 descriptor
+   private HandlerChainsMetaData handlerChains;
 
+   // JBoss properties 
+
+   // The optional <service-impl-class> element
+   private String serviceImplClass;
    // The optional JBossWS config-name
    private String configName;
    // The optional JBossWS config-file
    private String configFile;
-   /** The URL of the actual WSDL to use, <wsdl-override> */
-   private URL wsdlOverride;
-   /** Arbitrary proxy properties given by <call-property> */
-   private Properties callProperties;
+   // The optional URL of the actual WSDL to use, <wsdl-override> 
+   private String wsdlOverride;
+   // The optional <handler-chain> element. JAX-WS handler chain declared in the JBoss JavaEE5 descriptor
+   private String handlerChain;
+   // Arbitrary proxy properties given by <call-property> 
+   private List<CallPropertyMetaData> callProperties = new ArrayList<CallPropertyMetaData>();
 
-   /** Default constructor, used when unmarshalling on the client side
+   /**
+    * Default constructor, used when unmarshalling on the client side
     */
    public ServiceRefMetaData()
    {
    }
 
-   /** Constructor with a given service ref name
-    */
-   public ServiceRefMetaData(String serviceRefName)
+   public void merge(ServiceRefMetaData sref)
    {
-      this.serviceRefName = serviceRefName;
-   }
+      serviceImplClass = sref.serviceImplClass;
+      configName = sref.configName;
+      configFile = sref.configFile;
+      wsdlOverride = sref.wsdlOverride;
+      handlerChain = sref.handlerChain;
+      callProperties = sref.callProperties;
 
-   public void merge(ServiceRefMetaData sourceRef)
-   {
-      configName = sourceRef.configName;
-      configFile = sourceRef.configFile;
-      wsdlOverride = sourceRef.wsdlOverride;
-      callProperties = sourceRef.getCallProperties();
-      
-      for (PortComponentRefMetaData pcSourceRef : sourceRef.getPortComponentRefs())
+      if (serviceQName == null && sref.serviceQName != null)
+         serviceQName = sref.serviceQName;
+
+      for (PortComponentRefMetaData pcref : sref.getPortComponentRefs())
       {
-         String seiName = pcSourceRef.getServiceEndpointInterface();
+         String seiName = pcref.getServiceEndpointInterface();
          if (seiName == null)
          {
-            log.warn("Illegal service endpoint interface: " + seiName);
+            log.warn("Null service endpoint interface in: " + toXMLFragmet());
             continue;
          }
-         
+
          PortComponentRefMetaData pcTargetRef = portComponentRefs.get(seiName);
          if (pcTargetRef == null)
          {
             log.warn("Cannot find port component ref with SEI name: " + seiName);
-            addPortComponentRef(pcSourceRef);
-            pcTargetRef = pcSourceRef;
+            addPortComponentRef(pcref);
+            pcTargetRef = pcref;
          }
-         
-         pcTargetRef.setCallProperties(pcSourceRef.getCallProperties());
+
+         pcTargetRef.merge(pcref);
       }
    }
-   
+
    public String getMappingFile()
    {
       return mappingFile;
@@ -137,30 +144,28 @@
       portComponentRefs.values().toArray(array);
       return array;
    }
-   
+
    public PortComponentRefMetaData getPortComponentRef(String seiName)
    {
       PortComponentRefMetaData ref = portComponentRefs.get(seiName);
       return ref;
    }
-   
+
    public void addPortComponentRef(PortComponentRefMetaData pcRef)
    {
       portComponentRefs.put(pcRef.getServiceEndpointInterface(), pcRef);
    }
 
-   public HandlerMetaData[] getHandlers()
+   public List<HandlerMetaData> getHandlers()
    {
-      HandlerMetaData[] array = new HandlerMetaData[handlers.size()];
-      handlers.toArray(array);
-      return array;
+      return handlers;
    }
 
    public void addHandler(HandlerMetaData handler)
    {
       handlers.add(handler);
    }
-   
+
    public String getServiceInterface()
    {
       return serviceInterface;
@@ -171,6 +176,16 @@
       this.serviceInterface = serviceInterface;
    }
 
+   public String getServiceImplClass()
+   {
+      return serviceImplClass;
+   }
+
+   public void setServiceImplClass(String serviceImplClass)
+   {
+      this.serviceImplClass = serviceImplClass;
+   }
+
    public QName getServiceQName()
    {
       return serviceQName;
@@ -191,14 +206,14 @@
       this.serviceRefName = serviceRefName;
    }
 
-   public String getServiceResType()
+   public String getServiceRefType()
    {
-      return serviceResType;
+      return serviceRefType;
    }
 
-   public void setServiceResType(String serviceResType)
+   public void setServiceRefType(String serviceResType)
    {
-      this.serviceResType = serviceResType;
+      this.serviceRefType = serviceResType;
    }
 
    public String getWsdlFile()
@@ -231,54 +246,54 @@
       this.configName = configName;
    }
 
-   public URL getWsdlOverride()
+   public String getWsdlOverride()
    {
       return wsdlOverride;
    }
-   
+
    public void setWsdlOverride(String wsdlOverride)
    {
-      try
-      {
-         this.wsdlOverride = new URL(wsdlOverride);
-      }
-      catch (MalformedURLException e)
-      {
-         throw new IllegalArgumentException("Invalid wsdl-override: " + wsdlOverride);
-      }
+      this.wsdlOverride = wsdlOverride;
    }
 
-   public Properties getCallProperties()
+   public List<CallPropertyMetaData> getCallProperties()
    {
       return callProperties;
    }
 
-   public static boolean isValidDoctype(Element element)
+   public void setCallProperties(List<CallPropertyMetaData> callProps)
    {
-      // Verify J2EE-1.4
-      String nsURI = element.getOwnerDocument().getDocumentElement().getNamespaceURI();
-      boolean isValid = "http://java.sun.com/xml/ns/j2ee".equals(nsURI);
+      callProperties = callProps;
+   }
 
-      // Verify JBoss-4.0
-      DocumentType doctype = element.getOwnerDocument().getDoctype();
-      if (isValid == false && doctype != null)
-      {
-         String publicId = doctype.getPublicId();
-         isValid |= "-//JBoss//DTD JBOSS 4.0//EN".equals(publicId);
-         isValid |= "-//JBoss//DTD Web Application 2.4//EN".equals(publicId);
-         isValid |= "-//JBoss//DTD Application Client 4.0//EN".equals(publicId);
-      }
+   public void addCallProperty(CallPropertyMetaData callProp)
+   {
+      callProperties.add(callProp);
+   }
 
-      if (isValid == false)
-      {
-         String dtstr = (doctype != null ? "[public=" + doctype.getPublicId() + ",system=" + doctype.getSystemId() + "]" : null);
-         log.debug("Skip <service-ref> for: nsURI=" + nsURI + ",doctype=" + dtstr);
-      }
-      return isValid;
+   public HandlerChainsMetaData getHandlerChains()
+   {
+      return handlerChains;
    }
 
-   public void importStandardXml(Element element)
+   public void setHandlerChains(HandlerChainsMetaData handlerChains)
    {
+      this.handlerChains = handlerChains;
+   }
+
+   public String getHandlerChain()
+   {
+      return handlerChain;
+   }
+
+   public void setHandlerChain(String handlerChain)
+   {
+      this.handlerChain = handlerChain;
+   }
+
+   /** @deprecated */
+   public void importStandardXml(org.w3c.dom.Element element)
+   {
       serviceRefName = MetaData.getUniqueChildContent(element, "service-ref-name");
 
       serviceInterface = MetaData.getUniqueChildContent(element, "service-interface");
@@ -287,7 +302,7 @@
 
       mappingFile = MetaData.getOptionalChildContent(element, "jaxrpc-mapping-file");
 
-      Element qnameElement = MetaData.getOptionalChild(element, "service-qname");
+      org.w3c.dom.Element qnameElement = MetaData.getOptionalChild(element, "service-qname");
       if (qnameElement != null)
          serviceQName = QNameBuilder.buildQName(qnameElement, MetaData.getElementContent(qnameElement));
 
@@ -295,7 +310,7 @@
       Iterator iterator = MetaData.getChildrenByTagName(element, "port-component-ref");
       while (iterator.hasNext())
       {
-         Element pcrefElement = (Element)iterator.next();
+         org.w3c.dom.Element pcrefElement = (org.w3c.dom.Element)iterator.next();
          PortComponentRefMetaData pcrefMetaData = new PortComponentRefMetaData(this);
          pcrefMetaData.importStandardXml(pcrefElement);
          portComponentRefs.put(pcrefMetaData.getServiceEndpointInterface(), pcrefMetaData);
@@ -305,36 +320,26 @@
       iterator = MetaData.getChildrenByTagName(element, "handler");
       while (iterator.hasNext())
       {
-         Element handlerElement = (Element)iterator.next();
+         org.w3c.dom.Element handlerElement = (org.w3c.dom.Element)iterator.next();
          HandlerMetaData handlerMetaData = new HandlerMetaData();
          handlerMetaData.importStandardXml(handlerElement);
          handlers.add(handlerMetaData);
       }
    }
 
-   /** Parse jboss specific service-ref child elements
-    */
-   public void importJBossXml(Element element)
+   /** @deprecated */
+   public void importJBossXml(org.w3c.dom.Element element)
    {
       configName = MetaData.getOptionalChildContent(element, "config-name");
 
       configFile = MetaData.getOptionalChildContent(element, "config-file");
-      String wsdlOverrideOption = MetaData.getOptionalChildContent(element, "wsdl-override");
-      try
-      {
-         if (wsdlOverrideOption != null)
-            wsdlOverride = new URL(wsdlOverrideOption);
-      }
-      catch (MalformedURLException e)
-      {
-         throw new IllegalStateException("Invalid WSDL override: " + wsdlOverrideOption);
-      }
+      wsdlOverride = MetaData.getOptionalChildContent(element, "wsdl-override");
 
       // Parse the port-component-ref elements
       Iterator iterator = MetaData.getChildrenByTagName(element, "port-component-ref");
       while (iterator.hasNext())
       {
-         Element pcrefElement = (Element)iterator.next();
+         org.w3c.dom.Element pcrefElement = (org.w3c.dom.Element)iterator.next();
          String name = MetaData.getOptionalChildContent(pcrefElement, "service-endpoint-interface");
          if (name != null)
          {
@@ -355,12 +360,79 @@
       iterator = MetaData.getChildrenByTagName(element, "call-property");
       while (iterator.hasNext())
       {
-         Element propElement = (Element)iterator.next();
+         org.w3c.dom.Element propElement = (org.w3c.dom.Element)iterator.next();
          String name = MetaData.getUniqueChildContent(propElement, "prop-name");
          String value = MetaData.getUniqueChildContent(propElement, "prop-value");
-         if (callProperties == null)
-            callProperties = new Properties();
-         callProperties.setProperty(name, value);
+         callProperties.add(new CallPropertyMetaData(name, value));
       }
    }
+
+   public static boolean isJ2EE14Descriptor(org.w3c.dom.Element element)
+   {
+      // Verify J2EE-1.4
+      String nsURI = element.getOwnerDocument().getDocumentElement().getNamespaceURI();
+      boolean isValid = "http://java.sun.com/xml/ns/j2ee".equals(nsURI);
+
+      // Verify JBoss-4.0
+      org.w3c.dom.DocumentType doctype = element.getOwnerDocument().getDoctype();
+      if (isValid == false && doctype != null)
+      {
+         String publicId = doctype.getPublicId();
+         isValid |= "-//JBoss//DTD JBOSS 4.0//EN".equals(publicId);
+         isValid |= "-//JBoss//DTD JBOSS 4.2//EN".equals(publicId);
+         isValid |= "-//JBoss//DTD Web Application 2.4//EN".equals(publicId);
+         isValid |= "-//JBoss//DTD Application Client 4.0//EN".equals(publicId);
+         isValid |= "-//JBoss//DTD Application Client 4.2//EN".equals(publicId);
+      }
+
+      if (isValid == false)
+      {
+         String dtstr = (doctype != null ? "[public=" + doctype.getPublicId() + ",system=" + doctype.getSystemId() + "]" : null);
+         log.debug("Skip <service-ref> for: nsURI=" + nsURI + ",doctype=" + dtstr);
+      }
+      return isValid;
+   }
+
+   public String toXMLFragmet()
+   {
+      Document document = DocumentHelper.createDocument();
+      Element root = document.addElement("service-ref");
+      root.addElement("service-ref-name").addText(serviceRefName);
+      if (serviceInterface != null)
+         root.addElement("service-interface").addText(serviceInterface);
+      if (serviceRefType != null)
+         root.addElement("service-ref-type").addText(serviceRefType);
+      if (wsdlFile != null)
+         root.addElement("wsdl-file").addText(wsdlFile);
+      if (mappingFile != null)
+         root.addElement("jaxrpc-mapping-file").addText(mappingFile);
+      if (serviceQName != null)
+         root.addElement("service-qname").addText(serviceQName.toString());
+      for (PortComponentRefMetaData pcref : getPortComponentRefs())
+         root.add(pcref.toXMLFragment());
+      for (HandlerMetaData handler : getHandlers())
+         root.add(handler.toXMLFragment());
+      if (handlerChains != null)
+         root.add(handlerChains.toXMLFragment());
+
+      if (serviceImplClass != null)
+         root.addElement("service-impl-class").addText(serviceImplClass);
+      if (configName != null)
+         root.addElement("config-name").addText(configName);
+      if (configFile != null)
+         root.addElement("config-file").addText(configFile);
+      if (handlerChain != null)
+         root.addElement("handler-chain").addText(handlerChain);
+      if (wsdlOverride != null)
+         root.addElement("wsdl-override").addText(wsdlOverride);
+
+      for (CallPropertyMetaData prop : getCallProperties())
+      {
+         Element propEl = root.addElement("call-property");
+         propEl.addElement("prop-name").addText(prop.getPropName());
+         propEl.addElement("prop-value").addText(prop.getPropValue());
+      }
+
+      return root.asXML();
+   }
 }

Copied: trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java (from rev 61183, branches/tdiesler/trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java)
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/ServiceRefObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -0,0 +1,277 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.metadata.serviceref;
+
+// $Id$
+
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * A object model factory for <service-ref>
+ * 
+ * @author Thomas.Diesler at jboss.com
+ */
+public abstract class ServiceRefObjectFactory implements ObjectModelFactory
+{
+   public void setValue(ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   {
+      /* Standard properties */
+      if (localName.equals("service-ref-name"))
+      {
+         ref.setServiceRefName(value);
+      }
+      else if (localName.equals("service-interface"))
+      {
+         ref.setServiceInterface(value);
+      }
+      else if (localName.equals("service-ref-type"))
+      {
+         ref.setServiceRefType(value);
+      }
+      else if (localName.equals("wsdl-file"))
+      {
+         ref.setWsdlFile(value);
+      }
+      else if (localName.equals("jaxrpc-mapping-file"))
+      {
+         ref.setMappingFile(value);
+      }
+      else if (localName.equals("service-qname"))
+      {
+         ref.setServiceQName(QName.valueOf(value));
+      }
+
+      /* JBoss properties */
+      else if (localName.equals("service-impl-class"))
+      {
+         ref.setServiceImplClass(value);
+      }
+      else if (localName.equals("config-name"))
+      {
+         ref.setConfigName(value);
+      }
+      else if (localName.equals("config-file"))
+      {
+         ref.setConfigFile(value);
+      }
+      else if (localName.equals("wsdl-override"))
+      {
+         ref.setWsdlOverride(value);
+      }
+      else if (localName.equals("handler-chain"))
+      {
+         ref.setHandlerChain(value);
+      }
+   }
+
+   public Object newChild(ServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+   {
+      Object child = null;
+      if (localName.equals("port-component-ref"))
+         child = new PortComponentRefMetaData(ref);
+      else if (localName.equals("handler"))
+         child = new HandlerMetaData();
+      else if (localName.equals("handler-chains"))
+         child = new HandlerChainsMetaData();
+      
+      else if (localName.equals("call-property"))
+         child = new CallPropertyMetaData();
+
+      return child;
+   }
+
+   public Object newChild(HandlerChainsMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+   {
+      Object child = null;
+      if (localName.equals("handler-chain"))
+         child = new HandlerChainMetaData();
+
+      return child;
+   }
+
+   public void addChild(ServiceRefMetaData parent, PortComponentRefMetaData pcRef, UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      parent.addPortComponentRef(pcRef);
+   }
+
+   public void addChild(ServiceRefMetaData parent, HandlerMetaData handler, UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      parent.addHandler(handler);
+   }
+
+   public void addChild(ServiceRefMetaData parent, HandlerChainsMetaData handlerChains, UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      parent.setHandlerChains(handlerChains);
+   }
+
+   public void addChild(ServiceRefMetaData parent, CallPropertyMetaData callProp, UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      parent.addCallProperty(callProp);
+   }
+
+   public void addChild(HandlerChainsMetaData parent, HandlerChainMetaData handlerChain, UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      parent.addHandlerChain(handlerChain);
+   }
+
+   public void setValue(PortComponentRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   {
+      if (localName.equals("service-endpoint-interface"))
+      {
+         ref.setServiceEndpointInterface(value);
+      }
+      else if (localName.equals("enable-mtom"))
+      {
+         ref.setEnableMTOM(Boolean.valueOf(value));
+      }
+      else if (localName.equals("port-component-link"))
+      {
+         ref.setPortComponentLink(value);
+      }
+      else if (localName.equals("port-qname"))
+      {
+         ref.setPortQName(QName.valueOf(value));
+      }
+      else if (localName.equals("config-name"))
+      {
+         ref.setConfigName(value);
+      }
+      else if (localName.equals("config-file"))
+      {
+         ref.setConfigFile(value);
+      }
+   }
+
+   public Object newChild(PortComponentRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+   {
+      Object child = null;
+      if (localName.equals("call-property"))
+         child = new CallPropertyMetaData();
+      if (localName.equals("stub-property"))
+         child = new StubPropertyMetaData();
+      return child;
+   }
+
+   public void setValue(HandlerChainMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   {
+      if (localName.equals("service-name-pattern"))
+      {
+         ref.setServiceNamePattern(QName.valueOf(value));
+      }
+      else if (localName.equals("port-name-pattern"))
+      {
+         ref.setPortNamePattern(QName.valueOf(value));
+      }
+      else if (localName.equals("protocol-binding"))
+      {
+         ref.setProtocolBindings(value);
+      }
+   }
+
+   public void setValue(HandlerMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   {
+      if (localName.equals("handler-name"))
+      {
+         ref.setHandlerName(value);
+      }
+      else if (localName.equals("handler-class"))
+      {
+         ref.setHandlerClass(value);
+      }
+      else if (localName.equals("soap-header"))
+      {
+         ref.addSoapHeader(navigator.resolveQName(value));
+      }
+      else if (localName.equals("soap-role"))
+      {
+         ref.addSoapRole(value);
+      }
+      else if (localName.equals("port-name"))
+      {
+         ref.addPortName(value);
+      }
+   }
+
+   public Object newChild(HandlerMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+   {
+      Object child = null;
+      if (localName.equals("init-param"))
+         child = new InitParamMetaData();
+
+      return child;
+   }
+
+   public void addChild(HandlerMetaData parent, InitParamMetaData param, UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      parent.addInitParam(param);
+   }
+
+   public void setValue(InitParamMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   {
+      if (localName.equals("param-name"))
+      {
+         ref.setParamName(value);
+      }
+      else if (localName.equals("param-value"))
+      {
+         ref.setParamValue(value);
+      }
+   }
+
+   public void setValue(CallPropertyMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   {
+      if (localName.equals("prop-name"))
+      {
+         ref.setPropName(value);
+      }
+      else if (localName.equals("prop-value"))
+      {
+         ref.setPropValue(value);
+      }
+   }
+
+   public void setValue(StubPropertyMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   {
+      if (localName.equals("prop-name"))
+      {
+         ref.setPropName(value);
+      }
+      else if (localName.equals("prop-value"))
+      {
+         ref.setPropValue(value);
+      }
+   }
+   
+   public void addChild(PortComponentRefMetaData ref, CallPropertyMetaData callProp, UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      ref.addCallProperty(callProp);
+   }
+
+   public void addChild(PortComponentRefMetaData ref, StubPropertyMetaData stubProp, UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      ref.addStubProperty(stubProp);
+   }
+}

Copied: trunk/server/src/main/org/jboss/metadata/serviceref/StubPropertyMetaData.java (from rev 61183, branches/tdiesler/trunk/server/src/main/org/jboss/metadata/serviceref/StubPropertyMetaData.java)
===================================================================
--- trunk/server/src/main/org/jboss/metadata/serviceref/StubPropertyMetaData.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/metadata/serviceref/StubPropertyMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.metadata.serviceref;
+
+// $Id$
+
+import java.io.Serializable;
+
+/**
+ * @author Thomas.Diesler at jboss.org
+ * @since 06-May-2004
+ */
+public class StubPropertyMetaData implements Serializable
+{
+   // The required <prop-name> element
+   private String propName;
+   // The required <prop-value> element
+   private String propValue;
+
+   public String getPropName()
+   {
+      return propName;
+   }
+
+   public void setPropName(String paramName)
+   {
+      this.propName = paramName;
+   }
+
+   public String getPropValue()
+   {
+      return propValue;
+   }
+
+   public void setPropValue(String paramValue)
+   {
+      this.propValue = paramValue;
+   }
+
+   public String toString()
+   {
+      return "[name=" + propName + ",value=" + propValue + "]";
+   }
+}

Modified: trunk/server/src/main/org/jboss/metadata/web/JBossWebMetaDataObjectFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/web/JBossWebMetaDataObjectFactory.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metadata/web/JBossWebMetaDataObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -210,18 +210,22 @@
       parent.addSecurityRole(role);
    }
 
-   public void addChild(WebMetaData parent, ServiceRefMetaData sourceRef,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(WebMetaData parent, ServiceRefMetaData sref, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
-      String refName = sourceRef.getServiceRefName();
+      String refName = sref.getServiceRefName();
       if (refName == null)
          throw new IllegalStateException("Invalid service-ref-name: " + refName);
-      
+
       ServiceRefMetaData targetRef = parent.getServiceRef(refName);
       if (targetRef == null)
-         throw new IllegalStateException("Cannot find service-ref: " + refName);
-      
-      targetRef.merge(sourceRef);
+      {
+         log.debug("Cannot find <service-ref> with name: " + refName);
+         parent.addServiceRef(sref);
+      }
+      else
+      {
+         targetRef.merge(sref);
+      }
    }
 
    public void addChild(WebMetaData parent, Servlet servlet,

Modified: trunk/server/src/main/org/jboss/metamodel/descriptor/DDObjectFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/metamodel/descriptor/DDObjectFactory.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metamodel/descriptor/DDObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -22,8 +22,9 @@
 package org.jboss.metamodel.descriptor;
 
 import javax.persistence.PersistenceContextType;
-import javax.xml.namespace.QName;
 
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
+import org.jboss.metadata.serviceref.ServiceRefObjectFactory;
 import org.jboss.xb.binding.ObjectModelFactory;
 import org.jboss.xb.binding.UnmarshallingContext;
 import org.xml.sax.Attributes;
@@ -33,7 +34,7 @@
  * @author Thomas.Diesler at jboss.com
  * @version <tt>$Revision$</tt>
  */
-public abstract class DDObjectFactory implements ObjectModelFactory
+public abstract class DDObjectFactory extends ServiceRefObjectFactory implements ObjectModelFactory
 {
    public Object newChild(PersistenceUnitRef ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
@@ -75,11 +76,6 @@
       return newRefChild(ref, localName);
    }
 
-   public Object newChild(WebServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
-   {
-      return newServiceRefChild(ref, localName);
-   }
-
    public Object newChild(JndiRef ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
    {
       return newRefChild(ref, localName);
@@ -125,11 +121,6 @@
       parent.setInjectionTarget(target);
    }
 
-   public void addChild(WebServiceRefMetaData parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
-   {
-      parent.setInjectionTarget(target);
-   }
-
    public void addChild(JndiRef parent, InjectionTarget target, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setInjectionTarget(target);
@@ -322,88 +313,7 @@
          ref.setMappedName(getValue(localName, value));
       }
    }
-
-   public void setValue(WebServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
-   {
-      if (localName.equals("service-ref-name"))
-      {
-         ref.setServiceRefName(value);
-      }
-      else if (localName.equals("service-class-name"))
-      {
-         ref.setServiceClassName(value);
-      }
-      else if (localName.equals("service-qname"))
-      {
-         ref.setServiceQName(QName.valueOf(value));
-      }
-      else if (localName.equals("config-name"))
-      {
-         ref.setConfigName(value);
-      }
-      else if (localName.equals("config-file"))
-      {
-         ref.setConfigFile(value);
-      }
-      else if (localName.equals("handler-chain"))
-      {
-         ref.setHandlerChain(value);
-      }
-      else if (localName.equals("wsdl-override"))
-      {
-         ref.setWsdlOverride(value);
-      }
-   }
-
-   private Object newServiceRefChild(WebServiceRefMetaData ref, String localName)
-   {
-      Object child = newRefChild(ref, localName);
-
-      if (localName.equals("port-info"))
-         child = new PortInfo(ref);
-
-      return child;
-   }
-
-   public void addChild(WebServiceRefMetaData parent, PortInfo portInfo, UnmarshallingContext navigator, String namespaceURI, String localName)
-   {
-      parent.getPortInfos().add(portInfo);
-   }
-
-   public void setValue(PortInfo portInfo, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
-   {
-      if (localName.equals("service-endpoint-interface"))
-      {
-         portInfo.setServiceEndpointInterface(value);
-      }
-      else if (localName.equals("port-qname"))
-      {
-         portInfo.setPortQName(QName.valueOf(value));
-      }
-      else if (localName.equals("config-name"))
-      {
-         portInfo.setConfigName(value);
-      }
-      else if (localName.equals("config-file"))
-      {
-         portInfo.setConfigFile(value);
-      }
-   }
-
-   public Object newChild(PortInfo portInfo, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
-   {
-      Object child = null;
-      if (localName.equals("stub-property"))
-         child = new NameValuePair();
-
-      return child;
-   }
-
-   public void addChild(PortInfo parent, NameValuePair stubProp, UnmarshallingContext navigator, String namespaceURI, String localName)
-   {
-      parent.getStubProperties().add(stubProp);
-   }
-
+   
    public void setValue(NameValuePair nvPair, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
    {
       if (localName.equals("name"))
@@ -520,9 +430,9 @@
       {
          child = new MessageDestinationRef();
       }
-      else if (localName.equals("webservice-ref"))
+      else if (localName.equals("service-ref"))
       {
-         child = new WebServiceRefMetaData();
+         child = new ServiceRefMetaData();
       }
       else if (localName.equals("jndi-ref"))
       {

Modified: trunk/server/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java
===================================================================
--- trunk/server/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metamodel/descriptor/EnvironmentRefGroup.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -21,22 +21,15 @@
 */ 
 package org.jboss.metamodel.descriptor;
 
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.ArrayList;
 
 import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 
-import org.jboss.metamodel.descriptor.EjbLocalRef;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.EnvEntry;
-import org.jboss.metamodel.descriptor.JndiRef;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
-
 /**
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  * @version <tt>$Revision$</tt>
@@ -53,7 +46,7 @@
    protected HashMap<String, MessageDestinationRef> messageDestinationRefs = new HashMap<String, MessageDestinationRef>();
    /** An index of MessageDestinationRef keyed by message-destination-link values */
    protected HashMap<String, MessageDestinationRef> messageDestinationRefsByLink = new HashMap<String, MessageDestinationRef>();
-   protected HashMap<String, WebServiceRefMetaData> serviceRefs = new HashMap<String, WebServiceRefMetaData>();
+   protected HashMap<String, ServiceRefMetaData> serviceRefs = new LinkedHashMap<String, ServiceRefMetaData>();
    protected HashMap<String, JndiRef> jndiRefs = new HashMap<String, JndiRef>();
    protected List<PersistenceContextRef> persistenceContextRefs = new ArrayList<PersistenceContextRef>();
    protected List<PersistenceUnitRef> persistenceUnitRefs = new ArrayList<PersistenceUnitRef>();
@@ -134,16 +127,21 @@
       jndiRefs.put(ref.getJndiRefName(), ref);
    }
    
-   public Collection<WebServiceRefMetaData> getServiceRefs()
+   public Collection<ServiceRefMetaData> getServiceRefs()
    {
       return serviceRefs.values();
    }
 
-   public void addServiceRef(WebServiceRefMetaData ref)
+   public void addServiceRef(ServiceRefMetaData ref)
    {
       serviceRefs.put(ref.getServiceRefName(), ref);
    }
    
+   public ServiceRefMetaData getServiceRef(String name)
+   {
+      return serviceRefs.get(name);
+   }
+
    public void updateEjbRef(EjbRef updatedRef)
    {
       EjbRef ref = (EjbRef)ejbRefs.get(updatedRef.getEjbRefName());

Deleted: trunk/server/src/main/org/jboss/metamodel/descriptor/PortInfo.java
===================================================================
--- trunk/server/src/main/org/jboss/metamodel/descriptor/PortInfo.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metamodel/descriptor/PortInfo.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.metamodel.descriptor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-// $Id$
-
-/**
- * Represents a <port-info> element in <webservice-ref>
- *
- * @author Thomas.Diesler at jboss.com
- */
-public class PortInfo
-{
-   private WebServiceRefMetaData serviceRef;
-   private String serviceEndpointInterface;
-   private QName portQName;
-   private String configName;
-   private String configFile;
-   private List<NameValuePair> stubProperties = new ArrayList<NameValuePair>();
-
-   public PortInfo(WebServiceRefMetaData serviceRef)
-   {
-      this.serviceRef = serviceRef;
-   }
-   
-   public WebServiceRefMetaData getServiceRef()
-   {
-      return serviceRef;
-   }
-
-   public QName getPortQName()
-   {
-      return portQName;
-   }
-
-   public void setPortQName(QName portName)
-   {
-      this.portQName = portName;
-   }
-
-   public String getServiceEndpointInterface()
-   {
-      return serviceEndpointInterface;
-   }
-
-   public void setServiceEndpointInterface(String serviceEndpointInterface)
-   {
-      this.serviceEndpointInterface = serviceEndpointInterface;
-   }
-
-   public String getConfigFile()
-   {
-      return configFile;
-   }
-
-   public void setConfigFile(String configFile)
-   {
-      this.configFile = configFile;
-   }
-
-   public String getConfigName()
-   {
-      return configName;
-   }
-
-   public void setConfigName(String configName)
-   {
-      this.configName = configName;
-   }
-
-   public List<NameValuePair> getStubProperties()
-   {
-      return stubProperties;
-   }
-
-   public String toXMLFragment()
-   {
-      StringBuilder xml = new StringBuilder("<port-info>");
-
-      if (serviceEndpointInterface != null)
-         xml.append("<service-endpoint-interface>" + serviceEndpointInterface + "</service-endpoint-interface>");
-
-      if (portQName != null)
-         xml.append("<port-qname>" + portQName + "</port-qname>");
-
-      if (configName != null)
-         xml.append("<config-name>" + configName + "</config-name>");
-      if (configFile != null)
-         xml.append("<config-file>" + configFile + "</config-file>");
-      
-      for (NameValuePair nvp : stubProperties)
-      {
-         xml.append("<stub-property>");
-         xml.append("<name>" + nvp.getName() + "</name>");
-         xml.append("<value>" + nvp.getValue() + "</value>");
-         xml.append("</stub-property>");
-      }
-
-      xml.append("</port-info>");
-
-      return xml.toString();
-   }
-}

Deleted: trunk/server/src/main/org/jboss/metamodel/descriptor/WebServiceRefMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metamodel/descriptor/WebServiceRefMetaData.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/metamodel/descriptor/WebServiceRefMetaData.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -1,163 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.metamodel.descriptor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-// $Id$
-
-/**
- * Represents a <webservice-ref> element of the jboss.xml, jboss-web.xml, jboss-client.xml 
- * deployment descriptor for the 5.0 schema
- *
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @author Thomas.Diesler at jboss.com
- */
-public class WebServiceRefMetaData extends Ref
-{
-   private String serviceRefName;
-   private String serviceClassName;
-   private QName serviceQName;
-   private String configName;
-   private String configFile;
-   private String handlerChain;
-   private List<PortInfo> portInfos = new ArrayList<PortInfo>();
-   private String wsdlOverride;
-
-   public String getServiceRefName()
-   {
-      return serviceRefName;
-   }
-
-   public void setServiceRefName(String name)
-   {
-      this.serviceRefName = name;
-   }
-
-   public String getServiceClassName()
-   {
-      return serviceClassName;
-   }
-
-   public void setServiceClassName(String serviceClassName)
-   {
-      this.serviceClassName = serviceClassName;
-   }
-
-   public QName getServiceQName()
-   {
-      return serviceQName;
-   }
-
-   public void setServiceQName(QName serviceQName)
-   {
-      this.serviceQName = serviceQName;
-   }
-   
-   public String getConfigFile()
-   {
-      return configFile;
-   }
-
-   public void setConfigFile(String configFile)
-   {
-      this.configFile = configFile;
-   }
-
-   public String getConfigName()
-   {
-      return configName;
-   }
-
-   public void setConfigName(String configName)
-   {
-      this.configName = configName;
-   }
-
-   public String getHandlerChain()
-   {
-      return handlerChain;
-   }
-
-   public void setHandlerChain(String handlerChain)
-   {
-      this.handlerChain = handlerChain;
-   }
-
-   public List<PortInfo> getPortInfos()
-   {
-      return portInfos;
-   }
-
-   public String getWsdlOverride()
-   {
-      return wsdlOverride;
-   }
-
-   public void setWsdlOverride(String wsdlLocation)
-   {
-      this.wsdlOverride = wsdlLocation;
-   }
-
-   public String toXMLFragment() 
-   {
-      StringBuilder xml = new StringBuilder("<webservice-ref>");
-      
-      xml.append("<service-ref-name>" + serviceRefName + "</service-ref-name>");
-      
-      if (serviceClassName != null)
-         xml.append("<service-class-name>" + serviceClassName + "</service-class-name>");
-      
-      if (serviceQName != null)
-         xml.append("<service-qname>" + serviceQName + "</service-qname>");
-      
-      if (configName != null)
-         xml.append("<config-name>" + configName + "</config-name>");
-      if (configFile != null)
-         xml.append("<config-file>" + configFile + "</config-file>");
-      
-      if (handlerChain != null)
-         xml.append("<handler-chain>" + handlerChain + "</handler-chain>");
-      
-      for (PortInfo portInfo : portInfos)
-         xml.append(portInfo.toXMLFragment());
-      
-      if (wsdlOverride != null)
-         xml.append("<wsdl-override>" + wsdlOverride + "</wsdl-override>");
-      
-      xml.append("</webservice-ref>");
-
-      return xml.toString();
-   }
-
-   public String toString()
-   {
-      StringBuffer sb = new StringBuffer(100);
-      sb.append("[");
-      sb.append("name=").append(serviceRefName);
-      sb.append("]");
-      return sb.toString();
-   }
-}

Modified: trunk/server/src/main/org/jboss/web/AbstractWebDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/AbstractWebDeployer.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/web/AbstractWebDeployer.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -554,8 +554,8 @@
       Iterator ejbLocalRefs = metaData.getEjbLocalReferences();
       log.debug("linkEjbLocalRefs");
       linkEjbLocalRefs(ejbLocalRefs, envCtx, di);
-      Iterator serviceRefs = metaData.getServiceRefs();
       log.debug("linkServiceRefs");
+      //Iterator serviceRefs = metaData.getServiceRefs();
       //ServiceRefHandler refHandler = ServiceRefHandlerFactory.newInstance();
       //if (refHandler != null && serviceRefs.hasNext())
       //   refHandler.bindServiceRefs(envCtx, serviceRefs, di);

Modified: trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -53,11 +53,13 @@
 import org.jboss.metadata.WebMetaData;
 import org.jboss.metadata.serviceref.ServiceRefHandler;
 import org.jboss.metadata.serviceref.ServiceRefHandlerFactory;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.mx.loading.LoaderRepositoryFactory;
 import org.jboss.naming.NonSerializableFactory;
 import org.jboss.naming.Util;
 import org.jboss.security.AuthorizationManager;
 import org.jboss.security.authorization.PolicyRegistration;
+import org.jboss.virtual.VirtualFile;
 import org.jboss.web.WebApplication; 
 import org.omg.CORBA.ORB;
 
@@ -285,12 +287,12 @@
     * provide access to the min, max and total time in milliseconds. Expose this
     * information via MinServiceTime, MaxServiceTime and TotalServiceTime
     * attributes to integrate seemlessly with the JSR77 factory layer.
-    * @param di The deployment info that contains the context-root element value
+    * @param unit The deployment info that contains the context-root element value
     * from the J2EE application/module/web application.xml descriptor. This may
     * be null if war was is not being deployed as part of an enterprise
     * application. It also contains the URL of the web application war.
     */
-   public synchronized WebApplication start(DeploymentUnit di, WebMetaData metaData)
+   public synchronized WebApplication start(DeploymentUnit unit, WebMetaData metaData)
       throws Exception
    {
       Thread thread = Thread.currentThread();
@@ -300,17 +302,17 @@
       {
          // Create a classloader for the war to ensure a unique ENC
          URL[] empty = {};
-         URLClassLoader warLoader = URLClassLoader.newInstance(empty, di.getClassLoader());
+         URLClassLoader warLoader = URLClassLoader.newInstance(empty, unit.getClassLoader());
          thread.setContextClassLoader(warLoader);
          String webContext = metaData.getContextRoot();
    
          // Get the war URL
          // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
-         URL warURL = di.getAttachment("org.jboss.web.expandedWarURL", URL.class);
+         URL warURL = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class);
          if( warURL == null )
-            warURL = di.getAttachment("jbossws.expanded.war.url", URL.class);
+            warURL = unit.getAttachment("jbossws.expanded.war.url", URL.class);
          if (warURL == null)
-            warURL = di.getDeploymentContext().getRoot().toURL();
+            warURL = unit.getDeploymentContext().getRoot().toURL();
 
          // Strip any jar: url syntax. This should be be handled by the vfs
          String warURLString = warURL.toString();
@@ -323,7 +325,7 @@
          // Register the permissions with the JACC layer
          String contextID = metaData.getJaccContextID();
          if( contextID == null )
-            contextID = di.getSimpleName();
+            contextID = unit.getSimpleName();
          metaData.setJaccContextID(contextID);
          /*PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
          PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true);
@@ -356,7 +358,7 @@
    
          webApp = new WebApplication(metaData);
          webApp.setClassLoader(warLoader);
-         webApp.setDeploymentUnit(di);
+         webApp.setDeploymentUnit(unit);
          performDeploy(webApp, warURLString);
       }
       finally
@@ -509,11 +511,17 @@
       Iterator ejbLocalRefs = metaData.getEjbLocalReferences();
       log.debug("linkEjbLocalRefs");
       linkEjbLocalRefs(unit, ejbLocalRefs, envCtx);
-      Iterator serviceRefs = metaData.getServiceRefs();
       log.debug("linkServiceRefs");
       ServiceRefHandler refHandler = ServiceRefHandlerFactory.newInstance();
-      if (refHandler != null && serviceRefs.hasNext())
-         refHandler.bindServiceRefs(envCtx, serviceRefs, unit);
+      if (refHandler != null)
+      {
+         for (ServiceRefMetaData sref : metaData.getServiceRefs().values())
+         {
+            String encName = sref.getServiceRefName();
+            VirtualFile vfsRoot = unit.getDeploymentContext().getRoot();
+            refHandler.setupServiceRef(envCtx, encName, null, vfsRoot, sref.toXMLFragmet());
+         }
+      }
    }
 
    protected void addEnvEntries(Iterator envEntries, Context envCtx)

Modified: trunk/server/src/resources/dtd/jboss-client_5_0.dtd
===================================================================
--- trunk/server/src/resources/dtd/jboss-client_5_0.dtd	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/resources/dtd/jboss-client_5_0.dtd	2007-03-07 14:03:32 UTC (rev 61189)
@@ -12,12 +12,12 @@
        "http://www.jboss.org/j2ee/dtd/jboss-client_5_0.dtd">
 -->
 
-<!ENTITY % webservice-ref SYSTEM "./docs/dtd/webservice-ref_5_0.dtd"> 
-%webservice-ref;
+<!ENTITY % service-ref SYSTEM "./docs/dtd/service-ref_5_0.dtd"> 
+%service-ref;
 
 <!-- The jboss-client element is the root element.
 -->
-<!ELEMENT jboss-client (jndi-name, ejb-ref*, webservice-ref*, resource-ref*,
+<!ELEMENT jboss-client (jndi-name, ejb-ref*, service-ref*, resource-ref*,
  resource-env-ref*)>
 
 <!-- The required jndi-name element specifies the JNDI name of a deployed

Modified: trunk/server/src/resources/dtd/jboss-web_5_0.dtd
===================================================================
--- trunk/server/src/resources/dtd/jboss-web_5_0.dtd	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/resources/dtd/jboss-web_5_0.dtd	2007-03-07 14:03:32 UTC (rev 61189)
@@ -13,8 +13,8 @@
 
 -->
 
-<!ENTITY % webservice-ref SYSTEM "./docs/dtd/webservice-ref_5_0.dtd"> 
-%webservice-ref;
+<!ENTITY % service-ref SYSTEM "./docs/dtd/service-ref_5_0.dtd"> 
+%service-ref;
 
 <!-- The jboss-web element is the root element.
 -->
@@ -22,7 +22,7 @@
    virtual-host*, use-session-cookies?, replication-config?, resource-env-ref*,
    resource-ref*, security-role*, ejb-ref*, ejb-local-ref*, 
    message-destination-ref*, message-destination*, 
-   webservice-ref*, depends*, servlet*, max-active-sessions?, passivation-config?)>
+   service-ref*, depends*, servlet*, max-active-sessions?, passivation-config?)>
 
 <!-- The class-loading element allows one to override the default class
 loading behavior of the web container. You can specify the

Modified: trunk/server/src/resources/dtd/jboss_5_0.dtd
===================================================================
--- trunk/server/src/resources/dtd/jboss_5_0.dtd	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/resources/dtd/jboss_5_0.dtd	2007-03-07 14:03:32 UTC (rev 61189)
@@ -31,7 +31,7 @@
       <security-proxy>
       <ejb-ref>
       <ejb-local-ref>
-      <webservice-ref>
+      <service-ref>
       <security-identity>
         <run-as-principal>
       </security-identity>
@@ -53,7 +53,7 @@
       <security-proxy>
       <ejb-ref>
       <ejb-local-ref>
-      <webservice-ref>
+      <service-ref>
       <security-identity>
         <run-as-principal>
       </security-identity>
@@ -77,7 +77,7 @@
       <configuration-name>
       <security-proxy>
       <ejb-ref>
-      <webservice-ref>
+      <service-ref>
       <security-identity>
         <run-as-principal>
       </security-identity>
@@ -138,8 +138,8 @@
 </jboss>
 -->
 
-<!ENTITY % webservice-ref SYSTEM "./docs/dtd/webservice-ref_5_0.dtd"> 
-%webservice-ref;
+<!ENTITY % service-ref SYSTEM "./docs/dtd/service-ref_5_0.dtd"> 
+%service-ref;
 
 <!--
   The jboss element is the root element of the jboss.xml file. It
@@ -431,7 +431,7 @@
 -->
 <!ELEMENT entity (ejb-name , jndi-name? , local-jndi-name? , call-by-value?, read-only?,
  exception-on-rollback?, timer-persistence?, configuration-name? , invoker-bindings?,
- security-proxy? , ejb-ref* , ejb-local-ref* , webservice-ref*, security-identity? ,
+ security-proxy? , ejb-ref* , ejb-local-ref* , service-ref*, security-identity? ,
  resource-ref* , resource-env-ref*, message-destination-ref* , method-attributes? ,
  clustered? , cluster-config?, cache-invalidation? , cache-invalidation-config?,
  depends*, ior-security-config?)>
@@ -449,7 +449,7 @@
 -->
 <!ELEMENT session (ejb-name , jndi-name? , local-jndi-name?, call-by-value?,
  exception-on-rollback?, timer-persistence?, configuration-name?, invoker-bindings?,
- security-proxy? , ejb-ref* ,  ejb-local-ref* , webservice-ref*, security-identity? ,
+ security-proxy? , ejb-ref* ,  ejb-local-ref* , service-ref*, security-identity? ,
  resource-ref* , resource-env-ref*, message-destination-ref* , clustered? ,
  cluster-config?, method-attributes?, depends*,
  ior-security-config?, ejb-timeout-identity?)>
@@ -469,7 +469,7 @@
  local-jndi-name?,
  mdb-user?,  mdb-passwd? , mdb-client-id? , mdb-subscription-id? , resource-adapter-name? ,
  exception-on-rollback?, timer-persistence?, configuration-name? , invoker-bindings?,
- security-proxy? , ejb-ref* ,  ejb-local-ref*, webservice-ref*, security-identity?, resource-ref*,
+ security-proxy? , ejb-ref* ,  ejb-local-ref*, service-ref*, security-identity?, resource-ref*,
  resource-env-ref*, message-destination-ref*, depends*, ior-security-config?,
  ejb-timeout-identity?)>
 <!-- Allow the message-driven to have a unique id -->

Copied: trunk/server/src/resources/dtd/service-ref_5_0.dtd (from rev 61183, branches/tdiesler/trunk/server/src/resources/dtd/service-ref_5_0.dtd)
===================================================================
--- trunk/server/src/resources/dtd/service-ref_5_0.dtd	                        (rev 0)
+++ trunk/server/src/resources/dtd/service-ref_5_0.dtd	2007-03-07 14:03:32 UTC (rev 61189)
@@ -0,0 +1,155 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!-- 
+	$Id: jboss-client_5_0.dtd 58121 2006-11-04 19:57:58Z thomas.diesler at jboss.com $
+-->
+
+<!--
+  WebServiceRef customization
+-->
+
+<!--
+  Runtime settings for a web service reference. In the simplest case,
+  there is no runtime information required for a service ref.  Runtime info
+  is only needed in the following cases :
+  
+  * to define the port that should be used to resolve a container-managed port
+  * to define default Stub property settings for Stub objects
+  * to define the URL of a final WSDL document to be used
+
+  Example:
+  
+  <service-ref>
+   <service-ref-name>OrganizationService</service-ref-name>
+   <wsdl-override>file:/wsdlRepository/organization-service.wsdl</wsdl-override>
+  </service-ref>
+
+  <service-ref>
+   <service-ref-name>OrganizationService</service-ref-name>
+   <config-name>Secure Client Config</config-name>
+   <config-file>META-INF/jbossws-client-config.xml</config-file>
+   <handler-chain>META-INF/jbossws-client-handlers.xml</handler-chain>
+  </service-ref>
+  
+  <service-ref>
+   <service-ref-name>SecureService</service-ref-name>
+   <service-impl-class>org.jboss.tests.ws.jaxws.webserviceref.SecureEndpointService</service-impl-class>
+   <service-qname>{http://org.jboss.ws/wsref}SecureEndpointService</service-qname>
+    <port-component-ref>
+     <service-endpoint-interface>org.jboss.tests.ws.jaxws.webserviceref.SecureEndpoint</service-endpoint-interface>
+     <port-qname>{http://org.jboss.ws/wsref}SecureEndpointPort</port-qname>
+     <stub-property>
+      <name>javax.xml.ws.security.auth.username</name>
+      <value>kermit</value>
+     </stub-property>
+     <stub-property>
+      <name>javax.xml.ws.security.auth.password</name>
+      <value>thefrog</value>
+     </stub-property>
+   </port-component-ref>
+  </service-ref>
+-->
+<!ELEMENT service-ref (service-ref-name, service-impl-class?, service-qname?, config-name?, config-file?, handler-chain?, port-component-ref*, wsdl-override?)>
+
+<!-- 
+  The service-ref-name element gives the ENC relative name.
+  Overrides @WebServiceRef.name
+-->
+<!ELEMENT service-ref-name (#PCDATA)>
+
+<!--
+  Name of the JAXWS service implementation class.
+  Overrides @WebServiceRef.value
+-->
+<!ELEMENT service-impl-class (#PCDATA)>
+
+<!-- 
+  The service-qname element declares the specific WSDL service element.
+  Specify the qualified service name in the form defined by QName.valueOf()
+  
+  Example: 
+     <service-qname>{http://somensURI}SomeService</service-qname>
+-->
+<!ELEMENT service-qname (#PCDATA)>
+
+<!-- 
+  The optional handler-chain element is a URL or resource name to a handler chain configuration.
+  See: @HandlerChain.file
+-->
+<!ELEMENT handler-chain (#PCDATA)>
+
+<!-- 
+  Information for a port within a service-ref.
+  
+  Either service-endpoint-interface or wsdl-port or both
+  (service-endpoint-interface and wsdl-port) should be specified.  
+  
+  If both are specified, wsdl-port represents the
+  port the container should choose for container-managed port selection.
+  
+  The same wsdl-port value must not appear in
+  more than one port-component-ref entry within the same service-ref.
+  
+  If a particular service-endpoint-interface is using container-managed port
+  selection, it must not appear in more than one port-component-ref entry
+  within the same service-ref.
+-->
+<!ELEMENT port-component-ref (service-endpoint-interface?, port-qname?, config-name?, config-file?, stub-property*)>
+
+<!--
+  Fully qualified name of service endpoint interface
+-->
+<!ELEMENT service-endpoint-interface (#PCDATA)>
+
+<!-- 
+  Port used in port-component-ref.  
+  Specify the qualified port name in the form defined by QName.valueOf()
+  
+  Example: 
+     <port-qname>{http://somensURI}SomeService</port-qname>
+-->
+<!ELEMENT port-qname (#PCDATA)>
+
+<!-- 
+  The optional config-name element gives the client configuration name that must be present in
+  the configuration given by element config-file. Ports that match this port info will be 
+  configured with this config name.
+
+  The default is: Standard Client
+-->
+<!ELEMENT config-name (#PCDATA)>
+
+<!-- 
+  The optional config-file element is a URL or resource name for the client configuration.
+  Ports that match this port info will be configured with this config file.
+  
+  The default is: META-INF/standard-jbossws-client-config.xml
+-->
+<!ELEMENT config-file (#PCDATA)>
+
+<!-- 
+  Property values that should be set on a stub before it's returned to 
+  to the web service client.  The property names can be any properties supported
+  by the StubExt or Stub implementation. 
+  
+  See javadoc for org.jboss.ws.core.StubExt, javax.xml.rpc.Stub
+-->
+<!ELEMENT stub-property (prop-name, prop-value)>
+
+<!--
+  This text nodes holds a name string.
+-->
+<!ELEMENT prop-name (#PCDATA)>
+
+<!--
+  This text nodes holds a value string.
+-->
+<!ELEMENT prop-value (#PCDATA)>
+
+<!-- 
+  The wsdl-override element the actual wsdl docuement the web service client
+  uses to connect to the remote service. 
+  
+  Overrides @WebServiceRef.wsdlLocation
+-->
+<!ELEMENT wsdl-override (#PCDATA)>

Deleted: trunk/server/src/resources/dtd/webservice-ref_5_0.dtd
===================================================================
--- trunk/server/src/resources/dtd/webservice-ref_5_0.dtd	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/server/src/resources/dtd/webservice-ref_5_0.dtd	2007-03-07 14:03:32 UTC (rev 61189)
@@ -1,155 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
-<!-- 
-	$Id: jboss-client_5_0.dtd 58121 2006-11-04 19:57:58Z thomas.diesler at jboss.com $
--->
-
-<!--
-  WebServiceRef customization
--->
-
-<!--
-  Runtime settings for a web service reference. In the simplest case,
-  there is no runtime information required for a service ref.  Runtime info
-  is only needed in the following cases :
-  
-  * to define the port that should be used to resolve a container-managed port
-  * to define default Stub property settings for Stub objects
-  * to define the URL of a final WSDL document to be used
-
-  Example:
-  
-  <webservice-ref>
-   <service-ref-name>OrganizationService</service-ref-name>
-   <wsdl-override>file:/wsdlRepository/organization-service.wsdl</wsdl-override>
-  </webservice-ref>
-
-  <webservice-ref>
-   <service-ref-name>OrganizationService</service-ref-name>
-   <config-name>Secure Client Config</config-name>
-   <config-file>META-INF/jbossws-client-config.xml</config-file>
-   <handler-chain>META-INF/jbossws-client-handlers.xml</handler-chain>
-  </webservice-ref>
-  
-  <webservice-ref>
-   <service-ref-name>SecureService</service-ref-name>
-   <service-class-name>org.jboss.tests.ws.jaxws.webserviceref.SecureEndpointService</service-class-name>
-   <service-qname>{http://org.jboss.ws/wsref}SecureEndpointService</service-qname>
-    <port-info>
-     <service-endpoint-interface>org.jboss.tests.ws.jaxws.webserviceref.SecureEndpoint</service-endpoint-interface>
-     <port-qname>{http://org.jboss.ws/wsref}SecureEndpointPort</port-qname>
-     <stub-property>
-      <name>javax.xml.ws.security.auth.username</name>
-      <value>kermit</value>
-     </stub-property>
-     <stub-property>
-      <name>javax.xml.ws.security.auth.password</name>
-      <value>thefrog</value>
-     </stub-property>
-   </port-info>
-  </webservice-ref>
--->
-<!ELEMENT webservice-ref (service-ref-name, service-class-name?, service-qname?, config-name?, config-file?, handler-chain?, port-info*, wsdl-override?)>
-
-<!-- 
-  The service-ref-name element gives the ENC relative name.
-  Overrides @WebServiceRef.name
--->
-<!ELEMENT service-ref-name (#PCDATA)>
-
-<!--
-  Name of the class that implements javax.xml.ws.Service. 
-  Overrides @WebServiceRef.value
--->
-<!ELEMENT service-class-name (#PCDATA)>
-
-<!-- 
-  The service-qname element declares the specific WSDL service element.
-  Specify the qualified service name in the form defined by QName.valueOf()
-  
-  Example: 
-     <service-qname>{http://somensURI}SomeService</service-qname>
--->
-<!ELEMENT service-qname (#PCDATA)>
-
-<!-- 
-  The optional handler-chain element is a URL or resource name to a handler chain configuration.
-  See: @HandlerChain.file
--->
-<!ELEMENT handler-chain (#PCDATA)>
-
-<!-- 
-  Information for a port within a webservice-ref.
-  
-  Either service-endpoint-interface or wsdl-port or both
-  (service-endpoint-interface and wsdl-port) should be specified.  
-  
-  If both are specified, wsdl-port represents the
-  port the container should choose for container-managed port selection.
-  
-  The same wsdl-port value must not appear in
-  more than one port-info entry within the same webservice-ref.
-  
-  If a particular service-endpoint-interface is using container-managed port
-  selection, it must not appear in more than one port-info entry
-  within the same webservice-ref.
--->
-<!ELEMENT port-info (service-endpoint-interface?, port-qname?, config-name?, config-file?, stub-property*)>
-
-<!--
-  Fully qualified name of service endpoint interface
--->
-<!ELEMENT service-endpoint-interface (#PCDATA)>
-
-<!-- 
-  Port used in port-info.  
-  Specify the qualified port name in the form defined by QName.valueOf()
-  
-  Example: 
-     <port-qname>{http://somensURI}SomeService</port-qname>
--->
-<!ELEMENT port-qname (#PCDATA)>
-
-<!-- 
-  The optional config-name element gives the client configuration name that must be present in
-  the configuration given by element config-file. Ports that match this port info will be 
-  configured with this config name.
-
-  The default is: Standard Client
--->
-<!ELEMENT config-name (#PCDATA)>
-
-<!-- 
-  The optional config-file element is a URL or resource name for the client configuration.
-  Ports that match this port info will be configured with this config file.
-  
-  The default is: META-INF/standard-jbossws-client-config.xml
--->
-<!ELEMENT config-file (#PCDATA)>
-
-<!-- 
-  Property values that should be set on a stub before it's returned to 
-  to the web service client.  The property names can be any properties supported
-  by the StubExt or Stub implementation. 
-  
-  See javadoc for org.jboss.ws.core.StubExt, javax.xml.rpc.Stub
--->
-<!ELEMENT stub-property (name, value)>
-
-<!--
-  This text nodes holds a name string.
--->
-<!ELEMENT name (#PCDATA)>
-
-<!--
-  This text nodes holds a value string.
--->
-<!ELEMENT value (#PCDATA)>
-
-<!-- 
-  The wsdl-override element the actual wsdl docuement the web service client
-  uses to connect to the remote service. 
-  
-  Overrides @WebServiceRef.wsdlLocation
--->
-<!ELEMENT wsdl-override (#PCDATA)>

Modified: trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/JBossWebDDObjectFactory.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/JBossWebDDObjectFactory.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/JBossWebDDObjectFactory.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -21,7 +21,12 @@
  */
 package org.jboss.web.metamodel.descriptor;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
 import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.metamodel.descriptor.DDObjectFactory;
 import org.jboss.metamodel.descriptor.EjbLocalRef;
 import org.jboss.metamodel.descriptor.EjbRef;
@@ -30,7 +35,6 @@
 import org.jboss.metamodel.descriptor.MessageDestinationRef;
 import org.jboss.metamodel.descriptor.ResourceEnvRef;
 import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.metamodel.descriptor.WebServiceRefMetaData;
 import org.jboss.util.xml.JBossEntityResolver;
 import org.jboss.xb.binding.JBossXBException;
 import org.jboss.xb.binding.ObjectModelFactory;
@@ -39,10 +43,6 @@
 import org.jboss.xb.binding.UnmarshallingContext;
 import org.xml.sax.Attributes;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
 /**
  * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data
  * chuncks from unmarshaller and assembles them into an WebDD instance.
@@ -174,9 +174,22 @@
       parent.updateMessageDestinationRef(ref);
    }
 
-   public void addChild(WebDD parent, WebServiceRefMetaData ref, UnmarshallingContext navigator, String namespaceURI, String localName)
+   public void addChild(WebDD parent, ServiceRefMetaData sref, UnmarshallingContext navigator, String namespaceURI, String localName)
    {
-      parent.addServiceRef(ref);
+      String refName = sref.getServiceRefName();
+      if (refName == null)
+         throw new IllegalStateException("Invalid service-ref-name: " + refName);
+
+      ServiceRefMetaData targetRef = parent.getServiceRef(refName);
+      if (targetRef == null)
+      {
+         log.debug("Cannot find <service-ref> with name: " + refName);
+         parent.addServiceRef(sref);
+      }
+      else
+      {
+         targetRef.merge(sref);
+      }
    }
 
    public void addChild(WebDD parent, ResourceEnvRef ref, UnmarshallingContext navigator, String namespaceURI, String localName)

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -50,8 +50,6 @@
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.WebMetaData;
-import org.jboss.metadata.serviceref.ServiceRefHandler;
-import org.jboss.metadata.serviceref.ServiceRefHandlerFactory;
 import org.jboss.mx.util.MBeanServerLocator;
 import org.jboss.naming.NonSerializableFactory;
 import org.jboss.security.AuthorizationManager;
@@ -354,13 +352,19 @@
             envCtx = envCtx.createSubcontext("env");
             injectionContainer.populateEnc(webLoader.getClassLoader());
 
-            // TODO: should this be handled differently?
-            // JAX-RPC service refs are not injectable objects
-            Iterator serviceRefs = metaData.getServiceRefs();
-            log.debug("linkServiceRefs");
+            // Bind <service-ref> elements
+            /*
             ServiceRefHandler refHandler = ServiceRefHandlerFactory.newInstance();
-            if (refHandler != null && serviceRefs.hasNext())
-               refHandler.bindServiceRefs(envCtx, serviceRefs, unit);
+            if (refHandler != null)
+            {
+               for (ServiceRefMetaData sref : metaData.getServiceRefs().values())
+               {
+                  String encName = sref.getServiceRefName();
+                  VirtualFile vfsRoot = unit.getDeploymentContext().getRoot();
+                  refHandler.setupServiceRef(envCtx, encName, null, vfsRoot, sref.toXMLFragmet());
+               }
+            }
+            */
 
             // TODO: this should be bindings in the metadata
             currentThread.setContextClassLoader(webLoader.getClassLoader());

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment2.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment2.java	2007-03-07 13:37:51 UTC (rev 61188)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment2.java	2007-03-07 14:03:32 UTC (rev 61189)
@@ -55,6 +55,7 @@
 import org.jboss.metadata.WebMetaData;
 import org.jboss.metadata.serviceref.ServiceRefHandler;
 import org.jboss.metadata.serviceref.ServiceRefHandlerFactory;
+import org.jboss.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.mx.util.MBeanServerLocator;
 import org.jboss.naming.NonSerializableFactory;
 import org.jboss.security.AuthorizationManager;
@@ -472,14 +473,19 @@
                log.debug("linkSecurityDomain");
                linkSecurityDomain(securityDomain, envCtx);
 
-               // TODO: should this be handled differently?
-               // JAX-RPC service refs are not injectable objects
-               Iterator serviceRefs = metaData.getServiceRefs();
-               log.debug("linkServiceRefs");
+               // Bind <service-ref> elements
+               /*
                ServiceRefHandler refHandler = ServiceRefHandlerFactory.newInstance();
-               if (refHandler != null && serviceRefs.hasNext())
-                  refHandler.bindServiceRefs(envCtx, serviceRefs, unit);
-
+               if (refHandler != null)
+               {
+                  for (ServiceRefMetaData sref : metaData.getServiceRefs().values())
+                  {
+                     String encName = sref.getServiceRefName();
+                     VirtualFile vfsRoot = unit.getDeploymentContext().getRoot();
+                     refHandler.setupServiceRef(envCtx, encName, null, vfsRoot, sref.toXMLFragmet());
+                  }
+               }
+               */
             }
             catch (Throwable t)
             {




More information about the jboss-cvs-commits mailing list