4 Replies Latest reply on Mar 6, 2003 8:11 AM by davidjencks

    ByApplication Criteria question

    alwyn

      Hi,

      I have set my criteria to ByApplication.

      My implementation of the Connection interface uses a method getConnection (host, port) in order for the ManagedConnection implementation to connect to different servers.

      I want to have my pools grouped according to this host/port pair...

      Do I need to build a ConnectionRequestInfo using these values before I call allocateConnection? If so, must the object passed be the same object as it doesn't seem to work if not?

      If not so, how do you do this as allocateConnection has a very specific interface?

      I am not using CCI.

        • 1. Re: ByApplication Criteria question
          davidjencks

          You need to implement ConnectionRequestInfo, and you need to implement the equals and hashCode methods so they distinguish between the contents rather than basing on the object identity. Otherwise the pools can't guess what mc's might be appropriate.

          • 2. Re: ByApplication Criteria question
            alwyn

            Thank you David it works great!

            One more question, what is the reason for a ManagedConnectionFactory also implementing equals and hashCode?

            • 3. Re: ByApplication Criteria question
              alwyn

              Thank you David! It works great.

              One other related question..

              Why do ManagedConnectionFactory also implement equals and hashCode?

              • 4. Re: ByApplication Criteria question
                davidjencks

                It's a spec requirement that I don't fully understand. I think it's because some app servers serialize mcfs and then need to find the original after deserialization. At the moment I can't remember if I succeeded in preventing jboss from ever needing to serialize an mcf. If you have a non-transient reference to the mcf in a ConnectionFactory (or DataSource) you can end up serializing it if an ejb gets passivated while holding a reference to the cf/ds.