Example usage for org.springframework.remoting.rmi RmiServiceExporter setServiceInterface

List of usage examples for org.springframework.remoting.rmi RmiServiceExporter setServiceInterface

Introduction

In this page you can find the example usage for org.springframework.remoting.rmi RmiServiceExporter setServiceInterface.

Prototype

public void setServiceInterface(Class<?> serviceInterface) 

Source Link

Document

Set the interface of the service to export.

Usage

From source file:org.javassonne.networking.impl.RemotingUtils.java

/**
 * This method takes an object and exposes it as a remove RMI service. The
 * class that is passed should be the interface that you want the service
 * exposed as. The name and port will be used to create the url for the
 * service. e.g. if you provide the name "foo", port 5555, and your ip
 * address is 123.45.67.89, the following url will access the service:
 * rmi://123.45.67.89:5555/foo/*from w  ww  . ja  va2  s.  c o m*/
 * 
 * @param svc
 *            - the object that is to be exposed as a remote RMI service
 * @param svcinterface
 *            - the interface on the object to expose
 * @param name
 *            - the name of the service for the url
 * @return - the url of the service (can be passed to others to connect to)
 * 
 * @throws RemoteException
 * @throws UnknownHostException
 */
public static synchronized ServiceInfo exportRMIService(Object svc, Class svcinterface, int port, String name)
        throws RemoteException, UnknownHostException {
    RmiServiceExporter exporter = new RmiServiceExporter();
    exporter.setRegistryPort(port);
    exporter.setServiceInterface(svcinterface);
    exporter.setService(svc);
    exporter.setServiceName(name);
    exporter.afterPropertiesSet();
    exporter.prepare();
    serviceMap_.put(name, exporter);

    ServiceInfo info = ServiceInfo.create("_rmi._tcp.local.", name, port, "path=index.html");

    // return "rmi://"+LOCAL_HOST+":"+port+"/"+name;
    return info;
}

From source file:com.apress.prospringintegration.springenterprise.stocks.service.RmiServiceConfig.java

@Bean
public RmiServiceExporter serviceExporter() throws Exception {
    RmiServiceExporter se = new RmiServiceExporter();
    se.setServiceName("QuoteService");
    se.setService(quoteService());/*from   w  ww. jav  a 2s.c  om*/
    se.setServiceInterface(QuoteService.class);
    //se.setRegistryHost("localhost");
    //se.setRegistryPort(1399);
    se.afterPropertiesSet();
    return se;
}

From source file:org.lightadmin.core.config.context.LightAdminRemoteConfiguration.java

private RmiServiceExporter createRmiServiceExporter(final Object service, final String serviceName)
        throws RemoteException {
    RmiServiceExporter rmiServiceExporter = new RmiServiceExporter();
    rmiServiceExporter.setServiceName(serviceName);
    rmiServiceExporter.setService(service);
    rmiServiceExporter.setServiceInterface(ClassUtils.getAllInterfaces(service)[0]);
    rmiServiceExporter.setRegistryPort(1199);
    rmiServiceExporter.afterPropertiesSet();
    return rmiServiceExporter;
}

From source file:com.rk.grid.cluster.master.Broker.java

private void doRMIExport() throws RemoteException {
    /*/*from  w w w  .j  a  v  a  2s  .c o  m*/
     *    <bean id="broker" class="grid.client.Broker"></bean>
      <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    <property name="serviceName" value="clustered-executor-service" />
    <property name="service" ref="broker" />
      <property name="serviceInterface" value="grid.common.IBroker"/>
    <property name="registryPort" value="1234" />
      </bean>
     */
    try {
        RmiServiceExporter s = new RmiServiceExporter();
        s.setServiceName(this.serviceName);
        s.setService(this);
        s.setServiceInterface(IBroker.class);
        s.setRegistryPort(this.port);
        s.afterPropertiesSet();
        this.rmiServiceExporter = s;
    } catch (Throwable e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }

}

From source file:au.com.jwatmuff.genericp2p.rmi.RMIPeerManager.java

private void refreshService(PeerService service) {
    RmiServiceExporter exporter = new RmiServiceExporter();
    exporter.setRegistryPort(registryPort);
    exporter.setServiceName(service.name);
    exporter.setServiceInterface(service.serviceClass);
    exporter.setService(service.implementation);
    try {/*from   w  ww.j a v a  2  s . c  om*/
        service.exporter.destroy();
        exporter.afterPropertiesSet();
        exporter.prepare();
        service.exporter = exporter;
    } catch (RemoteException e) {
        log.error("Refreshing service " + service.name + " (" + service + ") failed", e);
    }
}

From source file:au.com.jwatmuff.genericp2p.rmi.RMIPeerManager.java

/**
 * Associates the given class and service name, so that the service may
 * be obtained from any Peer objects supplied by this PeerManager.
 * If an implementation is supplied, remote client may obtain an instance
 * of the service from the this client.//from   ww w.j  a v a  2 s  . c o  m
 * 
 * For the service to be obtainable from a given remote peer, that peer must
 * have also registered the service and supplied an implementation of the
 * service.
 * 
 * @param <T>
 * @param serviceName
 * @param serviceClass
 * @param implementation
 */
@Override
public <T> void registerService(String serviceName, Class<T> serviceClass, T implementation) {
    PeerService<T> service = new PeerService<T>();
    service.name = serviceName;
    service.serviceClass = serviceClass;
    service.implementation = implementation;

    if (peerServiceMap.containsKey(serviceName)) {
        log.warn("Service with name " + serviceName + " has already been registered");
    }

    if (implementation != null) {
        RmiServiceExporter exporter = new RmiServiceExporter();
        //exporter.setRegistryPort(registryPort);
        exporter.setRegistry(registry);
        exporter.setServiceName(serviceName);
        exporter.setServiceInterface(serviceClass);
        exporter.setService(implementation);
        try {
            exporter.afterPropertiesSet();
            exporter.prepare();
            service.exporter = exporter;
            peerServiceMap.put(serviceName, service);
        } catch (RemoteException e) {
            log.error("Exporting service " + serviceName + " (" + serviceClass + ") failed", e);
        }
    }
}