기본 JCA ResourceAdapter 구성 및 배치

JCA(Java™ EE Connector Architecture) ConnectionFactory 및 Resource Adapter를 구성하고 배치할 수 있습니다.

이 태스크 정보

자원 어댑터를 설치하고 제공되는 자원의 인스턴스를 구성할 수 있습니다. 이 태스크는 ExampleRA.rar이라는 자원 어댑터를 사용하며, 이는 3가지 유형의 자원을 제공합니다. 연결 팩토리 하나와 두 가지 자원 오브젝트 유형입니다.

프로시저

  1. server.xml 파일에서 JCA 기능을 사용하도록 설정하십시오. server.xml 파일은 [path_to_liberty\wlp\usr\servers\server_name]에 있습니다.
    <server>
      <featureManager>
        <feature>jca-1.6</feature>
        <feature>servlet-3.0</feature>
      </featureManager></server>
  2. 자원 어댑터 RAR 파일(ExampleRA.rar)을 서버의 드롭인 폴더에 넣으십시오. 서버가 실행 중인 경우, 콘솔 로그에 자원 어댑터가 설치되었음을 표시하는 다음과 같은 메시지가 표시됩니다.
    [AUDIT ] J2CA7001I: Resource adapter ExampleRA installed in 1.306 seconds. 
  3. 자원 어댑터에서 배치 디스크립터, 어노테이션 및 기타 문서를 검사하여 어댑터가 제공하는 자원 유형 및 각 어댑터가 승인하는 구성 특성을 식별하십시오. 예제 자원 어댑터인 ExampleRA.rar에는 ra.xml 배치 디스크립터에 있는 다음 정보가 있습니다. ra.xml 파일은 [path_to_ExampleRA\ExampleRA\META-INF]에 있습니다. 배치 디스크립터는 사용자가 구성할 수 있는 세 가지 유형의 자원을 식별합니다.
    <connection-definition>
     <managedconnectionfactory-class>com.ibm.example.jca.adapter.ManagedConnectionFactoryImpl</managedconnectionfactory-class>
     <config-property>
      <config-property-name>tableName</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
     </config-property>
     <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
     ...
    </connection-definition>
    
        <adminobject>
          <adminobject-interface>javax.resource.cci.ConnectionSpec</adminobject-interface>
          <adminobject-class>com.ibm.example.jca.adapter.ConnectionSpecImpl</adminobject-class>
          <config-property>
            <config-property-name>readOnly</config-property-name> 
            <config-property-type>java.lang.Boolean</config-property-type>
            <config-property-value>false</config-property-value> 
          </config-property>
        </adminobject>
    
        <adminobject>
          <adminobject-interface>javax.resource.cci.InteractionSpec</adminobject-interface>
          <adminobject-class>com.ibm.example.jca.adapter.InteractionSpecImpl</adminobject-class>
          <config-property>
            <description>Function name. Supported values are: ADD, FIND, REMOVE</description>
            <config-property-name>functionName</config-property-name> 
            <config-property-type>java.lang.String</config-property-type>
          </config-property>
        </adminobject>
  4. server.xml 파일에서 사용 가능한 자원 유형의 인스턴스를 구성하십시오.
    <server>
      <featureManager>
        <feature>jca-1.6</feature>
        <feature>servlet-3.0</feature>
      </featureManager>
      <connectionFactory jndiName="eis/conFactory">
        <properties.ExampleRA tableName="TABLE1"/>
      </connectionFactory>
    
      <adminObject jndiName="eis/conSpec">
        <properties.ExampleRA.ConnectionSpec/>
      </adminObject>
    
      <adminObject jndiName="eis/iSpec_ADD">
        <properties.ExampleRA.InteractionSpec functionName="ADD"/>
      </adminObject>
    
      <adminObject jndiName="eis/iSpec_FIND">
        <properties.ExampleRA.InteractionSpec functionName="FIND"/>
      </adminObject>
    
    </server>
  5. 사용자의 서블릿에서 자원 인젝션을 사용하여 자원에 액세스하십시오. 예제:
        @Resource(lookup = "eis/conFactory")
        private ConnectionFactory conFactory;
    
        @Resource(lookup = "eis/conSpec")
        private ConnectionSpec conSpec;
    
        @Resource(lookup = "eis/iSpec_ADD")
        private InteractionSpec iSpec_ADD;
    
        @Resource(lookup = "eis/iSpec_FIND")
        private InteractionSpec iSpec_FIND;
    
        ...
    
            MappedRecord input = conFactory.getRecordFactory().createMappedRecord("input");
            input.put("city", "Rochester");
            input.put("state", "Minnesota");
            input.put("population", 106769);
    
            Connection con = conFactory.getConnection(conSpec);
            try {
                Interaction interaction = con.createInteraction();
                interaction.execute(iSpec_ADD, input);
                interaction.close();
            		} finally {
                con.close();
            }
    참고: 인젝션을 사용하지 않고 네임스페이스에서 자원을 검색하려면 server.xml 파일에서 JNDI 기능을 사용하도록 설정해야 합니다.

주제의 유형을 표시하는 아이콘 태스크 주제

파일 이름: twlp_jca_config_dep.html