[jboss-svn-commits] JBL Code SVN: r28486 - in labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss: internal/soa/esb/listeners/war and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 27 05:20:23 EDT 2009
Author: tfennelly
Date: 2009-07-27 05:20:23 -0400 (Mon, 27 Jul 2009)
New Revision: 28486
Added:
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/HttpGatewayDeploymentFactory.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/Servlet.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebDeploymentArchive.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebGatewayDeploymentFactory.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebModel.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/web.xml.ftl
Removed:
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/BusDeploymentFactory.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayDeploymentFactory.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/web.xml.ftl
Modified:
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/LifecycleUtil.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers120/HttpListenerMapper.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayServlet.java
Log:
added war model and updated the deployer to use it
Copied: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/HttpGatewayDeploymentFactory.java (from rev 28334, labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayDeploymentFactory.java)
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/HttpGatewayDeploymentFactory.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/HttpGatewayDeploymentFactory.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.listeners.war;
+
+import org.jboss.internal.soa.esb.listeners.war.Servlet;
+import org.jboss.internal.soa.esb.listeners.war.WebDeploymentArchive;
+import org.jboss.soa.esb.listeners.config.DeploymentResourceLocator;
+import org.jboss.soa.esb.listeners.gateway.HttpGatewayServlet;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.apache.log4j.Logger;
+
+/**
+ * Http Gateway deployment factory.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class HttpGatewayDeploymentFactory implements WebGatewayDeploymentFactory {
+
+ private static Logger logger = Logger.getLogger(HttpGatewayDeploymentFactory.class);
+
+ private String busName;
+
+ public void setBusName(String busName) {
+ AssertArgument.isNotNullAndNotEmpty(busName, "busName");
+ this.busName = busName;
+ }
+
+ public void setDeploymentResourceLocator(DeploymentResourceLocator resourceLocator) {
+ // Not relevant to this factory!
+ }
+
+ public void updateDeployment(ConfigTree webEndpointConfig, WebDeploymentArchive webDeployment) throws ConfigurationException {
+ String servletName = webEndpointConfig.getRequiredAttribute("name");
+ Servlet servlet = new Servlet(servletName, HttpGatewayServlet.class);
+
+ // Set the endpoint urlPattern so as to map requests from that namespace into
+ // this servlet instance...
+ String urlPattern = webEndpointConfig.getAttribute("urlPattern", "");
+ if(urlPattern.startsWith("/")) {
+ servlet.getUrlMappings().add("/" + busName + urlPattern);
+ } else {
+ servlet.getUrlMappings().add("/" + busName + "/" + urlPattern);
+ }
+
+ // Map all config tree attributes as servlet parameters...
+ servlet.getParams().addAll(webEndpointConfig.attributesAsList());
+
+ // Add the servlet definition to the model...
+ webDeployment.getWebModel().getServlets().add(servlet);
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/HttpGatewayDeploymentFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/Servlet.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/Servlet.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/Servlet.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.listeners.war;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+
+import javax.servlet.http.HttpServlet;
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Servlet configuration model.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class Servlet {
+
+ private String name;
+ private Class<? extends HttpServlet> runtimeClass;
+ private List<KeyValuePair> params = new ArrayList<KeyValuePair>();
+ private List<String> urlMappings = new ArrayList<String>();
+
+ public Servlet(String name, Class<? extends HttpServlet> runtimeClass) {
+ AssertArgument.isNotNullAndNotEmpty(name, "name");
+ AssertArgument.isNotNull(runtimeClass, "runtimeClass");
+ this.name = name;
+ this.runtimeClass = runtimeClass;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<? extends HttpServlet> getRuntimeClass() {
+ return runtimeClass;
+ }
+
+ public List<KeyValuePair> getParams() {
+ return params;
+ }
+
+ public List<String> getUrlMappings() {
+ return urlMappings;
+ }
+}
Added: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebDeploymentArchive.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebDeploymentArchive.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebDeploymentArchive.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.listeners.war;
+
+import org.jboss.soa.esb.util.DeploymentArchive;
+import org.jboss.soa.esb.util.FreeMarkerTemplate;
+import org.jboss.soa.esb.ConfigurationException;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Web deployment archive.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WebDeploymentArchive extends DeploymentArchive {
+
+ private WebModel webModel = new WebModel();
+ private boolean archiveFinalized = false;
+
+ /**
+ * Public constructor.
+ *
+ * @param archiveName The archive name of the deployment.
+ */
+ public WebDeploymentArchive(String archiveName) {
+ super(archiveName);
+ }
+
+ public WebModel getWebModel() {
+ assertNotFinalized();
+ return webModel;
+ }
+
+ public void finalizeArchive() throws ConfigurationException {
+ try {
+ // Add the web.xml...
+ addWebDescriptor();
+
+ // TODO: Add jboss-web.xml
+ } finally {
+ // Mark as finalized...
+ archiveFinalized = true;
+ }
+ }
+
+ private void addWebDescriptor() throws ConfigurationException {
+ FreeMarkerTemplate template = new FreeMarkerTemplate("web.xml.ftl", WebDeploymentArchive.class);
+ Map contextObj = new HashMap();
+
+ contextObj.put("webModel", webModel);
+
+ try {
+ addEntry("WEB-INF/web.xml", new ByteArrayInputStream(template.apply(contextObj).getBytes("UTF-8")));
+ } catch (Exception e) {
+ throw new ConfigurationException("Error adding web.xml to web deployment.", e);
+ }
+ }
+
+ public void addEntry(String path, InputStream data) {
+ assertNotFinalized();
+ super.addEntry(path, data);
+ }
+
+ public void addEntry(String path) {
+ super.addEntry(path);
+ }
+
+ public void addEntry(String path, String resource) throws IOException {
+ super.addEntry(path, resource);
+ }
+
+ public void addEntry(Class clazz) throws IOException {
+ super.addEntry(clazz);
+ }
+
+ private void assertNotFinalized() {
+ if(archiveFinalized) {
+ throw new IllegalStateException("Cannot update archive after it has been finalized!");
+ }
+ }
+}
Copied: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebGatewayDeploymentFactory.java (from rev 28334, labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/BusDeploymentFactory.java)
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebGatewayDeploymentFactory.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebGatewayDeploymentFactory.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.listeners.war;
+
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.internal.soa.esb.listeners.war.HttpGatewayDeploymentFactory;
+import org.jboss.soa.esb.listeners.config.DeploymentResourceLocator;
+import org.jboss.logging.Logger;
+import org.jboss.internal.soa.esb.listeners.war.WebDeploymentArchive;
+
+/**
+ * Web Gateway Deployment Factory.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface WebGatewayDeploymentFactory {
+
+ /**
+ * Set the name of the bus configuration associated with the deployment.
+ * @param busName The bus name.
+ */
+ public void setBusName(String busName);
+
+ /**
+ * Set the {@link org.jboss.soa.esb.listeners.config.DeploymentResourceLocator} for the deployment.
+ * @param resourceLocator Deployment resource locator.
+ */
+ public void setDeploymentResourceLocator(DeploymentResourceLocator resourceLocator);
+
+ /**
+ * Get the deployment archives to be deployed.
+ * @param webEndpointConfig The web endpoint configuration.
+ * @param webDeployment The web deployment archive to be updated.
+ * @return The deployment archives.
+ * @throws ConfigurationException Failed to create the Deployment Archives.
+ */
+ public void updateDeployment(ConfigTree webEndpointConfig, WebDeploymentArchive webDeployment) throws ConfigurationException;
+
+ /**
+ * Factory builder.
+ */
+ public static class FactoryBuilder {
+
+ private final static Logger logger = Logger.getLogger(FactoryBuilder.class);
+
+ public static WebGatewayDeploymentFactory createInstance(String gatewayClass) {
+
+ // Intentionally not allowing specification of the implementation. Was deemed
+ // too risky. Must be an internally defined implementation.
+ if(HttpGatewayDeploymentFactory.class.getName().equals(gatewayClass)) {
+ return new HttpGatewayDeploymentFactory();
+ }
+
+ logger.debug("Not creating a WebGatewayDeploymentFactory instance for '" + gatewayClass + "'. Not an internally defined WebGatewayDeploymentFactory implementation.");
+
+ return null;
+ }
+ }
+}
Property changes on: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebGatewayDeploymentFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebModel.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebModel.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/WebModel.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.listeners.war;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * JEE WAR deployment model.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WebModel {
+
+ private List<Servlet> servlets = new ArrayList<Servlet>();
+
+ public List<Servlet> getServlets() {
+ return servlets;
+ }
+}
Copied: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/web.xml.ftl (from rev 28334, labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/web.xml.ftl)
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/web.xml.ftl (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/internal/soa/esb/listeners/war/web.xml.ftl 2009-07-27 09:20:23 UTC (rev 28486)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <#list webModel.servlets as servlet>
+
+ <!-- Servlet '${servlet.name}' configuration... -->
+ <servlet>
+ <servlet-name>${servlet.name}</servlet-name>
+ <servlet-class>${servlet.runtimeClass.name}</servlet-class>
+
+ <#list servlet.params as param>
+ <init-param>
+ <param-name>${param.key}</param-name>
+ <param-value>${param.value}</param-value>
+ </init-param>
+ </#list>
+
+ </servlet>
+
+ <#list servlet.urlMappings as urlMapping>
+ <servlet-mapping>
+ <servlet-name>${servlet.name}</servlet-name>
+ <url-pattern>${urlMapping}</url-pattern>
+ </servlet-mapping>
+ </#list>
+ </#list>
+
+</web-app>
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/LifecycleUtil.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/LifecycleUtil.java 2009-07-27 09:09:28 UTC (rev 28485)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/LifecycleUtil.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -29,7 +29,7 @@
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycle;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
-import org.jboss.soa.esb.listeners.config.BusDeploymentFactory;
+import org.jboss.internal.soa.esb.listeners.war.WebGatewayDeploymentFactory;
import org.jboss.soa.esb.parameters.ParamRepositoryException;
import org.jboss.soa.esb.parameters.ParamRepositoryFactory;
import org.jboss.soa.esb.util.ClassUtil;
@@ -135,7 +135,7 @@
if (!ManagedLifecycle.class.isAssignableFrom(instanceClass))
{
- if (BusDeploymentFactory.class.isAssignableFrom(instanceClass)) {
+ if (WebGatewayDeploymentFactory.class.isAssignableFrom(instanceClass)) {
// These guys are deployed as sub deployments by the main
// deployer, so we skip them here if they don't implement
// ManagedLifecycle...
Deleted: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/BusDeploymentFactory.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/BusDeploymentFactory.java 2009-07-27 09:09:28 UTC (rev 28485)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/BusDeploymentFactory.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2008, JBoss Inc.
- */
-package org.jboss.soa.esb.listeners.config;
-
-import org.jboss.soa.esb.util.DeploymentArchive;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.listeners.gateway.HttpGatewayDeploymentFactory;
-import org.jboss.logging.Logger;
-
-import java.util.List;
-
-/**
- * Bus Deployment Factory.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public interface BusDeploymentFactory {
-
-
-
- /**
- * Set the name of the bus configuration associated with the deployment.
- * @param busName The bus name.
- */
- public void setBusName(String busName);
-
- /**
- * Set the listener configurations associated with the Gateway.
- * @param listeners The listener configurations.
- */
- public void setListeners(List<ConfigTree> listeners);
-
- /**
- * Set the {@link DeploymentResourceLocator} for the deployment.
- * @param resourceLocator Deployment resource locator.
- */
- public void setDeploymentResourceLocator(DeploymentResourceLocator resourceLocator);
-
- /**
- * Get the deployment archives to be deployed.
- * @return The deployment archives.
- * @throws ConfigurationException Failed to create the Deployment Archives.
- */
- public List<DeploymentArchive> getDeploymentArchives() throws ConfigurationException;
-
- /**
- * Factory builder.
- */
- public static class FactoryBuilder {
-
- private final static Logger logger = Logger.getLogger(FactoryBuilder.class);
-
- public static BusDeploymentFactory createInstance(String gatewayClass) {
-
- // Intentionally not allowing specification of the implementation. Was deemed
- // too risky. Must be an internally defined implementation.
- if(HttpGatewayDeploymentFactory.class.getName().equals(gatewayClass)) {
- return new HttpGatewayDeploymentFactory();
- }
-
- logger.debug("Not creating a BusDeploymentFactory instance for '" + gatewayClass + "'. Not an internally defined BusDeploymentFactory implementation.");
-
- return null;
- }
- }
-}
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2009-07-27 09:09:28 UTC (rev 28485)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -47,6 +47,8 @@
import org.jboss.internal.soa.esb.webservice.ESBServiceEndpointInfo;
import org.jboss.internal.soa.esb.webservice.JAXWSProviderClassGenerator;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.listeners.war.WebDeploymentArchive;
+import org.jboss.internal.soa.esb.listeners.war.WebGatewayDeploymentFactory;
import org.jboss.logging.Logger;
import org.jboss.metadata.MetaData;
import org.jboss.metadata.XmlFileLoader;
@@ -62,8 +64,6 @@
import org.jboss.soa.esb.util.FileUtil;
import org.jboss.soa.esb.util.DeploymentArchive;
import org.jboss.system.ServiceControllerMBean;
-import org.jboss.system.server.ServerConfig;
-import org.jboss.system.server.ServerConfigLocator;
import org.jboss.web.AbstractWebContainer;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -266,7 +266,7 @@
// invoke super-class initialization
super.init(di);
-
+
// create webservice WAR
final ClassLoader origCL = Thread.currentThread().getContextClassLoader() ;
final List<ContractReferencePublisher> publishers = new ArrayList<ContractReferencePublisher>() ;
@@ -287,8 +287,8 @@
deployUrl(di, warFileURL, warFile.getName()) ;
}
- // Deploy all "deployable" gateways...
- deployDeployableGateways(model, di);
+ // Deploy web gateways...
+ deployWebGateways(model, di);
}
catch (Exception e)
{
@@ -563,38 +563,41 @@
return null ;
}
- private void deployDeployableGateways(ModelAdapter model, DeploymentInfo di) throws ConfigurationException, DeploymentException, JMException {
-
- // Gather the listener groups associated with each of the buses...
+ private void deployWebGateways(ModelAdapter model, DeploymentInfo di) throws ConfigurationException, DeploymentException, JMException {
Map<String, List<ConfigTree>> listenerGroups = getListenerGroups(model);
-
- // For each bus, gather the deployment archives to be deployed (can be one or more)...
- List<DeploymentArchive> deploymentArchives = new ArrayList<DeploymentArchive>();
Set<Map.Entry<String, List<ConfigTree>>> listenerGroupEntries = listenerGroups.entrySet();
+ ClasspathDeploymentResourceLocator diResourceLocator = new ClasspathDeploymentResourceLocator(di.localCl);
+ WebDeploymentArchive webDeployment = new WebDeploymentArchive(di.shortName + "-http.war"); // TODO: update after merging EBWS !!
+ // Add everything to the webDeployment...
for(Map.Entry<String, List<ConfigTree>> listenerGroup : listenerGroupEntries) {
String busIdRef = listenerGroup.getKey();
List<ConfigTree> listeners = listenerGroup.getValue();
String gatewayClass = listeners.get(0).getAttribute(ListenerTagNames.GATEWAY_CLASS_TAG);
if(gatewayClass != null) {
- BusDeploymentFactory deploymentFactory = BusDeploymentFactory.FactoryBuilder.createInstance(gatewayClass);
+ WebGatewayDeploymentFactory deploymentFactory = WebGatewayDeploymentFactory.FactoryBuilder.createInstance(gatewayClass);
if(deploymentFactory != null) {
deploymentFactory.setBusName(busIdRef);
- deploymentFactory.setListeners(listeners);
- deploymentFactory.setDeploymentResourceLocator(new ClasspathDeploymentResourceLocator(di.localCl));
+ deploymentFactory.setDeploymentResourceLocator(diResourceLocator);
- deploymentArchives.addAll(deploymentFactory.getDeploymentArchives());
+ // For each listener...
+ for(ConfigTree listenerConfig : listeners) {
+ deploymentFactory.updateDeployment(listenerConfig, webDeployment);
+ }
}
}
}
- // Now run the deploys...
- for(DeploymentArchive deployment : deploymentArchives) {
- File file = createGatewayTempDeployment(deployment, di);
+ if(!webDeployment.getWebModel().getServlets().isEmpty()) {
+ // Finalize the webDeployment...
+ webDeployment.finalizeArchive();
+
+ // Now create and deploy the web deployment...
+ File file = createGatewayTempDeployment(webDeployment, di);
try {
- deployUrl(di, file.toURL(), deployment.getArchiveName());
+ deployUrl(di, file.toURL(), webDeployment.getArchiveName());
// Maintain a list of sub deployments so we can clean them
// up on undeploy...
@@ -629,7 +632,6 @@
if(child.getNodeType() == Node.ELEMENT_NODE) {
Element listenerElement = (Element) child;
String busIdRef = listenerElement.getAttribute(ListenerTagNames.BUSIDREF_ATTRIBUTE_TAG);
- String listenerName = listenerElement.getAttribute("name");
List<ConfigTree> listenerGroup = listenerGroups.get(busIdRef);
@@ -646,7 +648,7 @@
private File createGatewayTempDeployment(DeploymentArchive deploymentArchive, DeploymentInfo di) throws ConfigurationException {
- File gatewayDeployFile = createTempDeploymentFile(esbWarFiles, di.shortName, deploymentArchive.getArchiveName(), true);
+ File gatewayDeployFile = createTempDeploymentFile(esbWarFiles, deploymentArchive.getArchiveName(), true);
FileOutputStream fileOutStream;
try {
@@ -670,19 +672,17 @@
return gatewayDeployFile;
}
- private File createTempDeploymentFile(final File tempDir, final String deploymentName, final String archiveName, final boolean createDir) throws ConfigurationException {
- final File deploymentDir = new File(tempDir, deploymentName) ;
-
- if (!deploymentDir.exists())
+ private File createTempDeploymentFile(final File tempDir, final String archiveName, final boolean createDir) throws ConfigurationException {
+ if (!tempDir.exists())
{
if (!createDir)
{
return null ;
}
- deploymentDir.mkdir() ;
+ tempDir.mkdir() ;
}
- File file = new File(deploymentDir, archiveName);
+ File file = new File(tempDir, archiveName);
if(file.exists()) {
log.debug("Deployment archive '" + archiveName + "' already exists. Overwriting!!");
}
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers120/HttpListenerMapper.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers120/HttpListenerMapper.java 2009-07-27 09:09:28 UTC (rev 28485)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers120/HttpListenerMapper.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -1,7 +1,6 @@
package org.jboss.soa.esb.listeners.config.mappers120;
import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
import org.jboss.soa.esb.dom.YADOMUtil;
import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.soa.esb.listeners.config.xbeanmodel120.PropertyDocument.Property;
@@ -9,7 +8,7 @@
import org.jboss.soa.esb.listeners.config.xbeanmodel120.HttpListenerDocument.HttpListener;
import org.jboss.soa.esb.listeners.config.xbeanmodel120.HttpProviderDocument.HttpProvider;
import org.jboss.soa.esb.listeners.config.xbeanmodel120.PayloadAs;
-import org.jboss.soa.esb.listeners.gateway.HttpGatewayDeploymentFactory;
+import org.jboss.internal.soa.esb.listeners.war.HttpGatewayDeploymentFactory;
import org.w3c.dom.Element;
/**
Deleted: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayDeploymentFactory.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayDeploymentFactory.java 2009-07-27 09:09:28 UTC (rev 28485)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayDeploymentFactory.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -1,216 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2008, JBoss Inc.
- */
-package org.jboss.soa.esb.listeners.gateway;
-
-import org.jboss.soa.esb.listeners.config.BusDeploymentFactory;
-import org.jboss.soa.esb.listeners.config.DeploymentResourceLocator;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.dom.YADOMUtil;
-import org.jboss.soa.esb.util.DeploymentArchive;
-import org.jboss.soa.esb.util.FreeMarkerTemplate;
-import org.jboss.internal.soa.esb.util.StreamUtils;
-import org.jboss.internal.soa.esb.assertion.AssertArgument;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-import org.apache.log4j.Logger;
-
-import javax.xml.transform.stream.StreamResult;
-import java.io.*;
-import java.util.*;
-
-import freemarker.template.TemplateException;
-
-/**
- * Http Gateway deployment factory.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class HttpGatewayDeploymentFactory implements BusDeploymentFactory {
-
- private static Logger logger = Logger.getLogger(HttpGatewayDeploymentFactory.class);
-
- private String busName;
- private List<ConfigTree> listeners;
- private DeploymentResourceLocator resourceLocator;
-
- public void setBusName(String busName) {
- AssertArgument.isNotNullAndNotEmpty(busName, "busName");
- this.busName = busName;
- }
-
- public void setListeners(List<ConfigTree> listeners) {
- AssertArgument.isNotNullAndNotEmpty(listeners, "listeners");
- this.listeners = listeners;
- }
-
- public void setDeploymentResourceLocator(DeploymentResourceLocator resourceLocator) {
- AssertArgument.isNotNull(resourceLocator, "resourceLocator");
- this.resourceLocator = resourceLocator;
- }
-
- public List<DeploymentArchive> getDeploymentArchives() throws ConfigurationException {
- List<ListenerConfig> listenerConfigModels = new ArrayList<ListenerConfig>();
- Set listenerNameSet = new HashSet<String>();
-
- for(ConfigTree listener : listeners) {
- ListenerConfig config = new ListenerConfig();
-
- config.setName(listener.getRequiredAttribute("name"));
- if(!listenerNameSet.contains(config.name)) {
- config.setUrlPattern(listener.getAttribute("urlPattern", "/"));
- config.setAttributes(listener.attributesAsList());
- listenerConfigModels.add(config);
-
- listenerNameSet.add(config.name);
- } else {
- throw new ConfigurationException("Duplicate listener/Gateway name '" + config.name + "'. Listener/Gateway names must be unique.");
- }
- }
-
- // Build the base web.xml from the list of listeners "listening" on this bus...
- String baseWebXML = constructBaseWebXML(listenerConfigModels);
-
- // If the user defined an extension web.xml. We need to merge it with the generated (base)
- // web.xml...
- String userWebXML = getFile("webXml");
- if(userWebXML != null) {
- try {
- baseWebXML = merge(baseWebXML, userWebXML);
- } catch (SAXException e) {
- throw new RuntimeException("Error parsing user defined web.xml.", e);
- }
- }
-
- // Now lets build the web archive...
- DeploymentArchive war = new DeploymentArchive(busName + ".war");
- try {
- war.addEntry("WEB-INF/web.xml", new ByteArrayInputStream(baseWebXML.getBytes("UTF-8")));
-
- String jbossWebXml = getFile("jbossWebXml");
- if(jbossWebXml != null) {
- war.addEntry("WEB-INF/jboss-web.xml", new ByteArrayInputStream(jbossWebXml.getBytes("UTF-8")));
- }
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Unexpected character encoding exception.", e);
- }
-
- List<DeploymentArchive> list = new ArrayList<DeploymentArchive>();
- list.add(war);
-
- return list;
- }
-
- private String constructBaseWebXML(List<ListenerConfig> listenerConfigModels) throws ConfigurationException {
- FreeMarkerTemplate template = new FreeMarkerTemplate("web.xml.ftl", HttpGatewayDeploymentFactory.class);
- Map contextObj = new HashMap();
-
- contextObj.put("listeners", listenerConfigModels);
-
- try {
- return template.apply(contextObj);
- } catch (TemplateException e) {
- throw new ConfigurationException("Error constructing web.xml file from listener configuration.", e);
- }
- }
-
- private String getFile(String specifierAttribute) throws ConfigurationException {
- String fileName = listeners.get(0).getAttribute(specifierAttribute);
-
- if(fileName != null) {
- InputStream inputStream = resourceLocator.getResource(fileName);
- if(inputStream != null) {
- try {
- return StreamUtils.readStreamString(inputStream, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Unexpected exception.", e);
- } finally {
- try {
- inputStream.close();
- } catch (IOException e) {
- logger.debug("Failed to close stream to resource '" + fileName + "'.", e);
- }
- }
- } else {
- throw new ConfigurationException("Failed to locate '" + specifierAttribute + "' file '" + fileName + "'.");
- }
- }
-
- return null;
- }
-
- private String merge(String baseWebXML, String userWebXML) throws SAXException {
- try {
- Document baseWebXmlDoc = YADOMUtil.parse(baseWebXML);
- Document userWebXmlDoc = YADOMUtil.parse(userWebXML);
- NodeList nodes = userWebXmlDoc.getDocumentElement().getChildNodes();
- int childCount = nodes.getLength();
-
- // Import the child nodes...
- for(int i = 0; i < childCount; i++) {
- Node child = nodes.item(i);
- baseWebXmlDoc.getDocumentElement().appendChild(baseWebXmlDoc.importNode(child, true));
- }
-
- StringWriter result = new StringWriter();
- try {
- YADOMUtil.serialize(baseWebXmlDoc, new StreamResult(result));
- } catch (ConfigurationException e) {
- throw new RuntimeException("Unexpected exception.", e);
- }
-
- return result.toString();
- } catch (IOException e) {
- throw new IllegalStateException("Unexpected exception.", e);
- }
- }
-
- public static class ListenerConfig {
- private String name;
- private String urlPattern;
- private List<KeyValuePair> attributes;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getUrlPattern() {
- return urlPattern;
- }
-
- public void setUrlPattern(String urlPattern) {
- this.urlPattern = urlPattern;
- }
-
- public List<KeyValuePair> getAttributes() {
- return attributes;
- }
-
- public void setAttributes(List<KeyValuePair> attributes) {
- this.attributes = attributes;
- }
- }
-}
\ No newline at end of file
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayServlet.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayServlet.java 2009-07-27 09:09:28 UTC (rev 28485)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayServlet.java 2009-07-27 09:20:23 UTC (rev 28486)
@@ -45,7 +45,7 @@
* An instance of this class gets configured for each http-listener urlPattern.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @see HttpGatewayDeploymentFactory
+ * @see org.jboss.internal.soa.esb.listeners.war.HttpGatewayDeploymentFactory
*/
public class HttpGatewayServlet extends HttpServlet {
Deleted: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/web.xml.ftl
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/web.xml.ftl 2009-07-27 09:09:28 UTC (rev 28485)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/web.xml.ftl 2009-07-27 09:20:23 UTC (rev 28486)
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- version="2.5">
-
- <#list listeners as listener>
- <servlet>
- <servlet-name>${listener.name}</servlet-name>
- <servlet-class>org.jboss.soa.esb.listeners.gateway.HttpGatewayServlet</servlet-class>
-
- <#list listener.attributes as kvp>
- <init-param>
- <param-name>${kvp.key}</param-name>
- <param-value>${kvp.value}</param-value>
- </init-param>
- </#list>
-
- </servlet>
-
- <servlet-mapping>
- <servlet-name>${listener.name}</servlet-name>
- <url-pattern>${listener.urlPattern}</url-pattern>
- </servlet-mapping>
- </#list>
-
-
-</web-app>
More information about the jboss-svn-commits
mailing list