

package com.acme;
import java.rmi.Remote;
public interface IReserveService extends Remote {
public void reserveElement(final String elid) throws java.rmi.RemoteException, Exception;
public void unreserveElement(final String elid) throws java.rmi.RemoteException, Exception;
}

package com.acme;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import com.osm.biz.WMElement;
import com.osm.biz.WMSession;
public class ReserveServiceImpl extends UnicastRemoteObject implements IReserveService {
public ReserveServiceImpl() throws RemoteException {
super();
}
public void reserveElement(final String elid) throws Exception {
final WMElement element = WMSession.getWMSession().openElement(elid, false);
try {
element.reserve();
} finally {
element.close();
}
}
public void unreserveElement(final String elid) throws Exception {
final WMElement element = WMSession.getWMSession().openElement(elid, false);
try {
element.unReserve();
} finally {
element.close();
}
}
}

package com.acme;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import com.osm.services.webservice.JettyServer;
@WebService(name = "ReserveService", serviceName = "ReserveService")
public class ReserveWebService {
@WebMethod(operationName = "reserveElement")
public void reserveElement(@WebParam(name = "elid")
final String elid) throws Exception {
try {
final IReserveService s = JettyServer.getInstance().get(IReserveService.class);
s.reserveElement(elid);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
@WebMethod(operationName = "unreserveElement")
public void unreserveElement(@WebParam(name = "elid")
final String elid) throws Exception {
try {
final IReserveService s = JettyServer.getInstance().get(IReserveService.class);
s.unreserveElement(elid);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
}
<!-- Enable the ReserveService api -->
<PublishedAPI implementation="com.acme.ReserveServiceImpl" interface="com.acme.IReserveService"/>
|
|
You must manually add or remove the JettyWorker tags in the CustomServiceControllerConfig.xml file to change the number of Jetty Workers.
|

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>OSM Web Services</display-name>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>ReserveService</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ReserveService</servlet-name>
<url-pattern>/ReserveService</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>Web Services</display-name>
<web-resource-collection>
<web-resource-name>ReserveService</web-resource-name>
<description/>
<url-pattern>/ReserveService</url-pattern>
<http-method>PUT</http-method>
<http-method>POST</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>osm-user</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>osmRealm</realm-name>
</login-config>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint name="ReserveService" implementation="com.acme.ReserveWebService" url-pattern="/ReserveService"/>
</endpoints>
<War context="/custom" location="webapps/custom/"/>