{
// Getting the class of the bean
Class<?> beanClass = bean.getClass();
// Creating the entry to hold the bean and adding it to the list
LdifEntry entry = new LdifEntry();
entry.setDn( getDn( rootDn, bean ) );
addObjectClassAttribute( schemaManager, entry, getObjectClassNameForBean( beanClass ) );
entries.add( entry );
// A flag to know when we reached the 'AdsBaseBean' class when
// looping on the class hierarchy of the bean
boolean adsBaseBeanClassFound = false;
// Looping until the 'AdsBaseBean' class has been found
while ( !adsBaseBeanClassFound )
{
// Checking if we reached the 'AdsBaseBean' class
if ( beanClass == AdsBaseBean.class )
{
adsBaseBeanClassFound = true;
}
// Looping on all fields of the bean
Field[] fields = beanClass.getDeclaredFields();
for ( Field field : fields )
{
// Making the field accessible (we get an exception if we don't do that)
field.setAccessible( true );
// Getting the class of the field
Class<?> fieldClass = field.getType();
Object fieldValue = field.get( bean );
// Looking for the @ConfigurationElement annotation
ConfigurationElement configurationElement = field.getAnnotation( ConfigurationElement.class );
if ( configurationElement != null )
{
// Checking if we have a value for the attribute type
String attributeType = configurationElement.attributeType();
if ( ( attributeType != null ) && ( !"".equals( attributeType ) ) )
{
// Checking if we're dealing with a container
String container = configurationElement.container();
if ( ( container != null ) && ( !"".equals( container ) ) )
{
// Creating the entry for the container and adding it to the list
LdifEntry containerEntry = new LdifEntry();
containerEntry.setDn( entry.getDn().add( new Rdn( SchemaConstants.OU_AT, container ) ) );
addObjectClassAttribute( schemaManager, containerEntry,
SchemaConstants.ORGANIZATIONAL_UNIT_OC );
addAttributeTypeValues( SchemaConstants.OU_AT, container, containerEntry );
entries.add( containerEntry );
if ( Collection.class.isAssignableFrom( fieldClass ) )
{
// Looping on the Collection's objects
Collection<Object> collection = ( Collection<Object> ) fieldValue;
for ( Object object : collection )
{
if ( object instanceof AdsBaseBean )
{
// Adding the bean
addBean( containerEntry.getDn(), schemaManager, ( AdsBaseBean ) object,
entries, entry, attributeType );
continue;
}
else