站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 4.0.0.11754MR2 API 英文版文档

ObjenesisBase (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.objenesis
Class ObjenesisBase

java.lang.Object
  extended by org.objenesis.ObjenesisBase
All Implemented Interfaces:
Objenesis
Direct Known Subclasses:
ObjenesisSerializer, ObjenesisStd

public class ObjenesisBase
extends Object
implements Objenesis

Base class to extend if you want to have a class providing your own default strategy. Can also be instantiated directly.

Author:
Henri Tremblay

Field Summary
protected  Map cache
          Strategy cache.
protected  InstantiatorStrategy strategy
          Strategy used by this Objenesi implementation to create classes
 
Constructor Summary
ObjenesisBase(InstantiatorStrategy strategy)
          Constructor allowing to pick a strategy and using cache
ObjenesisBase(InstantiatorStrategy strategy, boolean useCache)
          Flexible constructor allowing to pick the strategy and if caching should be used
 
Method Summary
 ObjectInstantiator getInstantiatorOf(Class clazz)
          Will pick the best instantiator for the provided class.
 Object newInstance(Class clazz)
          Will create a new object without any constructor being called
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

strategy

protected final InstantiatorStrategy strategy
Strategy used by this Objenesi implementation to create classes


cache

protected Map cache
Strategy cache. Key = Class, Value = InstantiatorStrategy

Constructor Detail

ObjenesisBase

public ObjenesisBase(InstantiatorStrategy strategy)
Constructor allowing to pick a strategy and using cache

Parameters:
strategy - Strategy to use

ObjenesisBase

public ObjenesisBase(InstantiatorStrategy strategy,
                     boolean useCache)
Flexible constructor allowing to pick the strategy and if caching should be used

Parameters:
strategy - Strategy to use
useCache - If ObjectInstantiators should be cached
Method Detail

toString

public String toString()
Overrides:
toString in class Object

newInstance

public Object newInstance(Class clazz)
Will create a new object without any constructor being called

Specified by:
newInstance in interface Objenesis
Parameters:
clazz - Class to instantiate
Returns:
New instance of clazz

getInstantiatorOf

public ObjectInstantiator getInstantiatorOf(Class clazz)
Will pick the best instantiator for the provided class. If you need to create a lot of instances from the same class, it is way more efficient to create them from the same ObjectInstantiator than calling newInstance(Class).

Specified by:
getInstantiatorOf in interface Objenesis
Parameters:
clazz - Class to instantiate
Returns:
Instantiator dedicated to the class


Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.