Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.openjpa.persistence.jest
Class PrototypeFactory<K,T>

    java.lang.Object
      org.apache.openjpa.persistence.jest.PrototypeFactory<K,T>

    public class PrototypeFactory<K,T>

extends Object

A factory for a specific type of objects registered by a key. The client registers a type indexed by name. The client can get a new instance of the registered type. The requested registered type not necessarily have to have a no-arg constructor. The constructor arguments can be passed during `new instance` request. Based on the arguments, a matching constructor, if any, is located and invoked. type of key for this registry base type of the objects to construct

Author:
  Pinaki Poddar

Constructor Summary
`PrototypeFactory()`

Method Summary
`(package private) Constructor<? extends T>` | `findConstructor(Class<? extends T> cls, Class<?>[] types)` Finds a constructor of the given class with given argument types.
`(package private) Class<?>[]` | `getConstructorParameterTypes(Object... args)`
`Set<K>` | `getRegisteredKeys()` Gets the keys registered in this factory.
`T` | `newInstance(K key, Object... args)` Create a new instance of the type registered before with the given key, if any.
`void` | `register(K key, Class<? extends T> prototype)` Register the given class with the given key.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PrototypeFactory

    public PrototypeFactory()

Method Detail

### register

    public void register(K key,
                         Class<? extends T> prototype)

  Register the given class with the given key.

  Parameters:
    `key` - a non-null key.
    `prototype` - a type.

### newInstance

    public T newInstance(K key,
                         Object... args)

  Create a new instance of the type registered before with the given key, if any. The given arguments are used to identify a constructor of the registered type and passed to the constructor of the registered type.

  Parameters:
    `key` - a key to identify a registered type.
    `args` - arguments to pass to the constructor of the type.
  Returns:
    null if no type has been registered against the given key.

### getRegisteredKeys

    public Set<K> getRegisteredKeys()

  Gets the keys registered in this factory.

  Returns:
    immutable set of registered keys.

### getConstructorParameterTypes

    Class<?>[] getConstructorParameterTypes(Object... args)

### findConstructor

    Constructor<? extends T> findConstructor(Class<? extends T> cls,
                                             Class<?>[] types)

  Finds a constructor of the given class with given argument types.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.