BeanFactory (Apache Tomcat 9.0.118 API Documentation)
Description: declaration: package: org.apache.naming.factory, class: BeanFactory

# Class BeanFactory

java.lang.Object
org.apache.naming.factory.BeanFactory

All Implemented Interfaces:
  `ObjectFactory`

public class BeanFactory extends Object implements ObjectFactory
Object factory for any Resource conforming to the JavaBean spec.

This factory can be configured in a `<Context>` element in your `conf/server.xml` configuration file. An example of factory configuration is:

    <Resource name="jdbc/myDataSource"
              auth="SERVLET"
              type="oracle.jdbc.pool.OracleConnectionCacheImpl"
              factory="org.apache.naming.factory.BeanFactory"
              driverType="thin"
              serverName="hue"
              networkProtocol="tcp"
              databaseName="XXXX"
              portNumber="NNNN"
              user="XXXX"
              password="XXXX"
              maxLimit="5"
              />

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BeanFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)`
  Create a new Bean instance.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### BeanFactory

    public BeanFactory()

- ## Method Details

  - ### getObjectInstance

    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) throws NamingException
    Create a new Bean instance.
    Specified by:
      `getObjectInstance` in interface `ObjectFactory`
    Parameters:
      `obj` - The reference object describing the Bean
      `name` - the bound name
      `nameCtx` - unused
      `environment` - unused
    Returns:
      the object instance
    Throws:
      `NamingException` - if an error occur creating the instance