You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2006/09/24 07:15:13 UTC
svn commit: r449361 - in /webservices/axis2/trunk/java/modules/kernel: conf/
src/org/apache/axis2/ src/org/apache/axis2/context/
src/org/apache/axis2/deployment/ src/org/apache/axis2/transport/http/
Author: chinthaka
Date: Sat Sep 23 22:15:12 2006
New Revision: 449361
URL: http://svn.apache.org/viewvc?view=rev&rev=449361
Log:
Making REST path also configurable
Returning REST EPR from AxisServlet as a supported EPR
Modified:
webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
Modified: webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml?view=diff&rev=449361&r1=449360&r2=449361
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Sat Sep 23 22:15:12 2006
@@ -28,8 +28,17 @@
<parameter name="userName" locked="false">admin</parameter>
<parameter name="password" locked="false">axis2</parameter>
+ <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+ <!--root which can configured using the following contextRoot parameter-->
<!--<parameter name="contextRoot" locked="false">axis2</parameter>-->
+
+ <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distingiush those endpoints-->
+ <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this -->
+ <!--context path to proper Axis2 servlets-->
<!--<parameter name="servicePath" locked="false">services</parameter>-->
+ <!--<parameter name="restPath" locked="false">rest</parameter>-->
+
+
<!--Set the flag to true if you want to enable transport level session mangment-->
<parameter name="manageTransportSession" locked="false">false</parameter>
@@ -75,20 +84,20 @@
<transportReceiver name="http"
class="org.apache.axis2.transport.http.SimpleHTTPServer">
<parameter name="port" locked="false">6060</parameter>
- <!-- Here is the complete list of supported parameters (see example settings further below):
- port: the port to listen on (default 6060)
- hostname: if non-null, url prefix used in reply-to endpoint references (default null)
- originServer: value of http Server header in outgoing messages (default "Simple-Server/1.1")
- requestTimeout: value in millis of time that requests can wait for data (default 20000)
- requestTcpNoDelay: true to maximize performance and minimize latency (default true)
- false to minimize bandwidth consumption by combining segments
- requestCoreThreadPoolSize: number of threads available for request processing (unless queue fills up) (default 25)
- requestMaxThreadPoolSize: number of threads available for request processing if queue fills us (default 150)
- note that default queue never fills up: see HttpFactory
- threadKeepAliveTime: time to keep threads in excess of core size alive while inactive (default 180)
- note that no such threads can exist with default unbounded request queue
- threadKeepAliveTimeUnit: TimeUnit of value in threadKeepAliveTime (default SECONDS) (default SECONDS)
- -->
+ <!-- Here is the complete list of supported parameters (see example settings further below):
+ port: the port to listen on (default 6060)
+ hostname: if non-null, url prefix used in reply-to endpoint references (default null)
+ originServer: value of http Server header in outgoing messages (default "Simple-Server/1.1")
+ requestTimeout: value in millis of time that requests can wait for data (default 20000)
+ requestTcpNoDelay: true to maximize performance and minimize latency (default true)
+ false to minimize bandwidth consumption by combining segments
+ requestCoreThreadPoolSize: number of threads available for request processing (unless queue fills up) (default 25)
+ requestMaxThreadPoolSize: number of threads available for request processing if queue fills us (default 150)
+ note that default queue never fills up: see HttpFactory
+ threadKeepAliveTime: time to keep threads in excess of core size alive while inactive (default 180)
+ note that no such threads can exist with default unbounded request queue
+ threadKeepAliveTimeUnit: TimeUnit of value in threadKeepAliveTime (default SECONDS) (default SECONDS)
+ -->
<!-- <parameter name="hostname" locked="false">http://www.myApp.com/ws</parameter> -->
<!-- <parameter name="originServer" locked="false">My-Server/1.1</parameter> -->
<!-- <parameter name="requestTimeout" locked="false">10000</parameter> -->
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?view=diff&rev=449361&r1=449360&r2=449361
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Sat Sep 23 22:15:12 2006
@@ -75,6 +75,7 @@
* To chenage the service path to somthing else
*/
public static final String PARAM_SERVICE_PATH = "servicePath";
+ public static final String PARAM_REST_PATH = "restPath";
//Parameter name for transport session managemntt
public static final String MANAGE_TRANSPORT_SESSION = "manageTransportSession";
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java?view=diff&rev=449361&r1=449360&r2=449361
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java Sat Sep 23 22:15:12 2006
@@ -19,7 +19,6 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
-import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.description.Parameter;
@@ -27,6 +26,7 @@
import org.apache.axis2.engine.DependencyManager;
import org.apache.axis2.engine.ListenerManager;
import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.util.SessionUtils;
import org.apache.axis2.util.UUIDGenerator;
import org.apache.axis2.util.threadpool.ThreadFactory;
@@ -62,6 +62,7 @@
//To specify url mapping for services
private String contextRoot = "axis2";
private String servicePath = "services";
+ private String restPath = "rest";
//To have your own context path
public ConfigurationContext(AxisConfiguration axisConfiguration) {
@@ -121,13 +122,13 @@
axisServiceGroup = (AxisServiceGroup) messageContext.getAxisService().getParent();
}
serviceGroupContext = new ServiceGroupContext(messageContext.getConfigurationContext(),
- axisServiceGroup);
+ axisServiceGroup);
applicationSessionServiceGroupContextTable.put(serviceGroupName, serviceGroupContext);
}
serviceContext = serviceGroupContext.getServiceContext(axisService);
} else if (!isNull(serviceGroupContextId)
- && (getServiceGroupContext(serviceGroupContextId, messageContext) != null)) {
+ && (getServiceGroupContext(serviceGroupContextId, messageContext) != null)) {
// SGC is already there
serviceGroupContext =
@@ -256,8 +257,8 @@
}
}
if (serviceGroupContext == null
- && msgContext != null
- && msgContext.getSessionContext() != null) {
+ && msgContext != null
+ && msgContext.getSessionContext() != null) {
serviceGroupContext = msgContext.getSessionContext().getServiceGroupContext(
serviceGroupContextId);
}
@@ -331,7 +332,7 @@
ServiceGroupContext serviceGroupContext =
(ServiceGroupContext) serviceGroupContextMap.get(sgCtxtId);
if ((currentTime - serviceGroupContext.getLastTouchedTime()) >
- getServiceGroupContextTimoutInterval()) {
+ getServiceGroupContextTimoutInterval()) {
sgCtxtMapKeyIter.remove();
cleanupServiceContexts(serviceGroupContext);
}
@@ -382,10 +383,10 @@
public String getServiceContextPath() {
String ctxRoot = getContextRoot().trim();
String path = "/";
- if(!ctxRoot.equals("/")){
- path = ctxRoot + "/";
+ if (!ctxRoot.equals("/")) {
+ path = ctxRoot + "/";
}
- if(servicePath == null || servicePath.trim().length() == 0){
+ if (servicePath == null || servicePath.trim().length() == 0) {
throw new IllegalArgumentException("service path cannot be null or empty");
} else {
path += servicePath.trim();
@@ -393,13 +394,34 @@
return path;
}
+ public String getRESTContextPath() {
+ String ctxRoot = getContextRoot().trim();
+ String path = "/";
+ if (!ctxRoot.equals("/")) {
+ path = ctxRoot + "/";
+ }
+ if (restPath == null || restPath.trim().length() == 0) {
+ throw new IllegalArgumentException("service path cannot be null or empty");
+ } else {
+ path += restPath.trim();
+ }
+ return path;
+ }
+
public String getServicePath() {
- if(servicePath == null || servicePath.trim().length() == 0){
+ if (servicePath == null || servicePath.trim().length() == 0) {
throw new IllegalArgumentException("service path cannot be null or empty");
}
return servicePath.trim();
}
+ public String getRESTPath() {
+ if (restPath == null || restPath.trim().length() == 0) {
+ throw new IllegalArgumentException("REST path cannot be null or empty");
+ }
+ return restPath.trim();
+ }
+
public String getContextRoot() {
if (contextRoot == null || contextRoot.trim().length() == 0) {
throw new IllegalArgumentException("context root cannot be null or empty");
@@ -409,6 +431,10 @@
public void setServicePath(String servicePath) {
this.servicePath = servicePath;
+ }
+
+ public void setRESTPath(String restPath) {
+ this.restPath = restPath;
}
public void setContextRoot(String contextRoot) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java?view=diff&rev=449361&r1=449360&r2=449361
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java Sat Sep 23 22:15:12 2006
@@ -125,6 +125,14 @@
configContext.setServicePath(spath);
}
}
+
+ Parameter restPathParam = axisConfig.getParameter(Constants.PARAM_REST_PATH);
+ if (restPathParam != null) {
+ String restPath = ((String) restPathParam.getValue()).trim();
+ if (restPath.length() > 0) {
+ configContext.setServicePath(restPath);
+ }
+ }
}
/**
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml?view=diff&rev=449361&r1=449360&r2=449361
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml Sat Sep 23 22:15:12 2006
@@ -20,8 +20,14 @@
<parameter name="userName" locked="false">admin</parameter>
<parameter name="password" locked="false">axis2</parameter>
+ <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+ <!--root which can configured using the following contextRoot parameter-->
<!--<parameter name="contextRoot" locked="false">axis2</parameter>-->
+
+ <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distingiush those endpoints-->
<!--<parameter name="servicePath" locked="false">services</parameter>-->
+ <!--<parameter name="restPath" locked="false">rest</parameter>-->
+
<!--Set the flag to true if you want to enable transport level session mangment-->
<parameter name="manageTransportSession" locked="false">false</parameter>
@@ -53,7 +59,7 @@
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</messageReceivers>
-
+
<!-- ================================================= -->
<!-- Target Resolvers -->
<!-- ================================================= -->
@@ -63,8 +69,8 @@
<!--<targetResolvers>-->
<!--<targetResolver class="" />-->
<!--</targetResolvers>-->
-
-
+
+
<!-- ================================================= -->
<!-- Transport Ins -->
<!-- ================================================= -->
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?view=diff&rev=449361&r1=449360&r2=449361
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java Sat Sep 23 22:15:12 2006
@@ -437,10 +437,19 @@
throw new AxisFault(e);
}
}
+
+
EndpointReference soapEndpoint = new EndpointReference("http://" + ip + ":" + port + '/' +
configContext.getServiceContextPath() + "/" + serviceName);
- return new EndpointReference[]{soapEndpoint};
+ if (!disableREST && !disableSeperateEndpointForREST) {
+ EndpointReference restEndpoint = new EndpointReference("http://" + ip + ":" + port + '/' +
+ configContext.getRESTContextPath() + "/" + serviceName);
+ return new EndpointReference[]{soapEndpoint, restEndpoint};
+ } else {
+ return new EndpointReference[]{soapEndpoint};
+ }
+
}
protected MessageContext createMessageContext(HttpServletRequest req,
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org