Project Report: fawkez

Packagesummary org.jcoderz.commons.connector.http

org.jcoderz.commons.connector.http.HttpManagedConnectionImpl

LineHitsNoteSource
1  /*
2   * $Id: HttpManagedConnectionImpl.java 1011 2008-06-16 17:57:36Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5   *
6   * Redistribution and use in source and binary forms, with or without
7   * modification, are permitted provided that the following conditions are
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   */
33  package org.jcoderz.commons.connector.http;
34  
35  import java.io.ByteArrayInputStream;
36  import java.io.PrintWriter;
37  import java.security.KeyStore;
38  import java.util.HashSet;
39  import java.util.Iterator;
40  import java.util.Set;
41  import java.util.logging.Level;
42  import java.util.logging.Logger;
43  
44  import javax.resource.NotSupportedException;
45  import javax.resource.ResourceException;
46  import javax.resource.spi.ConnectionEvent;
47  import javax.resource.spi.ConnectionEventListener;
48  import javax.resource.spi.ConnectionRequestInfo;
49  import javax.resource.spi.LocalTransaction;
50  import javax.resource.spi.ManagedConnection;
51  import javax.resource.spi.ManagedConnectionMetaData;
52  import javax.security.auth.Subject;
53  import javax.transaction.xa.XAResource;
54  
55  import org.jcoderz.commons.connector.ConnectorConfiguration;
56  import org.jcoderz.commons.connector.http.transport.ConnectorContext;
57  import org.jcoderz.commons.connector.http.transport.HttpClientConnection;
58  import org.jcoderz.commons.connector.http.transport.HttpClientConnectionImpl;
59  import org.jcoderz.commons.connector.http.transport.HttpConnectionException;
60  import org.jcoderz.commons.connector.http.transport.HttpConnectorEventListener;
61  import org.jcoderz.commons.connector.http.transport.HttpRequestResponseHeader;
62  import org.jcoderz.commons.types.Url;
63  import org.jcoderz.commons.util.Constants;
64  
65  
66  
67  
68  /**
69   * This class defines the managed connection maintained by the application
70   * server and triggered via the non-managed connection.
71   *
72   */
73 (1)public class HttpManagedConnectionImpl
74        implements ManagedConnection
75  {
76     /** Class name for use in logging. */
770    private static final String CLASSNAME
78           = HttpManagedConnectionImpl.class.getName();
79     /** Logger in use. */
800    private static final Logger logger
81           = Logger.getLogger(CLASSNAME);
82     /** Indicated if the managed connection is established. */
830    private boolean mConnectionAssociated = false;
84     /** Indicates if the managed connection is opened. */
850    private boolean mConnectionOpened = false;
86     /** The logger used for the implementation of the interface
87         ManagedConnection.*/
88     private PrintWriter mPrintWriter;
89     /** Object containing all app server references that must be notified
90         used for the implementation of the interface ManagedConnection. */
910    private final Set mEventListeners = new HashSet();
92     /** Connection handle associated with this ManagedConnection. */
93     private HttpConnectionImpl mConnectionHandle;
94     /** The factory which have created this object. */
95     private final HttpManagedConnectionFactoryImpl mManagedConnectionFactory;
96     /** The connection specification used to trigger the creation of
97         this physical connection. */
98     private HttpConnectionRequestInfo mConnectionRequestInfo;
99     /** Physical Connection */
100     private HttpClientConnection mConnection;
101     /** Flag indicates that the physical connection must be closed. */
1020    private boolean mPhysicalCloseRequired = false;
103     /** URL the physical Connection will connect to. */
104     private Url mUrl;
105     private final ConnectorConfiguration mConfig;
106  
107     private int mConnectTimeout;
108     private int mReadTimeout;
109     private String mKeyAlias;
110     private String mKeyAliasPassword;
1110(2)   private KeyStore mKeyStore = null;
1120(3)   private KeyStore mTrustStore = null;
113  
114     private HttpConnectorEventListener mHttpEventListener;
115     private ConnectorContext mConnectorContext;
116     private HttpRequestResponseHeader mRequestResponseHeader;
117  
118  
119     /**
120      * Constructor.
121      * @param mcf the HttpManagedConnectionFactoryImpl associated with
122      * @param cri the ConnectionRequestInfo specifying the requested connection
123      */
124     public HttpManagedConnectionImpl (
125        HttpManagedConnectionFactoryImpl mcf,
126        ConnectionRequestInfo cri)
1270    {
1280       final String methodName = "Constructor";
1290       if (logger.isLoggable(Level.FINER))
130        {
1310          logger.entering(CLASSNAME, methodName, cri);
132        }
1330       mConfig = ConfigurationFactory.getConfiguration();
134        // set the ManagedConnectionFactory creating this object
1350       mManagedConnectionFactory = mcf;
136         // set the obtained ConnectionRequestInfo
1370(4)      mConnectionRequestInfo = (HttpConnectionRequestInfo) cri;
1380       mConnectionAssociated = false;
1390       mConnectionOpened = false;
1400       mConnectionHandle = null;
1410       if (mConnectionRequestInfo != null)
142        {
1430          configure(mConnectionRequestInfo);
144        }
1450       if (logger.isLoggable(Level.FINER))
146        {
1470          logger.exiting(CLASSNAME, methodName);
148        }
1490    }
150  
151     /*
152      * Methods defined in interface
153      *     javax.resource.spi.ManagedConnection
154      *
155      *     void                            addConnectionEventListener
156      *                                        (ConnectionEventListener listener)
157      *     void                            associateConnection
158      *                                        (java.lang.Object connection)
159      *     void                            cleanup ()
160      *     void                            destroy ()
161      *     java.lang.Object                getConnection (Subject subject,
162      *                                         ConnectionRequestInfo info)
163      *     LocalTransaction                getLocalTransaction ()
164      *     java.io.PrintWriter             getLogWriter ()
165      *     void                            setLogWriter (java.io.PrintWriter out)
166      *     ManagedConnectionMetaData       getMetaData ()
167      *     javax.transaction.xa.XAResource getXAResource ()
168      *     void                            removeConnectionEventListener
169      *                                        (ConnectionEventListener listener
170      */
171  
172     /** {@inheritDoc} */
173     public void addConnectionEventListener (ConnectionEventListener listener)
174     {
1750       mEventListeners.add(listener);
1760    }
177  
178     /** {@inheritDoc} */
179     public void associateConnection (Object connection)
180     {
1810       final String methodName = "associateConnection";
1820       if (logger.isLoggable(Level.FINER))
183        {
1840          logger.entering(CLASSNAME, methodName);
185        }
186  
187        // the managed connection is already configured and the
188        // physical connection created anew if necessary
189        // - the check is obsolete
190        //checkIfDestroyed();
1910       if (mConnectionHandle != null)
192        {
1930          if (logger.isLoggable(Level.WARNING))
194           {
1950             final String messageText = "connection still have a handle";
1960             logger.warning(messageText);
197           }
1980          mConnectionHandle.disassociateManagedConnection(true);
199        }
2000       final HttpConnectionImpl usercon = (HttpConnectionImpl) connection;
2010       usercon.associateManagedConnection(this);
2020       mConnectionHandle = usercon;
2030       if (logger.isLoggable(Level.FINER))
204        {
2050          logger.exiting(CLASSNAME, methodName);
206        }
2070    }
208  
209     /** {@inheritDoc} */
210     public void cleanup ()
211     {
2120       final String methodName = "cleanup";
2130       if (logger.isLoggable(Level.FINER))
214        {
2150          logger.entering(CLASSNAME, methodName);
216        }
217  
218        // if makes no difference if the physical connection is closed
219        // or not cause reusing the managed connection creates a new
220        // physical connection inside "configure" if necessary
221        // - the check is obsolete
222        //checkIfDestroyed();
223        // Invalidate the connection handle and
224        // release the reference.
2250       if (mConnectionAssociated)
226        {
2270          mConnectionHandle.disassociateManagedConnection(true);
2280          mConnectionAssociated = false;
2290          mConnectionHandle = null;
230        }
2310        if (logger.isLoggable(Level.FINER))
232        {
2330          logger.exiting(CLASSNAME, methodName);
234        }
2350    }
236  
237     /** {@inheritDoc} */
238     public void destroy ()
239     {
2400       final String methodName = "destroy";
2410       if (logger.isLoggable(Level.FINER))
242        {
2430          logger.entering(CLASSNAME, methodName);
244        }
245  
246        // the container is not the only one allowed to close the physical
247        // connection - the managed connection close it itself in
248        // case of an "Connection : Close" attribute received in the
249        // response message
250        // - the check is obsolete
251        //checkIfDestroyed();
252  
253        // trace message
2540       if (logger.isLoggable(Level.FINE))
255        {
2560          final String messageText
257              = "destroy PHYSICAL CONNECTION (" + this + ") to "
258                    + mConnectionRequestInfo;
2590          logger.log(Level.FINE, messageText);
260        }
261        //
2620       disconnect();
263  
2640       if (logger.isLoggable(Level.FINER))
265        {
2660          logger.exiting(CLASSNAME, methodName);
267        }
2680    }
269  
270     /** {@inheritDoc} */
271     public Object getConnection (Subject subject, ConnectionRequestInfo cri)
272     {
2730       final String methodName = "getConnection";
2740       if (logger.isLoggable(Level.FINER))
275        {
2760          logger.entering(CLASSNAME, methodName);
277        }
2780       mPhysicalCloseRequired = false;
2790(5)      mConnectionRequestInfo = (HttpConnectionRequestInfo) cri;
280  
281        // There must not an association to a connection handle when this
282        // method is called.
2830       if (mConnectionAssociated)
284        {
2850          final String errorText
286              = "managed connection already associated to a connection handle";
2870(6)         throw new IllegalStateException(errorText);
288        }
289  
290        // if not connected then configure and connect
2910       if (!mConnectionOpened)
292        {
293           // trace message
2940          if (logger.isLoggable(Level.FINE))
295           {
2960             final String messageText
297                 = "establishing NEW PHYSICAL CONNECTION (" + this + ") to "
298                       + mConnectionRequestInfo;
2990             logger.fine(messageText);
300           }
301           //
3020          if (mConnectionRequestInfo != null)
303           {
3040             configure(mConnectionRequestInfo);
305           }
306           // we connect while sending....
307        }
308        else
309        {
310           // trace message
3110          if (logger.isLoggable(Level.FINE))
312           {
3130             final String messageText
314                 = "reusing PHYSICAL CONNECTION (" + this + ") to "
315                       + mConnectionRequestInfo;
3160             logger.fine(messageText);
317           }
318           //
319        }
3200       mConnectionAssociated = true;
3210       mConnectionHandle = new HttpConnectionImpl(this);
3220       return mConnectionHandle;
323     }
324  
325     /** {@inheritDoc} */
326     public LocalTransaction getLocalTransaction ()
327           throws ResourceException
328     {
3290       final String messageText = "Local transaction not supported";
3300       throw new NotSupportedException(messageText);
331     }
332  
333     /** {@inheritDoc} */
334     public PrintWriter getLogWriter ()
335     {
3360       return mPrintWriter;
337     }
338  
339     /** {@inheritDoc} */
340     public void setLogWriter (PrintWriter out)
341     {
3420       mPrintWriter = out;
3430    }
344  
345     /** {@inheritDoc} */
346     public ManagedConnectionMetaData getMetaData ()
347     {
348        // it is not specified that the physical connection have to be
349        // open whilst that call
3500       final HttpManagedConnectionMetaData managedConnectionMetaData
351           = new HttpManagedConnectionMetaData(this);
3520(7)      return managedConnectionMetaData;
353     }
354  
355     /** {@inheritDoc} */
356     public XAResource getXAResource ()
357           throws ResourceException
358     {
3590       final String messageText = "XA transaction not supported";
3600       throw new NotSupportedException(messageText);
361     }
362  
363     /** {@inheritDoc} */
364     public void removeConnectionEventListener (ConnectionEventListener listener)
365     {
3660       mEventListeners.remove(listener);
3670    }
368  
369  
370     /*
371      * Implementation of interface
372      *     javax.resource.spi.HttpManagedConnection
373      *
374      * finished.
375      */
376  
377  
378     /**
379      * Performs a physical connection close.
380      */
381     private void disconnect ()
382     {
3830       final String methodName = "disconnect";
3840       if (logger.isLoggable(Level.FINER))
385        {
3860          logger.entering(CLASSNAME, methodName);
387        }
388  
389        // if "disconnect" is triggered by container side
390        // and the response contained a "Connection:Close"
391        // HTTP header the connection has been already
392        // closed by the Managed Connection
3930       if (!mConnectionOpened && mPhysicalCloseRequired)
394        {
3950          if (logger.isLoggable(Level.FINE))
396           {
3970             final String messageText = "already disconnected (" + this + ")"
398                    + " due to \'Connection:Close\' in response";
3990             logger.fine(messageText);
4000          }
401        }
402        else
403        {
404           // close the physical socket connection
4050          mConnection.closeConnection();
4060          mConnectionOpened = false;
407        }
408  
4090       if (logger.isLoggable(Level.FINER))
410        {
4110          logger.exiting(CLASSNAME, methodName);
412        }
4130    }
414  
415    /**
416     * Configures the physical connection.
417     * Uses configuration parameter from the
418     * {@link org.jcoderz.commons.connector.http.HttpConnectionSpec
419     * HttpConnectionSpec}.
420     * This method is called inside the
421     * {@link #HttpManagedConnection(HttpManagedConnectionFactoryImpl,
422     * ConnectionRequestInfo) constructor}
423     * and
424     * {@link #getConnection(Subject, ConnectionRequestInfo ) getConnection(..)}
425     * method.
426     *
427     * @param cri the Connection Request Info
428     */
429     private final void configure (HttpConnectionRequestInfo cri)
430     {
4310       final String methodName = "configure";
4320       if (logger.isLoggable(Level.FINER))
433        {
4340          logger.entering(CLASSNAME, methodName);
435        }
436  
437        String messageText;
438        String errorText;
439  
4400       if (mConnectionOpened)
441        {
4420(8)         messageText = "Unable to configure an already opened connection";
443           // trace message
4440          if (logger.isLoggable(Level.WARNING))
445           {
4460             logger.warning(messageText);
447           }
448           //
449        }
450        else
451        {
4520          if (cri.getConnectionSpec() != null)
453           {
454              // set configuration parameters obtained in the cri
455              // for the connection
4560             mUrl = cri.getConnectionSpec().getUrl();
457  
4580             mConnectTimeout = mConfig.getConnectTimeoutInMilliSeconds();
4590             mReadTimeout = mConfig.getReadTimeoutInMilliSeconds();
460  
4610             mKeyAlias = mConfig.getSslKeyAlias();
4620             mKeyAliasPassword = mConfig.getSslKeyAliasPassword();
463 (9)            //FIXME: mKeyStore = KeyStoreLocator.getKeyStore();
464 (10)            //FIXME: mTrustStore = KeyStoreLocator.getTrustStore();
465  
4660             if (mConnection == null)
467              {
468                 // trace message
4690                if (logger.isLoggable(Level.FINER))
470                 {
4710                   messageText = "creating new HTTPConnection";
4720                   logger.log(Level.FINER, messageText);
473                 }
474                 //
4750                mConnection = new HttpClientConnectionImpl();
476              }
477  
4780             mConnection.initSsl(
479                    mKeyStore, mTrustStore, mKeyAlias, mKeyAliasPassword);
4800             mConnection.establishConnection(
481                    mUrl.toString(), mConnectTimeout, mReadTimeout);
482           }
483           else
484           {
4850             errorText = "connection specification is not set";
4860(11)            throw new IllegalStateException(errorText);
487           }
488        }
4890       if (logger.isLoggable(Level.FINER))
490        {
4910          logger.exiting(CLASSNAME, methodName);
492        }
4930    }
494  
495     /**
496      * This method is used by the
497      * {@link org.jcoderz.commons.connector.http.HttpConnectionImpl
498      * HttpConnection Implementation} class to send and receive an HTTP
499      * request/response using the commons-httpclient library.
500      *
501      * @param message the message body to send via HTTP.
502      * @return the response received.
503      * @throws HttpConnectionException for all types of connection failures
504      */
505     public byte[] sendAndReceive (byte[] message)
506           throws HttpConnectionException
507     {
5080       final String methodName = "sendAndReceive(byte[])";
5090       if (logger.isLoggable(Level.FINER))
510        {
5110          logger.entering(CLASSNAME, methodName);
512        }
513  
514        // set the event listener for "requestSend" / "responseReceived"
5150       mConnection.setEventListener(mHttpEventListener, mConnectorContext);
516  
517        // add Content-Length and Connection to the request header
518        // will not be overwritten if already set
5190       getRequestResponseHeader().addRequestHeader("Content-Length",
520              String.valueOf(message.length));
5210       getRequestResponseHeader().addRequestHeader("Connection",
522              "Keep-Alive");
523  
524        // set all given request header pairs
5250       mConnection.setRequestResponseHeader(getRequestResponseHeader());
526  
527        // set the given message body
5280       mConnection.setRequestBody(new ByteArrayInputStream(message));
529  
5300       mConnectionOpened = true;
531  
532        //execute the httpclient connection
5330       mConnection.execute();
534  
535        // obtain the response
5360       final byte[] responseBytes = mConnection.getResponseBody();
537  
5380       if (isCloseConnectionRequired())
539        {
5400          mPhysicalCloseRequired = true;
541        }
542  
5430       mConnection.releaseConnection();
5440       if (logger.isLoggable(Level.FINER))
545        {
5460          logger.exiting(CLASSNAME, methodName);
547        }
5480       return responseBytes;
549     }
550  
551     /**
552      * Sets the header set for sending and validate whilst receiving.
553      *
554      * @param header header to set and to validate
555      */
556     public void setRequestResponseHeader (HttpRequestResponseHeader header)
557     {
5580       mRequestResponseHeader = header;
5590    }
560  
561     /**
562      * Sets the event listener used for SLA logs.
563      * This listener will be set at the
564      *
565      * @param listener the listener to set
566      * @param context the context to set
567      */
568     public void setEventListener (HttpConnectorEventListener listener,
569           ConnectorContext context)
570     {
5710       mHttpEventListener = listener;
5720       mConnectorContext = context;
5730    }
574  
575     /**
576      * This method is used by the
577      * {@link HttpConnectionHelper HttpConnectionHelper}
578      * class to disassociate the connection handle
579      * from this HttpManagedConnection instance.
580      *
581      * @param conn the connection handle to be disassociated
582      * @throws javax.resource.spi.IllegalStateException if the connection handle
583      *          to disassociate is not associated
584      */
585     void disassociateConnection (HttpConnectionImpl conn)
586           throws IllegalStateException
587     {
5880       final String methodName = "disassociateConnection";
5890       if (logger.isLoggable(Level.FINER))
590        {
5910          logger.entering(CLASSNAME, methodName);
592        }
593  
5940       if (conn != mConnectionHandle)
595        {
5960          final String errorText = "Connection handle was not created by "
597                                 + "THIS HttpManagedConnection " + conn;
5980          final IllegalStateException ise = new IllegalStateException(errorText);
599            // trace message
6000          if (logger.isLoggable(Level.FINE))
601           {
6020             logger.log(Level.FINE, errorText);
603           }
6040          if (logger.isLoggable(Level.FINER))
605           {
6060             logger.throwing(CLASSNAME, methodName, ise);
607           }
608           //
6090          throw ise;
610        }
6110       mConnectionAssociated = false;
6120       mConnectionHandle = null;
6130       if (mPhysicalCloseRequired)
614        {
6150          disconnect();
616        }
617        else
618        {
6190          mConnection.releaseConnection();
620        }
621  
6220       if (logger.isLoggable(Level.FINER))
623        {
6240          logger.exiting(CLASSNAME, methodName);
625        }
6260    }
627  
628     /**
629      * Gets the connection specification used to trigger the creation
630      * of this physical connection.
631      *
632      * @return HttpConnectionRequestInfo - the requested object specifying
633      *         the requested connection
634      */
635     ConnectionRequestInfo getConnectionRequestInfo ()
636     {
6370       return mConnectionRequestInfo;
638     }
639  
640     /**
641      * Notify the registered set of listeners when an application component
642      * closes a connection handle. The application server uses this connection
643      * close event to make a decision on whether or not to put this
644      * HttpManagedConnection instance back into the connection pool.
645      *
646      * @param connectionHandle the connection handle performing a close
647      */
648     void notifyAboutConnectionClosed (
649        HttpConnectionImpl connectionHandle)
650     {
6510       final String methodName = "notifyAboutConnectionClosed";
6520       if (logger.isLoggable(Level.FINER))
653        {
6540          logger.entering(CLASSNAME, methodName);
655        }
656  
6570       if (mConnectionAssociated)
658        {
6590          if (logger.isLoggable(Level.WARNING))
660           {
6610             final String messageText
662                 = "HttpManagedConnection SHOULD have disassociated before";
6630             logger.warning(messageText);
664           }
665  
6660          mConnectionAssociated = false;
6670          mConnectionHandle = null;
668        }
6690       final ConnectionEvent ce = new ConnectionEvent(
670              this, ConnectionEvent.CONNECTION_CLOSED);
6710       ce.setConnectionHandle(connectionHandle);
6720       final Iterator it = mEventListeners.iterator();
6730       while (it.hasNext())
674        {
6750          final ConnectionEventListener listener
676              = (ConnectionEventListener) it.next();
6770          listener.connectionClosed(ce);
6780       }
6790        if (logger.isLoggable(Level.FINER))
680        {
6810          logger.exiting(CLASSNAME, methodName);
682        }
6830    }
684  
685    /**
686     * Notify the registered listeners of the occurrence of a physical
687     * connection-related error. The event notification happens just before
688     * a resource adapter throws an exception to the application component
689     * using the connection handle.
690     * The connectionErrorOccurred method indicates that the associated
691     * HttpManagedConnection instance is now invalid and unusable.
692     * The application server handles the connection error event
693     * notification by initiating application server-specific cleanup
694     * (for example, removing HttpManagedConnection instance from the
695     * connection pool) and then calling HttpManagedConnection.destroy
696     * method to destroy the physical connection.
697     *
698     * @param e the exception indication a connection error
699     * @param connectionHandle the connection handle notifying the
700     *                         connection error
701     */
702     void notifyAboutConnectionErrorOccurred (
703        Exception e,
704        HttpConnectionImpl connectionHandle)
705     {
7060       final String methodName = "notifyAboutConnectionErrorOccurred";
7070       if (logger.isLoggable(Level.FINER))
708        {
7090          logger.entering(CLASSNAME, methodName);
710        }
711  
7120       if (mConnectionAssociated)
713        {
7140          if (logger.isLoggable(Level.WARNING))
715           {
7160             final String messageText
717                 = "HttpManagedConnection SHOULD have disassociated before";
7180             logger.warning(messageText);
719           }
720        }
7210       final ConnectionEvent ce = new ConnectionEvent(
722              this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, e);
7230       if (connectionHandle != null)
724        {
7250          ce.setConnectionHandle(connectionHandle);
726        }
727  
7280       final Iterator it = mEventListeners.iterator();
7290       while (it.hasNext())
730        {
7310          final ConnectionEventListener listener
732               = (ConnectionEventListener) it.next();
7330          listener.connectionErrorOccurred(ce);
7340       }
7350       if (logger.isLoggable(Level.FINER))
736        {
7370           logger.exiting(CLASSNAME, methodName);
738        }
7390    }
740  
741     /**
742      *  Returns true if the underlying physical connection is currently open.
743      *
744      *  @return boolean - true if connection is open, else false
745      */
746     boolean isOpen ()
747     {
7480       return mConnectionOpened;
749     }
750  
751     /**
752      *  Checks the response header if a physical connection close is required.
753      */
754     private boolean isCloseConnectionRequired ()
755     {
7560       boolean result = false;
7570       final String connectionValue
758           = mConnection.getResponseHeader("Connection");
7590(12)       if (connectionValue != null
760              && connectionValue.toLowerCase(
761                    Constants.SYSTEM_LOCALE).equals("close"))
762        {
7630          logger.fine("\'Connection\' attribute in response header is \'"
764              + connectionValue
765              + "\' physical connection will be closed");
7660          result = true;
767        }
7680       return result;
769     }
770  
771     protected Url getUrl ()
772     {
7730       return mUrl;
774     }
775  
776     /**
777      * Gets the managed connection factory of this managed connection.
778      *
779      * @return ManagedPaymentProtocolConnectionFactory the factory in use
780      */
781     public HttpManagedConnectionFactoryImpl getManagedConnectionFactory ()
782     {
7830       return mManagedConnectionFactory;
784     }
785  
786     private HttpRequestResponseHeader getRequestResponseHeader ()
787     {
7880       if (mRequestResponseHeader == null)
789        {
7900          mRequestResponseHeader = new HttpRequestResponseHeader();
791        }
7920       return mRequestResponseHeader;
793     }
794  
795     /**
796      * Gets the string representation of the HttpManagedConnection.
797      *
798      * @return the string representation
799      */
800     public String toString ()
801     {
8020       final String result
803           = "HttpManagedConnectionImpl hashCode()=" + hashCode();
8040(13)      return result;
805     }
806  }

