You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/10/17 23:59:54 UTC

svn commit: r1185395 - in /directory/apacheds/trunk: ./ apache-felix/src/main/resources/ service-osgi/ service-osgi/src/ service-osgi/src/main/ service-osgi/src/main/java/ service-osgi/src/main/java/org/ service-osgi/src/main/java/org/apache/ service-o...

Author: elecharny
Date: Mon Oct 17 21:59:53 2011
New Revision: 1185395

URL: http://svn.apache.org/viewvc?rev=1185395&view=rev
Log:
Apply patch for DIRSERVER-1671

Added:
    directory/apacheds/trunk/service-osgi/
    directory/apacheds/trunk/service-osgi/log4j.properties
    directory/apacheds/trunk/service-osgi/pom.xml
    directory/apacheds/trunk/service-osgi/src/
    directory/apacheds/trunk/service-osgi/src/main/
    directory/apacheds/trunk/service-osgi/src/main/java/
    directory/apacheds/trunk/service-osgi/src/main/java/org/
    directory/apacheds/trunk/service-osgi/src/main/java/org/apache/
    directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/
    directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/
    directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDSInstance.java
    directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java
    directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/InstallationLayout.java
Modified:
    directory/apacheds/trunk/apache-felix/src/main/resources/config.properties
    directory/apacheds/trunk/pom.xml

Modified: directory/apacheds/trunk/apache-felix/src/main/resources/config.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/apache-felix/src/main/resources/config.properties?rev=1185395&r1=1185394&r2=1185395&view=diff
==============================================================================
--- directory/apacheds/trunk/apache-felix/src/main/resources/config.properties (original)
+++ directory/apacheds/trunk/apache-felix/src/main/resources/config.properties Mon Oct 17 21:59:53 2011
@@ -112,7 +112,7 @@ file:../../apacheds/jdbm-partition/targe
 file:../../apacheds/core-api/target/apacheds-core-api-2.0.0-M4-SNAPSHOT.jar \
 file:../../apacheds/core-shared/target/apacheds-core-shared-2.0.0-M4-SNAPSHOT.jar \
 file:../../apacheds/server-config/target/apacheds-server-config-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/service/target/original-apacheds-service-2.0.0-M4-SNAPSHOT.jar \
+file:../../apacheds/service-osgi/target/apacheds-service-osgi-2.0.0-M4-SNAPSHOT.jar \
 file:../../apacheds/server-annotations/target/apacheds-server-annotations-2.0.0-M4-SNAPSHOT.jar \
 file:../../apacheds/protocol-shared/target/apacheds-protocol-shared-2.0.0-M4-SNAPSHOT.jar \
 file:../../apacheds/core-avl/target/apacheds-core-avl-2.0.0-M4-SNAPSHOT.jar \
@@ -160,167 +160,4 @@ felix.log.level=1
 #
 
 org.osgi.service.http.port=8080
-obr.repository.url=http://felix.apache.org/obr/releases.xml
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-#
-# Framework config properties.
-#
-
-# To override the packages the framework exports by default from the
-# class path, set this variable.
-#org.osgi.framework.system.packages=
-
-# To append packages to the default set of exported system packages,
-# set this value.
-#org.osgi.framework.system.packages.extra=
-
-# The following property makes specified packages from the class path
-# available to all bundles. You should avoid using this property.
-#org.osgi.framework.bootdelegation=sun.*,com.sun.*
-
-# Felix tries to guess when to implicitly boot delegate in certain
-# situations to ease integration without outside code. This feature
-# is enabled by default, uncomment the following line to disable it.
-#felix.bootdelegation.implicit=false
-
-# The following property explicitly specifies the location of the bundle
-# cache, which defaults to "felix-cache" in the current working directory.
-# If this value is not absolute, then the felix.cache.rootdir controls
-# how the absolute location is calculated. (See next property)
-#org.osgi.framework.storage=${felix.cache.rootdir}/felix-cache
-
-# The following property is used to convert a relative bundle cache
-# location into an absolute one by specifying the root to prepend to
-# the relative cache path. The default for this property is the
-# current working directory.
-#felix.cache.rootdir=${user.dir}
-
-# The following property controls whether the bundle cache is flushed
-# the first time the framework is initialized. Possible values are
-# "none" and "onFirstInit"; the default is "none".
-org.osgi.framework.storage.clean=onFirstInit
-
-# The following property determines which actions are performed when
-# processing the auto-deploy directory. It is a comma-delimited list of
-# the following values: 'install', 'start', 'update', and 'uninstall'.
-# An undefined or blank value is equivalent to disabling auto-deploy
-# processing.
-felix.auto.deploy.action=install,start
-
-# The following property specifies the directory to use as the bundle
-# auto-deploy directory; the default is 'bundle' in the working directory.
-#felix.auto.deploy.dir=bundle
-
-# The following property is a space-delimited list of bundle URLs
-# to install when the framework starts. The ending numerical component
-# is the target start level. Any number of these properties may be
-# specified for different start levels.
-#felix.auto.install.1=
-
-# The following property is a space-delimited list of bundle URLs
-# to install and start when the framework starts. The ending numerical
-# component is the target start level. Any number of these properties
-# may be specified for different start levels.
-felix.auto.start.1=\
-file:../../apacheds/dependencies/target/apacheds-dependencies-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/changelog/target/apacheds-interceptors-changelog-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/trigger/target/apacheds-interceptors-trigger-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/hash/target/apacheds-interceptors-hash-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/admin/target/apacheds-interceptors-admin-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/collective/target/apacheds-interceptors-collective-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/operational/target/apacheds-interceptors-operational-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/event/target/apacheds-interceptors-event-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/referral/target/apacheds-interceptors-referral-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/authz/target/apacheds-interceptors-authz-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/schema/target/apacheds-interceptors-schema-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/journal/target/apacheds-interceptors-journal-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/logger/target/apacheds-interceptors-logger-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/subtree/target/apacheds-interceptors-subtree-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/exception/target/apacheds-interceptors-exception-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/authn/target/apacheds-interceptors-authn-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptors/normalization/target/apacheds-interceptors-normalization-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/protocol-kerberos/target/apacheds-protocol-kerberos-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/core-jndi/target/apacheds-core-jndi-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/jdbm/target/apacheds-jdbm-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/ldif-partition/target/apacheds-ldif-partition-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/server-jndi/target/apacheds-server-jndi-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/http-directory-bridge/target/apacheds-http-directory-bridge-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/xdbm-tools/target/apacheds-xdbm-tools-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/http-integration/target/apacheds-http-integration-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/xdbm-partition/target/apacheds-xdbm-partition-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/service-builder/target/apacheds-service-builder-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/kerberos-codec/target/apacheds-kerberos-codec-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/protocol-dhcp/target/apacheds-protocol-dhcp-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/protocol-ldap/target/apacheds-protocol-ldap-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/core/target/apacheds-core-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/interceptor-kerberos/target/apacheds-interceptor-kerberos-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/protocol-ntp/target/apacheds-protocol-ntp-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/jdbm-partition/target/apacheds-jdbm-partition-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/core-api/target/apacheds-core-api-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/core-shared/target/apacheds-core-shared-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/server-config/target/apacheds-server-config-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/service/target/original-apacheds-service-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/server-annotations/target/apacheds-server-annotations-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/protocol-shared/target/apacheds-protocol-shared-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/core-avl/target/apacheds-core-avl-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/protocol-dns/target/apacheds-protocol-dns-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/server-replication/target/apacheds-server-replication-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/core-annotations/target/apacheds-core-annotations-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/core-constants/target/apacheds-core-constants-2.0.0-M4-SNAPSHOT.jar \
-file:../../apacheds/i18n/target/apacheds-i18n-2.0.0-M4-SNAPSHOT.jar \
-file:../../shared/util/target/shared-util-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/codec/standalone/target/shared-ldap-codec-standalone-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/codec/core/target/shared-ldap-codec-core-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/net/mina/target/shared-ldap-net-mina-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/client/api/target/shared-ldap-client-api-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/extras/aci/target/shared-ldap-extras-aci-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/extras/util/target/shared-ldap-extras-util-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/extras/trigger/target/shared-ldap-extras-trigger-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/extras/codec/target/shared-ldap-extras-codec-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/extras/codec-api/target/shared-ldap-extras-codec-api-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/extras/sp/target/shared-ldap-extras-sp-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/schema/data/target/shared-ldap-schema-data-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/schema/converter/target/shared-ldap-schema-converter-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/ldap/model/target/shared-ldap-model-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/asn1/ber/target/shared-asn1-ber-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/asn1/api/target/shared-asn1-api-1.0.0-M9-SNAPSHOT.jar \
-file:../../shared/i18n/target/shared-i18n-1.0.0-M9-SNAPSHOT.jar
-
-felix.log.level=1
-
-# Sets the initial start level of the framework upon startup.
-#org.osgi.framework.startlevel.beginning=1
-
-# Sets the start level of newly installed bundles.
-#felix.startlevel.bundle=1
-
-# Felix installs a stream and content handler factories by default,
-# uncomment the following line to not install them.
-#felix.service.urlhandlers=false
-
-# The launcher registers a shutdown hook to cleanly stop the framework
-# by default, uncomment the following line to disable it.
-#felix.shutdown.hook=false
-
-#
-# Bundle config properties.
-#
-
-org.osgi.service.http.port=8080
-obr.repository.url=http://felix.apache.org/obr/releases.xml
+obr.repository.url=http://felix.apache.org/obr/releases.xml
\ No newline at end of file

Modified: directory/apacheds/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/pom.xml?rev=1185395&r1=1185394&r2=1185395&view=diff
==============================================================================
--- directory/apacheds/trunk/pom.xml (original)
+++ directory/apacheds/trunk/pom.xml Mon Oct 17 21:59:53 2011
@@ -150,6 +150,7 @@
     <module>installers</module>
     <module>apache-felix</module>
     <module>dependencies</module>
+    <module>service-osgi</module>
   </modules>
 
   <build>

Added: directory/apacheds/trunk/service-osgi/log4j.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-osgi/log4j.properties?rev=1185395&view=auto
==============================================================================
--- directory/apacheds/trunk/service-osgi/log4j.properties (added)
+++ directory/apacheds/trunk/service-osgi/log4j.properties Mon Oct 17 21:59:53 2011
@@ -0,0 +1,41 @@
+#############################################################################
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#############################################################################
+log4j.rootCategory=WARN, stdout, R
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=${apacheds.log.dir}/apacheds-rolling.log
+
+log4j.appender.R.MaxFileSize=1024KB
+# Keep some backup files
+log4j.appender.R.MaxBackupIndex=5
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+
+# with these we'll not get innundated when switching to DEBUG
+log4j.logger.org.apache.directory.shared.ldap.name=FATAL
+log4j.logger.org.apache.directory.shared.codec=FATAL
+log4j.logger.org.apache.directory.shared.asn1=FATAL
+
+log4j.logger.org.apache.directory.server.schema.registries=FATAL
+#log4j.logger.org.apache.directory.server.ldap.handlers=DEBUG
+

