01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.springframework.remoting.support;
18:
19: import org.apache.commons.logging.Log;
20: import org.apache.commons.logging.LogFactory;
21:
22: /**
23: * Abstract base class for classes that access a remote service.
24: * Provides a "serviceInterface" bean property.
25: *
26: * <p>Note that the service interface being used will show some signs of
27: * remotability, like the granularity of method calls that it offers.
28: * Furthermore, it has to have serializable arguments etc.
29: *
30: * <p>Accessors are supposed to throw Spring's generic
31: * {@link org.springframework.remoting.RemoteAccessException} in case
32: * of remote invocation failure, provided that the service interface
33: * does not declare <code>java.rmi.RemoteException</code>.
34: *
35: * @author Juergen Hoeller
36: * @since 13.05.2003
37: * @see org.springframework.remoting.RemoteAccessException
38: * @see java.rmi.RemoteException
39: */
40: public abstract class RemoteAccessor {
41:
42: /** Logger available to subclasses */
43: protected final Log logger = LogFactory.getLog(getClass());
44:
45: private Class serviceInterface;
46:
47: /**
48: * Set the interface of the service to access.
49: * The interface must be suitable for the particular service and remoting strategy.
50: * <p>Typically required to be able to create a suitable service proxy,
51: * but can also be optional if the lookup returns a typed proxy.
52: */
53: public void setServiceInterface(Class serviceInterface) {
54: if (serviceInterface != null && !serviceInterface.isInterface()) {
55: throw new IllegalArgumentException(
56: "'serviceInterface' must be an interface");
57: }
58: this .serviceInterface = serviceInterface;
59: }
60:
61: /**
62: * Return the interface of the service to access.
63: */
64: public Class getServiceInterface() {
65: return this.serviceInterface;
66: }
67:
68: }
|