public interface IBeanFactory
IBeanFactory factory = ...;
SomeBeanType bean = factory.create(SomeBeanType.class);
IBeanFactorys are the heart and the core of the IBean
framework. They are responsible for creating instances for provided IBean
compliant interfaces with their desired behavior. IBean interfaces consist of
setter and getter methods and super-interfaces.
public interface Person {
void setFirstname(String s);
String getFirstname();
void setDateOfBirth(Date d);
Date getDateOfBirth();
}
IBeanFactory of course cannot create a bean instance from every kind of interface.
An interface that can be handled by a factory needs to follow these criteria:IBeanFactory always looks on the complete list of methods including those
from super interfaces. The factory does not care in which hierarchy level a method is
declared. That means for example that you can declare getter and setter methods in
different parent or sub interfaces as long as they are complete in the final interface
that is provided to the create(Class) method.IBeanFactory. You must therefore not have
default implementations for getter or setter methods.boolean parameter, the getter should return the same type, not even
Boolean would be accepted instead. See BeanStyle for more information.IBeanFactory.
These interfaces are declared as super interfaces of the bean interface and
add certain functionality to the beans. The IBeanFactory simply ignores all
methods from these extension super interfaces.
See org.coliper.ibean.extension package for more
details about extension interfaces.InvalidIBeanTypeException will be thrown.
See IBean tutorial for a more holistic view on IBean.
At the moment there is only one IBeanFactory implementation which is
ProxyIBeanFactory.
| Modifier and Type | Method and Description |
|---|---|
<T> T |
create(Class<T> beanType)
Creates a new instance of a given bean type.
|
<T> T create(Class<T> beanType) throws InvalidIBeanTypeException
T - generic type T is the bean class provided with
parameter beanTypebeanType - a IBean that matches general IBean rules and
that complies to the specific requirements for this factory
like bean styles or supported extension interfacesnull. The
returned beans will usually have default values set for all field
values, like null for objects or zero for number
primitives.InvalidIBeanTypeException - if the given beanType is not a valid IBean
interface for this factory