1 52 53 package com.go.teaservlet; 54 55 import java.lang.reflect.Method ; 56 import java.beans.*; 57 import java.util.*; 58 import com.go.teaservlet.util.NameValuePair; 59 import com.go.trove.util.BeanComparator; 60 61 67 public class ApplicationInfo extends NameValuePair { 68 private String mPrefix; 69 70 public ApplicationInfo(String name, Application app, String prefix) { 71 super(name, app); 72 mPrefix = prefix; 73 } 74 75 public Class getContextType() { 76 return ((Application)getValue()).getContextType(); 77 } 78 79 public String getContextPrefixName() { 80 return mPrefix; 81 } 82 83 public MethodDescriptor[] getContextFunctions() { 84 Class contextType = getContextType(); 85 if (contextType == null) { 86 return new MethodDescriptor[0]; 87 } 88 89 try { 90 MethodDescriptor[] methods = 91 Introspector.getBeanInfo(contextType).getMethodDescriptors(); 92 93 List list = new ArrayList(methods.length); 94 for (int i=methods.length; --i >= 0; ) { 95 MethodDescriptor m = methods[i]; 96 if (m.getMethod().getDeclaringClass() != Object .class) { 97 list.add(m); 98 } 99 } 100 101 MethodDescriptor[] functions = 102 (MethodDescriptor[])list.toArray(new MethodDescriptor[list.size()]); 103 Comparator c = BeanComparator.forClass(MethodDescriptor.class).orderBy("method.name"); 104 Arrays.sort(functions, c); 105 return functions; 106 } 107 catch (Exception e) { 108 Thread t = Thread.currentThread(); 109 t.getThreadGroup().uncaughtException(t, e); 110 return new MethodDescriptor[0]; 111 } 112 } 113 114 public NameValuePair[] getInitParameters() { 115 return null; 117 } 118 } 119 | Popular Tags |