You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/11/11 22:00:25 UTC
svn commit: r1408118 - in /openejb/trunk/openejb:
container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/
container/openejb-core/src/main/java/org/apache/openejb/core/
container/openejb-core/src/main/java/org/apache/openejb/web/ serv...
Author: rmannibucau
Date: Sun Nov 11 21:00:23 2012
New Revision: 1408118
URL: http://svn.apache.org/viewvc?rev=1408118&view=rev
Log:
OPENEJB-1931 servlet deployment in embedded mode
Added:
openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java
openejb/trunk/openejb/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServletRegistrationTest.java
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java
openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1408118&r1=1408117&r2=1408118&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java Sun Nov 11 21:00:23 2012
@@ -908,7 +908,7 @@ public class Assembler extends Assembler
for (Map.Entry<String, Object> value : appContext.getBindings().entrySet()) {
String path = value.getKey();
// keep only global bindings
- if (path.startsWith("module/") || path.startsWith("app/") || path.equalsIgnoreCase("global/dummy")) {
+ if (path.startsWith("module/") || path.startsWith("app/") || path.startsWith("comp/") || path.equalsIgnoreCase("global/dummy")) {
continue;
}
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java?rev=1408118&r1=1408117&r2=1408118&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java Sun Nov 11 21:00:23 2012
@@ -43,6 +43,7 @@ public class WebContext {
private Map<Object, CreationalContext<?>> creatonalContexts = new ConcurrentHashMap<Object, CreationalContext<?>>();
private WebBeansContext webbeansContext;
private String contextRoot;
+ private Context initialContext;
public Context getInitialContext() {
if (initialContext != null) return initialContext;
@@ -54,7 +55,9 @@ public class WebContext {
return initialContext;
}
- private Context initialContext;
+ public void setInitialContext(final Context initialContext) {
+ this.initialContext = initialContext;
+ }
public WebContext(AppContext appContext) {
this.appContext = appContext;
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java?rev=1408118&r1=1408117&r2=1408118&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java Sun Nov 11 21:00:23 2012
@@ -20,8 +20,10 @@ import org.apache.openejb.AppContext;
import org.apache.openejb.Injection;
import org.apache.openejb.OpenEJBRuntimeException;
import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.ClassListInfo;
import org.apache.openejb.assembler.classic.InjectionBuilder;
import org.apache.openejb.assembler.classic.JndiEncBuilder;
+import org.apache.openejb.assembler.classic.ServletInfo;
import org.apache.openejb.assembler.classic.WebAppBuilder;
import org.apache.openejb.assembler.classic.WebAppInfo;
import org.apache.openejb.core.CoreContainerSystem;
@@ -29,13 +31,42 @@ import org.apache.openejb.core.WebContex
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.spi.ContainerSystem;
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.servlet.annotation.WebServlet;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
import java.util.Set;
public class LightweightWebAppBuilder implements WebAppBuilder {
+ private static final Method addServletMethod;
+ private static final Method removeServletMethod;
+
+ static {
+ try {
+ final Class<?> utilClass = LightweightWebAppBuilder.class.getClassLoader().loadClass("org.apache.openejb.server.httpd.util.HttpUtil");
+ addServletMethod = utilClass.getMethod("addServlet", String.class, WebContext.class, String.class);
+ removeServletMethod = utilClass.getMethod("removeServlet", String.class, WebContext.class);
+ } catch (Exception e) {
+ throw new OpenEJBRuntimeException(e);
+ }
+ }
+
+ private final Map<WebAppInfo, DeployedServlet> deploymentInfo = new HashMap<WebAppInfo, DeployedServlet>();
+
@Override
public void deployWebApps(final AppInfo appInfo, final ClassLoader classLoader) throws Exception {
final CoreContainerSystem cs = (CoreContainerSystem) SystemInstance.get().getComponent(ContainerSystem.class);
@@ -54,24 +85,237 @@ public class LightweightWebAppBuilder im
final WebContext webContext = new WebContext(appContext);
webContext.setBindings(bindings);
+ webContext.getBindings().putAll(new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader).buildBindings(JndiEncBuilder.JndiScope.comp));
webContext.setJndiEnc(WebInitialContext.create(bindings, appContext.getGlobalJndiContext()));
webContext.setClassLoader(classLoader);
webContext.setId(webAppInfo.moduleId);
webContext.setContextRoot(webAppInfo.contextRoot);
webContext.getInjections().addAll(injections);
+ webContext.setInitialContext(new EmbeddedInitialContext(webContext.getJndiEnc(), webContext.getBindings()));
appContext.getWebContexts().add(webContext);
cs.addWebContext(webContext);
+
+ final DeployedServlet deployedServlet = new DeployedServlet();
+ deployedServlet.webContext = webContext;
+
+ // register servlets
+ for (ServletInfo info : webAppInfo.servlets) {
+ for (String mapping : info.mappings) {
+ try {
+ addServletMethod.invoke(null, info.servletClass, webContext, mapping);
+ deployedServlet.mappings.add(mapping);
+ } catch (Exception e) {
+ // no-op
+ }
+ }
+ }
+ for (ClassListInfo info : webAppInfo.webAnnotatedClasses) {
+ final String url = info.name;
+ for (String servletPath : info.list) {
+ String classname = servletPath.substring(url.length()).replace(File.separatorChar, '/').replace('/', '.');
+ classname = classname.substring(0, classname.length() - ".class".length());
+
+ final Class<?> clazz = webContext.getClassLoader().loadClass(classname);
+ final WebServlet annotation = clazz.getAnnotation(WebServlet.class);
+ if (annotation != null) {
+ for (String mapping: annotation.urlPatterns()) {
+ try {
+ addServletMethod.invoke(null, classname, webContext, mapping);
+ deployedServlet.mappings.add(mapping);
+ } catch (Exception e) {
+ // no-op
+ }
+ }
+ }
+ }
+ }
+
+ deploymentInfo.put(webAppInfo, deployedServlet);
}
}
@Override
public void undeployWebApps(final AppInfo appInfo) throws Exception {
- // no-op
+ for (WebAppInfo webAppInfo : appInfo.webApps) {
+ final DeployedServlet context = deploymentInfo.remove(webAppInfo);
+
+ for (String mapping : context.mappings) {
+ try {
+ removeServletMethod.invoke(null, mapping, context.webContext);
+ } catch (Exception e) {
+ // no-op
+ }
+ }
+ }
}
@Override
public Map<ClassLoader, Map<String, Set<String>>> getJsfClasses() {
return Collections.emptyMap(); // while we don't manage servlet in embedded mode we don't need it
}
+
+ private static class DeployedServlet {
+ public List<String> mappings = new ArrayList<String>();
+ public WebContext webContext;
+ }
+
+ private static class EmbeddedInitialContext implements Context {
+ private final Context delegate;
+ private final Map<String, Object> bindings;
+
+ public EmbeddedInitialContext(final Context jndiEnc, final Map<String, Object> bindings) {
+ this.delegate = jndiEnc;
+ this.bindings = bindings;
+ }
+
+ @Override
+ public Object lookup(final Name name) throws NamingException {
+ return lookup(name.toString());
+ }
+
+ @Override
+ public Object lookup(final String name) throws NamingException {
+ try {
+ return delegate.lookup(name);
+ } catch (NameNotFoundException nnfe) {
+ return bindings.get(name);
+ }
+ }
+
+ @Override
+ public void bind(final Name name, final Object obj) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public void bind(final String name, final Object obj) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public void rebind(final Name name, final Object obj) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public void rebind(final String name, final Object obj) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public void unbind(final Name name) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public void unbind(final String name) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public void rename(final Name oldName, final Name newName) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public void rename(final String oldName, final String newName) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public NamingEnumeration<NameClassPair> list(final String name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public NamingEnumeration<Binding> listBindings(final String name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public void destroySubcontext(final Name name) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public void destroySubcontext(final String name) throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public Context createSubcontext(final Name name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Context createSubcontext(final String name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object lookupLink(final Name name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object lookupLink(final String name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public NameParser getNameParser(final Name name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public NameParser getNameParser(final String name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Name composeName(final Name name, final Name prefix) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public String composeName(final String name, final String prefix) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object addToEnvironment(final String propName, final Object propVal) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object removeFromEnvironment(final String propName) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Hashtable<?, ?> getEnvironment() throws NamingException {
+ return null;
+ }
+
+ @Override
+ public void close() throws NamingException {
+ // no-op
+ }
+
+ @Override
+ public String getNameInNamespace() throws NamingException {
+ return null;
+ }
+ }
}
Modified: openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java?rev=1408118&r1=1408117&r2=1408118&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java (original)
+++ openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java Sun Nov 11 21:00:23 2012
@@ -38,9 +38,8 @@ public class HttpListenerRegistry implem
String path = request.getURI().getPath();
for (Map.Entry<String, HttpListener> entry : listeners.entrySet()) {
String pattern = entry.getKey();
- HttpListener listener = entry.getValue();
if (path.matches(pattern)) {
- listener.onMessage(request, response);
+ entry.getValue().onMessage(request, response);
break;
}
}
Added: openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java?rev=1408118&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java (added)
+++ openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServletListener.java Sun Nov 11 21:00:23 2012
@@ -0,0 +1,36 @@
+/*
+ * 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.server.httpd;
+
+import javax.servlet.Servlet;
+
+public class ServletListener implements HttpListener {
+ private final Servlet delegate;
+
+ public ServletListener(final Servlet instance) {
+ delegate = instance;
+ }
+
+ @Override
+ public void onMessage(final HttpRequest request, final HttpResponse response) throws Exception {
+ delegate.service(request, response);
+ }
+
+ public Servlet getDelegate() {
+ return delegate;
+ }
+}
Modified: openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java?rev=1408118&r1=1408117&r2=1408118&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java (original)
+++ openejb/trunk/openejb/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java Sun Nov 11 21:00:23 2012
@@ -16,6 +16,13 @@
*/
package org.apache.openejb.server.httpd.util;
+import org.apache.openejb.OpenEJBRuntimeException;
+import org.apache.openejb.core.WebContext;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.server.httpd.HttpListenerRegistry;
+import org.apache.openejb.server.httpd.ServletListener;
+
+import javax.servlet.Servlet;
import java.util.List;
public final class HttpUtil {
@@ -44,4 +51,50 @@ public final class HttpUtil {
String address = addresses.iterator().next();
return address;
}
+
+ public static boolean addServlet(final String classname, final WebContext wc, final String mapping) {
+ final HttpListenerRegistry registry = SystemInstance.get().getComponent(HttpListenerRegistry.class);
+ if (registry == null || mapping == null) {
+ return false;
+ }
+
+ final ServletListener listener;
+ try {
+ listener = new ServletListener((Servlet) wc.newInstance(wc.getClassLoader().loadClass(classname)));
+ } catch (Exception e) {
+ throw new OpenEJBRuntimeException(e);
+ }
+ registry.addHttpListener(listener, pattern(wc.getContextRoot(), mapping));
+ return true;
+ }
+
+ public static void removeServlet(final String mapping, final WebContext wc) {
+ final HttpListenerRegistry registry = SystemInstance.get().getComponent(HttpListenerRegistry.class);
+ if (registry == null || mapping == null) {
+ return;
+ }
+
+ wc.destroy(((ServletListener) registry.removeHttpListener(pattern(wc.getContextRoot(), mapping))).getDelegate());
+ }
+
+ private static String pattern(final String contextRoot, final String mapping) {
+ String path = "";
+ if (contextRoot != null) {
+ path = contextRoot;
+ }
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!mapping.startsWith("/") && !path.endsWith("/")) {
+ path += '/';
+ }
+ path += mapping;
+
+ if (path.endsWith("*")) {
+ path = path.substring(0, path.length()) + ".*";
+ }
+ return path;
+ }
}
Added: openejb/trunk/openejb/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServletRegistrationTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServletRegistrationTest.java?rev=1408118&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServletRegistrationTest.java (added)
+++ openejb/trunk/openejb/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServletRegistrationTest.java Sun Nov 11 21:00:23 2012
@@ -0,0 +1,109 @@
+/*
+ * 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.server.httpd;
+
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Classes;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.apache.openejb.loader.IO;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.EJB;
+import javax.ejb.Singleton;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices({ "httpejbd" })
+@RunWith(ApplicationComposer.class)
+public class ServletRegistrationTest {
+ @Module
+ @Classes({ TestServlet.class, TestServlet2.class, TestServlet3.class, TestServlet4.class, SomeEjb.class })
+ public WebApp app() {
+ return new WebApp()
+ .contextRoot("servlet")
+ .addServlet("test", TestServlet.class.getName(), "/touch");
+ }
+
+ @Test
+ public void touch() throws IOException {
+ assertEquals("touched", IO.slurp(new URL("http://localhost:4204/servlet/touch")));
+ }
+
+ @Test
+ public void discover() throws IOException {
+ assertEquals("discovered", IO.slurp(new URL("http://localhost:4204/servlet/discover")));
+ }
+
+ @Test
+ public void wildcard() throws IOException {
+ assertEquals("wildcard", IO.slurp(new URL("http://localhost:4204/servlet/bar/openejb")));
+ }
+
+ @Test
+ public void injections() throws IOException {
+ assertEquals("true", IO.slurp(new URL("http://localhost:4204/servlet/injection")));
+ }
+
+ private static class TestServlet extends HttpServlet {
+ @Override
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ resp.getWriter().write("touched");
+ }
+ }
+
+ @WebServlet(urlPatterns = "/discover")
+ private static class TestServlet2 extends HttpServlet {
+ @Override
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ resp.getWriter().write("discovered");
+ }
+ }
+
+ @WebServlet(urlPatterns = "/bar/*")
+ private static class TestServlet3 extends HttpServlet {
+ @Override
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ resp.getWriter().write("wildcard");
+ }
+ }
+
+ @WebServlet(urlPatterns = "/injection")
+ private static class TestServlet4 extends HttpServlet {
+ @EJB
+ private SomeEjb ejb;
+
+ @Override
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+ resp.getWriter().write(Boolean.toString(ejb != null));
+ }
+ }
+
+ @Singleton
+ public static class SomeEjb {
+
+ }
+}
Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java?rev=1408118&r1=1408117&r2=1408118&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java (original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/FilteredServiceManager.java Sun Nov 11 21:00:23 2012
@@ -27,7 +27,7 @@ import java.util.Set;
*/
public class FilteredServiceManager extends SimpleServiceManager {
- private Collection<String> services;
+ private final Collection<String> services;
public FilteredServiceManager (String[] services) {
setServiceManager(this);
@@ -36,19 +36,19 @@ public class FilteredServiceManager exte
}
private Collection<String> convertServices(String[] services) {
- Set<String> realServices = new HashSet<String>();
- Collection<String> rsAliases = Arrays.asList("rest", "jaxrs", "jax-rs", "cxf-rs");
- Collection<String> wsAliases = Arrays.asList("jaxws", "jax-ws", "cxf");
+ final Set<String> realServices = new HashSet<String>();
+ final Collection<String> rsAliases = Arrays.asList("rest", "jaxrs", "jax-rs", "cxf-rs");
+ final Collection<String> wsAliases = Arrays.asList("jaxws", "jax-ws", "cxf");
for (String service : services) {
if (rsAliases.contains(service)) {
realServices.addAll(Arrays.asList("cxf-rs", "httpejbd"));
- }
- if (wsAliases.contains(service)) {
+ } else if (wsAliases.contains(service)) {
realServices.addAll(Arrays.asList("cxf", "httpejbd"));
- }
- if ("ejbd".equals(service)) {
+ } else if ("ejbd".equals(service)) {
realServices.add("httpejbd");
+ } else {
+ realServices.add(service);
}
}
return realServices;