//
// JmsaConnectionFactory.java - JMS Adapter ConnectionFactory
//
// JmsaCF handles the "administered" object side of things.
//

package nyangau.jmsadapter;

import java.util.Map;
import javax.jms.*;

public class JmsaConnectionFactory extends JmsaCF implements ConnectionFactory
  {
  protected transient ConnectionFactory cf;
//...sJmsaConnectionFactory:2:
// The JmsaConnectionFactory isn't registered in JNDI,
// its being directly created, given an underlying ConnectionFactory and Map.
// The map contains
//   no naming properties (if present, they'll be ignored)
//   no underlying ConnectionFactory name (if present, it'll be ignored)
//   JMS Adapter properties
public JmsaConnectionFactory(ConnectionFactory connfact, Map<String,Object> map)
  {
  super(map);
  cf = connfact;
  }

// We get called here when reconstructed from a Reference in JNDI,
// or a JNDI configuration tool is instantiating a CF
// The map contains
//   naming properties
//   underlying ConnectionFactory name
//   JMS Adapter properties
public JmsaConnectionFactory(Map<String,Object> map)
  {
  super(map);
  cf = null;
  }
public JmsaConnectionFactory(Map<String,Object> map, Map<String,Object> map2)
  {
  super(map, map2);
  cf = null;
  }

// We get called here when unserialised from JNDI
// The map contains
//   naming properties
//   underlying ConnectionFactory name
//   JMS Adapter properties
public JmsaConnectionFactory()
  {
  cf = null;
  }
//...e
//...screateConnection:2:
public Connection createConnection()
  throws JMSException
  {
  if ( cf == null )
    cf = (ConnectionFactory) findFactory();
  return new JmsaConnection( cf.createConnection(), getFlowProcessor() );
  }

public Connection createConnection(String userName, String password)
  throws JMSException
  {
  if ( cf == null )
    cf = (ConnectionFactory) findFactory();
  return new JmsaConnection( cf.createConnection(userName, password), getFlowProcessor() );
  }
//...e
  }
