[jboss-as7-dev] AS7 Naming URL resolution
Bartosz Baranowski
bbaranow at redhat.com
Fri Mar 9 06:17:45 EST 2012
Anyone?
----- Original Message -----
From: "Bartosz Baranowski" <bbaranow at redhat.com>
To: jboss-as7-dev at lists.jboss.org
Sent: Thursday, March 8, 2012 10:02:30 AM
Subject: AS7 Naming URL resolution
Hi
Not quite sure if Im correct on this but Ive been digging a bit in naming code of AS7 and here is what Ive found(I might have missed something but..):
1. NamingContext appends Context.URL_PACKAGES_PREFIXES with "org.jboss.as.naming.interfaces"
2. The "org.jboss.as.naming.interfaces" has single interface for "java" URL - which it seems is never used.
3. InitialContext:50 has static variable which maps URL scheme to ObjectFactory. Mappings are added/removed upon Extension/Subsystem start. At runtime it holds mappings like "ejb", "corba", "iiop" and similar. This does not include handlers for URLs like 'rmi', 'ldap' etc, and this is a a glitch.
Trick here is that NamingManager and InitialContext from JDK use Context.URL_PACKAGES_PREFIXES only in case when NamingManager has no InitialContextFactoryBuilder set. So this is basically what happens when application tries lookup from AS7:
1. JDK InitialContext uses NamingManager to create default CTX - this is AS7 InitialContext impl. This step bypasses URL_PACKAGES_PREFIXES code
2. Parse lokup name - this includes some hack for "java:" prefix
3. AS7 InitialContext check if there is URL scheme and check InitialContext:50 if it contains this scheme
4. If not, use AS7 NamingContext lookup - which essentially performs lookup in ServiceBasedNamingStore.
Now this missing part which works with package prefixes makes for instance JMXConnector unusable without explicitly setting custom InitialContext factory in env. There is ofcourse AS7 wide ObjectFactory but its used only for inmodule lookups - that is in case that ServiceBasedNamingStore returns something meaningful and not throw exception. Now after this long intro:
1. org.jboss.as.naming.interfaces.java seems not to be used since "java:" is handled with some hacks - possibly this package can be removed?
2. Is there any policy against URL_PACKAGES to be used to lookup context factory ? Right now its not used, effectively removing support for code like:
String urlString = "service:jmx:rmi:///jndi/rmi://any_host:1090/jmxrmi";
JMXServiceURL serviceURL = new JMXServiceURL(urlString);
Map<String, String> env = null;
connector = JMXConnectorFactory.connect(serviceURL, env);
If not, AS7 can fallback, in case it does not find any locally cached instance of factory, to this property and try to find factory class?
More information about the jboss-as7-dev
mailing list