java.rmi.server.RMIServerSocketFactory Java Examples

The following examples show how to use java.rmi.server.RMIServerSocketFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TCPEndpoint.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return new server socket to listen for connections on this endpoint.
 */
ServerSocket newServerSocket() throws IOException {
    if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
        TCPTransport.tcpLog.log(Log.VERBOSE,
            "creating server socket on " + this);
    }

    RMIServerSocketFactory serverFactory = ssf;
    if (serverFactory == null) {
        serverFactory = chooseFactory();
    }
    ServerSocket server = serverFactory.createServerSocket(listenPort);

    // if we listened on an anonymous port, set the default port
    // (for this socket factory)
    if (listenPort == 0)
        setDefaultPort(server.getLocalPort(), csf, ssf);

    return server;
}
 
Example #2
Source File: AlfrescoRmiRegistryFactoryBean.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected Registry getRegistry(
        String registryHost,
        int registryPort,
        RMIClientSocketFactory clientSocketFactory,
        RMIServerSocketFactory serverSocketFactory) throws RemoteException
{
    if(enabled)
    {
        return super.getRegistry(registryHost, registryPort, clientSocketFactory, serverSocketFactory);
    }
    else
    {
        throw new RemoteException(ERR_MSG_NOT_ENABLED);
    }
}
 
Example #3
Source File: TCPEndpoint.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return new server socket to listen for connections on this endpoint.
 */
ServerSocket newServerSocket() throws IOException {
    if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
        TCPTransport.tcpLog.log(Log.VERBOSE,
            "creating server socket on " + this);
    }

    RMIServerSocketFactory serverFactory = ssf;
    if (serverFactory == null) {
        serverFactory = chooseFactory();
    }
    ServerSocket server = serverFactory.createServerSocket(listenPort);

    // if we listened on an anonymous port, set the default port
    // (for this socket factory)
    if (listenPort == 0)
        setDefaultPort(server.getLocalPort(), csf, ssf);

    return server;
}
 
Example #4
Source File: ActivationGroupImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a default activation group implementation.
 *
 * @param id the group's identifier
 * @param data ignored
 */
public ActivationGroupImpl(ActivationGroupID id, MarshalledObject<?> data)
    throws RemoteException
{
    super(id);
    groupID = id;

    /*
     * Unexport activation group impl and attempt to export it on
     * an unshared anonymous port.  See 4692286.
     */
    unexportObject(this, true);
    RMIServerSocketFactory ssf = new ServerSocketFactoryImpl();
    UnicastRemoteObject.exportObject(this, 0, null, ssf);

    if (System.getSecurityManager() == null) {
        try {
            // Provide a default security manager.
            System.setSecurityManager(new SecurityManager());

        } catch (Exception e) {
            throw new RemoteException("unable to set security manager", e);
        }
    }
}
 
Example #5
Source File: ActivationGroupImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a default activation group implementation.
 *
 * @param id the group's identifier
 * @param data ignored
 */
public ActivationGroupImpl(ActivationGroupID id, MarshalledObject<?> data)
    throws RemoteException
{
    super(id);
    groupID = id;

    /*
     * Unexport activation group impl and attempt to export it on
     * an unshared anonymous port.  See 4692286.
     */
    unexportObject(this, true);
    RMIServerSocketFactory ssf = new ServerSocketFactoryImpl();
    UnicastRemoteObject.exportObject(this, 0, null, ssf);

    if (System.getSecurityManager() == null) {
        try {
            // Provide a default security manager.
            System.setSecurityManager(new SecurityManager());

        } catch (Exception e) {
            throw new RemoteException("unable to set security manager", e);
        }
    }
}
 
Example #6
Source File: RmiServiceExporter.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Locate or create the RMI registry for this exporter.
 * @param registryHost the registry host to use (if this is specified,
 * no implicit creation of a RMI registry will happen)
 * @param registryPort the registry port to use
 * @param clientSocketFactory the RMI client socket factory for the registry (if any)
 * @param serverSocketFactory the RMI server socket factory for the registry (if any)
 * @return the RMI registry
 * @throws RemoteException if the registry couldn't be located or created
 */
protected Registry getRegistry(String registryHost, int registryPort,
		@Nullable RMIClientSocketFactory clientSocketFactory, @Nullable RMIServerSocketFactory serverSocketFactory)
		throws RemoteException {

	if (registryHost != null) {
		// Host explicitly specified: only lookup possible.
		if (logger.isDebugEnabled()) {
			logger.debug("Looking for RMI registry at port '" + registryPort + "' of host [" + registryHost + "]");
		}
		Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory);
		testRegistry(reg);
		return reg;
	}

	else {
		return getRegistry(registryPort, clientSocketFactory, serverSocketFactory);
	}
}
 
Example #7
Source File: TCPEndpoint.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return new server socket to listen for connections on this endpoint.
 */
ServerSocket newServerSocket() throws IOException {
    if (TCPTransport.tcpLog.isLoggable(Log.VERBOSE)) {
        TCPTransport.tcpLog.log(Log.VERBOSE,
            "creating server socket on " + this);
    }

    RMIServerSocketFactory serverFactory = ssf;
    if (serverFactory == null) {
        serverFactory = chooseFactory();
    }
    ServerSocket server = serverFactory.createServerSocket(listenPort);

    // if we listened on an anonymous port, set the default port
    // (for this socket factory)
    if (listenPort == 0)
        setDefaultPort(server.getLocalPort(), csf, ssf);

    return server;
}
 
Example #8
Source File: RMIExporterTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Remote exportObject(Remote obj,
                           int port,
                           RMIClientSocketFactory csf,
                           RMIServerSocketFactory ssf)
    throws RemoteException {
    System.out.println("CustomRMIExporter::exportObject():: " +
                       "Remote = " + obj);
    if (obj.toString().startsWith(
            "javax.management.remote.rmi.RMIJRMPServerImpl"))
        rmiServerExported = true;
    if (obj.toString().startsWith(
            "javax.management.remote.rmi.RMIConnectionImpl"))
        rmiConnectionExported = true;
    return UnicastRemoteObject.exportObject(obj, port, csf, ssf);
}
 
Example #9
Source File: SingleEntryRegistry.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
SingleEntryRegistry(int port,
                    RMIClientSocketFactory csf,
                    RMIServerSocketFactory ssf,
                    String name,
                    Remote object)
        throws RemoteException {
    super(port, csf, ssf);
    this.name = name;
    this.object = object;
}
 
Example #10
Source File: AdminDUnitTestCase.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private JMXConnector createJMXConnector() throws Exception {
  JMXServiceURL url = new JMXServiceURL(this.urlString);
  RMIServerSocketFactory ssf = new MX4JServerSocketFactory(
      true, true, "any", "any", new LocalLogWriter(LogWriterImpl.FINE_LEVEL), new Properties());
  RMIClientSocketFactory csf = new SslRMIClientSocketFactory();
  
  Map env = new HashMap();
  env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, ssf);
  env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
    
  return JMXConnectorFactory.connect(url, env);
}
 
Example #11
Source File: Activation.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Recover activation state from the reliable log and initialize
 * activation services.
 */
private static void startActivation(int port,
                                    RMIServerSocketFactory ssf,
                                    String logName,
                                    String[] childArgs)
    throws Exception
{
    ReliableLog log = new ReliableLog(logName, new ActLogHandler());
    Activation state = (Activation) log.recover();
    state.init(port, ssf, log, childArgs);
}
 
Example #12
Source File: RMIConnectorServer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static RMIServerImpl newJRMPServer(Map<String, ?> env, int port)
        throws IOException {
    RMIClientSocketFactory csf = (RMIClientSocketFactory)
        env.get(RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE);
    RMIServerSocketFactory ssf = (RMIServerSocketFactory)
        env.get(RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE);
    return new RMIJRMPServerImpl(port, csf, ssf, env);
}
 
Example #13
Source File: RMIConnectorServer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static RMIServerImpl newJRMPServer(Map<String, ?> env, int port)
        throws IOException {
    RMIClientSocketFactory csf = (RMIClientSocketFactory)
        env.get(RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE);
    RMIServerSocketFactory ssf = (RMIServerSocketFactory)
        env.get(RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE);
    return new RMIJRMPServerImpl(port, csf, ssf, env);
}
 
