# Class DefaultAdhocObjectFactory

java.lang.Object
org.apache.cayenne.di.spi.DefaultAdhocObjectFactory

All Implemented Interfaces:
  `AdhocObjectFactory`

public class DefaultAdhocObjectFactory extends Object implements AdhocObjectFactory
A default implementation of `AdhocObjectFactory` that creates objects using default no-arg constructor and injects dependencies into annotated fields. Note that constructor injection is not supported by this factory.

Since:
  3.1

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected ClassLoaderManager`
  `classLoaderManager`
  `protected Injector`
  `injector`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DefaultAdhocObjectFactory(Injector injector, ClassLoaderManager classLoaderManager)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Class<?>`
  `getJavaClass(String className)`
  Returns a Java class loaded using ClassLoader returned from `ClassLoaderManager.getClassLoader(String)` for a given class name.
  `<T> T`
  `newInstance(Class<? super T> superType, Class<? extends T> type, boolean skipInjection)`
  Returns an instance of "type" that implements "superType", injecting dependencies from the registry into it if requested
  `<T> T`
  `newInstance(Class<? super T> superType, String className, boolean skipInjection)`
  Returns an instance of "className" that implements "superType", injecting dependencies from the registry into it if requested

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface AdhocObjectFactory

  `newInstance`

- ## Field Details

  - ### injector

    protected Injector injector

  - ### classLoaderManager

    protected ClassLoaderManager classLoaderManager

- ## Constructor Details

  - ### DefaultAdhocObjectFactory

    public DefaultAdhocObjectFactory(Injector injector, ClassLoaderManager classLoaderManager)
    Since:
      4.0

- ## Method Details

  - ### newInstance

    public <T> T newInstance(Class<? super T> superType, String className, boolean skipInjection)
    Description copied from interface: `AdhocObjectFactory`
    Returns an instance of "className" that implements "superType", injecting dependencies from the registry into it if requested
    Specified by:
      `newInstance` in interface `AdhocObjectFactory`

  - ### newInstance

    public <T> T newInstance(Class<? super T> superType, Class<? extends T> type, boolean skipInjection)
    Description copied from interface: `AdhocObjectFactory`
    Returns an instance of "type" that implements "superType", injecting dependencies from the registry into it if requested
    Specified by:
      `newInstance` in interface `AdhocObjectFactory`

  - ### getJavaClass

    public Class<?> getJavaClass(String className)
    Description copied from interface: `AdhocObjectFactory`
    Returns a Java class loaded using ClassLoader returned from `ClassLoaderManager.getClassLoader(String)` for a given class name.
    Specified by:
      `getJavaClass` in interface `AdhocObjectFactory`