1.1 --- a/json-beans/src/main/java/net/java/html/beans/JSONBeans.java Sun Aug 03 21:48:48 2014 +0200
1.2 +++ b/json-beans/src/main/java/net/java/html/beans/JSONBeans.java Sun Aug 03 22:09:35 2014 +0200
1.3 @@ -57,16 +57,37 @@
1.4 import java.util.HashMap;
1.5 import java.util.Map;
1.6 import net.java.html.BrwsrCtx;
1.7 +import net.java.html.json.Function;
1.8 +import net.java.html.json.Model;
1.9 +import net.java.html.json.Property;
1.10 import org.apidesign.html.json.spi.Proto;
1.11
1.12 /** Plain old JavaBean objects and {@link Model JSON models} finally together.
1.13 + * In can you own already written JavaBeans, you can use methods in this
1.14 + * class to register them for use where ever the classes generated by the
1.15 + * {@link Model} annotation can be.
1.16 + * In general it is expected that one can save a lot of boilerplate code
1.17 + * by using {@link Model}, but for purposes of compatibility it may be
1.18 + * suitable to spend time to write JavaBeans and only treat them as
1.19 + * models.
1.20 *
1.21 * @author Jaroslav Tulach
1.22 + * @since 0.9
1.23 */
1.24 public class JSONBeans {
1.25 private JSONBeans() {
1.26 }
1.27
1.28 + /** Registers the given class as a full featured {@link Model model}.
1.29 + * It inspects the class via {@link Introspector} and uses its properties
1.30 + * as {@link Property} definitions and its {@link BeanInfo#getMethodDescriptors() methods}
1.31 + * as {@link Function} definitions. This method has to be called
1.32 + * once and then all classes if this type can be treated as
1.33 + * {@link Model instances of models}.
1.34 + *
1.35 + * @param javaBeanClass the JavaBean class
1.36 + * @throws IntrospectionException if the JavaBean introspector fails
1.37 + */
1.38 public static void register(Class<?> javaBeanClass) throws IntrospectionException {
1.39 BeanInfo bi = Introspector.getBeanInfo(javaBeanClass);
1.40 Method addPCL;