Coverage Report - org.mule.module.jca.DefaultMuleConnectionFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultMuleConnectionFactory
0%
0/23
N/A
1
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.module.jca;
 8  
 
 9  
 import java.io.IOException;
 10  
 import java.io.ObjectInputStream;
 11  
 
 12  
 import javax.naming.Reference;
 13  
 import javax.resource.ResourceException;
 14  
 import javax.resource.spi.ConnectionManager;
 15  
 
 16  
 import org.apache.commons.logging.Log;
 17  
 import org.apache.commons.logging.LogFactory;
 18  
 
 19  
 /**
 20  
  * <code>DefaultMuleConnectionFactory</code> an implementation of the
 21  
  * MuleconnectionFactory interface used by clients of this ResourceAdapter to obtain
 22  
  * a connection to Mule resources.
 23  
  */
 24  
 public class DefaultMuleConnectionFactory implements MuleConnectionFactory
 25  
 {
 26  
     /**
 27  
      * Serial version
 28  
      */
 29  
     private static final long serialVersionUID = 1552386015565975623L;
 30  
 
 31  
     /**
 32  
      * logger used by this class
 33  
      */
 34  0
     protected transient Log logger = LogFactory.getLog(this.getClass());
 35  
 
 36  
     private transient ConnectionManager manager;
 37  
     private transient MuleManagedConnectionFactory factory;
 38  
     private Reference reference;
 39  
     private MuleConnectionRequestInfo info;
 40  
 
 41  
     public DefaultMuleConnectionFactory(MuleManagedConnectionFactory factory,
 42  
                                         ConnectionManager manager,
 43  
                                         MuleConnectionRequestInfo info)
 44  0
     {
 45  0
         this.factory = factory;
 46  0
         this.manager = manager;
 47  0
         this.info = info;
 48  0
     }
 49  
 
 50  
     private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException
 51  
     {
 52  0
         ois.defaultReadObject();
 53  
         // TODO this is incomplete:
 54  
         // MuleManagedConnectionFactory is Serializable but marked transient?!
 55  0
         this.logger = LogFactory.getLog(this.getClass());
 56  0
     }
 57  
 
 58  
     public MuleConnection createConnection() throws ResourceException
 59  
     {
 60  0
         return createConnection(info);
 61  
     }
 62  
 
 63  
     public MuleConnection createConnection(MuleConnectionRequestInfo info) throws ResourceException
 64  
     {
 65  
         // TODO try {
 66  0
         return (MuleConnection)manager.allocateConnection(factory, info);
 67  
         // }
 68  
         // catch (ResourceException e) {
 69  
         //            
 70  
         // logger.warn("Connection could not be created: " + e.getMessage(), e);
 71  
         // throw new DefaultMuleException(e.getMessage());
 72  
         // }
 73  
     }
 74  
 
 75  
     public ConnectionManager getManager()
 76  
     {
 77  0
         return manager;
 78  
     }
 79  
 
 80  
     public void setManager(ConnectionManager manager)
 81  
     {
 82  0
         this.manager = manager;
 83  0
     }
 84  
 
 85  
     public MuleManagedConnectionFactory getFactory()
 86  
     {
 87  0
         return factory;
 88  
     }
 89  
 
 90  
     public void setFactory(MuleManagedConnectionFactory factory)
 91  
     {
 92  0
         this.factory = factory;
 93  0
     }
 94  
 
 95  
     public Reference getReference()
 96  
     {
 97  0
         return reference;
 98  
     }
 99  
 
 100  
     public void setReference(Reference reference)
 101  
     {
 102  0
         this.reference = reference;
 103  0
     }
 104  
 
 105  
     public MuleConnectionRequestInfo getInfo()
 106  
     {
 107  0
         return info;
 108  
     }
 109  
 
 110  
     public void setInfo(MuleConnectionRequestInfo info)
 111  
     {
 112  0
         this.info = info;
 113  0
     }
 114  
 }