You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/07/01 00:37:29 UTC
svn commit: r418401 [3/32] - in /incubator/openjpa/trunk: openjpa-lib/
openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/
openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/
openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-lib/src/m...
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -16,17 +13,17 @@
package org.apache.openjpa.lib.conf;
import org.apache.commons.lang.*;
-
import org.apache.openjpa.lib.util.*;
-
/**
- * <p>An object {@link Value}.</p>
- *
- * @author Abe White
+ * An object {@link Value}.
+ *
+ * @author Abe White
*/
public class ObjectValue extends Value {
- private static final Localizer _loc = Localizer.forPackage(ObjectValue.class);
+ private static final Localizer _loc = Localizer.forPackage
+ (ObjectValue.class);
+
private Object _value = null;
public ObjectValue(String prop) {
@@ -34,28 +31,27 @@
}
/**
- * The internal value.
+ * The internal value.
*/
public Object get() {
return _value;
}
/**
- * The internal value.
+ * The internal value.
*/
public void set(Object obj) {
set(obj, false);
}
/**
- * The internal value.
- *
- * @param derived if true, this value was derived from other properties
+ * The internal value.
+ *
+ * @param derived if true, this value was derived from other properties
*/
public void set(Object obj, boolean derived) {
Object oldValue = _value;
_value = obj;
-
if (!derived && !ObjectUtils.equals(obj, oldValue)) {
objectChanged();
valueChanged();
@@ -63,26 +59,26 @@
}
/**
- * Instantiate the object as an instance of the given class. Equivalent
- * to <code>instantiate (type, conf, true)</code>.
+ * Instantiate the object as an instance of the given class. Equivalent
+ * to <code>instantiate(type, conf, true)</code>.
*/
public Object instantiate(Class type, Configuration conf) {
return instantiate(type, conf, true);
}
/**
- * Instantiate the object as an instance of the given class.
+ * Instantiate the object as an instance of the given class.
*/
public Object instantiate(Class type, Configuration conf, boolean fatal) {
throw new UnsupportedOperationException();
}
/**
- * Allow subclasses to instantiate additional plugins. This method does
- * not perform configuration.
+ * Allow subclasses to instantiate additional plugins. This method does
+ * not perform configuration.
*/
- public Object newInstance(String clsName, Class type, Configuration conf,
- boolean fatal) {
+ public Object newInstance(String clsName, Class type,
+ Configuration conf, boolean fatal) {
return Configurations.newInstance(clsName, this, conf,
type.getClassLoader(), fatal);
}
@@ -92,8 +88,8 @@
}
/**
- * Implement this method to synchronize internal data with the new
- * object value.
+ * Implement this method to synchronize internal data with the new
+ * object value.
*/
protected void objectChanged() {
}
@@ -103,12 +99,11 @@
}
protected void setInternalString(String str) {
- if (str == null) {
+ if (str == null)
set(null);
- } else {
+ else
throw new IllegalArgumentException(_loc.get("cant-set-string",
- getProperty()));
- }
+ getProperty()));
}
protected void setInternalObject(Object obj) {
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,23 +12,23 @@
*/
package org.apache.openjpa.lib.conf;
-import org.apache.openjpa.lib.util.*;
-
import java.lang.reflect.*;
-
import java.util.*;
-
+import org.apache.openjpa.lib.util.*;
/**
- * <p>A list of plugins. Defaults and aliases on plugin lists apply only
- * to individual class names.</p>
- *
- * @see PluginValue
- * @author Abe White
+ * A list of plugins. Defaults and aliases on plugin lists apply only
+ * to individual class names.
+ *
+ * @see PluginValue
+ * @author Abe White
*/
public class PluginListValue extends ObjectValue {
private static final String[] EMPTY = new String[0];
- private static final Localizer _loc = Localizer.forPackage(PluginListValue.class);
+
+ private static final Localizer _loc = Localizer.forPackage
+ (PluginListValue.class);
+
private String[] _names = EMPTY;
private String[] _props = EMPTY;
@@ -40,109 +37,91 @@
}
/**
- * The plugin class names.
+ * The plugin class names.
*/
public String[] getClassNames() {
return _names;
}
/**
- * The plugin class names.
+ * The plugin class names.
*/
public void setClassNames(String[] names) {
- if (names == null) {
+ if (names == null)
names = EMPTY;
- }
-
_names = names;
set(null, true);
valueChanged();
}
/**
- * The plugin properties.
+ * The plugin properties.
*/
public String[] getProperties() {
return _props;
}
/**
- * The plugin properties.
+ * The plugin properties.
*/
public void setProperties(String[] props) {
- if (props == null) {
+ if (props == null)
props = EMPTY;
- }
-
_props = props;
set(null, true);
valueChanged();
}
/**
- * Instantiate the plugins as instances of the given class.
+ * Instantiate the plugins as instances of the given class.
*/
public Object instantiate(Class elemType, Configuration conf, boolean fatal) {
Object[] ret;
-
- if (_names.length == 0) {
+ if (_names.length == 0)
ret = (Object[]) Array.newInstance(elemType, 0);
- } else {
+ else {
ret = (Object[]) Array.newInstance(elemType, _names.length);
-
for (int i = 0; i < ret.length; i++) {
ret[i] = newInstance(_names[i], elemType, conf, fatal);
Configurations.configureInstance(ret[i], conf, _props[i],
getProperty());
}
}
-
set(ret, true);
-
return ret;
}
/**
- * Override to recognize aliases of the class name without the attached
- * properties string.
+ * Override to recognize aliases of the class name without the attached
+ * properties string.
*/
public String getString() {
- if (_names.length == 0) {
+ if (_names.length == 0)
return null;
- }
StringBuffer buf = new StringBuffer();
-
for (int i = 0; i < _names.length; i++) {
- if (i > 0) {
+ if (i > 0)
buf.append(", ");
- }
-
buf.append(Configurations.getPlugin(alias(_names[i]), _props[i]));
}
-
- if (buf.length() == 0) {
+ if (buf.length() == 0)
return null;
- }
-
return buf.toString();
}
/**
- * Override to recognize aliases of the plugin name without the attached
- * properties string.
+ * Override to recognize aliases of the plugin name without the attached
+ * properties string.
*/
public void setString(String str) {
- if ((str == null) || (str.length() == 0)) {
+ if (str == null || str.length() == 0)
str = getDefault();
- }
-
- if ((str == null) || (str.length() == 0)) {
+ if (str == null || str.length() == 0) {
_names = EMPTY;
_props = EMPTY;
set(null, true);
valueChanged();
-
return;
}
@@ -152,58 +131,44 @@
StringBuffer plugin = new StringBuffer();
boolean inParen = false;
char c;
-
for (int i = 0; i < str.length(); i++) {
c = str.charAt(i);
-
switch (c) {
case '(':
inParen = true;
plugin.append(c);
-
break;
-
case ')':
inParen = false;
plugin.append(c);
-
break;
-
case ',':
-
- if (inParen) {
+ if (inParen)
plugin.append(c);
- } else {
+ else {
plugins.add(plugin.toString());
plugin = new StringBuffer();
}
-
break;
-
default:
plugin.append(c);
}
}
-
- if (plugin.length() > 0) {
+ if (plugin.length() > 0)
plugins.add(plugin.toString());
- }
// parse each plugin element into its name and properties
List names = new ArrayList();
List props = new ArrayList();
String clsName;
-
for (int i = 0; i < plugins.size(); i++) {
str = (String) plugins.get(i);
clsName = unalias(Configurations.getClassName(str));
-
if (clsName != null) {
names.add(clsName);
props.add(Configurations.getProperties(str));
}
}
-
_names = (String[]) names.toArray(new String[names.size()]);
_props = (String[]) props.toArray(new String[props.size()]);
set(null, true);
@@ -216,17 +181,14 @@
protected void objectChanged() {
Object[] vals = (Object[]) get();
-
- if ((vals == null) || (vals.length == 0)) {
+ if (vals == null || vals.length == 0)
_names = EMPTY;
- } else {
+ else {
_names = new String[vals.length];
-
for (int i = 0; i < vals.length; i++)
_names[i] = (vals[i] == null) ? null
- : vals[i].getClass().getName();
+ : vals[i].getClass().getName();
}
-
_props = EMPTY;
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -16,25 +13,24 @@
package org.apache.openjpa.lib.conf;
import org.apache.commons.lang.*;
-
import org.apache.openjpa.lib.util.*;
-
/**
- * <p>A plugin {@link Value} consisting of plugin name and properties.
- * Plugins should be specified in the form:<br />
- * <code><plugin-name>(<prop1>=<val1>, ...)</code><br />
- * Both the plugin name and prop list are optional, so that the following
- * forms are also valid:<br />
- * <code><plugin-name></code><br />
- * <code><prop1>=<val1> ...</code></p>
- *
- * <p>Defaults and aliases on plugin values apply only to the plugin name.</p>
- *
- * @author Abe White
+ * A plugin {@link Value} consisting of plugin name and properties.
+ * Plugins should be specified in the form:<br />
+ * <code><plugin-name>(<prop1>=<val1>, ...)</code><br />
+ * Both the plugin name and prop list are optional, so that the following
+ * forms are also valid:<br />
+ * <code><plugin-name></code><br />
+ * <code><prop1>=<val1> ...</code>
+ * Defaults and aliases on plugin values apply only to the plugin name.
+ *
+ * @author Abe White
*/
public class PluginValue extends ObjectValue {
- private static final Localizer _loc = Localizer.forPackage(PluginValue.class);
+ private static final Localizer _loc = Localizer.forPackage
+ (PluginValue.class);
+
private final boolean _singleton;
private String _name = null;
private String _props = null;
@@ -45,79 +41,68 @@
}
/**
- * Whether this value is a singleton.
+ * Whether this value is a singleton.
*/
public boolean isSingleton() {
return _singleton;
}
/**
- * The plugin class name.
+ * The plugin class name.
*/
public String getClassName() {
return _name;
}
/**
- * The plugin class name.
+ * The plugin class name.
*/
public void setClassName(String name) {
String oldName = _name;
_name = name;
-
if (!StringUtils.equals(oldName, name)) {
- if (_singleton) {
+ if (_singleton)
set(null, true);
- }
-
valueChanged();
}
}
/**
- * The plugin properties.
+ * The plugin properties.
*/
public String getProperties() {
return _props;
}
/**
- * The plugin properties.
+ * The plugin properties.
*/
public void setProperties(String props) {
String oldProps = _props;
_props = props;
-
if (!StringUtils.equals(oldProps, props)) {
- if (_singleton) {
+ if (_singleton)
set(null, true);
- }
-
valueChanged();
}
}
/**
- * Instantiate the plugin as an instance of the given class.
+ * Instantiate the plugin as an instance of the given class.
*/
public Object instantiate(Class type, Configuration conf, boolean fatal) {
Object obj = newInstance(_name, type, conf, fatal);
Configurations.configureInstance(obj, conf, _props,
(fatal) ? getProperty() : null);
-
- if (_singleton) {
+ if (_singleton)
set(obj, true);
- }
-
return obj;
}
public void set(Object obj, boolean derived) {
- if (!_singleton) {
+ if (!_singleton)
throw new IllegalStateException(_loc.get("not-singleton",
- getProperty()));
- }
-
+ getProperty()));
super.set(obj, derived);
}
@@ -129,11 +114,8 @@
_name = Configurations.getClassName(str);
_name = unalias(_name);
_props = Configurations.getProperties(str);
-
- if (_singleton) {
+ if (_singleton)
set(null, true);
- }
-
valueChanged();
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,14 +14,14 @@
import serp.util.*;
-
/**
- * <p>A comma-separated list of string values.</p>
- *
- * @author Abe White
+ * A comma-separated list of string values.
+ *
+ * @author Abe White
*/
public class StringListValue extends Value {
public static final String[] EMPTY = new String[0];
+
private String[] _values = EMPTY;
public StringListValue(String prop) {
@@ -32,7 +29,7 @@
}
/**
- * The internal value.
+ * The internal value.
*/
public void set(String[] values) {
_values = (values == null) ? EMPTY : values;
@@ -40,7 +37,7 @@
}
/**
- * The internal value.
+ * The internal value.
*/
public String[] get() {
return _values;
@@ -56,12 +53,9 @@
protected void setInternalString(String val) {
String[] vals = Strings.split(val, ",", 0);
-
- if (vals != null) {
+ if (vals != null)
for (int i = 0; i < vals.length; i++)
vals[i] = vals[i].trim();
- }
-
set(vals);
}
@@ -69,3 +63,4 @@
set((String[]) obj);
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,11 +14,10 @@
import org.apache.commons.lang.*;
-
/**
- * A string {@link Value}.
- *
- * @author Marc Prud'hommeaux
+ * A string {@link Value}.
+ *
+ * @author Marc Prud'hommeaux
*/
public class StringValue extends Value {
private String value;
@@ -35,22 +31,20 @@
}
/**
- * The internal value.
+ * The internal value.
*/
public String get() {
return value;
}
/**
- * The internal value.
+ * The internal value.
*/
public void set(String value) {
String oldValue = this.value;
this.value = value;
-
- if (!StringUtils.equals(value, oldValue)) {
+ if (!StringUtils.equals(value, oldValue))
valueChanged();
- }
}
protected String getInternalString() {
@@ -65,3 +59,4 @@
set((String) obj);
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,21 +12,19 @@
*/
package org.apache.openjpa.lib.conf;
+import java.util.*;
import org.apache.commons.lang.*;
-
import org.apache.openjpa.lib.util.*;
-import java.util.*;
-
-
/**
- * A configuration value.
- *
- * @author Marc Prud'hommeaux
+ * A configuration value.
+ *
+ * @author Marc Prud'hommeaux
*/
public abstract class Value implements Cloneable {
private static final String[] EMPTY_ALIASES = new String[0];
private static final Localizer s_loc = Localizer.forPackage(Value.class);
+
private String prop = null;
private String def = null;
private String[] aliases = null;
@@ -39,73 +34,70 @@
private Class scope = null;
/**
- * Constructor. Supply the property name.
- *
- * @see #setProperty
+ * Constructor. Supply the property name.
+ *
+ * @see #setProperty
*/
public Value(String prop) {
setProperty(prop);
}
/**
- * Default constructor.
+ * Default constructor.
*/
public Value() {
}
/**
- * The property name that will be used when setting or
- * getting this value in a {@link Map}.
+ * The property name that will be used when setting or
+ * getting this value in a {@link Map}.
*/
public String getProperty() {
return prop;
}
/**
- * The property name that will be used when setting or
- * getting this value in a {@link Map}.
+ * The property name that will be used when setting or
+ * getting this value in a {@link Map}.
*/
public void setProperty(String prop) {
this.prop = prop;
}
/**
- * Aliases for the value in the form key1, value1, key2, value2, ...
- * All alias values must be in string form.
+ * Aliases for the value in the form key1, value1, key2, value2, ...
+ * All alias values must be in string form.
*/
public String[] getAliases() {
- return (aliases == null) ? EMPTY_ALIASES : aliases;
+ return(aliases == null) ? EMPTY_ALIASES : aliases;
}
/**
- * Aliases for the value in the form key1, value1, key2, value2, ...
- * All alias values must be in string form.
+ * Aliases for the value in the form key1, value1, key2, value2, ...
+ * All alias values must be in string form.
*/
public void setAliases(String[] aliases) {
this.aliases = aliases;
}
/**
- * Replaces an existing alias, or adds the given alias to the front of the
- * alias list if it does not already exist. All alias values must be in
- * string form.
+ * Replaces an existing alias, or adds the given alias to the front of the
+ * alias list if it does not already exist. All alias values must be in
+ * string form.
*/
public void setAlias(String key, String value) {
aliases = setAlias(key, value, aliases);
}
/**
- * Set an alias into a current alias list, returning the new list.
+ * Set an alias into a current alias list, returning the new list.
*/
protected String[] setAlias(String key, String value, String[] aliases) {
- if (aliases == null) {
+ if (aliases == null)
aliases = EMPTY_ALIASES;
- }
-
for (int i = 0; i < aliases.length; i += 2) {
if (key.equals(aliases[i])) {
aliases[i + 1] = value;
-
return aliases;
}
}
@@ -115,121 +107,107 @@
System.arraycopy(aliases, 0, newAliases, 2, aliases.length);
newAliases[0] = key;
newAliases[1] = value;
-
return newAliases;
}
/**
- * Whether or not the alias list defines all possible settings for this
- * value. If so, an error will be generated when attempting to invoke
- * any method on this value with an unknown option.
+ * Whether or not the alias list defines all possible settings for this
+ * value. If so, an error will be generated when attempting to invoke
+ * any method on this value with an unknown option.
*/
public boolean isAliasListComprehensive() {
return aliasListComprehensive;
}
/**
- * Whether or not the alias list defines all possible settings for this
- * value. If so, an error will be generated when attempting to invoke
- * any method on this value with an unknown option.
+ * Whether or not the alias list defines all possible settings for this
+ * value. If so, an error will be generated when attempting to invoke
+ * any method on this value with an unknown option.
*/
public void setAliasListComprehensive(boolean aliasListIsComprehensive) {
this.aliasListComprehensive = aliasListIsComprehensive;
}
/**
- * Alias the given setting.
+ * Alias the given setting.
*/
public String alias(String str) {
return alias(str, aliases, false);
}
/**
- * Alias the given setting.
+ * Alias the given setting.
*/
protected String alias(String str, String[] aliases, boolean nullNotFound) {
- if (str != null) {
+ if (str != null)
str = str.trim();
- }
-
- if ((aliases == null) || (aliases.length == 0)) {
- return (nullNotFound) ? null : str;
- }
-
- boolean empty = (str != null) && (str.length() == 0);
+ if (aliases == null || aliases.length == 0)
+ return(nullNotFound) ? null : str;
+ boolean empty = str != null && str.length() == 0;
for (int i = 1; i < aliases.length; i += 2)
- if (StringUtils.equals(str, aliases[i]) ||
- (empty && (aliases[i] == null))) {
+ if (StringUtils.equals(str, aliases[i])
+ || (empty && aliases[i] == null))
return aliases[i - 1];
- }
-
- return (nullNotFound) ? null : str;
+ return(nullNotFound) ? null : str;
}
/**
- * Unalias the given setting.
+ * Unalias the given setting.
*/
public String unalias(String str) {
return unalias(str, aliases, false);
}
/**
- * Unalias the given setting.
+ * Unalias the given setting.
*/
protected String unalias(String str, String[] aliases, boolean nullNotFound) {
- if (str != null) {
+ if (str != null)
str = str.trim();
- }
- boolean empty = (str != null) && (str.length() == 0);
-
- if ((str == null) || (empty && (def != null))) {
+ boolean empty = str != null && str.length() == 0;
+ if (str == null || (empty && def != null))
str = def;
- }
-
- if (aliases != null) {
+ if (aliases != null)
for (int i = 0; i < aliases.length; i += 2)
- if (StringUtils.equals(str, aliases[i]) ||
- StringUtils.equals(str, aliases[i + 1]) ||
- (empty && (aliases[i] == null))) {
+ if (StringUtils.equals(str, aliases[i])
+ || StringUtils.equals(str, aliases[i+1])
+ || (empty && aliases[i] == null))
return aliases[i + 1];
- }
- }
- if (isAliasListComprehensive() && (aliases != null)) {
+ if (isAliasListComprehensive() && aliases != null)
throw new ParseException(s_loc.get("invalid-enumerated-config",
- getProperty(), str, Arrays.asList(aliases)));
- }
+ getProperty(), str, Arrays.asList(aliases)));
- return (nullNotFound) ? null : str;
+ return(nullNotFound) ? null : str;
}
/**
- * The default value for the property as a string.
+ * The default value for the property as a string.
*/
public String getDefault() {
return def;
}
/**
- * The default value for the propert as a string.
+ * The default value for the propert as a string.
*/
public void setDefault(String def) {
this.def = def;
}
/**
- * The name of the getter method for the instantiated value of this
- * property (as opposed to the string value)
+ * The name of the getter method for the instantiated value of this
+ * property(as opposed to the string value)
*/
public String getInstantiatingGetter() {
return getter;
}
/**
- * The name of the getter method for the instantiated value of this
- * property (as opposed to the string value)
+ * The name of the getter method for the instantiated value of this
+ * property(as opposed to the string value)
*/
public void setInstantiatingGetter(String getter) {
this.getter = getter;
@@ -254,22 +232,21 @@
}
/**
- * Return a stringified version of this value. If the current value has
- * a short alias key, the alias key is returned.
+ * Return a stringified version of this value. If the current value has
+ * a short alias key, the alias key is returned.
*/
public String getString() {
return alias(getInternalString());
}
/**
- * Set this value from the given string. If the given string is null or
- * empty and a default is defined, the default is used. If the given
- * string (or default) is an alias key, it will be converted to the
- * corresponding value internally.
+ * Set this value from the given string. If the given string is null or
+ * empty and a default is defined, the default is used. If the given
+ * string(or default) is an alias key, it will be converted to the
+ * corresponding value internally.
*/
public void setString(String val) {
String str = unalias(val);
-
try {
setInternalString(str);
} catch (ParseException pe) {
@@ -280,13 +257,13 @@
}
/**
- * Set this value as an object.
+ * Set this value as an object.
*/
public void setObject(Object obj) {
// if setting to null set as string to get defaults into play
- if ((obj == null) && (def != null)) {
+ if (obj == null && def != null)
setString(null);
- } else {
+ else {
try {
setInternalObject(obj);
} catch (ParseException pe) {
@@ -298,69 +275,63 @@
}
/**
- * Returns the type of the property that this Value represents.
+ * Returns the type of the property that this Value represents.
*/
public abstract Class getValueType();
/**
- * Return the internal string form of this value.
+ * Return the internal string form of this value.
*/
protected abstract String getInternalString();
/**
- * Set this value from the given string.
+ * Set this value from the given string.
*/
protected abstract void setInternalString(String str);
/**
- * Set this value from an object.
+ * Set this value from an object.
*/
protected abstract void setInternalObject(Object obj);
/**
- * Listener for value changes.
+ * Listener for value changes.
*/
public ValueListener getListener() {
return this.listen;
}
/**
- * Listener for value changes.
+ * Listener for value changes.
*/
public void setListener(ValueListener listen) {
this.listen = listen;
}
/**
- * Subclasses should call this method when their inernal value changes.
+ * Subclasses should call this method when their inernal value changes.
*/
public void valueChanged() {
- if (listen != null) {
+ if (listen != null)
listen.valueChanged(this);
- }
}
public int hashCode() {
String str = getString();
- int strHash = (str == null) ? 0 : str.hashCode();
+ int strHash = (str == null) ? 0 : str.hashCode();
int propHash = (prop == null) ? 0 : prop.hashCode();
-
return strHash ^ propHash;
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (!(other instanceof Value)) {
+ if (!(other instanceof Value))
return false;
- }
-
- Value o = (Value) other;
- return StringUtils.equals(prop, o.getProperty()) &&
- StringUtils.equals(getString(), o.getString());
+ Value o = (Value)other;
+ return StringUtils.equals(prop, o.getProperty())
+ && StringUtils.equals(getString(), o.getString());
}
public Object clone() {
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ValueListener.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ValueListener.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ValueListener.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ValueListener.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,16 +12,14 @@
*/
package org.apache.openjpa.lib.conf;
-
/**
- * <p>Components can listen on {@link Value} objects for changes directly.</p>
- *
- * @author Abe White
+ * Components can listen on {@link Value} objects for changes directly.
+ *
+ * @author Abe White
*/
public interface ValueListener {
/**
- * Callback used by {@link Value} objects to notify listener of
- * change.
+ * Callback used by {@link Value} objects to notify listener of change.
*/
public void valueChanged(Value val);
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/AbstractJDBCListener.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/AbstractJDBCListener.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/AbstractJDBCListener.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/AbstractJDBCListener.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,18 +12,16 @@
*/
package org.apache.openjpa.lib.jdbc;
-
/**
- * An abstract implementation of the {@link JDBCListener}
- * listener. It allows simple implementation of fine-grained
- * event handling.
- *
- * @author Marc Prud'hommeaux
+ * An abstract implementation of the {@link JDBCListener}
+ * listener. It allows simple implementation of fine-grained event handling.
+ *
+ * @author Marc Prud'hommeaux
*/
public class AbstractJDBCListener implements JDBCListener {
/**
- * Catch-all for unhandled events. This method is called by all other
- * event methods if you do not override them. Does nothing by default.
+ * Catch-all for unhandled events. This method is called by all other
+ * event methods if you do not override them. Does nothing by default.
*/
protected void eventOccurred(JDBCEvent event) {
}
@@ -87,3 +82,4 @@
eventOccurred(event);
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -16,100 +13,92 @@
package org.apache.openjpa.lib.jdbc;
import java.sql.*;
-
import javax.sql.*;
-
/**
- * <p>Connection decorator that can configure some properties of the
- * underlying connection. Understands the following properties:
- * <ul>
- * <li>QueryTimeout</li>
- * <li>TransactionIsolation ({@link Connection} constants)</li>
- * <li>AutoCommit</li>
- * </ul></p>
- *
- * @author Abe White
- * @nojavadoc */
+ * Connection decorator that can configure some properties of the
+ * underlying connection. Understands the following properties:
+ * <ul>
+ * <li>QueryTimeout</li>
+ * <li>TransactionIsolation({@link Connection} constants)</li>
+ * <li>AutoCommit</li>
+ * </ul>
+ *
+ * @author Abe White
+ * @nojavadoc
+ */
public class ConfiguringConnectionDecorator implements ConnectionDecorator {
private int _isolation = -1;
private int _queryTimeout = -1;
private Boolean _autoCommit = null;
/**
- * The number of seconds to wait for a query to execute before
- * terminating it.
+ * The number of seconds to wait for a query to execute before
+ * terminating it.
*/
public int getQueryTimeout() {
return _queryTimeout;
}
/**
- * The number of seconds to wait for a query to execute before
- * terminating it.
+ * The number of seconds to wait for a query to execute before
+ * terminating it.
*/
public void setQueryTimeout(int timeout) {
_queryTimeout = timeout;
}
/**
- * The transaction isolation level.
+ * The transaction isolation level.
*/
public int getTransactionIsolation() {
return _isolation;
}
/**
- * The transaction isolation level.
+ * The transaction isolation level.
*/
public void setTransactionIsolation(int isolation) {
_isolation = isolation;
}
/**
- * Whether auto commit should be on. Use null to keep
- * the connection's default setting. Defaults to null.
+ * Whether auto commit should be on. Use null to keep
+ * the connection's default setting. Defaults to null.
*/
public Boolean getAutoCommit() {
return _autoCommit;
}
/**
- * Whether auto commit should be on. Use null to keep
- * the connection's default setting. Defaults to null.
+ * Whether auto commit should be on. Use null to keep
+ * the connection's default setting. Defaults to null.
*/
public void setAutoCommit(Boolean autoCommit) {
_autoCommit = autoCommit;
}
public Connection decorate(Connection conn) throws SQLException {
- if ((_isolation == Connection.TRANSACTION_NONE) ||
- (_queryTimeout != -1) || (_autoCommit != null)) {
+ if (_isolation == Connection.TRANSACTION_NONE || _queryTimeout != -1
+ || _autoCommit != null)
conn = new ConfiguringConnection(conn);
- }
-
- if ((_isolation != -1) && (_isolation != Connection.TRANSACTION_NONE)) {
+ if (_isolation != -1 && _isolation != Connection.TRANSACTION_NONE)
conn.setTransactionIsolation(_isolation);
- }
-
return conn;
}
/**
- * Decorator to configure connection components correctly.
+ * Decorator to configure connection components correctly.
*/
private class ConfiguringConnection extends DelegatingConnection {
private boolean _curAutoCommit = false;
public ConfiguringConnection(Connection conn) throws SQLException {
super(conn);
-
if (_autoCommit != null) {
_curAutoCommit = ConfiguringConnection.this.getAutoCommit();
-
- if (_curAutoCommit != _autoCommit.booleanValue()) {
+ if (_curAutoCommit != _autoCommit.booleanValue())
setAutoCommit(_autoCommit.booleanValue());
- }
}
}
@@ -121,69 +110,50 @@
}
public void commit() throws SQLException {
- if (_isolation != TRANSACTION_NONE) {
+ if (_isolation != TRANSACTION_NONE)
super.commit();
- }
-
- if ((_autoCommit != null) &&
- (_autoCommit.booleanValue() != _curAutoCommit)) {
+ if (_autoCommit != null
+ && _autoCommit.booleanValue() != _curAutoCommit)
setAutoCommit(_autoCommit.booleanValue());
- }
}
public void rollback() throws SQLException {
- if (_isolation != TRANSACTION_NONE) {
+ if (_isolation != TRANSACTION_NONE)
super.rollback();
- }
-
- if ((_autoCommit != null) &&
- (_autoCommit.booleanValue() != _curAutoCommit)) {
+ if (_autoCommit != null
+ && _autoCommit.booleanValue() != _curAutoCommit)
setAutoCommit(_autoCommit.booleanValue());
- }
}
protected PreparedStatement prepareStatement(String sql, boolean wrap)
throws SQLException {
PreparedStatement stmnt = super.prepareStatement(sql, wrap);
-
- if (_queryTimeout != -1) {
+ if (_queryTimeout != -1)
stmnt.setQueryTimeout(_queryTimeout);
- }
-
return stmnt;
}
protected PreparedStatement prepareStatement(String sql, int rsType,
int rsConcur, boolean wrap) throws SQLException {
PreparedStatement stmnt = super.prepareStatement(sql, rsType,
- rsConcur, wrap);
-
- if (_queryTimeout != -1) {
+ rsConcur, wrap);
+ if (_queryTimeout != -1)
stmnt.setQueryTimeout(_queryTimeout);
- }
-
return stmnt;
}
- protected Statement createStatement(boolean wrap)
- throws SQLException {
+ protected Statement createStatement(boolean wrap) throws SQLException {
Statement stmnt = super.createStatement(wrap);
-
- if (_queryTimeout != -1) {
+ if (_queryTimeout != -1)
stmnt.setQueryTimeout(_queryTimeout);
- }
-
return stmnt;
}
protected Statement createStatement(int rsType, int rsConcur,
boolean wrap) throws SQLException {
Statement stmnt = super.createStatement(rsType, rsConcur, wrap);
-
- if (_queryTimeout != -1) {
+ if (_queryTimeout != -1)
stmnt.setQueryTimeout(_queryTimeout);
- }
-
return stmnt;
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConnectionDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConnectionDecorator.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConnectionDecorator.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConnectionDecorator.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,16 +14,15 @@
import java.sql.*;
-
/**
- * <p>A connection decorator can wrap {@link Connection}s before they are
- * returned to the user to add functionality.</p>
- *
- * @author Abe White
+ * A connection decorator can wrap {@link Connection}s before they are
+ * returned to the user to add functionality.
+ *
+ * @author Abe White
*/
public interface ConnectionDecorator {
/**
- * Decorate the given connection if desired.
+ * Decorate the given connection if desired.
*/
public Connection decorate(Connection conn) throws SQLException;
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DataSourceLogs.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DataSourceLogs.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DataSourceLogs.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DataSourceLogs.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,20 +12,17 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.log.*;
-
import java.sql.*;
-
import java.util.*;
-
import javax.sql.*;
-
+import org.apache.openjpa.lib.log.*;
/**
- * Provies basic logging facilities to a DataSource.
- *
- * @author Marc Prud'hommeaux
- * @nojavadoc */
+ * Provies basic logging facilities to a DataSource.
+ *
+ * @author Marc Prud'hommeaux
+ * @nojavadoc
+ */
public class DataSourceLogs {
private Log _jdbcLog = null;
private Log _sqlLog = null;
@@ -42,112 +36,108 @@
}
/**
- * The log to write JDBC messages to.
+ * The log to write JDBC messages to.
*/
public Log getJDBCLog() {
- return (_jdbcLog == null) ? NoneLogFactory.NoneLog.getInstance()
- : _jdbcLog;
+ return(_jdbcLog == null) ? NoneLogFactory.NoneLog.getInstance()
+ : _jdbcLog;
}
/**
- * The log to write JDBC messages to.
+ * The log to write JDBC messages to.
*/
public void setJDBCLog(Log log) {
_jdbcLog = log;
}
/**
- * Return true if JDBC logging is enabled.
+ * Return true if JDBC logging is enabled.
*/
public boolean isJDBCEnabled() {
- return ((_jdbcLog != null) && _jdbcLog.isTraceEnabled());
+ return(_jdbcLog != null && _jdbcLog.isTraceEnabled());
}
/**
- * The log to write SQL messages to.
+ * The log to write SQL messages to.
*/
public Log getSQLLog() {
- return (_sqlLog == null) ? NoneLogFactory.NoneLog.getInstance() : _sqlLog;
+ return(_sqlLog == null) ? NoneLogFactory.NoneLog.getInstance()
+ : _sqlLog;
}
/**
- * The log to write SQL messages to.
+ * The log to write SQL messages to.
*/
public void setSQLLog(Log log) {
_sqlLog = log;
}
/**
- * Return true if SQL logging is enabled.
+ * Return true if SQL logging is enabled.
*/
public boolean isSQLEnabled() {
- return ((_sqlLog != null) && _sqlLog.isTraceEnabled());
+ return(_sqlLog != null && _sqlLog.isTraceEnabled());
}
/**
- * Log a JDBC message on behalf of the given connection.
+ * Log a JDBC message on behalf of the given connection.
*/
public void logJDBC(String msg, Connection conn) {
log(msg, conn, _jdbcLog);
}
/**
- * Log a JDBC message on behalf of the given connection.
+ * Log a JDBC message on behalf of the given connection.
*/
public void logJDBC(String msg, long startTime, Connection conn) {
log(msg, conn, _jdbcLog, startTime);
}
/**
- * Log a SQL message on behalf of the given connection.
+ * Log a SQL message on behalf of the given connection.
*/
public void logSQL(String msg, Connection conn) {
log(msg, conn, _sqlLog);
}
/**
- * Log a SQL message on behalf of the given connection.
+ * Log a SQL message on behalf of the given connection.
*/
public void logSQL(String msg, long startTime, Connection conn) {
log(msg, conn, _sqlLog, startTime);
}
/**
- * Log a message to the given logger.
+ * Log a message to the given logger.
*/
private static void log(String msg, Connection conn, Log log) {
log(msg, conn, log, -1);
}
/**
- * Log a message to the given logger.
+ * Log a message to the given logger.
*/
- private static void log(String msg, Connection conn, Log log, long startTime) {
- if ((log == null) || !log.isTraceEnabled()) {
+ private static void log(String msg, Connection conn,
+ Log log, long startTime) {
+ if (log == null || !log.isTraceEnabled())
return;
- }
long totalTime = -1;
-
- if (startTime != -1) {
+ if (startTime != -1)
totalTime = System.currentTimeMillis() - startTime;
- }
StringBuffer buf = new StringBuffer(25 + msg.length());
buf.append("<t ").append(Thread.currentThread().hashCode());
-
- if (conn != null) {
+ if (conn != null)
buf.append(", ").append(conn);
- }
-
buf.append("> ");
// in the time != -1, append time profiling information
- if (totalTime != -1) {
+ if (totalTime != -1)
buf.append("[").append(totalTime).append(" ms] ");
- }
buf.append(msg);
log.trace(buf.toString());
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,67 +12,61 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.util.concurrent.*;
-
import java.sql.*;
-
import java.util.*;
-
import javax.sql.*;
-
+import org.apache.openjpa.lib.util.concurrent.*;
/**
- * <p>Delegating data source that maintains a list of
- * {@link ConnectionDecorator}s.</p>
- *
- * @author Abe White
- * @nojavadoc */
+ * Delegating data source that maintains a list of {@link ConnectionDecorator}s.
+ *
+ * @author Abe White
+ * @nojavadoc
+ */
public class DecoratingDataSource extends DelegatingDataSource {
private List _decorators = new CopyOnWriteArrayList();
private boolean _conf = false;
/**
- * Constructor. Supply wrapped data source.
+ * Constructor. Supply wrapped data source.
*/
public DecoratingDataSource(DataSource ds) {
super(ds);
}
/**
- * Return a read-only list of connection decorators in the order they were
- * added.
+ * Return a read-only list of connection decorators in the order they were
+ * added.
*/
public Collection getDecorators() {
return Collections.unmodifiableCollection(_decorators);
}
/**
- * Add a connection decorator.
+ * Add a connection decorator.
*/
public void addDecorator(ConnectionDecorator decorator) {
- if (decorator != null) {
+ if (decorator != null)
_decorators.add(decorator);
- }
}
/**
- * Add multiple connection decorators efficiently.
+ * Add multiple connection decorators efficiently.
*/
public void addDecorators(Collection decorators) {
- if (decorators != null) {
+ if (decorators != null)
_decorators.addAll(decorators);
- }
}
/**
- * Remove a connection decorator.
+ * Remove a connection decorator.
*/
public boolean removeDecorator(ConnectionDecorator decorator) {
return _decorators.remove(decorator);
}
/**
- * Clear all decorators.
+ * Clear all decorators.
*/
public void clearDecorators() {
_decorators.clear();
@@ -83,23 +74,19 @@
public Connection getConnection() throws SQLException {
Connection conn = super.getConnection();
-
return decorate(conn);
}
public Connection getConnection(String user, String pass)
throws SQLException {
Connection conn = super.getConnection(user, pass);
-
return decorate(conn);
}
private Connection decorate(Connection conn) throws SQLException {
- if (!_decorators.isEmpty()) {
+ if (!_decorators.isEmpty())
for (Iterator itr = _decorators.iterator(); itr.hasNext();)
conn = ((ConnectionDecorator) itr.next()).decorate(conn);
- }
-
return conn;
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,28 +12,21 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.util.*;
-import org.apache.openjpa.lib.util.Closeable;
-
import java.io.*;
-
import java.math.*;
-
import java.net.*;
-
import java.sql.*;
import java.sql.Date;
-
import java.util.*;
-
+import org.apache.openjpa.lib.util.*;
+import org.apache.openjpa.lib.util.Closeable;
/**
- * <p>{@link CallableStatement} that delegates to an internal statement.</p>
- *
- * @author Abe White
+ * {@link CallableStatement} that delegates to an internal statement.
+ *
+ * @author Abe White
*/
-public class DelegatingCallableStatement implements CallableStatement,
- Closeable {
+public class DelegatingCallableStatement implements CallableStatement, Closeable {
private final CallableStatement _stmnt;
private final DelegatingCallableStatement _del;
private final Connection _conn;
@@ -44,39 +34,35 @@
public DelegatingCallableStatement(CallableStatement stmnt, Connection conn) {
_conn = conn;
_stmnt = stmnt;
-
- if (_stmnt instanceof DelegatingCallableStatement) {
+ if (_stmnt instanceof DelegatingCallableStatement)
_del = (DelegatingCallableStatement) _stmnt;
- } else {
+ else
_del = null;
- }
}
private ResultSet wrapResult(boolean wrap, ResultSet rs) {
- if (!wrap) {
+ if (!wrap)
return rs;
- }
// never wrap null
- if (rs == null) {
+ if (rs == null)
return null;
- }
return new DelegatingResultSet(rs, this);
}
/**
- * Return the wrapped statement.
+ * Return the wrapped statement.
*/
public CallableStatement getDelegate() {
return _stmnt;
}
/**
- * Return the base underlying data store statement.
+ * Return the base underlying data store statement.
*/
public CallableStatement getInnermostDelegate() {
- return (_del == null) ? _stmnt : _del.getInnermostDelegate();
+ return(_del == null) ? _stmnt : _del.getInnermostDelegate();
}
public int hashCode() {
@@ -84,28 +70,23 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other instanceof DelegatingCallableStatement) {
- other = ((DelegatingCallableStatement) other).getInnermostDelegate();
- }
-
+ if (other instanceof DelegatingCallableStatement)
+ other = ((DelegatingCallableStatement) other).
+ getInnermostDelegate();
return getInnermostDelegate().equals(other);
}
public String toString() {
StringBuffer buf = new StringBuffer("prepstmnt ").append(hashCode());
appendInfo(buf);
-
return buf.toString();
}
protected void appendInfo(StringBuffer buf) {
- if (_del != null) {
+ if (_del != null)
_del.appendInfo(buf);
- }
}
public ResultSet executeQuery(String str) throws SQLException {
@@ -113,18 +94,16 @@
}
/**
- * Execute the query, with the option of not wrapping it in a
- * {@link DelegatingResultSet}, which is the default.
+ * Execute the query, with the option of not wrapping it in a
+ * {@link DelegatingResultSet}, which is the default.
*/
protected ResultSet executeQuery(String sql, boolean wrap)
throws SQLException {
ResultSet rs;
-
- if (_del != null) {
+ if (_del != null)
rs = _del.executeQuery(sql, false);
- } else {
+ else
rs = _stmnt.executeQuery(sql);
- }
return wrapResult(wrap, rs);
}
@@ -190,17 +169,15 @@
}
/**
- * Get the last result set, with the option of not wrapping it in a
- * {@link DelegatingResultSet}, which is the default.
+ * Get the last result set, with the option of not wrapping it in a
+ * {@link DelegatingResultSet}, which is the default.
*/
protected ResultSet getResultSet(boolean wrap) throws SQLException {
ResultSet rs;
-
- if (_del != null) {
+ if (_del != null)
rs = _del.getResultSet(false);
- } else {
+ else
rs = _stmnt.getResultSet();
- }
return wrapResult(wrap, rs);
}
@@ -258,22 +235,20 @@
}
/**
- * Execute the query, with the option of not wrapping it in a
- * {@link DelegatingResultSet}, which is the default.
+ * Execute the query, with the option of not wrapping it in a
+ * {@link DelegatingResultSet}, which is the default.
*/
protected ResultSet executeQuery(boolean wrap) throws SQLException {
ResultSet rs;
-
- if (_del != null) {
+ if (_del != null)
rs = _del.executeQuery(false);
- } else {
+ else
rs = _stmnt.executeQuery();
- }
return wrapResult(wrap, rs);
}
- public int executeUpdate() throws SQLException {
+ public int executeUpdate () throws SQLException {
return _stmnt.executeUpdate();
}
@@ -352,8 +327,7 @@
_stmnt.clearParameters();
}
- public void setObject(int i1, Object o, int i2, int i3)
- throws SQLException {
+ public void setObject(int i1, Object o, int i2, int i3) throws SQLException {
_stmnt.setObject(i1, o, i2, i3);
}
@@ -373,8 +347,7 @@
_stmnt.addBatch();
}
- public void setCharacterStream(int i1, Reader r, int i2)
- throws SQLException {
+ public void setCharacterStream(int i1, Reader r, int i2) throws SQLException {
_stmnt.setCharacterStream(i1, r, i2);
}
@@ -406,8 +379,7 @@
_stmnt.setTime(i, t, c);
}
- public void setTimestamp(int i, Timestamp t, Calendar c)
- throws SQLException {
+ public void setTimestamp(int i, Timestamp t, Calendar c) throws SQLException {
_stmnt.setTimestamp(i, t, c);
}
@@ -415,8 +387,9 @@
_stmnt.setNull(i1, i2, s);
}
- // JDBC 3.0 (unsupported) methods follow; these are required to be able
+ // JDBC 3.0 (unsupported) methods follow; these are required to be able
// to compile against JDK 1.4
+
public boolean getMoreResults(int i) throws SQLException {
throw new UnsupportedOperationException();
}
@@ -464,12 +437,12 @@
/////////////////////////////
// CallableStatement methods
/////////////////////////////
+
public void registerOutParameter(int i1, int i2) throws SQLException {
_stmnt.registerOutParameter(i1, i2);
}
- public void registerOutParameter(int i1, int i2, int i3)
- throws SQLException {
+ public void registerOutParameter(int i1, int i2, int i3) throws SQLException {
_stmnt.registerOutParameter(i1, i2, i3);
}
@@ -574,8 +547,9 @@
_stmnt.registerOutParameter(i1, i2, s);
}
- // JDBC 3.0 (unsupported) methods follow; these are required to be able
+ // JDBC 3.0 (unsupported) methods follow; these are required to be able
// to compile against JDK 1.4
+
public void registerOutParameter(String s, int i) throws SQLException {
throw new UnsupportedOperationException();
}
@@ -668,8 +642,7 @@
throw new UnsupportedOperationException();
}
- public void setObject(String a, Object b, int c, int d)
- throws SQLException {
+ public void setObject(String a, Object b, int c, int d) throws SQLException {
throw new UnsupportedOperationException();
}
@@ -787,8 +760,7 @@
throw new UnsupportedOperationException();
}
- public Timestamp getTimestamp(String a, Calendar b)
- throws SQLException {
+ public Timestamp getTimestamp(String a, Calendar b) throws SQLException {
throw new UnsupportedOperationException();
}
}