users@glassfish.java.net

Exposing Properties via JNDI

From: <glassfish_at_javadesktop.org>
Date: Wed, 19 May 2010 07:48:06 PDT

In JBoss AS there is a nice feature to expose Properties using JNDI:

<?xml version="1.0" encoding="UTF-8"?>
<server>
        <mbean code="org.jboss.naming.JNDIBindingServiceMgr" name="config:service=config">
                <attribute name="BindingsConfig" serialDataType="jbxb">
                        <jndi:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
                                xs:schemaLocation="urn:jboss:jndi-binding-service:1.0 resource:jndi-binding-service_1_0.xsd">
                                <jndi:binding name="config/portal">
                                        <java:properties xmlns:java="urn:jboss:java-properties"
                                                xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
                                                xs:schemaLocation="urn:jboss:java-properties resource:java-properties_1_0.xsd">
                                                
                                                <!-- Scanner -->
                                                
                                                <java:property>
                                                        <java:key>scanner.quartz.cron.expression</java:key>
                                                        <java:value>0 0/2 * * * ?</java:value>
                                                </java:property>
                                                
                                        </java:properties>
                                </jndi:binding>
                        </jndi:bindings>
                </attribute>
                <depends>jboss:service=Naming</depends>
        </mbean>
</server>

Later on you can use it in you Spring context:

        <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
                <property name="properties">
                        <bean class="org.springframework.jndi.JndiObjectFactoryBean">
                                <property name="jndiName" value="config/portal"/>
                        </bean>
                </property>
        </bean>

I wonder if I can do the same with Glassfish. Could anybody help me?
[Message sent by forum member 'lordorient']

http://forums.java.net/jive/thread.jspa?messageID=470482