找回密码
 FreeOZ用户注册
查看: 1394|回复: 1
打印 上一主题 下一主题

Redistribution JNP Server: Standalone Naming Service From JBoss 3.2.7

[复制链接]
跳转到指定楼层
1#
发表于 2-10-2009 17:46:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册

x
I need JNDI service for my server-side application running without J2EE
platform. I chose JND Server from JBoss, which was introduced here:

http://www.javaworld.com/javawor ... 19-jndi.html?page=1

However, the article above was posted in 2002. There are some incompatible
issues for the newer version of JBoss. Now I extracted the JNP Server from
JBoss 3.2.7, the lowest stable version I can find from the official website.

Usage
1. Make sure you've install JRE and ANT, and set the environment variables
such as PATH and JAVA_HOME properly.
2. Uncompress my ZIP file into a directory, e.g. /opt/jnpserver-3.2.7 in Linux
or C:\tools\jnpserver-3.2.7
3. Change to the directory
4. Run ant
$ant

That's all.
You will get a standalone JNDI service running at port 1099.

[ 本帖最后由 key 于 2-10-2009 16:50 编辑 ]

jnpserver-3.2.7.zip

850.12 KB, 下载次数: 8

回复  

使用道具 举报

2#
 楼主| 发表于 2-10-2009 18:05:11 | 只看该作者

Test Case for the JNP Server

import javax.naming.Context;
import javax.naming.InitialContext;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
*
* @author key - freeoz
*/
public class SimpleTest {
    private static int testValue;

    public SimpleTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
        System.setProperty("java.naming.provider.url", "localhost:1099");
        System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
        System.setProperty("java.naming.factory.url", "jnp://www.jboss.org:1099");
        testValue = (int)(Math.random() * 0xFFFFFF);
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }


    @Test
    public void initJndi() throws Exception{
        Context ctx = new InitialContext();
        System.out.println("Bind test value " + testValue + " to JNDI service");
        ctx.bind("TestValue", testValue);
        ctx.close();        
    }

    @Test
    public void testJndi() throws Exception {
        Context ctx = new InitialContext();
        Integer v = (Integer)ctx.lookup("TestValue");
        System.out.println("Retrieve value = " + v);
        ctx.close();
    }
}
回复  

使用道具 举报

您需要登录后才可以回帖 登录 | FreeOZ用户注册

本版积分规则

小黑屋|手机版|Archiver|FreeOZ论坛

GMT+11, 13-12-2024 07:42 , Processed in 0.030071 second(s), 19 queries , Gzip On, Redis On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表