📄 defaultcomponenttype.java
字号:
package xyz.frame.component;import java.util.ArrayList;import java.util.Collection;import java.util.List;import java.util.Map;import org.apache.log4j.Logger;import xyz.frame.annotations.In;import xyz.frame.annotations.Out;import xyz.frame.annotations.Read;import xyz.frame.interceptor.InterceptorClass;import xyz.frame.introspector.FieldReadParameter;import xyz.frame.util.ReflectionUtil;/** * Metadata information about a component class. This class is used to dealing * with component classes. * * @author Guilherme Silveira */public class DefaultComponentType implements ComponentType { private static final Logger logger = Logger.getLogger(DefaultComponentType.class); private Map<String, DefaultLogicMethod> actions; private List<FieldAnnotation<In>> inAnnotations; private List<FieldAnnotation<Out>> outAnnotations; private List<FieldReadParameter> readParameters = new ArrayList<FieldReadParameter>(); private List<InterceptorClass> interceptors; private Class<?> clazz; private String name; <T> DefaultComponentType(Class<T> clazz, String name, Map<String, DefaultLogicMethod> actions, List<FieldAnnotation<In>> inAnnotations, List<FieldAnnotation<Out>> outAnnotations, List<FieldAnnotation<Read>> readAnnotations, List<InterceptorClass> interceptors) { this.name = name; this.actions = actions; this.inAnnotations = inAnnotations; this.outAnnotations = outAnnotations; this.interceptors = interceptors; this.clazz = clazz; for (FieldAnnotation<Read> info : readAnnotations) { this.readParameters.add(new FieldReadParameter(info)); } } public Object newInstance() throws ComponentInstantiationException { logger.debug("Instantiating class " + this.clazz.getName()); return ReflectionUtil.instantiate(this.clazz); } public String getName() { return this.name; } public LogicMethod getLogic(String key) throws LogicNotFoundException { if (!this.actions.containsKey(key)) { throw new LogicNotFoundException("Unable to find action " + key); } return this.actions.get(key); } /* (non-Javadoc) * @see xyz.frame.component.ComponentType#getInterceptors() */ public List<InterceptorClass> getInterceptors() { return this.interceptors; } /* (non-Javadoc) * @see xyz.frame.component.ComponentType#getInAnnotations() */ public List<FieldAnnotation<In>> getInAnnotations() { return this.inAnnotations; } /* (non-Javadoc) * @see xyz.frame.component.ComponentType#getOutAnnotations() */ public List<FieldAnnotation<Out>> getOutAnnotations() { return this.outAnnotations; } /* (non-Javadoc) * @see xyz.frame.component.ComponentType#getReadParameters() */ public List<FieldReadParameter> getReadParameters() { return this.readParameters; } public Collection<LogicMethod> getLogics() { return new ArrayList<LogicMethod>(this.actions.values()); } public Class getComponentClass() { return this.clazz; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -