0 Replies Latest reply on Apr 28, 2004 4:49 AM by Andrew Oliver

    TODO: (post M1) unqued delivery

    Andrew Oliver Master

      Hi,

      I'm having a slight problem with the jndi stuff for the testing. I am trying to use the jboss naming service rather than the fake contet stuff.

      I have set up the jndi.properties file to be:

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

      Next I stepped through the org.jboss.naming.NamingService.startService() method. The first bit loads up the properties from the jndi.properties file and sets the in System.properties, as expected there is no java.naming.provider.url there. Also, when I do a System.getProperty("java.naming.provider.url") at any stage nothing is returned.

      However, once the first InitialContext is created and it's environment got, java.naming.provider.url is there! (i.e. it is in env below)

       InitialContext iniCtx = new InitialContext();
       Hashtable env = iniCtx.getEnvironment();
      




      I followed this through, and new InitialContext()
      calls javax.naming.InitialContext.init() //This initialises the environment for the InitialContext
      which calls javax.naming.internal.ResourceManager.getInitialEnvironment()
      which calls javax.naming.internal.VersionHelper.getJndiProperties()

      VersionHelper.getProperties() looks like this
       String[] getJndiProperties() {
       if (getSystemPropsFailed) {
       return null; // after one failure, don't bother trying again
       }
       Properties sysProps = (Properties) AccessController.doPrivileged(
       new PrivilegedAction() {
       public Object run() {
       try {
       return System.getProperties();
       } catch (SecurityException e) {
       getSystemPropsFailed = true;
       return null;
       }
       }
       }
       );
       if (sysProps == null) {
       return null;
       }
       String[] jProps = new String[PROPS.length];
       for (int i = 0; i < PROPS.length; i++) {
       jProps = sysProps.getProperty(PROPS);
       }
       return jProps;
       }
      
       String getJndiProperty(final int i) {
       return (String) AccessController.doPrivileged(
       new PrivilegedAction() {
       public Object run() {
       try {
       return System.getProperty(PROPS);
       } catch (SecurityException e) {
       return null;
       }
       }
       }
       );
       }
      




      In this funky looking code (which to be honest I don't understand the special bits) java.naming.provider.url and jnp://localhost:1099 are returned. I'm wondering
      a) Why doesn't this appear in JBoss when starting that without the java.naming.provider.url in the jndi.properties
      b) What the AccessController stuff does special to magically create the java.naming.provider.url=jnp://localhost:1099

      Any ideas?

      Cheers,

      Kab