Example #14
Source File: Activation.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
ActivationSystemImpl(int port, RMIServerSocketFactory ssf)
    throws RemoteException
{
    /* Server ref must be created and assigned before remote object
     * 'this' can be exported.
     */
    LiveRef lref = new LiveRef(new ObjID(4), port, null, ssf);
    UnicastServerRef uref = new SameHostOnlyServerRef(lref,
            "ActivationSystem.nonLocalAccess");
    ref = uref;
    uref.exportObject(this, null);
}
 
Example #15
Source File: RMIJRMPServerImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * <p>Creates a new {@link RMIServer} object that will be exported
 * on the given port using the given socket factories.</p>
 *
 * @param port the port on which this object and the {@link
 * RMIConnectionImpl} objects it creates will be exported.  Can be
 * zero, to indicate any available port.
 *
 * @param csf the client socket factory for the created RMI
 * objects.  Can be null.
 *
 * @param ssf the server socket factory for the created RMI
 * objects.  Can be null.
 *
 * @param env the environment map.  Can be null.
 *
 * @exception IOException if the {@link RMIServer} object
 * cannot be created.
 *
 * @exception IllegalArgumentException if <code>port</code> is
 * negative.
 */
public RMIJRMPServerImpl(int port,
                         RMIClientSocketFactory csf,
                         RMIServerSocketFactory ssf,
                         Map<String,?> env)
        throws IOException {

    super(env);

    if (port < 0)
        throw new IllegalArgumentException("Negative port: " + port);

    this.port = port;
    this.csf = csf;
    this.ssf = ssf;
    this.env = (env == null) ? Collections.<String, Object>emptyMap() : env;

    String[] credentialsTypes
            = (String[]) this.env.get(EnvHelp.CREDENTIAL_TYPES);
    List<String> types = null;
    if (credentialsTypes != null) {
        types = new ArrayList<>();
        for (String type : credentialsTypes) {
            if (type == null) {
                throw new IllegalArgumentException("A credential type is null.");
            }
            ReflectUtil.checkPackageAccess(type);
            types.add(type);
        }
    }
    exportedWrapper = types != null ?
            new ExportedWrapper(this, types) :
            null;
}
 
Example #16
Source File: RMIExporterTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Remote exportObject(Remote obj,
                           int port,
                           RMIClientSocketFactory csf,
                           RMIServerSocketFactory ssf)
    throws RemoteException {
    System.out.println("CustomRMIExporter::exportObject():: " +
                       "Remote = " + obj);
    if (obj.toString().startsWith(
            "javax.management.remote.rmi.RMIJRMPServerImpl"))
        rmiServerExported = true;
    if (obj.toString().startsWith(
            "javax.management.remote.rmi.RMIConnectionImpl"))
        rmiConnectionExported = true;
    return UnicastRemoteObject.exportObject(obj, port, csf, ssf);
}
 
Example #17
Source File: UnicastServerRef2.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Unicast server remote reference to be exported
 * on the specified port.
 */
public UnicastServerRef2(int port,
                         RMIClientSocketFactory csf,
                         RMIServerSocketFactory ssf,
                         ObjectInputFilter filter)
{
    super(new LiveRef(port, csf, ssf), filter);
}
 
Example #18
Source File: Activation.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
SystemRegistryImpl(int port,
                   RMIClientSocketFactory csf,
                   RMIServerSocketFactory ssf,
                   ActivationSystem systemStub)
    throws RemoteException
{
    super(port, csf, ssf);
    this.systemStub = systemStub;
}
 
Example #19
Source File: Activation.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
ActivationSystemImpl(int port, RMIServerSocketFactory ssf)
    throws RemoteException
{
    /* Server ref must be created and assigned before remote object
     * 'this' can be exported.
     */
    LiveRef lref = new LiveRef(new ObjID(4), port, null, ssf);
    UnicastServerRef uref = new UnicastServerRef(lref);
    ref = uref;
    uref.exportObject(this, null);
}
 
Example #20
Source File: TCPEndpoint.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a custom socket factory endpoint for a specified host and port.
 * This should not be used by external classes to create endpoints
 * for servers in this VM; use getLocalEndpoint instead.
 */
