Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E9D8A7302 for ; Sat, 19 Nov 2011 17:43:41 +0000 (UTC) Received: (qmail 2750 invoked by uid 500); 19 Nov 2011 17:43:41 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 2695 invoked by uid 500); 19 Nov 2011 17:43:41 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 2688 invoked by uid 99); 19 Nov 2011 17:43:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Nov 2011 17:43:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Nov 2011 17:43:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 96EEF23889BB for ; Sat, 19 Nov 2011 17:43:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1204027 - in /directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component: ./ hub/ schema/ Date: Sat, 19 Nov 2011 17:43:13 -0000 To: commits@directory.apache.org From: gokturk@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111119174313.96EEF23889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gokturk Date: Sat Nov 19 17:43:12 2011 New Revision: 1204027 URL: http://svn.apache.org/viewvc?rev=1204027&view=rev Log: ComponentCacheManager implemented to preserve IPojo instance(OSGI service) configurations across server sessions. TODO: * implement ComponentManager to combine all the facilities implemented so far in one spot. Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java?rev=1204027&r1=1204026&r2=1204027&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java (original) +++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponent.java Sat Nov 19 17:43:12 2011 @@ -34,14 +34,40 @@ import org.apache.felix.ipojo.Factory; */ public class ADSComponent { + /* + * IPojo factory reference for component + */ private Factory factory; + /* + * Component's type + */ private String componentType = "user"; + /* + * Name of the component(Its IPojo factory name in normalized form). + */ + private String componentName; + + /* + * Version of the component. + * (Implementing factory's Bundle version/Subject to change). + */ + private String componentVersion; + + /* + * List holding all the created instances of that component + */ private List instances; + /* + * cache handle for pointing places in the cache for that component. + */ private ADSComponentCacheHandle cacheHandle; + /* + * Generated/Choosed schema information + */ private ADSComponentSchema schema; @@ -74,6 +100,17 @@ public class ADSComponent /** + * Gets the current instances of the component + * + * @return Cloned ADSComponentInstance list. + */ + public List getInstances() + { + return new ArrayList( instances ); + } + + + /** * @return the cacheHandle */ public ADSComponentCacheHandle getCacheHandle() @@ -144,4 +181,47 @@ public class ADSComponent this.schema = schema; } + + /** + * @return the componentName + */ + public String getComponentName() + { + return componentName; + } + + + /** + * @param componentName the componentName to set + */ + public void setComponentName( String componentName ) + { + this.componentName = componentName; + } + + + /** + * @return the componentVersion + */ + public String getComponentVersion() + { + return componentVersion; + } + + + /** + * @param componentVersion the componentVersion to set + */ + public void setComponentVersion( String componentVersion ) + { + this.componentVersion = componentVersion; + } + + + @Override + public String toString() + { + return getComponentType() + ":" + getComponentName() + ":" + getComponentVersion(); + } + } Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java?rev=1204027&r1=1204026&r2=1204027&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java (original) +++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentCacheHandle.java Sat Nov 19 17:43:12 2011 @@ -1,20 +1,22 @@ package org.apache.directory.server.component; -import org.apache.directory.shared.ldap.model.ldif.LdifReader; - - public class ADSComponentCacheHandle { /* - * LdifReader pointing to a ldif file holding cached schema of the component. + * Dir path for cache + */ + private String cacheBaseDir; + + /* + * File path containing cached schema of the component. */ - private LdifReader cachedSchemaHandle; + private String cachedSchemaFileLocation; /* - * LdifReader pointing to a ldif file holding previously created component instance entries. + * Directory path containing cached instance configurations of the component. */ - private LdifReader cachedInstancesHandle; + private String cachedInstanceConfigurationsLocation; /* * Component version of the cache. Used for validating of invalidating the cache in case of @@ -23,33 +25,45 @@ public class ADSComponentCacheHandle private String cachedVersion; - public ADSComponentCacheHandle( LdifReader schema, LdifReader instances, String version ) + public ADSComponentCacheHandle( String base, String schema, String configurations, String version ) { - cachedSchemaHandle = schema; - cachedInstancesHandle = instances; + cacheBaseDir = base; + cachedSchemaFileLocation = schema; + cachedInstanceConfigurationsLocation = configurations; cachedVersion = version; } /** + * Getter for cache base dir + * + * @return String Location of the base cache path + */ + public String getCacheBaseDir() + { + return cacheBaseDir; + } + + + /** * Getter for cached schema handle * - * @return LdifReader pointing to a ldif file of schema. + * @return String containing file location of cached schema */ - public LdifReader getCachedSchemaHandle() + public String getCachedSchemaLocation() { - return cachedSchemaHandle; + return cachedSchemaFileLocation; } /** - * Getter for cached instances handle + * Getter for cached instance configurations * - * @return LdifReader pointing to a ldif file of instance entries. + * @return String containing directory location of cached instance configurations */ - public LdifReader getCachedInstancesHandle() + public String getCachedInstanceConfigurationsLocation() { - return cachedInstancesHandle; + return cachedInstanceConfigurationsLocation; } @@ -63,4 +77,15 @@ public class ADSComponentCacheHandle return cachedVersion; } + + /** + * Setter for cached version of cache + * + *@param ver Version set on cache. + */ + public void setCachedVersion( String ver ) + { + cachedVersion = ver; + } + } Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java?rev=1204027&r1=1204026&r2=1204027&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java (original) +++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSComponentInstance.java Sat Nov 19 17:43:12 2011 @@ -20,7 +20,7 @@ package org.apache.directory.server.component; -import org.apache.directory.shared.ldap.model.ldif.LdifEntry; +import java.util.Properties; /** @@ -43,7 +43,7 @@ public class ADSComponentInstance /* * LdifEntry of configuration hook. */ - private LdifEntry instanceEntry; + private Properties instanceConfiguration; /* * Dn value shows where the configuration hook is set on DIT. @@ -88,20 +88,20 @@ public class ADSComponentInstance /** - * @return the instanceEntry + * @return the instanceConfiguration */ - public LdifEntry getInstanceEntry() + public Properties getInstanceConfiguration() { - return instanceEntry; + return instanceConfiguration; } /** - * @param instanceEntry the instanceEntry to set + * @param instanceConfiguration the instanceConfiguration to set */ - public void setInstanceEntry( LdifEntry instanceEntry ) + public void setInstanceConfiguration( Properties instanceConfiguration ) { - this.instanceEntry = instanceEntry; + this.instanceConfiguration = instanceConfiguration; } Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java?rev=1204027&r1=1204026&r2=1204027&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java (original) +++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/ADSConstants.java Sat Nov 19 17:43:12 2011 @@ -83,11 +83,6 @@ public class ADSConstants public static final String ADS_COMPONENT_TYPE_USER = "user"; /* - * Base DN for @ADSComponent(componentType="user") component schema elements. - */ - public static final String ADS_USER_COMPONENTS_SCHEMA_DN = "cn=usercomponents,ou=schema"; - - /* * Hash table for mapping property type name to its syntax in ApacheDS */ public static Dictionary syntaxMappings; Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java?rev=1204027&r1=1204026&r2=1204027&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java (original) +++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentCacheManager.java Sat Nov 19 17:43:12 2011 @@ -20,17 +20,458 @@ package org.apache.directory.server.component.hub; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.directory.server.component.ADSComponent; import org.apache.directory.server.component.ADSComponentCacheHandle; +import org.apache.directory.server.component.ADSComponentInstance; +import org.apache.directory.server.component.ADSConstants; +import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.ldif.LdapLdifException; +import org.apache.directory.shared.ldap.model.ldif.LdifEntry; +import org.apache.directory.shared.ldap.model.ldif.LdifReader; +import org.apache.directory.shared.ldap.model.ldif.LdifUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /* - * Class to manage schema and instance cache locations for ADSComponents. + * Class to manage schema and instance cache for ADSComponents. */ public class ComponentCacheManager { + /* + * Logger + */ + private final Logger LOG = LoggerFactory.getLogger( ComponentCacheManager.class ); + + /* + * List to keep track of uncached ADSComponents which wants automatic caching. + */ + private Set uncachedComponents; + + + public ComponentCacheManager() + { + uncachedComponents = new HashSet(); + } + + + /** + * Adds component to watch list. + * + * @param component ADSComponent to watch its cache for. + */ + public void addCacheWatch( ADSComponent component ) + { + uncachedComponents.add( component ); + } + + + /** + * Removes component from watch list. + * Also called by cacheComponent() + * + * @param component ADSComponent release watch. + */ + public void removeCacheWatch( ADSComponent component ) + { + uncachedComponents.remove( component ); + } + + + /** + * Caches all the ADSComponents in the watch list, which are registered but didn't cached. + * It is called by ComponentHub when it is being invalidated. + */ + public void cacheRemaningComponents() + { + for ( ADSComponent component : uncachedComponents ) + { + cacheSchema( component ); + cacheInstanceConfigurations( component ); + } + } + + + /** + * Returns the cache handle for specified component. + * + * @param component Component to get cache handle for. + * @return cache handle. + */ public ADSComponentCacheHandle getCacheHandle( ADSComponent component ) { - return null; + String componentCachePath = getComponentCacheBaseDir( component ); + String schemaFile = componentCachePath + IOUtils.DIR_SEPARATOR + ADSConstants.ADS_CACHE_SCHEMA_FILE; + String instancesDir = componentCachePath + IOUtils.DIR_SEPARATOR + ADSConstants.ADS_CACHE_INSTANCES_FILE; + + String version = getCacheVersion( component ); + + return new ADSComponentCacheHandle( componentCachePath, schemaFile, instancesDir, version ); + + } + + + /** + * Caches the schema, instance configurations and set the version for a component. + * + * @param component ADSComponent reference to cache. + */ + public void cacheComponent( ADSComponent component ) + { + cacheSchema( component ); + cacheInstanceConfigurations( component ); + cacheVersion( component ); + + removeCacheWatch( component ); + } + + + /** + * Cache the schema for component. + * + * @param component ADSComponent reference to cache its schema. + */ + public void cacheSchema( ADSComponent component ) + { + List schema = component.getSchema().getSchemaElements(); + if ( schema == null ) + { + LOG.info( "Component does not have custom schema elements: " + + component ); + return; + } + + String componentPath = component.getCacheHandle().getCacheBaseDir(); + String filePath = component.getCacheHandle().getCachedSchemaLocation(); + + File cacheDirectory = new File( componentPath ); + + try + { + FileUtils.forceMkdir( cacheDirectory ); + BufferedWriter writer = new BufferedWriter( new FileWriter( filePath ) ); + + for ( LdifEntry ldif : schema ) + { + writer.write( LdifUtils.convertToLdif( ldif ) ); + writer.write( IOUtils.LINE_SEPARATOR + IOUtils.LINE_SEPARATOR ); + } + + writer.flush(); + writer.close(); + + cacheVersion( component ); + } + catch ( IOException e ) + { + LOG.info( " I/O Error while caching schema for component" + component ); + } + catch ( LdapException e ) + { + LOG.info( "LdifConvert Error while caching schema for component " + component ); + } + } + + + /** + * Caches the current configuration of instances of an ADSComponent. + * + * @param component ADSComponent reference to cache its instance configurations. + */ + public void cacheInstanceConfigurations( ADSComponent component ) + { + String instancesDirPath = component.getCacheHandle().getCachedInstanceConfigurationsLocation(); + File instancesDir = new File( instancesDirPath ); + try + { + if ( instancesDir.exists() ) + { + //Delete existing configuration cache. + FileUtils.deleteDirectory( instancesDir ); + } + + FileUtils.forceMkdir( instancesDir ); + + int counter = 1; + for ( ADSComponentInstance instance : component.getInstances() ) + { + Properties props = instance.getInstanceConfiguration(); + + String fileName = instancesDirPath + IOUtils.DIR_SEPARATOR + component.getComponentName() + "-" + + counter++ + ".config"; + + props.store( new FileOutputStream( fileName ), "Instance Configuration for" + component ); + } + } + catch ( IOException exc ) + { + LOG.info( "I/O error occured while caching instance configuration as Properties for component:" + + component ); + } + } + + + /** + * Set the cache version for the specified component + * + * @param component ADSComponent reference to set version on cache for. + */ + public void cacheVersion( ADSComponent component ) + { + String componentPath = component.getCacheHandle().getCacheBaseDir(); + String versionFilePath = componentPath + IOUtils.DIR_SEPARATOR + ADSConstants.ADS_CACHE_VERSION_FILE; + + File cacheDirectory = new File( componentPath ); + + try + { + if ( cacheDirectory.exists() ) + { + BufferedWriter writer = new BufferedWriter( new FileWriter( versionFilePath ) ); + String version = component.getComponentVersion(); + + writer.write( version ); + + writer.flush(); + writer.close(); + + component.getCacheHandle().setCachedVersion( version ); + } + } + catch ( IOException e ) + { + LOG.info( " Error while setting version under cache for component:" + component ); + } + } + + + /** + * Gets the cached schema of the component. + * Returning list is in the from it can loaded into ApacheDS without any sorting. + * + * @param component ADSComponent reference to search cache for its schema + * @return The cached schema in the form of LdifEntry list. + */ + public List getCachedSchema( ADSComponent component ) + { + + if ( !cacheVersionMatch( component ) ) + { + LOG.info( "Version mismatch between the cache and the component: " + + component ); + + if ( !validateCache( component ) ) + { + return null; + } + } + + String schemaFilePath = component.getCacheHandle().getCachedSchemaLocation(); + List schema = null; + + try + { + File schemaFile = new File( schemaFilePath ); + + if ( !schemaFile.exists() ) + { + return null; + } + + LdifReader reader = new LdifReader( schemaFile ); + schema = new ArrayList(); + + for ( LdifEntry entry : reader ) + { + schema.add( entry ); + } + + } + catch ( LdapLdifException e ) + { + LOG.info( "Error while readering cached schema file for component: " + + component ); + return null; + } + + return schema; + } + + + /** + * Gets the cached instance configurations from the cache as list. + * + * @param component ADSComponent reference to search cache for its instance configurations + * @return List of Properties describing cached instance configurations. + */ + public List getCachedInstanceConfigurations( ADSComponent component ) + { + String instancesDirPath = component.getCacheHandle().getCachedInstanceConfigurationsLocation(); + File instancesDir = new File( instancesDirPath ); + + if ( !instancesDir.exists() ) + { + return null; + } + + File[] configFiles = instancesDir.listFiles( new FileFilter() + { + + @Override + public boolean accept( File pathname ) + { + return pathname.toString().matches( "*-*.config" ); + } + } ); + + List instanceConfigurations = new ArrayList(); + + for ( File configFile : configFiles ) + { + try + { + Properties prop = new Properties(); + prop.load( new FileInputStream( configFile ) ); + + instanceConfigurations.add( prop ); + } + catch ( IOException exc ) + { + LOG.info( "I/O Error while loading properties from file:" + configFile ); + } + } + + if ( instanceConfigurations.size() == 0 ) + { + return null; + } + + return instanceConfigurations; + + } + + + /** + * Gets the version of cache for the component. + * + * @param component ADSComponent reference to get its cache version + * @return version of the cache. + */ + public String getCacheVersion( ADSComponent component ) + { + String componentPath = component.getCacheHandle().getCacheBaseDir(); + String versionFilePath = componentPath + IOUtils.DIR_SEPARATOR + ADSConstants.ADS_CACHE_VERSION_FILE; + String version = null; + + File versionFile = new File( versionFilePath ); + if ( !versionFile.exists() ) + { + return null; + } + + try + { + BufferedReader reader = new BufferedReader( new FileReader( versionFile ) ); + version = reader.readLine(); + reader.close(); + } + catch ( IOException e ) + { + LOG.info( "Error occured while reading version file of the cached component: " + + component ); + } + + return version; + } + + + /** + * Checks whether specified component's version is compatible with the cached version. + * + * TODO It looks for exact match for now, change it to some elegant match policy. + * + * @param component ADSComponent reference to check cache against. + * @return result of the test. + */ + public boolean cacheVersionMatch( ADSComponent component ) + { + String cachedVersion = component.getCacheHandle().getCachedVersion(); + String currentVersion = component.getComponentVersion(); + + if ( !currentVersion.equals( cachedVersion ) && cachedVersion != null ) + { + return false; + } + + return true; } + + + /** + * It is used to validate the cache for the given component. + * TODO validateCache will be implemented later. + * + * @param component ADSComponent to validate cache against. + * @return whether validation is successfull or not. + */ + public boolean validateCache( ADSComponent component ) + { + return false; + } + + + /** + * It removes all the cache for given component. + * + * @param component ADSComponent reference to purge its cache. + */ + public void purgeCache( ADSComponent component ) + { + File baseCacheDir = new File( component.getCacheHandle().getCacheBaseDir() ); + if ( baseCacheDir.exists() ) + { + try + { + FileUtils.forceDelete( baseCacheDir ); + } + catch ( IOException e ) + { + LOG.info( "I/O Error occured while purging the cache for component" + component ); + } + } + } + + + /** + * Gets the base dir in cache for specified component. + * + * @param component ADSComponent to get cache location for. + * @return cache location as String. + */ + private String getComponentCacheBaseDir( ADSComponent component ) + { + String componentType = component.getComponentType(); + String componentName = component.getComponentName(); + + return ADSConstants.ADS_CACHE_BASE_DIR + IOUtils.DIR_SEPARATOR + componentType + IOUtils.DIR_SEPARATOR + + componentName; + } + } Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java?rev=1204027&r1=1204026&r2=1204027&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java (original) +++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ComponentHub.java Sat Nov 19 17:43:12 2011 @@ -27,6 +27,7 @@ import java.util.Hashtable; import java.util.List; import org.apache.directory.server.component.ADSComponent; +import org.apache.directory.server.component.ADSComponentHelper; import org.apache.directory.server.component.ADSConstants; import org.apache.directory.server.component.hub.listener.HubListener; import org.apache.directory.server.component.instance.ADSComponentInstanceGenerator; @@ -145,7 +146,9 @@ public class ComponentHub @Invalidate public void hubInvalidated() { - logger.log( LogService.LOG_INFO, "ADSComponentHub validated." ); + logger.log( LogService.LOG_INFO, "ADSComponentHub being invalidated." ); + + cacheManager.cacheRemaningComponents(); } @@ -347,6 +350,8 @@ public class ComponentHub component.setFactory( factory ); component.setComponentType( componentType ); + component.setComponentName( ADSComponentHelper.getComponentName( component.getFactory() ) ); + component.setComponentVersion( ADSComponentHelper.getComponentVersion( component.getFactory() ) ); component.setCacheHandle( cacheManager.getCacheHandle( component ) ); return component; Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java?rev=1204027&r1=1204026&r2=1204027&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java (original) +++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/schema/UserComponentSchemaGenerator.java Sat Nov 19 17:43:12 2011 @@ -25,6 +25,7 @@ import java.util.Dictionary; import java.util.Hashtable; import java.util.List; +import org.apache.directory.server.component.ADSComponentHelper; import org.apache.directory.server.component.ADSConstants; import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException; import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException; @@ -39,7 +40,8 @@ import org.slf4j.LoggerFactory; public class UserComponentSchemaGenerator implements ComponentSchemaGenerator { - private static final Logger LOG = LoggerFactory.getLogger( UserComponentSchemaGenerator.class ); + private final Logger LOG = LoggerFactory.getLogger( UserComponentSchemaGenerator.class ); + private final String ADS_USER_COMPONENTS_SCHEMA_DN = "cn=usercomponents,ou=schema"; @Override @@ -47,16 +49,10 @@ public class UserComponentSchemaGenerato { List schemaElements = new ArrayList(); - String componentName = componentFactory.getName(); - if ( componentName.contains( "." ) ) - { - componentName = componentName.substring( componentName.lastIndexOf( '.' ) + 1 ); - } - - String schemaDn = ADSConstants.ADS_USER_COMPONENTS_SCHEMA_DN; + String componentName = ADSComponentHelper.getComponentName( componentFactory ); - String attribsDn = "ou=attributeTypes," + schemaDn; - String ocsDn = "ou=objectClasses," + schemaDn; + String attribsDn = "ou=attributeTypes," + ADS_USER_COMPONENTS_SCHEMA_DN; + String ocsDn = "ou=objectClasses," + ADS_USER_COMPONENTS_SCHEMA_DN; //Will hold the m-must attributes while iterating over properties of the component List ocAttribs = new ArrayList(); @@ -159,7 +155,7 @@ public class UserComponentSchemaGenerato + componentFactory ); } - ADSComponentSchema compSchema = new ADSComponentSchema( ADSConstants.ADS_USER_COMPONENTS_SCHEMA_DN, + ADSComponentSchema compSchema = new ADSComponentSchema( ADS_USER_COMPONENTS_SCHEMA_DN, schemaElements ); compSchema.setDefaultConf( defaultConf );