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 ofIBeanFactory
based on JavaProxy
technology. This means it creates IBeans as interface proxies. There is a ready-to-use instance ofProxyIBeanFactory
available by default inIBean
but you might want to create individual instances ofProxyIBeanFactory
. This is necessary if you want to- use a different
BeanStyle
, - change the
ToStringStyle
or - register your own extension interfaces.
To create a
ProxyIBeanFactory
use nestedProxyIBeanFactory.Builder
class. To obey aBuilder
instance 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
ProxyIBeanFactory
does not contain any extension interface support by default. Even the standard extension interfaces (likeNullSafe
orFreezable
) 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 class
ProxyIBeanFactory.Builder
Used for creating new instances ofProxyIBeanFactory
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ProxyIBeanFactory.Builder
builder()
Creates aProxyIBeanFactory.Builder
for setting up a newProxyIBeanFactory
.<T> T
create(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:IBeanFactory
Creates a new instance of a given bean type.- Specified by:
create
in interfaceIBeanFactory
- Type Parameters:
T
- generic typeT
is 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, likenull
for objects or zero for number primitives.
-
builder
public static ProxyIBeanFactory.Builder builder()
Creates aProxyIBeanFactory.Builder
for setting up a newProxyIBeanFactory
. See class description above for an usage example.- Returns:
- the
ProxyIBeanFactory.Builder
-
-