JBoss Community

Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info

created by berw in IronJacamar - View the full discussion

Ok, what do you need to see?

 

The resourceReference in the DD of the using EJB (the client) looks like this:

<session id="PCEXMLExchangeRateImportImpl">

          <ejb-name>PCEXMLExchangeRateImportImpl</ejb-name>

          <local-home>com.myproclassic.server.services.exchangerate.importer.PCEExchangeRateImportImplLocalHome</local-home>

          <local>com.myproclassic.server.services.exchangerate.importer.PCEExchangeRateImportImplLocal</local>

          <ejb-class>com.myproclassic.server.services.exchangerate.importer.xml.PCEXMLExchangeRateImportImplBean</ejb-class>

          <session-type>Stateless</session-type>

          <transaction-type>Bean</transaction-type>

          <resource-ref id="ResourceRef_RaFile">

                    <description>

                    </description>

                    <res-ref-name>res/PCERAFile</res-ref-name>

                    <res-type>javax.resource.cci.ConnectionFactory</res-type>

                    <res-auth>Container</res-auth>

<res-sharing-scope>Unshareable</res-sharing-scope>

          </resource-ref>

</session>

 

 

 

The client code looks like this:

PCERAFileConnectionRequestInfo requestInfoTemp = new PCERAFileConnectionRequestInfo(newName, "rw"); // newName is different at the second call within the same transaction.

fileConnection = (PCERAFileConnection) raFileConnectionFactory.getConnection(requestInfoTemp);

if (fileConnection != null)

     return fileConnection.getRandomAccessFile();

 

The connectionRequestInfo looks like this:

package com.wincor.jca;

import javax.resource.cci.ConnectionSpec;

import javax.resource.spi.ConnectionRequestInfo;

 

public class PCERAFileConnectionRequestInfo implements ConnectionRequestInfo, ConnectionSpec {

    private String fileName = "";

    private String openMode = "";

 

    public PCERAFileConnectionRequestInfo(String fileName, String openMode)     {

        this.fileName = fileName;

                         this.openMode = openMode;

    }

 

           public int hashCode() {

            return fileName.hashCode() + openMode.hashCode();

      }

 

    public boolean equals(Object obj)     {

        boolean result = false;

 

        if (obj != null)         {

            if (obj instanceof PCERAFileConnectionRequestInfo)             {

                                                       result = ((PCERAFileConnectionRequestInfo) obj).getFileName().equals(fileName)  && ((PCERAFileConnectionRequestInfo) obj).getOpenMode().equals(openMode);

            }

        }

        return result;

    }

    public String getFileName()    {

        return fileName;

    }

 

    public String getOpenMode()     {

        return openMode;

    }

}

Reply to this message by going to Community

Start a new discussion in IronJacamar at Community