JaxRpcPortProxyFactoryBean.java
Upload User: jiancairen
Upload Date: 2007-08-27
Package Size: 26458k
Code Size: 3k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright 2002-2004 the original author or authors.
  3.  * 
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  * 
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  * 
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */ 
  16. package org.springframework.remoting.jaxrpc;
  17. import javax.xml.rpc.ServiceException;
  18. import org.springframework.aop.framework.ProxyFactory;
  19. import org.springframework.beans.factory.FactoryBean;
  20. /**
  21.  * FactoryBean for a specific port of a JAX-RPC service.
  22.  * Exposes a proxy for the port, to be used for bean references.
  23.  * Inherits configuration properties from JaxRpcPortClientInterceptor.
  24.  *
  25.  * <p>This factory is typically used with an RMI service interface. Alternatively,
  26.  * this factory can also proxy a JAX-RPC service with a matching non-RMI business
  27.  * interface, i.e. an interface that mirrors the RMI service methods but does not
  28.  * declare RemoteExceptions. In the latter case, RemoteExceptions thrown by the
  29.  * JAX-RPC stub will automatically get converted to Spring's unchecked
  30.  * RemoteAccessException.
  31.  *
  32.  * <p>If exposing the JAX-RPC port interface (i.e. an RMI interface) directly,
  33.  * setting "serviceInterface" is sufficient. If exposing a non-RMI business
  34.  * interface, the business interface needs to be set as "serviceInterface",
  35.  * and the JAX-RPC port interface as "portInterface".
  36.  *
  37.  * @author Juergen Hoeller
  38.  * @since 15.12.2003
  39.  * @see #setServiceInterface
  40.  * @see #setPortInterface
  41.  * @see LocalJaxRpcServiceFactoryBean
  42.  */
  43. public class JaxRpcPortProxyFactoryBean extends JaxRpcPortClientInterceptor implements FactoryBean {
  44. private Object serviceProxy;
  45. public void afterPropertiesSet() throws ServiceException {
  46. if (getServiceInterface() == null) {
  47. throw new IllegalArgumentException("serviceInterface is required");
  48. }
  49. super.afterPropertiesSet();
  50. this.serviceProxy = ProxyFactory.getProxy(getServiceInterface(), this);
  51. }
  52. public Object getObject() {
  53. return this.serviceProxy;
  54. }
  55. public Class getObjectType() {
  56. return (this.serviceProxy != null) ? this.serviceProxy.getClass() : getServiceInterface();
  57. }
  58. public boolean isSingleton() {
  59. return true;
  60. }
  61. }