1 package org.springframework.samples.jpetstore.service; 2 3 import org.springframework.remoting.jaxrpc.ServletEndpointSupport; 4 import org.springframework.samples.jpetstore.domain.Order; 5 import org.springframework.samples.jpetstore.domain.logic.OrderService; 6 7 /** 8 * JAX-RPC OrderService endpoint that simply delegates to the OrderService 9 * implementation in the root web application context. Implements the plain 10 * OrderService interface as service interface, just like the target bean does. 11 * 12 * <p>This proxy class is necessary because JAX-RPC/Axis requires a dedicated 13 * endpoint class to instantiate. If an existing service needs to be exported, 14 * a wrapper that extends ServletEndpointSupport for simple application context 15 * access is the simplest JAX-RPC compliant way. 16 * 17 * <p>This is the class registered with the server-side JAX-RPC implementation. 18 * In the case of Axis, this happens in "server-config.wsdd" respectively via 19 * deployment calls. The Web Service tool manages the lifecycle of instances 20 * of this class: A Spring application context can just be accessed here. 21 * 22 * <p>Note that this class does <i>not</i> implement an RMI port interface, 23 * despite the JAX-RPC spec requiring this for service endpoints. Axis and 24 * other JAX-RPC implementations are known to accept non-RMI endpoint classes 25 * too, so there's no need to maintain an RMI port interface in addition to 26 * the existing non-RMI service interface (OrderService). 27 * 28 * <p>If your JAX-RPC implementation imposes a strict requirement on a service 29 * endpoint class to implement an RMI port interface, then let your endpoint 30 * class implement both the non-RMI service interface and the RMI port interface. 31 * This will work as long as the methods in both interfaces just differ in the 32 * declared RemoteException. Of course, this unfortunately involves double 33 * maintenance: one interface for your business logic, one for JAX-RPC. 34 * Therefore, it is usually preferable to avoid this if not absolutely necessary. 35 * 36 * @author Juergen Hoeller 37 * @since 26.12.2003 38 */ 39 public class JaxRpcOrderService extends ServletEndpointSupport implements OrderService { 40 41 private OrderService orderService; 42 43 protected void onInit() { 44 this.orderService = (OrderService) getWebApplicationContext().getBean("petStore"); 45 } 46 47 public Order getOrder(int orderId) { 48 return this.orderService.getOrder(orderId); 49 } 50 51 } 52