001/* 002 * Copyright 2002-2017 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 019import org.springframework.util.Assert; 020 021/** 022 * Abstract base class for classes that access a remote service. 023 * Provides a "serviceInterface" bean property. 024 * 025 * <p>Note that the service interface being used will show some signs of 026 * remotability, like the granularity of method calls that it offers. 027 * Furthermore, it has to have serializable arguments etc. 028 * 029 * <p>Accessors are supposed to throw Spring's generic 030 * {@link org.springframework.remoting.RemoteAccessException} in case 031 * of remote invocation failure, provided that the service interface 032 * does not declare {@code java.rmi.RemoteException}. 033 * 034 * @author Juergen Hoeller 035 * @since 13.05.2003 036 * @see org.springframework.remoting.RemoteAccessException 037 * @see java.rmi.RemoteException 038 */ 039public abstract class RemoteAccessor extends RemotingSupport { 040 041 private Class<?> serviceInterface; 042 043 044 /** 045 * Set the interface of the service to access. 046 * The interface must be suitable for the particular service and remoting strategy. 047 * <p>Typically required to be able to create a suitable service proxy, 048 * but can also be optional if the lookup returns a typed proxy. 049 */ 050 public void setServiceInterface(Class<?> serviceInterface) { 051 Assert.notNull(serviceInterface, "'serviceInterface' must not be null"); 052 Assert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface"); 053 this.serviceInterface = serviceInterface; 054 } 055 056 /** 057 * Return the interface of the service to access. 058 */ 059 public Class<?> getServiceInterface() { 060 return this.serviceInterface; 061 } 062 063}