Java Code Examples for java.beans.Introspector
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project ajah, under directory /ajah-spring-jdbc/src/main/java/com/ajah/spring/jdbc/.
Source file: AbstractAjahDao.java

private Object[] getInsertValues(final T entity){ final Object[] values=new Object[getColumns().size()]; try { final BeanInfo componentBeanInfo=Introspector.getBeanInfo(entity.getClass()); final PropertyDescriptor[] props=componentBeanInfo.getPropertyDescriptors(); for (int i=0; i < values.length; i++) { final Field field=this.colMap.get(this.columns.get(i)); values[i]=ReflectionUtils.propGetSafeAuto(entity,field,getProp(field,props)); if (log.isLoggable(Level.FINEST)) { log.finest(field.getName() + " set to " + values[i]); } } } catch ( final IntrospectionException e) { log.log(Level.SEVERE,entity.getClass().getName() + ": " + e.getMessage(),e); } return values; }
Example 2
From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/config/.
Source file: ParameterMapping.java

private static PropertyDescriptor[] getDescriptors(Class<?> clazz){ PropertyDescriptor[] descriptors; List<PropertyDescriptor> list; PropertyDescriptor[] mDescriptors=(PropertyDescriptor[])propertyDescriptorMap.get(clazz); if (null == mDescriptors) { try { descriptors=Introspector.getBeanInfo(clazz).getPropertyDescriptors(); list=new ArrayList<PropertyDescriptor>(); for (int i=0; i < descriptors.length; i++) { if (null != descriptors[i].getPropertyType()) { list.add(descriptors[i]); } } mDescriptors=new PropertyDescriptor[list.size()]; list.toArray(mDescriptors); } catch ( IntrospectionException ie) { ie.printStackTrace(); mDescriptors=new PropertyDescriptor[0]; } } propertyDescriptorMap.put(clazz,mDescriptors); return (mDescriptors); }
Example 3
From project Arecibo, under directory /alert-data-support/src/main/java/com/ning/arecibo/alert/confdata/dao/.
Source file: LowerToCamelBeanMapper.java

public LowerToCamelBeanMapper(final Class<T> type){ this.type=type; try { final BeanInfo info=Introspector.getBeanInfo(type); for ( final PropertyDescriptor descriptor : info.getPropertyDescriptors()) { properties.put(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,descriptor.getName()).toLowerCase(),descriptor); } } catch ( IntrospectionException e) { throw new IllegalArgumentException(e); } }
Example 4
public static BeanInfo getBeanInfo(Class<?> clazz){ try { return Introspector.getBeanInfo(clazz); } catch ( Exception e) { throw new RuntimeException(e); } }
Example 5
From project components-ness-jdbi, under directory /src/main/java/com/nesscomputing/jdbi/binding/.
Source file: BindDefineBeanFactory.java

@Override public Binder build(Annotation annotation){ return new Binder<BindDefineBean,Object>(){ @Override public void bind( SQLStatement q, BindDefineBean bind, Object arg){ final String prefix; if ("___jdbi_bare___".equals(bind.value())) { prefix=""; } else { prefix=bind.value() + "."; } try { BeanInfo infos=Introspector.getBeanInfo(arg.getClass()); PropertyDescriptor[] props=infos.getPropertyDescriptors(); for ( PropertyDescriptor prop : props) { String key=prefix + prop.getName(); Object value=prop.getReadMethod().invoke(arg); q.bind(key,value); q.define(key,value); } } catch ( Exception e) { throw new IllegalStateException("unable to bind bean properties",e); } } } ; }
Example 6
From project vaadin-lazyquerycontainer, under directory /vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/.
Source file: AbstractBeanQuery.java

/** * Constructs new item based on QueryDefinition. * @return new item. */ public final Item constructItem(){ try { T bean=constructBean(); BeanInfo info=Introspector.getBeanInfo(bean.getClass()); for ( PropertyDescriptor pd : info.getPropertyDescriptors()) { for ( Object propertyId : queryDefinition.getPropertyIds()) { if (pd.getName().equals(propertyId)) { pd.getWriteMethod().invoke(bean,queryDefinition.getPropertyDefaultValue(propertyId)); } } } return toItem(bean); } catch ( Exception e) { throw new RuntimeException("Error in bean construction or property population with default values.",e); } }
Example 7
From project api, under directory /weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/.
Source file: AbstractResourceServices.java

public static String getPropertyName(Method method){ String methodName=method.getName(); if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0) { return Introspector.decapitalize(methodName.substring(3)); } else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0) { return Introspector.decapitalize(methodName.substring(2)); } else { return null; } }
Example 8
From project asterisk-java, under directory /src/main/java/org/asteriskjava/tools/.
Source file: HtmlEventTracer.java

protected String getProperty(Object obj,String property){ try { BeanInfo beanInfo=Introspector.getBeanInfo(obj.getClass()); for ( PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) { if (!propertyDescriptor.getName().equals(property)) { continue; } return propertyDescriptor.getReadMethod().invoke(obj).toString(); } } catch ( Exception e) { System.err.println("Unable to read property '" + property + "' from object "+ obj+ ": "+ e.getMessage()); return null; } return null; }
Example 9
From project c3p0, under directory /src/java/com/mchange/v2/c3p0/management/.
Source file: DynamicPooledDataSourceManagerMBean.java

private static Map extractAttributeInfos(Object bean){ if (bean != null) { try { Map out=new HashMap(); BeanInfo beanInfo=Introspector.getBeanInfo(bean.getClass(),Object.class); PropertyDescriptor[] pds=beanInfo.getPropertyDescriptors(); for (int i=0, len=pds.length; i < len; ++i) { PropertyDescriptor pd=pds[i]; String name; String desc; Method getter; Method setter; name=pd.getName(); if (HIDE_PROPS.contains(name)) continue; desc=getDescription(name); getter=pd.getReadMethod(); setter=pd.getWriteMethod(); if (FORCE_READ_ONLY_PROPS.contains(name)) setter=null; try { out.put(name,new MBeanAttributeInfo(name,desc,getter,setter)); } catch ( javax.management.IntrospectionException e) { if (logger.isLoggable(MLevel.WARNING)) logger.log(MLevel.WARNING,"IntrospectionException while setting up MBean attribute '" + name + "'",e); } } return Collections.synchronizedMap(out); } catch ( java.beans.IntrospectionException e) { if (logger.isLoggable(MLevel.WARNING)) logger.log(MLevel.WARNING,"IntrospectionException while setting up MBean attributes for " + bean,e); return Collections.EMPTY_MAP; } } else return Collections.EMPTY_MAP; }
Example 10
From project cdk, under directory /generator/src/main/java/org/richfaces/cdk/model/.
Source file: ComponentLibrary.java

static <T extends Mergeable<T>>void merge(T target,T source){ try { PropertyDescriptor[] properties=Introspector.getBeanInfo(target.getClass()).getPropertyDescriptors(); for ( PropertyDescriptor propertyDescriptor : properties) { Method readMethod=propertyDescriptor.getReadMethod(); Method writeMethod=propertyDescriptor.getWriteMethod(); if (null != readMethod && null != writeMethod && readMethod.isAnnotationPresent(Merge.class)) { boolean overwrite=readMethod.getAnnotation(Merge.class).value(); Object oldValue=readMethod.invoke(target); Object newValue=readMethod.invoke(source); if (null != newValue && (overwrite || null == oldValue)) { writeMethod.invoke(target,newValue); } } } } catch ( IntrospectionException e) { } catch ( IllegalArgumentException e) { } catch ( IllegalAccessException e) { } catch ( InvocationTargetException e) { } }
Example 11
From project chromattic, under directory /metamodel/src/test/java/org/chromattic/metamodel/bean/.
Source file: JavaBeanTestCase.java

@Override protected Collection<PropertyMetaData> buildMetaData(Class<?> beanClass) throws Exception { java.beans.BeanInfo info=Introspector.getBeanInfo(beanClass,Object.class); List<PropertyMetaData> res=new ArrayList<PropertyMetaData>(); for ( PropertyDescriptor pd : info.getPropertyDescriptors()) { res.add(new PropertyMetaData(pd)); } return res; }
Example 12
From project Cinch, under directory /src/com/palantir/ptoss/cinch/core/.
Source file: BindingContext.java

private Map<String,ObjectFieldMethod> indexBindableProperties(Function<PropertyDescriptor,Method> methodFn) throws IntrospectionException { final Map<ObjectFieldMethod,String> getterOfms=Maps.newHashMap(); for ( Field field : Sets.newHashSet(bindableModels.values())) { BeanInfo beanInfo=Introspector.getBeanInfo(field.getType()); PropertyDescriptor[] props=beanInfo.getPropertyDescriptors(); for ( PropertyDescriptor descriptor : props) { Method method=methodFn.apply(descriptor); if (method == null) { continue; } BindableModel model=getFieldObject(field,BindableModel.class); getterOfms.put(new ObjectFieldMethod(model,field,method),descriptor.getName()); } } return dotIndex(getterOfms.keySet(),ObjectFieldMethod.TO_FIELD_NAME,Functions.forMap(getterOfms)); }
Example 13
From project codjo-standalone-common, under directory /src/main/java/net/codjo/persistent/sql/.
Source file: SimpleHomeMapping.java

/** * Initialisation. * @param objectClass La classe de l'objet * @param initMask Le masque d'initialisation * @exception IntrospectionException Recherche des accesseurs impossible * @exception NoSuchMethodException Methode accesseur introuvable */ private void initAccessors(Class objectClass,int initMask) throws IntrospectionException, NoSuchMethodException { if ((initMask & MASK) == INIT_GETTER) { getterMethods=new Method[dbColumnNames.size()]; } if ((initMask & MASK) == INIT_SETTER) { setterMethods=new Method[dbColumnNames.size()]; } BeanInfo info=Introspector.getBeanInfo(objectClass); PropertyDescriptor[] desc=info.getPropertyDescriptors(); for (int i=0; i < desc.length; i++) { int idx=propertyNames.indexOf(desc[i].getName()); if (idx != -1 && (initMask & MASK) == INIT_GETTER) { getterMethods[idx]=desc[i].getReadMethod(); } if (idx != -1 && (initMask & MASK) == INIT_SETTER) { setterMethods[idx]=desc[i].getWriteMethod(); } } if ((initMask & MASK) == INIT_GETTER) { for (int i=0; i < getterMethods.length; i++) { if (getterMethods[i] == null) { throw new NoSuchMethodException("Manque getter pour " + propertyNames.get(i)); } } } if ((initMask & MASK) == INIT_SETTER) { for (int i=0; i < setterMethods.length; i++) { if (setterMethods[i] == null) { throw new NoSuchMethodException("Manque setter pour " + propertyNames.get(i)); } } } }
Example 14
From project collections-generic, under directory /src/java/org/apache/commons/collections15/.
Source file: BeanMap.java

