01: /*
02: * BeanObjectDescFactory.java
03: *
04: * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.beans;
10:
11: import java.beans.Introspector;
12: import java.beans.IntrospectionException;
13: import org.pnuts.lang.ObjectDesc;
14: import org.pnuts.lang.ObjectDescFactory;
15: import pnuts.lang.Runtime;
16:
17: public class BeanObjectDescFactory extends ObjectDescFactory {
18:
19: private int flag;
20:
21: public BeanObjectDescFactory() {
22: if (Runtime.getBoolean("pnuts.lang.respect_bean_info")) {
23: this .flag = Introspector.USE_ALL_BEANINFO;
24: } else {
25: this .flag = Introspector.IGNORE_ALL_BEANINFO;
26: }
27: }
28:
29: public ObjectDesc create(Class cls) {
30: try {
31: return new BeanObjectDesc(cls, null, flag);
32: } catch (IntrospectionException e) {
33: return null;
34: }
35: }
36:
37: public ObjectDesc create(Class cls, Class stopClass) {
38: try {
39: return new BeanObjectDesc(cls, stopClass, flag);
40: } catch (IntrospectionException e) {
41: return null;
42: }
43: }
44: }
|