Findings in this File

w (14) Field only ever set to null: org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.mKeyStore
w (15) Field only ever set to null: org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.mTrustStore
c (1) 73 : 0 Type Javadoc comment is missing an @author tag.
c (2) 111 : 21 Private field 'mKeyStore' could be made final; it is only initialized in the declaration or constructor.
c (3) 112 : 21 Private field 'mTrustStore' could be made final; it is only initialized in the declaration or constructor.
i (4) 137 : 0 Unchecked/unconfirmed cast from javax.resource.spi.ConnectionRequestInfo to org.jcoderz.commons.connector.http.HttpConnectionRequestInfo in new org.jcoderz.commons.connector.http.HttpManagedConnectionImpl(HttpManagedConnectionFactoryImpl, ConnectionRequestInfo)
i (5) 279 : 0 Unchecked/unconfirmed cast from javax.resource.spi.ConnectionRequestInfo to org.jcoderz.commons.connector.http.HttpConnectionRequestInfo in org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.getConnection(Subject, ConnectionRequestInfo)
i (6) 287 : 0 method org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.getConnection(Subject, ConnectionRequestInfo) throws exception with static message string
w (7) 352 : 0 method org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.getMetaData() stores return result in local before immediately returning it
w (8) 442 : 0 Method org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.configure(HttpConnectionRequestInfo) assigns a variable in a larger scope then is needed
i (9) 463 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
i (10) 464 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
i (11) 486 : 0 method org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.configure(HttpConnectionRequestInfo) throws exception with static message string
i (12) 759 : 0 method org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.isCloseConnectionRequired() makes literal string comparisons passing the literal as an argument
w (13) 804 : 0 method org.jcoderz.commons.connector.http.HttpManagedConnectionImpl.toString() stores return result in local before immediately returning it