2011-11-04 3 views
1

Grails의 resource.xml (표준 스프링 xml 파일)에서 잘 작동하는 것을 가져 가고 싶습니다.Grails resources.groovy에서 Spring의 jee : jndi-lookup과 같은 것을 어떻게 작성합니까?

 <jee:jndi-lookup id="remoteConnectionFactory" 
    jndi-name="jms/WLQueueConnectionFactory" resource-ref="false"> 
     <jee:environment> 
      java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory 
      java.naming.provider.url=t3://remote_uri:port/ 
     </jee:environment> 
</jee:jndi-lookup> 

resources.groovy에있는 Grails bean builder DSL로 바꾸십시오. 나는 다음과 같은 조합을 시도했다. (기본적으로 시행 착오를 통해 작동 여부를 확인할 수있다. 아무 것도하지 않는다.) :

ejbJndi(JndiTemplate) 
{ bean -> 
    bean.scope = 'session' 
    environment = [ 
     "java.naming.provider.url" : "t3://remote_uri:port/", 
     "java.naming.factory.initial" : "weblogic.jndi.WLInitialContextFactory" 
    ] 
} 
xmlns jee:"http://www.springframework.org/schema/jee" 
xmlns context:"http://www.springframework.org/schema/context" 

jee.'jndi-lookup'(id:"jmsConnectionFactory", jndiName: "com.retailexp.jms.ConnectionFactory", lookupOnStartup: false, 
    proxyInterface: "javax.jms.ConnectionFactory", resourceRef: "false", 'jndi-environment': ref("ejbJndi")) { 
    cache = true 
    exposeAccessContext = true 

    jndiTemplate = ref("ejbJndi") 
    jndiEnvironment = [ 
     "java.naming.provider.url" : "t3://remote_uri:port/", 
     "java.naming.factory.initial" : "weblogic.jndi.WLInitialContextFactory" 
    ] as Properties 

    environmentRef = [ 
     "java.naming.provider.url" : "t3://remote_uri:port/", 
     "java.naming.factory.initial" : "weblogic.jndi.WLInitialContextFactory" 
    ] 

    environment = """ 
     java.naming.provider.url=t3://remote_uri:port/ 
     java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory 
""" 

다시 말하지만 이것들은 내가 시도한 것의 조합이다. 최종 코드는 다음과 같이 보일 것입니다 (이 중 하나가 작동하기를 바랍니다!). 당신이 말할 수 있듯이, 나는 어둠 속에서 조금씩 놀고있다.

xndx 조회가 설정되어 있고 유효한 Bean DSL이지만 환경 (JndiTemplate 유형의 항목)에 값 (java.naming.factory.initial 등)이 없습니다. 원격 InitialContext를 가져올 설정입니다. .

답변

1

당신이 XML 네임 스페이스를 사용하려면 당신은 당신의 Grails의 콩 '정의의 상단에 다음이 필요합니다

beans { 
    xmlns context:"http://www.springframework.org/schema/context" 
    xmlns jee:"http://www.springframework.org/schema/jee" 

    context.'property-placeholder'('location':'classpath:config.properties') 
    jee.'jndi-lookup'(id:"jmsConnectionFactory", jndiName: "com.retailexp.jms.ConnectionFactory", lookupOnStartup: false, etc. 

    ... 

} 

또는 사용'콩 '표기를 시도보다는를 사용하려고 할 수 있습니다 XML 네임 스페이스 'jee ...'는 Grails bean 표기법으로 구현하기가 더 쉽지만 더 쉽습니다.

XML :

<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiName" value="jdbc/MyDataSource"/> 
    <property name="jndiEnvironment"> 
     <props> 
      <prop key="foo">bar</prop> 
     </props> 
    </property> 
</bean> 

Grails의 DSL : 자세한 내용은 here에 대해서도 "봄 네임 스페이스 사용"

beans { 
    simple(org.springframework.jndi.JndiObjectFactoryBean) { 
     jndiName = 'jdbc/MyDataSource' 
     jndiEnvironment = ["foo":"bar"] 
    } 

    ... 
} 

참조 Grails의에 대한 설명서를 참조하십시오.

또한 blogged Grails 외부에서 Grails BeanBuilder DSL을 사용하는 것이 도움이 될지 모르지만 Grails 설명서가 도움이 될 것입니다.

관련 문제