/**
* Extract a filtered set of PropertyDescriptors from the given BeanWrapper,
* excluding ignored dependency types or properties defined on ignored dependency interfaces.
* @param bw the BeanWrapper the bean was created with
* @param cache whether to cache filtered PropertyDescriptors for the given bean Class
* @return the filtered PropertyDescriptors
* @see #isExcludedFromDependencyCheck
* @see #filterPropertyDescriptorsForDependencyCheck(org.springframework.beans.BeanWrapper)
*/
protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw, boolean cache) {
PropertyDescriptor[] filtered = this.filteredPropertyDescriptorsCache.get(bw.getWrappedClass());
if (filtered == null) {
if (cache) {
synchronized (this.filteredPropertyDescriptorsCache) {
filtered = this.filteredPropertyDescriptorsCache.get(bw.getWrappedClass());
if (filtered == null) {
filtered = filterPropertyDescriptorsForDependencyCheck(bw);
this.filteredPropertyDescriptorsCache.put(bw.getWrappedClass(), filtered);
}
}
}
else {
filtered = filterPropertyDescriptorsForDependencyCheck(bw);
}
}
return filtered;
}
java类java.beans.PropertyDescriptor的实例源码
AbstractAutowireCapableBeanFactory.java 文件源码
项目:lams
阅读 17
收藏 0
点赞 0
评论 0
PropertyUtils.java 文件源码
项目:reflection-util
阅读 20
收藏 0
点赞 0
评论 0
public static void writeDirectly(Object destination, PropertyDescriptor propertyDescriptor, Object value) {
try {
Field field = findField(destination, propertyDescriptor);
boolean accessible = field.isAccessible();
try {
if (!accessible) {
field.setAccessible(true);
}
field.set(destination, value);
} finally {
if (!accessible) {
field.setAccessible(false);
}
}
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new ReflectionRuntimeException("Failed to write " + getQualifiedPropertyName(destination, propertyDescriptor), e);
}
}
ClientInstructionSetCheckedBeanInfo.java 文件源码
项目:convertigo-engine
阅读 14
收藏 0
点赞 0
评论 0
public ClientInstructionSetCheckedBeanInfo() {
try {
beanClass = ClientInstructionSetChecked.class;
additionalBeanClass = com.twinsoft.convertigo.beans.extractionrules.siteclipper.AbstractClientInstructionWithPath.class;
iconNameC16 = "/com/twinsoft/convertigo/beans/extractionrules/siteclipper/images/rule_clientinstructionsetchecked_color_16x16.png";
iconNameC32 = "/com/twinsoft/convertigo/beans/extractionrules/siteclipper/images/rule_clientinstructionsetchecked_color_32x32.png";
resourceBundle = getResourceBundle("res/ClientInstructionSetChecked");
displayName = getExternalizedString("display_name");
shortDescription = getExternalizedString("short_description");
properties = new PropertyDescriptor[1];
properties[0] = new PropertyDescriptor("targetValue", beanClass, "getTargetValue", "setTargetValue");
properties[0].setDisplayName(getExternalizedString("property.targetvalue.display_name"));
properties[0].setShortDescription(getExternalizedString("property.targetvalue.short_description"));
properties[0].setValue("scriptable", Boolean.TRUE);
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
BeanMapUtil.java 文件源码
项目:zooadmin
阅读 21
收藏 0
点赞 0
评论 0
public static Object convertMap2Bean(Class type, Map map)
throws IntrospectionException, IllegalAccessException,
InstantiationException, InvocationTargetException {
BeanInfo beanInfo = Introspector.getBeanInfo(type);
Object obj = type.newInstance();
PropertyDescriptor[] propertyDescriptors = beanInfo
.getPropertyDescriptors();
for (PropertyDescriptor pro : propertyDescriptors) {
String propertyName = pro.getName();
if (pro.getPropertyType().getName().equals("java.lang.Class")) {
continue;
}
if (map.containsKey(propertyName)) {
Object value = map.get(propertyName);
Method setter = pro.getWriteMethod();
setter.invoke(obj, value);
}
}
return obj;
}
BeanUtils.java 文件源码
项目:xmanager
阅读 27
收藏 0
点赞 0
评论 0
/**
* 获取Bean的属性
* @param bean bean
* @param propertyName 属性名
* @return 属性值
*/
public static Object getProperty(Object bean, String propertyName) {
PropertyDescriptor pd = getPropertyDescriptor(bean.getClass(), propertyName);
if (pd == null) {
throw new RuntimeException("Could not read property '" + propertyName + "' from bean PropertyDescriptor is null");
}
Method readMethod = pd.getReadMethod();
if (readMethod == null) {
throw new RuntimeException("Could not read property '" + propertyName + "' from bean readMethod is null");
}
if (!readMethod.isAccessible()) {
readMethod.setAccessible(true);
}
try {
return readMethod.invoke(bean);
} catch (Throwable ex) {
throw new RuntimeException("Could not read property '" + propertyName + "' from bean", ex);
}
}
UIStyleBeanInfo.java 文件源码
项目:convertigo-engine
阅读 14
收藏 0
点赞 0
评论 0
public UIStyleBeanInfo() {
try {
beanClass = UIStyle.class;
additionalBeanClass = com.twinsoft.convertigo.beans.mobile.components.UIComponent.class;
iconNameC16 = "/com/twinsoft/convertigo/beans/mobile/components/images/uistyle_color_16x16.png";
iconNameC32 = "/com/twinsoft/convertigo/beans/mobile/components/images/uistyle_color_32x32.png";
resourceBundle = getResourceBundle("res/UIStyle");
displayName = resourceBundle.getString("display_name");
shortDescription = resourceBundle.getString("short_description");
properties = new PropertyDescriptor[1];
properties[0] = new PropertyDescriptor("styleContent", beanClass, "getStyleContent", "setStyleContent");
properties[0].setDisplayName(getExternalizedString("property.styleContent.display_name"));
properties[0].setShortDescription(getExternalizedString("property.styleContent.short_description"));
properties[0].setHidden(true);
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
DatasourceServletAction.java 文件源码
项目:ureport
阅读 16
收藏 0
点赞 0
评论 0
public void buildClass(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String clazz=req.getParameter("clazz");
List<Field> result=new ArrayList<Field>();
try{
Class<?> targetClass=Class.forName(clazz);
PropertyDescriptor[] propertyDescriptors=PropertyUtils.getPropertyDescriptors(targetClass);
for(PropertyDescriptor pd:propertyDescriptors){
String name=pd.getName();
if("class".equals(name)){
continue;
}
result.add(new Field(name));
}
writeObjectToJson(resp, result);
}catch(Exception ex){
throw new ReportDesignException(ex);
}
}
SerialStepBeanInfo.java 文件源码
项目:convertigo-engine
阅读 13
收藏 0
点赞 0
评论 0
public SerialStepBeanInfo() {
try {
beanClass = SerialStep.class;
additionalBeanClass = com.twinsoft.convertigo.beans.steps.BranchStep.class;
iconNameC16 = "/com/twinsoft/convertigo/beans/steps/images/serial_16x16.png";
iconNameC32 = "/com/twinsoft/convertigo/beans/steps/images/serial_32x32.png";
resourceBundle = getResourceBundle("res/SerialStep");
displayName = resourceBundle.getString("display_name");
shortDescription = resourceBundle.getString("short_description");
PropertyDescriptor property = getPropertyDescriptor("maxNumberOfThreads");
property.setHidden(true) ;
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
DefaultPropertyModelTest.java 文件源码
项目:incubator-netbeans
阅读 14
收藏 0
点赞 0
评论 0
public void testUsageOfExplicitPropertyDescriptor() throws Exception {
PropertyDescriptor pd = new PropertyDescriptor(
"myProp", this.getClass(),
"getterUsageOfExplicitPropertyDescriptor",
"setterUsageOfExplicitPropertyDescriptor"
);
DefaultPropertyModel model = new DefaultPropertyModel(this, pd);
assertEquals("Getter returns this", model.getValue(), this);
String msgToThrow = "msgToThrow";
try {
model.setValue(msgToThrow);
fail("Setter should throw an exception");
} catch (InvocationTargetException ex) {
// when an exception occurs it should throw InvocationTargetException
assertEquals("The right message", msgToThrow, ex.getTargetException().getMessage());
}
}
XMLHttpHeadersBeanInfo.java 文件源码
项目:convertigo-engine
阅读 15
收藏 0
点赞 0
评论 0
public XMLHttpHeadersBeanInfo() {
try {
beanClass = XMLHttpHeaders.class;
additionalBeanClass = com.twinsoft.convertigo.beans.extractionrules.HtmlExtractionRule.class;
iconNameC16 = "/com/twinsoft/convertigo/beans/common/images/xmlhttpheaders_color_16x16.png";
iconNameC32 = "/com/twinsoft/convertigo/beans/common/images/xmlhttpheaders_color_32x32.png";
resourceBundle = getResourceBundle("res/XMLHttpHeaders");
displayName = getExternalizedString("display_name");
shortDescription = getExternalizedString("short_description");
PropertyDescriptor property = getPropertyDescriptor("xpath");
property.setHidden(true);
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
ObjectUtil.java 文件源码
项目:FCat
阅读 33
收藏 0
点赞 0
评论 0
/**
* 对象到map
* @param obj
* @return
*/
public static Map<String, Object> objectToMap(Object obj) {
Map<String, Object> map = new HashMap<String, Object>();
if(obj == null) {
return map;
}
try{
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor property : propertyDescriptors) {
String key = property.getName();
if (key.compareToIgnoreCase("class") == 0) {
continue;
}
Method getter = property.getReadMethod();
Object value = getter!=null ? getter.invoke(obj) : null;
map.put(key, value);
}
}catch(Exception e) {
logger.error(e.getMessage());
}
return map;
}
Enums.java 文件源码
项目:Dude
阅读 22
收藏 0
点赞 0
评论 0
/**
* 获取枚举中指定属性的值
*
* @param enumCls 枚举类型
* @param prop Bean属性名
* @return (枚举值, 指定属性的值)
*/
public static Map<Enum<?>, Object> getEnumAndValue(Class<?> enumCls, String prop) {
Object[] enumValues = enumCls.getEnumConstants();
if (isEmpty(enumValues)) {
return newLinkedHashMap();
}
Map<Enum<?>, Object> result = newLinkedHashMapWithExpectedSize(enumValues.length * 2);
try {
for (Object enumValue : enumValues) {
PropertyDescriptor pd = getPropertyDescriptor(enumValue, prop);
if (pd == null || pd.getReadMethod() == null) {
continue;
}
result.put((Enum<?>) enumValue, pd.getReadMethod().invoke(enumValue));
}
} catch (Exception e) {
// ignore
}
return result;
}
MetadataMBeanInfoAssembler.java 文件源码
项目:lams
阅读 19
收藏 0
点赞 0
评论 0
/**
* Retrieves the description for the supplied {@code Method} from the
* metadata. Uses the method name is no description is present in the metadata.
*/
@Override
protected String getOperationDescription(Method method, String beanKey) {
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
if (pd != null) {
ManagedAttribute ma = this.attributeSource.getManagedAttribute(method);
if (ma != null && StringUtils.hasText(ma.getDescription())) {
return ma.getDescription();
}
ManagedMetric metric = this.attributeSource.getManagedMetric(method);
if (metric != null && StringUtils.hasText(metric.getDescription())) {
return metric.getDescription();
}
return method.getName();
}
else {
ManagedOperation mo = this.attributeSource.getManagedOperation(method);
if (mo != null && StringUtils.hasText(mo.getDescription())) {
return mo.getDescription();
}
return method.getName();
}
}
ReflectionUtils.java 文件源码
项目:spring-rest-commons-options
阅读 31
收藏 0
点赞 0
评论 0
private static void collectParameters(Collection<Parameters> parameters, Parameter parameter, Annotation a,
boolean isPathVariable) {
if (a != null) {
String typeStr = parameter.getType().getSimpleName();
Type type = parameter.getParameterizedType();
if (type instanceof ParameterizedType) {
typeStr = ((Class<?>) ((ParameterizedType) type).getActualTypeArguments()[0]).getSimpleName();
}
parameters.add(new Parameters((boolean) AnnotationUtils.getValue(a, "required"),
(String) (AnnotationUtils.getValue(a).equals("") ? parameter.getName()
: AnnotationUtils.getValue(a)),
typeStr));
} else if (Pageable.class.isAssignableFrom(parameter.getType()) && !isPathVariable) {
try {
for (PropertyDescriptor propertyDescriptor : Introspector.getBeanInfo(parameter.getType())
.getPropertyDescriptors()) {
parameters.add(new Parameters(false, propertyDescriptor.getName(),
propertyDescriptor.getPropertyType().getSimpleName()));
}
} catch (IntrospectionException e) {
LOGGER.error("Problemas al obtener el Pageable: {}", parameter, e);
}
}
}
InjectorBeanInfo.java 文件源码
项目:convertigo-engine
阅读 12
收藏 0
点赞 0
评论 0
public InjectorBeanInfo() {
try {
beanClass = Injector.class;
additionalBeanClass = com.twinsoft.convertigo.beans.extractionrules.siteclipper.BaseRule.class;
resourceBundle = getResourceBundle("res/Injector");
properties = new PropertyDescriptor[2];
properties[0] = new PropertyDescriptor("location", beanClass, "getLocation", "setLocation");
properties[0].setDisplayName(getExternalizedString("property.location.display_name"));
properties[0].setShortDescription(getExternalizedString("property.location.short_description"));
properties[0].setPropertyEditorClass(HtmlLocation.class);
properties[1] = new PropertyDescriptor("customRegexp", beanClass, "getCustomRegexp", "setCustomRegexp");
properties[1].setDisplayName(getExternalizedString("property.customRegexp.display_name"));
properties[1].setShortDescription(getExternalizedString("property.customRegexp.short_description"));
properties[1].setExpert(true);
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
ModelStrategy.java 文件源码
项目:spring-rest-commons-options
阅读 20
收藏 0
点赞 0
评论 0
private List<DetailField> createDetail(Class<?> c, boolean isRequest) {
List<DetailField> detailFields = new ArrayList<>();
ReflectionUtils.getGenericClass(c).ifPresent(clazz -> {
try {
for (PropertyDescriptor propertyDescriptor : Introspector.getBeanInfo(clazz, Object.class)
.getPropertyDescriptors()) {
if (!propertyDescriptor.getReadMethod().getDeclaringClass().equals(Object.class)) {
Optional<Field> field = getField(clazz, propertyDescriptor);
if (checkIfAddField(field, propertyDescriptor, isRequest)) {
Optional<DetailField> detail = super.createDetail(propertyDescriptor, field, isRequest);
detail.ifPresent(detailFields::add);
}
}
}
} catch (Exception e) {
LOGGER.error("Error al inspeccionar la clase {}", clazz, e);
}
});
return detailFields;
}
CriteriaWithRegexBeanInfo.java 文件源码
项目:convertigo-engine
阅读 14
收藏 0
点赞 0
评论 0
public CriteriaWithRegexBeanInfo() {
try {
beanClass = CriteriaWithRegex.class;
additionalBeanClass = com.twinsoft.convertigo.beans.criteria.siteclipper.BaseCriteria.class;
resourceBundle = getResourceBundle("res/CriteriaWithRegex");
properties = new PropertyDescriptor[1];
properties[0] = new PropertyDescriptor("regexp", beanClass, "getRegexp", "setRegexp");
properties[0].setDisplayName(getExternalizedString("property.regexp.display_name"));
properties[0].setShortDescription(getExternalizedString("property.regexp.short_description"));
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
ExtendedBeanInfo.java 文件源码
项目:lams
阅读 23
收藏 0
点赞 0
评论 0
public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target)
throws IntrospectionException {
target.setExpert(source.isExpert());
target.setHidden(source.isHidden());
target.setPreferred(source.isPreferred());
target.setName(source.getName());
target.setShortDescription(source.getShortDescription());
target.setDisplayName(source.getDisplayName());
// Copy all attributes (emulating behavior of private FeatureDescriptor#addTable)
Enumeration<String> keys = source.attributeNames();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
target.setValue(key, source.getValue(key));
}
// See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor)
target.setPropertyEditorClass(source.getPropertyEditorClass());
target.setBound(source.isBound());
target.setConstrained(source.isConstrained());
}
UIPageEventBeanInfo.java 文件源码
项目:convertigo-engine
阅读 18
收藏 0
点赞 0
评论 0
public UIPageEventBeanInfo() {
try {
beanClass = UIPageEvent.class;
additionalBeanClass = com.twinsoft.convertigo.beans.mobile.components.UIComponent.class;
iconNameC16 = "/com/twinsoft/convertigo/beans/mobile/components/images/uipageevent_color_16x16.png";
iconNameC32 = "/com/twinsoft/convertigo/beans/mobile/components/images/uipageevent_color_32x32.png";
resourceBundle = getResourceBundle("res/UIPageEvent");
displayName = resourceBundle.getString("display_name");
shortDescription = resourceBundle.getString("short_description");
properties = new PropertyDescriptor[1];
properties[0] = new PropertyDescriptor("viewEvent", beanClass, "getViewEvent", "setViewEvent");
properties[0].setDisplayName(getExternalizedString("property.viewEvent.display_name"));
properties[0].setShortDescription(getExternalizedString("property.viewEvent.short_description"));
properties[0].setPropertyEditorClass(getEditorClass("StringComboBoxPropertyDescriptor"));
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
InputHtmlSetFileStatementBeanInfo.java 文件源码
项目:convertigo-engine
阅读 14
收藏 0
点赞 0
评论 0
public InputHtmlSetFileStatementBeanInfo() {
try {
beanClass = InputHtmlSetFileStatement.class;
additionalBeanClass = com.twinsoft.convertigo.beans.statements.AbstractEventStatement.class;
iconNameC16 = "/com/twinsoft/convertigo/beans/statements/images/inputhtmlsetfile_16x16.png";
iconNameC32 = "/com/twinsoft/convertigo/beans/statements/images/inputhtmlsetfile_32x32.png";
resourceBundle = getResourceBundle("res/InputHtmlSetFileStatement");
displayName = resourceBundle.getString("display_name");
shortDescription = resourceBundle.getString("short_description");
properties = new PropertyDescriptor[1];
properties[0] = new PropertyDescriptor("filename", beanClass, "getFilename", "setFilename");
properties[0].setDisplayName(getExternalizedString("property.filename.display_name"));
properties[0].setShortDescription(getExternalizedString("property.filename.short_description"));
properties[0].setValue("scriptable", Boolean.TRUE);
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
DefaultClientBuilderTest.java 文件源码
项目:aws-sdk-java-v2
阅读 16
收藏 0
点赞 0
评论 0
@Test
public void clientBuilderFieldsHaveBeanEquivalents() throws Exception {
ClientBuilder<TestClientBuilder, TestClient> builder = testClientBuilder();
BeanInfo beanInfo = Introspector.getBeanInfo(builder.getClass());
Method[] clientBuilderMethods = ClientBuilder.class.getDeclaredMethods();
Arrays.stream(clientBuilderMethods).filter(m -> !m.isSynthetic()).forEach(builderMethod -> {
String propertyName = builderMethod.getName();
Optional<PropertyDescriptor> propertyForMethod =
Arrays.stream(beanInfo.getPropertyDescriptors())
.filter(property -> property.getName().equals(propertyName))
.findFirst();
assertThat(propertyForMethod).as(propertyName + " property").hasValueSatisfying(property -> {
assertThat(property.getReadMethod()).as(propertyName + " getter").isNull();
assertThat(property.getWriteMethod()).as(propertyName + " setter").isNotNull();
});
});
}
AbstractComplexeEventStatementBeanInfo.java 文件源码
项目:convertigo-engine
阅读 14
收藏 0
点赞 0
评论 0
public AbstractComplexeEventStatementBeanInfo() {
try {
beanClass = AbstractComplexeEventStatement.class;
additionalBeanClass = com.twinsoft.convertigo.beans.statements.AbstractEventStatement.class;
resourceBundle = getResourceBundle("res/AbstractComplexeEventStatement");
properties = new PropertyDescriptor[1];
properties[0] = new PropertyDescriptor("uiEvent", beanClass, "getUiEvent", "setUiEvent");
properties[0].setDisplayName(getExternalizedString("property.uievent.display_name"));
properties[0].setShortDescription(getExternalizedString("property.uievent.short_description"));
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
InstanceUtil.java 文件源码
项目:iBase4J-Common
阅读 23
收藏 0
点赞 0
评论 0
public static <T> T transMap2Bean(Map<String, Object> map, Class<T> clazz) {
T bean = null;
try {
bean = clazz.newInstance();
BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor property : propertyDescriptors) {
String key = property.getName();
if (map.containsKey(key)) {
Object value = map.get(key);
// 得到property对应的setter方法
Method setter = property.getWriteMethod();
setter.invoke(bean, TypeParseUtil.convert(value, property.getPropertyType(), null));
}
}
} catch (Exception e) {
logger.error("transMap2Bean Error ", e);
}
return bean;
}
AbstractObjectExporter.java 文件源码
项目:neoscada
阅读 20
收藏 0
点赞 0
评论 0
/**
* create data items from the properties
*/
protected void createDataItems ( final Class<?> targetClazz )
{
try
{
final BeanInfo bi = Introspector.getBeanInfo ( targetClazz );
for ( final PropertyDescriptor pd : bi.getPropertyDescriptors () )
{
final DataItem item = createItem ( pd, targetClazz );
this.items.put ( pd.getName (), item );
final Map<String, Variant> itemAttributes = new HashMap<String, Variant> ();
fillAttributes ( pd, itemAttributes );
this.attributes.put ( pd.getName (), itemAttributes );
initAttribute ( pd );
}
}
catch ( final IntrospectionException e )
{
logger.info ( "Failed to read initial item", e );
}
}
BeanMoulder.java 文件源码
项目:jaffa-framework
阅读 16
收藏 0
点赞 0
评论 0
private static void setProperty (PropertyDescriptor pd, Object value, Object source)
throws IllegalAccessException, InvocationTargetException, MouldException {
if(pd!=null && pd.getWriteMethod()!=null) {
Method m = pd.getWriteMethod();
if(!m.isAccessible()) m.setAccessible(true);
Class tClass = m.getParameterTypes()[0];
if(value==null || tClass.isAssignableFrom(value.getClass())) {
m.invoke(source, new Object[] {value});
log.debug("Set property '" + pd.getName() + "=" + value + "' on object '" + source.getClass().getName() + "'");
} else if(DataTypeMapper.instance().isMappable(value.getClass(),tClass)) {
// See if there is a datatype mapper for these classes
value = DataTypeMapper.instance().map(value, tClass);
m.invoke(source, new Object[] {value});
log.debug("Translate+Set property '" + pd.getName() + "=" + value + "' on object '" + source.getClass().getName() + "'");
} else {
// Data type mismatch
throw new MouldException(MouldException.DATATYPE_MISMATCH, source.getClass().getName() + "." + m.getName(), tClass.getName(), value.getClass().getName());
}
} else {
MouldException me = new MouldException(MouldException.NO_SETTER, null,
pd==null?"???":pd.getName(), source.getClass().getName());
log.error(me.getLocalizedMessage());
throw me;
}
}
JavaScriptBeanInfo.java 文件源码
项目:convertigo-engine
阅读 14
收藏 0
点赞 0
评论 0
public JavaScriptBeanInfo() {
try {
beanClass = JavaScript.class;
additionalBeanClass = BaseRule.class;
resourceBundle = getResourceBundle("res/JavaScript");
properties = new PropertyDescriptor[1];
properties[0] = new PropertyDescriptor("expression", beanClass, "getExpression", "setExpression" );
properties[0].setDisplayName(getExternalizedString("property.expression.display_name") );
properties[0].setShortDescription(getExternalizedString("property.expression.short_description") );
properties[0].setPropertyEditorClass(getEditorClass("JavascriptTextEditor"));
properties[0].setValue("scriptable", Boolean.TRUE);
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}
MetadataMBeanInfoAssembler.java 文件源码
项目:lams
阅读 16
收藏 0
点赞 0
评论 0
/**
* Creates a description for the attribute corresponding to this property
* descriptor. Attempts to create the description using metadata from either
* the getter or setter attributes, otherwise uses the property name.
*/
@Override
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) {
Method readMethod = propertyDescriptor.getReadMethod();
Method writeMethod = propertyDescriptor.getWriteMethod();
ManagedAttribute getter =
(readMethod != null ? this.attributeSource.getManagedAttribute(readMethod) : null);
ManagedAttribute setter =
(writeMethod != null ? this.attributeSource.getManagedAttribute(writeMethod) : null);
if (getter != null && StringUtils.hasText(getter.getDescription())) {
return getter.getDescription();
}
else if (setter != null && StringUtils.hasText(setter.getDescription())) {
return setter.getDescription();
}
ManagedMetric metric = (readMethod != null ? this.attributeSource.getManagedMetric(readMethod) : null);
if (metric != null && StringUtils.hasText(metric.getDescription())) {
return metric.getDescription();
}
return propertyDescriptor.getDisplayName();
}
RequiredAnnotationBeanPostProcessor.java 文件源码
项目:lams
阅读 29
收藏 0
点赞 0
评论 0
@Override
public PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)
throws BeansException {
if (!this.validatedBeanNames.contains(beanName)) {
if (!shouldSkip(this.beanFactory, beanName)) {
List<String> invalidProperties = new ArrayList<String>();
for (PropertyDescriptor pd : pds) {
if (isRequiredProperty(pd) && !pvs.contains(pd.getName())) {
invalidProperties.add(pd.getName());
}
}
if (!invalidProperties.isEmpty()) {
throw new BeanInitializationException(buildExceptionMessage(invalidProperties, beanName));
}
}
this.validatedBeanNames.add(beanName);
}
return pvs;
}
ParameterMapping.java 文件源码
项目:mycat-src-1.6.1-RELEASE
阅读 15
收藏 0
点赞 0
评论 0
/**
* 用于导出clazz这个JavaBean的所有属性的PropertyDescriptor
* @param clazz
* @return
*/
private static PropertyDescriptor[] getDescriptors(Class<?> clazz) {
//PropertyDescriptor类表示JavaBean类通过存储器导出一个属性
PropertyDescriptor[] pds;
List<PropertyDescriptor> list;
PropertyDescriptor[] pds2 = descriptors.get(clazz);
//该clazz是否第一次加载
if (null == pds2) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
pds = beanInfo.getPropertyDescriptors();
list = new ArrayList<PropertyDescriptor>();
//加载每一个类型不为空的property
for (int i = 0; i < pds.length; i++) {
if (null != pds[i].getPropertyType()) {
list.add(pds[i]);
}
}
pds2 = new PropertyDescriptor[list.size()];
list.toArray(pds2);
} catch (IntrospectionException ie) {
LOGGER.error("ParameterMappingError", ie);
pds2 = new PropertyDescriptor[0];
}
}
descriptors.put(clazz, pds2);
return (pds2);
}
UrlMappingResponseBeanInfo.java 文件源码
项目:convertigo-engine
阅读 15
收藏 0
点赞 0
评论 0
public UrlMappingResponseBeanInfo() {
try {
beanClass = UrlMappingResponse.class;
additionalBeanClass = com.twinsoft.convertigo.beans.core.DatabaseObject.class;
iconNameC16 = "/com/twinsoft/convertigo/beans/core/images/urlmappingresponse_color_16x16.png";
iconNameC32 = "/com/twinsoft/convertigo/beans/core/images/urlmappingresponse_color_32x32.png";
resourceBundle = getResourceBundle("res/UrlMappingResponse");
displayName = resourceBundle.getString("display_name");
shortDescription = resourceBundle.getString("short_description");
properties = new PropertyDescriptor[0];
}
catch(Exception e) {
com.twinsoft.convertigo.engine.Engine.logBeans.error("Exception with bean info; beanClass=" + beanClass.toString(), e);
}
}