Method from org.apache.geronimo.console.BasePortlet Detail: |
public final void addErrorMessage(PortletRequest request,
String messages) {
addCommonMessage(CommonMessage.Type.Error, request, messages);
}
|
public final void addInfoMessage(PortletRequest request,
String messages) {
addCommonMessage(CommonMessage.Type.Info, request, messages);
}
|
public final void addWarningMessage(PortletRequest request,
String messages) {
addCommonMessage(CommonMessage.Type.Warn, request, messages);
}
|
public static final Object callOperation(Object target,
String operation,
Object[] args) {
Class cls = target.getClass();
Method[] list = cls.getMethods();
for (int i = 0; i < list.length; i++) {
Method method = list[i];
if(method.getName().equals(operation) && ((args == null && method.getParameterTypes().length == 0) || (args != null && args.length == method.getParameterTypes().length))
&& Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers())) {
try {
return method.invoke(target, args);
} catch (Exception e) {
log.error("Unable to invoke "+operation+" on "+target.getClass().getName());
}
break;
}
}
throw new IllegalArgumentException("No such method found ("+operation+" on "+target.getClass().getName()+")");
}
|
public final String getLocalizedString(PortletRequest request,
String key,
Object vars) {
String value = resourceRegistry.handleGetObject(BASENAME, request.getLocale(), key);
if (null == value || 0 == value.length()) return key;
return MessageFormat.format(value, vars);
}
|
public static final Object getProperty(Object target,
String name) {
Class cls = target.getClass();
String getter = "get"+Character.toUpperCase(name.charAt(0))+name.substring(1);
String booleanGetter = "is"+Character.toUpperCase(name.charAt(0))+name.substring(1);
Method[] list = cls.getMethods();
for (int i = 0; i < list.length; i++) {
Method method = list[i];
String methodName = method.getName();
if( (methodName.equals(getter) || methodName.equals(booleanGetter))
&& method.getParameterTypes().length == 0 && Modifier.isPublic(method.getModifiers()) &&
!Modifier.isStatic(method.getModifiers())) {
try {
return method.invoke(target, new Object[0]);
} catch (Exception e) {
log.error("Unable to get property "+name+" on "+target.getClass().getName());
}
break;
}
}
throw new IllegalArgumentException("No such method found ("+getter+" on "+target.getClass().getName()+")");
}
|
protected static final String getWebServerType(Class cls) {
Class[] intfs = cls.getInterfaces();
for (int i = 0; i < intfs.length; i++) {
Class intf = intfs[i];
if(intf.getName().indexOf("Jetty") > -1) {
return WEB_SERVER_JETTY;
} else if(intf.getName().indexOf("Tomcat") > -1) {
return WEB_SERVER_TOMCAT;
}
}
return WEB_SERVER_GENERIC;
}
|
public void render(RenderRequest request,
RenderResponse response) throws PortletException, IOException {
@SuppressWarnings("unchecked")
SoftReference< List< CommonMessage > > msgRef = (SoftReference< List< CommonMessage > >) request.getPortletSession().getAttribute(COMMON_MESSAGES);
if (null != msgRef && null != msgRef.get()) {
request.setAttribute(COMMON_MESSAGES, msgRef.get());
}
request.getPortletSession().removeAttribute(COMMON_MESSAGES);
request.setAttribute(FMT_LOCALE, request.getLocale());
super.render(request, response);
}
|
public static final void setProperty(Object target,
String name,
Object value) {
boolean found = false;
Class cls = target.getClass();
String setter = "set"+Character.toUpperCase(name.charAt(0))+name.substring(1);
Method[] list = cls.getMethods();
for (int i = 0; i < list.length; i++) {
Method method = list[i];
if(method.getName().equals(setter) && method.getParameterTypes().length == 1 && Modifier.isPublic(method.getModifiers()) &&
!Modifier.isStatic(method.getModifiers())) {
found = true;
try {
method.invoke(target, new Object[]{value});
} catch (Exception e) {
log.error("Unable to set property "+name+" on "+target.getClass().getName());
}
break;
}
}
if(!found) {
throw new IllegalArgumentException("No such method found ("+setter+" on "+target.getClass().getName()+")");
}
}
|