private void initialise(){ if (getBean() == null) return; Class beanClass=getBean().getClass(); try { BeanInfo beanInfo=Introspector.getBeanInfo(beanClass); PropertyDescriptor[] propertyDescriptors=beanInfo.getPropertyDescriptors(); if (propertyDescriptors != null) { for (int i=0; i < propertyDescriptors.length; i++) { PropertyDescriptor propertyDescriptor=propertyDescriptors[i]; if (propertyDescriptor != null) { String name=propertyDescriptor.getName(); Method readMethod=propertyDescriptor.getReadMethod(); Method writeMethod=propertyDescriptor.getWriteMethod(); Class aType=propertyDescriptor.getPropertyType(); if (readMethod != null) { readMethods.put(name,readMethod); } if (writeMethods != null) { writeMethods.put(name,writeMethod); } types.put(name,aType); } } } } catch ( IntrospectionException e) { logWarn(e); } }
Example 15
From project cometd, under directory /cometd-java/cometd-java-annotations/src/test/java/org/cometd/annotation/spring/.
Source file: SpringAnnotationTest.java

@Test public void testSpringWiringOfCometDServices() throws Exception { ClassPathXmlApplicationContext applicationContext=new ClassPathXmlApplicationContext(); applicationContext.setConfigLocation("classpath:applicationContext.xml"); applicationContext.refresh(); String beanName=Introspector.decapitalize(SpringBayeuxService.class.getSimpleName()); String[] beanNames=applicationContext.getBeanDefinitionNames(); assertTrue(Arrays.asList(beanNames).contains(beanName)); SpringBayeuxService service=(SpringBayeuxService)applicationContext.getBean(beanName); assertNotNull(service); assertNotNull(service.dependency); assertNotNull(service.bayeuxServer); assertNotNull(service.serverSession); assertTrue(service.active); assertEquals(1,service.bayeuxServer.getChannel(SpringBayeuxService.CHANNEL).getSubscribers().size()); applicationContext.close(); assertFalse(service.active); }
Example 16
From project core_1, under directory /runtime/src/main/java/org/switchyard/internal/io/graph/.
Source file: PropertyGraph.java

private List<Access<?>> getAccessList(Class<?> clazz){ List<Access<?>> accessList=new ArrayList<Access<?>>(); if (clazz.getAnnotation(Deprecated.class) != null) { return accessList; } Strategy strategy=clazz.getAnnotation(Strategy.class); AccessType accessType=strategy != null ? strategy.access() : AccessType.BEAN; CoverageType coverageType=strategy != null ? strategy.coverage() : CoverageType.INCLUSIVE; switch (accessType) { case BEAN: BeanInfo info; try { info=Introspector.getBeanInfo(clazz); } catch ( IntrospectionException ie) { throw new SwitchYardException(ie); } for (PropertyDescriptor desc : info.getPropertyDescriptors()) { Method method=desc.getReadMethod(); if (((CoverageType.INCLUSIVE.equals(coverageType) && method.getAnnotation(Exclude.class) == null) || (CoverageType.EXCLUSIVE.equals(coverageType) && method.getAnnotation(Include.class) != null)) && method.getAnnotation(Deprecated.class) == null) { @SuppressWarnings("rawtypes") Access<?> access=new BeanAccess(desc); if (access.isReadable() && !"class".equals(access.getName())) { accessList.add(access); } } } break; case FIELD: for (Field field : clazz.getDeclaredFields()) { if (((CoverageType.INCLUSIVE.equals(coverageType) && field.getAnnotation(Exclude.class) == null) || (CoverageType.EXCLUSIVE.equals(coverageType) && field.getAnnotation(Include.class) != null)) && field.getAnnotation(Deprecated.class) == null && !Modifier.isTransient(field.getModifiers())) { @SuppressWarnings("rawtypes") Access<?> access=new FieldAccess(field); if (access.isReadable()) { accessList.add(access); } } } break; } return accessList; }
Example 17
From project core_4, under directory /api/src/main/java/org/ajax4jsf/javascript/.
Source file: PropertyUtils.java

public static PropertyDescriptor[] getPropertyDescriptors(Object bean){ if (bean == null) { throw new IllegalArgumentException("argument is null"); } PropertyDescriptor[] descriptors=null; try { BeanInfo beanInfo=Introspector.getBeanInfo(bean.getClass()); descriptors=beanInfo.getPropertyDescriptors(); } catch ( IntrospectionException e) { LOGGER.error(e.getMessage(),e); } if (descriptors == null) { descriptors=EMPTY_DESCRIPTORS_ARRAY; } return descriptors; }
Example 18
From project dawn-isencia, under directory /com.isencia.passerelle.commons/src/main/java/com/isencia/util/swing/calendar/.
Source file: JCalendarBeanInfo.java

/** * This method returns an array of PropertyDescriptors describing the editable properties supported by this bean. */ public PropertyDescriptor[] getPropertyDescriptors(){ try { if (PropertyEditorManager.findEditor(Locale.class) == null) { BeanInfo beanInfo=Introspector.getBeanInfo(JPanel.class); PropertyDescriptor[] p=beanInfo.getPropertyDescriptors(); int length=p.length; PropertyDescriptor[] propertyDescriptors=new PropertyDescriptor[length + 1]; for (int i=0; i < length; i++) propertyDescriptors[i + 1]=p[i]; propertyDescriptors[0]=new PropertyDescriptor("locale",JCalendar.class); propertyDescriptors[0].setBound(true); propertyDescriptors[0].setConstrained(false); propertyDescriptors[0].setPropertyEditorClass(LocaleEditor.class); return propertyDescriptors; } } catch ( IntrospectionException e) { e.printStackTrace(); } return null; }
Example 19
From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/config/.
Source file: PropertySetter.java

/** * Uses JavaBeans {@link Introspector} to computer setters of object to beconfigured. */ protected void introspect(){ try { BeanInfo bi=Introspector.getBeanInfo(obj.getClass()); props=bi.getPropertyDescriptors(); } catch ( IntrospectionException ex) { LogLog.error("Failed to introspect " + obj + ": "+ ex.getMessage()); props=new PropertyDescriptor[0]; } }
Example 20
From project drools-planner, under directory /drools-planner-core/src/main/java/org/drools/planner/core/domain/entity/.
Source file: PlanningEntityDescriptor.java

public PlanningEntityDescriptor(SolutionDescriptor solutionDescriptor,Class<?> planningEntityClass){ this.solutionDescriptor=solutionDescriptor; this.planningEntityClass=planningEntityClass; try { planningEntityBeanInfo=Introspector.getBeanInfo(planningEntityClass); } catch ( IntrospectionException e) { throw new IllegalStateException("The planningEntityClass (" + planningEntityClass + ") is not a valid java bean.",e); } }
Example 21
From project dynalink, under directory /src/main/java/org/dynalang/dynalink/beans/.
Source file: BeanIntrospector.java

BeanIntrospector(Class<?> clazz){ super(clazz); try { beanInfo=Introspector.getBeanInfo(clazz); } catch ( IntrospectionException e) { throw new UndeclaredThrowableException(e); } }
Example 22
From project echo2, under directory /src/app/java/nextapp/echo2/app/componentxml/.
Source file: ComponentIntrospector.java

/** * Creates a new <code>ComponentIntrospector</code> for the specified type. * @param typeName the component type name */ private ComponentIntrospector(String typeName,ClassLoader classLoader) throws ClassNotFoundException { super(); componentClass=Class.forName(typeName,true,classLoader); try { beanInfo=Introspector.getBeanInfo(componentClass,Introspector.IGNORE_ALL_BEANINFO); } catch ( IntrospectionException ex) { throw new RuntimeException("Introspection Error",ex); } loadConstants(); loadPropertyData(); }
Example 23
From project echo3, under directory /src/server-java/app/nextapp/echo/app/reflect/.
Source file: IntrospectorFactory.java

/** * Disposes an <code>IntrospectorFactory</code> for a specific <code>ClassLoader</code>. * @param classLoader the <code>ClassLoader</code> */ public static void dispose(ClassLoader classLoader){ synchronized (classLoaderCache) { Map oiStore=(Map)classLoaderCache.remove(classLoader); if (oiStore == null) { throw new IllegalStateException("ObjectIntrospectorFactory does not exist for specified ClassLoader."); } Introspector.flushCaches(); } }
Example 24
From project elasticsearch-osem, under directory /src/main/java/org/elasticsearch/osem/annotations/impl/.
Source file: AttributeSourceImpl.java

private static Collection<PropertyDescriptor> getPropertyDescriptors(Class<?> clazz){ Collection<PropertyDescriptor> descriptors=new HashSet<PropertyDescriptor>(); try { BeanInfo bean; bean=Introspector.getBeanInfo(clazz); descriptors.addAll(Arrays.asList(bean.getPropertyDescriptors())); } catch ( IntrospectionException e) { throw new ObjectContextException("Unable to introspect class '" + clazz.getName() + "'",e); } for ( Class<?> i : clazz.getInterfaces()) { descriptors.addAll(getPropertyDescriptors(i)); } if (clazz.getSuperclass() != null) { descriptors.addAll(getPropertyDescriptors(clazz.getSuperclass())); } return descriptors; }
Example 25
From project entando-core-engine, under directory /src/main/java/com/agiletec/apsadmin/tags/.
Source file: AbstractObjectInfoTag.java

protected Object getPropertyValue(Object masterObject,String propertyValue){ try { BeanInfo beanInfo=Introspector.getBeanInfo(masterObject.getClass()); PropertyDescriptor[] descriptors=beanInfo.getPropertyDescriptors(); for (int i=0; i < descriptors.length; i++) { PropertyDescriptor descriptor=descriptors[i]; if (!descriptor.getName().equals(propertyValue)) { continue; } Method method=descriptor.getReadMethod(); Object[] args=null; return method.invoke(masterObject,args); } if (ApsSystemUtils.getLogger().isLoggable(Level.FINEST)) { ApsSystemUtils.getLogger().finest("Invalid required object property : Master Object '" + masterObject.getClass().getName() + "' - property '"+ propertyValue+ "'"); } } catch ( Throwable t) { ApsSystemUtils.logThrowable(t,this,"getPropertyValue","Error extracting property value : Master Object '" + masterObject.getClass().getName() + "' - property '"+ propertyValue+ "'"); } return null; }
Example 26
From project fakereplace, under directory /plugins/jsf/src/main/java/org/fakereplace/integration/jsf/.
Source file: ClassRedefinitionPlugin.java

@Override public void afterChange(List<ChangedClass> changed,List<ClassIdentifier> added,final Attachments attachments){ try { Introspector.flushCaches(); } catch ( Exception e) { e.printStackTrace(); } Set<?> data=InstanceTracker.get("javax.el.BeanELResolver"); for ( Object i : data) { clearBeanElResolver(i); } }
Example 27
From project fest-reflect, under directory /src/main/java/org/fest/reflect/beanproperty/.
Source file: Invoker.java

private static PropertyDescriptor descriptorForProperty(String propertyName,Object target){ BeanInfo beanInfo=null; Class<?> type=target.getClass(); try { beanInfo=Introspector.getBeanInfo(type); } catch ( Exception e) { throw new ReflectionError(concat("Unable to get BeanInfo for type ",type.getName()),e); } for ( PropertyDescriptor d : beanInfo.getPropertyDescriptors()) if (propertyName.equals(d.getName())) return d; throw new ReflectionError(concat("Unable to find property ",quote(propertyName)," in ",type.getName())); }
Example 28
From project gedcomx, under directory /enunciate-gedcomx-support/src/main/java/org/gedcomx/build/enunciate/rdf/.
Source file: RDFProcessor.java

/** * Find the RDF URI for the specified type declaration. * @param typeDeclaration The type declaration. * @return The RDF URI, in terms of its QName. */ private QName findRDFUri(TypeDeclaration typeDeclaration){ if (typeDeclaration == null || Object.class.getName().equals(typeDeclaration.getQualifiedName())) { return null; } String namespace=""; String name=Introspector.decapitalize(typeDeclaration.getSimpleName()); PackageDeclaration pkg=typeDeclaration.getPackage(); if (pkg != null && pkg.getAnnotation(XmlSchema.class) != null) { namespace=pkg.getAnnotation(XmlSchema.class).namespace(); } XmlType xmlType=typeDeclaration.getAnnotation(XmlType.class); if (xmlType != null) { if (!"##default".equals(xmlType.namespace())) { namespace=xmlType.namespace(); } if (!"##default".equals(xmlType.name())) { name=xmlType.name(); } } return new QName(namespace,name); }
Example 29
From project gemini-dbaccess, under directory /org.eclipse.gemini.dbaccess.util/src/org/eclipse/gemini/dbaccess/.
Source file: AbstractDataSourceFactory.java

protected void setProperty(Object object,String name,String value) throws SQLException { Class<?> type=object.getClass(); PropertyDescriptor[] descriptors; try { descriptors=Introspector.getBeanInfo(type).getPropertyDescriptors(); } catch ( Exception ex) { SQLException sqlException=new SQLException(); sqlException.initCause(ex); throw sqlException; } List<String> names=new ArrayList<String>(); for (int i=0; i < descriptors.length; i++) { if (descriptors[i].getWriteMethod() == null) { continue; } if (descriptors[i].getName().equals(name)) { Method method=descriptors[i].getWriteMethod(); Class<?> paramType=method.getParameterTypes()[0]; Object param=toBasicType(value,paramType.getName()); try { method.invoke(object,new Object[]{param}); } catch ( Exception ex) { SQLException sqlException=new SQLException(); sqlException.initCause(ex); throw sqlException; } return; } names.add(descriptors[i].getName()); } throw new SQLException("No such property: " + name + ", exists. Writable properties are: "+ names); }
Example 30
From project gemini.dbaccess, under directory /org.eclipse.gemini.dbaccess.util/src/org/eclipse/gemini/dbaccess/.
Source file: AbstractDataSourceFactory.java

protected void setProperty(Object object,String name,String value) throws SQLException { Class<?> type=object.getClass(); PropertyDescriptor[] descriptors; try { descriptors=Introspector.getBeanInfo(type).getPropertyDescriptors(); } catch ( Exception ex) { SQLException sqlException=new SQLException(); sqlException.initCause(ex); throw sqlException; } List<String> names=new ArrayList<String>(); for (int i=0; i < descriptors.length; i++) { if (descriptors[i].getWriteMethod() == null) { continue; } if (descriptors[i].getName().equals(name)) { Method method=descriptors[i].getWriteMethod(); Class<?> paramType=method.getParameterTypes()[0]; Object param=toBasicType(value,paramType.getName()); try { method.invoke(object,new Object[]{param}); } catch ( Exception ex) { SQLException sqlException=new SQLException(); sqlException.initCause(ex); throw sqlException; } return; } names.add(descriptors[i].getName()); } throw new SQLException("No such property: " + name + ", exists. Writable properties are: "+ names); }
Example 31
From project geronimo-xbean, under directory /xbean-blueprint/src/main/java/org/apache/xbean/blueprint/context/impl/.
Source file: XBeanNamespaceHandler.java

private BeanInfo getBeanInfo(Class type){ if (type == null) { return null; } try { return Introspector.getBeanInfo(type); } catch ( IntrospectionException e) { throw new ComponentDefinitionException("Failed to introspect type: " + type.getName() + ". Reason: "+ e,e); } }
Example 32
From project grails-data-mapping, under directory /grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/.
Source file: AbstractPersistentEntity.java

public AbstractPersistentEntity(Class javaClass,MappingContext context){ Assert.notNull(javaClass,"The argument [javaClass] cannot be null"); this.javaClass=javaClass; this.context=context; decapitalizedName=Introspector.decapitalize(javaClass.getSimpleName()); }
Example 33
From project grails-searchable, under directory /src/java/grails/plugin/searchable/internal/support/.
Source file: DynamicMethodUtils.java

/** * Extract the property names from the given method name suffix * @param methodSuffix a method name suffix like 'NameAndAddress' * @return a Collection of property names like ['name', 'address'] */ public static Collection extractPropertyNames(String methodSuffix){ String[] splited=methodSuffix.split("And"); Set propertyNames=new HashSet(); for (int i=0; i < splited.length; i++) { if (splited[i].length() > 0) { propertyNames.add(Introspector.decapitalize(splited[i])); } } return propertyNames; }
Example 34
From project ha-jdbc, under directory /src/main/java/net/sf/hajdbc/sql/.
Source file: AbstractDatabaseClusterConfiguration.java

static Map<String,Map.Entry<PropertyDescriptor,PropertyEditor>> findDescriptors(Class<?> targetClass) throws Exception { Map<String,Map.Entry<PropertyDescriptor,PropertyEditor>> map=new HashMap<String,Map.Entry<PropertyDescriptor,PropertyEditor>>(); for ( PropertyDescriptor descriptor : Introspector.getBeanInfo(targetClass).getPropertyDescriptors()) { if ((descriptor.getReadMethod() != null) && (descriptor.getWriteMethod() != null)) { PropertyEditor editor=PropertyEditorManager.findEditor(descriptor.getPropertyType()); if (editor != null) { map.put(descriptor.getName(),new AbstractMap.SimpleImmutableEntry<PropertyDescriptor,PropertyEditor>(descriptor,editor)); } } } return map; }
Example 35
From project hibernate-commons-annotations, under directory /src/main/java/org/hibernate/annotations/common/reflection/java/.
Source file: JavaXProperty.java

public String getName(){ String fullName=getMember().getName(); if (getMember() instanceof Method) { if (fullName.startsWith("get")) { return Introspector.decapitalize(fullName.substring("get".length())); } if (fullName.startsWith("is")) { return Introspector.decapitalize(fullName.substring("is".length())); } throw new RuntimeException("Method " + fullName + " is not a property getter"); } else { return fullName; } }
Example 36
From project hibernate-metamodelgen, under directory /src/main/java/org/hibernate/jpamodelgen/annotation/.
Source file: AnnotationMetaAttribute.java

public String getPropertyName(){ Elements elementsUtil=parent.getContext().getElementUtils(); if (element.getKind() == ElementKind.FIELD) { return element.getSimpleName().toString(); } else if (element.getKind() == ElementKind.METHOD) { String name=element.getSimpleName().toString(); if (name.startsWith("get")) { return elementsUtil.getName(Introspector.decapitalize(name.substring("get".length()))).toString(); } else if (name.startsWith("is")) { return (elementsUtil.getName(Introspector.decapitalize(name.substring("is".length())))).toString(); } return elementsUtil.getName(Introspector.decapitalize(name)).toString(); } else { return elementsUtil.getName(element.getSimpleName() + "/* " + element.getKind()+ " */").toString(); } }
Example 37
From project hibernate-tools, under directory /src/java/org/hibernate/cfg/reveng/.
Source file: DefaultReverseEngineeringStrategy.java

/** * Does some crude english pluralization TODO: are the from/to names correct ? */ public String foreignKeyToCollectionName(String keyname,TableIdentifier fromTable,List fromColumns,TableIdentifier referencedTable,List referencedColumns,boolean uniqueReference){ String propertyName=Introspector.decapitalize(StringHelper.unqualify(getRoot().tableToClassName(fromTable))); propertyName=pluralize(propertyName); if (!uniqueReference) { if (fromColumns != null && fromColumns.size() == 1) { String columnName=((Column)fromColumns.get(0)).getName(); propertyName=propertyName + "For" + toUpperCamelCase(columnName); } else { propertyName=propertyName + "For" + toUpperCamelCase(keyname); } } return propertyName; }
Example 38
From project hibernate-validator, under directory /engine/src/main/java/org/hibernate/validator/internal/util/.
Source file: ReflectionHelper.java

/** * Process bean properties getter by applying the JavaBean naming conventions. * @param member the member for which to get the property name. * @return The bean method name with the "is" or "get" prefix stripped off, <code>null</code>the method name id not according to the JavaBeans standard. */ public static String getPropertyName(Member member){ String name=null; if (member instanceof Field) { name=member.getName(); } if (member instanceof Method) { String methodName=member.getName(); for ( String prefix : PROPERTY_ACCESSOR_PREFIXES) { if (methodName.startsWith(prefix)) { name=Introspector.decapitalize(methodName.substring(prefix.length())); } } } return name; }
Example 39
From project interface-processor, under directory /src/main/java/com/shelfmap/interfaceprocessor/util/.
Source file: Objects.java

public static <A extends Object & Annotation>A findAnnotationOnProperty(Class<?> targetClass,String propertyName,Class<A> findingAnnotation) throws IntrospectionException { CLASS_LOOP: for ( Class<?> clazz : linearize(targetClass)) { PropertyDescriptor[] descriptors=Introspector.getBeanInfo(clazz).getPropertyDescriptors(); for ( PropertyDescriptor descriptor : descriptors) { if (descriptor.getName().equals(propertyName)) { Method readMethod=descriptor.getReadMethod(); if (readMethod == null) throw new IllegalStateException("the property '" + propertyName + "' does not have a getter method."); A annotation=readMethod.getAnnotation(findingAnnotation); if (annotation != null) { return annotation; } else { continue CLASS_LOOP; } } } } return null; }
Example 40
From project jAPS2, under directory /src/com/agiletec/apsadmin/tags/.
Source file: AbstractObjectInfoTag.java

protected Object getPropertyValue(Object masterObject,String propertyValue){ try { BeanInfo beanInfo=Introspector.getBeanInfo(masterObject.getClass()); PropertyDescriptor[] descriptors=beanInfo.getPropertyDescriptors(); for (int i=0; i < descriptors.length; i++) { PropertyDescriptor descriptor=descriptors[i]; if (!descriptor.getName().equals(propertyValue)) { continue; } Method method=descriptor.getReadMethod(); Object[] args=null; return method.invoke(masterObject,args); } if (ApsSystemUtils.getLogger().isLoggable(Level.FINEST)) { ApsSystemUtils.getLogger().finest("Invalid required object property : Master Object '" + masterObject.getClass().getName() + "' - property '"+ propertyValue+ "'"); } } catch ( Throwable t) { ApsSystemUtils.logThrowable(t,this,"getPropertyValue","Error extracting property value : Master Object '" + masterObject.getClass().getName() + "' - property '"+ propertyValue+ "'"); } return null; }
Example 41
From project java-cas-client, under directory /cas-client-core/src/main/java/org/jasig/cas/client/jaas/.
Source file: CasLoginModule.java

/** * Creates a {@link TicketValidator} instance from a class name and map of property name/value pairs. * @param className Fully-qualified name of {@link TicketValidator} concrete class. * @param propertyMap Map of property name/value pairs to set on validator instance. * @return Ticket validator with properties set. */ private TicketValidator createTicketValidator(final String className,final Map<String,?> propertyMap){ CommonUtils.assertTrue(propertyMap.containsKey("casServerUrlPrefix"),"Required property casServerUrlPrefix not found."); final Class<TicketValidator> validatorClass=ReflectUtils.loadClass(className); final TicketValidator validator=ReflectUtils.newInstance(validatorClass,propertyMap.get("casServerUrlPrefix")); try { final BeanInfo info=Introspector.getBeanInfo(validatorClass); for ( final String property : propertyMap.keySet()) { if (!"casServerUrlPrefix".equals(property)) { log.debug("Attempting to set TicketValidator property " + property); final String value=(String)propertyMap.get(property); final PropertyDescriptor pd=ReflectUtils.getPropertyDescriptor(info,property); if (pd != null) { ReflectUtils.setProperty(property,convertIfNecessary(pd,value),validator,info); log.debug("Set " + property + "="+ value); } else { log.warn("Cannot find property " + property + " on "+ className); } } } } catch ( final IntrospectionException e) { throw new RuntimeException("Error getting bean info for " + validatorClass,e); } return validator; }
Example 42
From project jboss-el-api_spec, under directory /src/main/java/javax/el/.
Source file: BeanELResolver.java

public BeanProperties(Class<?> baseClass){ PropertyDescriptor[] descriptors; try { BeanInfo info=Introspector.getBeanInfo(baseClass); descriptors=info.getPropertyDescriptors(); } catch ( IntrospectionException ie) { throw new ELException(ie); } for ( PropertyDescriptor pd : descriptors) { propertyMap.put(pd.getName(),new BeanProperty(baseClass,pd)); } }
Example 43
From project jboss-jsf-api_spec, under directory /src/main/java/javax/faces/component/.
Source file: UIComponentBase.java

/** * <p>Return an array of <code>PropertyDescriptors</code> for this {@link UIComponent}'s implementation class. If no descriptors can be identified, a zero-length array will be returned.</p> * @throws FacesException if an introspection exception occurs */ private PropertyDescriptor[] getPropertyDescriptors(){ PropertyDescriptor[] pd; try { pd=Introspector.getBeanInfo(this.getClass()).getPropertyDescriptors(); } catch ( IntrospectionException e) { throw new FacesException(e); } return (pd); }
Example 44
From project jboss-jstl-api_spec, under directory /src/main/java/org/apache/taglibs/standard/lang/jstl/.
Source file: BeanInfoManager.java

/** * Initializes by mapping property names to BeanInfoProperties */ void initialize(Logger pLogger) throws ELException { try { mBeanInfo=Introspector.getBeanInfo(mBeanClass); mPropertyByName=new HashMap(); mIndexedPropertyByName=new HashMap(); PropertyDescriptor[] pds=mBeanInfo.getPropertyDescriptors(); for (int i=0; pds != null && i < pds.length; i++) { PropertyDescriptor pd=pds[i]; if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd=(IndexedPropertyDescriptor)pd; Method readMethod=getPublicMethod(ipd.getIndexedReadMethod()); Method writeMethod=getPublicMethod(ipd.getIndexedWriteMethod()); BeanInfoIndexedProperty property=new BeanInfoIndexedProperty(readMethod,writeMethod,ipd); mIndexedPropertyByName.put(ipd.getName(),property); } Method readMethod=getPublicMethod(pd.getReadMethod()); Method writeMethod=getPublicMethod(pd.getWriteMethod()); BeanInfoProperty property=new BeanInfoProperty(readMethod,writeMethod,pd); mPropertyByName.put(pd.getName(),property); } mEventSetByName=new HashMap(); EventSetDescriptor[] esds=mBeanInfo.getEventSetDescriptors(); for (int i=0; esds != null && i < esds.length; i++) { EventSetDescriptor esd=esds[i]; mEventSetByName.put(esd.getName(),esd); } } catch ( IntrospectionException exc) { if (pLogger.isLoggingWarning()) { pLogger.logWarning(Constants.EXCEPTION_GETTING_BEANINFO,exc,mBeanClass.getName()); } } }
Example 45
From project jCAE, under directory /jcae/mesh-algos/src/org/jcae/netbeans/.
Source file: BeanProperty.java

private static Class getClass(Object bean,String property) throws IntrospectionException { PropertyDescriptor[] pd=Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors(); for (int i=0; i < pd.length; i++) { if (pd[i].getName().equals(property)) { if (pd[i].getReadMethod() != null) return pd[i].getReadMethod().getReturnType(); else return pd[i].getWriteMethod().getParameterTypes()[0]; } } return String.class; }
Example 46
From project jdbi, under directory /src/main/java/org/skife/jdbi/v2/.
Source file: BeanMapper.java

public BeanMapper(Class<T> type){ this.type=type; try { BeanInfo info=Introspector.getBeanInfo(type); for ( PropertyDescriptor descriptor : info.getPropertyDescriptors()) { properties.put(descriptor.getName().toLowerCase(),descriptor); } } catch ( IntrospectionException e) { throw new IllegalArgumentException(e); } }
Example 47
From project jdonframework, under directory /JdonAccessory/src/com/jdon/model/factory/.
Source file: ModelHandlerClassFactoryXmlImp.java

private Class getKeyClassType(Class beanClasses,String propertyName){ try { BeanInfo beanInfo=Introspector.getBeanInfo(beanClasses); PropertyDescriptor[] pds=beanInfo.getPropertyDescriptors(); for (int i=0; i < pds.length; i++) { PropertyDescriptor pd=pds[i]; if (pd.getName().equalsIgnoreCase(propertyName)) { Debug.logVerbose("[JdonFramework]found the key Class Type==" + pd.getPropertyType().getName(),module); return pd.getPropertyType(); } } } catch ( Exception e) { Debug.logError(e); } Debug.logVerbose("[JdonFramework]not found the key Class Type, propertyName=" + propertyName,module); return Object.class; }
Example 48
From project jibu, under directory /jibu-core/src/main/java/org/gaixie/jibu/utils/.
Source file: BeanConverter.java

/** * ??? Map ??avabean ???????????? <p> Map ???????????? key/value ???? map ??? key ? javabean ??????????????????????????????????<p> Map ??? value ?????????????????????? request.getParameterValues() ???? value?<p> * @param cls ???? bean ? Class * @param map ? bean ????? key ? Map * @return ??????????????? Bean * @exception JibuException ?????????? */ public static <T>T mapToBean(Class<T> cls,Map map) throws JibuException { try { T bean=cls.newInstance(); BeanInfo beanInfo=Introspector.getBeanInfo(cls); PropertyDescriptor[] pds=beanInfo.getPropertyDescriptors(); for ( PropertyDescriptor pd : pds) { Object obj=map.get(pd.getName()); if (null != obj) { Class type=pd.getPropertyType(); Object value=getBeanValue(type,obj); if (null != value) { pd.getWriteMethod().invoke(bean,value); } } } return bean; } catch ( Exception e) { throw new JibuException(e.getMessage()); } }
Example 49
From project jo4neo, under directory /tags/jo4neo-0.2/main/java/jo4neo/.
Source file: TypeWrapper.java

protected static BeanInfo beanInfo(Class<?> c){ try { return Introspector.getBeanInfo(c); } catch ( IntrospectionException e1) { e1.printStackTrace(); } return null; }
Example 50
From project jPOS, under directory /jpos/src/main/java/org/jpos/q2/.
Source file: QBeanSupport.java

protected Element createElement(String name,Class mbeanClass){ Element e=new Element(name); Element classPath=persist != null ? persist.getChild("classpath") : null; if (classPath != null) e.addContent(classPath); e.setAttribute("class",getClass().getName()); if (!e.getName().equals(getName())) e.setAttribute("name",getName()); String loggerName=getLogger(); if (loggerName != null) e.setAttribute("logger",loggerName); try { BeanInfo info=Introspector.getBeanInfo(mbeanClass); PropertyDescriptor[] desc=info.getPropertyDescriptors(); for ( PropertyDescriptor aDesc : desc) { if (aDesc.getWriteMethod() != null) { Method read=aDesc.getReadMethod(); Object obj=read.invoke(this,new Object[]{}); String type=read.getReturnType().getName(); if ("java.lang.String".equals(type)) type=null; addAttr(e,aDesc.getName(),obj,type); } } } catch ( Exception ex) { log.warn("get-persist",ex); } return e; }
Example 51
From project jsecurity, under directory /web/src/main/java/org/apache/ki/web/tags/.
Source file: PrincipalTag.java

private String getPrincipalProperty(Object principal,String property) throws JspTagException { String strValue=null; try { BeanInfo bi=Introspector.getBeanInfo(principal.getClass()); boolean foundProperty=false; for ( PropertyDescriptor pd : bi.getPropertyDescriptors()) { if (pd.getName().equals(property)) { Object value=pd.getReadMethod().invoke(principal,(Object[])null); strValue=String.valueOf(value); foundProperty=true; break; } } if (!foundProperty) { final String message="Property [" + property + "] not found in principal of type ["+ principal.getClass().getName()+ "]"; if (log.isErrorEnabled()) { log.error(message); } throw new JspTagException(message); } } catch ( Exception e) { final String message="Error reading property [" + property + "] from principal of type ["+ principal.getClass().getName()+ "]"; if (log.isErrorEnabled()) { log.error(message,e); } throw new JspTagException(message,e); } return strValue; }
Example 52
From project jsfunit, under directory /jboss-jsfunit-analysis/src/main/java/org/jboss/jsfunit/analysis/el/.
Source file: JSFUnitELResolver.java

@Override public Object getValue(final ELContext context,final Object base,final Object property){ if (context == null) { throw new NullPointerException("context is null"); } if (base instanceof Class<?>) { final BeanInfo beanInfo; try { beanInfo=Introspector.getBeanInfo((Class<?>)base); } catch ( final IntrospectionException e) { throw new ELException(e); } for ( final PropertyDescriptor pDes : beanInfo.getPropertyDescriptors()) { if (pDes.getName().equals(property)) { context.setPropertyResolved(true); return pDes.getReadMethod(); } } for ( final MethodDescriptor mDes : beanInfo.getMethodDescriptors()) { if (mDes.getName().equals(property)) { context.setPropertyResolved(true); return mDes.getMethod(); } } throw new PropertyNotFoundException("Could not resolve property " + property + " for base "+ base); } else if (base instanceof Method) { final Class<?> baseClass=((Method)base).getReturnType(); return getValue(context,baseClass,property); } else { return null; } }
Example 53
From project juel, under directory /modules/api/src/main/java/javax/el/.
Source file: BeanELResolver.java

public BeanProperties(Class<?> baseClass){ PropertyDescriptor[] descriptors; try { descriptors=Introspector.getBeanInfo(baseClass).getPropertyDescriptors(); } catch ( IntrospectionException e) { throw new ELException(e); } for ( PropertyDescriptor descriptor : descriptors) { map.put(descriptor.getName(),new BeanProperty(descriptor)); } }
Example 54
From project liquibase, under directory /liquibase-core/src/main/java/liquibase/change/.
Source file: AbstractChange.java

/** * Generate the ChangeMetaData for this class. By default reads from the @DatabaseChange annotation, but can return anything */ protected ChangeMetaData createChangeMetaData(){ try { DatabaseChange databaseChange=this.getClass().getAnnotation(DatabaseChange.class); if (databaseChange == null) { throw new UnexpectedLiquibaseException("No @DatabaseChange annotation for " + getClass().getName()); } Set<ChangeParameterMetaData> params=new HashSet<ChangeParameterMetaData>(); for ( PropertyDescriptor property : Introspector.getBeanInfo(this.getClass()).getPropertyDescriptors()) { Method readMethod=property.getReadMethod(); Method writeMethod=property.getWriteMethod(); if (readMethod != null && writeMethod != null) { DatabaseChangeProperty annotation=readMethod.getAnnotation(DatabaseChangeProperty.class); if (annotation == null || annotation.includeInMetaData()) { ChangeParameterMetaData param=createChangeParameterMetadata(property.getDisplayName()); params.add(param); } } } return new ChangeMetaData(databaseChange.name(),databaseChange.description(),databaseChange.priority(),databaseChange.appliesTo(),params); } catch ( Throwable e) { throw new UnexpectedLiquibaseException(e); } }
Example 55
From project log4j, under directory /src/main/java/org/apache/log4j/config/.
Source file: PropertySetter.java

/** * Uses JavaBeans {@link Introspector} to computer setters of object to beconfigured. */ protected void introspect(){ try { BeanInfo bi=Introspector.getBeanInfo(obj.getClass()); props=bi.getPropertyDescriptors(); } catch ( IntrospectionException ex) { LogLog.error("Failed to introspect " + obj + ": "+ ex.getMessage()); props=new PropertyDescriptor[0]; } }
Example 56
From project log4jna, under directory /thirdparty/log4j/src/main/java/org/apache/log4j/config/.
Source file: PropertySetter.java

/** * Uses JavaBeans {@link Introspector} to computer setters of object to beconfigured. */ protected void introspect(){ try { BeanInfo bi=Introspector.getBeanInfo(obj.getClass()); props=bi.getPropertyDescriptors(); } catch ( IntrospectionException ex) { LogLog.error("Failed to introspect " + obj + ": "+ ex.getMessage()); props=new PropertyDescriptor[0]; } }
Example 57
From project logback, under directory /logback-core/src/main/java/ch/qos/logback/core/joran/util/.
Source file: PropertySetter.java

/** * Uses JavaBeans {@link Introspector} to computer setters of object to beconfigured. */ protected void introspect(){ try { BeanInfo bi=Introspector.getBeanInfo(obj.getClass()); propertyDescriptors=bi.getPropertyDescriptors(); methodDescriptors=bi.getMethodDescriptors(); } catch ( IntrospectionException ex) { addError("Failed to introspect " + obj + ": "+ ex.getMessage()); propertyDescriptors=new PropertyDescriptor[0]; methodDescriptors=new MethodDescriptor[0]; } }
Example 58
From project MCStats3, under directory /src/com/ubempire/MCStats3/reporting/.
Source file: JSONEncoder.java

public ObjectEncoder(final Class<?> type) throws IntrospectionException { final BeanInfo info=Introspector.getBeanInfo(type); final PropertyDescriptor[] descriptors=info.getPropertyDescriptors(); final List<Property> props=new ArrayList<Property>(descriptors.length); for (int i=0; i < descriptors.length; i++) { final PropertyDescriptor d=descriptors[i]; final Method read=d.getReadMethod(); if (!read.getDeclaringClass().equals(Object.class)) { props.add(new Property(d.getName(),read)); } } properties=props.toArray(new Property[props.size()]); }
Example 59
From project mob, under directory /com.netappsid.mob/src/com/netappsid/mob/ejb3/tools/.
Source file: JPAHelper.java

/** * @param toInspect * @param entitiesClass * @throws IntrospectionException */ private static void visitProperties(Class<?> toInspect,Set<Class<?>> entitiesClass) throws IntrospectionException { BeanInfo beanInfo=Introspector.getBeanInfo(toInspect); PropertyDescriptor[] propertyDescriptors=beanInfo.getPropertyDescriptors(); for ( PropertyDescriptor propertyDescriptor : propertyDescriptors) { Method readMethod=propertyDescriptor.getReadMethod(); if (readMethod == null) { continue; } if (readMethod.isAnnotationPresent(OneToMany.class) || readMethod.isAnnotationPresent(OneToOne.class) || readMethod.isAnnotationPresent(ManyToMany.class)|| readMethod.isAnnotationPresent(ManyToOne.class)) { Class<?> propertyType=propertyDescriptor.getPropertyType(); if (propertyType.isAnnotationPresent(Entity.class) && !entitiesClass.contains(propertyType)) { entitiesClass.add(propertyType); recurseSuperClass(propertyType,entitiesClass); visitProperties(propertyType,entitiesClass); } else if (Collection.class.isAssignableFrom(propertyType)) { Class<?> entity=(Class<?>)((ParameterizedType)propertyDescriptor.getReadMethod().getGenericReturnType()).getActualTypeArguments()[0]; if (entity.isAnnotationPresent(Entity.class) && !entitiesClass.contains(entity)) { entitiesClass.add(entity); recurseSuperClass(entity,entitiesClass); visitProperties(entity,entitiesClass); } } else if (Map.class.isAssignableFrom(propertyType)) { Class<?> entity=(Class<?>)((ParameterizedType)propertyDescriptor.getReadMethod().getGenericReturnType()).getActualTypeArguments()[1]; if (entity.isAnnotationPresent(Entity.class) && !entitiesClass.contains(entity)) { entitiesClass.add(entity); recurseSuperClass(entity,entitiesClass); visitProperties(entity,entitiesClass); } } } } }
Example 60
From project modelmapper, under directory /core/src/main/java/org/modelmapper/convention/.
Source file: NameTransformers.java

public String transform(String name,NameableType nameableType){ if (NameableType.METHOD.equals(nameableType)) { if (name.startsWith("get")) return Introspector.decapitalize(name.substring(3)); else if (name.startsWith("is")) return Introspector.decapitalize(name.substring(2)); } return name; }
Example 61
From project mvel, under directory /src/test/java/org/mvel2/marshalling/.
Source file: MarshallingTest.java

private ObjectConverter generateConverter(Class cls){ BeanInfo beanInfo=null; try { beanInfo=Introspector.getBeanInfo(cls); } catch ( IntrospectionException e) { throw new RuntimeException(e); } PropertyDescriptor[] props=beanInfo.getPropertyDescriptors(); List<ObjectConverterEntry> list=new ArrayList<ObjectConverterEntry>(); for (int i=0, length=props.length; i < length; i++) { PropertyDescriptor prop=props[i]; if ("class".equals(prop.getName())) { continue; } list.add(new ObjectConverterEntry(prop.getName(),prop.getReadMethod(),getType(prop.getPropertyType()))); } return new ObjectConverter(cls,list.toArray(new ObjectConverterEntry[list.size()])); }
Example 62
From project myfaces-extcdi, under directory /jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/.
Source file: DefaultViewConfigDescriptor.java

private String getBeanName(Class<?> pageBeanClass){ if (pageBeanClass.isAnnotationPresent(Named.class)) { String beanName=pageBeanClass.getAnnotation(Named.class).value(); if (!"".equals(beanName)) { return beanName; } } return Introspector.decapitalize(pageBeanClass.getSimpleName()); }
Example 63
From project niravCS2103, under directory /CS2103/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/config/.
Source file: PropertySetter.java

/** * Uses JavaBeans {@link Introspector} to computer setters of object to beconfigured. */ protected void introspect(){ try { BeanInfo bi=Introspector.getBeanInfo(obj.getClass()); props=bi.getPropertyDescriptors(); } catch ( IntrospectionException ex) { LogLog.error("Failed to introspect " + obj + ": "+ ex.getMessage()); props=new PropertyDescriptor[0]; } }
Example 64
From project nuxeo-tycho-osgi, under directory /nuxeo-runtime/nuxeo-runtime-management/src/main/java/org/nuxeo/runtime/management/inspector/.
Source file: ModelMBeanIntrospector.java

ModelMBeanInfo introspect(){ if (managementInfo != null) { return managementInfo; } List<Class> ifaces=new ArrayList<Class>(1); if (clazz.isInterface()) { ifaces.add(clazz); } else { doCollectIfaces(ifaces,clazz); } for ( Class iface : ifaces) { BeanInfo beanInfo; try { beanInfo=Introspector.getBeanInfo(iface); } catch ( java.beans.IntrospectionException e) { throw ManagementRuntimeException.wrap("Cannot introspect " + iface,e); } doCollectAttributes(iface,beanInfo); doCollectConstructors(iface,beanInfo); doCollectOperations(iface,beanInfo); doCollectNotifications(iface,beanInfo); } managementInfo=new ModelMBeanInfoSupport(clazz.getCanonicalName(),"",attributesInfo.values().toArray(new ModelMBeanAttributeInfo[attributesInfo.size()]),constructorsInfo.values().toArray(new ModelMBeanConstructorInfo[constructorsInfo.size()]),operationsInfo.values().toArray(new ModelMBeanOperationInfo[operationsInfo.size()]),notificationsInfo.values().toArray(new ModelMBeanNotificationInfo[notificationsInfo.size()])); return managementInfo; }
Example 65
protected void loadBean() throws IntrospectionException { propertyMap=new HashMap<String,PropertyDescriptor>(); BeanInfo info=Introspector.getBeanInfo(beanClass); PropertyDescriptor[] properties=info.getPropertyDescriptors(); for (int i=0; i < properties.length; i++) { propertyMap.put(properties[i].getName(),properties[i]); } }
Example 66
From project openengsb-connector-promreport, under directory /src/main/java/org/openengsb/connector/promreport/internal/.
Source file: DefaultEventTransformator.java

private List<Data.Attribute> getData(Event event){ List<Data.Attribute> data=new ArrayList<Data.Attribute>(); BeanInfo beanInfo; try { beanInfo=Introspector.getBeanInfo(event.getClass()); PropertyDescriptor[] propertyDescriptors=beanInfo.getPropertyDescriptors(); for ( PropertyDescriptor p : propertyDescriptors) { if (!p.getName().equals("processId") && !p.getName().equals("name") && !p.getName().equals("type")) { try { Data.Attribute att=new Data.Attribute(); att.setName(p.getName()); Method readMethod=p.getReadMethod(); if (readMethod != null) { att.setValue(String.valueOf(readMethod.invoke(event))); } data.add(att); } catch ( IllegalAccessException e) { LOGGER.warn("An attribute couldn't be read",e); } catch ( InvocationTargetException e) { LOGGER.warn("Underlying Method throws an exception.",e); } } } } catch ( IntrospectionException e) { LOGGER.warn("An exception occurs during introspection. No attribute was set.",e); } return data; }
Example 67
From project openengsb-framework, under directory /components/util/src/main/java/org/openengsb/core/util/.
Source file: BeanUtilsExtended.java

/** * Analyzes the bean and returns a map containing the property-values. Works similar to {@link BeanUtils#describe(Object)} but does not convert everything to strings. * @throws IllegalArgumentException if the bean cannot be analyzed properly. Probably because some getter throw anException */ public static Map<String,Object> buildObjectAttributeMap(Object bean) throws IllegalArgumentException { BeanInfo beanInfo; try { beanInfo=Introspector.getBeanInfo(bean.getClass(),Object.class); } catch ( IntrospectionException e1) { throw new IllegalArgumentException(e1); } Map<String,Object> result; result=Maps.newHashMap(); for ( PropertyDescriptor pDesc : beanInfo.getPropertyDescriptors()) { String name=pDesc.getName(); Object propertyValue; try { propertyValue=pDesc.getReadMethod().invoke(bean); } catch ( IllegalAccessException e) { LOGGER.error("WTF: got property descriptor with inaccessible read-method"); throw new IllegalStateException(e); } catch ( InvocationTargetException e) { ReflectionUtils.handleInvocationTargetException(e); throw new IllegalStateException("Should never get here"); } if (propertyValue != null) { result.put(name,propertyValue); } } return result; }
Example 68
From project org.openscada.atlantis, under directory /org.openscada.da.core.common/src/org/openscada/da/core/.
Source file: VariantBeanHelper.java

/** * Extract the property data as string/variant map * @param source the source object * @return the map with bean data * @throws IntrospectionException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InvocationTargetException */ public static Map<String,Variant> extract(final Object source) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { final Map<String,Variant> result=new HashMap<String,Variant>(); final BeanInfo bi=Introspector.getBeanInfo(source.getClass()); for ( final PropertyDescriptor pd : bi.getPropertyDescriptors()) { final Method m=pd.getReadMethod(); if (m != null) { result.put(pd.getName(),Variant.valueOf(m.invoke(source))); } } return result; }
Example 69
From project org.openscada.aurora, under directory /org.openscada.utils.filter/src/org/openscada/utils/filter/bean/.
Source file: BeanMatcher.java

protected static PropertyDescriptor getProperyDescriptor(final Class<?> clazz,final String name) throws Exception { final BeanInfo bi=Introspector.getBeanInfo(clazz); for ( final PropertyDescriptor pd : bi.getPropertyDescriptors()) { if (pd.getName().equals(name)) { return pd; } } return null; }
Example 70
From project org.ops4j.pax.logging, under directory /pax-logging-service/src/main/java/org/apache/log4j/config/.
Source file: PaxPropertySetter.java

/** * Uses JavaBeans {@link Introspector} to computer setters of object to beconfigured. */ protected void introspect(){ try { BeanInfo bi=Introspector.getBeanInfo(obj.getClass()); props=bi.getPropertyDescriptors(); } catch ( IntrospectionException ex) { LogLog.error("Failed to introspect " + obj + ": "+ ex.getMessage()); props=new PropertyDescriptor[0]; } }
Example 71
From project pivote-java, under directory /protocol/src/main/java/ch/piratenpartei/pivote/serialize/util/.
Source file: SerializerBuilder.java

private static Map<String,PropertyDescriptor> getProperties(Class<?> type){ PropertyDescriptor[] properties; try { properties=Introspector.getBeanInfo(type).getPropertyDescriptors(); } catch ( IntrospectionException e) { throw new BeanException("Error introspecting " + type); } Map<String,PropertyDescriptor> result=new HashMap<String,PropertyDescriptor>(properties.length); for ( PropertyDescriptor descriptor : properties) { result.put(descriptor.getName(),descriptor); } return result; }
Example 72
From project plugin-WoT-staging, under directory /src/plugins/WebOfTrust/introduction/captcha/kaptcha/jhlabs/image/.
Source file: TransitionFilter.java

/** * Construct a TransitionFilter. * @param filter the filter to use * @param property the filter property which is changed over the transition * @param minValue the start value for the filter property * @param maxValue the end value for the filter property */ public TransitionFilter(BufferedImageOp filter,String property,float minValue,float maxValue){ this.filter=filter; this.property=property; this.minValue=minValue; this.maxValue=maxValue; try { BeanInfo info=Introspector.getBeanInfo(filter.getClass()); PropertyDescriptor[] pds=info.getPropertyDescriptors(); for (int i=0; i < pds.length; i++) { PropertyDescriptor pd=pds[i]; if (property.equals(pd.getName())) { method=pd.getWriteMethod(); break; } } if (method == null) throw new IllegalArgumentException("No such property in object: " + property); } catch ( IntrospectionException e) { throw new IllegalArgumentException(e.toString()); } }
Example 73
From project polyglot-maven, under directory /pmaven-yaml/src/main/java/org/sonatype/maven/polyglot/yaml/.
Source file: ModelRepresenter.java

private Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { Set<Property> properties=new TreeSet<Property>(); for ( PropertyDescriptor property : Introspector.getBeanInfo(type).getPropertyDescriptors()) if (property.getWriteMethod() != null && property.getReadMethod() != null && !property.getReadMethod().getName().equals("getClass") && !property.getReadMethod().getName().endsWith("AsMap") && !property.getReadMethod().getName().equals("getModelEncoding")) { properties.add(new MethodProperty(property)); } for ( Field field : type.getFields()) { int modifiers=field.getModifiers(); if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) continue; properties.add(new FieldProperty(field)); } if (properties.isEmpty()) { throw new YAMLException("No JavaBean properties found in " + type.getName()); } return properties; }
Example 74
From project Possom, under directory /data-model-api/src/main/java/no/sesat/search/datamodel/generic/.
Source file: MapDataObjectBeanInfo.java

/** * @param name * @param cls * @return */ public static PropertyDescriptor[] addSingleMappedPropertyDescriptor(final String name,final Class<?> cls){ try { final PropertyDescriptor[] existing=Introspector.getBeanInfo(cls,Introspector.IGNORE_ALL_BEANINFO).getPropertyDescriptors(); Introspector.flushFromCaches(cls); final PropertyDescriptor[] result=new PropertyDescriptor[existing.length + 2]; System.arraycopy(existing,0,result,0,existing.length); result[existing.length]=new MappedPropertyDescriptor(name,cls); if (!System.getProperty("java.version").startsWith("1.6")) { fixForJavaBug4984912(cls,(MappedPropertyDescriptor)result[existing.length]); } final String captialised=Character.toUpperCase(name.charAt(0)) + name.substring(1); try { result[existing.length + 1]=new PropertyDescriptor(name + 's',cls,"get" + captialised + 's',null); } catch ( IntrospectionException ie) { result[existing.length + 1]=new PropertyDescriptor(name + "es",cls,"get" + captialised + 's',null); } return result; } catch ( IntrospectionException ex) { LOG.error(ex.getMessage(),ex); throw new IllegalStateException('[' + cls.getSimpleName() + ']'+ ex.getMessage(),ex); } }
Example 75
From project processFlowProvision, under directory /pfpServices/adminConsole/src/main/java/org/jboss/processFlow/console/binding/.
Source file: AbstractDataBinder.java

/** * Get the bean properties as <code>java.uti.Map</code> * @param bean * @return * @throws IntrospectionException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InvocationTargetException */ protected Map getProperties(Object bean) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Map<String,Object> properties=new HashMap<String,Object>(); BeanInfo bi=Introspector.getBeanInfo(bean.getClass()); PropertyDescriptor[] props=bi.getPropertyDescriptors(); for (int i=0; i < props.length; i++) { Method getter=props[i].getReadMethod(); if (getter == null) continue; String name=props[i].getName(); Object result=getter.invoke(bean,NULL_ARG); properties.put(name,result); } return properties; }
Example 76
From project querydsl, under directory /querydsl-core/src/main/java/com/mysema/util/.
Source file: BeanMap.java

private void initialise(){ if (getBean() == null) { return; } Class<?> beanClass=getBean().getClass(); try { BeanInfo beanInfo=Introspector.getBeanInfo(beanClass); PropertyDescriptor[] propertyDescriptors=beanInfo.getPropertyDescriptors(); if (propertyDescriptors != null) { for (int i=0; i < propertyDescriptors.length; i++) { PropertyDescriptor propertyDescriptor=propertyDescriptors[i]; if (propertyDescriptor != null) { String name=propertyDescriptor.getName(); Method readMethod=propertyDescriptor.getReadMethod(); Method writeMethod=propertyDescriptor.getWriteMethod(); Class<?> aType=propertyDescriptor.getPropertyType(); if (readMethod != null) { readMethods.put(name,readMethod); } if (writeMethods != null) { writeMethods.put(name,writeMethod); } types.put(name,aType); } } } } catch ( IntrospectionException e) { } }
Example 77
From project rabbitmq-java-client, under directory /src/com/rabbitmq/tools/json/.
Source file: JSONUtil.java

/** * Uses reflection to fill public fields and optionally Bean properties of the target object from the source Map. */ public static Object fill(Object target,Map<String,Object> source,boolean useProperties) throws IntrospectionException, IllegalAccessException, InvocationTargetException { if (useProperties) { BeanInfo info=Introspector.getBeanInfo(target.getClass()); PropertyDescriptor[] props=info.getPropertyDescriptors(); for (int i=0; i < props.length; ++i) { PropertyDescriptor prop=props[i]; String name=prop.getName(); Method setter=prop.getWriteMethod(); if (setter != null && !Modifier.isStatic(setter.getModifiers())) { setter.invoke(target,new Object[]{source.get(name)}); } } } Field[] ff=target.getClass().getDeclaredFields(); for (int i=0; i < ff.length; ++i) { Field field=ff[i]; int fieldMod=field.getModifiers(); if (Modifier.isPublic(fieldMod) && !(Modifier.isFinal(fieldMod) || Modifier.isStatic(fieldMod))) { try { field.set(target,source.get(field.getName())); } catch ( IllegalArgumentException iae) { } } } return target; }
Example 78
From project rapid, under directory /rapid-generator/rapid-generator/src/main/java/cn/org/rapid_framework/generator/provider/java/model/.
Source file: JavaClass.java

public JavaProperty[] getProperties() throws Exception { List<JavaProperty> result=new ArrayList<JavaProperty>(); BeanInfo beanInfo=Introspector.getBeanInfo(clazz); PropertyDescriptor[] pds=beanInfo.getPropertyDescriptors(); for ( PropertyDescriptor pd : pds) { if (!"class".equalsIgnoreCase(pd.getName())) { result.add(new JavaProperty(pd,this)); } } return (JavaProperty[])result.toArray(new JavaProperty[0]); }
Example 79
From project recommenders, under directory /tests/org.eclipse.recommenders.tests.rcp/src/org/eclipse/recommenders/tests/rcp/models/.
Source file: MetadataTest.java

@Test public void testGetters() throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { BeanInfo info=Introspector.getBeanInfo(ModelArchiveMetadata.class); for ( PropertyDescriptor d : info.getPropertyDescriptors()) { Method m=d.getReadMethod(); m.invoke(sut); } }
Example 80
From project red5-mavenized, under directory /red5_tomcat/src/main/java/org/red5/server/war/.
Source file: WarLoaderServlet.java

/** * Clearing the in-memory configuration parameters, we will receive notification that the servlet context is about to be shut down */ @Override public void contextDestroyed(ServletContextEvent sce){ synchronized (servletContext) { logger.info("Webapp shutdown"); try { ServletContext ctx=sce.getServletContext(); Introspector.flushCaches(); for (Enumeration<?> e=DriverManager.getDrivers(); e.hasMoreElements(); ) { Driver driver=(Driver)e.nextElement(); if (driver.getClass().getClassLoader() == getClass().getClassLoader()) { DriverManager.deregisterDriver(driver); } } JMXAgent.shutdown(); FilePersistenceThread persistenceThread=FilePersistenceThread.getInstance(); if (persistenceThread != null) { persistenceThread.shutdown(); } Object attr=ctx.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (attr != null) { ConfigurableWebApplicationContext applicationContext=(ConfigurableWebApplicationContext)attr; ConfigurableBeanFactory factory=applicationContext.getBeanFactory(); try { for ( String singleton : factory.getSingletonNames()) { logger.debug("Registered singleton: {}",singleton); factory.destroyScopedBean(singleton); } } catch ( RuntimeException e) { } factory.destroySingletons(); ctx.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); applicationContext.close(); } getContextLoader().closeWebApplicationContext(ctx); } catch ( Throwable e) { e.printStackTrace(); } } }
Example 81
From project rewrite, under directory /integration-cdi/src/main/java/org/ocpsoft/rewrite/cdi/util/.
Source file: Reflections.java

/** * Gets the property name from a getter method. <p/> We extend JavaBean conventions, allowing the getter method to have parameters * @param method The getter method * @return The name of the property. Returns null if method wasn't JavaBeangetter-styled */ public static String getPropertyName(Method method){ String methodName=method.getName(); if (methodName.matches("^(get).*")) { return Introspector.decapitalize(methodName.substring(3)); } else if (methodName.matches("^(is).*")) { return Introspector.decapitalize(methodName.substring(2)); } else { return null; } }
Example 82
From project rhevm-api, under directory /api/src/main/java/com/redhat/rhevm/api/resteasy/yaml/.
Source file: CustomBeanWrapper.java

public CustomBeanWrapper(Class type){ super(type); try { for ( PropertyDescriptor prop : Introspector.getBeanInfo(type).getPropertyDescriptors()) { if (prop.getReadMethod() != null && prop.getWriteMethod() == null && prop.getPropertyType().isAssignableFrom(List.class)) { extraKeys.add(prop.getName()); } } } catch ( IntrospectionException e) { } }
Example 83
From project saiku-adhoc, under directory /saiku-adhoc-core/src/main/java/org/saiku/adhoc/utils/.
Source file: TemplateUtils.java

public static void mergeElementFormats(SaikuElementFormat source,SaikuElementFormat target) throws Exception { BeanInfo beanInfo=Introspector.getBeanInfo(target.getClass()); for ( PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) { if (descriptor.getWriteMethod() != null) { Object sourceValue=descriptor.getReadMethod().invoke(source); if (sourceValue != null) { descriptor.getWriteMethod().invoke(target,sourceValue); } } } }
Example 84
From project servicemix4-specs, under directory /jaxb-api-2.1/src/main/java/javax/xml/bind/.
Source file: JAXB.java

public static void marshal(Object object,Result result){ try { JAXBContext context; if (object instanceof JAXBElement) { context=getContext(((JAXBElement<?>)object).getDeclaredType()); } else { Class<?> clazz=object.getClass(); XmlRootElement r=clazz.getAnnotation(XmlRootElement.class); if (r == null) { object=new JAXBElement(new QName(Introspector.decapitalize(clazz.getSimpleName())),clazz,object); } context=getContext(clazz); } Marshaller m=context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); m.marshal(object,result); } catch ( JAXBException e) { throw new DataBindingException(e); } }
Example 85
From project shiro, under directory /support/faces/src/main/java/org/apache/shiro/web/faces/tags/.
Source file: PrincipalTag.java

private String getPrincipalProperty(Object principal,String property) throws IOException { String strValue=null; try { BeanInfo bi=Introspector.getBeanInfo(principal.getClass()); boolean foundProperty=false; for ( PropertyDescriptor pd : bi.getPropertyDescriptors()) { if (pd.getName().equals(property) && (Modifier.isPublic(pd.getReadMethod().getModifiers()))) { Object value=null; try { pd.getReadMethod().setAccessible(true); value=pd.getReadMethod().invoke(principal,(Object[])null); } finally { pd.getReadMethod().setAccessible(false); } strValue=String.valueOf(value); foundProperty=true; break; } } if (!foundProperty) { final String message="Property [" + property + "] not found in principal of type ["+ principal.getClass().getName()+ "]"; if (log.isErrorEnabled()) { log.error(message); } throw new IOException(message); } } catch ( Exception e) { final String message="Error reading property [" + property + "] from principal of type ["+ principal.getClass().getName()+ "]"; if (log.isErrorEnabled()) { log.error(message,e); } throw new IOException(message); } return strValue; }
Example 86
From project SIARD-Val, under directory /SIARD-Val/external-sources/log4j-1.2.12/java/org/apache/log4j/config/.
Source file: PropertySetter.java

/** * Uses JavaBeans {@link Introspector} to computer setters of object to beconfigured. */ protected void introspect(){ try { BeanInfo bi=Introspector.getBeanInfo(obj.getClass()); props=bi.getPropertyDescriptors(); } catch ( IntrospectionException ex) { LogLog.error("Failed to introspect " + obj + ": "+ ex.getMessage()); props=new PropertyDescriptor[0]; } }
Example 87
From project sitebricks, under directory /sitebricks/src/main/java/com/google/sitebricks/binding/.
Source file: ConcurrentPropertyCache.java

public boolean exists(String property,Class<?> anObjectClass){ Map<String,String> properties=cache.get(anObjectClass); if (null == properties) { PropertyDescriptor[] propertyDescriptors; try { propertyDescriptors=Introspector.getBeanInfo(anObjectClass).getPropertyDescriptors(); } catch ( IntrospectionException e) { throw new IllegalArgumentException(); } properties=new LinkedHashMap<String,String>(); for ( PropertyDescriptor descriptor : propertyDescriptors) { properties.put(descriptor.getName(),descriptor.getName()); } cache.putIfAbsent(anObjectClass,properties); } return properties.containsKey(property); }
Example 88
From project socialpm, under directory /gwt/src/main/java/com/ocpsoft/socialpm/gwt/server/util/.
Source file: HibernateDetachUtility.java

private static void nullOutFieldsByAccessors(Object value,Map<Integer,Object> checkedObjects,Map<Integer,List<Object>> checkedObjectCollisionMap,int depth,SerializationType serializationType) throws Exception { BeanInfo bi=Introspector.getBeanInfo(value.getClass(),Object.class); PropertyDescriptor[] pds=bi.getPropertyDescriptors(); for ( PropertyDescriptor pd : pds) { Object propertyValue=null; try { propertyValue=pd.getReadMethod().invoke(value); } catch ( Throwable lie) { if (log.isDebugEnabled()) { log.debug("Couldn't load: " + pd.getName() + " off of "+ value.getClass().getSimpleName(),lie); } } if (!Hibernate.isInitialized(propertyValue)) { try { if (log.isDebugEnabled()) { log.debug("Nulling out: " + pd.getName() + " off of "+ value.getClass().getSimpleName()); } Method writeMethod=pd.getWriteMethod(); if ((writeMethod != null) && (writeMethod.getAnnotation(XmlTransient.class) == null)) { pd.getWriteMethod().invoke(value,new Object[]{null}); } else { nullOutField(value,pd.getName()); } } catch ( Exception lie) { log.debug("Couldn't null out: " + pd.getName() + " off of "+ value.getClass().getSimpleName()+ " trying field access",lie); nullOutField(value,pd.getName()); } } else { if ((propertyValue instanceof Collection) || ((propertyValue != null) && validType(propertyValue))) { nullOutUninitializedFields(propertyValue,checkedObjects,checkedObjectCollisionMap,depth + 1,serializationType); } } } }
Example 89
From project solder, under directory /api/src/main/java/org/jboss/solder/reflection/.
Source file: Reflections.java

/** * Gets the property name from a getter method. <p/> We extend JavaBean conventions, allowing the getter method to have parameters * @param method The getter method * @return The name of the property. Returns null if method wasn't JavaBeangetter-styled */ public static String getPropertyName(Method method){ String methodName=method.getName(); if (methodName.matches("^(get).*")) { return Introspector.decapitalize(methodName.substring(3)); } else if (methodName.matches("^(is).*")) { return Introspector.decapitalize(methodName.substring(2)); } else { return null; } }
Example 90
From project spring-data-commons, under directory /spring-data-commons-core/src/main/java/org/springframework/data/mapping/context/.
Source file: AbstractMappingContext.java

/** * Adds the given {@link TypeInformation} to the {@link MappingContext}. * @param typeInformation * @return */ protected E addPersistentEntity(TypeInformation<?> typeInformation){ E persistentEntity=persistentEntities.get(typeInformation); if (persistentEntity != null) { return persistentEntity; } Class<?> type=typeInformation.getType(); try { write.lock(); final E entity=createPersistentEntity(typeInformation); persistentEntities.put(typeInformation,entity); BeanInfo info=Introspector.getBeanInfo(type); final Map<String,PropertyDescriptor> descriptors=new HashMap<String,PropertyDescriptor>(); for ( PropertyDescriptor descriptor : info.getPropertyDescriptors()) { descriptors.put(descriptor.getName(),descriptor); } ReflectionUtils.doWithFields(type,new PersistentPropertyCreator(entity,descriptors),PersistentFieldFilter.INSTANCE); try { entity.verify(); } catch ( MappingException e) { persistentEntities.remove(typeInformation); throw e; } if (null != applicationEventPublisher) { applicationEventPublisher.publishEvent(new MappingContextEvent<E,P>(this,entity)); } return entity; } catch ( IntrospectionException e) { throw new MappingException(e.getMessage(),e); } finally { write.unlock(); } }
Example 91
From project spring-framework-issues, under directory /SPR-9702/src/test/java/org/springframework/beans/.
Source file: ReproTests.java

@Test public void tester() throws Exception { final Class<?> c=Vehicle.class; Introspector.flushCaches(); Introspector.getBeanInfo(c); while (true) { System.out.println("test"); new ExtendedBeanInfo(Introspector.getBeanInfo(c)); System.out.println("allocate"); allocate(); } }
Example 92
From project spring-js, under directory /src/main/java/org/springframework/context/annotation/.
Source file: CommonAnnotationBeanPostProcessor.java

@Override protected void initAnnotation(AnnotatedElement ae){ Resource resource=ae.getAnnotation(Resource.class); String resourceName=resource.name(); Class resourceType=resource.type(); this.isDefaultName=!StringUtils.hasLength(resourceName); if (this.isDefaultName) { resourceName=this.member.getName(); if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) { resourceName=Introspector.decapitalize(resourceName.substring(3)); } } else if (beanFactory instanceof ConfigurableBeanFactory) { resourceName=((ConfigurableBeanFactory)beanFactory).resolveEmbeddedValue(resourceName); } if (resourceType != null && !Object.class.equals(resourceType)) { checkResourceType(resourceType); } else { resourceType=getResourceType(); } this.name=resourceName; this.lookupType=resourceType; this.mappedName=resource.mappedName(); this.shareable=resource.shareable(); }
Example 93
From project SpringSecurityDemo, under directory /src/test/java/com/github/peholmst/springsecuritydemo/domain/.
Source file: AbstractEntityTest.java

@Test public void testWritableProperties() throws Exception { System.out.println("testWritableProperties"); BeanInfo info=Introspector.getBeanInfo(getEntity().getClass()); for ( PropertyDescriptor pd : info.getPropertyDescriptors()) { if (pd.getWriteMethod() != null) { Object testData=createRandomValue(pd.getPropertyType()); System.out.println(" Testing property " + pd.getName()); pd.getWriteMethod().invoke(getEntity(),testData); assertEquals("Returned property value should be equal to the set property value",testData,pd.getReadMethod().invoke(getEntity())); } } }
Example 94
From project teatrove, under directory /trove/src/main/java/org/teatrove/trove/classfile/.
Source file: ClassFile.java

private static MethodDescriptor lookupMethodDescriptor(Method method){ MethodDescriptor methodDescriptor=null; try { for ( MethodDescriptor methodDescriptor1 : Introspector.getBeanInfo(method.getDeclaringClass()).getMethodDescriptors()) { if (methodDescriptor1.getMethod() == method) { methodDescriptor=methodDescriptor1; break; } } } catch ( IntrospectionException e) { throw new RuntimeException("Unable to find MethodDescriptor for method " + method,e); } return methodDescriptor; }
Example 95
From project thymeleaf, under directory /src/main/java/org/thymeleaf/util/.
Source file: DartUtils.java

private static void printObject(final StringBuilder output,final Object object){ try { final PropertyDescriptor[] descriptors=Introspector.getBeanInfo(object.getClass()).getPropertyDescriptors(); final Map<String,Object> properties=new LinkedHashMap<String,Object>(descriptors.length + 1,1.0f); for ( final PropertyDescriptor descriptor : descriptors) { final Method readMethod=descriptor.getReadMethod(); if (readMethod != null) { final String name=descriptor.getName(); if (!name.toLowerCase().equals("class")) { final Object value=readMethod.invoke(object); properties.put(name,value); } } } printMap(output,properties); } catch ( final IllegalAccessException e) { throw new IllegalArgumentException("Could not perform introspection on object of class " + object.getClass().getName(),e); } catch ( final InvocationTargetException e) { throw new IllegalArgumentException("Could not perform introspection on object of class " + object.getClass().getName(),e); } catch ( final IntrospectionException e) { throw new IllegalArgumentException("Could not perform introspection on object of class " + object.getClass().getName(),e); } }
Example 96
From project tiles-request, under directory /tiles-request-api/src/main/java/org/apache/tiles/request/reflect/.
Source file: ClassUtil.java

/** * Collects bean infos from a class and filling a list. * @param clazz The class to be inspected. * @param name2descriptor The map in the form: name of the property ->descriptor. */ public static void collectBeanInfo(Class<?> clazz,Map<String,PropertyDescriptor> name2descriptor){ Logger log=LoggerFactory.getLogger(ClassUtil.class); BeanInfo info=null; try { info=Introspector.getBeanInfo(clazz); } catch ( Exception ex) { if (log.isDebugEnabled()) { log.debug("Cannot inspect class " + clazz,ex); } } if (info == null) { return; } for ( PropertyDescriptor pd : info.getPropertyDescriptors()) { pd.setValue("type",pd.getPropertyType()); pd.setValue("resolvableAtDesignTime",Boolean.TRUE); name2descriptor.put(pd.getName(),pd); } }
Example 97
From project torpedoquery, under directory /src/main/java/org/torpedoquery/jpa/internal/utils/.
Source file: FieldUtils.java

public static String getFieldName(Method method){ String name=method.getName(); if (name.startsWith("get")) { name=name.substring(3); } else if (name.startsWith("is")) { name=name.substring(2); } name=Introspector.decapitalize(name); return name; }