All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.remoting.rmi.JndiRmiProxyFactoryBean Maven / Gradle / Ivy

/*
 * Copyright 2002-2005 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.remoting.rmi;

import javax.naming.NamingException;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.FactoryBean;

/**
 * Factory bean for RMI proxies from JNDI.
 * Typically used for RMI-IIOP (CORBA), but can also be used for EJB home objects
 * (for example, a Stateful Session Bean home). In contrast to a plain JNDI lookup,
 * this accessor also performs narrowing through PortableRemoteObject.
 *
 * 

With conventional RMI services, this invoker is typically used with the RMI * service interface. Alternatively, this invoker can also proxy a remote RMI service * with a matching non-RMI business interface, i.e. an interface that mirrors the RMI * service methods but does not declare RemoteExceptions. In the latter case, * RemoteExceptions thrown by the RMI stub will automatically get converted to * Spring's unchecked RemoteAccessException. * *

The JNDI environment can be specified as jndiEnvironment property, * or be configured in a jndi.properties file or as system properties. * For example: * *

 * <property name="jndiEnvironment">
 * 	 <props>
 *		 <prop key="java.naming.factory.initial">com.sun.jndi.cosnaming.CNCtxFactory</prop>
 *		 <prop key="java.naming.provider.url">iiop://localhost:1050</prop>
 *	 </props>
 * </property>
* * @author Juergen Hoeller * @since 1.1 * @see #setServiceInterface * @see #setJndiName * @see #setJndiTemplate * @see #setJndiEnvironment * @see #setJndiName * @see JndiRmiServiceExporter * @see JndiRmiProxyFactoryBean * @see org.springframework.remoting.RemoteAccessException * @see java.rmi.RemoteException * @see java.rmi.Remote * @see javax.rmi.PortableRemoteObject#narrow */ public class JndiRmiProxyFactoryBean extends JndiRmiClientInterceptor implements FactoryBean { private Object serviceProxy; public void afterPropertiesSet() throws NamingException { super.afterPropertiesSet(); if (getServiceInterface() == null) { throw new IllegalArgumentException("serviceInterface is required"); } this.serviceProxy = ProxyFactory.getProxy(getServiceInterface(), this); } public Object getObject() { return this.serviceProxy; } public Class getObjectType() { return (this.serviceProxy != null) ? this.serviceProxy.getClass() : getServiceInterface(); } public boolean isSingleton() { return true; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy