[jboss-jira] [JBoss JIRA] Updated: (JBAS-1288) Java5 Enum for mbean and configurations
Dimitris Andreadis (JIRA)
jira-events at lists.jboss.org
Tue Feb 5 15:28:04 EST 2008
[ http://jira.jboss.com/jira/browse/JBAS-1288?page=all ]
Dimitris Andreadis updated JBAS-1288:
-------------------------------------
Fix Version/s: Backlog
(was: JBossAS-5.0.0.Beta4)
> Java5 Enum for mbean and configurations
> ---------------------------------------
>
> Key: JBAS-1288
> URL: http://jira.jboss.com/jira/browse/JBAS-1288
> Project: JBoss Application Server
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: JMX
> Affects Versions: JBossAS-4.0.1 Final
> Reporter: Michael Kopp
> Priority: Minor
> Fix For: Backlog
>
>
> Whenever you try to get a PropertyEditor for something but none is there, do the following additional check:
> if (type.getSuperclass().getName().equals("java.lang.Enum"))
> {
> editor = new EnumPropertyEditor(type);
> }
> where the EnumPropertyEditor is:
> public class EnumPropertyEditor extends PropertyEditorSupport implements PropertyEditor
> {
> private final Class targetType;
> public EnumPropertyEditor(Class targetType)
> {
> this.targetType = targetType;
> }
> public void setAsText(String text) throws IllegalArgumentException
> {
> try
> {
> setValue(targetType.getMethod("valueOf",new Class[]{String.class}).invoke(null,new Object[]{text});
> } catch (IllegalAccessException e)
> {
> throw new IllegalStateException(e);
> } catch (InvocationTargetException e)
> {
> if (e.getTargetException() instanceof RuntimeException);
> throw (RuntimeException)e.getTargetException();
> throw new IllegalStateException(e);
> } catch (NoSuchMethodException e)
> {
> String err = type.getName() +
> " does not contain the required method: public static " +
> type.getName() + " valueOf(String);";
> throw new IllegalArgumentException(err,e);
> }
>
> }
> public String getAsText()
> {
>
> try
> {
> return targetType.getMethod("name",null).invoke(getValue(),null)
> } catch (IllegalAccessException e)
> {
> throw new IllegalStateException(e);
> } catch (InvocationTargetException e)
> {
> if (e.getTargetException() instanceof RuntimeException);
> throw (RuntimeException)e.getTargetException();
> throw new IllegalStateException(e);
> } catch (NoSuchMethodException e)
> {
> String err = type.getName() +
> " does not contain the required method: public String name()";
> throw new IllegalStateException(err,e);
> }
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list