Author: rareddy
Date: 2009-07-07 14:28:08 -0400 (Tue, 07 Jul 2009)
New Revision: 1097
Modified:
trunk/adminshell/src/main/resources/commands/mparse.bsh
trunk/adminshell/src/main/resources/scripts/server.bsh
trunk/adminshell/src/main/resources/scripts/util.bsh
Log:
TEIID-698: reducing the noise of exceptions generated during the admin api calls to simple
error message.
Modified: trunk/adminshell/src/main/resources/commands/mparse.bsh
===================================================================
--- trunk/adminshell/src/main/resources/commands/mparse.bsh 2009-07-07 16:47:45 UTC (rev
1096)
+++ trunk/adminshell/src/main/resources/commands/mparse.bsh 2009-07-07 18:28:08 UTC (rev
1097)
@@ -12,7 +12,7 @@
mmstr="execute(\""+orig_str.substring(0,orig_str.length()-1)+"\");";
record = true;
}
- else if (str.matches("(help|exit|dir|pwd)\\(?\\)?")) {
+ else if (str.matches("(help|exit|quit|dir|pwd)\\(?\\)?")) {
idx = str.indexOf("(");
if (idx == -1) {
mmstr = str+"();";
Modified: trunk/adminshell/src/main/resources/scripts/server.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/server.bsh 2009-07-07 16:47:45 UTC (rev
1096)
+++ trunk/adminshell/src/main/resources/scripts/server.bsh 2009-07-07 18:28:08 UTC (rev
1097)
@@ -46,7 +46,7 @@
url = url + ";" + optional_url;
}
com.metamatrix.jdbc.api.Connection mmConn = connectDriver(user_driver, url);
- currentContext().internalAdmin = mmConn.getAdminAPI();
+ currentContext().internalAdmin = createExceptionHandlingProxy(mmConn.getAdminAPI());
currentContext().internalPrompt =
contextName+"["+vdb+"@"+host+"] $ ";
return mmConn;
}
@@ -85,7 +85,7 @@
newContext(contextName);
com.metamatrix.jdbc.api.Connection mmConn = connectDriver(driver, url);
currentContext().internalPrompt =
contextName+"["+extractVDBName(url)+"@"+extractHost(url)+"] $
";
- currentContext().internalAdmin = mmConn.getAdminAPI();
+ currentContext().internalAdmin =
createExceptionHandlingProxy(mmConn.getAdminAPI());
return mmConn;
}
else {
@@ -107,7 +107,7 @@
newContext(contextName);
//url is in "server URL format": connect via ServerAdminFactory
- currentContext().internalAdmin =
ServerAdminFactory.getInstance().createAdmin(username, password.toCharArray(), url);
+ currentContext().internalAdmin =
createExceptionHandlingProxy(ServerAdminFactory.getInstance().createAdmin(username,
password.toCharArray(), url));
currentContext().internalPrompt =
currentConnectionName()+"["+url+"] $ ";
} else {
@@ -116,7 +116,7 @@
//url is in "jdbc URL format": connect via MMServerConnection
currentContext().internalConnection =
connectDriver("org.teiid.jdbc.TeiidDriver", url, username, password);
- currentContext().internalAdmin =
currentContext().internalConnection.getAdminAPI();
+ currentContext().internalAdmin =
createExceptionHandlingProxy(currentContext().internalConnection.getAdminAPI());
}
}
Modified: trunk/adminshell/src/main/resources/scripts/util.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/util.bsh 2009-07-07 16:47:45 UTC (rev
1096)
+++ trunk/adminshell/src/main/resources/scripts/util.bsh 2009-07-07 18:28:08 UTC (rev
1097)
@@ -1,9 +1,11 @@
import java.io.*;
import org.teiid.adminapi.*;
import com.metamatrix.core.util.*;
+import java.lang.reflect.*;
debug=false;
+
getBshPrompt() {
if (currentContext().internalPrompt == void || currentContext().internalPrompt ==
null) {
return "admin $ ";
@@ -165,6 +167,37 @@
return "";
}
+class ExceptionHandler implements InvocationHandler{
+ Object impl;
+ ExceptionHandler(Object obj){
+ impl=obj;
+ }
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ try {
+ return method.invoke(impl, args);
+ } catch (InvocationTargetException e) {
+ Throwable ex = e;
+ while (ex instanceof InvocationTargetException) {
+ ex = e.getTargetException();
+ }
+ if (ex instanceof AdminException) {
+ print("Error:"+ex.getMessage());
+ }
+ } catch(AdminComponentException e) {
+ print(e.getClass().getName() +" Error:"+e.getMessage());
+ } catch (AdminProcessingException e) {
+ print(e.getClass().getName() +" Error:"+e.getMessage());
+ } catch(Throwable t) {
+ print(t.getClass().getName() +" Error:"+e.getMessage());
+ }
+ return null;
+ }
+}
+
+Object createExceptionHandlingProxy(Object obj) {
+ return Proxy.newProxyInstance(obj.getClass().getClassLoader(),
obj.getClass().getInterfaces(), new ExceptionHandler(obj));
+}
+
quit(){
exit();
}
Show replies by date