[jboss-dev-forums] [Design of POJO Server] - JNDI server updates for MC
scott.stark@jboss.org
do-not-reply at jboss.com
Tue Sep 30 14:38:07 EDT 2008
I'm cleaning up some outstanding issues and updating the jndi name service to be more usable under the MC. One change in the upcoming naming 5.0.0.CR2 release is the addition of two naming beans for setting up an InitialContext(org.jboss.naming.InitialContextFactoryBean) and adding jndi bindings(org.jboss.naming.BindingsInitializer):
| <?xml version="1.0" encoding="UTF-8"?>
|
| <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
| xmlns="urn:jboss:bean-deployer:2.0">
|
| <bean name="InitialContextFactory" class="org.jboss.naming.InitialContextFactoryBean">
| <property name="env">
| <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
| <entry>
| <key>java.naming.factory.initial</key>
| <value>org.jnp.interfaces.LocalOnlyContextFactory</value>
| </entry>
| <entry>
| <key>java.naming.factory.url</key>
| <value>org.jboss.naming:org.jnp.interfaces</value>
| </entry>
| </map>
| </property>
| <depends>testLocaNamingBeanImpl</depends>
| </bean>
| <bean name="JndiBindings" class="org.jboss.naming.BindingsInitializer">
| <property name="ctx">
| <inject bean="InitialContextFactory" property="ctx"/>
| </property>
| <property name="bindings">
| <map keyClass="java.lang.String">
| <entry>
| <key>ints/1</key>
| <value class="java.lang.Integer">1</value>
| </entry>
| <entry>
| <key>strings/1</key>
| <value class="java.lang.String">String1</value>
| </entry>
| <entry>
| <key>bigint/1</key>
| <value class="java.math.BigInteger">123456789</value>
| </entry>
| <entry>
| <key>env-props</key>
| <value>
| <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
| <entry>
| <key>java.naming.factory.initial</key>
| <value>org.jnp.interfaces.LocalOnlyContextFactory</value>
| </entry>
| <entry>
| <key>java.naming.factory.url</key>
| <value>org.jboss.naming:org.jnp.interfaces</value>
| </entry>
| </map>
| </value>
| </entry>
| </map>
| </property>
| </bean>
| <bean name="testLocaNamingBeanImpl" class="org.jnp.server.NamingBeanImpl">
| <!-- Install this bean as the global JVM NamingServer -->
| <property name="installGlobalService">true</property>
|
| <property name="useGlobalService">false</property>
| </bean>
|
| </deployment>
|
This deployment is used by the following unit test fragment:
| /**
| * Obtain the InitialContext from the InitialContextFactory bean ctx property.
| * Each test expects an InitialContextFactory bean
| * @see org.jboss.naming.InitialContextFactory
| *
| * @param ctx
| */
| @Inject(bean="InitialContextFactory", property="ctx")
| public void setInitialContext(InitialContext ctx)
| {
| this.ctx = ctx;
| }
|
| public void testLocaNamingBeanImpl()
| throws Exception
| {
| assertNotNull(ctx);
| validateCtx(ctx);
| }
|
| protected void validateCtx(InitialContext ic)
| throws Exception
| {
| Integer i1 = (Integer) ctx.lookup("ints/1");
| assertEquals("ints/1", new Integer(1), i1);
| String s1 = (String) ctx.lookup("strings/1");
| assertEquals("strings/1", "String1", s1);
| BigInteger bi1 = (BigInteger) ctx.lookup("bigint/1");
| assertEquals("bigint/1", new BigInteger("123456789"), bi1);
| Properties env = (Properties) ctx.lookup("env-props");
| Properties expected = new Properties();
| expected.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
| expected.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
| assertEquals("env-props", expected, env);
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4179647#4179647
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4179647
More information about the jboss-dev-forums
mailing list