Package net.sf.cglib.beans

Examples of net.sf.cglib.beans.BeanGenerator


    // properties. The getters will
    // in fact never get called as the intercepter will return the cached
    // result of the previous setter.

    final Method[] methods = clazz.getMethods();
    final BeanGenerator beanGenerator = new BeanGenerator();

    beanGenerator.setSuperclass(clazz);

    for (int i = 0; i < methods.length; i++) {
      final Method m = methods[i];

      if (ReflectUtils.isSetter(m)) {
        beanGenerator.addProperty(ReflectUtils.getPropertyName(m), ReflectUtils.getPropertyType(m));
      }
    }

    //
    // Enhance the class by placing a GetCachingMethodInterceptor
    // intercepter on all the getter and setter methods.

    final Class newClazz = (Class) beanGenerator.createClass();

    final Callback[] callbacks = new Callback[] { new GetCachingMethodInterceptor(clazz.newInstance()), NoOp.INSTANCE };

    return (ConnectionFactory) Enhancer.create(newClazz, new Class[] { ConnectionFactory.class, QueueConnectionFactory.class, TopicConnectionFactory.class }, new CallbackFilter() {
      public int accept(Method m) {
View Full Code Here

TOP

Related Classes of net.sf.cglib.beans.BeanGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.