2362N/A * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <p>An RMI object representing a connector server. Remote clients 0N/A * can make connections using the {@link #newClient(Object)} method. This 0N/A * method returns an RMI object representing the connection.</p> 0N/A * <p>User code does not usually reference this class directly. 0N/A * RMI connection servers are usually created with the class {@link 0N/A * RMIConnectorServer}. Remote clients usually create connections 0N/A * either with {@link javax.management.remote.JMXConnectorFactory} 0N/A * or by instantiating {@link RMIConnector}.</p> 0N/A * <p>This is an abstract class. Concrete subclasses define the 0N/A * details of the client connection objects, such as whether they use 0N/A * <p>Constructs a new <code>RMIServerImpl</code>.</p> 0N/A * @param env the environment containing attributes for the new 0N/A * <code>RMIServerImpl</code>. Can be null, which is equivalent 0N/A * <p>Exports this RMI object.</p> 0N/A * @exception IOException if this RMI object cannot be exported. 0N/A * Returns a remotable stub for this server object. 0N/A * @return a remotable stub. 0N/A * @exception IOException if the stub cannot be obtained - e.g the 0N/A * RMIServerImpl has not been exported yet. 0N/A * <p>Sets the default <code>ClassLoader</code> for this connector 0N/A * server. New client connections will use this classloader. 0N/A * Existing client connections are unaffected.</p> 0N/A * @param cl the new <code>ClassLoader</code> to be used by this 0N/A * @see #getDefaultClassLoader 0N/A * <p>Gets the default <code>ClassLoader</code> used by this connector 0N/A * @return the default <code>ClassLoader</code> used by this 0N/A * connector server.</p> 0N/A * @see #setDefaultClassLoader 0N/A * <p>Sets the <code>MBeanServer</code> to which this connector 0N/A * server is attached. New client connections will interact 0N/A * with this <code>MBeanServer</code>. Existing client connections are 0N/A * @param mbs the new <code>MBeanServer</code>. Can be null, but 0N/A * new client connections will be refused as long as it is. 0N/A * @see #getMBeanServer 0N/A * <p>The <code>MBeanServer</code> to which this connector server 0N/A * is attached. This is the last value passed to {@link 0N/A * #setMBeanServer} on this object, or null if that method has 0N/A * never been called.</p> 0N/A * @return the <code>MBeanServer</code> to which this connector 0N/A * @see #setMBeanServer 0N/A // Expected format is: "protocol-version implementation-name" 0N/A return "1.0 java_runtime_" +
0N/A * <p>Creates a new client connection. This method calls {@link 0N/A * #makeClient makeClient} and adds the returned client connection 0N/A * object to an internal list. When this 0N/A * <code>RMIServerImpl</code> is shut down via its {@link 0N/A * #close()} method, the {@link RMIConnection#close() close()} 0N/A * method of each object remaining in the list is called.</p> 0N/A * <p>The fact that a client connection object is in this internal 0N/A * list does not prevent it from being garbage collected.</p> 0N/A * @param credentials this object specifies the user-defined 0N/A * credentials to be passed in to the server in order to 0N/A * authenticate the caller before creating the 0N/A * <code>RMIConnection</code>. Can be null. 0N/A * @return the newly-created <code>RMIConnection</code>. This is 0N/A * usually the object created by <code>makeClient</code>, though 0N/A * an implementation may choose to wrap that object in another 0N/A * object implementing <code>RMIConnection</code>. 0N/A * @exception IOException if the new client object cannot be 0N/A * created or exported. 0N/A * @exception SecurityException if the given credentials do not allow 0N/A * the server to authenticate the user successfully. 0N/A * @exception IllegalStateException if {@link #getMBeanServer()} 0N/A * This method could be overridden by subclasses defined in this package 0N/A * to perform additional operations specific to the underlying transport 0N/A * before creating the new client connection. 0N/A * Create the JAAS-based authenticator only if authentication 744N/A // can be removed only by a JMXConnectionNotification listener 0N/A * <p>Creates a new client connection. This method is called by 0N/A * the public method {@link #newClient(Object)}.</p> 0N/A * @param connectionId the ID of the new connection. Every 0N/A * connection opened by this connector server will have a 0N/A * different ID. The behavior is unspecified if this parameter is 0N/A * @param subject the authenticated subject. Can be null. 0N/A * @return the newly-created <code>RMIConnection</code>. 0N/A * @exception IOException if the new client object cannot be 0N/A * created or exported. 0N/A * <p>Closes a client connection made by {@link #makeClient makeClient}. 0N/A * @param client a connection previously returned by 0N/A * <code>makeClient</code> on which the <code>closeClient</code> 0N/A * method has not previously been called. The behavior is 0N/A * unspecified if these conditions are violated, including the 0N/A * case where <code>client</code> is null. 0N/A * @exception IOException if the client connection cannot be 0N/A * <p>Returns the protocol string for this object. The string is 0N/A * @return the protocol string for this object. 0N/A * <p>Method called when a client connection created by {@link 0N/A * #makeClient makeClient} is closed. A subclass that defines 0N/A * <code>makeClient</code> must arrange for this method to be 0N/A * called when the resultant object's {@link RMIConnection#close() 0N/A * close} method is called. This enables it to be removed from 0N/A * the <code>RMIServerImpl</code>'s list of connections. It is 0N/A * not an error for <code>client</code> not to be in that 0N/A * <p>After removing <code>client</code> from the list of 0N/A * connections, this method calls {@link #closeClient 0N/A * closeClient(client)}.</p> 0N/A * @param client the client connection that has been closed. 0N/A * @exception IOException if {@link #closeClient} throws this 0N/A * @exception NullPointerException if <code>client</code> is null. 0N/A /* It is not a bug for this loop not to find the client. In 0N/A our close() method, we remove a client from the list before 0N/A calling its close() method. */ 0N/A * <p>Closes this connection server. This method first calls the 0N/A * {@link #closeServer()} method so that no new client connections 0N/A * will be accepted. Then, for each remaining {@link 0N/A * RMIConnection} object returned by {@link #makeClient 0N/A * makeClient}, its {@link RMIConnection#close() close} method is 0N/A * <p>The behavior when this method is called more than once is 0N/A * <p>If {@link #closeServer()} throws an 0N/A * <code>IOException</code>, the individual connections are 0N/A * nevertheless closed, and then the <code>IOException</code> is 0N/A * thrown from this method.</p> 0N/A * <p>If {@link #closeServer()} returns normally but one or more 0N/A * of the individual connections throws an 0N/A * <code>IOException</code>, then, after closing all the 0N/A * connections, one of those <code>IOException</code>s is thrown 0N/A * from this method. If more than one connection throws an 0N/A * <code>IOException</code>, it is unspecified which one is thrown 0N/A * from this method.</p> 0N/A * @exception IOException if {@link #closeServer()} or one of the 0N/A * {@link RMIConnection#close()} calls threw 0N/A * <code>IOException</code>. 0N/A // Loop to close all clients 0N/A /* Loop until we find a non-null client. Because we called 0N/A dropDeadReferences(), this will usually be the first 0N/A element of the list, but a garbage collection could have 0N/A happened in between. */ 0N/A * <p>Called by {@link #close()} to close the connector server. 0N/A * After returning from this method, the connector server must 0N/A * not accept any new connections.</p> 0N/A * @exception IOException if the attempt to close the connector 6417N/A * According to the rules specified in the javax.management.remote 6417N/A * package description, a numeric IPv6 address (detected by the 6417N/A * presence of otherwise forbidden ":" character) forming a part 6417N/A * of the connection id must be enclosed in square brackets. 0N/A //Notification buffer is lazily created when the first client connects 0N/A /** List of WeakReference values. Each one references an 0N/A RMIConnection created by this object, or null if the 0N/A RMIConnection has been garbage-collected. */