Modified:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ParamUtils.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ParamUtils.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ParamUtils.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ParamUtils.java
Mon Nov 3 13:07:13 2008
@@ -1,107 +1,107 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.axis2.transport.base;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.util.JavaUtils;
-
-/**
- * Utility class with methods to manipulate service or transport parameters.
- */
-public class ParamUtils {
- private ParamUtils() {}
-
- public static String getRequiredParam(ParameterInclude paramInclude,
String paramName) throws AxisFault {
- Parameter param = paramInclude.getParameter(paramName);
- if (param != null && param.getValue() != null && param.getValue()
instanceof String) {
- return (String) param.getValue();
- } else {
- throw new AxisFault("Cannot find parameter '" + paramName + "' for
"
- + getDescriptionFor(paramInclude));
- }
- }
-
- public static String getOptionalParam(ParameterInclude paramInclude,
String paramName) throws AxisFault {
- Parameter param = paramInclude.getParameter(paramName);
- if (param != null && param.getValue() != null && param.getValue()
instanceof String) {
- return (String) param.getValue();
- } else {
- return null;
- }
- }
-
- public static Integer getOptionalParamInt(ParameterInclude paramInclude,
String paramName) throws AxisFault {
- Parameter param = paramInclude.getParameter(paramName);
- if (param == null || param.getValue() == null) {
- return null;
- } else {
- Object paramValue = param.getValue();
- if (paramValue instanceof Integer) {
- return (Integer)paramValue;
- } else if (paramValue instanceof String) {
- try {
- return Integer.valueOf((String)paramValue);
- } catch (NumberFormatException ex) {
- throw new AxisFault("Invalid value '" + paramValue + "'
for parameter '" + paramName +
- "' for " + getDescriptionFor(paramInclude));
- }
- } else {
- throw new AxisFault("Invalid type for parameter '" + paramName
+ "' for " +
- getDescriptionFor(paramInclude));
- }
- }
- }
-
- public static int getOptionalParamInt(ParameterInclude paramInclude,
String paramName, int defaultValue) throws AxisFault {
- Integer value = getOptionalParamInt(paramInclude, paramName);
- return value == null ? defaultValue : value.intValue();
- }
-
- public static boolean getOptionalParamBoolean(ParameterInclude
paramInclude, String paramName, boolean defaultValue) throws AxisFault {
- Parameter param = paramInclude.getParameter(paramName);
- return param == null ? defaultValue :
JavaUtils.isTrueExplicitly(param.getValue(), defaultValue);
- }
-
- public static int getRequiredParamInt(ParameterInclude paramInclude,
String paramName) throws AxisFault {
- Integer value = getOptionalParamInt(paramInclude, paramName);
- if (value == null) {
- throw new AxisFault("Cannot find parameter '" + paramName +
- "' for " + getDescriptionFor(paramInclude));
- } else {
- return value.intValue();
- }
- }
-
- private static String getDescriptionFor(ParameterInclude paramInclude) {
- if (paramInclude instanceof AxisService) {
- return "service '" + ((AxisService)paramInclude).getName() + "'";
- } else if (paramInclude instanceof TransportInDescription) {
- return "transport receiver '" +
((TransportInDescription)paramInclude).getName() + "'";
- } else if (paramInclude instanceof TransportOutDescription) {
- return "transport sender '" +
((TransportOutDescription)paramInclude).getName() + "'";
- } else {
- return paramInclude.getClass().getName();
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.transport.base;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ParameterInclude;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.util.JavaUtils;
+
+/**
+ * Utility class with methods to manipulate service or transport parameters.
+ */
+public class ParamUtils {
+ private ParamUtils() {}
+
+ public static String getRequiredParam(ParameterInclude paramInclude,
String paramName) throws AxisFault {
+ Parameter param = paramInclude.getParameter(paramName);
+ if (param != null && param.getValue() != null && param.getValue()
instanceof String) {
+ return (String) param.getValue();
+ } else {
+ throw new AxisFault("Cannot find parameter '" + paramName + "' for
"
+ + getDescriptionFor(paramInclude));
+ }
+ }
+
+ public static String getOptionalParam(ParameterInclude paramInclude,
String paramName) throws AxisFault {
+ Parameter param = paramInclude.getParameter(paramName);
+ if (param != null && param.getValue() != null && param.getValue()
instanceof String) {
+ return (String) param.getValue();
+ } else {
+ return null;
+ }
+ }
+
+ public static Integer getOptionalParamInt(ParameterInclude paramInclude,
String paramName) throws AxisFault {
+ Parameter param = paramInclude.getParameter(paramName);
+ if (param == null || param.getValue() == null) {
+ return null;
+ } else {
+ Object paramValue = param.getValue();
+ if (paramValue instanceof Integer) {
+ return (Integer)paramValue;
+ } else if (paramValue instanceof String) {
+ try {
+ return Integer.valueOf((String)paramValue);
+ } catch (NumberFormatException ex) {
+ throw new AxisFault("Invalid value '" + paramValue + "'
for parameter '" + paramName +
+ "' for " + getDescriptionFor(paramInclude));
+ }
+ } else {
+ throw new AxisFault("Invalid type for parameter '" + paramName
+ "' for " +
+ getDescriptionFor(paramInclude));
+ }
+ }
+ }
+
+ public static int getOptionalParamInt(ParameterInclude paramInclude,
String paramName, int defaultValue) throws AxisFault {
+ Integer value = getOptionalParamInt(paramInclude, paramName);
+ return value == null ? defaultValue : value.intValue();
+ }
+
+ public static boolean getOptionalParamBoolean(ParameterInclude
paramInclude, String paramName, boolean defaultValue) throws AxisFault {
+ Parameter param = paramInclude.getParameter(paramName);
+ return param == null ? defaultValue :
JavaUtils.isTrueExplicitly(param.getValue(), defaultValue);
+ }
+
+ public static int getRequiredParamInt(ParameterInclude paramInclude,
String paramName) throws AxisFault {
+ Integer value = getOptionalParamInt(paramInclude, paramName);
+ if (value == null) {
+ throw new AxisFault("Cannot find parameter '" + paramName +
+ "' for " + getDescriptionFor(paramInclude));
+ } else {
+ return value.intValue();
+ }
+ }
+
+ private static String getDescriptionFor(ParameterInclude paramInclude) {
+ if (paramInclude instanceof AxisService) {
+ return "service '" + ((AxisService)paramInclude).getName() + "'";
+ } else if (paramInclude instanceof TransportInDescription) {
+ return "transport receiver '" +
((TransportInDescription)paramInclude).getName() + "'";
+ } else if (paramInclude instanceof TransportOutDescription) {
+ return "transport sender '" +
((TransportOutDescription)paramInclude).getName() + "'";
+ } else {
+ return paramInclude.getClass().getName();
+ }
+ }
+}
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ParamUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/SynchronousCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/TransportListenerEndpointView.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/TransportListenerEndpointViewMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/TransportMBeanSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/TransportView.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/TransportViewMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramDispatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramDispatcherCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/ProcessPacketTask.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/Utils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportError.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/event/TransportErrorSourceSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/threads/NativeThreadFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/threads/NativeWorkerPool.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/threads/WorkerPool.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/threads/WorkerPoolFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/PlainTextFormatterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/pom.xml
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/pom.xml?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/pom.xml (original)
+++ webservices/commons/trunk/modules/transport/modules/http/pom.xml Mon Nov 3
13:07:13 2008
@@ -1,112 +1,112 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport</artifactId>
- <version>SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
- <artifactId>axis2-transport-http</artifactId>
- <name>Apache Axis2 - Transport - HTTP</name>
- <description>This inclues all the available transports in
Axis2</description>
- <packaging>bundle</packaging>
-
- <build>
- <sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test</testSourceDirectory>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Version>1.0</Bundle-Version>
- <Bundle-Name>${pom.artifactId}</Bundle-Name>
- <Bundle-Vendor>Apache Software
Foundation</Bundle-Vendor>
-
<Bundle-Description>${pom.description}</Bundle-Description>
-
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
- <Export-Package>
-
org.apache.axis2.transport.http.*;-split-package:=merge-last,
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <directory>conf</directory>
- <excludes>
- <exclude>**/*.properties</exclude>
- </excludes>
- <filtering>false</filtering>
- </resource>
- <resource>
- <directory>src</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-transport-base</artifactId>
- <version>${axis2-transport-base.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <properties>
- <axis2-transport-base.version>SNAPSHOT</axis2-transport-base.version>
- </properties>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport</artifactId>
+ <version>SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>axis2-transport-http</artifactId>
+ <name>Apache Axis2 - Transport - HTTP</name>
+ <description>This inclues all the available transports in
Axis2</description>
+ <packaging>bundle</packaging>
+
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <testSourceDirectory>test</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Version>1.0</Bundle-Version>
+ <Bundle-Name>${pom.artifactId}</Bundle-Name>
+ <Bundle-Vendor>Apache Software
Foundation</Bundle-Vendor>
+
<Bundle-Description>${pom.description}</Bundle-Description>
+
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Export-Package>
+
org.apache.axis2.transport.http.*;-split-package:=merge-last,
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>conf</directory>
+ <excludes>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ <filtering>false</filtering>
+ </resource>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-base</artifactId>
+ <version>${axis2-transport-base.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <axis2-transport-base.version>SNAPSHOT</axis2-transport-base.version>
+ </properties>
+</project>
Propchange: webservices/commons/trunk/modules/transport/modules/http/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/AbstractAgent.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/AbstractAgent.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/AbstractAgent.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/AbstractAgent.java
Mon Nov 3 13:07:13 2008
@@ -1,168 +1,168 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http;
-
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The AbstractAgent acts as a simple dispatcher for http requests.
- * It delegates incoming requests to processXyz methods while Xyz
- * is the part of the request uri past last /.
- */
-public class AbstractAgent {
- protected static final String DEFAULT_INDEX_JSP = "index.jsp";
-
- private static final String METHOD_PREFIX = "process";
- private static final Log log = LogFactory.getLog(AbstractAgent.class);
-
- protected transient Map operationCache = new HashMap();
- protected transient ConfigurationContext configContext;
-
- public AbstractAgent(ConfigurationContext aConfigContext) {
- configContext = aConfigContext;
- preloadMethods();
- }
-
- public void handle(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse)
- throws IOException, ServletException {
-
-
- String requestURI = httpServletRequest.getRequestURI();
-
- String operation;
- int i = requestURI.lastIndexOf('/');
- if (i < 0) {
- processUnknown(httpServletRequest, httpServletResponse);
- return;
- } else if (i == requestURI.length() - 1) {
- processIndex(httpServletRequest, httpServletResponse);
- return;
- } else {
- operation = requestURI.substring(i + 1);
- }
-
-
- Method method = (Method) operationCache.get(operation.toLowerCase());
- if (method != null) {
- try {
- method.invoke(this, new Object[]{httpServletRequest,
httpServletResponse});
- } catch (Exception e) {
- log.warn("Error dispatching request " + requestURI, e);
-
httpServletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
- } else {
- processUnknown(httpServletRequest, httpServletResponse);
- }
- }
-
- /**
- * Callback method for index page. Forwards to [EMAIL PROTECTED]
DEFAULT_INDEX_JSP} by default.
- *
- * @param httpServletRequest The incoming request.
- * @param httpServletResponse The outgoing response.
- */
- protected void processIndex(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse)
- throws IOException, ServletException {
- renderView(DEFAULT_INDEX_JSP, httpServletRequest, httpServletResponse);
- }
-
- /**
- * Callback method for unknown/unsupported requests. Returns HTTP Status
404 by default.
- *
- * @param httpServletRequest The incoming request.
- * @param httpServletResponse The outgoing response.
- */
-
- protected void processUnknown(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse)
- throws IOException, ServletException {
- httpServletResponse
- .sendError(HttpServletResponse.SC_NOT_FOUND,
httpServletRequest.getRequestURI());
- }
-
-
- protected void renderView(String jspName,
- HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse)
- throws IOException, ServletException {
- httpServletResponse.setContentType("text/html");
- try {
-
httpServletRequest.getRequestDispatcher(Constants.AXIS_WEB_CONTENT_ROOT +
jspName)
- .include(httpServletRequest, httpServletResponse);
- } catch (Throwable t) {
- log.info("Old Servlet API :" + t);
- }
- }
-
- private void preloadMethods() {
- Class clazz = getClass();
- while (clazz != null && !clazz.equals(Object.class)) {
- examineMethods(clazz.getDeclaredMethods());
- clazz = clazz.getSuperclass();
- }
- }
-
- private void examineMethods(Method[] aDeclaredMethods) {
- for (int i = 0; i < aDeclaredMethods.length; i++) {
- Method method = aDeclaredMethods[i];
-
- Class[] parameterTypes = method.getParameterTypes();
- if (
- (Modifier.isProtected(method.getModifiers()) ||
- Modifier.isPublic(method.getModifiers())) &&
- method.getName().startsWith(METHOD_PREFIX) &&
- parameterTypes.length == 2 &&
- parameterTypes[0].equals(HttpServletRequest.class)
&&
-
parameterTypes[1].equals(HttpServletResponse.class)) {
-
- String key =
method.getName().substring(METHOD_PREFIX.length()).toLowerCase();
-
- // ensure we don't overwrite existing method with superclass
method
- if (!operationCache.containsKey(key)) {
- operationCache.put(key, method);
- }
- }
- }
- }
-
- protected void populateSessionInformation(HttpServletRequest req) {
- HashMap services = configContext.getAxisConfiguration().getServices();
- try {
- req.getSession().setAttribute(Constants.SERVICE_MAP, services);
- req.getSession().setAttribute(Constants.SERVICE_PATH,
configContext.getServicePath());
- } catch (Throwable t){
- log.info("Old Servlet API :" + t);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The AbstractAgent acts as a simple dispatcher for http requests.
+ * It delegates incoming requests to processXyz methods while Xyz
+ * is the part of the request uri past last /.
+ */
+public class AbstractAgent {
+ protected static final String DEFAULT_INDEX_JSP = "index.jsp";
+
+ private static final String METHOD_PREFIX = "process";
+ private static final Log log = LogFactory.getLog(AbstractAgent.class);
+
+ protected transient Map operationCache = new HashMap();
+ protected transient ConfigurationContext configContext;
+
+ public AbstractAgent(ConfigurationContext aConfigContext) {
+ configContext = aConfigContext;
+ preloadMethods();
+ }
+
+ public void handle(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse)
+ throws IOException, ServletException {
+
+
+ String requestURI = httpServletRequest.getRequestURI();
+
+ String operation;
+ int i = requestURI.lastIndexOf('/');
+ if (i < 0) {
+ processUnknown(httpServletRequest, httpServletResponse);
+ return;
+ } else if (i == requestURI.length() - 1) {
+ processIndex(httpServletRequest, httpServletResponse);
+ return;
+ } else {
+ operation = requestURI.substring(i + 1);
+ }
+
+
+ Method method = (Method) operationCache.get(operation.toLowerCase());
+ if (method != null) {
+ try {
+ method.invoke(this, new Object[]{httpServletRequest,
httpServletResponse});
+ } catch (Exception e) {
+ log.warn("Error dispatching request " + requestURI, e);
+
httpServletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+ } else {
+ processUnknown(httpServletRequest, httpServletResponse);
+ }
+ }
+
+ /**
+ * Callback method for index page. Forwards to [EMAIL PROTECTED]
DEFAULT_INDEX_JSP} by default.
+ *
+ * @param httpServletRequest The incoming request.
+ * @param httpServletResponse The outgoing response.
+ */
+ protected void processIndex(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse)
+ throws IOException, ServletException {
+ renderView(DEFAULT_INDEX_JSP, httpServletRequest, httpServletResponse);
+ }
+
+ /**
+ * Callback method for unknown/unsupported requests. Returns HTTP Status
404 by default.
+ *
+ * @param httpServletRequest The incoming request.
+ * @param httpServletResponse The outgoing response.
+ */
+
+ protected void processUnknown(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse)
+ throws IOException, ServletException {
+ httpServletResponse
+ .sendError(HttpServletResponse.SC_NOT_FOUND,
httpServletRequest.getRequestURI());
+ }
+
+
+ protected void renderView(String jspName,
+ HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse)
+ throws IOException, ServletException {
+ httpServletResponse.setContentType("text/html");
+ try {
+
httpServletRequest.getRequestDispatcher(Constants.AXIS_WEB_CONTENT_ROOT +
jspName)
+ .include(httpServletRequest, httpServletResponse);
+ } catch (Throwable t) {
+ log.info("Old Servlet API :" + t);
+ }
+ }
+
+ private void preloadMethods() {
+ Class clazz = getClass();
+ while (clazz != null && !clazz.equals(Object.class)) {
+ examineMethods(clazz.getDeclaredMethods());
+ clazz = clazz.getSuperclass();
+ }
+ }
+
+ private void examineMethods(Method[] aDeclaredMethods) {
+ for (int i = 0; i < aDeclaredMethods.length; i++) {
+ Method method = aDeclaredMethods[i];
+
+ Class[] parameterTypes = method.getParameterTypes();
+ if (
+ (Modifier.isProtected(method.getModifiers()) ||
+ Modifier.isPublic(method.getModifiers())) &&
+ method.getName().startsWith(METHOD_PREFIX) &&
+ parameterTypes.length == 2 &&
+ parameterTypes[0].equals(HttpServletRequest.class)
&&
+
parameterTypes[1].equals(HttpServletResponse.class)) {
+
+ String key =
method.getName().substring(METHOD_PREFIX.length()).toLowerCase();
+
+ // ensure we don't overwrite existing method with superclass
method
+ if (!operationCache.containsKey(key)) {
+ operationCache.put(key, method);
+ }
+ }
+ }
+ }
+
+ protected void populateSessionInformation(HttpServletRequest req) {
+ HashMap services = configContext.getAxisConfiguration().getServices();
+ try {
+ req.getSession().setAttribute(Constants.SERVICE_MAP, services);
+ req.getSession().setAttribute(Constants.SERVICE_PATH,
configContext.getServicePath());
+ } catch (Throwable t){
+ log.info("Old Servlet API :" + t);
+ }
+ }
+}
Propchange:
webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/AbstractAgent.java
------------------------------------------------------------------------------
svn:eol-style = native