Examples of ObjenesisStd


Examples of org.objenesis.ObjenesisStd

public class ObjenesisInstanceCreator
  implements InstanceCreator {

  @SuppressWarnings("unchecked")
  public <T> T instanceFor(Class<T> clazz) {
  return (T) new ObjenesisStd().newInstance(clazz);
  }
View Full Code Here

Examples of org.objenesis.ObjenesisStd

    private final Set<Class<?>> ignoredClasses = new HashSet<Class<?>>();
    private final Map<Object, Boolean> ignoredInstances = new IdentityHashMap<Object, Boolean>();
    private final ConcurrentHashMap<Class<?>, List<Field>> fieldsMap = new ConcurrentHashMap<Class<?>, List<Field>>();

    public ObjectCloner() {
        objenesis = new ObjenesisStd();
        init();
    }
View Full Code Here

Examples of org.objenesis.ObjenesisStd

                } else if (l.getAttributes().getNamedItem( ATTRIBUTE_NAME ).getNodeValue().equals( JCL_SYSTEM )) {
                    processLoader( jcl.getSystemLoader(), l );
                } else if (l.getAttributes().getNamedItem( ATTRIBUTE_NAME ).getNodeValue().equals( JCL_BOOTOSGI )) {
                    processLoader( jcl.getOsgiBootLoader(), l );
                } else {
                    Objenesis objenesis = new ObjenesisStd();

                    Class<?> clazz = null;
                    try {
                        clazz = getClass().getClassLoader().loadClass(
                                l.getAttributes().getNamedItem( ATTRIBUTE_CLASS ).getNodeValue() );
                    } catch (Exception e) {
                        throw new JclContextException( e );
                    }

                    ProxyClassLoader pcl = (ProxyClassLoader) objenesis.newInstance( clazz );
                    jcl.addLoader( pcl );

                    processLoader( pcl, l );
                }
            }
View Full Code Here

Examples of org.objenesis.ObjenesisStd

    }
    return null;
  }

  public static Object objectForClassForcibly(Class<?> clazz) {
    Objenesis objenesis = new ObjenesisStd();
    ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(clazz);
    return thingyInstantiator.newInstance();
  }
View Full Code Here

Examples of org.objenesis.ObjenesisStd

   * This method does not throw any exception
   * @param Class<?>
   * @return Object if one was instantiated, null otherwise
   */
  public static Object getInstanceOfClassForcibly(Class<?> clazz) {
    Objenesis objenesis = new ObjenesisStd();
    ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(clazz);
    return thingyInstantiator.newInstance();
  }
View Full Code Here

Examples of org.objenesis.ObjenesisStd

   * This method throws exception if there were issues creating the object
   * @param Class<?>
   * @return Object if one was instantiated, null otherwise
   */
  public static Object getInstanceOfClass(Class<?> clazz) {
    Objenesis objenesis = new ObjenesisStd();
    ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(clazz);
    return thingyInstantiator.newInstance();
  }
View Full Code Here

Examples of org.objenesis.ObjenesisStd

@ApplicationScoped
public class ObjenesisProxifier extends AbstractCglibProxifier {

  public <T> T proxify(Class<T> type, MethodInvocation<? super T> handler) {
    Class<?> proxyClass = enhanceTypeWithCGLib(type, handler).createClass();
    Factory proxyInstance = (Factory) new ObjenesisStd().newInstance(proxyClass);
    proxyInstance.setCallbacks(new Callback[] {cglibMethodInterceptor(handler), NoOp.INSTANCE});
    return type.cast(proxyInstance);
  }
View Full Code Here

Examples of org.objenesis.ObjenesisStd

            object = Array.newInstance(classToInstantiate.getComponentType(), 0);
        } else if (Modifier.isAbstract(modifiers)) {
            throw new IllegalArgumentException(
                    "Cannot instantiate an abstract class. Please use the ConcreteClassGenerator in PowerMock support to generate a concrete class first.");
        } else {
            Objenesis objenesis = new ObjenesisStd();
            ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(classToInstantiate);
            object = thingyInstantiator.newInstance();
        }
        return (T) object;
    }
View Full Code Here

Examples of org.objenesis.ObjenesisStd

   * This method does not throw any exception
   * @param Class<?>
   * @return Object if one was instantiated, null otherwise
   */
  public static Object getInstanceOfClassForcibly(Class<?> clazz) {
    Objenesis objenesis = new ObjenesisStd();
    ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(clazz);
    return thingyInstantiator.newInstance();
//    try {
//      Constructor<?> c = clazz.getDeclaredConstructor();
//      c.setAccessible(true);
//      return c.newInstance();
View Full Code Here

Examples of org.objenesis.ObjenesisStd

   * This method throws exception if there were issues creating the object
   * @param Class<?>
   * @return Object if one was instantiated, null otherwise
   */
  public static Object getInstanceOfClass(Class<?> clazz) {
    Objenesis objenesis = new ObjenesisStd();
    ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(clazz);
    return thingyInstantiator.newInstance();
//    try {
//      return clazz.newInstance();
//    } catch (InstantiationException e) {
//      // TODO Auto-generated catch block
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.