Skip to content

Commit

Permalink
more porting
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Apr 20, 2011
1 parent 3f0a1b1 commit 938dae5
Show file tree
Hide file tree
Showing 18 changed files with 1,309 additions and 421 deletions.
@@ -1,20 +1,55 @@
package org.jumpmind.symmetric.core.common;

import java.lang.reflect.Method;
import java.util.Arrays;

public class ClassUtils {

public static ClassLoader getDefaultClassLoader() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
}
catch (Throwable ex) {
// Cannot access thread context ClassLoader - falling back to system class loader...
} catch (Throwable ex) {
// Cannot access thread context ClassLoader - falling back to system
// class loader...
}
if (cl == null) {
// No thread context class loader -> use class loader of this class.
cl = ClassUtils.class.getClassLoader();
}
return cl;
}

/**
* Attempt to find a {@link Method} on the supplied class with the supplied
* name and parameter types. Searches all superclasses up to
* <code>Object</code>.
* <p>
* Returns <code>null</code> if no {@link Method} can be found.
*
* @param clazz
* the class to introspect
* @param name
* the name of the method
* @param paramTypes
* the parameter types of the method (may be <code>null</code> to
* indicate any signature)
* @return the Method object, or <code>null</code> if none found
*/
public static Method findMethod(Class<?> clazz, String name, Class<?>... paramTypes) {
Class<?> searchType = clazz;
while (searchType != null) {
Method[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType
.getDeclaredMethods());
for (Method method : methods) {
if (name.equals(method.getName())
&& (paramTypes == null || Arrays.equals(paramTypes,
method.getParameterTypes()))) {
return method;
}
}
searchType = searchType.getSuperclass();
}
return null;
}
}
Expand Up @@ -10,8 +10,8 @@ public class LogFactory {
private static Map<Class<?>, Log> logs = new HashMap<Class<?>, Log>();

static {
String clazzName = System.getProperty("org.jumpmind.symmmetric.data.common.ILog",
"org.jumpmind.symmmetric.data.common.DefaultLog");
String clazzName = System.getProperty(Log.class.getName(),
DefaultLog.class.getName());
try {
logClass = Class.forName(clazzName);
Object log = logClass.newInstance();
Expand Down
Expand Up @@ -40,6 +40,12 @@ abstract public class AbstractPlatform implements IPlatform {
protected String defaultSchema;

protected String defaultCatalog;

protected SqlBuilder sqlBuilder;

public SqlBuilder getSqlBuilder() {
return sqlBuilder;
}

public Object[] getObjectValues(BinaryEncoding encoding, String[] values,
Column[] orderedMetaData) {
Expand Down
Expand Up @@ -4,13 +4,18 @@

import org.jumpmind.symmetric.core.common.BinaryEncoding;
import org.jumpmind.symmetric.core.model.Column;
import org.jumpmind.symmetric.core.model.Database;
import org.jumpmind.symmetric.core.model.Parameters;
import org.jumpmind.symmetric.core.model.Table;

public interface IPlatform {

public PlatformInfo getPlatformInfo();

public String getAlterScriptFor(Table... tables);

public Database findDatabase(String catalogName, String schemaName);

public Table findTable(String tableName, Parameters parameters);

public Table findTable(String catalogName, String schemaName, String tableName, boolean useCached, Parameters parameters);
Expand All @@ -23,6 +28,8 @@ public Object[] getObjectValues(BinaryEncoding encoding, String[] values,
public String getDefaultCatalog();

public String getDefaultSchema();

public SqlBuilder getSqlBuilder();

/**
* Returns the constraint name. This method takes care of length limitations
Expand Down
Expand Up @@ -37,6 +37,8 @@ public class PlatformInfo {
/** The Log to which logging calls will be made. */
private final Log log = LogFactory.getLog(PlatformInfo.class);

private boolean scriptModeOn = false;

private boolean sqlCommentsOn = false;

private boolean dateOverridesToTimestamp = false;
Expand Down Expand Up @@ -1215,5 +1217,12 @@ public boolean isSqlCommentsOn() {
public void setSqlCommentsOn(boolean sqlCommentsOn) {
this.sqlCommentsOn = sqlCommentsOn;
}

public void setScriptModeOn(boolean scriptModeOn) {
this.scriptModeOn = scriptModeOn;
}

public boolean isScriptModeOn() {
return scriptModeOn;
}
}

0 comments on commit 938dae5

Please sign in to comment.