Author: vyemialyanchyk
Date: 2010-04-08 10:18:02 -0400 (Thu, 08 Apr 2010)
New Revision: 21346
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/base/HObject.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLCodeAssistStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCompletionRequestorStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCToHibernateTypeHelperStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ProgressListenerStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6070 - create/invoke by string name - for all
classes 2
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2010-04-08
14:09:46 UTC (rev 21345)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2010-04-08
14:18:02 UTC (rev 21346)
@@ -458,7 +458,15 @@
//HibernateConsolePlugin.getDefault().logErrorMessage(mess, e);
}
}
- return configStub.getHQLCodeAssist();
+ HQLCodeAssistStub res = (HQLCodeAssistStub)execute(new ExecutionContext.Command() {
+ public Object execute() {
+ if (configStub != null) {
+ return configStub.getHQLCodeAssist();
+ }
+ return null;
+ }
+ } );
+ return res;
}
public void buildMappings() {
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/base/HObject.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/base/HObject.java 2010-04-08
14:09:46 UTC (rev 21345)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/base/HObject.java 2010-04-08
14:18:02 UTC (rev 21346)
@@ -111,13 +111,30 @@
return invokeStaticMethod(className, methodName, new HObject[] { ho(param0) });
}
- public static Object invokeStaticMethod(final String className, final String methodName,
Object param0, Object param1) {
+ public static Object invokeStaticMethod(final String className, final String methodName,
Object param0,
+ Object param1) {
return invokeStaticMethod(className, methodName, new HObject[] { ho(param0), ho(param1)
});
}
- public static Object invokeStaticMethod(final String className, final String methodName,
Object param0, Object param1, Object param2) {
+ public static Object invokeStaticMethod(final String className, final String methodName,
Object param0,
+ Object param1, Object param2) {
return invokeStaticMethod(className, methodName, new HObject[] { ho(param0),
ho(param1), ho(param2) });
}
+
+ public static Object invokeStaticMethod(final String className, final String methodName,
Object param0,
+ Object param1, Object param2, Object param3) {
+ return invokeStaticMethod(className, methodName, new HObject[] { ho(param0),
ho(param1), ho(param2), ho(param3) });
+ }
+
+ public static Object invokeStaticMethod(final String className, final String methodName,
Object param0,
+ Object param1, Object param2, Object param3, Object param4) {
+ return invokeStaticMethod(className, methodName, new HObject[] { ho(param0),
ho(param1), ho(param2), ho(param3), ho(param4) });
+ }
+
+ public static Object invokeStaticMethod(final String className, final String methodName,
Object param0,
+ Object param1, Object param2, Object param3, Object param4, Object param5) {
+ return invokeStaticMethod(className, methodName, new HObject[] { ho(param0),
ho(param1), ho(param2), ho(param3), ho(param4), ho(param5) });
+ }
public static Object invokeStaticMethod(final String className, final String
methodName, HObject[] params ) {
Class<?>[] signature = new Class<?>[params.length];
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLCodeAssistStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLCodeAssistStub.java 2010-04-08
14:09:46 UTC (rev 21345)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLCodeAssistStub.java 2010-04-08
14:18:02 UTC (rev 21346)
@@ -18,6 +18,6 @@
}
public void codeComplete(String query, int position, IHQLCompletionRequestorStub
requestor) {
- invoke(mn(), query, position, requestor);
+ invoke(mn(), query, position, requestor.hqlCompletionRequestor);
}
}
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCompletionRequestorStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCompletionRequestorStub.java 2010-04-08
14:09:46 UTC (rev 21345)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCompletionRequestorStub.java 2010-04-08
14:18:02 UTC (rev 21346)
@@ -1,30 +1,38 @@
package org.hibernate.mediator.stubs;
-import org.hibernate.tool.ide.completion.IHQLCompletionRequestor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import org.hibernate.mediator.stubs.util.ReflectHelper;
+
public abstract class IHQLCompletionRequestorStub {
- public static final String CL =
"org.hibernate.tool.ide.completion.HQLCompletionProposal"; //$NON-NLS-1$
+ public static final String CL =
"org.hibernate.tool.ide.completion.IHQLCompletionRequestor"; //$NON-NLS-1$
- protected IHQLCompletionRequestor hqlCompletionRequestor;
-
+ protected Object hqlCompletionRequestor;
+
public IHQLCompletionRequestorStub() {
- }
- /** /
- protected IHQLCompletionRequestorStub() {
- hqlCompletionRequestor = new IHQLCompletionRequestor() {
-
- public boolean accept(HQLCompletionProposal proposal) {
- return IHQLCompletionRequestorStub.this.accept(new
HQLCompletionProposalStub(proposal));
+ Class<?> clazz;
+ try {
+ clazz = ReflectHelper.classForName(CL);
+ } catch (ClassNotFoundException e) {
+ throw new HibernateConsoleRuntimeException(e);
+ }
+ InvocationHandler handler = new InvocationHandler() {
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if ("accept".equals(method.getName())) { //$NON-NLS-1$
+ return IHQLCompletionRequestorStub.this.accept(new
HQLCompletionProposalStub(args[0]));
+ } else if ("completionFailure".equals(method.getName())) { //$NON-NLS-1$
+ IHQLCompletionRequestorStub.this.completionFailure(args[0].toString());
+ }
+ return null;
}
-
- public void completionFailure(String errorMessage) {
- IHQLCompletionRequestorStub.this.completionFailure(errorMessage);
- }
-
};
+ hqlCompletionRequestor = Proxy.newProxyInstance(clazz.getClassLoader(),
+ new Class[] { clazz }, handler);
}
- /**/
-
+
public abstract boolean accept(HQLCompletionProposalStub proposal);
+
public abstract void completionFailure(String errorMessage);
}
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCToHibernateTypeHelperStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCToHibernateTypeHelperStub.java 2010-04-08
14:09:46 UTC (rev 21345)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCToHibernateTypeHelperStub.java 2010-04-08
14:18:02 UTC (rev 21346)
@@ -1,27 +1,26 @@
package org.hibernate.mediator.stubs;
-import org.hibernate.cfg.reveng.JDBCToHibernateTypeHelper;
+import org.hibernate.mediator.base.HObject;
-// TODO: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
public class JDBCToHibernateTypeHelperStub {
public static final String CL =
"org.hibernate.cfg.reveng.JDBCToHibernateTypeHelper"; //$NON-NLS-1$
public static String getJDBCTypeName(int intValue) {
- return JDBCToHibernateTypeHelper.getJDBCTypeName(intValue);
+ return (String)HObject.invokeStaticMethod(CL, "getJDBCTypeName",
(Integer)intValue); //$NON-NLS-1$
}
public static String getPreferredHibernateType(int intValue, int length, int precision,
int scale, boolean nullability, boolean b) {
- return JDBCToHibernateTypeHelper.getPreferredHibernateType(intValue,
- length, precision, scale, nullability, b);
+ return (String)HObject.invokeStaticMethod(CL, "getPreferredHibernateType",
(Integer)intValue, //$NON-NLS-1$
+ (Integer)length, (Integer)precision, (Integer)scale, (Boolean)nullability,
(Boolean)b);
}
public static boolean typeHasLength(int intValue) {
- return JDBCToHibernateTypeHelper.typeHasLength(intValue);
+ return (Boolean)HObject.invokeStaticMethod(CL, "typeHasLength",
(Integer)intValue); //$NON-NLS-1$
}
public static boolean typeHasScaleAndPrecision(int intValue) {
- return JDBCToHibernateTypeHelper.typeHasScaleAndPrecision(intValue);
+ return (Boolean)HObject.invokeStaticMethod(CL, "typeHasScaleAndPrecision",
(Integer)intValue); //$NON-NLS-1$
}
}
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ProgressListenerStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ProgressListenerStub.java 2010-04-08
14:09:46 UTC (rev 21345)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ProgressListenerStub.java 2010-04-08
14:18:02 UTC (rev 21346)
@@ -1,20 +1,33 @@
package org.hibernate.mediator.stubs;
-import org.hibernate.cfg.reveng.ProgressListener;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
-//TODO: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+import org.hibernate.mediator.stubs.util.ReflectHelper;
+
public abstract class ProgressListenerStub {
public static final String CL = "org.hibernate.cfg.reveng.ProgressListener";
//$NON-NLS-1$
- protected ProgressListener progressListener = new ProgressListener() {
-
- public void startSubTask(String name) {
- ProgressListenerStub.this.startSubTask(name);
- }
-
- };
+ protected Object progressListener;
protected ProgressListenerStub() {
+ Class<?> clazz;
+ try {
+ clazz = ReflectHelper.classForName(CL);
+ } catch (ClassNotFoundException e) {
+ throw new HibernateConsoleRuntimeException(e);
+ }
+ InvocationHandler handler = new InvocationHandler() {
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if ("startSubTask".equals(method.getName())) { //$NON-NLS-1$
+ ProgressListenerStub.this.startSubTask(args[0].toString());
+ }
+ return null;
+ }
+ };
+ progressListener = Proxy.newProxyInstance(clazz.getClassLoader(),
+ new Class[] { clazz }, handler);
}
public abstract void startSubTask(String name);
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java 2010-04-08
14:09:46 UTC (rev 21345)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java 2010-04-08
14:18:02 UTC (rev 21346)
@@ -29,6 +29,7 @@
import bsh.EvalError;
import bsh.Interpreter;
+// TODO: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
public class SessionStub extends HObject {
public static final String CL = "org.hibernate.Session"; //$NON-NLS-1$