001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.remoting.support; 018 019/** 020 * Abstract base class for classes that access a remote service. 021 * Provides a "serviceInterface" bean property. 022 * 023 * <p>Note that the service interface being used will show some signs of 024 * remotability, like the granularity of method calls that it offers. 025 * Furthermore, it has to have serializable arguments etc. 026 * 027 * <p>Accessors are supposed to throw Spring's generic 028 * {@link org.springframework.remoting.RemoteAccessException} in case 029 * of remote invocation failure, provided that the service interface 030 * does not declare {@code java.rmi.RemoteException}. 031 * 032 * @author Juergen Hoeller 033 * @since 13.05.2003 034 * @see org.springframework.remoting.RemoteAccessException 035 * @see java.rmi.RemoteException 036 */ 037public abstract class RemoteAccessor extends RemotingSupport { 038 039 private Class<?> serviceInterface; 040 041 042 /** 043 * Set the interface of the service to access. 044 * The interface must be suitable for the particular service and remoting strategy. 045 * <p>Typically required to be able to create a suitable service proxy, 046 * but can also be optional if the lookup returns a typed proxy. 047 */ 048 public void setServiceInterface(Class<?> serviceInterface) { 049 if (serviceInterface != null && !serviceInterface.isInterface()) { 050 throw new IllegalArgumentException("'serviceInterface' must be an interface"); 051 } 052 this.serviceInterface = serviceInterface; 053 } 054 055 /** 056 * Return the interface of the service to access. 057 */ 058 public Class<?> getServiceInterface() { 059 return this.serviceInterface; 060 } 061 062}