MethodExecutorpublic class MethodExecutor extends Object implements SerializableExecute the methods based on the parameters. |
Fields Summary |
---|
private static Logger | _logger | private boolean | debug | private static com.sun.enterprise.util.i18n.StringManager | sm |
Methods Summary |
---|
private java.lang.Object | convertType(java.lang.Class type, java.lang.String parameter)Converts the type from String to the Class type.
try {
String typeName = type.getName();
if (typeName.equals("java.lang.String") || typeName.equals("java.lang.Object")) {
return parameter;
}
if (typeName.equals("int") || typeName.equals("java.lang.Integer")) {
return new Integer(parameter);
}
if (typeName.equals("short") || typeName.equals("java.lang.Short")) {
return new Short(parameter);
}
if (typeName.equals("byte") || typeName.equals("java.lang.Byte")) {
return new Byte(parameter);
}
if (typeName.equals("long") || typeName.equals("java.lang.Long")) {
return new Long(parameter);
}
if (typeName.equals("float") || typeName.equals("java.lang.Float")) {
return new Float(parameter);
}
if (typeName.equals("double") || typeName.equals("java.lang.Double")) {
return new Double(parameter);
}
if (typeName.equals("java.math.BigDecimal")) {
return new java.math.BigDecimal(parameter);
}
if (typeName.equals("java.math.BigInteger")) {
return new java.math.BigInteger(parameter);
}
if (typeName.equals("boolean") || typeName.equals("java.lang.Boolean")) {
return Boolean.valueOf(parameter);
}
return parameter;
} catch (NumberFormatException nfe) {
_logger.log(Level.SEVERE, "jdbc.exc_nfe", parameter);
String msg = sm.getString("me.invalid_param", parameter);
throw new ResourceException(msg);
}
| public void | runJavaBeanMethod(java.lang.String value, java.lang.reflect.Method method, java.lang.Object obj)Exceute a simple set Method.
if (value == null || value.trim().equals("")) {
return;
}
try {
Class[] parameters = method.getParameterTypes();
if (parameters.length == 1) {
Object[] values = new Object[1];
values[0] = convertType(parameters[0], value);
method.invoke(obj, values);
}
} catch (IllegalAccessException iae) {
_logger.log(Level.SEVERE, "jdbc.exc_jb_val", iae);
String msg = sm.getString("me.access_denied", method.getName());
throw new ResourceException(msg);
} catch (IllegalArgumentException ie) {
_logger.log(Level.SEVERE, "jdbc.exc_jb_val", ie);
String msg = sm.getString("me.illegal_args", method.getName());
throw new ResourceException(msg);
} catch (InvocationTargetException ite) {
_logger.log(Level.SEVERE, "jdbc.exc_jb_val", ite);
String msg = sm.getString("me.access_denied", method.getName());
throw new ResourceException(msg);
}
| public void | runMethod(java.lang.reflect.Method method, java.lang.Object obj, java.util.Vector values)Executes the method.
try {
Class[] parameters = method.getParameterTypes();
if (values.size() != parameters.length) {
return;
}
Object[] actualValues = new Object[parameters.length];
for (int i = 0; i < parameters.length; i++) {
String val = (String) values.get(i);
if (val.trim().equals("NULL")) {
actualValues[i] = null;
} else {
actualValues[i] = convertType(parameters[i], val);
}
}
method.invoke(obj, actualValues);
} catch (IllegalAccessException iae) {
_logger.log(Level.SEVERE, "jdbc.exc_jb_val", iae);
String msg = sm.getString("me.access_denied", method.getName());
throw new ResourceException(msg);
} catch (IllegalArgumentException ie) {
_logger.log(Level.SEVERE, "jdbc.exc_jb_val", ie);
String msg = sm.getString("me.illegal_args", method.getName());
throw new ResourceException(msg);
} catch (InvocationTargetException ite) {
_logger.log(Level.SEVERE, "jdbc.exc_jb_val", ite);
String msg = sm.getString("me.access_denied", method.getName());
throw new ResourceException(msg);
}
|
|