Project Report: fawkez

Packagesummary org.jcoderz.commons.connector

org.jcoderz.commons.connector.DefaultConnectionManager

LineHitsNoteSource
1  /*
2   * $Id: DefaultConnectionManager.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;
34  
35  import java.util.HashSet;
36  import java.util.Iterator;
37  import java.util.Set;
38  import java.util.logging.Logger;
39  
40  import javax.resource.ResourceException;
41  import javax.resource.spi.ConnectionManager;
42  import javax.resource.spi.ConnectionRequestInfo;
43  import javax.resource.spi.ManagedConnection;
44  import javax.resource.spi.ManagedConnectionFactory;
45  
46  /**
47   * The default Connection Manager. This Manager is intended to be used in a
48   * <b>two tier scenario</b> (Non-managed Environment, see Connection
49   * Architecture 1.0 Chapter 5.9).
50   *
51   */
52100(1)public class DefaultConnectionManager
53        implements ConnectionManager
54  {
55     /** The full qualified name of this class. */
5675    private static final transient String CLASSNAME
57           = DefaultConnectionManager.class.getName();
58  
59     /** The logger to use. */
60100    private static final transient Logger logger = Logger.getLogger(CLASSNAME);
61  
62     /**
63      * The Default <code>serialVersionUID</code>
64      */
65     private static final long serialVersionUID = 1L;
66  
67100    private final Set mMc = new HashSet();
68  
69     /**
70      * Creates a new physical connection to the underlying EIS instance.
71      *
72      * @see javax.resource.spi.ConnectionManager#allocateConnection(javax.resource.spi.ManagedConnectionFactory, javax.resource.spi.ConnectionRequestInfo)
73      */
74 (2)(3)   public Object allocateConnection (ManagedConnectionFactory mcf,
75 (4)         ConnectionRequestInfo cri)
76 (5)         throws ResourceException
77     {
78100       logger.entering(CLASSNAME, "allocateConnection",
79              new Object [] {mcf, cri});
80  
81100       ManagedConnection mc = mcf.matchManagedConnections(mMc, null, cri);
82  
83100       if (mc == null)
84        {
85100          mc = mcf.createManagedConnection(null, cri);
86100          synchronized (mMc)
87           {
88100             mMc.add(mc);
8950          }
90        }
91  
92100       final Object result = mc.getConnection(null, cri);
93  
94100       logger.exiting(CLASSNAME, "allocateConnection", result);
95  
96100       return result;
97     }
98  
99     /**
100      * Cleans up all managed connections.
101      */
102     public void cleanUp ()
103     {
104100       synchronized (mMc)
105        {
106100          final Iterator itr = mMc.iterator();
107100          while (itr.hasNext())
108           {
109              try
110              {
111100                ((ManagedConnection) itr.next()).cleanup();
112              }
1130             catch (ResourceException re)
114              {
115                 // nothing to do
11650             }
117           }
11850       }
119100    }
120  
121     /**
122      * Destroys all managed connections.
123      */
124     public void destroy ()
125     {
126100       synchronized (mMc)
127        {
128100          final Iterator itr = mMc.iterator();
129100          while (itr.hasNext())
130           {
131              try
132              {
133100                ((ManagedConnection) itr.next()).destroy();
134              }
1350             catch (ResourceException re)
136              {
137                 // nothing to do
13850             }
139           }
14050       }
141100       mMc.clear();
142100    }
143  }

Findings in this File

i (6) Class org.jcoderz.commons.connector.DefaultConnectionManager defines non-transient non-serializable instance field mMc
i (7) The field org.jcoderz.commons.connector.DefaultConnectionManager.CLASSNAME is transient but isn't set by deserialization
c (1) 52 : 0 Type Javadoc comment is missing an @author tag.
c (2) 74 : 0 Expected an @return tag.
c (3) 74 : 63 Expected @param tag for 'mcf'.
c (4) 75 : 32 Expected @param tag for 'cri'.
c (5) 76 : 17 Expected @throws tag for 'ResourceException'.