이 콘텐츠는 선택한 언어로 제공되지 않습니다.
9.5. Additional Naming MBeans
In addition to the
NamingService MBean that configures an embedded JBossNS server within JBoss, there are several additional MBean services related to naming that ship with JBoss. They are JndiBindingServiceMgr, NamingAlias, ExternalContext, and JNDIView.
9.5.1. JNDI Binding Manager 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The JNDI binding manager service allows you to quickly bind objects into JNDI for use by application code. The MBean class for the binding service is
org.jboss.naming.JNDIBindingServiceMgr. It has a single attribute, BindingsConfig, which accepts an XML document that conforms to the jndi-binding-service_1_0.xsd schema. The content of the BindingsConfig attribute is unmarshaled using the JBossXB framework. The following is an MBean definition that shows the most basic form usage of the JNDI binding manager service.
This binds the text string "
Hello, JNDI!" under the JNDI name bindexample/message. An application would look up the value just as it would for any other JNDI value. The trim attribute specifies that leading and trailing whitespace should be ignored. The use of the attribute here is purely for illustrative purposes as the default value is true.
InitialContext ctx = new InitialContext();
String text = (String) ctx.lookup("bindexample/message");
InitialContext ctx = new InitialContext();
String text = (String) ctx.lookup("bindexample/message");
String values themselves are not that interesting. If a JavaBeans property editor is available, the desired class name can be specified using the
type attribute
<jndi:binding name="urls/jboss-home">
<jndi:value type="java.net.URL">http://www.jboss.org</jndi:value>
</jndi:binding>
<jndi:binding name="urls/jboss-home">
<jndi:value type="java.net.URL">http://www.jboss.org</jndi:value>
</jndi:binding>
The
editor attribute can be used to specify a particular property editor to use.
For more complicated structures, any JBossXB-ready schema may be used. The following example shows how a
java.util.Properties object would be mapped.