You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2009/04/02 23:36:02 UTC
svn commit: r761436 - in /ode/trunk/axis2/src/main/java/org/apache/ode/axis2:
BindingContextImpl.java ODEServer.java service/DeploymentWebService.java
Author: midon
Date: Thu Apr 2 21:36:02 2009
New Revision: 761436
URL: http://svn.apache.org/viewvc?rev=761436&view=rev
Log:
Spring Clean-up: move service lifecycle methods from ODEServer to BindingContextImpl
Modified:
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java?rev=761436&r1=761435&r2=761436&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/BindingContextImpl.java Thu Apr 2 21:36:02 2009
@@ -21,17 +21,24 @@
package org.apache.ode.axis2;
import org.apache.axis2.AxisFault;
-import org.apache.ode.bpel.iapi.BindingContext;
-import org.apache.ode.bpel.iapi.ContextException;
-import org.apache.ode.bpel.iapi.Endpoint;
-import org.apache.ode.bpel.iapi.EndpointReference;
-import org.apache.ode.bpel.iapi.PartnerRoleChannel;
-import org.apache.ode.bpel.iapi.ProcessConf;
-import org.apache.ode.bpel.iapi.ProcessStore;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.commons.collections.map.MultiKeyMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.axis2.hooks.ODEAxisService;
+import org.apache.ode.axis2.hooks.ODEMessageReceiver;
+import org.apache.ode.axis2.httpbinding.HttpExternalService;
+import org.apache.ode.axis2.soapbinding.SoapExternalService;
+import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.utils.wsdl.WsdlUtils;
import javax.wsdl.Definition;
import javax.wsdl.PortType;
import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Iterator;
/**
* AXIS2 implementation of the {@link org.apache.ode.bpel.iapi.BindingContext}
@@ -41,22 +48,23 @@
*
*/
public class BindingContextImpl implements BindingContext {
+ protected final Log __log = LogFactory.getLog(getClass());
+
private ODEServer _server;
- private ProcessStore _store;
+ private MultiKeyMap _services = new MultiKeyMap();
- public BindingContextImpl(ODEServer server, ProcessStore store) {
+ public BindingContextImpl(ODEServer server) {
_server = server;
- _store = store;
}
public EndpointReference activateMyRoleEndpoint(QName processId, Endpoint myRoleEndpoint) {
try {
- ProcessConf pconf = _store.getProcessConfiguration(processId);
+ ProcessConf pconf = _server._store.getProcessConfiguration(processId);
Definition wsdl = pconf.getDefinitionForService(myRoleEndpoint.serviceName);
if (wsdl == null)
throw new ContextException("Unable to access WSDL definition to activate MyRole endpoint for service " + myRoleEndpoint.serviceName
+ " and port " + myRoleEndpoint.portName);
- ODEService svc = _server.createService(pconf, myRoleEndpoint.serviceName, myRoleEndpoint.portName);
+ ODEService svc = createService(pconf, myRoleEndpoint.serviceName, myRoleEndpoint.portName);
return svc.getMyServiceRef();
} catch (AxisFault axisFault) {
throw new ContextException("Could not activate endpoint for service " + myRoleEndpoint.serviceName
@@ -65,20 +73,100 @@
}
public void deactivateMyRoleEndpoint(Endpoint myRoleEndpoint) {
- _server.destroyService(myRoleEndpoint.serviceName, myRoleEndpoint.portName);
+ destroyService(myRoleEndpoint.serviceName, myRoleEndpoint.portName);
}
public PartnerRoleChannel createPartnerRoleChannel(QName processId, PortType portType,
Endpoint initialPartnerEndpoint) {
// NOTE: This implementation assumes that the initial value of the
// partner role determines the binding.
- ProcessConf pconf = _store.getProcessConfiguration(processId);
+ ProcessConf pconf = _server._store.getProcessConfiguration(processId);
Definition wsdl = pconf.getDefinitionForService(initialPartnerEndpoint.serviceName);
if (wsdl == null) {
throw new ContextException("Cannot find definition for service " + initialPartnerEndpoint.serviceName
- + " in the context of process "+processId);
+ + " in the context of process " + processId);
+ }
+ return createExternalService(pconf, initialPartnerEndpoint.serviceName, initialPartnerEndpoint.portName);
+ }
+
+ protected ODEService createService(ProcessConf pconf, QName serviceName, String portName) throws AxisFault {
+ AxisService axisService = ODEAxisService.createService(_server._axisConfig, pconf, serviceName, portName);
+ ODEService odeService = new ODEService(axisService, pconf, serviceName, portName, _server._bpelServer);
+
+ destroyService(serviceName, portName);
+ _services.put(serviceName, portName, odeService);
+
+ // Setting our new service on the ODE receiver
+ Iterator operationIterator = axisService.getOperations();
+ while (operationIterator.hasNext()) {
+ AxisOperation op = (AxisOperation) operationIterator.next();
+ if (op.getMessageReceiver() instanceof ODEMessageReceiver) {
+ ((ODEMessageReceiver) op.getMessageReceiver()).setService(odeService);
+ break;
+ }
+ }
+
+ // We're public!
+ _server._axisConfig.addService(axisService);
+ __log.debug("Created Axis2 service " + serviceName);
+ return odeService;
+ }
+
+
+ protected void destroyService(QName serviceName, String portName) {
+ __log.debug("Destroying service " + serviceName + " port " + portName);
+ ODEService service = (ODEService) _services.remove(serviceName, portName);
+ if (service != null) {
+ // try to clean up the service after itself
+ try {
+ String axisServiceName = service.getAxisService().getName();
+ AxisService axisService = _server._axisConfig.getService(axisServiceName);
+ // first, de-allocate its schemas
+ axisService.releaseSchemaList();
+ // then, de-allocate its parameters
+ // the service's wsdl object model is stored as one of its parameters!
+ // can't stress strongly enough how important it is to clean this up.
+ ArrayList<Parameter> parameters = (ArrayList<Parameter>) axisService.getParameters();
+ for (Parameter parameter : parameters) {
+ axisService.removeParameter(parameter);
+ }
+ // now, stop the service
+ _server._axisConfig.stopService(axisServiceName);
+ // if only this method did a good job of cleaning up after itself
+ _server._axisConfig.removeService(axisServiceName);
+ _server._axisConfig.cleanup();
+ } catch (AxisFault axisFault) {
+ __log.error("Couldn't destroy service " + serviceName);
+ }
+ } else {
+ __log.debug("Couldn't find service " + serviceName + " port " + portName + " to destroy.");
}
- return _server.createExternalService(pconf, initialPartnerEndpoint.serviceName, initialPartnerEndpoint.portName);
+ }
+
+ protected ExternalService createExternalService(ProcessConf pconf, QName serviceName, String portName) throws ContextException {
+ ExternalService extService = null;
+
+ Definition def = pconf.getDefinitionForService(serviceName);
+ try {
+ if (WsdlUtils.useHTTPBinding(def, serviceName, portName)) {
+ if (__log.isDebugEnabled()) __log.debug("Creating HTTP-bound external service " + serviceName);
+ extService = new HttpExternalService(pconf, serviceName, portName, _server._bpelServer, _server.httpConnectionManager);
+ } else if (WsdlUtils.useSOAPBinding(def, serviceName, portName)) {
+ if (__log.isDebugEnabled()) __log.debug("Creating SOAP-bound external service " + serviceName);
+ extService = new SoapExternalService(def, serviceName, portName, _server._axisConfig, pconf, _server.httpConnectionManager);
+ }
+ } catch (Exception ex) {
+ __log.error("Could not create external service.", ex);
+ throw new ContextException("Error creating external service! name:" + serviceName + ", port:" + portName, ex);
+ }
+
+ // if not SOAP nor HTTP binding
+ if (extService == null) {
+ throw new ContextException("Only SOAP and HTTP binding supported!");
+ }
+
+ __log.debug("Created external service " + serviceName);
+ return extService;
}
}
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?rev=761436&r1=761435&r2=761436&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java Thu Apr 2 21:36:02 2009
@@ -100,7 +100,7 @@
protected File _appRoot;
protected File _configRoot;
protected File _workRoot;
- protected BpelServerImpl _server;
+ protected BpelServerImpl _bpelServer;
protected ProcessStoreImpl _store;
protected ODEConfigProperties _odeConfig;
protected AxisConfiguration _axisConfig;
@@ -112,8 +112,8 @@
private MultiKeyMap _services = new MultiKeyMap();
private BpelServerConnector _connector;
private ManagementService _mgtService;
- private MultiThreadedHttpConnectionManager httpConnectionManager;
-
+ protected MultiThreadedHttpConnectionManager httpConnectionManager;
+
public void init(ServletConfig config, AxisConfiguration axisConf) throws ServletException {
init(config.getServletContext().getRealPath("/WEB-INF"), axisConf);
}
@@ -176,7 +176,7 @@
registerExternalVariableModules();
try {
- _server.start();
+ _bpelServer.start();
} catch (Exception ex) {
String errmsg = __msgs.msgOdeBpelServerStartFailure();
__log.error(errmsg, ex);
@@ -187,11 +187,15 @@
_poller = new DeploymentPoller(deploymentDir, this);
_mgtService = new ManagementService();
- _mgtService.enableService(_axisConfig, _server, _store, _appRoot.getAbsolutePath());
-
- new DeploymentWebService().enableService(_axisConfig, _server, _store, _poller, _appRoot.getAbsolutePath(), _workRoot
- .getAbsolutePath());
+ _mgtService.enableService(_axisConfig, _bpelServer, _store, _appRoot.getAbsolutePath());
+ try {
+ __log.debug("Initializing Deployment Web Service");
+ new DeploymentWebService().enableService(_axisConfig, _store, _poller, _appRoot.getAbsolutePath(), _workRoot
+ .getAbsolutePath());
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
_store.loadAll();
__log.debug("Initializing JCA adapter.");
@@ -248,11 +252,11 @@
__log.debug("Error stopping poller.", t);
}
- if (_server != null)
+ if (_bpelServer != null)
try {
__log.debug("shutting down ODE server.");
- _server.shutdown();
- _server = null;
+ _bpelServer.shutdown();
+ _bpelServer = null;
} catch (Throwable ex) {
__log.debug("Error stopping services.", ex);
}
@@ -330,7 +334,7 @@
public ODEService createService(ProcessConf pconf, QName serviceName, String portName) throws AxisFault {
AxisService axisService = ODEAxisService.createService(_axisConfig, pconf, serviceName, portName);
- ODEService odeService = new ODEService(axisService, pconf, serviceName, portName, _server);
+ ODEService odeService = new ODEService(axisService, pconf, serviceName, portName, _bpelServer);
destroyService(serviceName, portName);
@@ -358,7 +362,7 @@
try {
if (WsdlUtils.useHTTPBinding(def, serviceName, portName)) {
if(__log.isDebugEnabled())__log.debug("Creating HTTP-bound external service " + serviceName);
- extService = new HttpExternalService(pconf, serviceName, portName, _server, httpConnectionManager);
+ extService = new HttpExternalService(pconf, serviceName, portName, _bpelServer, httpConnectionManager);
} else if (WsdlUtils.useSOAPBinding(def, serviceName, portName)) {
if(__log.isDebugEnabled())__log.debug("Creating SOAP-bound external service " + serviceName);
extService = new SoapExternalService(def, serviceName, portName, _axisConfig, pconf, httpConnectionManager);
@@ -428,7 +432,7 @@
__log.info("Skipping connector initialization.");
} else {
_connector = new BpelServerConnector();
- _connector.setBpelServer(_server);
+ _connector.setBpelServer(_bpelServer);
_connector.setProcessStore(_store);
_connector.setPort(_odeConfig.getConnectorPort());
_connector.setId(_odeConfig.getConnectorName());
@@ -480,23 +484,23 @@
__log.debug("ODE initializing");
}
- _server = new BpelServerImpl();
+ _bpelServer = new BpelServerImpl();
_scheduler = createScheduler();
- _scheduler.setJobProcessor(_server);
+ _scheduler.setJobProcessor(_bpelServer);
- _server.setDaoConnectionFactory(_daoCF);
- _server.setEndpointReferenceContext(eprContext);
- _server.setMessageExchangeContext(new MessageExchangeContextImpl(this));
- _server.setBindingContext(new BindingContextImpl(this, _store));
- _server.setScheduler(_scheduler);
- _server.setTransactionManager(_txMgr);
+ _bpelServer.setDaoConnectionFactory(_daoCF);
+ _bpelServer.setEndpointReferenceContext(eprContext);
+ _bpelServer.setMessageExchangeContext(new MessageExchangeContextImpl(this));
+ _bpelServer.setBindingContext(new BindingContextImpl(this));
+ _bpelServer.setScheduler(_scheduler);
+ _bpelServer.setTransactionManager(_txMgr);
if (_odeConfig.isDehydrationEnabled()) {
CountLRUDehydrationPolicy dehy = new CountLRUDehydrationPolicy();
// dehy.setProcessMaxAge(10000);
- _server.setDehydrationPolicy(dehy);
+ _bpelServer.setDehydrationPolicy(dehy);
}
- _server.setConfigProperties(_odeConfig);
- _server.init();
+ _bpelServer.setConfigProperties(_odeConfig);
+ _bpelServer.init();
}
private void initHttpConnectionManager() throws ServletException {
@@ -522,7 +526,7 @@
}
public BpelServerImpl getBpelServer() {
- return _server;
+ return _bpelServer;
}
public InstanceManagement getInstanceManagement() {
@@ -544,7 +548,7 @@
private void registerEventListeners() {
// let's always register the debugging listener....
- _server.registerBpelEventListener(new DebugBpelEventListener());
+ _bpelServer.registerBpelEventListener(new DebugBpelEventListener());
// then, whatever else they want.
String listenersStr = _odeConfig.getEventListeners();
@@ -552,7 +556,7 @@
for (StringTokenizer tokenizer = new StringTokenizer(listenersStr, ",;"); tokenizer.hasMoreTokens();) {
String listenerCN = tokenizer.nextToken();
try {
- _server.registerBpelEventListener((BpelEventListener) Class.forName(listenerCN).newInstance());
+ _bpelServer.registerBpelEventListener((BpelEventListener) Class.forName(listenerCN).newInstance());
__log.info(__msgs.msgBpelEventListenerRegistered(listenerCN));
} catch (Exception e) {
__log.warn("Couldn't register the event listener " + listenerCN + ", the class couldn't be "
@@ -569,7 +573,7 @@
for (StringTokenizer tokenizer = new StringTokenizer(listenersStr, ",;"); tokenizer.hasMoreTokens();) {
String interceptorCN = tokenizer.nextToken();
try {
- _server.registerMessageExchangeInterceptor((MessageExchangeInterceptor) Class.forName(interceptorCN).newInstance());
+ _bpelServer.registerMessageExchangeInterceptor((MessageExchangeInterceptor) Class.forName(interceptorCN).newInstance());
__log.info(__msgs.msgMessageExchangeInterceptorRegistered(interceptorCN));
} catch (Exception e) {
__log.warn("Couldn't register the event listener " + interceptorCN + ", the class couldn't be "
@@ -590,7 +594,7 @@
// instantiate bundle
ExtensionBundleRuntime bundleRT = (ExtensionBundleRuntime) Class.forName(bundleCN).newInstance();
// register extension bundle (BPEL server)
- _server.registerExtensionBundle(bundleRT);
+ _bpelServer.registerExtensionBundle(bundleRT);
} catch (Exception e) {
__log.warn("Couldn't register the extension bundle runtime " + bundleCN + ", the class couldn't be " +
"loaded properly.");
@@ -620,7 +624,7 @@
JdbcExternalVariableModule jdbcext;
jdbcext = new JdbcExternalVariableModule();
jdbcext.registerDataSource("ode", _db.getDataSource());
- _server.registerExternalVariableEngine(jdbcext);
+ _bpelServer.registerExternalVariableEngine(jdbcext);
}
@@ -638,14 +642,14 @@
case ACTIVATED:
case RETIRED:
// bounce the process
- _server.unregister(pse.pid);
+ _bpelServer.unregister(pse.pid);
ProcessConf pconf = _store.getProcessConfiguration(pse.pid);
- if (pconf != null) _server.register(pconf);
+ if (pconf != null) _bpelServer.register(pconf);
else __log.debug("slighly odd: recevied event " + pse + " for process not in store!");
break;
case DISABLED:
case UNDEPLOYED:
- _server.unregister(pse.pid);
+ _bpelServer.unregister(pse.pid);
break;
default:
__log.debug("Ignoring store event: " + pse);
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java?rev=761436&r1=761435&r2=761436&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java Thu Apr 2 21:36:02 2009
@@ -82,28 +82,22 @@
_deployapi = OMAbstractFactory.getOMFactory().createOMNamespace("http://www.apache.org/ode/deployapi","deployapi");
}
- public void enableService(AxisConfiguration axisConfig, BpelServer server, ProcessStore store,
- DeploymentPoller poller, String rootpath, String workPath) {
+ public void enableService(AxisConfiguration axisConfig, ProcessStore store,
+ DeploymentPoller poller, String rootpath, String workPath) throws AxisFault, WSDLException {
_deployPath = new File(workPath, "processes");
_store = store;
+ _poller = poller;
Definition def;
- try {
- WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
- wsdlReader.setFeature("javax.wsdl.verbose", false);
-
- File wsdlFile = new File(rootpath + "/deploy.wsdl");
- def = wsdlReader.readWSDL(wsdlFile.toURI().toString());
- AxisService deployService = ODEAxisService.createService(
- axisConfig, new QName("http://www.apache.org/ode/deployapi", "DeploymentService"),
- "DeploymentPort", "DeploymentService", def, new DeploymentMessageReceiver());
- axisConfig.addService(deployService);
- _poller = poller;
- } catch (WSDLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose", false);
+
+ File wsdlFile = new File(rootpath + "/deploy.wsdl");
+ def = wsdlReader.readWSDL(wsdlFile.toURI().toString());
+ AxisService deployService = ODEAxisService.createService(
+ axisConfig, new QName("http://www.apache.org/ode/deployapi", "DeploymentService"),
+ "DeploymentPort", "DeploymentService", def, new DeploymentMessageReceiver());
+ axisConfig.addService(deployService);
}
class DeploymentMessageReceiver extends AbstractMessageReceiver {
@@ -178,9 +172,8 @@
throw new OdeFault("Couldn't find deployment package " + pkg + " in directory " + _deployPath);
try {
- // We're going to create a directory under the deployment root and put
- // files in there. The poller shouldn't pick them up so we're asking
- // it to hold on for a while.
+ // We're going to delete files & directories under the deployment root.
+ // Put the poller on hold to avoid undesired side effects
_poller.hold();
Collection<QName> undeployed = _store.undeploy(deploymentDir);