| Home >> All >> org >> springframework >> beans >> [ factory Javadoc ] |
| | org.springframework.beans.factory.access.* (5) | | org.springframework.beans.factory.config.* (30) |
| | org.springframework.beans.factory.support.* (25) | | org.springframework.beans.factory.xml.* (5) |
org.springframework.beans.factory: Javadoc index of package org.springframework.beans.factory.
Package Samples:
org.springframework.beans.factory.xml: The core package implementing Spring's lightweight Inversion of Control (IoC) container.
org.springframework.beans.factory.access
org.springframework.beans.factory.config
org.springframework.beans.factory.support
Classes:
SingletonBeanFactoryLocator: Keyed-singleton implementation of BeanFactoryLocator, which leverages existing Spring constructs. This is normally accessed through DefaultLocatorFactory, but may also be used directly. Please see the warning in BeanFactoryLocator's javadoc about appropriate usage of singleton style BeanFactoryLocator implementations. It is the opinion of the Spring team that the use of this class and similar classes is unnecessary except (sometimes) for a small amount of glue code. Excessive usage will lead to code that is more tightly coupled, and harder to modify or test. In this implementation, a BeanFactory ...
MethodInvokingFactoryBean: FactoryBean which returns a value which is the result of a static or instance method invocation. For most use cases it is better to just use the container's built-in factory-method support for the same purpose, since that is smarter at converting arguments. This factory bean is still useful though when you need to call a method which doesn't return any value (for example, a static class method to force some sort of initialization to happen). This use case is not supported by factory-methods, since a return value is needed to become the bean. Note that as it is expected to be used mostly for accessing ...
BeanFactory: The root interface for accessing a Spring IoC container. This interface is implemented by objects that hold a number of bean definitions, each uniquely identified by a String name. Depending on the bean definition, the factory will return either an independent instance of a contained object (the Prototype design pattern), or a single shared instance (a superior alternative to the Singleton design pattern, in which the instance is a singleton in the scope of the factory). Which type of instance will be returned depends on the bean factory configuration - the API is the same. The Singleton approach ...
PropertyPlaceholderConfigurer: A property resource configurer that resolves placeholders in bean property values of context definitions. It pulls values from a properties file into bean definitions. The default placeholder syntax follows the Ant / Log4J / JSP EL style: ${...} Example XML context definition: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"><value>${driver}</value></property> <property name="url"><value>jdbc:${dbname}</value></property> </bean> Example properties file: driver=com.mysql.jdbc.Driver ...
ServiceLocatorFactoryBean: FactoryBean that takes an interface which must have one or more methods with the signatures MyType xxx() or MyType xxx(MyIdType id) (typically, MyService getService() or MyService getService(String id) ) and creates a dynamic proxy which implements that interface, delegating to the Spring BeanFactory underneath. Such service locator allow to decouple the caller from Spring BeanFactory API, using an appropriate custom locator interface. They will typically be used for prototype beans , i.e. for factory methods that are supposed to return a new instance for each call. The client receives a reference ...
PropertyPathFactoryBean: FactoryBean that evaluates a property path on a given target object. The target object can be specified directly or via a bean name. Usage examples: // target bean to be referenced by name <bean id="tb" class="org.springframework.beans.TestBean" singleton="false"> <property name="age"><value>10</value></property> <property name="spouse"> <bean class="org.springframework.beans.TestBean"> <property name="age"><value>11</value></property> </bean> </property> </bean> // will result in 12, which is the value of property ...
BeanFactoryLocator: An interface for a class used to lookup/use, and optionally allow the release of a BeanFactory, or BeanFactory subclass such as ApplicationContext. Where this interface is implemented as a singleton class such as SingletonBeanFactoryLocator, the Spring team strongly suggests that it be used sparingly and with caution. By far the vast majority of the code inside an application is best written in a Dependency Injection style, where that code is served out of a BeanFactory/ApplicationContext container, and has its own dependencies supplied by the container when it is created. However, even such a ...
ListableBeanFactory: Extension of the BeanFactory interface to be implemented by bean factories that can enumerate all their bean instances, rather than attempting bean lookup by name one by one as requested by clients. BeanFactory implementations that preload all their beans (for example, DOM-based XML factories) may implement this interface. This interface is discussed in "Expert One-on-One J2EE Design and Development", by Rod Johnson. If this is a HierarchicalBeanFactory, the return values will not take any BeanFactory hierarchy into account, but will relate only to the beans defined in the current factory. Use ...
AbstractAutowireCapableBeanFactory: Abstract BeanFactory superclass that implements default bean creation, with the full capabilities specified by the RootBeanDefinition class. Implements the AutowireCapableBeanFactory interface. Like the base class AbstractBeanFactory, this superclass does not assume a listable bean factory. Provides bean creation (with constructor resolution), property population, wiring (including autowiring), and initialization. Handles runtime bean references, resolves managed collections, calls initialization methods, etc. Supports autowiring constructors, properties by name, and properties by type. The main ...
PropertyOverrideConfigurer: A property resource configurer that overrides bean property values in an application context definition. It pushes values from a properties file into bean definitions. Configuration lines are expected to be of the following form: beanName.property=value Example properties file: dataSource.driverClassName=com.mysql.jdbc.Driver dataSource.url=jdbc:mysql:mydb In contrast to PropertyPlaceholderConfigurer, the original definition can have default values or no values at all for such bean properties. If an overriding properties file does not have an entry for a certain bean property, the default context ...
AutowireCapableBeanFactory: Extension of the BeanFactory interface to be implemented by bean factories that are capable of autowiring, provided that they want to expose this functionality for existing bean instances. This subinterface of BeanFactory is not meant to be used in normal application code: stick to BeanFactory or ListableBeanFactory for typical use cases. Integration code for other frameworks can leverage this interface to wire and populate existing bean instances that Spring does not control the lifecycle of. This is particularly useful for WebWork Actions or Tapestry Page objects, for example. Note that this ...
AbstractBeanFactory: Abstract superclass for BeanFactory implementations, implementing the ConfigurableBeanFactory SPI interface. Does not assume a listable bean factory: can therefore also be used as base class for bean factory implementations which fetch bean definitions from a variety of backend resources (where bean definition access is an expensive operation). This class provides singleton/prototype determination, singleton cache, aliases, FactoryBean handling, bean definition merging for child bean definitions, and bean destruction (DisposableBean interface, custom destroy methods). Furthermore, it can manage ...
PropertiesBeanDefinitionReader: Bean definition reader for a simple properties format. Provides bean definition registration methods for Map/Properties and ResourceBundle. Typically applied to a DefaultListableBeanFactory. Example: employee.class=MyClass // bean is of class MyClass employee.(abstract)=true // this bean can't be instantiated directly employee.group=Insurance // real property employee.usesDialUp=false // real property (potentially overridden) salesrep.parent=employee // derives from "employee" bean definition salesrep.(lazy-init)=true // lazily initialize this singleton bean salesrep.manager(ref)=tony // reference ...
ObjectFactoryCreatingFactoryBean: FactoryBean which returns a value which is an ObjectFactory that returns a bean from the BeanFactory. As such, this may be used to avoid having a client bean directly calling getBean() the BeanFactory to get a prototype bean out of the BeanFactory, a violation of inversion of control. Instead, with the use of this class, the client bean can be fed an ObjectFactory as a property which directly returns only the one target (usually prototype) bean. A Sample config in an XML BeanFactory might look as follows: <beans> <!-- Prototype bean since we have state --> <bean id="myService" class="a.b.c.MyService" ...
CustomEditorConfigurer: BeanFactoryPostProcessor implementation that allows for convenient registration of custom property editors. Configuration example, assuming XML bean definitions and inner beans for PropertyEditor instances: <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.Date"> <bean class="mypackage.MyCustomDateEditor"/> </entry> <entry key="mypackage.MyObject"> <bean id="myEditor" class="mypackage.MyObjectEditor"> <property name="myParam"><value>myValue</value></property> ...
XmlBeanFactory: Convenience extension of DefaultListableBeanFactory that reads bean definitions from an XML document. Delegates to XmlBeanDefinitionReader underneath; effectively equivalent to using an XmlBeanDefinitionReader with a DefaultListableBeanFactory. The structure, element and attribute names of the required XML document are hard-coded in this class. (Of course a transform could be run if necessary to produce this format). "beans" doesn't need to be the root element of the XML document: This class will parse all bean definition elements in the XML file. This class registers each bean definition with ...
PropertyResourceConfigurer: Allows for configuration of individual bean property values from a property resource, i.e. a properties file. Useful for custom config files targetted at system administrators that override bean properties configured in the application context. 2 concrete implementations are provided in the distribution: PropertyOverrideConfigurer for "beanName.property=value" style overriding ( pushing values from a properties file into bean definitions) PropertyPlaceholderConfigurer for replacing "${...}" placeholders ( pulling values from a properties file into bean definitions) Property values can be converted ...
DefaultListableBeanFactory: Default implementation of the ListableBeanFactory and BeanDefinitionRegistry interfaces: a full-fledged bean factory based on bean definitions. Typical usage is registering all bean definitions first (possibly read from a bean definition file), before accessing beans. Bean definition lookup is therefore an inexpensive operation in a local bean definition table. Can be used as a standalone bean factory, or as a superclass for custom bean factories. Note that readers for specific bean definition formats are typically implemented separately rather than as bean factory subclasses. For an alternative ...
ChildBeanDefinition: Bean definition for beans who inherit settings from their parent. Will use the bean class of the parent if none specified, but can also override it. In the latter case, the child bean class must be compatible with the parent, i.e. accept the parent's property values and constructor argument values, if any. A child bean definition will inherit constructor argument values, property values and method overrides from the parent, with the option to add new values. If init method, destroy method and/or static factory method are specified, they will override the corresponding parent settings. The remaining ...
FactoryBean: Interface to be implemented by objects used within a BeanFactory that are themselves factories. If a bean implements this interface, it is used as a factory, not directly as a bean. NB: A bean that implements this interface cannot be used as a normal bean. A FactoryBean is defined in a bean style, but the object exposed for bean references is always the object that it creates. FactoryBeans can support singletons and prototypes, and can either create objects lazily on demand or eagerly on startup. This interface is heavily used within the framework, for example for the AOP ProxyFactoryBean or JndiObjectFactoryBean. ...
FieldRetrievingFactoryBean: FactoryBean which retrieves a static or non-static field value. Typically used for retrieving public static final constants. Usage example: // standard definition for exposing a static field, specifying the "staticField" property <bean id="myField" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"> <property name="staticField"><value>java.sql.Connection.TRANSACTION_SERIALIZABLE</value></property> </bean> // convenience version that specifies a static field pattern as bean name <bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE" ...
BeanDefinitionRegistry: Interface for registries that hold bean definitions, for example RootBeanDefinition and ChildBeanDefinition instances. Typically implemented by bean factories that internally work with the AbstractBeanDefinition hierarchy. This is the only interface in Spring's bean factory packages that encapsulates registration of bean definitions. The standard bean factory interfaces only cover access to a fully configured factory instance. Spring's bean definition readers expect to work on an implementation of this interface. Known implementors are DefaultListableBeanFactory and GenericApplicationContext, for ...
FactoryBeanNotInitializedException: Exception thrown if a FactoryBean is not fully initialized, for example because it is involved in a circular reference. Usually indicated by the getObject method returning null. A circular reference with a FactoryBean cannot be solved by eagerly caching singleton instances like with normal beans. The reason is that every FactoryBean needs to be fully initialized before it can return the created bean, while only specific normal beans need to be initialized - that is, if a collaborating bean actually invokes them on initialization instead of just storing the reference.
BeanPostProcessor: Allows for custom modification of new bean instances, e.g. checking for marker interfaces or wrapping them with proxies. Application contexts can auto-detect BeanPostProcessor beans in their bean definitions and apply them before any other beans get created. Plain bean factories allow for programmatic registration of post-processors. Typically, post-processors that populate beans via marker interfaces or the like will implement postProcessBeforeInitialization, and post-processors that wrap beans with proxies will normally implement postProcessAfterInitialization.
BeanFactoryPostProcessor: Allows for custom modification of an application context's bean definitions, adapting the bean property values of the context's underlying bean factory. Application contexts can auto-detect BeanFactoryPostProcessor beans in their bean definitions and apply them before any other beans get created. Useful for custom config files targeted at system administrators that override bean properties configured in the application context. See PropertyResourceConfigurer and its concrete implementations for out-of-the-box solutions that address such configuration needs.
| Home | Contact Us | Privacy Policy | Terms of Service |