{title:'@Bean Annotation', updated:'8.2.0,9.0.0'}
The {@link oaj.annotation.Bean @Bean} annotation is used to tailor how beans are interpreted by the framework.
Bean property inclusion and ordering on a bean class can be done using the {@link oaj.annotation.Bean#properties() @Bean(properties|p)} annotation.
|
Bean properties can be excluded using the {@link oaj.annotation.Bean#excludeProperties() @Bean(excludeProperties|xp)} annotation.
|
Bean properties can be sorted alphabetically using {@link oaj.annotation.Bean#sort() @Bean(sort)}
|
The {@link oaj.annotation.Bean#propertyNamer() @Bean(propertyNamer)} annotation is used to provide customized naming of properties.
Property namers are used to transform bean property names from standard form to some other form. For example, the {@link oaj.PropertyNamerDLC} will convert property names to dashed-lowercase, and these will be used as attribute names in JSON and element names in XML.
|
The {@link oaj.annotation.Bean#interfaceClass @Bean(interfaceClass)} annotation is used to limit properties on beans to specific interface classes. When specified, only the list of properties defined on the interface class will be used during serialization. Additional properties on subclasses will be ignored.
|
Note that this annotation can be used on the parent class so that it filters to all child classes. Or can be set individually on the child classes.
The {@link oaj.annotation.Bean#stopClass @Bean(stopClass)} annotation is another way to limit which properties are serialized (except from the opposite direction). It's identical in purpose to the stop class specified by {@link java.beans.Introspector#getBeanInfo(Class, Class)}. Any properties in the stop class or in its base classes will be ignored during analysis.
For example, in the following class hierarchy, instances of
|
The {@link oaj.annotation.Bean#interceptor() @Bean(interceptor)} annotation and {@link oaj.swap.BeanInterceptor} class can be used to perform interception and inline handling of bean getter and setter calls.
|
The {@link oaj.annotation.Bean#on() @Bean(on)} and {@link oaj.annotation.Bean#onClass() @Bean(onClass)}
annotations can be used to programmatically attach
|