DefaultAdhocObjectFactory (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.di.spi, class: DefaultAdhocObjectFactory

# 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, 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`
  Modifier and Type
  Method
  Description
  `default <T> T`
  `newInstance(Class<? super T> superType, String className)`
  Returns an instance of "className" that implements "superType", injecting dependencies from the registry into it.

- ## 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`

  - ### 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`