Search in sources :

Example 1 with RmiServiceExporter

use of org.springframework.remoting.rmi.RmiServiceExporter in project otter by alibaba.

the class RmiCommunicationEndpoint method initial.

public void initial() {
    export = new RmiServiceExporter();
    export.setServiceName("endpoint");
    // 暴露自己
    export.setService(this);
    export.setServiceInterface(CommunicationEndpoint.class);
    export.setRegistryHost(host);
    export.setRegistryPort(port);
    // 强制创建一个
    export.setAlwaysCreateRegistry(alwaysCreateRegistry);
    try {
        export.afterPropertiesSet();
    } catch (RemoteException e) {
        throw new CommunicationException("Rmi_Create_Error", e);
    }
}
Also used : CommunicationException(com.alibaba.otter.shared.communication.core.exception.CommunicationException) RmiServiceExporter(org.springframework.remoting.rmi.RmiServiceExporter) RemoteException(java.rmi.RemoteException)

Example 2 with RmiServiceExporter

use of org.springframework.remoting.rmi.RmiServiceExporter in project dubbo by alibaba.

the class RmiProtocol method doExport.

protected <T> Runnable doExport(final T impl, Class<T> type, URL url) throws RpcException {
    final RmiServiceExporter rmiServiceExporter = new RmiServiceExporter();
    rmiServiceExporter.setRegistryPort(url.getPort());
    rmiServiceExporter.setServiceName(url.getPath());
    rmiServiceExporter.setServiceInterface(type);
    rmiServiceExporter.setService(impl);
    try {
        rmiServiceExporter.afterPropertiesSet();
    } catch (RemoteException e) {
        throw new RpcException(e.getMessage(), e);
    }
    return new Runnable() {

        public void run() {
            try {
                rmiServiceExporter.destroy();
            } catch (Throwable e) {
                logger.warn(e.getMessage(), e);
            }
        }
    };
}
Also used : RpcException(com.alibaba.dubbo.rpc.RpcException) RmiServiceExporter(org.springframework.remoting.rmi.RmiServiceExporter) RemoteException(java.rmi.RemoteException)

Aggregations

RemoteException (java.rmi.RemoteException)2 RmiServiceExporter (org.springframework.remoting.rmi.RmiServiceExporter)2 RpcException (com.alibaba.dubbo.rpc.RpcException)1 CommunicationException (com.alibaba.otter.shared.communication.core.exception.CommunicationException)1