Creating the services.xml file – HP Integrity NonStop J-Series User Manual

Page 262

Advertising
background image

import org.apache.axiom.om.OMElement;
import org.apache.axis2.engine.ServiceLifeCycle;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.description.AxisService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class SpringInit implements ServiceLifeCycle {

private static Log logger = LogFactory
.getLog(SpringInit .class);

// The web service
public OMElement springInit(OMElement ignore) {

return null;
}

public void init(ServiceContext serviceContext) {

}

public void setOperationContext(OperationContext arg0) {

}

public void destroy(ServiceContext arg0) {

}

/**
* this will be called during the deployement time of the service. irrespective
* of the service scope this method will be called
*/
public void startUp(ConfigurationContext ignore, AxisService service) {
ClassLoader classLoader = service.getClassLoader();
ClassPathXmlApplicationContext appCtx = new
ClassPathXmlApplicationContext(new String[] {"applicationContext.xml"}, false);
appCtx.setClassLoader(classLoader);
appCtx.refresh();
if (logger.isDebugEnabled()) {
logger.debug("\n\nstartUp() set spring classloader via axisService.getClassLoader() ... ");
}
}
/**
* this will be called during the deployement time of the service. irrespective
* of the service scope this method will be called
*/
public void shutDown(ConfigurationContext ignore, AxisService service) {

}
}

Creating the services.xml File

Create the Axis2/Java Deployment Descriptor file (services.xml) to instantiate the SpringInit
and EmpInfo services.

To create the services.xml file, complete the following steps:

1.

Create the services.xml file in the EmpInfo/WebContent/META-INF directory, as
explained in the

Creating the EmpInfo-servlet.xml File

section in the

Getting Started

with Spring

section.

2.

Modify the services.xml file to include the instances SpringInit and EmpInfo services.

After modification, the services.xml file must appear as:

<serviceGroup>
<service name="SpringInit" class="com.hp.empinfo.service.SpringInit">
<description>
This web service initializes Spring.
</description>
<parameter name="ServiceClass" >com.hp.empinfo.service.SpringInit</parameter>
<parameter name="ServiceTCCL" >composite</parameter>
<parameter name="load-on-startup" >true</parameter>
<operation name="springInit">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
</operation>
</service>
<service name="EmpInfo">
<description>
Spring EmpInfo Axis2 AAR deployment
</description>
<parameter name="ServiceClass" >com.hp.empinfo.service.EmployeeDao</parameter>

262 Integrating Frameworks

Advertising
This manual is related to the following products: