You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/09/16 14:47:04 UTC
svn commit: r695841 - in
/servicemix/components/bindings/servicemix-http/trunk/src:
main/java/org/apache/servicemix/http/
main/java/org/apache/servicemix/http/endpoints/
main/java/org/apache/servicemix/http/processors/
test/java/org/apache/servicemix/h...
Author: gnodet
Date: Tue Sep 16 05:47:03 2008
New Revision: 695841
URL: http://svn.apache.org/viewvc?rev=695841&view=rev
Log:
SM-1576: Change endpoints lifecycle to use activate / start / stop / deactivate
Modified:
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpComponent.java
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java
servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java
servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpProviderTest.java
servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpXBeanDeployerTest.java
servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpComponent.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpComponent.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpComponent.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpComponent.java Tue Sep 16 05:47:03 2008
@@ -31,6 +31,7 @@
import org.apache.servicemix.common.Deployer;
import org.apache.servicemix.common.Endpoint;
import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.DefaultServiceUnit;
import org.apache.servicemix.common.util.IntrospectionSupport;
import org.apache.servicemix.common.util.URISupport;
import org.apache.servicemix.common.security.AuthenticationService;
@@ -218,7 +219,6 @@
}
protected void doInit() throws Exception {
- super.doInit();
// Load configuration
configuration.setRootDir(context.getWorkspaceRoot());
configuration.setComponentName(context.getComponentName());
@@ -271,6 +271,9 @@
}
server.setConfiguration(configuration);
server.init();
+ server.start();
+ // Default initalization
+ super.doInit();
}
protected void doShutDown() throws Exception {
@@ -278,6 +281,7 @@
if (server != null) {
ContextManager s = server;
server = null;
+ s.stop();
s.shutDown();
}
if (connectionPool != null) {
@@ -292,13 +296,11 @@
}
protected void doStart() throws Exception {
- server.start();
super.doStart();
}
protected void doStop() throws Exception {
super.doStop();
- server.stop();
}
protected String[] getEPRProtocols() {
@@ -308,8 +310,8 @@
protected Endpoint getResolvedEPR(ServiceEndpoint ep) throws Exception {
// We receive an exchange for an EPR that has not been used yet.
// Register a provider endpoint and restart processing.
- HttpEndpoint httpEp = new HttpEndpoint();
- httpEp.setServiceUnit(new ServiceUnit(component));
+ HttpEndpoint httpEp = new HttpEndpoint(true);
+ httpEp.setServiceUnit(new DefaultServiceUnit(component));
httpEp.setService(ep.getServiceName());
httpEp.setEndpoint(ep.getEndpointName());
httpEp.setRole(MessageExchange.Role.PROVIDER);
@@ -321,7 +323,6 @@
if (httpEp.getLocationURI() == null) {
httpEp.setLocationURI(uri.toString());
}
- httpEp.activateDynamic();
return httpEp;
}
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpEndpoint.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpEndpoint.java Tue Sep 16 05:47:03 2008
@@ -30,7 +30,6 @@
import javax.wsdl.extensions.http.HTTPAddress;
import javax.xml.namespace.QName;
-import org.apache.servicemix.common.ExchangeProcessor;
import org.apache.servicemix.common.ExternalEndpoint;
import org.apache.servicemix.common.ManagementSupport;
import org.apache.servicemix.common.security.AuthenticationService;
@@ -39,6 +38,7 @@
import org.apache.servicemix.http.processors.ProviderProcessor;
import org.apache.servicemix.http.tools.PortTypeDecorator;
import org.apache.servicemix.soap.SoapEndpoint;
+import org.apache.servicemix.soap.SoapExchangeProcessor;
import com.ibm.wsdl.extensions.http.HTTPAddressImpl;
@@ -62,6 +62,13 @@
protected boolean wantContentTypeHeaderFromExchangeIntoHttpRequest;
protected int timeout;
+ public HttpEndpoint() {
+ }
+
+ public HttpEndpoint(boolean dynamic) {
+ super(dynamic);
+ }
+
/**
* Determines if the HTTP provider processor copies the HTTP headers from the HTTP response into the JBI exchange.
*
@@ -375,11 +382,11 @@
}
}
- protected ExchangeProcessor createProviderProcessor() {
+ protected SoapExchangeProcessor createProviderProcessor() {
return new ProviderProcessor(this);
}
- protected ExchangeProcessor createConsumerProcessor() {
+ protected SoapExchangeProcessor createConsumerProcessor() {
return new ConsumerProcessor(this);
}
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/HttpWsdl1Deployer.java Tue Sep 16 05:47:03 2008
@@ -24,6 +24,7 @@
import org.apache.servicemix.common.Endpoint;
import org.apache.servicemix.common.ServiceMixComponent;
+import org.apache.servicemix.common.endpoints.AbstractEndpoint;
import org.apache.servicemix.common.wsdl1.AbstractWsdl1Deployer;
import org.apache.servicemix.common.wsdl1.JbiEndpoint;
@@ -43,7 +44,7 @@
* @see org.servicemix.common.wsdl1.AbstractWsdl1Deployer#createEndpoint(javax.wsdl.extensions.ExtensibilityElement,
* javax.wsdl.extensions.ExtensibilityElement)
*/
- protected Endpoint createEndpoint(ExtensibilityElement portElement, ExtensibilityElement bindingElement,
+ protected AbstractEndpoint createEndpoint(ExtensibilityElement portElement, ExtensibilityElement bindingElement,
JbiEndpoint jbiEndpoint) {
if (jbiEndpoint == null) {
return null;
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java Tue Sep 16 05:47:03 2008
@@ -78,6 +78,8 @@
private Map<String, MessageExchange> exchanges = new ConcurrentHashMap<String, MessageExchange>();
private Object httpContext;
+ private boolean started = false;
+
public HttpConsumerEndpoint() {
super();
}
@@ -206,15 +208,25 @@
this.defaultMep = defaultMep;
}
- public void start() throws Exception {
- super.start();
+ public void activate() throws Exception {
+ super.activate();
loadStaticResources();
httpContext = getServerManager().createContext(locationURI, this);
}
- public void stop() throws Exception {
+ public void deactivate() throws Exception {
getServerManager().remove(httpContext);
httpContext = null;
+ super.deactivate();
+ }
+
+ public void start() throws Exception {
+ super.start();
+ started = true;
+ }
+
+ public void stop() throws Exception {
+ started = false;
super.stop();
}
@@ -252,6 +264,11 @@
if (handleStaticResource(request, response)) {
return;
}
+ // Check endpoint is started
+ if (!started) {
+ response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Endpoint is stopped");
+ return;
+ }
// Not giving a specific mutex will synchronize on the continuation
// itself
Continuation cont = ContinuationSupport.getContinuation(request, null);
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Tue Sep 16 05:47:03 2008
@@ -40,7 +40,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.common.JbiConstants;
import org.apache.servicemix.common.EndpointComponentContext;
-import org.apache.servicemix.common.ExchangeProcessor;
import org.apache.servicemix.http.ContextManager;
import org.apache.servicemix.http.HttpComponent;
import org.apache.servicemix.http.HttpEndpoint;
@@ -51,6 +50,7 @@
import org.apache.servicemix.soap.Context;
import org.apache.servicemix.soap.SoapFault;
import org.apache.servicemix.soap.SoapHelper;
+import org.apache.servicemix.soap.SoapExchangeProcessor;
import org.apache.servicemix.soap.marshalers.JBIMarshaler;
import org.apache.servicemix.soap.marshalers.SoapMessage;
import org.apache.servicemix.soap.marshalers.SoapWriter;
@@ -58,7 +58,7 @@
import org.mortbay.util.ajax.Continuation;
import org.mortbay.util.ajax.ContinuationSupport;
-public class ConsumerProcessor extends AbstractProcessor implements ExchangeProcessor, HttpProcessor {
+public class ConsumerProcessor extends AbstractProcessor implements SoapExchangeProcessor, HttpProcessor {
private static Log log = LogFactory.getLog(ConsumerProcessor.class);
@@ -69,6 +69,7 @@
protected Map<String, Continuation> locks;
protected Map<String, MessageExchange> exchanges;
protected int suspentionTime = 60000;
+ protected boolean started = false;
public ConsumerProcessor(HttpEndpoint endpoint) {
super(endpoint);
@@ -106,17 +107,25 @@
}
}
- public void start() throws Exception {
+ public void init() throws Exception {
String url = endpoint.getLocationURI();
context = new EndpointComponentContext(endpoint);
channel = context.getDeliveryChannel();
httpContext = getServerManager().createContext(url, this);
}
- public void stop() throws Exception {
+ public void shutdown() throws Exception {
getServerManager().remove(httpContext);
}
+ public void start() throws Exception {
+ started = true;
+ }
+
+ public void stop() throws Exception {
+ started = false;
+ }
+
public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Receiving HTTP request: " + request);
@@ -125,6 +134,10 @@
processGetRequest(request, response);
return;
}
+ if (!started) {
+ response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Endpoint is stopped");
+ return;
+ }
if (!"POST".equals(request.getMethod())) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, request.getMethod() + " not supported");
return;
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java Tue Sep 16 05:47:03 2008
@@ -51,12 +51,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.common.JbiConstants;
-import org.apache.servicemix.common.ExchangeProcessor;
import org.apache.servicemix.common.security.KeystoreManager;
import org.apache.servicemix.http.HttpComponent;
import org.apache.servicemix.http.HttpEndpoint;
import org.apache.servicemix.soap.Context;
import org.apache.servicemix.soap.SoapHelper;
+import org.apache.servicemix.soap.SoapExchangeProcessor;
import org.apache.servicemix.soap.marshalers.SoapMessage;
import org.apache.servicemix.soap.marshalers.SoapReader;
import org.apache.servicemix.soap.marshalers.SoapWriter;
@@ -67,7 +67,7 @@
* @version $Revision: 370186 $
* @since 3.0
*/
-public class ProviderProcessor extends AbstractProcessor implements ExchangeProcessor {
+public class ProviderProcessor extends AbstractProcessor implements SoapExchangeProcessor {
private static Log log = LogFactory.getLog(ProviderProcessor.class);
@@ -292,13 +292,19 @@
return host;
}
- public void start() throws Exception {
+ public void init() throws Exception {
channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel();
}
+ public void start() throws Exception {
+ }
+
public void stop() throws Exception {
}
+ public void shutdown() throws Exception {
+ }
+
protected Map<String, String> getHeaders(HttpServletRequest request) {
Map<String, String> headers = new HashMap<String, String>();
Enumeration<?> enumeration = request.getHeaderNames();
Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java Tue Sep 16 05:47:03 2008
@@ -56,9 +56,12 @@
fail("Received ERROR status");
}
} else if (me.getFault() != null) {
- fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
+ String txt = new SourceTransformer().toString(me.getFault().getContent());
+ client.done(me);
+ fail("Received fault: " + txt);
} else {
Node node = new SourceTransformer().toDOMNode(me.getOutMessage());
+ client.done(me);
log.info(new SourceTransformer().toString(node));
assertEquals("myid", textValueOfXPath(node, "//*[local-name()='RelatesTo']"));
assertNotNull(textValueOfXPath(node, "//*[local-name()='MessageID']"));
Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java Tue Sep 16 05:47:03 2008
@@ -91,6 +91,7 @@
File path = new File(new URI(url.toString()));
path = path.getParentFile();
component.getServiceUnitManager().deploy("consumer", path.getAbsolutePath());
+ component.getServiceUnitManager().init("consumer", path.getAbsolutePath());
component.getServiceUnitManager().start("consumer");
// Call it
@@ -138,6 +139,7 @@
File path = new File(new URI(url.toString()));
path = path.getParentFile();
component.getServiceUnitManager().deploy("consumer", path.getAbsolutePath());
+ component.getServiceUnitManager().init("consumer", path.getAbsolutePath());
component.getServiceUnitManager().start("consumer");
// Retrieve WSDL
Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpProviderTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpProviderTest.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpProviderTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpProviderTest.java Tue Sep 16 05:47:03 2008
@@ -88,6 +88,7 @@
File path = new File(new URI(url.toString()));
path = path.getParentFile();
component.getServiceUnitManager().deploy("provider", path.getAbsolutePath());
+ component.getServiceUnitManager().init("provider", path.getAbsolutePath());
component.getServiceUnitManager().start("provider");
// Call it
@@ -147,6 +148,7 @@
File path = new File(new URI(url.toString()));
path = path.getParentFile();
component.getServiceUnitManager().deploy("provider", path.getAbsolutePath());
+ component.getServiceUnitManager().init("provider", path.getAbsolutePath());
component.getServiceUnitManager().start("provider");
// Call it
@@ -198,6 +200,7 @@
File path = new File(new URI(url.toString()));
path = path.getParentFile();
component.getServiceUnitManager().deploy("provider", path.getAbsolutePath());
+ component.getServiceUnitManager().init("provider", path.getAbsolutePath());
component.getServiceUnitManager().start("provider");
// Call it
Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpXBeanDeployerTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpXBeanDeployerTest.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpXBeanDeployerTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpXBeanDeployerTest.java Tue Sep 16 05:47:03 2008
@@ -111,6 +111,7 @@
File path = new File(new URI(url.toString()));
path = path.getParentFile();
component.getServiceUnitManager().deploy("xbean", path.getAbsolutePath());
+ component.getServiceUnitManager().init("xbean", path.getAbsolutePath());
component.getServiceUnitManager().start("xbean");
// Test wsdls
Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java?rev=695841&r1=695840&r2=695841&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java Tue Sep 16 05:47:03 2008
@@ -114,8 +114,8 @@
+ " </jbi:part>"
+ "</jbi:message>"));
client.sendSync(me);
-
System.err.println(new SourceTransformer().contentToString(me.getOutMessage()));
+ client.done(me);
}
public void testSoap() throws Exception {
@@ -168,7 +168,7 @@
+ " </jbi:part>"
+ "</jbi:message>"));
client.sendSync(me);
-
+ client.done(me);
assertEquals("\"urn:myaction\"", soapAction.get());
}
@@ -350,7 +350,7 @@
+ " </jbi:part>"
+ "</jbi:message>"));
client.sendSync(me);
-
System.err.println(new SourceTransformer().contentToString(me.getOutMessage()));
+ client.done(me);
}
}