[esb-java-dev] svn commit r729 - in esb/java/trunk: .
modules/core/src/main/java/org/wso2/esb
modules/core/src/main/java/org/wso2/esb/services
modules/core/src/main/java/org/wso2/esb/services/utils
modules/core/src/main/java/org/wso2/esb/transport
modules/core/src/main/java/org/wso2/esb/transport/jetty
modules/core/src/main/java/org/wso2/esb/util
svn at wso2.com
svn at wso2.com
Mon Feb 5 04:29:23 PST 2007
Author: asankha
Date: Mon Feb 5 04:28:43 2007
New Revision: 729
Added:
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/utils/ServerData.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/ServiceHTMLProcessor.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2Handler.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2RestHandler.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/JettyHTTPOutTransportInfo.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/ManagementConsoleRequestHandler.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/ServerDefaultHandler.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/JettyWebConfiguration.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/MIMEType2FileExtensionMap.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/XmlConfiguration.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/XmlConfigurationFactory.java
Modified:
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/Constants.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBus.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/ServerAdmin.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/utils/ServerStatus.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2SOAPHandler.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Constants.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpGetRequestProcessor.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpTransportListener.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpsTransportListener.java
esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/JettyServer.java
esb/java/trunk/pom.xml
Log:
remove dependencies on WSAS by moving jetty code into ESB completely
removed tracer dependency and references
code may not work but checkin is required before svn change tonight
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/Constants.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/Constants.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/Constants.java Mon Feb 5 04:28:43 2007
@@ -29,12 +29,13 @@
public static final String IN_FAULT_MESSAGE_MAP_KEY = "IN_FAULT_Message_Map_Key";
public static final String OUT_FAULT_MESSAGE_MAP_KEY = "OUT_FAULT_Message_Map_Key";
- public static String ADMIN_SERVICE = "ESBAdmin";
+ public static String ADMIN_SERVICE_GROUP = "ESBAdmin";
public static String ESB_INSTANCE = "WSO2 ESB";
public static String ESB_XML_NAMESPACE = "http://www.wso2.org/projects/esb";
public static String ESB_WEB_XML_KEY = "ESB_WEB_XML_KEY";
public static final String WELCOME_PAGE = "INDEX_HTML_FILE";
+ public static final String GENERATED_PAGES = "wso2esb.generated.pages";
// Constants for ESB registry
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBus.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBus.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBus.java Mon Feb 5 04:28:43 2007
@@ -27,7 +27,6 @@
import org.wso2.utils.ServerConfiguration;
import org.wso2.utils.security.CryptoUtil;
import org.wso2.utils.transport.http.HttpServerManager;
-import org.wso2.wsas.ServerConstants;
import java.io.File;
/*
@@ -76,8 +75,8 @@
startListeners();
try {
HttpServerManager
- .startServer(ServerConstants.Jetty.HTTP_SERVER);
- HttpServerManager.startServer(ServerConstants.Jetty.HTTPS_SERVER);
+ .startServer(org.wso2.esb.transport.jetty.Constants.HTTP_SERVER);
+ HttpServerManager.startServer(org.wso2.esb.transport.jetty.Constants.HTTPS_SERVER);
} catch (Exception e) {
log.fatal("WSO2 ESB Encounterd an Error", e);
throw new ServiceBusException(e);
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/ServiceBusManager.java Mon Feb 5 04:28:43 2007
@@ -26,9 +26,8 @@
import org.apache.derby.drda.NetworkServerControl;
import org.wso2.adminui.UIProcessingException;
import org.wso2.adminui.UIProcessor;
-import org.wso2.wsas.ServerConstants;
-import org.wso2.wsas.util.JettyWebConfiguration;
-import org.wso2.wsas.util.XmlConfigurationFactory;
+import org.wso2.esb.util.XmlConfigurationFactory;
+import org.wso2.esb.util.JettyWebConfiguration;
import java.io.File;
import java.net.UnknownHostException;
@@ -84,7 +83,6 @@
Thread.sleep(1000);
try {
networkServerControl.ping();
- log.info("Derby SB Network Server started..");
Properties properties = networkServerControl.getCurrentProperties();
String host = properties.getProperty("derby.drda.host");
int port = Integer.parseInt(properties.getProperty("derby.drda.portNumber"));
@@ -153,7 +151,7 @@
log.warn("Welcome page generation failed: " + e);
log.debug("Welcome page generation failed", e);
}
- configurationContext.setProperty(ServerConstants.GENERATED_PAGES, fileContents);
+ configurationContext.setProperty(Constants.GENERATED_PAGES, fileContents);
}
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/ServerAdmin.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/ServerAdmin.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/ServerAdmin.java Mon Feb 5 04:28:43 2007
@@ -26,9 +26,8 @@
import org.wso2.esb.Constants;
import org.wso2.esb.ServiceBusException;
import org.wso2.esb.services.utils.ServerStatus;
-import org.wso2.tracer.TracerConstants;
+import org.wso2.esb.services.utils.ServerData;
import org.wso2.utils.MemoryAppender;
-import org.wso2.wsas.admin.service.util.ServerData;
/*
*
*/
@@ -44,30 +43,6 @@
return serverStatus;
}
- public String getMessageMonitoringStatus() {
- boolean isTracing =
- ((Boolean) getConfigContext().
- getProperty(TracerConstants.IS_TRACING)).booleanValue();
- if (isTracing) {
- return "ON";
- }
- return "OFF";
- }
-
- public void setTracing(String onOff) throws AxisFault {
- if (!onOff.equalsIgnoreCase("ON") && !onOff.equalsIgnoreCase("OFF")) {
- throw new AxisFault("IllegalArgument for monitoring status :" +
- onOff);
- }
- ConfigurationContext configContext = getConfigContext();
- if (onOff.equalsIgnoreCase("on")) {
- configContext.setProperty(TracerConstants.IS_TRACING, Boolean.valueOf("true"));
- } else {
- configContext.setProperty(TracerConstants.IS_TRACING, Boolean.valueOf("false"));
- configContext.getProperties().remove(TracerConstants.MSG_SEQ_BUFFER);
- }
- }
-
public ServerData getServerData() throws AxisFault {
return new ServerData(
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/utils/ServerData.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/utils/ServerData.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,191 @@
+package org.wso2.esb.services.utils;
+
+import org.wso2.esb.ServiceBusConfiguration;
+
+public class ServerData {
+ private String javaRuntimeName;
+ private String javaVMVersion;
+ private String javaVMVendor;
+ private String javaHome;
+ private String javaVersion;
+ private String osName;
+ private String osVersion;
+ private String userHome;
+ private String userTimezone;
+ private String userName;
+ private String userCountry;
+ private String axis2Location;
+ private String serverName;
+ private String repoLocation;
+ private String wso2wsasVersion;
+
+ public ServerData(String serverName, String repoLocation) {
+ init();
+ this.serverName = serverName;
+ this.repoLocation = repoLocation;
+ }
+
+ public ServerData() {
+ init();
+ }
+
+ private void init() {
+ javaRuntimeName = System.getProperty("java.runtime.name");
+ javaVMVersion = System.getProperty("java.vm.version");
+ javaVMVendor = System.getProperty("java.vm.vendor");
+ userCountry = System.getProperty("user.country");
+ osName = System.getProperty("os.name");
+ osVersion = System.getProperty("os.version");
+ userHome = System.getProperty("user.home");
+ userTimezone = System.getProperty("user.timezone");
+ userName = System.getProperty("user.name");
+ javaHome = System.getProperty("java.home");
+ javaVersion = System.getProperty("java.version");
+ wso2wsasVersion = ServiceBusConfiguration.getInstance().getFirstProperty("Version");
+ axis2Location = axis2Location();
+ }
+
+ private String axis2Location() {
+ try {
+ Class clazz = Class.forName("org.apache.axis2.engine.AxisEngine");
+ java.net.URL url = clazz.getProtectionDomain().getCodeSource()
+ .getLocation();
+ String location = url.toString();
+
+ if (location.startsWith("jar")) {
+ url = ((java.net.JarURLConnection) url.openConnection()).getJarFileURL();
+ location = url.toString();
+ }
+
+ if (location.startsWith("file")) {
+ java.io.File file = new java.io.File(url.getFile());
+
+ return file.getAbsolutePath();
+ } else {
+ return url.toString();
+ }
+ } catch (Throwable t) {
+ return "an unknown location";
+ }
+ }
+
+ public String getJavaRuntimeName() {
+ return javaRuntimeName;
+ }
+
+ public void setJavaRuntimeName(String javaRuntimeName) {
+ this.javaRuntimeName = javaRuntimeName;
+ }
+
+ public String getJavaVMVersion() {
+ return javaVMVersion;
+ }
+
+ public void setJavaVMVersion(String javaVMVersion) {
+ this.javaVMVersion = javaVMVersion;
+ }
+
+ public String getUserCountry() {
+ return userCountry;
+ }
+
+ public void setUserCountry(String userCountry) {
+ this.userCountry = userCountry;
+ }
+
+ public String getJavaVMVendor() {
+ return javaVMVendor;
+ }
+
+ public void setJavaVMVendor(String javaVMVendor) {
+ this.javaVMVendor = javaVMVendor;
+ }
+
+ public String getOsName() {
+ return osName;
+ }
+
+ public void setOsName(String osName) {
+ this.osName = osName;
+ }
+
+ public String getOsVersion() {
+ return osVersion;
+ }
+
+ public void setOsVersion(String osVersion) {
+ this.osVersion = osVersion;
+ }
+
+ public String getUserHome() {
+ return userHome;
+ }
+
+ public void setUserHome(String userHome) {
+ this.userHome = userHome;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getUserTimezone() {
+ return userTimezone;
+ }
+
+ public void setUserTimezone(String userTimezone) {
+ this.userTimezone = userTimezone;
+ }
+
+ public String getJavaHome() {
+ return javaHome;
+ }
+
+ public void setJavaHome(String javaHome) {
+ this.javaHome = javaHome;
+ }
+
+ public String getJavaVersion() {
+ return javaVersion;
+ }
+
+ public void setJavaVersion(String javaVersion) {
+ this.javaVersion = javaVersion;
+ }
+
+ public String getAxis2Location() {
+ return axis2Location;
+ }
+
+ public void setAxis2Location(String axis2Location) {
+ this.axis2Location = axis2Location;
+ }
+
+ public String getServerName() {
+ return serverName;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
+ public String getRepoLocation() {
+ return repoLocation;
+ }
+
+ public void setRepoLocation(String repoLocation) {
+ this.repoLocation = repoLocation;
+ }
+
+ public String getWso2wsasVersion() {
+ return wso2wsasVersion;
+ }
+
+ public void setWso2wsasVersion(String wso2wsasVersion) {
+ this.wso2wsasVersion = wso2wsasVersion;
+ }
+}
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/utils/ServerStatus.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/utils/ServerStatus.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/services/utils/ServerStatus.java Mon Feb 5 04:28:43 2007
@@ -81,7 +81,7 @@
freeMemory = formatMemoryValue(Runtime.getRuntime().freeMemory());
totalMemory = formatMemoryValue(Runtime.getRuntime().totalMemory());
- AxisServiceGroup asg = axisConfig.getServiceGroup(org.wso2.esb.Constants.ADMIN_SERVICE);
+ AxisServiceGroup asg = axisConfig.getServiceGroup(org.wso2.esb.Constants.ADMIN_SERVICE_GROUP);
Iterator srviceitr = asg.getServices();
int adminservicecout = 0;
int activeServices = 0;
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/ServiceHTMLProcessor.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/ServiceHTMLProcessor.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,111 @@
+package org.wso2.esb.transport;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.AxisFault;
+import org.wso2.esb.Constants;
+
+import java.util.Iterator;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+public class ServiceHTMLProcessor {
+
+ /**
+ * Returns the HTML text for the list of services deployed.
+ * This can be delegated to another Class as well
+ * where it will handle more options of GET messages.
+ *
+ * @return Returns String.
+ */
+ public static String getServicesHTML(ConfigurationContext configContext) {
+ String temp = "";
+ Iterator serviceGroupsItr = configContext.getAxisConfiguration().getServiceGroups();
+ boolean status = false;
+ if (serviceGroupsItr.hasNext()) {
+ status = true;
+ temp += "<h2>" + "Deployed services" + "</h2>";
+ while (serviceGroupsItr.hasNext()) {
+ AxisServiceGroup axisServiceGroup = (AxisServiceGroup) serviceGroupsItr.next();
+ if (!Constants.ADMIN_SERVICE_GROUP.equals(axisServiceGroup.getServiceGroupName()))
+ {
+ status = true;
+ for (Iterator serviceItr = axisServiceGroup.getServices();
+ serviceItr.hasNext();) {
+ AxisService axisService = (AxisService) serviceItr.next();
+ temp += "<h3><a href=\"" + axisService.getName() + "?info\">" +
+ axisService.getName() + "</a></h3>";
+ }
+ }
+ }
+ }
+ Hashtable erroneousServices =
+ configContext.getAxisConfiguration().getFaultyServices();
+
+ if ((erroneousServices != null) && !erroneousServices.isEmpty()) {
+ temp += "<hr><h2><font color=\"blue\">Faulty Services</font></h2>";
+ status = true;
+ Enumeration faultyservices = erroneousServices.keys();
+ while (faultyservices.hasMoreElements()) {
+ String faultyserviceName = (String) faultyservices.nextElement();
+ temp += "<h3><font color=\"blue\">" + faultyserviceName + "</font></h3>";
+ }
+ }
+
+ if (!status) {
+ temp = "<h2>There are no services deployed</h2>";
+ }
+
+ temp = "<html><head><title>Axis2: Services</title></head>" + "<body>" + temp
+ + "</body></html>";
+
+ return temp;
+ }
+
+ public static String printServiceHTML(String serviceName,
+ ConfigurationContext configurationContext) {
+ String temp = "";
+ try {
+ AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
+ AxisService axisService = axisConfig.getService(serviceName);
+ if (axisService != null) {
+ if (!axisService.isActive()) {
+ temp += "<b>Service " + serviceName +
+ " is inactive. Cannot display service information.</b>";
+ } else {
+ temp += "<h3>" + axisService.getName() + "</h3>";
+ temp += "<a href=\"" + axisService.getName() + "?wsdl\">wsdl</a> : ";
+ temp += "<a href=\"" + axisService.getName() + "?xsd\">schema</a> : ";
+ temp += "<a href=\"" + axisService.getName() + "?policy\">policy</a><br/>";
+ temp += "<i>Service Description : " +
+ axisService.getServiceDescription() + "</i><br/><br/>";
+ Iterator pubOpIter = axisService.getPublishedOperations().iterator();
+ if (pubOpIter.hasNext()) {
+ temp += "Published operations <ul>";
+ for (; pubOpIter.hasNext();) {
+ AxisOperation axisOperation = (AxisOperation) pubOpIter.next();
+ temp += "<li>" + axisOperation.getName().getLocalPart() + "</li>";
+ }
+ temp += "</ul>";
+ } else {
+ temp += "No operations specified for this service";
+ }
+ }
+ } else {
+ temp += "<b>Service " + serviceName +
+ " not found. Cannot display service information.</b>";
+ }
+ temp = "<html><head><title>Service Information</title></head>" + "<body>" + temp
+ + "</body></html>";
+ }
+ catch (AxisFault axisFault) {
+ temp = "<html><head><title>Service has a fualt</title></head>" + "<body>"
+ + "<hr><h2><font color=\"blue\">" + axisFault.getMessage() + "</font></h2></body></html>";
+ }
+ return temp;
+ }
+
+}
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2Handler.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2Handler.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,266 @@
+package org.wso2.esb.transport.jetty;
+
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.HttpConnection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.transport.http.TransportHeaders;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.*;
+import org.apache.axis2.Constants;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.om.OMElement;
+import org.wso2.utils.ServerConfiguration;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.ServletException;
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public abstract class Axis2Handler extends AbstractHandler {
+
+ protected static final Log log = LogFactory.getLog(Axis2Handler.class);
+ protected ConfigurationContext configurationContext;
+
+
+ public Axis2Handler(ConfigurationContext configurationContext) {
+ this.configurationContext = configurationContext;
+ }
+
+ protected Map getHeaders(HttpServletRequest request) {
+ HashMap headerMap = new HashMap();
+ Enumeration e = request.getAttributeNames();//TODO .getFieldNames();
+ while (e.hasMoreElements()) {
+ String field = (String) e.nextElement();
+ headerMap.put(field, request.getAttribute(field)); // TODO .getField(field)
+ }
+ return headerMap;
+ }
+
+ protected Map getTransportHeaders(HttpServletRequest req) {
+ return new TransportHeaders(req);
+ }
+
+ /**
+ * New documentation
+ *
+ * @param target
+ * @param request
+ * @param response
+ * @param dispatch
+ * @throws java.io.IOException
+ * @throws javax.servlet.ServletException
+ */
+ public void handle(String target, HttpServletRequest request, HttpServletResponse response,
+ int dispatch) throws IOException, ServletException {
+
+ if (configurationContext == null) {
+ throw new AxisFault(Messages
+ .getMessage("cannotBeNullConfigurationContext"));
+ }
+ Request baseRequest = (request instanceof Request) ? (Request) request :
+ HttpConnection.getCurrentConnection().getRequest();
+ baseRequest.setHandled(true);
+
+ OutputStream bos = response.getOutputStream();
+ TransportOutDescription transportOut =
+ configurationContext.getAxisConfiguration().
+ getTransportOut(new QName(org.apache.axis2.Constants.TRANSPORT_HTTP));
+ MessageContext msgContext = new MessageContext();
+
+ String trsPrefix = request.getRequestURL().toString();
+ int sepindex = trsPrefix.indexOf(':');
+ if (sepindex >= 0) {
+ trsPrefix = trsPrefix.substring(0, sepindex);
+ msgContext.setIncomingTransportName(trsPrefix);
+ } else {
+ msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
+ }
+ msgContext.setConfigurationContext(configurationContext);
+ msgContext.
+ setTransportIn(configurationContext.getAxisConfiguration().
+ getTransportIn(new QName(Constants.TRANSPORT_HTTP)));
+ msgContext.setTransportOut(transportOut);
+ msgContext.setServerSide(true);
+
+ String requestURI = request.getRequestURI();
+ ServerConfiguration serverConfig = ServerConfiguration.getInstance();
+ requestURI =
+ requestURI.replaceFirst(serverConfig.getFirstProperty("Axis2Config.RESTContext"),
+ serverConfig.getFirstProperty("Axis2Config.SOAPContext"));
+ msgContext.setTo(new EndpointReference(requestURI));
+
+ msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
+ new JettyHTTPOutTransportInfo(response));
+
+ msgContext.setProperty(MessageContext.TRANSPORT_OUT, bos);
+
+ // set the transport Headers
+ msgContext.setProperty(MessageContext.TRANSPORT_HEADERS,
+ getTransportHeaders(request));
+ msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
+
+ // set msg context properties
+ msgContext.setProperty(MessageContext.REMOTE_ADDR, request.getRemoteAddr());
+ // set request to context properties
+ msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, request);
+
+ msgContext.setFrom(new EndpointReference(request.getRemoteAddr()));
+
+ /*Session Management for Admin Services*/
+ manageSessionContext(request, response, msgContext);
+
+ String method = request.getMethod();
+ try {
+ if ("GET".equals(method))
+ { // HttpServletRequest.this. __GET
+ boolean processed = processGetRequest(msgContext, request, response);
+ if (!processed) {
+ response.setStatus(200);
+ }
+ } else
+ if ("POST".equals(method)) {
+
+ if (configurationContext == null) {
+ throw new AxisFault(Messages
+ .getMessage("cannotBeNullConfigurationContext"));
+ }
+ boolean processed = processPostRequest(msgContext, request, response);
+
+ if (msgContext.getOperationContext() == null) {
+ response.setStatus(202);
+ } else {
+ Object contextWritten =
+ msgContext.getOperationContext()
+ .getProperty(Constants.RESPONSE_WRITTEN);
+
+ if ((contextWritten == null) || !Constants.VALUE_TRUE.equals(contextWritten)) {
+ response.setStatus(HttpServletResponse.SC_ACCEPTED);
+ } else if (processed) {
+ response.setStatus(200);
+ }
+ }
+
+ } else {
+ log.debug("Unsupported: not POST or GET");
+ response.sendError(
+ HttpServletResponse.SC_NOT_IMPLEMENTED);//HttpResponse.__501_Not_Implemented);
+ } // not GET or POST
+ } catch (AxisFault e) {
+ //TODO null check for instance of MessageContext
+ try {
+ AxisEngine engine = new AxisEngine(configurationContext);
+ msgContext.setProperty(MessageContext.TRANSPORT_OUT, bos);
+ MessageContext faultContext =
+ engine.createFaultMessageContext(msgContext, e);
+
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+ SOAPFaultCode code = faultContext.getEnvelope().getBody().getFault().getCode();
+ OMElement valueElement = null;
+ if (code != null) {
+ valueElement = code.getFirstChildWithName(new QName(
+ SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+ SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
+ }
+
+ if (valueElement != null) {
+ if (valueElement.getText().trim().indexOf(SOAP12Constants.FAULT_CODE_SENDER) >
+ -1) {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ }
+ }
+
+ String state =
+ (String) msgContext.
+ getProperty(org.wso2.esb.transport.jetty.Constants.HTTP_RESPONSE_STATE);
+ if (state != null) {
+ int stateInt = Integer.parseInt(state);
+ response.setStatus(stateInt);
+ if (stateInt == 401) { // Unauthorized
+ response.addHeader("WWW-Authenticate",
+ "basic realm=\"WSO2 WSAS Users\"");
+ }
+ }
+
+ engine.sendFault(faultContext);
+ } catch (Throwable t) {
+ log.error(t.getMessage(), t);
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+ String msg = e.getMessage();
+ if (msg != null && msg.toLowerCase().indexOf("invalid service group id") == -1) {
+ log.error("Unable to handle request", e);
+ }
+ }
+ }
+
+ /**
+ * This method will determine, which requests should be injected with SessionContext.
+ * @param request
+ * @param response
+ * @param msgContext
+ * @throws ServletException
+ */
+ protected void manageSessionContext(HttpServletRequest request, HttpServletResponse response,
+ MessageContext msgContext) throws ServletException {
+
+ HttpSession httpSession = request.getSession(true);
+
+ if (httpSession != null) {
+ SessionContext sessionContext =
+ (SessionContext) httpSession.getAttribute(Constants.SESSION_CONTEXT_PROPERTY);
+ if (sessionContext == null && httpSession.isNew()) {
+ if (!explicitlyIngnorePaths(request)) {
+ String cookieValueString = httpSession.getId();
+ sessionContext = new SessionContext(null);
+ sessionContext.setCookieID(cookieValueString);
+ httpSession.setAttribute(Constants.SESSION_CONTEXT_PROPERTY, sessionContext);
+ msgContext.setSessionContext(sessionContext);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * TODO This is a temp method; that will used to temporary supress creation of SessionContexts
+ *
+ * @param request
+ * @return bolean
+ * @depricate
+ */
+ private boolean explicitlyIngnorePaths(HttpServletRequest request) {
+ String matchingString = "statistics";
+ return request.getRequestURI().indexOf(matchingString) > -1;
+
+ }
+
+
+ protected abstract boolean processPostRequest(MessageContext msgContext,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws AxisFault;
+
+ protected abstract boolean processGetRequest(MessageContext msgContext,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws AxisFault;
+
+}
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2RestHandler.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2RestHandler.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,35 @@
+package org.wso2.esb.transport.jetty;
+
+import org.apache.axis2.transport.http.util.RESTUtil;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class Axis2RestHandler extends Axis2Handler {
+ private RESTUtil restUtil = new RESTUtil(configurationContext);
+
+ public Axis2RestHandler(ConfigurationContext configurationContext) {
+ super(configurationContext);
+ }
+
+ protected boolean processPostRequest(MessageContext msgContext,
+ HttpServletRequest request,
+ HttpServletResponse response) throws AxisFault {
+ return restUtil.processPostRequest(msgContext,
+ request,
+ response);
+
+ }
+
+ protected boolean processGetRequest(MessageContext msgContext,
+ HttpServletRequest request,
+ HttpServletResponse response) throws AxisFault {
+ return restUtil.processGetRequest(msgContext,
+ request,
+ response);
+
+ }
+}
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2SOAPHandler.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2SOAPHandler.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Axis2SOAPHandler.java Mon Feb 5 04:28:43 2007
@@ -21,7 +21,6 @@
import org.apache.axis2.transport.http.util.SOAPUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.wsas.transport.jetty.Axis2Handler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Constants.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Constants.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/Constants.java Mon Feb 5 04:28:43 2007
@@ -19,4 +19,5 @@
public static final String HTTP_SERVER = "jetty.http.server";
public static final String HTTPS_SERVER = "jetty.https.server";
public static final String ADMIN_SERVER = "jetty.admin.server";
+ public static final String HTTP_RESPONSE_STATE = "HTTP_RESPONSE_STATE";
}
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpGetRequestProcessor.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpGetRequestProcessor.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpGetRequestProcessor.java Mon Feb 5 04:28:43 2007
@@ -36,11 +36,8 @@
import org.wso2.utils.NetworkUtils;
import org.wso2.utils.ServerConfiguration;
import org.wso2.utils.ServerException;
-import org.wso2.wsas.ServerManager;
-import org.wso2.wsas.feed.FeedConstants;
-import org.wso2.wsas.feed.atom.AtomFeed;
-import org.wso2.wsas.feed.rss.RSSFeed;
-import org.wso2.wsas.transport.jetty.ServiceHTMLProcessor;
+import org.wso2.esb.ServiceBusManager;
+import org.wso2.esb.transport.ServiceHTMLProcessor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -87,12 +84,12 @@
contextRoot = requestURI.substring(0, indexOfServletPath);
}
- if (requestURI.indexOf("rss") >= 0) {
+ /*if (requestURI.indexOf("rss") >= 0) {
return processRssFeed(response, contextRoot);
}
if (requestURI.indexOf("atom") >= 0) {
return processAtomFeed(response, contextRoot);
- }
+ }*/
String queryString = request.getQueryString();
if (queryString != null) {
if (queryString.toLowerCase().indexOf("info") == 0) {
@@ -323,7 +320,7 @@
outputStream.write("<b>Policy is not found!</b>".getBytes());
} else {
String ipAddress = "http://" + NetworkUtils.getLocalHostname() + ":" +
- ServerManager.httpPort;
+ ServiceBusManager.httpPort;
outputStream.write(("<html><head>" +
"<title>WSO2 Web Services Application Server v" +
ServerConfiguration.getInstance().getFirstProperty("Version") +
@@ -409,7 +406,7 @@
}
} else {
String ipAddress = "http://" + NetworkUtils.getLocalHostname() + ":" +
- ServerManager.httpPort;
+ ServiceBusManager.httpPort;
outputStream.write(("<html><head>" +
"<title>WSO2 Web Services Application Server v" +
ServerConfiguration.getInstance().getFirstProperty("Version") +
@@ -492,7 +489,7 @@
return true;
}
- private boolean processAtomFeed(HttpServletResponse response,
+ /*private boolean processAtomFeed(HttpServletResponse response,
String contextRoot) {
try {
response.setContentType("text/xml; charset=utf-8");
@@ -535,5 +532,5 @@
log.error(e);
}
return true;
- }
+ }*/
}
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpTransportListener.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpTransportListener.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpTransportListener.java Mon Feb 5 04:28:43 2007
@@ -30,7 +30,6 @@
import org.wso2.utils.RESTEndpointReferenceUtil;
import org.wso2.utils.transport.AbstractTransportListener;
import org.wso2.utils.transport.http.HttpServerManager;
-import org.wso2.wsas.ServerConstants;
import javax.xml.namespace.QName;
import java.net.ServerSocket;
@@ -70,7 +69,7 @@
public void start() throws AxisFault {
//selectPort(configurationContext);
- Server httpServer = HttpServerManager.getServer(ServerConstants.Jetty.HTTP_SERVER);
+ Server httpServer = HttpServerManager.getServer(org.wso2.esb.transport.jetty.Constants.HTTP_SERVER);
Connector connector = new SocketConnector();
connector.setPort(port);
ServiceBusManager.httpPort = port;
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpsTransportListener.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpsTransportListener.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/HttpsTransportListener.java Mon Feb 5 04:28:43 2007
@@ -28,7 +28,6 @@
import org.wso2.utils.RESTEndpointReferenceUtil;
import org.wso2.utils.transport.AbstractTransportListener;
import org.wso2.utils.transport.http.HttpServerManager;
-import org.wso2.wsas.ServerConstants;
import javax.xml.namespace.QName;
/*
@@ -62,7 +61,7 @@
public void start() throws AxisFault {
Server httpsServer = HttpServerManager
- .getServer(ServerConstants.Jetty.HTTPS_SERVER);
+ .getServer(Constants.HTTPS_SERVER);
SslSocketConnector sslSocketConnector = new SslSocketConnector();
sslSocketConnector.setPort(port);
ServiceBusManager.httpsPort = port;
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/JettyHTTPOutTransportInfo.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/JettyHTTPOutTransportInfo.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,21 @@
+package org.wso2.esb.transport.jetty;
+
+import org.apache.axis2.transport.OutTransportInfo;
+
+import javax.servlet.http.HttpServletResponse;
+
+public class JettyHTTPOutTransportInfo implements OutTransportInfo {
+ public JettyHTTPOutTransportInfo(HttpServletResponse response) {
+ this.response = response;
+ }
+ private HttpServletResponse response = null;
+ public void setContentType(String ct) {
+ response.setContentType(ct);
+
+ }
+
+ public void setCharacterEncoding(String charEnc) {
+ response.setContentType(charEnc); //TODO is this the correct method .setCharacterEncoding(charEnc);
+ }
+
+}
\ No newline at end of file
Modified: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/JettyServer.java
==============================================================================
--- esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/JettyServer.java (original)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/JettyServer.java Mon Feb 5 04:28:43 2007
@@ -29,10 +29,7 @@
import org.mortbay.jetty.security.SslSocketConnector;
import org.wso2.utils.NetworkUtils;
import org.wso2.utils.transport.http.HttpServerManager;
-import org.wso2.wsas.transport.jetty.Axis2RestHandler;
-import org.wso2.wsas.transport.jetty.ManagementConsoleRequestHandler;
-import org.wso2.wsas.transport.jetty.ServerDefaultHandler;
-import org.wso2.wsas.util.JettyWebConfiguration;
+import org.wso2.esb.util.JettyWebConfiguration;
import javax.xml.namespace.QName;
import java.text.SimpleDateFormat;
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/ManagementConsoleRequestHandler.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/ManagementConsoleRequestHandler.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,158 @@
+package org.wso2.esb.transport.jetty;
+
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.HttpConnection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.AxisFault;
+import org.wso2.utils.transport.http.FaviconProvider;
+import org.wso2.utils.NetworkUtils;
+import org.wso2.esb.util.JettyWebConfiguration;
+import org.wso2.esb.util.MIMEType2FileExtensionMap;
+import org.wso2.esb.ServiceBusManager;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletException;
+import java.util.Map;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+
+public class ManagementConsoleRequestHandler extends AbstractHandler {
+
+ protected static final Log log = LogFactory.getLog(ManagementConsoleRequestHandler.class);
+ private static JettyWebConfiguration jettyConfig = JettyWebConfiguration.getInstance();
+
+ private FaviconProvider faviconProvider;
+ private ConfigurationContext configurationContext;
+
+ public ManagementConsoleRequestHandler(ConfigurationContext configurationContext) {
+ this.configurationContext = configurationContext;
+ try {
+ faviconProvider = new FaviconProvider();
+ faviconProvider.setFavIconFromResource("org/wso2/wsas/transport/jetty/favicon.ico");
+ } catch (Exception e) {
+ log.warn(e);
+ }
+ }
+
+ private void generateWelcomePages(HttpServletRequest request, HttpServletResponse response) throws AxisFault {
+
+ try {
+
+ if (faviconProvider.provideFavIcon(request, response)) {
+ return;
+ }
+
+ String requestURI = request.getRequestURI();
+ String path = requestURI.equals(jettyConfig.adminWebCtx) ?
+ jettyConfig.adminWebResourceBase + "index.html" :
+ jettyConfig.adminWebResourceBase + requestURI;
+ ServletOutputStream op = response.getOutputStream();
+ if (requestURI.equals(jettyConfig.adminWebCtx)) {
+ String fileContents = (String) ((Map) configurationContext.
+ getProperty(org.wso2.esb.Constants.GENERATED_PAGES)).get("index.html");
+ if (fileContents != null) {
+ response.setContentType("text/html");
+ response.setContentLength(fileContents.getBytes().length);
+ op.write(fileContents.getBytes());
+ } else {
+ op.write("index.html was not generated properly.".getBytes());
+ }
+ op.flush();
+ } else {
+ String urlKey;
+ if (jettyConfig.adminWebCtx.equals("/")) {
+ urlKey = requestURI.substring(jettyConfig.adminWebCtx.length(),
+ requestURI.length());
+ } else {
+ urlKey = requestURI.substring(1 + jettyConfig.adminWebCtx.length(),
+ requestURI.length() - 1);
+
+ }
+ String fileContents = (String) ((Map) configurationContext.
+ getProperty(org.wso2.esb.Constants.GENERATED_PAGES)).get(urlKey);
+ if (fileContents != null) {
+ response.setContentType("text/html");
+ response.setContentLength(fileContents.getBytes().length);
+ op.write(fileContents.getBytes());
+ op.flush();
+ } else {
+ File file = new File(path);
+ if (!file.exists()) {
+ op.write(("Requested resource " + requestURI + " not found").getBytes());
+ op.flush();
+ return;
+ }
+ if (!file.isDirectory()) {
+ FileInputStream fis = new FileInputStream(file);
+ byte[] fileBytes = new byte[(int) file.length()];
+ int length = fis.read(fileBytes);
+ if (length == 0) {
+ log.warn(file.getName() + " is 0 bytes");
+ }
+ response.setContentType(MIMEType2FileExtensionMap.getInstance().
+ getMIMEType(file));
+ response.setContentLength((int) file.length());
+ op.write(fileBytes);
+ fis.close();
+ op.close();
+ } else {
+ //TOdO Fix this
+// op.write("Directory listing is forbidden".getBytes());
+// return false;
+ }
+ }
+ }
+ } catch (org.mortbay.jetty.EofException ignored) {
+ // NO OP : Socket connection break. No need to handle this.
+ } catch (EOFException ignored) {
+ // NO OP : Socket connection break. No need to handle this.
+ } catch (Exception e) {
+ String msg = "Exception occurred while processing Request";
+ log.error(msg, e);
+ throw new AxisFault(msg, e);
+ }
+ }
+
+
+ public void handle(String target, HttpServletRequest request, HttpServletResponse response,
+ int dispatch) throws IOException, ServletException {
+ Request baseRequest = (request instanceof Request) ? (Request) request :
+ HttpConnection.getCurrentConnection().getRequest();
+ baseRequest.setHandled(true);
+
+ if (hostResolver(request, response)) {
+ return;
+ }
+
+ generateWelcomePages(request,response);
+
+ }
+
+ /**
+ * This will redirect the request first before doing anything else
+ * @param request
+ * @param response
+ * @return boolean
+ * @throws IOException
+ */
+ private boolean hostResolver(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ String contextRoot = configurationContext.getContextRoot();
+ if (request.getRequestURL().toString().indexOf(NetworkUtils.getLocalHostname()) == -1) {
+ response.sendRedirect("https://" +
+ NetworkUtils.getLocalHostname() + ":" + ServiceBusManager.httpsPort +
+ (contextRoot.equals("/") ? contextRoot : contextRoot + "/"));
+ return true;
+
+ }
+ return false;
+
+ }
+}
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/ServerDefaultHandler.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/transport/jetty/ServerDefaultHandler.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,60 @@
+package org.wso2.esb.transport.jetty;
+
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.HttpConnection;
+import org.mortbay.log.Log;
+import org.wso2.utils.transport.http.FaviconProvider;
+import org.wso2.utils.NetworkUtils;
+import org.wso2.esb.util.JettyWebConfiguration;
+import org.wso2.esb.ServiceBusManager;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.net.SocketException;
+
+/**
+ * If users tried to use of any root context other than the registred contextes in server-web.xml
+ * or axis2.xml, this handler will invoke. Since this is Jetty related, all logger etc. are sync with
+ * Jetty symantics.
+ */
+public class ServerDefaultHandler extends AbstractHandler {
+
+ private static JettyWebConfiguration jettyConfig = JettyWebConfiguration.getInstance();
+
+
+ private FaviconProvider faviconProvider;
+
+ public ServerDefaultHandler() {
+ try {
+ faviconProvider = new FaviconProvider();
+ faviconProvider.setFavIconFromResource("org/wso2/wsas/transport/jetty/favicon.ico");
+ } catch (Exception e) {
+ Log.warn(e);
+ }
+ }
+
+
+ public void handle(String target, HttpServletRequest request, HttpServletResponse response,
+ int dispatch) throws IOException, ServletException {
+ Request baseRequest = request instanceof Request ? (Request) request :
+ HttpConnection.getCurrentConnection().getRequest();
+ if (response.isCommitted() || baseRequest.isHandled()) {
+ return;
+ }
+ baseRequest.setHandled(true);
+
+ if (faviconProvider.provideFavIcon(request, response)) {
+ return;
+ }
+
+ try {
+ response.sendRedirect("https://" + NetworkUtils.getLocalHostname() + ":" + ServiceBusManager
+ .httpsPort + jettyConfig.adminWebCtx);
+ } catch (SocketException e) {
+ throw new ServletException(e);
+ }
+ }
+}
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/JettyWebConfiguration.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/JettyWebConfiguration.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,77 @@
+package org.wso2.esb.util;
+
+public class JettyWebConfiguration {
+
+ private static JettyWebConfiguration instance;
+ private String xmlFileKey;
+
+ public String adminWebCtx;
+ public String adminWebResourceBase;
+ public String serviceUiWebCtx;
+ public String serviceUiResourceBase;
+ public String feedsWebCtx;
+ public String feedsWebResourceBase;
+ public String docsWebCtx;
+ public String docsWebResourceBase;
+ public String samplesWebCtx;
+ public String samplesWebResourceBase;
+ public String stylesWebCtx;
+ public String stylesWebResourceBase;
+
+ public static JettyWebConfiguration getInstance() {
+ if (instance == null) {
+ instance = new JettyWebConfiguration();
+ }
+ return instance;
+ }
+
+ /**
+ * Initialize the web admin content wrt the value of xmlFileKey;
+ */
+ public void init() {
+ adminWebCtx =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"admin\"]/ns:ContextPath");
+ adminWebResourceBase =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"admin\"]/ns:ResourceBase") + "/";
+ serviceUiWebCtx =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"serviceui\"]/ns:ContextPath");
+ serviceUiResourceBase =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"serviceui\"]/ns:ResourceBase") + "/";
+ feedsWebCtx =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"feeds\"]/ns:ContextPath");
+ feedsWebResourceBase =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"feeds\"]/ns:ResourceBase") + "/";
+ stylesWebCtx =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"styles\"]/ns:ContextPath");
+ stylesWebResourceBase =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"styles\"]/ns:ResourceBase") + "/";
+ docsWebCtx =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"docs\"]/ns:ContextPath");
+ docsWebResourceBase =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"docs\"]/ns:ResourceBase") + "/";
+ samplesWebCtx =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"samples\"]/ns:ContextPath");
+ samplesWebResourceBase =
+ XmlConfigurationFactory.getXmlConfiguration(xmlFileKey).
+ getUniqueValue("//ns:Mapping[@name=\"samples\"]/ns:ResourceBase") + "/";
+
+ }
+
+ private JettyWebConfiguration() {
+ }
+
+ public void setXmlFileKey(String xmlFileKey) {
+ this.xmlFileKey = xmlFileKey;
+ }
+}
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/MIMEType2FileExtensionMap.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/MIMEType2FileExtensionMap.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,61 @@
+package org.wso2.esb.util;
+
+import org.apache.log4j.Logger;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.io.File;
+
+public class MIMEType2FileExtensionMap {
+ public static String mappingFileName = "conf/mime-mappings.xml";
+
+ private Map extensionToMimeMap;
+ public static MIMEType2FileExtensionMap instance;
+ private static Logger log = Logger.getLogger(MIMEType2FileExtensionMap.class);
+
+ public static MIMEType2FileExtensionMap getInstance(){
+ if(instance == null){
+ instance = new MIMEType2FileExtensionMap();
+ }
+ return instance;
+ }
+
+ private MIMEType2FileExtensionMap() {
+ extensionToMimeMap = new HashMap();
+ init();
+ }
+
+ public String getMIMEType(File file) {
+ String filename = file.getName();
+ int index = filename.lastIndexOf(".");
+ if (index == -1 || index == filename.length() - 1) {
+ return "application/octet-stream";
+ } else {
+ String extension = filename.substring(index + 1);
+ String contentType = (String) extensionToMimeMap.get(extension);
+ return contentType != null ? contentType : "application/octet-stream";
+ }
+ }
+
+ private void init() {
+
+ try {
+ OMElement doc = new StAXOMBuilder(mappingFileName).getDocumentElement();
+ for (Iterator childIter = doc.getChildElements(); childIter.hasNext();) {
+ OMElement mappingEle = (OMElement) childIter.next();
+ String ext = mappingEle.getFirstChildWithName(new QName("Extension")).getText();
+ String mimeType = mappingEle.getFirstChildWithName(new QName("MimeType")).getText();
+ extensionToMimeMap.put(ext, mimeType);
+ }
+ } catch (Exception e) {
+ String msg = "Unable to load all MIME Mappings";
+ e.printStackTrace();
+ log.error(msg, e);
+ throw new RuntimeException(msg, e);
+ }
+ }
+}
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/XmlConfiguration.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/XmlConfiguration.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,82 @@
+package org.wso2.esb.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.axiom.om.OMElement;
+import org.wso2.utils.ServerException;
+import org.wso2.esb.Constants;
+import org.jaxen.SimpleNamespaceContext;
+import org.jaxen.XPath;
+import org.jaxen.JaxenException;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+public class XmlConfiguration {
+
+ private static Log log = LogFactory.getLog(XmlConfiguration.class);
+
+ private StAXOMBuilder builder;
+
+ /* Default namespace is set to http://www.wso2.org/products/wsas */
+ private String serverNamespace = Constants.ESB_XML_NAMESPACE;
+
+ public XmlConfiguration(String xmlFile) throws ServerException {
+ this(xmlFile, null);
+ }
+
+ public XmlConfiguration(String xmlFile, String serverNamespace) throws ServerException {
+ if (serverNamespace != null) {
+ this.serverNamespace = serverNamespace;
+ }
+ try {
+ builder = new StAXOMBuilder(xmlFile);
+ } catch (XMLStreamException e) {
+ log.error(e);
+ throw new ServerException(e);
+ } catch (FileNotFoundException e) {
+ log.error(e);
+ throw new ServerException(e);
+ }
+ }
+
+ public String getUniqueValue(String xPath) {
+ SimpleNamespaceContext nsCtx = new SimpleNamespaceContext();
+ nsCtx.addNamespace("ns", serverNamespace);
+ try {
+ XPath xp = new AXIOMXPath(xPath);
+ xp.setNamespaceContext(nsCtx);
+ OMElement elem = builder.getDocumentElement();
+ if (elem != null) {
+ List nodeList = xp.selectNodes(elem);
+ Object obj;
+ if (!nodeList.isEmpty() && ((obj = nodeList.get(0)) != null)) {
+ return ((OMElement) obj).getText();
+ }
+ }
+ } catch (JaxenException e) {
+ throw new RuntimeException("XPath expression " + xPath + " failed", e);
+ }
+ return null;
+ }
+
+ public OMElement[] getElements(String xPath) {
+ SimpleNamespaceContext nsCtx = new SimpleNamespaceContext();
+ nsCtx.addNamespace("ns", serverNamespace);
+ try {
+ XPath xp = new AXIOMXPath(xPath);
+ xp.setNamespaceContext(nsCtx);
+ OMElement elem = builder.getDocumentElement();
+ if (elem != null) {
+ List nodeList = xp.selectNodes(elem);
+ return (OMElement[]) nodeList.toArray(new OMElement[nodeList.size()]);
+ }
+ } catch (JaxenException e) {
+ throw new RuntimeException("XPath expression " + xPath + " failed", e);
+ }
+ return new OMElement[0];
+ }
+}
Added: esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/XmlConfigurationFactory.java
==============================================================================
--- (empty file)
+++ esb/java/trunk/modules/core/src/main/java/org/wso2/esb/util/XmlConfigurationFactory.java Mon Feb 5 04:28:43 2007
@@ -0,0 +1,33 @@
+package org.wso2.esb.util;
+
+import org.wso2.utils.ServerException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public class XmlConfigurationFactory {
+ private static Map configurations = new HashMap();
+
+ public static void init(String configKey, String configFile) throws ServerException {
+ init(configKey, configFile, null);
+ }
+
+ public static void init(String configKey,
+ String configFile,
+ String serverNamespace) throws ServerException {
+ if (serverNamespace != null) {
+ configurations.put(configKey, new XmlConfiguration(configFile,serverNamespace));
+ } else {
+ configurations.put(configKey, new XmlConfiguration(configFile));
+ }
+ }
+
+ public static XmlConfiguration getXmlConfiguration(String configKey) {
+ XmlConfiguration config = null;
+ Object obj = configurations.get(configKey);
+ if (obj != null) {
+ config = (XmlConfiguration) obj;
+ }
+ return config;
+ }
+}
Modified: esb/java/trunk/pom.xml
==============================================================================
--- esb/java/trunk/pom.xml (original)
+++ esb/java/trunk/pom.xml Mon Feb 5 04:28:43 2007
@@ -36,22 +36,21 @@
</organization>
<issueManagement>
<system>JIRA</system>
- <url>http://www.wso2.org/jira/browse/ESB-JAVA</url>
+ <url>http://www.wso2.org/jira/browse/ESBJAVA</url>
</issueManagement>
<mailingLists>
<mailingList>
<name>WSO2 ESB Developer List</name>
- <!-- todo: change the new list -->
- <subscribe>esb-java-dev-subscribe at wso2.org</subscribe>
- <unsubscribe>esb-java-dev-unsubscribe at wso2.org</unsubscribe>
- <archive></archive>
+ <subscribe>esb-java-dev-request at wso2.org</subscribe>
+ <unsubscribe>esb-java-dev-request at lists.wso2.com</unsubscribe>
+ <archive>http://www.wso2.org/mailarchive/esb-java-dev/</archive>
</mailingList>
<mailingList>
<name>WSO2 ESB User List</name>
- <subscribe>esb-java-user-subscribe at wso2.org</subscribe>
- <unsubscribe>esb-java-user-unsubscribe at wso2.org</unsubscribe>
- <archive></archive>
+ <subscribe>esb-java-user-request at wso2.org</subscribe>
+ <unsubscribe>esb-java-user-request at wso2.org</unsubscribe>
+ <archive>http://www.wso2.org/mailarchive/esb-java-user/</archive>
</mailingList>
</mailingLists>
@@ -156,11 +155,9 @@
</developers>
<scm>
- <!-- todo: change the svn repo -->
- <connection>scm:svn:https://www-lk.wso2.com/wso2/svn/titanium/java</connection>
- <developerConnection>
- scm:svn:https://www-lk.wso2.com/wso2/svn/titanium/java</developerConnection>
- <url>https://www-lk.wso2.com/wso2/svn/titanium/java</url>
+ <connection>scm:svn:http://wso2.org/repos/wso2/wsas/java/</connection>
+ <developerConnection>scm:svn:https://wso2.org/repos/wso2/wsas/java/</developerConnection>
+ <url>https://wso2.org/repos/wso2/wsas/java/</url>
</scm>
<repositories>
@@ -250,93 +247,35 @@
<dependencies>
- <!-- WSO2 WSAS Jars-->
- <dependency>
- <groupId>org.wso2.wsas</groupId>
- <artifactId>wso2wsas-core</artifactId>
- <version>${wso2wsas.version}</version>
- <exclusions>
- <exclusion>
- <groupId>httpcomponents-httpcore</groupId>
- <artifactId>jakarta-httpcore</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.wso2.wsas</groupId>
- <artifactId>wso2wsas-admin</artifactId>
- <version>${wso2wsas.version}</version>
- <exclusions>
- <exclusion>
- <groupId>httpcomponents-httpcore</groupId>
- <artifactId>jakarta-httpcore</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
<!-- WSO2 WSF Jars-->
<dependency>
<groupId>org.wso2.utils</groupId>
<artifactId>wso2utils</artifactId>
<version>${wso2wsf.version}</version>
<type>jar</type>
- <exclusions>
- <exclusion>
- <groupId>httpcomponents-httpcore</groupId>
- <artifactId>jakarta-httpcore</artifactId>
- </exclusion>
- </exclusions>
</dependency>
+ <!-- WSO2 commons -->
<dependency>
<groupId>org.wso2.throttle</groupId>
<artifactId>wso2throttle</artifactId>
<version>${wso2wsf.version}</version>
<type>jar</type>
- <exclusions>
- <exclusion>
- <groupId>httpcomponents-httpcore</groupId>
- <artifactId>jakarta-httpcore</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.wso2.tracer</groupId>
- <artifactId>wso2tracer</artifactId>
- <version>${wso2wsf.version}</version>
- <type>jar</type>
- <exclusions>
- <exclusion>
- <groupId>httpcomponents-httpcore</groupId>
- <artifactId>jakarta-httpcore</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.wso2.statistics</groupId>
<artifactId>wso2statistics</artifactId>
<version>${wso2wsf.version}</version>
<type>jar</type>
- <exclusions>
- <exclusion>
- <groupId>httpcomponents-httpcore</groupId>
- <artifactId>jakarta-httpcore</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.wso2.statistics</groupId>
<artifactId>wso2statistics</artifactId>
<version>${wso2wsf.version}</version>
<type>mar</type>
- <exclusions>
- <exclusion>
- <groupId>httpcomponents-httpcore</groupId>
- <artifactId>jakarta-httpcore</artifactId>
- </exclusion>
- </exclusions>
</dependency>
- <!-- -->
+
+ <!-- ignore tcpmon -->
<dependency>
<groupId>ws-commons</groupId>
<artifactId>tcpmon</artifactId>
@@ -344,6 +283,7 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
+
<!-- AdminUI -->
<dependency>
<groupId>org.wso2.adminui</groupId>
@@ -734,12 +674,12 @@
<groupId>smack</groupId>
<artifactId>smackx</artifactId>
<version>${smack.version}</version>
- </dependency>
- <dependency>
+ </dependency>
+ <dependency>
<groupId>smack</groupId>
<artifactId>smackx-debug</artifactId>
<version>${smack.version}</version>
- </dependency -->
+ </dependency -->
<!-- Derby jars -->
<dependency>
@@ -757,7 +697,8 @@
<artifactId>derbynet</artifactId>
<version>${derby.version}</version>
</dependency>
- <!-- Hybernate jars -->
+
+ <!-- Hibernate jars -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
@@ -839,34 +780,6 @@
<module>modules/distribution</module>
</modules>
- <!--<profiles>
- <profile>
- <id>release</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.1</version>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/bin.xml</descriptor>
- <descriptor>src/main/assembly/src.xml</descriptor>
- </descriptors>
- <finalName>synapse-${synapse.version}-incubating</finalName>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <activation>
- <property>
- <name>release</name>
- </property>
- </activation>
- </profile>
- </profiles>-->
-
-
<properties>
<server.name>WSO2 Enterprise Service Bus (ESB)</server.name>
<server.short.name>WSO2 ESB</server.short.name>
More information about the Esb-java-dev
mailing list