You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2010/12/09 16:10:40 UTC

svn commit: r1043994 - /directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/ApacheDS2ConfigurationPlugin.java

Author: pamarcelot
Date: Thu Dec  9 15:10:40 2010
New Revision: 1043994

URL: http://svn.apache.org/viewvc?rev=1043994&view=rev
Log:
Added in the Plugin Class a common Schema Manager (initialized only once) accessible for loading all configurations.

Modified:
    directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/ApacheDS2ConfigurationPlugin.java

Modified: directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/ApacheDS2ConfigurationPlugin.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/ApacheDS2ConfigurationPlugin.java?rev=1043994&r1=1043993&r2=1043994&view=diff
==============================================================================
--- directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/ApacheDS2ConfigurationPlugin.java (original)
+++ directory/studio/trunk/plugins/apacheds.configuration.v2/src/main/java/org/apache/directory/studio/apacheds/configuration/v2/ApacheDS2ConfigurationPlugin.java Thu Dec  9 15:10:40 2010
@@ -22,8 +22,15 @@ package org.apache.directory.studio.apac
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.List;
 import java.util.PropertyResourceBundle;
 
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
+import org.apache.directory.shared.ldap.util.LdapExceptionUtils;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
@@ -46,6 +53,9 @@ public class ApacheDS2ConfigurationPlugi
     /** The plugin properties */
     private PropertyResourceBundle properties;
 
+    /** The schema manager */
+    private SchemaManager schemaManager;
+
 
     /**
      * Creates a new instance of ApacheDS2ConfigurationPlugin.
@@ -63,8 +73,6 @@ public class ApacheDS2ConfigurationPlugi
     public void start( BundleContext context ) throws Exception
     {
         super.start( context );
-        
-        System.out.println("start ApacheDS2Configuration");
     }
 
 
@@ -79,6 +87,37 @@ public class ApacheDS2ConfigurationPlugi
 
 
     /**
+     * Gets the schema manager.
+     *
+     * @return
+     *      the schema manager
+     * @throws Exception
+     *      if an error occurs when initializing the schema manager
+     */
+    public SchemaManager getSchemaManager() throws Exception
+    {
+        // Is the schema manager initialized?
+        if ( schemaManager == null )
+        {
+            // Initializing the schema loader and schema manager
+            SchemaLoader loader = new JarLdifSchemaLoader();
+            schemaManager = new DefaultSchemaManager( loader );
+
+            // Loading only the 'adsconfig' schema with its dependencies
+            schemaManager.loadWithDeps( "adsconfig" );
+
+            // Checking if no error occurred when loading the schemas
+            if ( schemaManager.getErrors().size() != 0 )
+            {
+                throw new Exception( "Could not load the schema correctly." );
+            }
+        }
+
+        return schemaManager;
+    }
+
+
+    /**
      * Returns the shared instance.
      *
      * @return