Package org.objenesis.strategy

Examples of org.objenesis.strategy.StdInstantiatorStrategy


  }

  @SuppressWarnings("synthetic-access")
  public void testInstantiatorStrategy () {
    kryo.register(HasArgumentConstructor.class);
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
    HasArgumentConstructor test = new HasArgumentConstructor("cow");
    roundTrip(4, 4, test);

    kryo.register(HasPrivateConstructor.class);
    test = new HasPrivateConstructor();
View Full Code Here


    public <T> KryoPool getKryo(final ClassTag<T> tag, final Serializer<T> serializer){
        KryoInstantiator kryoInstantiator = new KryoInstantiator() {
            public Kryo newKryo() {
                Kryo k =super.newKryo();
                k.setInstantiatorStrategy(new StdInstantiatorStrategy());
                k.register(tag.runtimeClass(), serializer);
                return k;
            }
        };
View Full Code Here

     * override this to implement your own subclass of Kryo
     * default is new Kryo with StdInstantiatorStrategy.
     */
    public Kryo newKryo() {
      Kryo k = new Kryo();
      k.setInstantiatorStrategy(new StdInstantiatorStrategy());
      return k;
    }
View Full Code Here

  }

  @SuppressWarnings("synthetic-access")
  public void testInstantiatorStrategy () {
    kryo.register(HasArgumentConstructor.class);
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
    HasArgumentConstructor test = new HasArgumentConstructor("cow");
    roundTrip(4, 4, test);

    kryo.register(HasPrivateConstructor.class);
    test = new HasPrivateConstructor();
View Full Code Here

  /** This test uses StdInstantiatorStrategy and should bypass invocation of no-arg constructor, even if it is provided. **/
  @SuppressWarnings("synthetic-access")
  public void testStdInstantiatorStrategy () {
    kryo.register(HasArgumentConstructor.class);
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
    HasArgumentConstructor test = new HasPrivateConstructor();
    HasPrivateConstructor.invocations = 0;

    kryo.register(HasPrivateConstructor.class);
    roundTrip(4, 4, test);
View Full Code Here

   /**
    * Default constructor using the {@link org.objenesis.strategy.StdInstantiatorStrategy}
    */
   public ObjenesisStd() {
      super(new StdInstantiatorStrategy());
   }
View Full Code Here

    * caching {@link org.objenesis.instantiator.ObjectInstantiator}s
    *
    * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached
    */
   public ObjenesisStd(boolean useCache) {
      super(new StdInstantiatorStrategy(), useCache);
   }
View Full Code Here

   /**
    * Default constructor using the {@link org.objenesis.strategy.StdInstantiatorStrategy}
    */
   public ObjenesisStd() {
      super(new StdInstantiatorStrategy());
   }
View Full Code Here

    * caching {@link org.objenesis.instantiator.ObjectInstantiator}s
    *
    * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached
    */
   public ObjenesisStd(boolean useCache) {
      super(new StdInstantiatorStrategy(), useCache);
   }
View Full Code Here

        };
        // The default strategy is needed so that HashMap is created via the constructor,
        // the StdInstantiatorStrategy (fallback) is needed for classes without default
        // constructor (e.g. DelegatingHandler).
        final DefaultInstantiatorStrategy instantiatorStrategy = new DefaultInstantiatorStrategy();
        instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
        kryo.setInstantiatorStrategy(instantiatorStrategy);
        kryo.register( CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer() );
        kryo.register( Arrays.asList( "" ).getClass(), new ArraysAsListSerializer() );
        return kryo;
    }
View Full Code Here

TOP

Related Classes of org.objenesis.strategy.StdInstantiatorStrategy

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.