Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » remoting » rmi » [javadoc | source]
    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.rmi;
   18   
   19   import java.lang.reflect.InvocationTargetException;
   20   import java.rmi.RemoteException;
   21   
   22   import org.springframework.remoting.support.RemoteInvocation;
   23   import org.springframework.util.Assert;
   24   
   25   /**
   26    * Server-side implementation of {@link RmiInvocationHandler}. An instance
   27    * of this class exists for each remote object. Automatically created
   28    * by {@link RmiServiceExporter} for non-RMI service implementations.
   29    *
   30    * <p>This is an SPI class, not to be used directly by applications.
   31    *
   32    * @author Juergen Hoeller
   33    * @since 14.05.2003
   34    * @see RmiServiceExporter
   35    */
   36   class RmiInvocationWrapper implements RmiInvocationHandler {
   37   
   38   	private final Object wrappedObject;
   39   
   40   	private final RmiBasedExporter rmiExporter;
   41   
   42   
   43   	/**
   44   	 * Create a new RmiInvocationWrapper for the given object
   45   	 * @param wrappedObject the object to wrap with an RmiInvocationHandler
   46   	 * @param rmiExporter the RMI exporter to handle the actual invocation
   47   	 */
   48   	public RmiInvocationWrapper(Object wrappedObject, RmiBasedExporter rmiExporter) {
   49   		Assert.notNull(wrappedObject, "Object to wrap is required");
   50   		Assert.notNull(rmiExporter, "RMI exporter is required");
   51   		this.wrappedObject = wrappedObject;
   52   		this.rmiExporter = rmiExporter;
   53   	}
   54   
   55   
   56   	/**
   57   	 * Exposes the exporter's service interface, if any, as target interface.
   58   	 * @see RmiBasedExporter#getServiceInterface()
   59   	 */
   60   	public String getTargetInterfaceName() {
   61   		Class ifc = this.rmiExporter.getServiceInterface();
   62   		return (ifc != null ? ifc.getName() : null);
   63   	}
   64   
   65   	/**
   66   	 * Delegates the actual invocation handling to the RMI exporter.
   67   	 * @see RmiBasedExporter#invoke(org.springframework.remoting.support.RemoteInvocation, Object)
   68   	 */
   69   	public Object invoke(RemoteInvocation invocation)
   70   	    throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
   71   
   72   		return this.rmiExporter.invoke(invocation, this.wrappedObject);
   73   	}
   74   
   75   }

Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » remoting » rmi » [javadoc | source]