Added: directory/apacheds/trunk/service-osgi/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-osgi/pom.xml?rev=1185395&view=auto
==============================================================================
--- directory/apacheds/trunk/service-osgi/pom.xml (added)
+++ directory/apacheds/trunk/service-osgi/pom.xml Mon Oct 17 21:59:53 2011
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.directory.server</groupId>
+    <artifactId>apacheds-parent</artifactId>
+    <version>2.0.0-M4-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>apacheds-service-osgi</artifactId>
+  <name>ApacheDS OSGI Deployer</name>
+  <packaging>bundle</packaging>
+
+  <description />
+  <dependencies>
+  
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-annotations</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-api</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-service-builder</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-model</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-schema-data</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-util</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+  	  <artifactId>org.apache.felix.ipojo.annotations</artifactId>
+  	  <version>1.8.0</version>
+  	</dependency>
+    
+    <!-- Moving the scope of inherited slf4j-log4j12 dependency to compile -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <inherited>true</inherited>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+          </instructions>
+        </configuration>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-ipojo-plugin</artifactId>
+        <version>1.8.0</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>ipojo-bundle</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      
+    </plugins>
+  </build>
+
+
+</project>
+

Added: directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDSInstance.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDSInstance.java?rev=1185395&view=auto
==============================================================================
--- directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDSInstance.java (added)
+++ directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDSInstance.java Mon Oct 17 21:59:53 2011
@@ -0,0 +1,103 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server;
+
+
+import org.apache.directory.server.core.api.InstanceLayout;
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Instantiate;
+import org.apache.felix.ipojo.annotations.Invalidate;
+import org.apache.felix.ipojo.annotations.Property;
+import org.apache.felix.ipojo.annotations.Validate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * IPojo Component that represents live ApacheDS instance
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
+ *         Project</a>
+ */
+@Component(name = "ApacheDSInstance")
+@Instantiate(name = "ApacheDSInstance-Default")
+public class ApacheDSInstance
+{
+    /** A logger for this class */
+    private final Logger LOG = LoggerFactory
+        .getLogger( ApacheDSInstance.class );
+
+    /** Property for specifying instance directory. It is "default" by default */
+    @Property(name = "apacheds.instance.dir", value = "default")
+    private String instanceDir;
+
+    /* ApacheDSService reference */
+    private ApacheDsService service;
+
+
+    /**
+     * Will be called, when this component instance is validated,
+     * Means all of its requirements are satisfied.
+     * 
+     *
+     */
+    @Validate
+    public void validated()
+    {
+        service = new ApacheDsService();
+
+        // Creating instance layouts from the argument
+        InstanceLayout instanceLayout = new InstanceLayout( instanceDir );
+
+        // Initializing the service
+        try
+        {
+            service.start( instanceLayout );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+            LOG.error( "Failed to start the service.", e );
+            System.exit( 1 );
+        }
+    }
+
+
+    /**
+     * Will be called when this component instance is invalidated,
+     * means one of its requirements is lost.
+     *
+     */
+    @Invalidate
+    public void invalidated()
+    {
+        //Stopping the service
+        try
+        {
+            service.stop();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+            LOG.error( "Failed to stop the service.", e );
+            System.exit( 1 );
+        }
+    }
+}

