KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > remoting > support > RemoteAccessor


1 /*
2  * Copyright 2002-2007 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
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 JavaDoc serviceInterface;
46
47
48     /**
49      * Set the interface of the service to access.
50      * The interface must be suitable for the particular service and remoting strategy.
51      * <p>Typically required to be able to create a suitable service proxy,
52      * but can also be optional if the lookup returns a typed proxy.
53      */

54     public void setServiceInterface(Class JavaDoc serviceInterface) {
55         if (serviceInterface != null && !serviceInterface.isInterface()) {
56             throw new IllegalArgumentException JavaDoc("'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 JavaDoc getServiceInterface() {
65         return this.serviceInterface;
66     }
67
68 }
69
Popular Tags