Application Server에서 실행 중인 응용 프로그램에서 외부 JNDI 저장소에 저장된 자원에 액세스해야 할 경우가 자주 있습니다. 예를 들어, LDAP 서버에 일반 Java 객체를 Java 스키마별로 저장할 수 있습니다. 외부 JNDI 자원 요소를 사용하면 이러한 외부 자원 저장소를 구성할 수 있습니다. 외부 JNDI 팩토리는 javax.naming.spi.InitialContextFactory 인터페이스를 구현해야 합니다.
다음은 외부 JNDI 자원 사용 예입니다.
<resources> <!-- external-jndi-resource element specifies how to access J2EE resources -- stored in an external JNDI repository. The following example -- illustrates how to access a java object stored in LDAP. -- factory-class element specifies the JNDI InitialContext factory that -- needs to be used to access the resource factory. property element -- corresponds to the environment applicable to the external JNDI context -- and jndi-lookup-name refers to the JNDI name to lookup to fetch the -- designated (in this case the java) object. --> <external-jndi-resource jndi-name="test/myBean" jndi-lookup-name="cn=myBean" res-type="test.myBean" factory-class="com.sun.jndi.ldap.LdapCtxFactory"> <property name="PROVIDER-URL" value="ldap://ldapserver:389/o=myObjects" /> <property name="SECURITY_AUTHENTICATION" value="simple" /> <property name="SECURITY_PRINCIPAL", value="cn=joeSmith, o=Engineering" /> <property name="SECURITY_CREDENTIALS" value="changeit" /> </external-jndi-resource> </resources>