Added: directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java?rev=1185395&view=auto
==============================================================================
--- directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java (added)
+++ directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java Mon Oct 17 21:59:53 2011
@@ -0,0 +1,737 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.directory.server.config.ConfigPartitionReader;
+import org.apache.directory.server.config.LdifConfigExtractor;
+import org.apache.directory.server.config.beans.ConfigBean;
+import org.apache.directory.server.config.beans.DirectoryServiceBean;
+import org.apache.directory.server.config.beans.HttpServerBean;
+import org.apache.directory.server.config.beans.KdcServerBean;
+import org.apache.directory.server.config.beans.LdapServerBean;
+import org.apache.directory.server.config.beans.NtpServerBean;
+import org.apache.directory.server.config.builder.ServiceBuilder;
+import org.apache.directory.server.core.api.CoreSession;
+import org.apache.directory.server.core.api.DirectoryService;
+import org.apache.directory.server.core.api.InstanceLayout;
+import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
+import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
+import org.apache.directory.server.core.api.partition.Partition;
+import org.apache.directory.server.core.api.schema.SchemaPartition;
+import org.apache.directory.server.core.partition.ldif.LdifPartition;
+import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
+import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.server.integration.http.HttpServer;
+import org.apache.directory.server.kerberos.kdc.KdcServer;
+import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.server.ntp.NtpServer;
+import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.entry.Attribute;
+import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
+import org.apache.directory.shared.ldap.model.entry.DefaultModification;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.Modification;
+import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.model.filter.ExprNode;
+import org.apache.directory.shared.ldap.model.filter.PresenceNode;
+import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.model.message.SearchScope;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.AttributeTypeOptions;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.model.schema.registries.SchemaLoader;
+import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.CsnSyntaxChecker;
+import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.GeneralizedTimeSyntaxChecker;
+import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.UuidSyntaxChecker;
+import org.apache.directory.shared.ldap.schemaextractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.DateUtils;
+import org.apache.directory.shared.util.exception.Exceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A class used to start various servers in a given {@link InstanceLayout}.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ApacheDsService
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( ApacheDsService.class );
+
+    /** The LDAP server instance */
+    private LdapServer ldapServer;
+
+    /** The NTP server instance */
+    private NtpServer ntpServer;
+
+    /** The DNS server instance */
+    //    private DnsServer dnsServer;
+
+    /** The Change Password server instance *
+    private ChangePasswordServer changePwdServer;/
+
+    /** The Kerberos server instance */
+    private KdcServer kdcServer;
+
+    /** The started HttpServer */
+    private HttpServer httpServer;
+
+    /** The Schema partition */
+    private LdifPartition schemaLdifPartition;
+
+    /** The SchemaManager instance */
+    private SchemaManager schemaManager;
+
+    /** The configuration partition */
+    private SingleFileLdifPartition configPartition;
+
+    /** The configuration reader instance */
+    private ConfigPartitionReader cpReader;
+
+    // variables used during the initial startup to update the mandatory operational
+    // attributes
+    /** The UUID syntax checker instance */
+    private UuidSyntaxChecker uuidChecker = new UuidSyntaxChecker();
+
+    /** The CSN syntax checker instance */
+    private CsnSyntaxChecker csnChecker = new CsnSyntaxChecker();
+
+    private GeneralizedTimeSyntaxChecker timeChecker = new GeneralizedTimeSyntaxChecker();
+
+    private static final Map<String, AttributeTypeOptions> MANDATORY_ENTRY_ATOP_MAP = new HashMap<String, AttributeTypeOptions>();
+
+    private boolean isConfigPartitionFirstExtraction = false;
+
+    private boolean isSchemaPartitionFirstExtraction = false;
+
+
+    /**
+     * starts various services configured according to the 
+     * configuration present in the given instance's layout
+     *
+     * @param instanceLayout the on disk location's layout of the intance to be started
+     * @throws Exception
+     */
+    public void start( InstanceLayout instanceLayout ) throws Exception
+    {
+        File partitionsDir = instanceLayout.getPartitionsDirectory();
+
+        if ( !partitionsDir.exists() )
+        {
+            LOG.info( "partition directory doesn't exist, creating {}", partitionsDir.getAbsolutePath() );
+            if ( !partitionsDir.mkdirs() )
+            {
+                throw new IOException(I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, partitionsDir ) );
+            }
+        }
+
+        LOG.info( "using partition dir {}", partitionsDir.getAbsolutePath() );
+
+        initSchemaManager( instanceLayout );
+        initSchemaLdifPartition( instanceLayout );
+        initConfigPartition( instanceLayout );
+
+        // Read the configuration
+        cpReader = new ConfigPartitionReader( configPartition );
+
+        ConfigBean configBean = cpReader.readConfig();
+
+        DirectoryServiceBean directoryServiceBean = configBean.getDirectoryServiceBean();
+
+        // Initialize the DirectoryService now
+        DirectoryService directoryService = initDirectoryService( instanceLayout, directoryServiceBean );
+
+        // start the LDAP server
+        startLdap( directoryServiceBean.getLdapServerBean(), directoryService );
+
+        // start the NTP server
+        startNtp( directoryServiceBean.getNtpServerBean(), directoryService );
+
+        // Initialize the DNS server (Not ready yet)
+        // initDns( configBean );
+
+        // Initialize the DHCP server (Not ready yet)
+        // initDhcp( configBean );
+
+        // start the ChangePwd server (Not ready yet)
+        //startChangePwd( directoryServiceBean.getChangePasswordServerBean(), directoryService );
+
+        // start the Kerberos server
+        startKerberos( directoryServiceBean.getKdcServerBean(), directoryService );
+
+        // start the jetty http server
+        startHttpServer( directoryServiceBean.getHttpServerBean(), directoryService );
+    }
+
+
+    /**
+     * Initialize the schema Manager by loading the schema LDIF files
+     * 
+     * @param instanceLayout the instance layout
+     * @throws Exception in case of any problems while extracting and writing the schema files
+     */
+    private void initSchemaManager( InstanceLayout instanceLayout ) throws Exception
+    {
+        File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema" );
+
+        // Extract the schema on disk (a brand new one) and load the registries
+        if ( schemaPartitionDirectory.exists() )
+        {
+            LOG.info( "schema partition already exists, skipping schema extraction" );
+        }
+        else
+        {
+            SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( instanceLayout.getPartitionsDirectory() );
+            extractor.extractOrCopy();
+            isSchemaPartitionFirstExtraction = true;
+        }
+
+        SchemaLoader loader = new LdifSchemaLoader( schemaPartitionDirectory );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        // We have to load the schema now, otherwise we won't be able
+        // to initialize the Partitions, as we won't be able to parse 
+        // and normalize their suffix Dn
+        schemaManager.loadAllEnabled();
+
+        List<Throwable> errors = schemaManager.getErrors();
+
+        if ( errors.size() != 0 )
+        {
+            throw new Exception( I18n.err( I18n.ERR_317, Exceptions.printErrors( errors ) ) );
+        }
+    }
+
+
+    /**
+     * Initialize the schema partition
+     * 
+     * @param instanceLayout the instance layout
+     * @throws Exception in case of any problems while initializing the SchemaPartition
+     */
+    private void initSchemaLdifPartition( InstanceLayout instanceLayout ) throws Exception
+    {
+        File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema" );
+
+        // Init the LdifPartition
+        schemaLdifPartition = new LdifPartition( schemaManager );
+        schemaLdifPartition.setPartitionPath( schemaPartitionDirectory.toURI() );
+    }
+
+
+    /**
+     * 
+     * initializes a LDIF partition for configuration
+     * 
+     * @param instanceLayout the instance layout
+     * @throws Exception in case of any issues while extracting the schema
+     */
+    private void initConfigPartition( InstanceLayout instanceLayout ) throws Exception
+    {
+        File confFile = new File( instanceLayout.getConfDirectory(), LdifConfigExtractor.LDIF_CONFIG_FILE );
+
+        if ( confFile.exists() )
+        {
+            LOG.info( "config partition already exists, skipping default config extraction" );
+        }
+        else
+        {
+            LdifConfigExtractor.extractSingleFileConfig( instanceLayout.getConfDirectory(),
+                LdifConfigExtractor.LDIF_CONFIG_FILE, true );
+            isConfigPartitionFirstExtraction = true;
+        }
+
+        configPartition = new SingleFileLdifPartition( schemaManager );
+        configPartition.setId( "config" );
+        configPartition.setPartitionPath( confFile.toURI() );
+        configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
+        configPartition.setSchemaManager( schemaManager );
+
+        configPartition.initialize();
+    }
+
+
+    private DirectoryService initDirectoryService( InstanceLayout instanceLayout,
+        DirectoryServiceBean directoryServiceBean ) throws Exception
+    {
+        LOG.info( "Initializing the DirectoryService..." );
+
+        long startTime = System.currentTimeMillis();
+
+        DirectoryService directoryService = ServiceBuilder.createDirectoryService( directoryServiceBean,
+            instanceLayout, schemaManager );
+
+        // The schema partition
+        SchemaPartition schemaPartition = new SchemaPartition( schemaManager );
+        schemaPartition.setWrappedPartition( schemaLdifPartition );
+        directoryService.setSchemaPartition( schemaPartition );
+
+        directoryService.addPartition( configPartition );
+
+        // Store the default directories
+        directoryService.setInstanceLayout( instanceLayout );
+
+        directoryService.startup();
+
+        AttributeType ocAt = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
+        MANDATORY_ENTRY_ATOP_MAP.put( ocAt.getName(), new AttributeTypeOptions( ocAt ) );
+
+        AttributeType uuidAt = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_UUID_AT );
+        MANDATORY_ENTRY_ATOP_MAP.put( uuidAt.getName(), new AttributeTypeOptions( uuidAt ) );
+
+        AttributeType csnAt = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT );
+        MANDATORY_ENTRY_ATOP_MAP.put( csnAt.getName(), new AttributeTypeOptions( csnAt ) );
+
+        AttributeType creatorAt = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CREATORS_NAME_AT );
+        MANDATORY_ENTRY_ATOP_MAP.put( creatorAt.getName(), new AttributeTypeOptions( creatorAt ) );
+
+        AttributeType createdTimeAt = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CREATE_TIMESTAMP_AT );
+        MANDATORY_ENTRY_ATOP_MAP.put( createdTimeAt.getName(), new AttributeTypeOptions( createdTimeAt ) );
+
+        if ( isConfigPartitionFirstExtraction )
+        {
+            LOG.info( "begining to update config partition LDIF files after modifying manadatory attributes" );
+
+            // disable writes to the disk upon every modification to improve performance
+            configPartition.setEnableRewriting( false );
+
+            // perform updates
+            updateMandatoryOpAttributes( configPartition, directoryService );
+
+            // enable writes to disk, this will save the partition data first if found dirty
+            configPartition.setEnableRewriting( true );
+
+            LOG.info( "config partition data was successfully updated" );
+        }
+
+        if ( isSchemaPartitionFirstExtraction )
+        {
+            LOG.info( "begining to update schema partition LDIF files after modifying manadatory attributes" );
+
+            updateMandatoryOpAttributes( schemaLdifPartition, directoryService );
+
+            LOG.info( "schema partition data was successfully updated" );
+        }
+
+        LOG.info( "DirectoryService initialized in {} milliseconds", ( System.currentTimeMillis() - startTime ) );
+
+        return directoryService;
+    }
+
+
+    /**
+     * start the LDAP server
+     */
+    private void startLdap( LdapServerBean ldapServerBean, DirectoryService directoryService ) throws Exception
+    {
+        LOG.info( "Starting the LDAP server" );
+        long startTime = System.currentTimeMillis();
+
+        ldapServer = ServiceBuilder.createLdapServer( ldapServerBean, directoryService );
+
+        if ( ldapServer == null )
+        {
+            LOG.info( "Cannot find any reference to the LDAP Server in the configuration : the server won't be started" );
+            return;
+        }
+
+        printBanner( BANNER_LDAP );
+
+        ldapServer.setDirectoryService( directoryService );
+
+        // And start the server now
+        try
+        {
+            ldapServer.start();
+        }
+        catch ( Exception e )
+        {
+            LOG.error( "Cannot start the server : " + e.getMessage() );
+        }
+
+        LOG.info( "LDAP server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "" );
+    }
+
+
+    /**
+     * start the NTP server
+     */
+    private void startNtp( NtpServerBean ntpServerBean, DirectoryService directoryService ) throws Exception
+    {
+        LOG.info( "Starting the NTP server" );
+        long startTime = System.currentTimeMillis();
+
+        ntpServer = ServiceBuilder.createNtpServer( ntpServerBean, directoryService );
+
+        if ( ntpServer == null )
+        {
+            LOG.info( "Cannot find any reference to the NTP Server in the configuration : the server won't be started" );
+            return;
+        }
+
+        printBanner( BANNER_NTP );
+
+        ntpServer.start();
+
+        if ( LOG.isInfoEnabled() )
+        {
+            LOG.info( "NTP server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "" );
+        }
+    }
+
+
+    /**
+     * Initialize the DNS server
+     */
+    //    private void initDns( InstanceLayout layout ) throws Exception
+    //    {
+    //        if ( factory == null )
+    //        {
+    //            return;
+    //        }
+    //
+    //        try
+    //        {
+    //            dnsServer = ( DnsServer ) factory.getBean( "dnsServer" );
+    //        }
+    //        catch ( Exception e )
+    //        {
+    //            LOG.info( "Cannot find any reference to the DNS Server in the configuration : the server won't be started" );
+    //            return;
+    //        }
+    //        
+    //        System.out.println( "Starting the DNS server" );
+    //        LOG.info( "Starting the DNS server" );
+    //        
+    //        printBanner( BANNER_DNS );
+    //        long startTime = System.currentTimeMillis();
+    //
+    //        dnsServer.start();
+    //        System.out.println( "DNS Server started" );
+    //
+    //        if ( LOG.isInfoEnabled() )
+    //        {
+    //            LOG.info( "DNS server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "" );
+    //        }
+    //    }
+
+    /**
+     * start the KERBEROS server
+     */
+    private void startKerberos( KdcServerBean kdcServerBean, DirectoryService directoryService ) throws Exception
+    {
+        LOG.info( "Starting the Kerberos server" );
+        long startTime = System.currentTimeMillis();
+
+        kdcServer = ServiceBuilder.createKdcServer( kdcServerBean, directoryService );
+
+        if ( kdcServer == null )
+        {
+            LOG.info( "Cannot find any reference to the Kerberos Server in the configuration : the server won't be started" );
+            return;
+        }
+
+        getDirectoryService().startup();
+        kdcServer.setDirectoryService( getDirectoryService() );
+
+        printBanner( BANNER_KERBEROS );
+
+        kdcServer.start();
+
+        if ( LOG.isInfoEnabled() )
+        {
+            LOG.info( "Kerberos server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "" );
+        }
+    }
+
+
+    /**
+     * start the Change Password server
+     *
+    private void startChangePwd( ChangePasswordServerBean changePwdServerBean, DirectoryService directoryService ) throws Exception
+    {
+        changePwdServer = ServiceBuilder.createChangePasswordServer( changePwdServerBean, directoryService );
+        
+        if ( changePwdServer == null )
+        {
+            LOG.info( "Cannot find any reference to the Change Password Server in the configuration : the server won't be started" );
+            return;
+        }
+
+        LOG.info( "Starting the Change Password server" );
+        long startTime = System.currentTimeMillis();
+
+        getDirectoryService().startup();
+        changePwdServer.setDirectoryService( getDirectoryService() );
+
+        LOG.info( "Starting the Change Password server" );
+
+        printBanner( BANNER_CHANGE_PWD );
+
+        changePwdServer.start();
+
+        if ( LOG.isInfoEnabled() )
+        {
+            LOG.info( "Change Password server: started in {} milliseconds", ( System.currentTimeMillis() - startTime )
+                + "" );
+        }
+    }
+    */
+
+    /**
+     * start the embedded HTTP server
+     */
+    private void startHttpServer( HttpServerBean httpServerBean, DirectoryService directoryService ) throws Exception
+    {
+        httpServer = ServiceBuilder.createHttpServer( httpServerBean, directoryService );
+
+        if ( httpServer == null )
+        {
+            LOG.info( "Cannot find any reference to the HTTP Server in the configuration : the server won't be started" );
+            return;
+        }
+
+        LOG.info( "Starting the Http server" );
+        long startTime = System.currentTimeMillis();
+
+        httpServer.start( getDirectoryService() );
+
+        if ( LOG.isInfoEnabled() )
+        {
+            LOG.info( "Http server: started in {} milliseconds", ( System.currentTimeMillis() - startTime )
+                + "" );
+        }
+    }
+
+
+    public DirectoryService getDirectoryService()
+    {
+        return ldapServer.getDirectoryService();
+    }
+
+
+    public void synch() throws Exception
+    {
+        ldapServer.getDirectoryService().sync();
+    }
+
+
+    public void stop() throws Exception
+    {
+        // Stops the server
+        if ( ldapServer != null )
+        {
+            ldapServer.stop();
+        }
+
+        if ( kdcServer != null )
+        {
+            kdcServer.stop();
+        }
+
+        /*if ( changePwdServer != null )
+        {
+            changePwdServer.stop();
+        }*/
+
+        if ( ntpServer != null )
+        {
+            ntpServer.stop();
+        }
+
+        if ( httpServer != null )
+        {
+            httpServer.stop();
+        }
+
+        // We now have to stop the underlaying DirectoryService
+        ldapServer.getDirectoryService().shutdown();
+    }
+
+    private static final String BANNER_LDAP = "           _                     _          ____  ____   \n"
+        + "          / \\   _ __    ___  ___| |__   ___|  _ \\/ ___|  \n"
+        + "         / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ | | \\___ \\  \n"
+        + "        / ___ \\| |_) | (_| | (__| | | |  __/ |_| |___) | \n"
+        + "       /_/   \\_\\ .__/ \\__,_|\\___|_| |_|\\___|____/|____/  \n"
+        + "               |_|                                       \n";
+
+    private static final String BANNER_NTP = "           _                     _          _   _ _____ _ __    \n"
+        + "          / \\   _ __    ___  ___| |__   ___| \\ | |_  __| '_ \\   \n"
+        + "         / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ .\\| | | | | |_) |  \n"
+        + "        / ___ \\| |_) | (_| | (__| | | |  __/ |\\  | | | | .__/   \n"
+        + "       /_/   \\_\\ .__/ \\__,_|\\___|_| |_|\\___|_| \\_| |_| |_|      \n"
+        + "               |_|                                              \n";
+
+    private static final String BANNER_KERBEROS = "           _                     _          _  __ ____   ___    \n"
+        + "          / \\   _ __    ___  ___| |__   ___| |/ /|  _ \\ / __|   \n"
+        + "         / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ ' / | | | / /      \n"
+        + "        / ___ \\| |_) | (_| | (__| | | |  __/ . \\ | |_| \\ \\__    \n"
+        + "       /_/   \\_\\ .__/ \\__,_|\\___|_| |_|\\___|_|\\_\\|____/ \\___|   \n"
+        + "               |_|                                              \n";
+
+    //    private static final String BANNER_DNS =
+    //          "           _                     _          ____  _   _ ____    \n"
+    //        + "          / \\   _ __    ___  ___| |__   ___|  _ \\| \\ | / ___|   \n"
+    //        + "         / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ | | |  \\| \\__  \\   \n"
+    //        + "        / ___ \\| |_) | (_| | (__| | | |  __/ |_| | . ' |___) |  \n"
+    //        + "       /_/   \\_\\ .__/ \\__,_|\\___|_| |_|\\___|____/|_|\\__|____/   \n"
+    //        + "               |_|                                              \n";
+    //
+    //    
+    //    private static final String BANNER_DHCP =
+    //          "           _                     _          ____  _   _  ___ ____  \n"
+    //        + "          / \\   _ __    ___  ___| |__   ___|  _ \\| | | |/ __|  _ \\ \n"
+    //        + "         / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ | | | |_| / /  | |_) )\n"
+    //        + "        / ___ \\| |_) | (_| | (__| | | |  __/ |_| |  _  \\ \\__|  __/ \n"
+    //        + "       /_/   \\_\\ .__/ \\__,_|\\___|_| |_|\\___|____/|_| |_|\\___|_|    \n"
+    //        + "               |_|                                                 \n";
+
+    private static final String BANNER_CHANGE_PWD = "         ___                              ___ __  __ __  ______    \n"
+        + "        / __|_       ___ _ __   ____  ___|  _ \\ \\ \\ / / / |  _ \\   \n"
+        + "       / /  | |__  / _` | '  \\ / ___\\/ _ \\ |_) \\ \\ / /\\/ /| | | |  \n"
+        + "       \\ \\__| '_  \\ (_| | |\\  | |___ | __/  __/ \\ ' /   / | |_| |  \n"
+        + "        \\___|_| |_|\\__,_|_| |_|\\__. |\\___| |     \\_/ \\_/  |____/   \n"
+        + "                                  |_|    |_|                       \n";
+
+
+    /**
+     * Print the banner for a server
+     */
+    public static void printBanner( String bannerConstant )
+    {
+        System.out.println( bannerConstant );
+    }
+
+
+    /**
+     * 
+     * adds mandatory operational attributes {@link #MANDATORY_ENTRY_ATOP_MAP} and updates all the LDIF files.
+     * WARN: this method is only called for the first time when schema and config files are bootstrapped
+     *       afterwards it is the responsibility of the user to ensure correctness of LDIF files if modified
+     *       by hand 
+     * 
+     * Note: we do these modifications explicitly cause we have no idea if each entry's LDIF file has the
+     *       correct values for all these mandatory attributes
+     *       
+     * @param partition instance of the partition Note: should only be those which are loaded before starting the DirectoryService
+     * @param dirService the DirectoryService instance
+     * @throws Exception
+     */
+    public void updateMandatoryOpAttributes( Partition partition, DirectoryService dirService ) throws Exception
+    {
+        CoreSession session = dirService.getAdminSession();
+
+        String adminDn = session.getEffectivePrincipal().getName();
+
+        ExprNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT );
+
+        EntryFilteringCursor cursor = session.search( partition.getSuffixDn(), SearchScope.SUBTREE, filter,
+            AliasDerefMode.NEVER_DEREF_ALIASES, new HashSet<AttributeTypeOptions>( MANDATORY_ENTRY_ATOP_MAP.values() ) );
+        cursor.beforeFirst();
+
+        List<Modification> mods = new ArrayList<Modification>();
+
+        while ( cursor.next() )
+        {
+            Entry entry = cursor.get();
+
+            AttributeType atType = MANDATORY_ENTRY_ATOP_MAP.get( SchemaConstants.ENTRY_UUID_AT ).getAttributeType();
+
+            Attribute uuidAt = entry.get( atType );
+            String uuid = ( uuidAt == null ? null : uuidAt.getString() );
+
+            if ( !uuidChecker.isValidSyntax( uuid ) )
+            {
+                uuidAt = new DefaultAttribute( atType, UUID.randomUUID().toString() );
+            }
+
+            Modification uuidMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, uuidAt );
+            mods.add( uuidMod );
+
+            atType = MANDATORY_ENTRY_ATOP_MAP.get( SchemaConstants.ENTRY_CSN_AT ).getAttributeType();
+            Attribute csnAt = entry.get( atType );
+            String csn = ( csnAt == null ? null : csnAt.getString() );
+
+            if ( !csnChecker.isValidSyntax( csn ) )
+            {
+                csnAt = new DefaultAttribute( atType, dirService.getCSN().toString() );
+            }
+
+            Modification csnMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, csnAt );
+            mods.add( csnMod );
+
+            atType = MANDATORY_ENTRY_ATOP_MAP.get( SchemaConstants.CREATORS_NAME_AT ).getAttributeType();
+            Attribute creatorAt = entry.get( atType );
+            String creator = ( creatorAt == null ? "" : creatorAt.getString().trim() );
+
+            if ( ( creator.length() == 0 ) || ( !Dn.isValid( creator ) ) )
+            {
+                creatorAt = new DefaultAttribute( atType, adminDn );
+            }
+
+            Modification creatorMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, creatorAt );
+            mods.add( creatorMod );
+
+            atType = MANDATORY_ENTRY_ATOP_MAP.get( SchemaConstants.CREATE_TIMESTAMP_AT ).getAttributeType();
+            Attribute createdTimeAt = entry.get( atType );
+            String createdTime = ( createdTimeAt == null ? null : createdTimeAt.getString() );
+
+            if ( !timeChecker.isValidSyntax( createdTime ) )
+            {
+                createdTimeAt = new DefaultAttribute( atType, DateUtils.getGeneralizedTime() );
+            }
+
+            Modification createdMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, createdTimeAt );
+            mods.add( createdMod );
+
+            if ( !mods.isEmpty() )
+            {
+                LOG.debug( "modifying the entry {} after adding missing manadatory operational attributes",
+                    entry.getDn() );
+                ModifyOperationContext modifyContext = new ModifyOperationContext( session );
+                modifyContext.setEntry( entry );
+                modifyContext.setDn( entry.getDn() );
+                modifyContext.setModItems( mods );
+                partition.modify( modifyContext );
+            }
+
+            mods.clear();
+        }
+
+        cursor.close();
+    }
+
+}

