You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Joe Bohn <jo...@earthlink.net> on 2007/11/06 17:14:03 UTC

Re: svn commit: r591858 [2/13] - in /openejb/trunk/openejb3: ./ assembly/openejb-tomcat/ assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-cor...

These changes in JndiEncBuilder require some comparable changes in 
Geronimo's EjbRefBuidler.   I don't really know the details of the big 
change but Geronimo used construct a JndiEncBuilder using just these two 
parameters:

JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(jndiEncInfo, 
module.getName())

It seems that the new constructor requires a list of injections and a 
classloader.  I presume something like this would work but I'm not sure 
which classloader we need to pass.  Any pointers?

             InjectionBuilder injectionBuilder = new 
InjectionBuilder(classloader?);
             List<Injection> injections = 
injectionBuilder.buildInjections(jndiEncInfo);
             JndiEncBuilder jndiEncBuilder = new 
JndiEncBuilder(jndiEncInfo, injections, module.getTargetPath(), 
classloader?);


Thanks,
Joe




dain@apache.org wrote:
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java Sun Nov  4 14:41:49 2007
> @@ -101,6 +101,7 @@
>      private SecurityService securityService;
>      private OpenEjbConfigurationFactory configFactory;
>      private final Map<String, AppInfo> deployedApplications = new HashMap<String, AppInfo>();
> +    private final List<DeploymentListener> deploymentListeners = new ArrayList<DeploymentListener>();
>  
>  
>      public org.apache.openejb.spi.ContainerSystem getContainerSystem() {
> @@ -115,6 +116,42 @@
>          return securityService;
>      }
>  
> +    public synchronized void addDeploymentListener(DeploymentListener deploymentListener) {
> +        deploymentListeners.add(deploymentListener);
> +    }
> +
> +    public synchronized void removeDeploymentListener(DeploymentListener deploymentListener) {
> +        deploymentListeners.remove(deploymentListener);
> +    }
> +
> +    private synchronized void fireAfterApplicationCreated(AppInfo appInfo) {
> +        ArrayList<DeploymentListener> listeners;
> +        synchronized (this) {
> +            listeners = new ArrayList<DeploymentListener>(deploymentListeners);
> +        }
> +        for (DeploymentListener listener : listeners) {
> +            try {
> +                listener.afterApplicationCreated(appInfo);
> +            } catch (Throwable e) {
> +                logger.error("Error notifying deployment listener of created application " + appInfo.jarPath, e);
> +            }
> +        }
> +    }
> +
> +    private synchronized void fireBeforeApplicationDestroyed(AppInfo appInfo) {
> +        ArrayList<DeploymentListener> listeners;
> +        synchronized (this) {
> +            listeners = new ArrayList<DeploymentListener>(deploymentListeners);
> +        }
> +        for (DeploymentListener listener : listeners) {
> +            try {
> +                listener.beforeApplicationDestroyed(appInfo);
> +            } catch (Throwable e) {
> +                logger.error("Error notifying deployment listener of destroyed application " + appInfo.jarPath, e);
> +            }
> +        }
> +    }
> +
>      protected SafeToolkit toolkit = SafeToolkit.getToolkit("Assembler");
>      protected OpenEjbConfiguration config;
>  
> @@ -507,7 +544,13 @@
>  
>              // App Client
>              for (ClientInfo clientInfo : appInfo.clients) {
> -                JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(clientInfo.jndiEnc, clientInfo.moduleId);
> +                // determind the injections
> +                InjectionBuilder injectionBuilder = new InjectionBuilder(classLoader);
> +                List<Injection> injections = injectionBuilder.buildInjections(clientInfo.jndiEnc);
> +
> +                // build the enc
> +                JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(clientInfo.jndiEnc, injections, clientInfo.moduleId, classLoader);
> +                jndiEncBuilder.setClient(true);
>                  jndiEncBuilder.setUseCrossClassLoaderRef(false);
>                  Context context = (Context) jndiEncBuilder.build().lookup("env");
>                  containerSystem.getJNDIContext().bind("java:openejb/client/" + clientInfo.moduleId + "/comp/env", context);
> @@ -520,41 +563,6 @@
>                  if (clientInfo.callbackHandler != null) {
>                      containerSystem.getJNDIContext().bind("java:openejb/client/" + clientInfo.moduleId + "/comp/callbackHandler", clientInfo.callbackHandler);
>                  }
> -                ArrayList<Injection> injections = new ArrayList<Injection>();
> -                JndiEncInfo jndiEnc = clientInfo.jndiEnc;
> -                for (EjbReferenceInfo info : jndiEnc.ejbReferences) {
> -                    for (InjectionInfo target : info.targets) {
> -                        try {
> -                            Class targetClass = classLoader.loadClass(target.className);
> -                            Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> -                            injections.add(injection);
> -                        } catch (ClassNotFoundException e) {
> -                            logger.error("Injection Target invalid: class=" + target.className + ", name=" + target.propertyName + ".  Exception: " + e.getMessage(), e);
> -                        }
> -                    }
> -                }
> -                for (ResourceReferenceInfo info : jndiEnc.resourceRefs) {
> -                    for (InjectionInfo target : info.targets) {
> -                        try {
> -                            Class targetClass = classLoader.loadClass(target.className);
> -                            Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> -                            injections.add(injection);
> -                        } catch (ClassNotFoundException e) {
> -                            logger.error("Injection Target invalid: class=" + target.className + ", name=" + target.propertyName + ".  Exception: " + e.getMessage(), e);
> -                        }
> -                    }
> -                }
> -                for (ResourceEnvReferenceInfo info : jndiEnc.resourceEnvRefs) {
> -                    for (InjectionInfo target : info.targets) {
> -                        try {
> -                            Class targetClass = classLoader.loadClass(target.className);
> -                            Injection injection = new Injection(info.resourceEnvRefName, target.propertyName, targetClass);
> -                            injections.add(injection);
> -                        } catch (ClassNotFoundException e) {
> -                            logger.error("Injection Target invalid: class=" + target.className + ", name=" + target.propertyName + ".  Exception: " + e.getMessage(), e);
> -                        }
> -                    }
> -                }
>                  containerSystem.getJNDIContext().bind("java:openejb/client/" + clientInfo.moduleId + "/comp/injections", injections);
>              }
>  
> @@ -567,6 +575,7 @@
>              logger.info("Deployed Application(path="+appInfo.jarPath+")");
>  
>              deployedApplications.put(appInfo.jarPath, appInfo);
> +            fireAfterApplicationCreated(appInfo);
>          } catch (Throwable t) {
>              try {
>                  destroyApplication(appInfo);
> @@ -587,6 +596,9 @@
>  
>      private void destroyApplication(AppInfo appInfo) throws UndeployException {
>          logger.info("Undeploying app: "+appInfo.jarPath);
> +
> +        fireBeforeApplicationDestroyed(appInfo);
> +
>          Context globalContext = containerSystem.getJNDIContext();
>          UndeployException undeployException = new UndeployException("Failed undeploying application: id=" + appInfo.jarPath);
>  
> 
> Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentListener.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentListener.java?rev=591858&view=auto
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentListener.java (added)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentListener.java Sun Nov  4 14:41:49 2007
> @@ -0,0 +1,23 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.openejb.assembler.classic;
> +
> +public interface DeploymentListener {
> +    void afterApplicationCreated(AppInfo appInfo);
> +    void beforeApplicationDestroyed(AppInfo appInfo);
> +}
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java Sun Nov  4 14:41:49 2007
> @@ -36,5 +36,6 @@
>      public final List<InterceptorBindingInfo> interceptorBindings = new ArrayList<InterceptorBindingInfo>();
>      public final List<MethodInfo> excludeList = new ArrayList<MethodInfo>();
>      public final List<ApplicationExceptionInfo> applicationException = new ArrayList<ApplicationExceptionInfo>();
> +    public final List<PortInfo> portInfos = new ArrayList<PortInfo>();
>      public final Set<String> watchedResources = new TreeSet<String>();
>  }
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java Sun Nov  4 14:41:49 2007
> @@ -21,8 +21,6 @@
>  import org.apache.openejb.OpenEJBException;
>  import org.apache.openejb.core.CoreDeploymentInfo;
>  import org.apache.openejb.core.DeploymentContext;
> -import org.apache.openejb.core.timer.EjbTimerServiceImpl;
> -import org.apache.openejb.core.timer.NullEjbTimerServiceImpl;
>  import org.apache.openejb.core.cmp.CmpUtil;
>  import org.apache.openejb.util.Index;
>  import org.apache.openejb.util.Messages;
> @@ -113,7 +111,12 @@
>  
>          final String transactionType = bean.transactionType;
>  
> -        JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(bean.jndiEnc, transactionType, emfLinkResolver, moduleId);
> +        // determind the injections
> +        InjectionBuilder injectionBuilder = new InjectionBuilder(cl);
> +        List<Injection> injections = injectionBuilder.buildInjections(bean.jndiEnc);
> +
> +        // build the enc
> +        JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(bean.jndiEnc, injections, transactionType, emfLinkResolver, moduleId, cl);
>          Context root = jndiEncBuilder.build();
>  
>          DeploymentContext deploymentContext = new DeploymentContext(bean.ejbDeploymentId, cl, root);
> @@ -147,69 +150,7 @@
>              deployment.addSecurityRoleReference(alias, actualName);
>          }
>  
> -        for (EnvEntryInfo info : bean.jndiEnc.envEntries) {
> -            for (InjectionInfo target : info.targets) {
> -                Class targetClass = loadClass(target.className, "classNotFound.injectionTarget");
> -                Injection injection = new Injection(info.name, target.propertyName, targetClass);
> -                deployment.getInjections().add(injection);
> -            }
> -        }
> -
> -        for (EjbReferenceInfo info : bean.jndiEnc.ejbReferences) {
> -            for (InjectionInfo target : info.targets) {
> -                Class targetClass = loadClass(target.className, "classNotFound.injectionTarget");
> -                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> -                deployment.getInjections().add(injection);
> -            }
> -        }
> -
> -        for (EjbLocalReferenceInfo info : bean.jndiEnc.ejbLocalReferences) {
> -            for (InjectionInfo target : info.targets) {
> -                Class targetClass = loadClass(target.className, "classNotFound.injectionTarget");
> -                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> -                deployment.getInjections().add(injection);
> -            }
> -        }
> -
> -        for (PersistenceUnitReferenceInfo info : bean.jndiEnc.persistenceUnitRefs) {
> -            for (InjectionInfo target : info.targets) {
> -                Class targetClass = loadClass(target.className, "classNotFound.injectionTarget");
> -                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> -                deployment.getInjections().add(injection);
> -            }
> -        }
> -
> -        for (PersistenceContextReferenceInfo info : bean.jndiEnc.persistenceContextRefs) {
> -            for (InjectionInfo target : info.targets) {
> -                Class targetClass = loadClass(target.className, "classNotFound.injectionTarget");
> -                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> -                deployment.getInjections().add(injection);
> -            }
> -        }
> -
> -        for (ResourceReferenceInfo info : bean.jndiEnc.resourceRefs) {
> -            for (InjectionInfo target : info.targets) {
> -                Class targetClass = loadClass(target.className, "classNotFound.injectionTarget");
> -                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> -                deployment.getInjections().add(injection);
> -            }
> -        }
> -
> -        for (ResourceEnvReferenceInfo info : bean.jndiEnc.resourceEnvRefs) {
> -            for (InjectionInfo target : info.targets) {
> -                Class targetClass = loadClass(target.className, "classNotFound.injectionTarget");
> -                Injection injection = new Injection(info.resourceEnvRefName, target.propertyName, targetClass);
> -                deployment.getInjections().add(injection);
> -            }
> -        }
> -
> -        for (ServiceReferenceInfo info : bean.jndiEnc.serviceRefs) {
> -            for (InjectionInfo target : info.targets) {
> -                Class targetClass = loadClass(target.className, "classNotFound.injectionTarget");
> -                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> -                deployment.getInjections().add(injection);
> -            }
> -        }
> +        deployment.getInjections().addAll(injections);
>  
>          // ejbTimeout
>          deployment.setEjbTimeout(getTimeout(ejbClass, bean.timeoutMethod));
> 
> Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/HandlerChainInfo.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/HandlerChainInfo.java?rev=591858&view=auto
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/HandlerChainInfo.java (added)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/HandlerChainInfo.java Sun Nov  4 14:41:49 2007
> @@ -0,0 +1,28 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.openejb.assembler.classic;
> +
> +import java.util.ArrayList;
> +import java.util.List;
> +
> +public class HandlerChainInfo extends InfoObject {
> +    public String serviceNamePattern;
> +    public String portNamePattern;
> +    public final List<String> protocolBindings = new ArrayList<String>();
> +    public final List<HandlerInfo> handlers = new ArrayList<HandlerInfo>();
> +}
> 
> Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/HandlerInfo.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/HandlerInfo.java?rev=591858&view=auto
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/HandlerInfo.java (added)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/HandlerInfo.java Sun Nov  4 14:41:49 2007
> @@ -0,0 +1,31 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.openejb.assembler.classic;
> +
> +import javax.xml.namespace.QName;
> +import java.util.Properties;
> +import java.util.List;
> +import java.util.ArrayList;
> +
> +public class HandlerInfo extends InfoObject {
> +    public String handlerName;
> +    public String handlerClass;
> +    public final Properties initParams = new Properties();
> +    public final List<QName> soapHeaders = new ArrayList<QName>();
> +    public final List<String> soapRoles = new ArrayList<String>();
> +}
> 
> Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java?rev=591858&view=auto
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java (added)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java Sun Nov  4 14:41:49 2007
> @@ -0,0 +1,113 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.openejb.assembler.classic;
> +
> +import org.apache.openejb.Injection;
> +import org.apache.openejb.OpenEJBException;
> +
> +import java.util.List;
> +import java.util.ArrayList;
> +
> +public class InjectionBuilder {
> +    private final ClassLoader classLoader;
> +
> +    public InjectionBuilder(ClassLoader classLoader) {
> +        this.classLoader = classLoader;
> +    }
> +
> +    public List<Injection> buildInjections(JndiEncInfo jndiEnc) throws OpenEJBException {
> +        List<Injection> injections = new ArrayList<Injection>();
> +        for (EnvEntryInfo info : jndiEnc.envEntries) {
> +            for (InjectionInfo target : info.targets) {
> +                Class targetClass = loadClass(target.className);
> +                Injection injection = new Injection(info.name, target.propertyName, targetClass);
> +                injections.add(injection);
> +            }
> +        }
> +
> +        for (EjbReferenceInfo info : jndiEnc.ejbReferences) {
> +            for (InjectionInfo target : info.targets) {
> +                Class targetClass = loadClass(target.className);
> +                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> +                injections.add(injection);
> +            }
> +        }
> +
> +        for (EjbLocalReferenceInfo info : jndiEnc.ejbLocalReferences) {
> +            for (InjectionInfo target : info.targets) {
> +                Class targetClass = loadClass(target.className);
> +                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> +                injections.add(injection);
> +            }
> +        }
> +
> +        for (PersistenceUnitReferenceInfo info : jndiEnc.persistenceUnitRefs) {
> +            for (InjectionInfo target : info.targets) {
> +                Class targetClass = loadClass(target.className);
> +                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> +                injections.add(injection);
> +            }
> +        }
> +
> +        for (PersistenceContextReferenceInfo info : jndiEnc.persistenceContextRefs) {
> +            for (InjectionInfo target : info.targets) {
> +                Class targetClass = loadClass(target.className);
> +                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> +                injections.add(injection);
> +            }
> +        }
> +
> +        for (ResourceReferenceInfo info : jndiEnc.resourceRefs) {
> +            for (InjectionInfo target : info.targets) {
> +                Class targetClass = loadClass(target.className);
> +                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> +                injections.add(injection);
> +            }
> +        }
> +
> +        for (ResourceEnvReferenceInfo info : jndiEnc.resourceEnvRefs) {
> +            for (InjectionInfo target : info.targets) {
> +                Class targetClass = loadClass(target.className);
> +                Injection injection = new Injection(info.resourceEnvRefName, target.propertyName, targetClass);
> +                injections.add(injection);
> +            }
> +        }
> +
> +        for (ServiceReferenceInfo info : jndiEnc.serviceRefs) {
> +            for (InjectionInfo target : info.targets) {
> +                Class targetClass = loadClass(target.className);
> +                Injection injection = new Injection(info.referenceName, target.propertyName, targetClass);
> +                injections.add(injection);
> +            }
> +        }
> +        return injections;
> +    }
> +
> +    private Class loadClass(String className) throws OpenEJBException {
> +        try {
> +            Class clazz = Class.forName(className, true, classLoader);
> +            clazz.getDeclaredMethods();
> +            clazz.getDeclaredFields();
> +            clazz.getDeclaredConstructors();
> +            clazz.getInterfaces();
> +            return clazz;
> +        } catch (Throwable e) {
> +            throw new OpenEJBException("Unable to load class " + className);
> +        }
> +    }
> +}
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java Sun Nov  4 14:41:49 2007
> @@ -16,23 +16,30 @@
>   */
>  package org.apache.openejb.assembler.classic;
>  
> +import org.apache.openejb.Injection;
>  import org.apache.openejb.OpenEJBException;
> -import org.apache.openejb.loader.SystemInstance;
> -import org.apache.openejb.persistence.JtaEntityManager;
> -import org.apache.openejb.persistence.JtaEntityManagerRegistry;
>  import org.apache.openejb.core.CoreUserTransaction;
> +import org.apache.openejb.core.ivm.naming.CrossClassLoaderJndiReference;
>  import org.apache.openejb.core.ivm.naming.IntraVmJndiReference;
> +import org.apache.openejb.core.ivm.naming.IvmContext;
> +import org.apache.openejb.core.ivm.naming.JaxWsServiceReference;
>  import org.apache.openejb.core.ivm.naming.JndiReference;
> -import org.apache.openejb.core.ivm.naming.PersistenceUnitReference;
> -import org.apache.openejb.core.ivm.naming.Reference;
> -import org.apache.openejb.core.ivm.naming.PersistenceContextReference;
>  import org.apache.openejb.core.ivm.naming.JndiUrlReference;
> -import org.apache.openejb.core.ivm.naming.IvmContext;
>  import org.apache.openejb.core.ivm.naming.NameNode;
>  import org.apache.openejb.core.ivm.naming.ParsedName;
> +import org.apache.openejb.core.ivm.naming.PersistenceContextReference;
> +import org.apache.openejb.core.ivm.naming.PersistenceUnitReference;
> +import org.apache.openejb.core.ivm.naming.Reference;
>  import org.apache.openejb.core.ivm.naming.SystemComponentReference;
> -import org.apache.openejb.core.ivm.naming.CrossClassLoaderJndiReference;
>  import org.apache.openejb.core.ivm.naming.URLReference;
> +import org.apache.openejb.core.webservices.HandlerChainData;
> +import org.apache.openejb.core.webservices.PortRefData;
> +import org.apache.openejb.core.webservices.ServiceRefData;
> +import org.apache.openejb.loader.SystemInstance;
> +import org.apache.openejb.persistence.JtaEntityManager;
> +import org.apache.openejb.persistence.JtaEntityManagerRegistry;
> +import org.apache.openejb.util.LogCategory;
> +import org.apache.openejb.util.Logger;
>  import org.apache.openejb.core.timer.TimerServiceWrapper;
>  import org.apache.xbean.naming.context.WritableContext;
>  import org.omg.CORBA.ORB;
> @@ -42,21 +49,23 @@
>  import javax.ejb.spi.HandleDelegate;
>  import javax.naming.Context;
>  import javax.naming.LinkRef;
> -import javax.naming.NamingException;
>  import javax.naming.Name;
> +import javax.naming.NamingException;
>  import javax.persistence.EntityManagerFactory;
>  import javax.transaction.TransactionManager;
>  import javax.transaction.TransactionSynchronizationRegistry;
>  import javax.transaction.UserTransaction;
> +import javax.xml.ws.Service;
>  import javax.xml.ws.WebServiceContext;
> -
> -import java.util.HashMap;
> -import java.util.Map;
> -import java.util.Iterator;
> +import java.net.MalformedURLException;
>  import java.net.URI;
>  import java.net.URISyntaxException;
>  import java.net.URL;
> -import java.net.MalformedURLException;
> +import java.util.HashMap;
> +import java.util.Iterator;
> +import java.util.List;
> +import java.util.Map;
> +import java.util.ArrayList;
>  
>  /**
>   * TODO: This class is essentially an over glorified sym-linker.  The names
> @@ -66,21 +75,27 @@
>   * symlinked version of all the components.
>   */
>  public class JndiEncBuilder {
> +    public static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP, JndiEncBuilder.class.getPackage().getName());
>  
>      private final boolean beanManagedTransactions;
>      private final JndiEncInfo jndiEnc;
>      private final URI moduleUri;
> +    private final List<Injection> injections;
> +    private final ClassLoader classLoader;
>  
>      // JPA factory indexes
>      private final LinkResolver<EntityManagerFactory> emfLinkResolver;
>  
>      private boolean useCrossClassLoaderRef = true;
> +    private boolean client = false;
>  
> -    public JndiEncBuilder(JndiEncInfo jndiEnc, String moduleId) throws OpenEJBException {
> -        this(jndiEnc, null, null, moduleId);
> +    public JndiEncBuilder(JndiEncInfo jndiEnc, List<Injection> injections, String moduleId, ClassLoader classLoader) throws OpenEJBException {
> +        this(jndiEnc, injections, null, null, moduleId, classLoader);
>      }
>  
> -    public JndiEncBuilder(JndiEncInfo jndiEnc, String transactionType, LinkResolver<EntityManagerFactory> emfLinkResolver, String moduleId) throws OpenEJBException {
> +    public JndiEncBuilder(JndiEncInfo jndiEnc, List<Injection> injections, String transactionType, LinkResolver<EntityManagerFactory> emfLinkResolver, String moduleId, ClassLoader classLoader) throws OpenEJBException {
> +        this.jndiEnc = jndiEnc;
> +        this.injections = injections;
>          beanManagedTransactions = transactionType != null && transactionType.equalsIgnoreCase("Bean");
>  
>          try {
> @@ -88,8 +103,8 @@
>          } catch (URISyntaxException e) {
>              throw new OpenEJBException(e);
>          }
> -        this.jndiEnc = jndiEnc;
>          this.emfLinkResolver = emfLinkResolver;
> +        this.classLoader = classLoader;
>      }
>  
>      public boolean isUseCrossClassLoaderRef() {
> @@ -100,6 +115,14 @@
>          this.useCrossClassLoaderRef = useCrossClassLoaderRef;
>      }
>  
> +    public boolean isClient() {
> +        return client;
> +    }
> +
> +    public void setClient(boolean client) {
> +        this.client = client;
> +    }
> +
>      public Context build() throws OpenEJBException {
>          Map<String, Object> bindings = buildMap();
>  
> @@ -326,6 +349,75 @@
>              if (referenceInfo.location != null){
>                  Reference reference = buildReferenceLocation(referenceInfo.location);
>                  bindings.put(normalize(referenceInfo.referenceName), reference);
> +                continue;
> +            }
> +
> +            // load service class which is used to construct the port
> +            Class<? extends Service> serviceClass = Service.class;
> +            if (referenceInfo.serviceType != null) {
> +                try {
> +                    serviceClass = classLoader.loadClass(referenceInfo.serviceType).asSubclass(Service.class);
> +                } catch (Exception e) {
> +                    throw new OpenEJBException("Could not load service type class "+ referenceInfo.serviceType, e);
> +                }
> +            }
> +
> +            // load the reference class which is the ultimate type of the port
> +            Class<?> referenceClass = null;
> +            if (referenceInfo.referenceType != null) {
> +                try {
> +                    referenceClass = classLoader.loadClass(referenceInfo.referenceType);
> +                } catch (Exception e) {
> +                    throw new OpenEJBException("Could not load reference type class " + referenceInfo.referenceType, e);
> +                }
> +            }
> +
> +            // if ref class is a subclass of Service, use it for the service class
> +            if (referenceClass != null && Service.class.isAssignableFrom(referenceClass)) {
> +                serviceClass = referenceClass.asSubclass(Service.class);
> +            }
> +
> +            // determine the location of the wsdl file
> +            URL wsdlUrl = null;
> +            if (referenceInfo.wsdlFile != null) {
> +                try {
> +                    wsdlUrl = new URL(referenceInfo.wsdlFile);
> +                } catch (MalformedURLException e) {
> +                    wsdlUrl = classLoader.getResource(referenceInfo.wsdlFile);
> +                    if (wsdlUrl == null) {
> +                        logger.warning("Error obtaining WSDL: " + referenceInfo.wsdlFile, e);
> +                    }
> +
> +                }
> +            }
> +
> +            // port refs
> +            List<PortRefData> portRefs = new ArrayList<PortRefData>(referenceInfo.portRefs.size());
> +            for (PortRefInfo portRefInfo : referenceInfo.portRefs) {
> +                PortRefData portRef = new PortRefData();
> +                try {
> +                    portRef.setServiceEndpointInterface(classLoader.loadClass(portRefInfo.serviceEndpointInterface));
> +                } catch (Exception e) {
> +                    throw new OpenEJBException("Could not load service endpoint interface "+ portRefInfo.serviceEndpointInterface, e);
> +                }
> +                portRef.setEnableMtom(portRefInfo.enableMtom);
> +                portRef.setPortComponentLink(portRefInfo.portComponentLink);
> +                portRef.getProperties().putAll(portRefInfo.properties);
> +                portRefs.add(portRef);
> +            }
> +
> +            // create the handle chains
> +            List<HandlerChainData> handlerChains = null;
> +            if (!referenceInfo.handlerChains.isEmpty()) {
> +                handlerChains = WsBuilder.toHandlerChainData(referenceInfo.handlerChains, classLoader);
> +            }
> +
> +            if (!client) {
> +                Reference reference = new JaxWsServiceReference(serviceClass, referenceClass, wsdlUrl, referenceInfo.serviceQName, referenceInfo.wsdlRepoUri, portRefs, handlerChains, injections);
> +                bindings.put(normalize(referenceInfo.referenceName), reference);
> +            } else {
> +                ServiceRefData serviceRefData = new ServiceRefData(serviceClass, referenceClass, wsdlUrl, referenceInfo.serviceQName, referenceInfo.wsdlRepoUri, handlerChains, portRefs);
> +                bindings.put(normalize(referenceInfo.referenceName), serviceRefData);
>              }
>          }
>          return bindings;
> 
> Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java?rev=591858&view=auto
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java (added)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java Sun Nov  4 14:41:49 2007
> @@ -0,0 +1,37 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.openejb.assembler.classic;
> +
> +import javax.xml.namespace.QName;
> +import java.util.List;
> +import java.util.ArrayList;
> +
> +public class PortInfo extends InfoObject {
> +    public String serviceName;
> +    public String portName;
> +    public String seiInterfaceName;
> +    public String wsdlFile;
> +    public String serviceLink;
> +    public final List<HandlerChainInfo> handlerChains = new ArrayList<HandlerChainInfo>();
> +    public boolean mtomEnabled;
> +    public String binding;
> +    public QName wsdlPort;
> +    public QName wsdlService;
> +    public String location;
> +    public String wsdlPublishLocation;
> +}
> 
> Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortRefInfo.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortRefInfo.java?rev=591858&view=auto
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortRefInfo.java (added)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortRefInfo.java Sun Nov  4 14:41:49 2007
> @@ -0,0 +1,27 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.openejb.assembler.classic;
> +
> +import java.util.Properties;
> +
> +public class PortRefInfo extends InfoObject {
> +    public String serviceEndpointInterface;
> +    public boolean enableMtom;
> +    public String portComponentLink;
> +    public final Properties properties = new Properties();
> +}
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServiceReferenceInfo.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServiceReferenceInfo.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServiceReferenceInfo.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServiceReferenceInfo.java Sun Nov  4 14:41:49 2007
> @@ -16,6 +16,10 @@
>   */
>  package org.apache.openejb.assembler.classic;
>  
> +import javax.xml.namespace.QName;
> +import java.util.List;
> +import java.util.ArrayList;
> +
>  /**
>   * @version $Rev$ $Date$
>   */
> @@ -23,5 +27,14 @@
>  
>      public String referenceName;
>  
> +    public QName serviceQName;
> +    public String wsdlFile;
> +    public String jaxrpcMappingFile;
> +    public String referenceType;
> +    public String serviceType;
> +    public String wsdlRepoUri;
> +    public final List<HandlerChainInfo> handlerChains = new ArrayList<HandlerChainInfo>();
> +    public final List<PortRefInfo> portRefs =new ArrayList<PortRefInfo>();
> +    
>      public ReferenceLocationInfo location;
>  }
> 
> Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServletInfo.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServletInfo.java?rev=591858&view=auto
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServletInfo.java (added)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServletInfo.java Sun Nov  4 14:41:49 2007
> @@ -0,0 +1,24 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.openejb.assembler.classic;
> +
> +public class ServletInfo extends InfoObject {
> +    public String servletName;
> +    public String servletClass;
> +    public String runAs;
> +}
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java Sun Nov  4 14:41:49 2007
> @@ -19,9 +19,11 @@
>  
>  import java.util.Set;
>  import java.util.TreeSet;
> +import java.util.List;
> +import java.util.ArrayList;
> +import java.util.Collection;
>  
>  public class WebAppInfo extends InfoObject {
> -
>      public String codebase;
>      public String description;
>      public String displayName;
> @@ -31,6 +33,7 @@
>      public String host;
>      public String contextRoot;
>      public final Set<String> watchedResources = new TreeSet<String>();
> -
> +    public final List<PortInfo> portInfos = new ArrayList<PortInfo>();
>      public JndiEncInfo jndiEnc;
> +    public final List<ServletInfo> servlets = new ArrayList<ServletInfo>();
>  }
> 
> Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java?rev=591858&view=auto
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java (added)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java Sun Nov  4 14:41:49 2007
> @@ -0,0 +1,103 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.openejb.assembler.classic;
> +
> +import org.apache.openejb.core.webservices.HandlerChainData;
> +import org.apache.openejb.core.webservices.HandlerData;
> +import org.apache.openejb.core.webservices.PortData;
> +import org.apache.openejb.OpenEJBException;
> +import org.apache.openejb.Injection;
> +
> +import javax.xml.namespace.QName;
> +import java.util.List;
> +import java.util.ArrayList;
> +import java.util.Collection;
> +import java.net.URL;
> +import java.net.MalformedURLException;
> +
> +public class WsBuilder {
> +    public static PortData toPortData(PortInfo port, Collection<Injection> injections, URL baseUrl, ClassLoader classLoader) throws OpenEJBException {
> +        PortData portData = new PortData();
> +        if (port.serviceName != null && port.serviceName.length() != 0) {
> +            portData.setServiceName(QName.valueOf(port.serviceName));
> +        }
> +        if (port.portName != null && port.portName.length() != 0) {
> +            portData.setPortName(QName.valueOf(port.portName));
> +        }
> +        portData.setWsdlUrl(getWsdlURL(port.wsdlFile, baseUrl, classLoader));
> +        portData.getHandlerChains().addAll(toHandlerChainData(port.handlerChains, classLoader));
> +        portData.getInjections().addAll(injections);
> +        portData.setMtomEnabled(port.mtomEnabled);
> +        portData.setBindingID(port.binding);
> +        portData.setWsdlPort(port.wsdlPort);
> +        portData.setWsdlService(port.wsdlService);
> +        portData.setLocation(port.location);
> +        portData.setWsdlPublishLocation(port.wsdlPublishLocation);
> +        return portData;
> +    }
> +
> +    public static List<HandlerChainData> toHandlerChainData(List<HandlerChainInfo> chains, ClassLoader classLoader) throws OpenEJBException {
> +        List<HandlerChainData> handlerChains = new ArrayList<HandlerChainData>();
> +        for (HandlerChainInfo handlerChain : chains) {
> +            List<HandlerData> handlers = new ArrayList<HandlerData>();
> +            for (HandlerInfo handler : handlerChain.handlers) {
> +                try {
> +                    Class<?> handlerClass = classLoader.loadClass(handler.handlerClass);
> +                    HandlerData handlerData = new HandlerData(handlerClass);
> +                    handlerData.getInitParams().putAll(handler.initParams);
> +                    handlerData.getSoapHeaders().addAll(handler.soapHeaders);
> +                    handlerData.getSoapRoles().addAll(handler.soapRoles);
> +                    handlers.add(handlerData);
> +                } catch (ClassNotFoundException e) {
> +                    throw new OpenEJBException("Could not load handler class "+ handler.handlerClass);
> +                }
> +            }
> +
> +            HandlerChainData handlerChainData = new HandlerChainData(handlerChain.serviceNamePattern,
> +                    handlerChain.portNamePattern,
> +                    handlerChain.protocolBindings,
> +                    handlers);
> +            handlerChains.add(handlerChainData);
> +
> +        }
> +        return handlerChains;
> +    }
> +
> +    public static URL getWsdlURL(String wsdlFile, URL baseUrl, ClassLoader classLoader) {
> +        URL wsdlURL = null;
> +        if (wsdlFile != null && wsdlFile.length() > 0) {
> +            try {
> +                wsdlURL = new URL(wsdlFile);
> +            } catch (MalformedURLException e) {
> +                // Not a URL, try as a resource
> +                wsdlURL = classLoader.getResource(wsdlFile);
> +
> +                if (wsdlURL == null && baseUrl != null) {
> +                    // Cannot get it as a resource, try with
> +                    // configurationBaseUrl
> +                    try {
> +                        wsdlURL = new URL(baseUrl, wsdlFile);
> +                    } catch (MalformedURLException ee) {
> +                        // ignore
> +                    }
> +                }
> +            }
> +        }
> +        return wsdlURL;
> +    }
> +}
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Sun Nov  4 14:41:49 2007
> @@ -18,6 +18,7 @@
>  
>  import org.apache.openejb.DeploymentInfo;
>  import org.apache.openejb.OpenEJBException;
> +import org.apache.openejb.core.webservices.JaxWsUtils;
>  import org.apache.openejb.jee.ActivationConfig;
>  import org.apache.openejb.jee.ApplicationClient;
>  import org.apache.openejb.jee.AroundInvoke;
> @@ -61,12 +62,16 @@
>  import org.apache.openejb.jee.SessionType;
>  import org.apache.openejb.jee.StatefulBean;
>  import org.apache.openejb.jee.StatelessBean;
> +import org.apache.openejb.jee.Tag;
>  import org.apache.openejb.jee.TimerConsumer;
> +import org.apache.openejb.jee.TldTaglib;
>  import org.apache.openejb.jee.TransAttribute;
>  import org.apache.openejb.jee.TransactionType;
>  import org.apache.openejb.jee.WebApp;
> -import org.apache.openejb.jee.TldTaglib;
> -import org.apache.openejb.jee.Tag;
> +import org.apache.openejb.jee.HandlerChains;
> +import org.apache.openejb.jee.Handler;
> +import org.apache.openejb.jee.WebserviceDescription;
> +import org.apache.openejb.jee.PortComponent;
>  import static org.apache.openejb.util.Join.join;
>  import org.apache.openejb.util.LogCategory;
>  import org.apache.openejb.util.Logger;
> @@ -107,6 +112,7 @@
>  import javax.interceptor.ExcludeDefaultInterceptors;
>  import javax.interceptor.Interceptors;
>  import javax.jws.WebService;
> +import javax.jws.HandlerChain;
>  import javax.persistence.PersistenceContext;
>  import javax.persistence.PersistenceContexts;
>  import javax.persistence.PersistenceUnit;
> @@ -114,9 +120,11 @@
>  import javax.xml.ws.WebServiceProvider;
>  import javax.xml.ws.WebServiceRef;
>  import javax.xml.ws.WebServiceRefs;
> +import javax.xml.ws.Service;
>  import java.io.File;
>  import java.lang.reflect.Field;
>  import java.lang.reflect.Method;
> +import java.lang.reflect.Modifier;
>  import java.net.MalformedURLException;
>  import java.net.URL;
>  import java.util.ArrayList;
> @@ -209,6 +217,39 @@
>          }
>  
>          public WebModule deploy(WebModule webModule) throws OpenEJBException {
> +            WebApp webApp = webModule.getWebApp();
> +            if (webApp != null && (webApp.isMetadataComplete() || !webApp.getServlet().isEmpty())) return webModule;
> +
> +            ClassFinder finder;
> +            try {
> +                finder = new ClassFinder(webModule.getClassLoader());
> +            } catch (Exception e) {
> +                DeploymentLoader.logger.warning("Unable to scrape for @WebService or @WebServiceProvider annotations. ClassFinder failed.", e);
> +                return webModule;
> +            }
> +
> +            List<Class> classes = new ArrayList<Class>();
> +            classes.addAll(finder.findAnnotatedClasses(WebService.class));
> +            classes.addAll(finder.findAnnotatedClasses(WebServiceProvider.class));
> +            for (Class<?> webServiceClass : classes) {
> +                int modifiers = webServiceClass.getModifiers();
> +                if (!Modifier.isPublic(modifiers) || Modifier.isFinal(modifiers) || Modifier.isAbstract(modifiers)) {
> +                    continue;
> +                }
> +
> +                // create webApp and webservices objects if they don't exist already
> +                if (webApp == null) {
> +                    webApp = new WebApp();
> +                    webModule.setWebApp(webApp);
> +                }
> +
> +                // add new <servlet/> element
> +                Servlet servlet = new Servlet();
> +                servlet.setServletName(webServiceClass.getName());
> +                servlet.setServletClass(webServiceClass.getName());
> +                webApp.getServlet().add(servlet);
> +            }
> +
>              return webModule;
>          }
>  
> @@ -362,7 +403,8 @@
>              }
>              ApplicationClient client = clientModule.getApplicationClient();
>              ClassFinder inheritedClassFinder = createInheritedClassFinder(clazz);
> -            buildAnnotatedRefs(client, inheritedClassFinder);
> +            buildAnnotatedRefs(client, inheritedClassFinder, classLoader);
> +            processWebServiceClientHandlers(client, classLoader);
>  
>              return clientModule;
>          }
> @@ -377,11 +419,12 @@
>              if (webApp != null && webApp.isMetadataComplete()) return webModule;
>  
>              Set<Class<?>> classes = new HashSet<Class<?>>();
> +            ClassLoader classLoader = webModule.getClassLoader();
>              for (Servlet servlet : webApp.getServlet()) {
>                  String servletClass = servlet.getServletClass();
>                  if (servletClass != null) {
>                      try {
> -                        Class clazz = webModule.getClassLoader().loadClass(servletClass);
> +                        Class clazz = classLoader.loadClass(servletClass);
>                          classes.add(clazz);
>                      } catch (ClassNotFoundException e) {
>                          throw new OpenEJBException("Unable to load servlet class: " + servletClass, e);
> @@ -392,7 +435,7 @@
>                  String filterClass = filter.getFilterClass();
>                  if (filterClass != null) {
>                      try {
> -                        Class clazz = webModule.getClassLoader().loadClass(filterClass);
> +                        Class clazz = classLoader.loadClass(filterClass);
>                          classes.add(clazz);
>                      } catch (ClassNotFoundException e) {
>                          throw new OpenEJBException("Unable to load servlet filter class: " + filterClass, e);
> @@ -403,7 +446,7 @@
>                  String listenerClass = listener.getListenerClass();
>                  if (listenerClass != null) {
>                      try {
> -                        Class clazz = webModule.getClassLoader().loadClass(listenerClass);
> +                        Class clazz = classLoader.loadClass(listenerClass);
>                          classes.add(clazz);
>                      } catch (ClassNotFoundException e) {
>                          throw new OpenEJBException("Unable to load servlet listener class: " + listenerClass, e);
> @@ -415,7 +458,7 @@
>                      String listenerClass = listener.getListenerClass();
>                      if (listenerClass != null) {
>                          try {
> -                            Class clazz = webModule.getClassLoader().loadClass(listenerClass);
> +                            Class clazz = classLoader.loadClass(listenerClass);
>                              classes.add(clazz);
>                          } catch (ClassNotFoundException e) {
>                              throw new OpenEJBException("Unable to load tag library servlet listener class: " + listenerClass, e);
> @@ -426,7 +469,7 @@
>                      String tagClass = tag.getTagClass();
>                      if (tagClass != null) {
>                          try {
> -                            Class clazz = webModule.getClassLoader().loadClass(tagClass);
> +                            Class clazz = classLoader.loadClass(tagClass);
>                              classes.add(clazz);
>                          } catch (ClassNotFoundException e) {
>                              throw new OpenEJBException("Unable to load tag library tag class: " + tagClass, e);
> @@ -434,11 +477,34 @@
>                      }
>                  }
>              }
> -            
> +            if (webModule.getWebservices() != null) {
> +                for (WebserviceDescription webservice : webModule.getWebservices().getWebserviceDescription()) {
> +                    for (PortComponent port : webservice.getPortComponent()) {
> +                        // skip ejb port defs
> +                        if (port.getServiceImplBean().getEjbLink() != null) continue;
> +
> +                        for (org.apache.openejb.jee.HandlerChain handlerChain : port.getHandlerChains().getHandlerChain()) {
> +                            for (Handler handler : handlerChain.getHandler()) {
> +                                String handlerClass = handler.getHandlerClass();
> +                                if (handlerClass != null) {
> +                                    try {
> +                                        Class clazz = classLoader.loadClass(handlerClass);
> +                                        classes.add(clazz);
> +                                    } catch (ClassNotFoundException e) {
> +                                        throw new OpenEJBException("Unable to load webservice handler class: " + handlerClass, e);
> +                                    }
> +                                }
> +                            }
> +                        }
> +                    }
> +                }
> +            }
> +
>              ClassFinder inheritedClassFinder = createInheritedClassFinder(classes.toArray(new Class<?>[0]));
>  
>              // Currently we only process the JNDI annotations for web applications
> -            buildAnnotatedRefs(webApp, inheritedClassFinder);
> +            buildAnnotatedRefs(webApp, inheritedClassFinder, classLoader);
> +            processWebServiceClientHandlers(webApp, classLoader);
>  
>              return webModule;
>          }
> @@ -856,8 +922,36 @@
>                      }
>  
>                  }
> -                buildAnnotatedRefs(bean, inheritedClassFinder);
>  
> +                // add webservice handler classes to the class finder used in annotation processing
> +                Set<Class<?>> classes = new HashSet<Class<?>>();
> +                classes.add(clazz);
> +                if (ejbModule.getWebservices() != null) {
> +                    for (WebserviceDescription webservice : ejbModule.getWebservices().getWebserviceDescription()) {
> +                        for (PortComponent port : webservice.getPortComponent()) {
> +                            // only process port definitions for this ejb
> +                            if (!ejbName.equals(port.getServiceImplBean().getEjbLink())) continue;
> +
> +                            for (org.apache.openejb.jee.HandlerChain handlerChain : port.getHandlerChains().getHandlerChain()) {
> +                                for (Handler handler : handlerChain.getHandler()) {
> +                                    String handlerClass = handler.getHandlerClass();
> +                                    if (handlerClass != null) {
> +                                        try {
> +                                            Class handlerClazz = classLoader.loadClass(handlerClass);
> +                                            classes.add(handlerClazz);
> +                                        } catch (ClassNotFoundException e) {
> +                                            throw new OpenEJBException("Unable to load webservice handler class: " + handlerClass, e);
> +                                        }
> +                                    }
> +                                }
> +                            }
> +                        }
> +                    }
> +                }
> +                inheritedClassFinder = createInheritedClassFinder(classes.toArray(new Class<?>[0]));
> +
> +                buildAnnotatedRefs(bean, inheritedClassFinder, classLoader);
> +                processWebServiceClientHandlers(bean, classLoader);
>              }
>  
>              for (Interceptor interceptor : ejbModule.getEjbJar().getInterceptors()) {
> @@ -872,7 +966,8 @@
>  
>                  processCallbacks(interceptor, inheritedClassFinder);
>  
> -                buildAnnotatedRefs(interceptor, inheritedClassFinder);
> +                buildAnnotatedRefs(interceptor, inheritedClassFinder, classLoader);
> +                processWebServiceClientHandlers(interceptor, classLoader);
>  
>                  for (EnterpriseBean bean : enterpriseBeans) {
>                      // DMB: TODO, we should actually check to see if the ref exists in the bean's enc.
> @@ -884,6 +979,7 @@
>                      bean.getPersistenceContextRef().addAll(interceptor.getPersistenceContextRef());
>                      bean.getPersistenceUnitRef().addAll(interceptor.getPersistenceUnitRef());
>                      bean.getMessageDestinationRef().addAll(interceptor.getMessageDestinationRef());
> +                    bean.getServiceRef().addAll(interceptor.getServiceRef());
>                  }
>              }
>  
> @@ -984,7 +1080,7 @@
>              }
>          }
>  
> -        private void buildAnnotatedRefs(JndiConsumer consumer, ClassFinder classFinder) throws OpenEJBException {
> +        private void buildAnnotatedRefs(JndiConsumer consumer, ClassFinder classFinder, ClassLoader classLoader) throws OpenEJBException {
>              //
>              // @EJB
>              //
> @@ -1070,23 +1166,25 @@
>  
>              for (WebServiceRef webserviceref : webservicerefList) {
>  
> -                buildWebServiceRef(consumer, webserviceref, null);
> +                buildWebServiceRef(consumer, webserviceref, null, null, classLoader);
>              }
>  
>              for (Field field : classFinder.findAnnotatedFields(WebServiceRef.class)) {
>                  WebServiceRef webserviceref = field.getAnnotation(WebServiceRef.class);
> +                HandlerChain handlerChain = field.getAnnotation(HandlerChain.class);
>  
>                  Member member = new FieldMember(field);
>  
> -                buildWebServiceRef(consumer, webserviceref, member);
> +                buildWebServiceRef(consumer, webserviceref, handlerChain, member, classLoader);
>              }
>  
>              for (Method method : classFinder.findAnnotatedMethods(WebServiceRef.class)) {
>                  WebServiceRef webserviceref = method.getAnnotation(WebServiceRef.class);
> +                HandlerChain handlerChain = method.getAnnotation(HandlerChain.class);
>  
>                  Member member = new MethodMember(method);
>  
> -                buildWebServiceRef(consumer, webserviceref, member);
> +                buildWebServiceRef(consumer, webserviceref, handlerChain, member, classLoader);
>              }
>  
>              //
> @@ -1148,6 +1246,37 @@
>  
>          }
>  
> +        private void processWebServiceClientHandlers(JndiConsumer consumer, ClassLoader classLoader) throws OpenEJBException {
> +            Set<Class<?>> processedClasses = new HashSet<Class<?>>();
> +            Set<Class<?>> handlerClasses = new HashSet<Class<?>>();
> +            do {
> +                // get unprocessed handler classes
> +                handlerClasses.clear();
> +                for (ServiceRef serviceRef : consumer.getServiceRef()) {
> +                    HandlerChains chains = serviceRef.getHandlerChains();
> +                    if (chains == null) continue;
> +                    for (org.apache.openejb.jee.HandlerChain handlerChain : chains.getHandlerChain()) {
> +                        for (Handler handler : handlerChain.getHandler()) {
> +                            if (handler.getHandlerClass() != null) {
> +                                try {
> +                                    Class clazz = classLoader.loadClass(handler.getHandlerClass());
> +                                    handlerClasses.add(clazz);
> +                                } catch (ClassNotFoundException e) {
> +                                    throw new OpenEJBException("Unable to load webservice handler class: " + handler.getHandlerClass(), e);
> +                                }
> +                            }
> +                        }
> +                    }
> +                }
> +                handlerClasses.removeAll(processedClasses);
> +
> +                // process handler classes
> +                ClassFinder handlerClassFinder = createInheritedClassFinder(handlerClasses.toArray(new Class<?>[0]));
> +                buildAnnotatedRefs(consumer, handlerClassFinder, classLoader);
> +                processedClasses.addAll(handlerClasses);
> +            } while (!handlerClasses.isEmpty());
> +        }
> +
>          private void buildPersistenceUnit(JndiConsumer consumer, PersistenceUnit persistenceUnit, Member member) throws OpenEJBException {
>              // Get the ref-name
>              String refName = persistenceUnit.name();
> @@ -1266,7 +1395,7 @@
>  
>          }
>  
> -        private void buildWebServiceRef(JndiConsumer consumer, WebServiceRef webService, Member member) {
> +        private void buildWebServiceRef(JndiConsumer consumer, WebServiceRef webService, HandlerChain handlerChain, Member member, ClassLoader classLoader) throws OpenEJBException {
>  
>              ServiceRef serviceRef = null;
>  
> @@ -1280,6 +1409,7 @@
>              if (serviceRef == null) {
>                  serviceRef = new ServiceRef();
>                  serviceRef.setServiceRefName(refName);
> +
>                  consumer.getServiceRef().add(serviceRef);
>              }
>  
> @@ -1292,16 +1422,34 @@
>              }
>  
>              // Set service interface
> +            Class<?> serviceInterface = null;
>              if (serviceRef.getServiceInterface() == null) {
> -                Class<?> interfce = webService.type();
> -                if (interfce.equals(Object.class)) {
> +                serviceInterface = webService.type();
> +                if (serviceInterface.equals(Object.class)) {
>                      if (member != null) {
> -                        interfce = member.getType();
> +                        serviceInterface = member.getType();
>                      } else {
> -                        interfce = webService.value();
> +                        serviceInterface = webService.value();
>                      }
>                  }
> -                serviceRef.setServiceInterface(interfce.getName());
> +            }
> +            if (serviceInterface == null || !serviceInterface.isAssignableFrom(Service.class)) {
> +                serviceInterface = Service.class;
> +            }
> +            serviceRef.setServiceInterface(serviceInterface.getName());
> +
> +            // reference type
> +            if (serviceRef.getServiceRefType() == null || ("").equals(serviceRef.getServiceRefType())) {
> +                if (webService.type() != java.lang.Object.class) {
> +                    serviceRef.setServiceRefType(webService.type().getName());
> +                } else {
> +                    serviceRef.setServiceRefType(member.getType().getName());
> +                }
> +            }
> +            Class<?> refType = null;
> +            try {
> +                refType = classLoader.loadClass(serviceRef.getType());
> +            } catch (ClassNotFoundException e) {
>              }
>  
>              // Set the mappedName
> @@ -1313,11 +1461,36 @@
>                  serviceRef.setMappedName(mappedName);
>              }
>  
> -            // Set wsdl file
> +            // wsdl file
>              if (serviceRef.getWsdlFile() == null) {
>                  String wsdlLocation = webService.wsdlLocation();
>                  if (!wsdlLocation.equals("")) {
>                      serviceRef.setWsdlFile(wsdlLocation);
> +                }
> +            }
> +            if (serviceRef.getWsdlFile() == null && refType != null) {
> +                serviceRef.setWsdlFile(JaxWsUtils.getServiceWsdlLocation(refType, classLoader));
> +            }
> +            if (serviceRef.getWsdlFile() == null && serviceInterface != null) {
> +                serviceRef.setWsdlFile(JaxWsUtils.getServiceWsdlLocation(serviceInterface, classLoader));
> +            }
> +
> +            // service qname
> +            if (serviceRef.getServiceQname() == null && refType != null) {
> +                serviceRef.setServiceQname(JaxWsUtils.getServiceQName(refType).toString());
> +            }
> +            if (serviceRef.getServiceQname() == null && serviceInterface != null) {
> +                serviceRef.setServiceQname(JaxWsUtils.getServiceQName(serviceInterface).toString());
> +            }
> +
> +            // handlers
> +            if (serviceRef.getHandlerChains() == null && handlerChain != null) {
> +                try {
> +                    URL handlerFileURL = member.getDeclaringClass().getResource(handlerChain.file());
> +                    HandlerChains handlerChains = ReadDescriptors.readHandlerChains(handlerFileURL);
> +                    serviceRef.setHandlerChains(handlerChains);
> +                } catch (Throwable e) {
> +                    throw new OpenEJBException("Unable to load handler chain file: " + handlerChain.file(), e);
>                  }
>              }
>          }
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Sun Nov  4 14:41:49 2007
> @@ -43,6 +43,10 @@
>  import org.apache.openejb.assembler.classic.TransactionServiceInfo;
>  import org.apache.openejb.assembler.classic.ConnectorInfo;
>  import org.apache.openejb.assembler.classic.WebAppInfo;
> +import org.apache.openejb.assembler.classic.PortInfo;
> +import org.apache.openejb.assembler.classic.HandlerChainInfo;
> +import org.apache.openejb.assembler.classic.HandlerInfo;
> +import org.apache.openejb.assembler.classic.ServletInfo;
>  import org.apache.openejb.config.sys.ConnectionManager;
>  import org.apache.openejb.config.sys.Container;
>  import org.apache.openejb.config.sys.JndiProvider;
> @@ -64,6 +68,15 @@
>  import org.apache.openejb.jee.InboundResource;
>  import org.apache.openejb.jee.MessageListener;
>  import org.apache.openejb.jee.AdminObject;
> +import org.apache.openejb.jee.Webservices;
> +import org.apache.openejb.jee.WebserviceDescription;
> +import org.apache.openejb.jee.PortComponent;
> +import org.apache.openejb.jee.ServiceImplBean;
> +import org.apache.openejb.jee.HandlerChain;
> +import org.apache.openejb.jee.Handler;
> +import org.apache.openejb.jee.ParamValue;
> +import org.apache.openejb.jee.HandlerChains;
> +import org.apache.openejb.jee.Servlet;
>  import org.apache.openejb.jee.jpa.EntityMappings;
>  import org.apache.openejb.jee.jpa.JpaJaxbUtil;
>  import org.apache.openejb.jee.jpa.unit.Persistence;
> @@ -151,6 +164,8 @@
>              chain.add(new DebuggableVmHackery());
>          }
>  
> +        chain.add(new WsDeployer());
> +
>          chain.add(new CmpJpaConversion());
>          chain.add(new OpenEjb2Conversion());
>          chain.add(new SunConversion());
> @@ -355,6 +370,8 @@
>                      bean.containerId = d.getContainerId();
>                  }
>  
> +                ejbJarInfo.portInfos.addAll(configureWebservices(ejbModule.getWebservices()));
> +
>                  appInfo.ejbJars.add(ejbJarInfo);
>  
>              } catch (OpenEJBException e) {
> @@ -572,6 +589,16 @@
>  
>              JndiEncInfoBuilder jndiEncInfoBuilder = new JndiEncInfoBuilder(appInfo.ejbJars);
>              webAppInfo.jndiEnc = jndiEncInfoBuilder.build(webApp, webModule.getJarLocation(), webAppInfo.moduleId);
> +
> +            webAppInfo.portInfos.addAll(configureWebservices(webModule.getWebservices()));
> +
> +            for (Servlet servlet : webModule.getWebApp().getServlet()) {
> +                ServletInfo servletInfo = new ServletInfo();
> +                servletInfo.servletName = servlet.getServletName();
> +                servletInfo.servletClass = servlet.getServletClass();
> +                webAppInfo.servlets.add(servletInfo);
> +            }
> +
>              appInfo.webApps.add(webAppInfo);
>          }
>  
> @@ -597,6 +624,72 @@
>  
>          logger.info("Loaded Module: " + appInfo.jarPath);
>          return appInfo;
> +    }
> +
> +    private List<PortInfo> configureWebservices(Webservices webservices) {
> +        List<PortInfo> portMap = new ArrayList<PortInfo>();
> +        if (webservices == null) {
> +            return portMap;
> +        }
> +
> +        for (WebserviceDescription desc : webservices.getWebserviceDescription()) {
> +            String wsdlFile = desc.getWsdlFile();
> +            String serviceName = desc.getWebserviceDescriptionName();
> +
> +            for (PortComponent port : desc.getPortComponent()) {
> +                PortInfo portInfo = new PortInfo();
> +
> +                ServiceImplBean serviceImplBean = port.getServiceImplBean();
> +                portInfo.serviceLink = serviceImplBean.getEjbLink();
> +                if (portInfo.serviceLink == null) {
> +                    portInfo.serviceLink = serviceImplBean.getServletLink();
> +                }
> +
> +                portInfo.seiInterfaceName = port.getServiceEndpointInterface();
> +                portInfo.portName = port.getPortComponentName();
> +                portInfo.binding = port.getProtocolBinding();
> +                portInfo.serviceName = serviceName;
> +                portInfo.wsdlFile = wsdlFile;
> +                portInfo.mtomEnabled = port.isEnableMtom();
> +                portInfo.wsdlPort = port.getWsdlPort();
> +                portInfo.wsdlService = port.getWsdlService();
> +                portInfo.location = port.getLocation();
> +                portInfo.wsdlPublishLocation = port.getWsdlPublishLocation();
> +
> +                List<HandlerChainInfo> handlerChains = toHandlerChainInfo(port.getHandlerChains());
> +                portInfo.handlerChains.addAll(handlerChains);
> +
> +                // todo configure jaxrpc mappings here
> +                
> +                portMap.add(portInfo);
> +            }
> +        }
> +        return portMap;
> +    }
> +
> +    public static List<HandlerChainInfo> toHandlerChainInfo(HandlerChains chains) {
> +        List<HandlerChainInfo> handlerChains = new ArrayList<HandlerChainInfo>();
> +        if (chains == null) return handlerChains;
> +
> +        for (HandlerChain handlerChain : chains.getHandlerChain()) {
> +            HandlerChainInfo handlerChainInfo = new HandlerChainInfo();
> +            handlerChainInfo.serviceNamePattern = handlerChain.getServiceNamePattern();
> +            handlerChainInfo.portNamePattern = handlerChain.getPortNamePattern();
> +            handlerChainInfo.protocolBindings.addAll(handlerChain.getProtocolBindings());
> +            for (Handler handler : handlerChain.getHandler()) {
> +                HandlerInfo handlerInfo = new HandlerInfo();
> +                handlerInfo.handlerName = handler.getHandlerName();
> +                handlerInfo.handlerClass = handler.getHandlerClass();
> +                handlerInfo.soapHeaders.addAll(handler.getSoapHeader());
> +                handlerInfo.soapRoles.addAll(handler.getSoapRole());
> +                for (ParamValue param : handler.getInitParam()) {
> +                    handlerInfo.initParams.setProperty(param.getParamName(), param.getParamValue());
> +                }
> +                handlerChainInfo.handlers.add(handlerInfo);
> +            }
> +            handlerChains.add(handlerChainInfo);
> +        }
> +        return handlerChains;
>      }
>  
>      private static String getClientModuleId(ClientModule clientModule) {
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java Sun Nov  4 14:41:49 2007
> @@ -30,6 +30,9 @@
>  import org.apache.openejb.jee.JspConfig;
>  import org.apache.openejb.jee.Taglib;
>  import org.apache.openejb.jee.TldTaglib;
> +import org.apache.openejb.jee.Webservices;
> +import org.apache.openejb.jee.WebserviceDescription;
> +import org.apache.openejb.jee.JavaWsdlMapping;
>  import org.apache.openejb.util.LogCategory;
>  import org.apache.openejb.util.Logger;
>  import org.apache.openejb.util.Messages;
> @@ -265,6 +268,9 @@
>                              ejbModule.getWatchedResources().add(ejbJarXmlUrl.getPath());
>                          }
>  
> +                        // load webservices descriptor
> +                        addWebservices(ejbModule);
> +
>                          appModule.getEjbModules().add(ejbModule);
>                      } catch (OpenEJBException e) {
>                          logger.error("Unable to load EJBs from EAR: " + appDir.getAbsolutePath() + ", module: " + moduleName + ". Exception: " + e.getMessage(), e);
> @@ -356,6 +362,9 @@
>                  ejbModule.getWatchedResources().add(ejbJarXmlUrl.getPath());
>              }
>  
> +            // load webservices descriptor
> +            addWebservices(ejbModule);
> +
>              // wrap the EJB Module with an Application Module
>              AppModule appModule = new AppModule(classLoader, ejbModule.getJarLocation());
>              appModule.getEjbModules().add(ejbModule);
> @@ -451,7 +460,63 @@
>          // find all tag libs
>          addTagLibraries(webModule);
>  
> +        // load webservices descriptor
> +        addWebservices(webModule);
> +
>          return webModule;
> +    }
> +
> +    private void addWebservices(WsModule wsModule) throws OpenEJBException {
> +        // get location of webservices.xml file
> +        Object webservicesObject = wsModule.getAltDDs().get("webservices.xml");
> +        if (!(webservicesObject instanceof URL)) {
> +            return;
> +        }
> +        URL webservicesUrl = (URL) webservicesObject;
> +
> +        // determine the base url for this module (either file: or jar:)
> +        URL moduleUrl = null;
> +        try {
> +            File jarFile = new File(wsModule.getJarLocation());
> +            moduleUrl = jarFile.toURL();
> +            if (jarFile.isFile()) {
> +                moduleUrl = new URL("jar", "", -1, moduleUrl + "!/");
> +            }
> +        } catch (MalformedURLException e) {
> +            logger.warning("Invalid module location " + wsModule.getJarLocation());
> +            return;
> +        }
> +
> +        // parse the webservices.xml file
> +        Map<URL,JavaWsdlMapping> jaxrpcMappingCache = new HashMap<URL,JavaWsdlMapping>();
> +        Webservices webservices = ReadDescriptors.readWebservices(webservicesUrl);
> +        wsModule.setWebservices(webservices);
> +        if (webservicesUrl != null && "file".equals(webservicesUrl.getProtocol())) {
> +            wsModule.getWatchedResources().add(webservicesUrl.getPath());
> +        }
> +
> +        // parse any jaxrpc-mapping-files mentioned in the webservices.xml file
> +        for (WebserviceDescription webserviceDescription : webservices.getWebserviceDescription()) {
> +            String jaxrpcMappingFile = webserviceDescription.getJaxrpcMappingFile();
> +            if (jaxrpcMappingFile != null) {
> +                URL jaxrpcMappingUrl = null;
> +                try {
> +                    jaxrpcMappingUrl = new URL(moduleUrl, jaxrpcMappingFile);
> +                    JavaWsdlMapping jaxrpcMapping = jaxrpcMappingCache.get(jaxrpcMappingUrl);
> +                    if (jaxrpcMapping == null) {
> +                        jaxrpcMapping = ReadDescriptors.readJaxrpcMapping(jaxrpcMappingUrl);
> +                        jaxrpcMappingCache.put(jaxrpcMappingUrl, jaxrpcMapping);
> +                    }
> +                    webserviceDescription.setJaxrpcMapping(jaxrpcMapping);
> +                    if (jaxrpcMappingUrl != null && "file".equals(jaxrpcMappingUrl.getProtocol())) {
> +                        wsModule.getWatchedResources().add(jaxrpcMappingUrl.getPath());
> +                    }
> +                } catch (MalformedURLException e) {
> +                    logger.warning("Invalid jaxrpc-mapping-file location " + jaxrpcMappingFile);
> +                }
> +            }
> +        }
> +
>      }
>  
>      private void addTagLibraries(WebModule webModule) throws OpenEJBException {
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java Sun Nov  4 14:41:49 2007
> @@ -18,6 +18,7 @@
>  package org.apache.openejb.config;
>  
>  import org.apache.openejb.jee.EjbJar;
> +import org.apache.openejb.jee.Webservices;
>  import org.apache.openejb.jee.oejb3.OpenejbJar;
>  
>  import java.io.File;
> @@ -31,7 +32,7 @@
>   * Class is intentionally not an interface as that would encourage "smart" implementations
>   * @version $Revision$ $Date$
>   */
> -public class EjbModule implements DeploymentModule {
> +public class EjbModule implements WsModule {
>  
>      private final ValidationContext validation;
>  
> @@ -39,6 +40,7 @@
>      private String jarLocation;
>      private EjbJar ejbJar;
>      private OpenejbJar openejbJar;
> +    private Webservices webservices;
>      private String moduleId;
>      private final Map<String,Object> altDDs = new HashMap<String,Object>();
>      private final Set<String> watchedResources = new TreeSet<String>();
> @@ -128,6 +130,14 @@
>  
>      public void setOpenejbJar(OpenejbJar openejbJar) {
>          this.openejbJar = openejbJar;
> +    }
> +
> +    public Webservices getWebservices() {
> +        return webservices;
> +    }
> +
> +    public void setWebservices(Webservices webservices) {
> +        this.webservices = webservices;
>      }
>  
>      public Set<String> getWatchedResources() {
> 
> Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java?rev=591858&r1=591857&r2=591858&view=diff
> ==============================================================================
> --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java (original)
> +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java Sun Nov  4 14:41:49 2007
> @@ -17,6 +17,7 @@
>  package org.apache.openejb.config;
>  
>  import org.apache.openejb.OpenEJBException;
> +import org.apache.openejb.assembler.classic.AppInfo;
>  import org.apache.openejb.assembler.classic.EjbJarInfo;
>  import org.apache.openejb.assembler.classic.EjbLocalReferenceInfo;
>  import org.apache.openejb.assembler.classic.EjbReferenceInfo;
> @@ -24,46 +25,48 @@
>  import org.apache.openejb.assembler.classic.EnvEntryInfo;
>  import org.apache.openejb.assembler.classic.InjectionInfo;
>  import org.apache.openejb.assembler.classic.JndiEncInfo;
> +import org.apache.openejb.assembler.classic.LinkResolver;
>  import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
>  import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
> +import org.apache.openejb.assembler.classic.PortRefInfo;
>  import org.apache.openejb.assembler.classic.ReferenceLocationInfo;
>  import org.apache.openejb.assembler.classic.ResourceEnvReferenceInfo;
>  import org.apache.openejb.assembler.classic.ResourceReferenceInfo;
>  import org.apache.openejb.assembler.classic.ServiceReferenceInfo;
> -import org.apache.openejb.assembler.classic.AppInfo;
> -import org.apache.openejb.assembler.classic.LinkResolver;
>  import org.apache.openejb.jee.EjbLocalRef;
>  import org.apache.openejb.jee.EjbRef;
> +import org.apache.openejb.jee.EnterpriseBean;
>  import org.apache.openejb.jee.EnvEntry;
>  import org.apache.openejb.jee.Injectable;
>  import org.apache.openejb.jee.InjectionTarget;
>  import org.apache.openejb.jee.JndiConsumer;
>  import org.apache.openejb.jee.JndiReference;
> +import org.apache.openejb.jee.MessageDestinationRef;
>  import org.apache.openejb.jee.PersistenceContextRef;
>  import org.apache.openejb.jee.PersistenceContextType;
>  import org.apache.openejb.jee.PersistenceUnitRef;
> +import org.apache.openejb.jee.PortComponentRef;
>  import org.apache.openejb.jee.Property;
> +import org.apache.openejb.jee.ResAuth;
>  import org.apache.openejb.jee.ResourceEnvRef;
>  import org.apache.openejb.jee.ResourceRef;
>  import org.apache.openejb.jee.ServiceRef;
> -import org.apache.openejb.jee.MessageDestinationRef;
> -import org.apache.openejb.jee.EnterpriseBean;
> -import org.apache.openejb.jee.ResAuth;
>  import org.apache.openejb.jee.oejb3.EjbDeployment;
> -import org.apache.openejb.jee.oejb3.ResourceLink;
>  import org.apache.openejb.jee.oejb3.EjbLink;
> +import org.apache.openejb.jee.oejb3.ResourceLink;
>  import org.apache.openejb.util.LogCategory;
>  import org.apache.openejb.util.Logger;
>  import org.apache.openejb.util.Messages;
>  
> +import javax.xml.namespace.QName;
> +import java.net.URI;
> +import java.net.URISyntaxException;
>  import java.util.ArrayList;
> +import java.util.Arrays;
>  import java.util.Collection;
>  import java.util.List;
>  import java.util.Map;
> -import java.util.Arrays;
>  import java.util.TreeMap;
> -import java.net.URI;
> -import java.net.URISyntaxException;
>  
>  /**
>   * @version $Rev$ $Date$
> @@ -230,6 +233,26 @@
>          for (ServiceRef ref : jndiConsumer.getServiceRef()) {
>              ServiceReferenceInfo info = new ServiceReferenceInfo();
>              info.referenceName = ref.getName();
> +            if (ref.getServiceQname() != null && ref.getServiceQname().length() != 0) {
> +                info.serviceQName = QName.valueOf(ref.getServiceQname());
> +            }
> +            info.wsdlFile = ref.getWsdlFile();
> +            info.jaxrpcMappingFile = ref.getJaxrpcMappingFile();
> +            info.referenceType = ref.getServiceRefType();
> +            info.serviceType = ref.getServiceInterface();
> +            String mappedName = ref.getMappedName();
> +            if (mappedName != null && mappedName.startsWith("wsdlrepo:")) {
> +                info.wsdlRepoUri = mappedName.substring("wsdlrepo:".length());
> +            }
> +            info.handlerChains.addAll(ConfigurationFactory.toHandlerChainInfo(ref.getHandlerChains()));
> +            for (PortComponentRef portComponentRef : ref.getPortComponentRef()) {
> +                PortRefInfo portRefInfo = new PortRefInfo();
> +                portRefInfo.serviceEndpointInterface = portComponentRef.getServiceEndpointInterface();
> +                portRefInfo.enableMtom = portComponentRef.isEnableMtom();
> +                portRefInfo.portComponentLink = portComponentRef.getPortComponentLink();
> +                portRefInfo.properties.putAll(portComponentRef.getProperties());
> +                info.portRefs.add(portRefInfo);
> +            }
>              info.location = buildLocationInfo(ref);
>              info.targets.addAll(buildInjectionInfos(ref));
>              infos.add(info);
> 
> 
> 

Re: svn commit: r591858 [2/13] - in /openejb/trunk/openejb3: ./ assembly/openejb-tomcat/ assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-cor...

Posted by Dain Sundstrom <da...@iq80.com>.
Injections and classloader are only used for webservice refs, and  
since G does it's own processing of webservice refs, you can pass in  
null or an empty list for injections.  For the class loader, I'd pass  
in the correct module class loader.

-dain

On Nov 6, 2007, at 1:33 PM, Joe Bohn wrote:

> I just checked in a change that gets things building again. It may  
> be totally incorrect so please make updates or revert as necessary.
>
> http://svn.apache.org/viewvc?view=rev&revision=592559
>
> Thanks,
> Joe
>
>
> David Blevins wrote:
>> On Nov 6, 2007, at 8:14 AM, Joe Bohn wrote:
>>> These changes in JndiEncBuilder require some comparable changes  
>>> in Geronimo's EjbRefBuidler.   I don't really know the details of  
>>> the big change but Geronimo used construct a JndiEncBuilder using  
>>> just these two parameters:
>>>
>>> JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(jndiEncInfo,  
>>> module.getName())
>>>
>>> It seems that the new constructor requires a list of injections  
>>> and a classloader.  I presume something like this would work but  
>>> I'm not sure which classloader we need to pass.  Any pointers?
>>>
>>>            InjectionBuilder injectionBuilder = new  
>>> InjectionBuilder(classloader?);
>>>            List<Injection> injections =  
>>> injectionBuilder.buildInjections(jndiEncInfo);
>>>            JndiEncBuilder jndiEncBuilder = new JndiEncBuilder 
>>> (jndiEncInfo, injections, module.getTargetPath(), classloader?);
>> Still looking through that change myself, so I'm not too sure.
>> Gives me the idea that we should add a little javadoc "@geronimo  
>> EjbRefBuilder" note to the methods we had to expose to the  
>> Geronimo geronimo-openejb-builder module so it's easier to spot.
>> -David


Re: svn commit: r591858 [2/13] - in /openejb/trunk/openejb3: ./ assembly/openejb-tomcat/ assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-cor...

Posted by Joe Bohn <jo...@earthlink.net>.
I just checked in a change that gets things building again. It may be 
totally incorrect so please make updates or revert as necessary.

http://svn.apache.org/viewvc?view=rev&revision=592559

Thanks,
Joe


David Blevins wrote:
> 
> On Nov 6, 2007, at 8:14 AM, Joe Bohn wrote:
> 
>> These changes in JndiEncBuilder require some comparable changes in 
>> Geronimo's EjbRefBuidler.   I don't really know the details of the big 
>> change but Geronimo used construct a JndiEncBuilder using just these 
>> two parameters:
>>
>> JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(jndiEncInfo, 
>> module.getName())
>>
>> It seems that the new constructor requires a list of injections and a 
>> classloader.  I presume something like this would work but I'm not 
>> sure which classloader we need to pass.  Any pointers?
>>
>>            InjectionBuilder injectionBuilder = new 
>> InjectionBuilder(classloader?);
>>            List<Injection> injections = 
>> injectionBuilder.buildInjections(jndiEncInfo);
>>            JndiEncBuilder jndiEncBuilder = new 
>> JndiEncBuilder(jndiEncInfo, injections, module.getTargetPath(), 
>> classloader?);
> 
> Still looking through that change myself, so I'm not too sure.
> 
> Gives me the idea that we should add a little javadoc "@geronimo 
> EjbRefBuilder" note to the methods we had to expose to the Geronimo 
> geronimo-openejb-builder module so it's easier to spot.
> 
> -David
> 
> 

Re: svn commit: r591858 [2/13] - in /openejb/trunk/openejb3: ./ assembly/openejb-tomcat/ assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-cor...

Posted by David Blevins <da...@visi.com>.
On Nov 6, 2007, at 8:14 AM, Joe Bohn wrote:

> These changes in JndiEncBuilder require some comparable changes in  
> Geronimo's EjbRefBuidler.   I don't really know the details of the  
> big change but Geronimo used construct a JndiEncBuilder using just  
> these two parameters:
>
> JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(jndiEncInfo,  
> module.getName())
>
> It seems that the new constructor requires a list of injections and  
> a classloader.  I presume something like this would work but I'm not  
> sure which classloader we need to pass.  Any pointers?
>
>            InjectionBuilder injectionBuilder = new  
> InjectionBuilder(classloader?);
>            List<Injection> injections =  
> injectionBuilder.buildInjections(jndiEncInfo);
>            JndiEncBuilder jndiEncBuilder = new  
> JndiEncBuilder(jndiEncInfo, injections, module.getTargetPath(),  
> classloader?);

Still looking through that change myself, so I'm not too sure.

Gives me the idea that we should add a little javadoc "@geronimo  
EjbRefBuilder" note to the methods we had to expose to the Geronimo  
geronimo-openejb-builder module so it's easier to spot.

-David