Date | 2007/07/27 |
---|---|
Codebase | 1739 |
Reviews | 2873 |
DPMO | 306 |
Sigma | 4.926 |
Name | Number | Min | Avg | Max | Total |
---|---|---|---|---|---|
Class complexity | 1 | 32.00 | 32.00 | 32.00 | 32.00 |
Code length | 18 | 1.00 | 3.33 | 21.00 | 60.00 |
File length | 1 | 207.00 | 207.00 | 207.00 | 207.00 |
Operation complexity | 18 | 1.00 | 1.77 | 6.00 | 32.00 |
Work order | 1 | 32.25 | 32.25 | 32.25 | 32.25 |
# | Line | Column | Name | Severity | Description |
---|---|---|---|---|---|
1 | 23 | 1 | ER-023 | 3 | Packages should begin with [] |
2 | 66 | 91 | ER-036 | 3 | Line is too long |
3 | 79 | 112 | ER-036 | 3 | Line is too long |
4 | 86 | 86 | ER-036 | 3 | Line is too long |
5 | 88 | 108 | ER-036 | 3 | Line is too long |
6 | 144 | 94 | ER-036 | 3 | Line is too long |
7 | 145 | 85 | ER-036 | 3 | Line is too long |
8 | 174 | 99 | ER-036 | 3 | Line is too long |
9 | 179 | 108 | ER-036 | 3 | Line is too long |
10 | 187 | 100 | ER-036 | 3 | Line is too long |
11 | 50 | 1 | ER-049 | 2 | Unify logging strategy - define individual logger for class |
12 | 71 | 25 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
13 | 85 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
14 | 88 | 88 | ER-116 | 3 | Use StringBuffer for excessive String concatenation |
15 | 88 | 61 | ER-030 | 3 | Avoid hardwired string literals |
16 | 88 | 89 | ER-030 | 3 | Avoid hardwired string literals |
17 | 99 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
18 | 103 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
19 | 107 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
20 | 111 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
21 | 120 | 32 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
22 | 130 | 9 | ER-102 | 2 | String Arrays are deprecated and are ONLY allowed for final variables |
23 | 130 | 9 | ER-104 | 2 | Use a Collection instead of arrays Object[] |
24 | 132 | 33 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
25 | 136 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
26 | 136 | 9 | ER-107 | 3 | Instance variables and method names shouldn't have same name |
27 | 140 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
28 | 147 | 35 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
29 | 149 | 35 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
30 | 157 | 19 | ER-103 | 2 | Catch-blocks should log the exeption with Log4J.error("Context String" , exception ) |
31 | 179 | 57 | ER-030 | 3 | Avoid hardwired string literals |
32 | 183 | 28 | ER-082 | 3 | Avoid using method parameter names that conflict with class member names |
33 | 187 | 61 | ER-030 | 3 | Avoid hardwired string literals |
34 | 197 | 9 | ER-105 | 3 | Document all Interfaces and public methods. Use a Class header. Provide Javadoc |
1/*
2 * Hammurapi
3 * Automated Java code review system.
4 * Copyright (C) 2004 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * URL: http://www.hammurapi.org
21 * e-Mail: support@hammurapi.biz
22 */
23package org.hammurapi;
24
25import java.io.IOException;
26import java.io.Reader;
27import java.sql.SQLException;
28import java.util.ArrayList;
29import java.util.Collection;
30import java.util.HashMap;
31import java.util.Iterator;
32import java.util.Map;
33import java.util.Properties;
34
35import javax.sql.DataSource;
36
37import org.hammurapi.results.ResultsFactory;
38
39import com.pavelvlasov.config.ConfigurationException;
40import com.pavelvlasov.persistence.Storage;
41import com.pavelvlasov.sql.ConnectionPerThreadDataSource;
42import com.pavelvlasov.sql.SQLProcessor;
43import com.pavelvlasov.sql.hypersonic.HypersonicTmpDataSource;
44import com.pavelvlasov.util.DispatchingVisitor;
45
46/**
47 * @author Pavel Vlasov
48 * @version $Revision: 1.6 $
49 */
50public class SessionImpl implements Session {
51
52 private DispatchingVisitor visitor;
53
54 private Map contexts=new HashMap();
55
56 private Collection inspectors;
57
58 private Storage storage;
59
60 private boolean inspectorsSet;
61
62 /**
63 * @return Returns the storage.
64 */
65 public Storage getStorage() {
66 return storage==null ? ResultsFactory.getInstance().getStorage() : storage;
67 }
68 /**
69 * @param storage The storage to set.
70 */
71 void setStorage(Storage storage) {
72 this.storage = storage;
73 }
74 /**
75 * @param inspectorSet The inspectors to set.
76 * @throws HammurapiException
77 * @throws ConfigurationException
78 */
79 public void setInspectors(InspectorSet inspectorSet) throws ConfigurationException, HammurapiException {
80 this.inspectorsSet=true;
81 this.inspectors = new ArrayList(inspectorSet.getInspectors());
82 inspectorSet.initInspectors();
83 }
84
85 public InspectorContext getContext(String inspectorName) {
86 InspectorContext ret = (InspectorContext) contexts.get(inspectorName);
87 if (ret==null) {
88 throw new HammurapiRuntimeException("Inspector '"+inspectorName+"' does not exist");
89 }
90 return ret;
91 }
92
93 void addContext(String inspectorName, InspectorContext context) {
94 contexts.put(inspectorName, context);
95 }
96
97 private Map attributes=new HashMap();
98
99 public void setAttribute(Object key, Object value) {
100 attributes.put(key, value);
101 }
102
103 public Object getAttribute(Object key) {
104 return attributes.get(key);
105 }
106
107 public Object removeAttribute(Object key) {
108 return attributes.remove(key);
109 }
110
111 public void disable(Inspector inspector) {
112 if (visitor!=null) {
113 visitor.remove(inspector);
114 }
115 }
116
117 /**
118 * @param visitor The visitor to set.
119 */
120 public void setVisitor(DispatchingVisitor visitor) {
121 this.visitor = visitor;
122 }
123
124 private SQLProcessor processor;
125
126 private ConnectionPerThreadDataSource datasource;
127
128 private boolean scheduleInitDb;
129
130 private String[] classPath;
131
132 void setClassPath(String[] classPath) {
133 this.classPath=classPath;
134 }
135
136 public void scheduleInitDb() {
137 this.scheduleInitDb = true;
138 }
139
140 public SQLProcessor getProcessor() {
141 try {
142 if (processor==null) {
143 try {
144 datasource=new HypersonicTmpDataSource((Reader) null);
145 processor=new SQLProcessor(datasource, null);
146 scheduleInitDb=true;
147 } catch (ClassNotFoundException e) {
148 throw new HammurapiRuntimeException(e);
149 } catch (IOException e) {
150 throw new HammurapiRuntimeException(e);
151 }
152 }
153 if (scheduleInitDb) {
154 scheduleInitDb=false;
155 initDb();
156 }
157 } catch (SQLException e) {
158 throw new HammurapiRuntimeException(e);
159 }
160
161 return processor;
162 }
163
164 /**
165 * @throws SQLException
166 */
167 private void initDb() throws SQLException {
168 if (inspectorsSet) {
169 if (inspectors!=null) {
170 Iterator it=inspectors.iterator();
171 while (it.hasNext()) {
172 Object next = it.next();
173 if (next instanceof Inspector) {
174 ((Inspector) next).initDb(processor, dbProperties);
175 }
176 }
177 }
178 } else {
179 throw new IllegalStateException("getProcessor() called before inspectors were set");
180 }
181 }
182
183 void setDatasource(DataSource datasource) {
184 if (processor==null) {
185 processor=new SQLProcessor(datasource,null);
186 } else {
187 throw new HammurapiRuntimeException("Illegal state: processor is not null");
188 }
189 }
190
191 void shutdown() throws SQLException {
192 if (datasource != null) {
193 datasource.shutdown();
194 }
195 }
196
197 public String[] getClassPath() {
198 return classPath;
199 }
200
201 private Properties dbProperties=new Properties();
202
203 void setDbProperty(String name, String value) {
204 dbProperties.setProperty(name, value);
205 }
206}
207
208