Added: directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/InstallationLayout.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/InstallationLayout.java?rev=1185395&view=auto
==============================================================================
--- directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/InstallationLayout.java (added)
+++ directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/InstallationLayout.java Mon Oct 17 21:59:53 2011
@@ -0,0 +1,195 @@
+package org.apache.directory.server;
+
+
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+import java.io.File;
+
+import org.apache.directory.server.core.api.AbstractLayout;
+
+
+/**
+ * Convenience class to encapsulate paths to various directories and files within
+ * an installation.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InstallationLayout extends AbstractLayout
+{
+    /**
+     * Creates a new instance of InstallationLayout.
+     *
+     * @param installationDirectory
+     *      the installation directory
+     */
+    public InstallationLayout( File installationDirectory )
+    {
+        super( installationDirectory );
+        init();
+    }
+
+
+    /**
+     * Creates a new instance of InstallationLayout.
+     *
+     * @param installationDirectoryPath
+     *      the path to the installation directory
+     */
+    public InstallationLayout( String installationDirectoryPath )
+    {
+        super( installationDirectoryPath );
+        init();
+    }
+
+
+    /**
+     * Initializes the InstallationLayout.
+     */
+    private void init()
+    {
+        // The required directories
+        File[] requiredDirectories = new File[]
+            {
+                getInstallationDirectory(),
+                getBinDirectory(),
+                getConfDirectory(),
+                getLibDirectory()
+            };
+        setRequiredDirectories( requiredDirectories );
+
+        // The required files
+        File[] requiredFiles = new File[]
+            {
+                getScriptFile(),
+                getWrapperFile(),
+                getWrapperConfigurationFile()
+            };
+        setRequiredFiles( requiredFiles );
+    }
+
+
+    /**
+     * Gets the 'bin' directory in the installation directory.
+     *
+     * @return
+     *      the 'bin' directory
+     */
+    public File getBinDirectory()
+    {
+        return new File( getInstallationDirectory(), "bin" );
+    }
+
+
+    /**
+     * Gets the 'conf' directory in the installation directory.
+     *
+     * @return
+     *      the 'conf' directory
+     */
+    public File getConfDirectory()
+    {
+        return new File( getInstallationDirectory(), "conf" );
+    }
+
+
+    /**
+     * Gets the installation directory.
+     *
+     * @return
+     *      the installation directory
+     */
+    public File getInstallationDirectory()
+    {
+        return getDirectory();
+    }
+
+
+    /**
+     * Gets the 'lib' directory in the installation directory.
+     *
+     * @return
+     *      the 'lib' directory
+     */
+    public File getLibDirectory()
+    {
+        return new File( getInstallationDirectory(), "lib" );
+    }
+
+
+    /**
+     * Gets the LICENSE file (<em>'/LICENSE'</em>).
+     *
+     * @return
+     *      the LICENSE file
+     */
+    public File getLicenseFile()
+    {
+        return new File( getInstallationDirectory(), "LICENSE" );
+    }
+
+
+    /**
+     * Gets the NOTICE file (<em>'/NOTICE'</em>).
+     *
+     * @return
+     *      the NOTICE file
+     */
+    public File getNoticeFile()
+    {
+        return new File( getInstallationDirectory(), "NOTICE" );
+    }
+
+
+    /**
+     * Gets the script file (<em>'/bin/apacheds'</em>).
+     *
+     * @return
+     *      the script file
+     */
+    public File getScriptFile()
+    {
+        return new File( getBinDirectory(), "apacheds" );
+    }
+
+
+    /**
+     * Gets the wrapper configuration file (<em>'/conf/wrapper.conf'</em>).
+     *
+     * @return
+     *      the wrapper configuration file
+     */
+    public File getWrapperConfigurationFile()
+    {
+        return new File( getConfDirectory(), "wrapper.conf" );
+    }
+
+
+    /**
+     * Gets the wrapper file (<em>'/bin/wrapper'</em>).
+     *
+     * @return
+     *      the wrapper file
+     */
+    public File getWrapperFile()
+    {
+        return new File( getBinDirectory(), "wrapper" );
+    }
+}