Package org.coliper.ibean.proxy
Class ProxyIBeanFactory
- java.lang.Object
-
- org.coliper.ibean.proxy.ProxyIBeanFactory
-
- All Implemented Interfaces:
IBeanFactory
public class ProxyIBeanFactory extends Object implements IBeanFactory
Default implementation ofIBeanFactorybased on JavaProxytechnology. This means it creates IBeans as interface proxies. There is a ready-to-use instance ofProxyIBeanFactoryavailable by default inIBeanbut you might want to create individual instances ofProxyIBeanFactory. This is necessary if you want to- use a different
BeanStyle, - change the
ToStringStyleor - register your own extension interfaces.
To create a
ProxyIBeanFactoryuse nestedProxyIBeanFactory.Builderclass. To obey aBuilderinstance callbuilder().
For example:ProxyIBeanFactory factory = ProxyIBeanFactory.builder() .withBeanStyle(BeanStyle.MODERN_WITH_OPTIONAL) .withToStringStyle(myToStringStyle) .withDefaultInterfaceSupport() .withInterfaceSupport(extensionSupport1) .withInterfaceSupport(extensionSupport2) .build();Please note that a newly built
ProxyIBeanFactorydoes not contain any extension interface support by default. Even the standard extension interfaces (likeNullSafeorFreezable) are not supported out of the box, you need to useProxyIBeanFactory.Builder.withDefaultInterfaceSupport()when building the factory.- See Also:
Proxy,ProxyIBeanFactory.Builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProxyIBeanFactory.BuilderUsed for creating new instances ofProxyIBeanFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ProxyIBeanFactory.Builderbuilder()Creates aProxyIBeanFactory.Builderfor setting up a newProxyIBeanFactory.<T> Tcreate(Class<T> beanType)Creates a new instance of a given bean type.
-
-
-
Method Detail
-
create
public <T> T create(Class<T> beanType)
Description copied from interface:IBeanFactoryCreates a new instance of a given bean type.- Specified by:
createin interfaceIBeanFactory- Type Parameters:
T- generic typeTis the bean class provided with parameterbeanType- Parameters:
beanType- a IBean that matches general IBean rules and that complies to the specific requirements for this factory like bean styles or supported extension interfaces- Returns:
- an instance of the bean type, never
null. The returned beans will usually have default values set for all field values, likenullfor objects or zero for number primitives.
-
builder
public static ProxyIBeanFactory.Builder builder()
Creates aProxyIBeanFactory.Builderfor setting up a newProxyIBeanFactory. See class description above for an usage example.- Returns:
- the
ProxyIBeanFactory.Builder
-
-