简体   繁体   English

所有的jndi.properties属性名称是什么?

[英]what are all the jndi.properties property names?

What are the possible property names for a jndi.properties key? jndi.properties键的可能的属性名称是什么? I cannot find documentation as to what all the possible key names are. 我找不到有关所有可能的键名的文档。

How do I output the principal, credentials and remote key/value pairs for jndi.properties? 如何输出jndi.properties的主体,凭证和远程键/值对?

-run:
     [java] Sep 12, 2014 6:36:43 PM dur.bounceme.net.remotelookup.RemoteLookup run
     [java] INFO: java.naming.factory.initial   com.sun.enterprise.naming.impl.SerialInitContextFactory
     [java] Sep 12, 2014 6:36:43 PM dur.bounceme.net.remotelookup.RemoteLookup run
     [java] INFO: java.naming.factory.url.pkgs  com.sun.enterprise.naming
     [java] Sep 12, 2014 6:36:43 PM dur.bounceme.net.remotelookup.RemoteLookup run
     [java] INFO: java.naming.factory.state com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl

run:

BUILD SUCCESSFUL
Total time: 13 seconds
thufir@dur:~/NetBeansProjects/LegacyEJB$ 
thufir@dur:~/NetBeansProjects/LegacyEJB$ cat src/java/jndi.properties 
java.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=server.local\:1199
java.naming.security.principal=user
java.naming.security.credentials=password
remote=net.bounceme.ix.Foo
thufir@dur:~/NetBeansProjects/LegacyEJB$ 

as can be seen, not all the key/value pairs are being output. 可以看出,并非所有键/值对都在输出。 Why? 为什么?

For the "remote" name and value, should that go in a different properties file? 对于“远程”名称和值,是否应将其放在其他属性文件中?

Main class: 主班:

package dur.bounceme.net.remotelookup;

import java.util.Enumeration;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class RemoteLookup {

    private static final Logger log = Logger.getLogger(RemoteLookup.class.getName());
    private final MyProps p = new MyProps();

    public static void main(String... args) {
        try {
            new RemoteLookup().run();
        } catch (NamingException ex) {
            Logger.getLogger(RemoteLookup.class.getName()).log(Level.SEVERE, ex.getExplanation(), ex);
        }
    }

    private void run() throws NamingException {
        Properties jndi = p.getJNDI();
        Enumeration e = jndi.propertyNames();
        while (e.hasMoreElements()) {
            String key = (String) e.nextElement();
            String val = jndi.getProperty(key);
            log.info(key + "\t" + val);
        }
        Context ic = new InitialContext();
//        MyRemote mr = (MyRemote) ic.lookup("java:comp/env/ejb/Foo");  //
    }
}

to read properties files, has worked in the past: 读取属性文件,过去曾有过工作:

package dur.bounceme.net.remotelookup;

import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MyProps {

    private static final Logger log = Logger.getLogger(MyProps.class.getName());
    private final Properties jndi = new Properties();

    public MyProps() {
        try {
            loadJNDI();
            String name = jndi.getProperty("name");
        } catch (IOException ex) {
            Logger.getLogger(MyProps.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public Properties getJNDI() {
        return jndi;
    }

    private void loadJNDI() throws IOException {
        jndi.load(MyProps.class.getResourceAsStream("/jndi.properties"));
    }

}

more to the point, what should the key be named as for the values? 更重要的是,该键应如何命名?

------------------------------------------------------edit------------------------- -------------------------------------------------- - - 编辑 - - - - - - - - - - - - -

java.naming.factory.initial=TO_BE_CHANGED_BY_USER java.naming.factory.object=TO_BE_CHANGED_BY_USER java.naming.factory.state=TO_BE_CHANGED_BY_USER java.naming.factory.control=TO_BE_CHANGED_BY_USER java.naming.factory.url.pkgs=TO_BE_CHANGED_BY_USER java.naming.provider.url=TO_BE_CHANGED_BY_USER java.naming.dns.url=TO_BE_CHANGED_BY_USER java.naming.factory.initial = TO_BE_CHANGED_BY_USER java.naming.factory.object = TO_BE_CHANGED_BY_USER java.naming.factory.state = TO_BE_CHANGED_BY_USER java.naming.factory.control = TO_BE_CHANGED_BY_USER java.naming.factory.CHAN = BY .provider.url = TO_BE_CHANGED_BY_USER java.naming.dns.url = TO_BE_CHANGED_BY_USER

from: 从:

http://www.pressinganswer.com/433577/how-to-access-datasource-in-geronimo-via-jndi-by-remote-client-application http://www.pressinganswer.com/433577/how-to-access-datasource-in-geronimo-via-jndi-by-remote-client-application

您需要在JNDI文档页面上查找每个提供程序的文档(在您的情况下为COSNaming提供程序)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM