Skip to content

Commit

Permalink
rename plugins for H2 and Derby so correct prototypes can be found
Browse files Browse the repository at this point in the history
  • Loading branch information
darkv committed Jun 22, 2012
1 parent e53ac3e commit 6a08b83
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

/**
* 5.4 declares the same class name for the DerbyPlugIn. If your classpath isn't
* exactly right, they'll win, so we pushed the real code into ERDerbyPlugIn and
* we set a custom principal class that registers the ER variant that is
* exactly right, they'll win, so we pushed the real code into _DerbyPlugIn and
* we set a custom principal class that registers the _ variant that is
* "guaranteed" to not have collisions as the plugin for the "derby"
* subprotocol.
*
* @author hprange guided by mschrag
*/
public class DerbyPlugIn extends ERDerbyPlugIn {
public class DerbyPlugIn extends _DerbyPlugIn {
public DerbyPlugIn(final JDBCAdaptor adaptor) {
super(adaptor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.webobjects.foundation.NSTimestamp;
import com.webobjects.foundation.NSTimestampFormatter;

public class ERDerbyPlugIn extends JDBCPlugIn {
public class _DerbyPlugIn extends JDBCPlugIn {
static final boolean USE_NAMED_CONSTRAINTS = true;

protected static String quoteTableName(String s) {
Expand Down Expand Up @@ -79,6 +79,7 @@ protected boolean enableBooleanQuoting() {
*
* @param value
* @param eoattribute
* @return string representation of the BigDecimal
* @author ak
*/
private String fixBigDecimal(final BigDecimal value, final EOAttribute eoattribute) {
Expand Down Expand Up @@ -201,6 +202,7 @@ else if (obj == null || obj == NSKeyValueCoding.NullValue) {
* Helper to check for timestamp columns that have a "D" value type.
*
* @param eoattribute
* @return <code>true</code> if date attribute
*/
private boolean isDateAttribute(final EOAttribute eoattribute) {
return "D".equals(eoattribute.valueType());
Expand All @@ -210,6 +212,7 @@ private boolean isDateAttribute(final EOAttribute eoattribute) {
* Helper to check for timestamp columns that have a "T" value type.
*
* @param eoattribute
* @return <code>true</code> if timestamp attribute
*/
private boolean isTimestampAttribute(final EOAttribute eoattribute) {
return "T".equals(eoattribute.valueType());
Expand Down Expand Up @@ -387,7 +390,7 @@ public boolean supportsSchemaSynchronization() {
*/
private static Method _bigDecimalToString = null;

public ERDerbyPlugIn(final JDBCAdaptor adaptor) {
public _DerbyPlugIn(final JDBCAdaptor adaptor) {
super(adaptor);
}

Expand All @@ -412,12 +415,12 @@ public Class defaultExpressionClass() {
}

/**
* <P>
* This is usually extracted from the the database using JDBC, but this is
* really inconvenient for users who are trying to generate SQL at some. A
* specific version of the data has been written into the property list of
* the framework and this can be used as a hard-coded equivalent.
* </P>
*
* @return JDBC info
*/
@Override
public NSDictionary jdbcInfo() {
Expand Down Expand Up @@ -461,16 +464,18 @@ public NSDictionary jdbcInfo() {
return jdbcInfo;
}

@Override
public String name() {
return DRIVER_NAME;
}

/**
* <P>
* This method returns true if the connection URL for the database has
* This method returns <code>true</code> if the connection URL for the database has
* <code>useBundledJdbcInfo=true</code> on it which indicates to the system
* that the jdbcInfo which has been bundled into the plugin is acceptable to
* use in place of actually going to the database and getting it.
*
* @return <code>true</code> if bundled JDBC info should be used
*/
protected boolean shouldUseBundledJdbcInfo() {
boolean shouldUseBundledJdbcInfo = false;
Expand All @@ -480,5 +485,4 @@ protected boolean shouldUseBundledJdbcInfo() {
}
return shouldUseBundledJdbcInfo;
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package er.derby;

import com.webobjects.jdbcadaptor.ERDerbyPlugIn;
import com.webobjects.jdbcadaptor._DerbyPlugIn;
import com.webobjects.jdbcadaptor.JDBCPlugIn;

/**
* 5.4 declares the same class name for the DerbyPlugIn. If your classpath isn't
* exactly right, they'll win, so we pushed the real code into ERDerbyPlugIn and
* we set a custom principal class that registers the ER variant that is
* exactly right, they'll win, so we pushed the real code into _DerbyPlugIn and
* we set a custom principal class that registers the _ variant that is
* "guaranteed" to not have collisions as the plugin for the "derby"
* subprotocol.
*
* @author hprange guided by mschrag
*/
public class ERDerbyPlugInPrincipal {
static {
JDBCPlugIn.setPlugInNameForSubprotocol(ERDerbyPlugIn.class.getName(), "derby");
JDBCPlugIn.setPlugInNameForSubprotocol(_DerbyPlugIn.class.getName(), "derby");
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.webobjects.jdbcadaptor;

import er.h2.jdbcadaptor.ERH2PlugIn;

/**
* This is a default plugIn for the H2 database protocol.
*
* 5.4 declares the same class name for the H2PlugIn. If your classpath isn't
* exactly right, they'll win, so we pushed the real code into _H2PlugIn and
* we set a custom principal class that registers the _ variant that is
* "guaranteed" to not have collisions as the plugin for the "h2"
* subprotocol.
*
* @author ldeck
*/
public class H2PlugIn extends ERH2PlugIn {

public class H2PlugIn extends _H2PlugIn {
public H2PlugIn(final JDBCAdaptor adaptor) {
super(adaptor);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package er.h2.jdbcadaptor;
package com.webobjects.jdbcadaptor;

import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -31,8 +31,7 @@
import com.webobjects.jdbcadaptor.JDBCExpression;
import com.webobjects.jdbcadaptor.JDBCPlugIn;

public class ERH2PlugIn extends JDBCPlugIn {

public class _H2PlugIn extends JDBCPlugIn {
static final boolean USE_NAMED_CONSTRAINTS = true;

protected static String quoteTableName(String name) {
Expand Down Expand Up @@ -485,7 +484,7 @@ private static Format timestampFormatter() {
*/
private volatile boolean testedJdbcInfo;

public ERH2PlugIn(final JDBCAdaptor adaptor) {
public _H2PlugIn(final JDBCAdaptor adaptor) {
super(adaptor);
}

Expand Down Expand Up @@ -593,5 +592,4 @@ protected boolean shouldUseBundledJdbcInfo() {
}
return shouldUseBundledJdbcInfo;
}

}
14 changes: 10 additions & 4 deletions Frameworks/PlugIns/H2PlugIn/Sources/er/h2/ERH2PlugInPrincipal.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package er.h2;

import er.h2.jdbcadaptor.ERH2PlugIn;
import com.webobjects.jdbcadaptor._H2PlugIn;
import com.webobjects.jdbcadaptor.JDBCPlugIn;

/**
* This principal class registers the ERH2PlugIn class as the PlugIn
* for the "h2" database for the "h2" subprotocol.
* This principal class registers the _H2PlugIn class as the PlugIn
* for the H2 database for the "h2" subprotocol.
*
* 5.4 declares the same class name for the H2PlugIn. If your classpath isn't
* exactly right, they'll win, so we pushed the real code into _H2PlugIn and
* we set a custom principal class that registers the _ variant that is
* "guaranteed" to not have collisions as the plugin for the "h2"
* subprotocol.
*
* @author ldeck
*/
public class ERH2PlugInPrincipal {
static {
JDBCPlugIn.setPlugInNameForSubprotocol(ERH2PlugIn.class.getName(), "h2");
JDBCPlugIn.setPlugInNameForSubprotocol(_H2PlugIn.class.getName(), "h2");
}
}

0 comments on commit 6a08b83

Please sign in to comment.