01: package org.drools.objenesis.instantiator.basic;
02:
03: import org.drools.objenesis.ObjenesisException;
04: import org.drools.objenesis.instantiator.ObjectInstantiator;
05:
06: /**
07: * The simplest instantiator - simply calls Class.newInstance(). This can deal with default public
08: * constructors, but that's about it.
09: *
10: * @see ObjectInstantiator
11: */
12: public class NewInstanceInstantiator implements ObjectInstantiator {
13:
14: private final Class type;
15:
16: public NewInstanceInstantiator(final Class type) {
17: this .type = type;
18: }
19:
20: public Object newInstance() {
21: try {
22: return this .type.newInstance();
23: } catch (final Exception e) {
24: throw new ObjenesisException(e);
25: }
26: }
27:
28: }
|