Update of /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18818/src/org/mc4j/console/connection
Modified Files:
JSR160ConnectionNode.java
Log Message:
Initial context can now be set for JSR 160 connections.
Security Exceptions are now properly handled.
Index: JSR160ConnectionNode.java
===================================================================
RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection/JSR160ConnectionNode.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** JSR160ConnectionNode.java 16 Apr 2004 18:54:35 -0000 1.7
--- JSR160ConnectionNode.java 21 Apr 2004 12:56:36 -0000 1.8
***************
*** 34,37 ****
--- 34,38 ----
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
+ import javax.naming.Context;
***************
*** 59,62 ****
--- 60,72 ----
JMXServiceURL url = new JMXServiceURL(this.connectionSettings.getServerUrl());
+ HashMap env = new HashMap();
+
+ if ((connectionSettings.getInitialContextName() != null) &&
+ (connectionSettings.getInitialContextName().trim().length() > 0)) {
+ env.put(Context.INITIAL_CONTEXT_FACTORY, connectionSettings.getInitialContextName());
+ } else {
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
+ }
+
String[] credentials =
new String[] {
***************
*** 64,69 ****
this.connectionSettings.getCredentials() };
! HashMap env = new HashMap();
! env.put("jmx.remote.credentials", credentials);
this.jmxConnector = JMXConnectorFactory.connect(url, env);
--- 74,78 ----
this.connectionSettings.getCredentials() };
! env.put(JMXConnector.CREDENTIALS, credentials);
this.jmxConnector = JMXConnectorFactory.connect(url, env);
***************
*** 82,85 ****
--- 91,101 ----
NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(d);
+ } catch (SecurityException se) {
+ NotifyDescriptor d =
+ new NotifyDescriptor.Message("Invalid username and password combination at [" +
+ this.connectionSettings.getServerUrl() +
+ "]. \nCheck to make sure the server is running on the specified host and port.",
+ NotifyDescriptor.ERROR_MESSAGE);
+ DialogDisplayer.getDefault().notify(d);
}
}
***************
*** 108,111 ****
--- 124,131 ----
}
+ public String getDefaultInitialContext() {
+ return "com.sun.jndi.rmi.registry.RegistryContextFactory";
+ }
+
}
|