public void retarget(FacesContext ctx, CompCompInterfaceMethodMetadata metadata, Object sourceValue, UIComponent target) {
ValueExpression ve = (ValueExpression) sourceValue;
ExpressionFactory f = ctx.getApplication()
.getExpressionFactory();
// There is no explicit methodExpression property on
// an inner component to which this MethodExpression
// should be retargeted. In this case, replace the
// ValueExpression with a method expresson.
// Pull apart the methodSignature to derive the
// expectedReturnType and expectedParameters
String methodSignature = metadata.getMethodSignature(ctx);
assert (null != methodSignature);
methodSignature = methodSignature.trim();
Class<?> expectedReturnType;
Class<?>[] expectedParameters = NO_ARGS;
// Get expectedReturnType
int j, i = methodSignature.indexOf(" ");
if (-1 != i) {
String strValue = methodSignature.substring(0, i);
try {
expectedReturnType = Util.getTypeFromString(strValue.trim());
} catch (ClassNotFoundException cnfe) {
throw new FacesException(methodSignature
+ " : Unable to load type '"
+ strValue
+ '\'');
}
} else {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.severe(
"Unable to determine expected return type for " +
methodSignature);
}
return;
}
// derive the arguments
i = methodSignature.indexOf("(");
if (-1 != i) {
j = methodSignature.indexOf(")", i + 1);
if (-1 != j) {
String strValue = methodSignature.substring(i + 1, j);
if (0 < strValue.length()) {
String[] params = strValue.split(",");
expectedParameters = new Class[params.length];
boolean exceptionThrown = false;
for (i = 0; i < params.length; i++) {
try {
expectedParameters[i] =
Util.getTypeFromString(params[i].trim());
} catch (ClassNotFoundException cnfe) {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.log(Level.SEVERE,
"Unable to determine parameter type for "
+ methodSignature,
cnfe);
}
exceptionThrown = true;
break;
}
}
if (exceptionThrown) {
return;
}
} else {
expectedParameters = NO_ARGS;
}
}
}
assert (null != expectedReturnType);
assert (null != expectedParameters);
MethodExpression me = f
.createMethodExpression(ctx.getELContext(),
ve.getExpressionString(),
expectedReturnType,
expectedParameters);
target.getAttributes().put(metadata.getName(),