public TCPEndpoint(String host, int port, RMIClientSocketFactory csf,
                   RMIServerSocketFactory ssf)
{
    if (host == null)
        host = "";
    this.host = host;
    this.port = port;
    this.csf = csf;
    this.ssf = ssf;
}
 
Example #21
Source File: RMIExporterTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Remote exportObject(Remote obj,
                           int port,
                           RMIClientSocketFactory csf,
                           RMIServerSocketFactory ssf)
    throws RemoteException {
    System.out.println("CustomRMIExporter::exportObject():: " +
                       "Remote = " + obj);
    if (obj.toString().startsWith(
            "javax.management.remote.rmi.RMIJRMPServerImpl"))
        rmiServerExported = true;
    if (obj.toString().startsWith(
            "javax.management.remote.rmi.RMIConnectionImpl"))
        rmiConnectionExported = true;
    return UnicastRemoteObject.exportObject(obj, port, csf, ssf);
}
 
Example #22
Source File: Activation.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
ActivationSystemImpl(int port, RMIServerSocketFactory ssf)
    throws RemoteException
{
    /* Server ref must be created and assigned before remote object
     * 'this' can be exported.
     */
    LiveRef lref = new LiveRef(new ObjID(4), port, null, ssf);
    UnicastServerRef uref = new UnicastServerRef(lref);
    ref = uref;
    uref.exportObject(this, null);
}
 
Example #23
Source File: Activation.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
SystemRegistryImpl(int port,
                   RMIClientSocketFactory csf,
                   RMIServerSocketFactory ssf,
                   ActivationSystem systemStub)
    throws RemoteException
{
    super(port, csf, ssf);
    this.systemStub = systemStub;
}
 
Example #24
Source File: Activation.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a new Activator on a specified port.
 */
ActivatorImpl(int port, RMIServerSocketFactory ssf)
    throws RemoteException
{
    /* Server ref must be created and assigned before remote object
     * 'this' can be exported.
     */
    LiveRef lref =
        new LiveRef(new ObjID(ObjID.ACTIVATOR_ID), port, null, ssf);
    UnicastServerRef uref = new UnicastServerRef(lref);
    ref = uref;
    uref.exportObject(this, null, false);
}
 
Example #25
Source File: Activation.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
SystemRegistryImpl(int port,
                   RMIClientSocketFactory csf,
                   RMIServerSocketFactory ssf,
                   ActivationSystem systemStub)
    throws RemoteException
{
    super(port, csf, ssf);
    this.systemStub = systemStub;
}
 
Example #26
Source File: Activation.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
ActivationSystemImpl(int port, RMIServerSocketFactory ssf)
    throws RemoteException
{
    /* Server ref must be created and assigned before remote object
     * 'this' can be exported.
     */
    LiveRef lref = new LiveRef(new ObjID(4), port, null, ssf);
    UnicastServerRef uref = new UnicastServerRef(lref);
    ref = uref;
    uref.exportObject(this, null);
}
 
Example #27
Source File: SingleEntryRegistry.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
SingleEntryRegistry(int port,
                    RMIClientSocketFactory csf,
                    RMIServerSocketFactory ssf,
                    String name,
                    Remote object)
        throws RemoteException {
    super(port, csf, ssf);
    this.name = name;
    this.object = object;
}
 
Example #28
Source File: LiveRef.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a new live reference for a server object in the local
 * address space, to use sockets of the specified type.
 */
public LiveRef(int port,
               RMIClientSocketFactory csf,
               RMIServerSocketFactory ssf)
{
    this((new ObjID()), port, csf, ssf);
}
 
Example #29
Source File: UnicastServerRef2.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a Unicast server remote reference to be exported
 * on the specified port.
 */
public UnicastServerRef2(int port,
                         RMIClientSocketFactory csf,
                         RMIServerSocketFactory ssf,
                         ObjectInputFilter filter)
{
    super(new LiveRef(port, csf, ssf), filter);
}
 
Example #30
Source File: RegistryImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a new RegistryImpl on the specified port with the
 * given custom socket factory pair.
 */
public RegistryImpl(int port,
                    RMIClientSocketFactory csf,
                    RMIServerSocketFactory ssf)
    throws RemoteException
{
    this(port, csf, ssf, RegistryImpl::registryFilter);
}