Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.resource.adapter.jms;
 
 import java.util.Set;
 
 
Jms ManagedConectionFactory

Author(s):
Peter Antman .
Adrian Brock
Version:
$Revision: 76316 $
 
 {
    private static final long serialVersionUID = -923483284031773011L;
 
    private static final Logger log = Logger.getLogger(JmsManagedConnection.class);

   
Settable attributes in ra.xml
 
    private JmsMCFProperties mcfProperties = new JmsMCFProperties();

   
Whether we are strict
 
    private boolean strict = true;

   
For local access.
 
    private JMSProviderAdapter adapter;
   
   
The try lock
 
    private int useTryLock = 60;
 
    {
       // empty
    }

   
Create a "non managed" connection factory. No appserver involved
 
    {
       return createConnectionFactory(null);
    }

   
Create a ConnectionFactory with appserver hook
 
    {
       Object cf = new JmsConnectionFactoryImpl(thiscxManager);
 
       if (.isTraceEnabled())
       {
          .trace("Created connection factory: " + cf + ", using connection manager: " + cxManager);
       }
 
       return cf;
    }

   
Create a new connection to manage in pool
 
          throws ResourceException
    {
       boolean trace = .isTraceEnabled();
 
      info = getInfo(info);
      if (trace)
         .trace("connection request info: " + info);
      JmsCred cred = JmsCred.getJmsCred(thissubjectinfo);
      if (trace)
         .trace("jms credentials: " + cred);
      // OK we got autentication stuff
      JmsManagedConnection mc = new JmsManagedConnection(thisinfocred.namecred.pwd);
      if (trace)
         .trace("created new managed connection: " + mc);
      return mc;
   }

   
Match a set of connections from the pool
   public ManagedConnection matchManagedConnections(Set connectionSetSubject subjectConnectionRequestInfo info)
         throws ResourceException
   {
      boolean trace = .isTraceEnabled();
      // Get cred
      info = getInfo(info);
      JmsCred cred = JmsCred.getJmsCred(thissubjectinfo);
      if (trace)
         .trace("Looking for connection matching credentials: " + cred);
      // Traverse the pooled connections and look for a match, return first
      // found
      Iterator connections = connectionSet.iterator();
      while (connections.hasNext())
      {
         Object obj = connections.next();
         // We only care for connections of our own type
         if (obj instanceof JmsManagedConnection)
         {
            // This is one from the pool
            JmsManagedConnection mc = (JmsManagedConnectionobj;
            // Check if we even created this on
            ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
            // Only admit a connection if it has the same username as our
            // asked for creds
            // FIXME, Here we have a problem, jms connection
            // may be anonymous, have a user name
            if ((mc.getUserName() == null || (mc.getUserName() != null && mc.getUserName().equals(cred.name)))
                  && mcf.equals(this))
            {
               // Now check if ConnectionInfo equals
               if (info.equals(mc.getInfo()))
               {
                  if (trace)
                     .trace("Found matching connection: " + mc);
                  return mc;
               }
            }
         }
      }
      if (trace)
         .trace("No matching connection was found");
      return null;
   }
   public void setLogWriter(PrintWriter outthrows ResourceException
   {
      // 
      // jason: screw the logWriter stuff for now it sucks ass
      //
   }
   {
      // 
      // jason: screw the logWriter stuff for now it sucks ass
      //
      return null;
   }

   
Checks for equality ower the configured properties.
   public boolean equals(Object obj)
   {
      if (obj == null)
         return false;
      if (obj instanceof JmsManagedConnectionFactory)
      {
         return .equals(((JmsManagedConnectionFactoryobj).getProperties());
      }
      else
      {
         return false;
      }
   }
   public int hashCode()
   {
      return .hashCode();
   }
   // --- Connfiguration API ---
   public void setJmsProviderAdapterJNDI(String jndi)
   {
   }
   {
      return .getProviderJNDI();
   }

   
Set userName, null by default.
   public void setUserName(String userName)
   {
      .setUserName(userName);
   }

   
Get userName, may be null.
   public String getUserName()
   {
      return .getUserName();
   }

   
Set password, null by default.
   public void setPassword(String password)
   {
      .setPassword(password);
   }

   
Get password, may be null.
   public String getPassword()
   {
      return .getPassword();
   }

   
Get client id, may be null.
   public String getClientID()
   {
      return .getClientID();
   }

   
Set client id, null by default.
   public void setClientID(final String clientID)
   {
      .setClientID(clientID);
   }
   public boolean isStrict()
   {
      return ;
   }
   public void setStrict(boolean strict)
   {
      this. = strict;
   }
   public void setStrict(Boolean strict)
   {
      this. = strict.booleanValue();
   }

   
Set the default session typ

Parameters:
type either javax.jms.Topic or javax.jms.Queue
Throws:
javax.resource.ResourceException if type was not a valid type.
   public void setSessionDefaultType(String typethrows ResourceException
   {
   }
   {
   }

   
For local access
   public void setJmsProviderAdapter(final JMSProviderAdapter adapter)
   {
      this. = adapter;
   }
   {
      return ;
   }
   
   
Get the useTryLock.

Returns:
the useTryLock.
   public int getUseTryLock()
   {
      return ;
   }

   
Set the useTryLock.

Parameters:
useTryLock the useTryLock.
   public void setUseTryLock(int useTryLock)
   {
      this. = useTryLock;
   }
   {
      if (info == null)
      {
         // Create a default one
         return new JmsConnectionRequestInfo();
      }
      else
      {
         // Fill the one with any defaults
         return info;
      }
   }
   {
      return new JmsConnectionMetaData();
   }
   //---- MCF to MCF API
   {
      return ;
   }
New to GrepCode? Check out our FAQ X