Repository: tomee Updated Branches: refs/heads/tomee-1.7.x d82f8386a -> 3a12c9385
Fix copy paste on shutdown port Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3a12c938 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3a12c938 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3a12c938 Branch: refs/heads/tomee-1.7.x Commit: 3a12c9385ccd02b2ccfe6e1cfd4170f89f59bc7e Parents: d82f838 Author: AndyGee <[email protected]> Authored: Mon Nov 16 11:48:13 2015 +0100 Committer: AndyGee <[email protected]> Committed: Mon Nov 16 11:48:13 2015 +0100 ---------------------------------------------------------------------- .../main/resources/openejb-version.properties | 42 +-- .../openejb/maven/plugin/AbstractTomEEMojo.java | 15 +- .../maven/plugin/test/TomEEMavenPluginTest.java | 132 ++++---- .../org/apache/tomee/common/NamingUtil.java | 300 +++++++++---------- .../java/org/apache/tomee/common/WsFactory.java | 262 ++++++++-------- .../src/main/resources/META-INF/NOTICE | 72 ++--- 6 files changed, 420 insertions(+), 403 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/3a12c938/container/openejb-core/src/main/resources/openejb-version.properties ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/resources/openejb-version.properties b/container/openejb-core/src/main/resources/openejb-version.properties index d395844..caf510a 100644 --- a/container/openejb-core/src/main/resources/openejb-version.properties +++ b/container/openejb-core/src/main/resources/openejb-version.properties @@ -1,21 +1,21 @@ -# -# 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. -# -copyright=Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved. -url=http://tomee.apache.org/ -version=${pom.version} -date=@DATE-REPLACED-BY-MAVEN@ -time=@TIME-REPLACED-BY-MAVEN@ +# +# 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. +# +copyright=Copyright 1999-2015 (C) Apache OpenEJB/TomEE Project, All Rights Reserved. +url=http://tomee.apache.org/ +version=${pom.version} +date=@DATE-REPLACED-BY-MAVEN@ +time=@TIME-REPLACED-BY-MAVEN@ http://git-wip-us.apache.org/repos/asf/tomee/blob/3a12c938/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java ---------------------------------------------------------------------- diff --git a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java index 9936bca..2ebfbd9 100644 --- a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java +++ b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java @@ -755,7 +755,7 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo { writer = new FileWriter(serverXml); writer.write(value .replace(parser.http(), Integer.toString(this.getTomeeHttpPortChecked())) - .replace(parser.https(), Integer.toString(tomeeHttpsPort)) + .replace(parser.https(), Integer.toString(this.getTomeeHttpsPortChecked())) .replace(parser.ajp(), Integer.toString(tomeeAjpPort)) .replace(parser.stop(), Integer.toString(this.getTomeeShutdownPortChecked())) .replace(parser.host(), tomeeHost) @@ -859,7 +859,7 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo { getLog().info("Running '" + getClass().getName().replace("TomEEMojo", "").toLowerCase(Locale.ENGLISH) + "'. Configured TomEE in plugin is " + tomeeHost + ":" + this.getTomeeHttpPortChecked() - + " (plugin shutdown port is " + this.getTomeeShutdownPortChecked() + " and https port is " + tomeeHttpsPort + ")"); + + " (plugin shutdown port is " + this.getTomeeShutdownPortChecked() + " and https port is " + this.getTomeeHttpsPortChecked() + ")"); } else { getLog().info("Running '" + getClass().getSimpleName().replace("TomEEMojo", "").toLowerCase(Locale.ENGLISH)); } @@ -919,11 +919,18 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo { return this.tomeeHttpPort; } + private synchronized int getTomeeHttpsPortChecked() { + if (this.tomeeHttpsPort <= 0) { + this.tomeeHttpsPort = NetworkUtil.getNextAvailablePort(); + } + return this.tomeeHttpsPort; + } + private synchronized int getTomeeShutdownPortChecked() { if (this.tomeeShutdownPort <= 0) { - this.tomeeHttpPort = NetworkUtil.getNextAvailablePort(); + this.tomeeShutdownPort = NetworkUtil.getNextAvailablePort(); } - return this.tomeeHttpPort; + return this.tomeeShutdownPort; } private String getNextLine(final Scanner reader) { http://git-wip-us.apache.org/repos/asf/tomee/blob/3a12c938/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java ---------------------------------------------------------------------- diff --git a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java index b8d3b12..2e2584e 100644 --- a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java +++ b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java @@ -1,63 +1,69 @@ -/* - * 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.maven.plugin.test; - -import org.apache.openejb.loader.IO; -import org.apache.openejb.maven.plugin.TomEEMavenPluginRule; -import org.apache.openejb.maven.plugin.Url; -import org.junit.Rule; -import org.junit.Test; - -import java.io.IOException; -import java.net.URI; -import java.net.URL; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; - -public class TomEEMavenPluginTest { - @Rule - public TomEEMavenPluginRule TMPRule = new TomEEMavenPluginRule(); - - @Url - private String url; - - @Test - public void simpleStart() throws Exception { - final String slurp = slurp(URI.create(url + "/docs").toURL(), 5); - assertThat(slurp, containsString("Apache Tomcat")); - } - - private String slurp(final URL url, int attempts) throws IOException { - try { - return IO.slurp(url); - } catch (final IOException e) { - if (attempts < 1) { - throw e; - } else { - try { - Thread.sleep(1000); - return slurp(url, --attempts); - } catch (final InterruptedException ie) { - // - } - } - } - - return ""; - } -} +/* + * 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.maven.plugin.test; + +import org.apache.openejb.loader.IO; +import org.apache.openejb.maven.plugin.TomEEMavenPluginRule; +import org.apache.openejb.maven.plugin.Url; +import org.junit.Rule; +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; + +public class TomEEMavenPluginTest { + + private final Logger logger = Logger.getLogger(TomEEMavenPluginTest.class.getName()); + + @Rule + public TomEEMavenPluginRule TMPRule = new TomEEMavenPluginRule(); + + @Url + private String url; + + @Test + public void simpleStart() throws Exception { + final String slurp = slurp(URI.create(url + "/docs").toURL(), 5); + assertThat(slurp, containsString("Apache Tomcat")); + } + + private String slurp(final URL url, int attempts) throws IOException { + try { + return IO.slurp(url); + } catch (final IOException e) { + if (attempts < 1) { + logger.log(Level.SEVERE, "Failed to connect to: " + url, e); + throw e; + } else { + try { + Thread.sleep(1000); + return slurp(url, --attempts); + } catch (final InterruptedException ie) { + // + } + } + } + + return ""; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/3a12c938/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java b/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java index 1da7d57..0bdceff 100644 --- a/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java +++ b/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java @@ -1,151 +1,149 @@ -/** - * - * 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.tomee.common; - -import org.apache.catalina.core.StandardContext; -import org.apache.naming.EjbRef; - -import javax.naming.RefAddr; -import javax.naming.Reference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - -public class NamingUtil { - public static final String NAME = "name"; - public static final String DEPLOYMENT_ID = "deploymentid"; - public static final String EXTERNAL = "external"; - public static final String LOCAL = "local"; - public static final String LOCALBEAN = "localbean"; - public static final String REMOTE = EjbRef.REMOTE; - public static final String JNDI_NAME = "jndiname"; - public static final String JNDI_PROVIDER_ID = "jndiproviderid"; - public static final String UNIT = "unit"; - public static final String EXTENDED = "extended"; - public static final String PROPERTIES = "properties"; - public static final String RESOURCE_ID = "resourceid"; - public static final String COMPONENT_TYPE = "componenttype"; - public static final String WS_ID = "wsid"; - public static final String WS_CLASS = "wsclass"; - public static final String WS_QNAME = "wsqname"; - public static final String WS_PORT_QNAME = "wsportqname"; - public static final String WSDL_URL = "wsdlurl"; - - private static final AtomicInteger id = new AtomicInteger(31); - private static final Map<String,Object> registry = new ConcurrentHashMap<String, Object>(); - - // these two attributes are used to be able to cleanup quickly the registry (otherwise we need to duplicate a lot of logic) - private static StandardContext currentContext; - private static Map<StandardContext, Collection<String>> ID_BY_CONTEXT = new HashMap<StandardContext, Collection<String>>(); - - public static String getProperty(final Reference ref, final String name) { - final RefAddr addr = ref.get(name); - if (addr == null) { - return null; - } - final Object value = addr.getContent(); - return (String) value; - } - - public static boolean isPropertyTrue(final Reference ref, final String name) { - final RefAddr addr = ref.get(name); - if (addr == null) { - return false; - } - final Object value = addr.getContent(); - return Boolean.parseBoolean(String.valueOf(value)); - } - - public static void setStaticValue(final Resource resource, final Object value) { - setStaticValue(resource, null, value); - } - - public static void setStaticValue(final Resource resource, final String name, final Object value) { - final String token = String.valueOf(id.incrementAndGet()); - registry.put(token, value); - resource.setProperty("static-token" + (name != null ? "-" + name : ""), token); - if (currentContext != null) { - Collection<String> ids = ID_BY_CONTEXT.get(currentContext); - if (ids == null) { - ids = new ArrayList<String>(); - ID_BY_CONTEXT.put(currentContext, ids); - } - ids.add(token); - } - } - - @SuppressWarnings({"unchecked"}) - public static<T> T getStaticValue(final Reference ref) { - return (T) getStaticValue(ref, null); - } - - @SuppressWarnings({"unchecked"}) - public static <T> T getStaticValue(final Reference ref, String name) { - name = name != null ? "-" + name : ""; - final String token = getProperty(ref, "static-token" + name); - if (token == null) { - return null; - } - final T object = (T) registry.get(token); - return object; - } - - public static Class<?> loadClass(final String className) { - if (className == null) { - return null; - } - try { - final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - if (classLoader != null) { - try { - final Class clazz = classLoader.loadClass(className); - return clazz; - } catch(final ClassNotFoundException e) { - // no-op - } - } - return Class.forName(className); - } catch (final ClassNotFoundException e) { - return null; - } - } - - /** - * This interface exists because the class org.apache.catalina.deploy.ContextResource - * is not available in the common classloader in tomcat 55 - */ - public interface Resource { - void setProperty(String name, Object value); - } - - public static void setCurrentContext(final StandardContext currentContext) { - NamingUtil.currentContext = currentContext; - } - - public static void cleanUpContextResource(final StandardContext context) { - final Collection<String> keys = ID_BY_CONTEXT.remove(context); - if (keys != null) { - for (final String k : keys) { - registry.remove(k); - } - } - } -} +/** + * + * 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.tomee.common; + +import org.apache.catalina.core.StandardContext; +import org.apache.naming.EjbRef; + +import javax.naming.RefAddr; +import javax.naming.Reference; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; + +public class NamingUtil { + public static final String NAME = "name"; + public static final String DEPLOYMENT_ID = "deploymentid"; + public static final String EXTERNAL = "external"; + public static final String LOCAL = "local"; + public static final String LOCALBEAN = "localbean"; + public static final String REMOTE = EjbRef.REMOTE; + public static final String JNDI_NAME = "jndiname"; + public static final String JNDI_PROVIDER_ID = "jndiproviderid"; + public static final String UNIT = "unit"; + public static final String EXTENDED = "extended"; + public static final String PROPERTIES = "properties"; + public static final String RESOURCE_ID = "resourceid"; + public static final String COMPONENT_TYPE = "componenttype"; + public static final String WS_ID = "wsid"; + public static final String WS_CLASS = "wsclass"; + public static final String WS_QNAME = "wsqname"; + public static final String WS_PORT_QNAME = "wsportqname"; + public static final String WSDL_URL = "wsdlurl"; + + private static final AtomicInteger id = new AtomicInteger(31); + private static final Map<String,Object> registry = new ConcurrentHashMap<String, Object>(); + + // these two attributes are used to be able to cleanup quickly the registry (otherwise we need to duplicate a lot of logic) + private static StandardContext currentContext; + private static final Map<StandardContext, Collection<String>> ID_BY_CONTEXT = new HashMap<StandardContext, Collection<String>>(); + + public static String getProperty(final Reference ref, final String name) { + final RefAddr addr = ref.get(name); + if (addr == null) { + return null; + } + final Object value = addr.getContent(); + return (String) value; + } + + public static boolean isPropertyTrue(final Reference ref, final String name) { + final RefAddr addr = ref.get(name); + if (addr == null) { + return false; + } + final Object value = addr.getContent(); + return Boolean.parseBoolean(String.valueOf(value)); + } + + public static void setStaticValue(final Resource resource, final Object value) { + setStaticValue(resource, null, value); + } + + public static void setStaticValue(final Resource resource, final String name, final Object value) { + final String token = String.valueOf(id.incrementAndGet()); + registry.put(token, value); + resource.setProperty("static-token" + (name != null ? "-" + name : ""), token); + if (currentContext != null) { + Collection<String> ids = ID_BY_CONTEXT.get(currentContext); + if (ids == null) { + ids = new ArrayList<String>(); + ID_BY_CONTEXT.put(currentContext, ids); + } + ids.add(token); + } + } + + @SuppressWarnings({"unchecked"}) + public static<T> T getStaticValue(final Reference ref) { + return (T) getStaticValue(ref, null); + } + + @SuppressWarnings({"unchecked"}) + public static <T> T getStaticValue(final Reference ref, String name) { + name = name != null ? "-" + name : ""; + final String token = getProperty(ref, "static-token" + name); + if (token == null) { + return null; + } + return (T) registry.get(token); + } + + public static Class<?> loadClass(final String className) { + if (className == null) { + return null; + } + try { + final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader != null) { + try { + return classLoader.loadClass(className); + } catch(final ClassNotFoundException e) { + // no-op + } + } + return Class.forName(className); + } catch (final ClassNotFoundException e) { + return null; + } + } + + /** + * This interface exists because the class org.apache.catalina.deploy.ContextResource + * is not available in the common classloader in tomcat 55 + */ + public interface Resource { + void setProperty(String name, Object value); + } + + public static void setCurrentContext(final StandardContext currentContext) { + NamingUtil.currentContext = currentContext; + } + + public static void cleanUpContextResource(final StandardContext context) { + final Collection<String> keys = ID_BY_CONTEXT.remove(context); + if (keys != null) { + for (final String k : keys) { + registry.remove(k); + } + } + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/3a12c938/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java b/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java index 5558161..1de7a83 100644 --- a/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java +++ b/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java @@ -1,128 +1,134 @@ -/** - * - * 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.tomee.common; - -import org.apache.naming.ResourceRef; -import org.apache.openejb.Injection; -import org.apache.openejb.core.ivm.naming.JaxWsServiceReference; -import org.apache.openejb.core.webservices.HandlerChainData; -import org.apache.openejb.core.webservices.PortRefData; - -import javax.naming.Context; -import javax.naming.Name; -import javax.naming.NamingException; -import javax.naming.Reference; -import javax.xml.namespace.QName; -import javax.xml.ws.Service; -import java.net.URL; -import java.util.Collection; -import java.util.Collections; -import java.util.Hashtable; -import java.util.List; -import java.util.Properties; - -public class WsFactory extends AbstractObjectFactory { - public Object getObjectInstance(final Object object, final Name name, final Context context, final Hashtable environment) throws Exception { - // ignore non resource-refs - if (!(object instanceof ResourceRef)) { - return null; - } - - final Reference ref = (Reference) object; - - final Object value; - if (NamingUtil.getProperty(ref, NamingUtil.JNDI_NAME) != null) { - // lookup the value in JNDI - value = super.getObjectInstance(object, name, context, environment); - } else { - // load service class which is used to construct the port - final String serviceClassName = NamingUtil.getProperty(ref, NamingUtil.WS_CLASS); - Class<? extends Service> serviceClass = Service.class; - if (serviceClassName != null) { - serviceClass = NamingUtil.loadClass(serviceClassName).asSubclass(Service.class); - if (serviceClass == null) { - throw new NamingException("Could not load service type class "+ serviceClassName); - } - } - - // load the reference class which is the ultimate type of the port - final Class<?> referenceClass = NamingUtil.loadClass(ref.getClassName()); - - // 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); - } - - // PORT ID - final String serviceId = NamingUtil.getProperty(ref, NamingUtil.WS_ID); - - // Service QName - QName serviceQName = null; - if (NamingUtil.getProperty(ref, NamingUtil.WS_QNAME) != null) { - serviceQName = QName.valueOf(NamingUtil.getProperty(ref, NamingUtil.WS_QNAME)); - } - - // WSDL URL - URL wsdlUrl = null; - if (NamingUtil.getProperty(ref, NamingUtil.WSDL_URL) != null) { - wsdlUrl = new URL(NamingUtil.getProperty(ref, NamingUtil.WSDL_URL)); - } - - // Port QName - QName portQName = null; - if (NamingUtil.getProperty(ref, NamingUtil.WS_PORT_QNAME) != null) { - portQName = QName.valueOf(NamingUtil.getProperty(ref, NamingUtil.WS_PORT_QNAME)); - } - - // port refs - List<PortRefData> portRefs = NamingUtil.getStaticValue(ref, "port-refs"); - if (portRefs == null) { - portRefs = Collections.emptyList(); - } - - // HandlerChain - List<HandlerChainData> handlerChains = NamingUtil.getStaticValue(ref, "handler-chains"); - if (handlerChains == null) { - handlerChains = Collections.emptyList(); - } - Collection<Injection> injections = NamingUtil.getStaticValue(ref, "injections"); - if (injections == null) { - injections = Collections.emptyList(); - } - - final Properties properties = new Properties(); - properties.putAll(environment); - final JaxWsServiceReference serviceReference = new JaxWsServiceReference(serviceId, - serviceQName, - serviceClass, portQName, - referenceClass, - wsdlUrl, - portRefs, - handlerChains, - injections, - properties); - value = serviceReference.getObject(); - } - - return value; - } - - protected String buildJndiName(final Reference reference) throws NamingException { - throw new UnsupportedOperationException(); - } -} +/** + * + * 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.tomee.common; + +import org.apache.naming.ResourceRef; +import org.apache.openejb.Injection; +import org.apache.openejb.core.ivm.naming.JaxWsServiceReference; +import org.apache.openejb.core.webservices.HandlerChainData; +import org.apache.openejb.core.webservices.PortRefData; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingException; +import javax.naming.Reference; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import java.net.URL; +import java.util.Collection; +import java.util.Collections; +import java.util.Hashtable; +import java.util.List; +import java.util.Properties; + +public class WsFactory extends AbstractObjectFactory { + public Object getObjectInstance(final Object object, final Name name, final Context context, final Hashtable environment) throws Exception { + // ignore non resource-refs + if (!(object instanceof ResourceRef)) { + return null; + } + + final Reference ref = (Reference) object; + + final Object value; + if (NamingUtil.getProperty(ref, NamingUtil.JNDI_NAME) != null) { + // lookup the value in JNDI + value = super.getObjectInstance(object, name, context, environment); + } else { + // load service class which is used to construct the port + final String serviceClassName = NamingUtil.getProperty(ref, NamingUtil.WS_CLASS); + Class<? extends Service> serviceClass = Service.class; + if (serviceClassName != null) { + final Class<?> loadClass = NamingUtil.loadClass(serviceClassName); + + if (loadClass == null) { + throw new NamingException("Could not load service type class "+ serviceClassName); + } + + serviceClass = loadClass.asSubclass(Service.class); + } + + // load the reference class which is the ultimate type of the port + final Class<?> referenceClass = NamingUtil.loadClass(ref.getClassName()); + + // 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); + } + + // PORT ID + final String serviceId = NamingUtil.getProperty(ref, NamingUtil.WS_ID); + + // Service QName + QName serviceQName = null; + String property = NamingUtil.getProperty(ref, NamingUtil.WS_QNAME); + if (property != null) { + serviceQName = QName.valueOf(property); + } + + // WSDL URL + URL wsdlUrl = null; + property = NamingUtil.getProperty(ref, NamingUtil.WSDL_URL); + if (property != null) { + wsdlUrl = new URL(property); + } + + // Port QName + QName portQName = null; + property = NamingUtil.getProperty(ref, NamingUtil.WS_PORT_QNAME); + if (property != null) { + portQName = QName.valueOf(property); + } + + // port refs + List<PortRefData> portRefs = NamingUtil.getStaticValue(ref, "port-refs"); + if (portRefs == null) { + portRefs = Collections.emptyList(); + } + + // HandlerChain + List<HandlerChainData> handlerChains = NamingUtil.getStaticValue(ref, "handler-chains"); + if (handlerChains == null) { + handlerChains = Collections.emptyList(); + } + Collection<Injection> injections = NamingUtil.getStaticValue(ref, "injections"); + if (injections == null) { + injections = Collections.emptyList(); + } + + final Properties properties = new Properties(); + properties.putAll(environment); + final JaxWsServiceReference serviceReference = new JaxWsServiceReference(serviceId, + serviceQName, + serviceClass, portQName, + referenceClass, + wsdlUrl, + portRefs, + handlerChains, + injections, + properties); + value = serviceReference.getObject(); + } + + return value; + } + + protected String buildJndiName(final Reference reference) throws NamingException { + throw new UnsupportedOperationException(); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/3a12c938/tomee/tomee-webaccess/src/main/resources/META-INF/NOTICE ---------------------------------------------------------------------- diff --git a/tomee/tomee-webaccess/src/main/resources/META-INF/NOTICE b/tomee/tomee-webaccess/src/main/resources/META-INF/NOTICE index 251295a..5864485 100644 --- a/tomee/tomee-webaccess/src/main/resources/META-INF/NOTICE +++ b/tomee/tomee-webaccess/src/main/resources/META-INF/NOTICE @@ -1,36 +1,36 @@ -Apache OpenEJB, Apache TomEE -Copyright 1999-2015 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - -This product includes schema files developed for the Glassfish Java EE -reference implementation (http://java.sun.com/xml/ns/j2ee/). -Apache OpenEJB elects to include this software in this distribution -under the CDDL license. You can obtain a copy of the License at: - https://glassfish.dev.java.net/public/CDDL+GPL.html - -Apache Commons Codec -Copyright 2002-2013 The Apache Software Foundation - -src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java -contains test data from http://aspell.net/test/orig/batch0.tab. -Copyright (C) 2002 Kevin Atkinson ([email protected]) - -"Twitter Bootstrap" is licensed under Apache License v2.0. -You can obtain a copy of the License at: https://github.com/twitter/bootstrap/wiki/License - -"less.js " is licensed under the Apache License. -You can obtain a copy of the License at: https://github.com/cloudhead/less.js/blob/master/LICENSE - -"jquery" is licensed under the MIT License. -You can obtain a copy of the License at: https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt - -"handlebars.js" is licensed under the MIT License. -You can obtain a copy of the License at: https://github.com/wycats/handlebars.js/blob/master/LICENSE - -"codemirror" is licensed under the MIT License. -You can obtain a copy of the License at: http://codemirror.net/LICENSE - -"require.js" is licensed under the MIT License. -You can obtain a copy of the License at: https://github.com/jrburke/requirejs/blob/master/LICENSE +Apache OpenEJB, Apache TomEE +Copyright 1999-2015 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +This product includes schema files developed for the Glassfish Java EE +reference implementation (http://java.sun.com/xml/ns/j2ee/). +Apache OpenEJB elects to include this software in this distribution +under the CDDL license. You can obtain a copy of the License at: + https://glassfish.dev.java.net/public/CDDL+GPL.html + +Apache Commons Codec +Copyright 2002-2015 The Apache Software Foundation + +src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java +contains test data from http://aspell.net/test/orig/batch0.tab. +Copyright (C) 2002 Kevin Atkinson ([email protected]) + +"Twitter Bootstrap" is licensed under Apache License v2.0. +You can obtain a copy of the License at: https://github.com/twitter/bootstrap/wiki/License + +"less.js " is licensed under the Apache License. +You can obtain a copy of the License at: https://github.com/cloudhead/less.js/blob/master/LICENSE + +"jquery" is licensed under the MIT License. +You can obtain a copy of the License at: https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt + +"handlebars.js" is licensed under the MIT License. +You can obtain a copy of the License at: https://github.com/wycats/handlebars.js/blob/master/LICENSE + +"codemirror" is licensed under the MIT License. +You can obtain a copy of the License at: http://codemirror.net/LICENSE + +"require.js" is licensed under the MIT License. +You can obtain a copy of the License at: https://github.com/jrburke/requirejs/blob/master/LICENSE
