140 this.env = Collections.unmodifiableMap(environment); |
140 this.env = Collections.unmodifiableMap(environment); |
141 } |
141 } |
142 } |
142 } |
143 |
143 |
144 /** |
144 /** |
145 * <p>Constructs an <code>RMIConnector</code> that will connect |
145 * <p>Constructs an {@code RMIConnector} that will connect |
146 * the RMI connector server with the given address.</p> |
146 * the RMI connector server with the given address.</p> |
147 * |
147 * |
148 * <p>The address can refer directly to the connector server, |
148 * <p>The address can refer directly to the connector server, |
149 * using one of the following syntaxes:</p> |
149 * using one of the following syntaxes:</p> |
150 * |
150 * |
151 * <pre> |
151 * <pre> |
152 * service:jmx:rmi://<em>[host[:port]]</em>/stub/<em>encoded-stub</em> |
152 * service:jmx:rmi://<em>[host[:port]]</em>/stub/<em>encoded-stub</em> |
153 * service:jmx:iiop://<em>[host[:port]]</em>/ior/<em>encoded-IOR</em> |
153 * service:jmx:iiop://<em>[host[:port]]</em>/ior/<em>encoded-IOR</em> |
154 * </pre> |
154 * </pre> |
155 * |
155 * |
156 * <p>(Here, the square brackets <code>[]</code> are not part of the |
156 * <p>(Here, the square brackets {@code []} are not part of the |
157 * address but indicate that the host and port are optional.)</p> |
157 * address but indicate that the host and port are optional.)</p> |
158 * |
158 * |
159 * <p>The address can instead indicate where to find an RMI stub |
159 * <p>The address can instead indicate where to find an RMI stub |
160 * through JNDI, using one of the following syntaxes:</p> |
160 * through JNDI, using one of the following syntaxes:</p> |
161 * |
161 * |
177 * the connection. For JNDI-based addresses, these attributes can |
177 * the connection. For JNDI-based addresses, these attributes can |
178 * usefully include JNDI attributes recognized by {@link |
178 * usefully include JNDI attributes recognized by {@link |
179 * InitialContext#InitialContext(Hashtable) InitialContext}. This |
179 * InitialContext#InitialContext(Hashtable) InitialContext}. This |
180 * parameter can be null, which is equivalent to an empty Map. |
180 * parameter can be null, which is equivalent to an empty Map. |
181 * |
181 * |
182 * @exception IllegalArgumentException if <code>url</code> |
182 * @exception IllegalArgumentException if {@code url} |
183 * is null. |
183 * is null. |
184 */ |
184 */ |
185 public RMIConnector(JMXServiceURL url, Map<String,?> environment) { |
185 public RMIConnector(JMXServiceURL url, Map<String,?> environment) { |
186 this(null, url, environment); |
186 this(null, url, environment); |
187 } |
187 } |
188 |
188 |
189 /** |
189 /** |
190 * <p>Constructs an <code>RMIConnector</code> using the given RMI stub. |
190 * <p>Constructs an {@code RMIConnector} using the given RMI stub. |
191 * |
191 * |
192 * @param rmiServer an RMI stub representing the RMI connector server. |
192 * @param rmiServer an RMI stub representing the RMI connector server. |
193 * @param environment additional attributes specifying how to make |
193 * @param environment additional attributes specifying how to make |
194 * the connection. This parameter can be null, which is |
194 * the connection. This parameter can be null, which is |
195 * equivalent to an empty Map. |
195 * equivalent to an empty Map. |
196 * |
196 * |
197 * @exception IllegalArgumentException if <code>rmiServer</code> |
197 * @exception IllegalArgumentException if {@code rmiServer} |
198 * is null. |
198 * is null. |
199 */ |
199 */ |
200 public RMIConnector(RMIServer rmiServer, Map<String,?> environment) { |
200 public RMIConnector(RMIServer rmiServer, Map<String,?> environment) { |
201 this(rmiServer, null, environment); |
201 this(rmiServer, null, environment); |
202 } |
202 } |
203 |
203 |
204 /** |
204 /** |
205 * <p>Returns a string representation of this object. In general, |
205 * <p>Returns a string representation of this object. In general, |
206 * the <code>toString</code> method returns a string that |
206 * the {@code toString} method returns a string that |
207 * "textually represents" this object. The result should be a |
207 * "textually represents" this object. The result should be a |
208 * concise but informative representation that is easy for a |
208 * concise but informative representation that is easy for a |
209 * person to read.</p> |
209 * person to read.</p> |
210 * |
210 * |
211 * @return a String representation of this object. |
211 * @return a String representation of this object. |
1730 * </ul> |
1730 * </ul> |
1731 * @param rmiServer A RMI Server Stub. |
1731 * @param rmiServer A RMI Server Stub. |
1732 * @param environment An environment map, possibly containing an ORB. |
1732 * @param environment An environment map, possibly containing an ORB. |
1733 * @return the given stub. |
1733 * @return the given stub. |
1734 * @exception IllegalArgumentException if the |
1734 * @exception IllegalArgumentException if the |
1735 * <tt>java.naming.corba.orb</tt> property is specified and |
1735 * {@code java.naming.corba.orb} property is specified and |
1736 * does not point to an {@link org.omg.CORBA.ORB ORB}. |
1736 * does not point to an {@link org.omg.CORBA.ORB ORB}. |
1737 * @exception IOException if the connection to the ORB failed. |
1737 * @exception IOException if the connection to the ORB failed. |
1738 **/ |
1738 **/ |
1739 static RMIServer connectStub(RMIServer rmiServer, |
1739 static RMIServer connectStub(RMIServer rmiServer, |
1740 Map<String, ?> environment) |
1740 Map<String, ?> environment) |
1765 * stubs. However, no reference is ever kept on the ORB provided |
1765 * stubs. However, no reference is ever kept on the ORB provided |
1766 * in the <var>environment</var> map, if any. |
1766 * in the <var>environment</var> map, if any. |
1767 * @param environment An environment map, possibly containing an ORB. |
1767 * @param environment An environment map, possibly containing an ORB. |
1768 * @return An ORB. |
1768 * @return An ORB. |
1769 * @exception IllegalArgumentException if the |
1769 * @exception IllegalArgumentException if the |
1770 * <tt>java.naming.corba.orb</tt> property is specified and |
1770 * {@code java.naming.corba.orb} property is specified and |
1771 * does not point to an {@link org.omg.CORBA.ORB ORB}. |
1771 * does not point to an {@link org.omg.CORBA.ORB ORB}. |
1772 * @exception IOException if the ORB initialization failed. |
1772 * @exception IOException if the ORB initialization failed. |
1773 **/ |
1773 **/ |
1774 static Object resolveOrb(Map<String, ?> environment) |
1774 static Object resolveOrb(Map<String, ?> environment) |
1775 throws IOException { |
1775 throws IOException { |
1791 } |
1791 } |
1792 |
1792 |
1793 /** |
1793 /** |
1794 * Read RMIConnector fields from an {@link java.io.ObjectInputStream |
1794 * Read RMIConnector fields from an {@link java.io.ObjectInputStream |
1795 * ObjectInputStream}. |
1795 * ObjectInputStream}. |
1796 * Calls <code>s.defaultReadObject()</code> and then initializes |
1796 * Calls {@code s.defaultReadObject()} and then initializes |
1797 * all transient variables that need initializing. |
1797 * all transient variables that need initializing. |
1798 * @param s The ObjectInputStream to read from. |
1798 * @param s The ObjectInputStream to read from. |
1799 * @exception InvalidObjectException if none of <var>rmiServer</var> stub |
1799 * @exception InvalidObjectException if none of <var>rmiServer</var> stub |
1800 * or <var>jmxServiceURL</var> are set. |
1800 * or <var>jmxServiceURL</var> are set. |
1801 * @see #RMIConnector(JMXServiceURL,Map) |
1801 * @see #RMIConnector(JMXServiceURL,Map) |
1816 * ObjectOutputStream}. |
1816 * ObjectOutputStream}. |
1817 * <p>Connects the underlying RMIServer stub to an ORB, if needed, |
1817 * <p>Connects the underlying RMIServer stub to an ORB, if needed, |
1818 * before serializing it. This is done using the environment |
1818 * before serializing it. This is done using the environment |
1819 * map that was provided to the constructor, if any, and as documented |
1819 * map that was provided to the constructor, if any, and as documented |
1820 * in {@link javax.management.remote.rmi}.</p> |
1820 * in {@link javax.management.remote.rmi}.</p> |
1821 * <p>This method then calls <code>s.defaultWriteObject()</code>. |
1821 * <p>This method then calls {@code s.defaultWriteObject()}. |
1822 * Usually, <var>rmiServer</var> is null if this object |
1822 * Usually, <var>rmiServer</var> is null if this object |
1823 * was constructed with a JMXServiceURL, and <var>jmxServiceURL</var> |
1823 * was constructed with a JMXServiceURL, and <var>jmxServiceURL</var> |
1824 * is null if this object is constructed with a RMIServer stub. |
1824 * is null if this object is constructed with a RMIServer stub. |
1825 * <p>Note that the environment Map is not serialized, since the objects |
1825 * <p>Note that the environment Map is not serialized, since the objects |
1826 * it contains are assumed to be contextual and relevant only |
1826 * it contains are assumed to be contextual and relevant only |
1937 |
1937 |
1938 /** |
1938 /** |
1939 * Lookup the RMIServer stub in a directory. |
1939 * Lookup the RMIServer stub in a directory. |
1940 * @param jndiURL A JNDI URL indicating the location of the Stub |
1940 * @param jndiURL A JNDI URL indicating the location of the Stub |
1941 * (see {@link javax.management.remote.rmi}), e.g.: |
1941 * (see {@link javax.management.remote.rmi}), e.g.: |
1942 * <ul><li><tt>rmi://registry-host:port/rmi-stub-name</tt></li> |
1942 * <ul><li>{@code rmi://registry-host:port/rmi-stub-name}</li> |
1943 * <li>or <tt>iiop://cosnaming-host:port/iiop-stub-name</tt></li> |
1943 * <li>or {@code iiop://cosnaming-host:port/iiop-stub-name}</li> |
1944 * <li>or <tt>ldap://ldap-host:port/java-container-dn</tt></li> |
1944 * <li>or {@code ldap://ldap-host:port/java-container-dn}</li> |
1945 * </ul> |
1945 * </ul> |
1946 * @param env the environment Map passed to the connector. |
1946 * @param env the environment Map passed to the connector. |
1947 * @param isIiop true if the stub is expected to be an IIOP stub. |
1947 * @param isIiop true if the stub is expected to be an IIOP stub. |
1948 * @return The retrieved RMIServer stub. |
1948 * @return The retrieved RMIServer stub. |
1949 * @exception NamingException if the stub couldn't be found. |
1949 * @exception NamingException if the stub couldn't be found. |