1 22 package org.jboss.beans.info.plugins; 23 24 import java.util.Iterator ; 25 import java.util.List ; 26 import java.util.Set ; 27 28 import org.jboss.beans.info.spi.BeanInfo; 29 import org.jboss.beans.info.spi.BeanInfoFactory; 30 import org.jboss.beans.info.spi.EventInfo; 31 import org.jboss.beans.info.spi.PropertyInfo; 32 import org.jboss.classadapter.spi.ClassAdapter; 33 import org.jboss.joinpoint.spi.JoinpointFactory; 34 import org.jboss.reflect.spi.ClassInfo; 35 import org.jboss.reflect.spi.ConstructorInfo; 36 import org.jboss.reflect.spi.MethodInfo; 37 import org.jboss.repository.spi.MetaDataContext; 38 import org.jboss.repository.spi.MetaDataContextFactory; 39 import org.jboss.util.JBossObject; 40 import org.jboss.util.JBossStringBuilder; 41 42 48 public class AbstractBeanInfo extends JBossObject implements BeanInfo 49 { 50 51 protected String name; 52 53 54 protected ClassAdapter classAdapter; 55 56 57 protected Set <PropertyInfo> properties; 58 59 60 protected Set <ConstructorInfo> constructors; 61 62 63 protected Set <MethodInfo> methods; 64 65 66 protected Set <EventInfo> events; 67 68 69 protected BeanInfoFactory beanInfoFactory; 70 71 72 82 public AbstractBeanInfo(BeanInfoFactory beanInfoFactory, ClassAdapter classAdapter, Set <PropertyInfo> properties, Set <ConstructorInfo> constructors, 83 Set <MethodInfo> methods, Set <EventInfo> events) 84 { 85 this.beanInfoFactory = beanInfoFactory; 86 this.name = classAdapter.getClassInfo().getName(); 87 this.classAdapter = classAdapter; 88 this.properties = properties; 89 if (properties != null && properties.isEmpty() == false) 90 { 91 for (Iterator i = properties.iterator(); i.hasNext();) 92 { 93 AbstractPropertyInfo ainfo = (AbstractPropertyInfo) i.next(); 94 ainfo.beanInfo = this; 95 } 96 } 97 this.constructors = constructors; 98 this.methods = methods; 99 this.events = events; 100 } 101 102 protected AbstractBeanInfo(AbstractBeanInfo template) 103 { 104 this.name = template.name; 105 this.classAdapter = template.classAdapter.getInstanceAdapter(template.classAdapter.getClassInfo()); 106 this.properties = template.properties; 107 this.constructors = template.constructors; 108 this.methods = template.methods; 109 this.events = template.events; 110 this.beanInfoFactory = template.beanInfoFactory; 111 } 112 113 public String getName() 114 { 115 return name; 116 } 117 118 public Set <PropertyInfo> getProperties() 119 { 120 return properties; 121 } 122 123 public void setProperties(Set <PropertyInfo> properties) 124 { 125 this.properties = properties; 126 } 127 128 public ClassInfo getClassInfo() 129 { 130 return classAdapter.getClassInfo(); 131 } 132 133 public List <Object > getDependencies() 134 { 135 return classAdapter.getDependencies(); 136 } 137 138 public JoinpointFactory getJoinpointFactory() 139 { 140 return classAdapter.getJoinpointFactory(); 141 } 142 143 public MetaDataContextFactory getMetaDataContextFactory() 144 { 145 return classAdapter.getMetaDataContextFactory(); 146 } 147 148 public Set <ConstructorInfo> getConstructors() 149 { 150 return constructors; 151 } 152 153 public void setConstructors(Set <ConstructorInfo> constructors) 154 { 155 this.constructors = constructors; 156 } 157 158 public Set <EventInfo> getEvents() 159 { 160 return events; 161 } 162 163 public void setEvents(Set <EventInfo> events) 164 { 165 this.events = events; 166 } 167 168 public Set <MethodInfo> getMethods() 169 { 170 return methods; 171 } 172 173 public void setMethods(Set <MethodInfo> methods) 174 { 175 this.methods = methods; 176 } 177 178 public BeanInfoFactory getBeanInfoFactory() 179 { 180 return beanInfoFactory; 181 } 182 183 public MetaDataContext getMetaDataContext() 184 { 185 return classAdapter.getMetaDataContext(); 186 } 187 188 public void setMetaDataContext(MetaDataContext metaCtx) 189 { 190 classAdapter.setMetaDataContext(metaCtx); 191 } 192 193 public boolean equals(Object object) 194 { 195 if (object == null || object instanceof AbstractBeanInfo == false) 196 return false; 197 198 AbstractBeanInfo other = (AbstractBeanInfo) object; 199 if (notEqual(name, other.name)) 200 return false; 201 else if (notEqual(classAdapter, other.classAdapter)) 202 return false; 203 else if (notEqual(properties, other.properties)) 204 return false; 205 else if (notEqual(methods, other.methods)) 206 return false; 207 else if (notEqual(constructors, other.constructors)) 208 return false; 209 else if (notEqual(events, other.events)) 210 return false; 211 return true; 212 } 213 214 public void toString(JBossStringBuilder buffer) 215 { 216 buffer.append("name=").append(name); 217 buffer.append(" classInfo="); 218 classAdapter.toShortString(buffer); 219 buffer.append(" properties="); 220 JBossObject.list(buffer, properties); 221 buffer.append(" methods="); 222 JBossObject.list(buffer, methods); 223 buffer.append(" constructors="); 224 JBossObject.list(buffer, constructors); 225 buffer.append(" events="); 226 JBossObject.list(buffer, events); 227 } 228 229 public void toShortString(JBossStringBuilder buffer) 230 { 231 buffer.append(name); 232 } 233 234 public int getHashCode() 235 { 236 return name.hashCode(); 237 } 238 239 240 public BeanInfo getInstanceInfo() 241 { 242 return new AbstractInstanceBeanInfo(this); 243 } 244 } 245 | Popular Tags |