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/09/16 13:45:03 UTC
svn commit: r997697 - in /directory/apacheds/branches/apacheds-apacheds-2.0:
./ service/ service/src/ service/src/main/ service/src/main/java/
service/src/main/java/org/ service/src/main/java/org/apache/
service/src/main/java/org/apache/directory/ serv...
Author: pamarcelot
Date: Thu Sep 16 11:45:02 2010
New Revision: 997697
URL: http://svn.apache.org/viewvc?rev=997697&view=rev
Log:
Added two new modules (service and wrapper).
Added:
directory/apacheds/branches/apacheds-apacheds-2.0/service/
directory/apacheds/branches/apacheds-apacheds-2.0/service/pom.xml
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/ApacheDsService.java
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstallationLayout.java
directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstanceLayout.java
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/pom.xml
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ApacheDsTanukiWrapper.java
directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ExitCodes.java
Modified:
directory/apacheds/branches/apacheds-apacheds-2.0/pom.xml
Modified: directory/apacheds/branches/apacheds-apacheds-2.0/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/pom.xml?rev=997697&r1=997696&r2=997697&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/pom.xml (original)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/pom.xml Thu Sep 16 11:45:02 2010
@@ -133,6 +133,8 @@
<module>http-integration</module>
<module>test-framework</module>
<module>ldap-client-test</module>
+ <module>service</module>
+ <module>wrapper</module>
</modules>
<build>
@@ -396,6 +398,18 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apacheds-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apacheds-wrapper</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- Shared dependencies -->
<dependency>
Added: directory/apacheds/branches/apacheds-apacheds-2.0/service/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/service/pom.xml?rev=997697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/service/pom.xml (added)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/service/pom.xml Thu Sep 16 11:45:02 2010
@@ -0,0 +1,57 @@
+<?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>1.5.8-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>apacheds-service</artifactId>
+ <name>ApacheDS Service</name>
+ <packaging>jar</packaging>
+
+ <description />
+
+ <dependencies>
+ <dependency>
+ <artifactId>apacheds-core-annotations</artifactId>
+ <groupId>org.apache.directory.server</groupId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <artifactId>apacheds-core-api</artifactId>
+ <groupId>org.apache.directory.server</groupId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <artifactId>server-config</artifactId>
+ <groupId>org.apache.directory.server</groupId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
+
Added: directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/ApacheDsService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/ApacheDsService.java?rev=997697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/ApacheDsService.java (added)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/ApacheDsService.java Thu Sep 16 11:45:02 2010
@@ -0,0 +1,674 @@
+/*
+ * 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.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.changepw.ChangePasswordServer;
+import org.apache.directory.server.config.ConfigPartitionReader;
+import org.apache.directory.server.config.LdifConfigExtractor;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
+import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.core.partition.ldif.LdifPartition;
+import org.apache.directory.server.core.schema.SchemaPartition;
+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.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.AttributeTypeOptions;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+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.schema.syntaxCheckers.CsnSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.GeneralizedTimeSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.UuidSyntaxChecker;
+import org.apache.directory.shared.ldap.util.DateUtils;
+import org.apache.directory.shared.ldap.util.LdapExceptionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * DirectoryServer bean used by both the daemon code and by the ServerMain here.
+ *
+ * @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;
+
+ private HttpServer httpServer;
+
+ private LdifPartition schemaLdifPartition;
+
+ private SchemaManager schemaManager;
+
+ private LdifPartition configPartition;
+
+ private ConfigPartitionReader cpReader;
+
+ // variables used during the initial startup to update the mandatory operational
+ // attributes
+ private UuidSyntaxChecker uuidChecker = new UuidSyntaxChecker();
+
+ 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;
+
+
+ public void init( InstallationLayout layout, InstanceLayout instanceLayout ) throws Exception
+ {
+ File partitionsDir = instanceLayout.getPartitionsDirectory();
+ if ( !partitionsDir.exists() )
+ {
+ LOG.info( "partition directory doesn't exist, creating {}", partitionsDir.getAbsolutePath() );
+ partitionsDir.mkdirs();
+ }
+
+ LOG.info( "using partition dir {}", partitionsDir.getAbsolutePath() );
+ initSchemaLdifPartition( partitionsDir );
+ initConfigPartition( partitionsDir );
+
+ cpReader = new ConfigPartitionReader( configPartition );
+
+ // Initialize the LDAP server
+ initLdap( layout, instanceLayout );
+
+ // Initialize the NTP server
+ initNtp( layout );
+
+ // Initialize the DNS server (Not ready yet)
+ // initDns( layout );
+
+ // Initialize the DHCP server (Not ready yet)
+ // initDhcp( layout );
+
+ // Initialize the ChangePwd server (Not ready yet)
+ initChangePwd( layout );
+
+ // Initialize the Kerberos server
+ initKerberos( layout );
+
+ // initialize the jetty http server
+ initHttpServer();
+ }
+
+
+ /**
+ * initialize the schema partition by loading the schema LDIF files
+ *
+ * @throws Exception in case of any problems while extracting and writing the schema files
+ */
+ private void initSchemaLdifPartition( File partitionsDir ) throws Exception
+ {
+ // Init the LdifPartition
+ schemaLdifPartition = new LdifPartition();
+ schemaLdifPartition.setWorkingDirectory( partitionsDir.getPath() + "/schema" );
+
+ // Extract the schema on disk (a brand new one) and load the registries
+ File schemaRepository = new File( partitionsDir, "schema" );
+
+ if ( schemaRepository.exists() )
+ {
+ LOG.info( "schema partition already exists, skipping schema extraction" );
+ }
+ else
+ {
+ SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( partitionsDir );
+ extractor.extractOrCopy();
+ isSchemaPartitionFirstExtraction = true;
+ }
+
+ SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+ 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, LdapExceptionUtils.printErrors( errors ) ) );
+ }
+ }
+
+
+ /**
+ *
+ * initializes a LDIF partition for configuration
+ *
+ * @param partitionsDir the directory where all the partitions' data is stored
+ * @throws Exception in case of any issues while extracting the schema
+ */
+ private void initConfigPartition( File partitionsDir ) throws Exception
+ {
+
+ File configRepository = new File( partitionsDir, "config" );
+
+ if ( configRepository.exists() )
+ {
+ LOG.info( "config partition already exists, skipping default config extraction" );
+ }
+ else
+ {
+ LdifConfigExtractor.extract( partitionsDir, true );
+ isConfigPartitionFirstExtraction = true;
+ }
+
+ configPartition = new LdifPartition();
+ configPartition.setId( "config" );
+ configPartition.setSuffix( new DN( "ou=config" ) );
+ configPartition.setSchemaManager( schemaManager );
+ configPartition.setWorkingDirectory( partitionsDir.getPath() + "/config" );
+ configPartition.setPartitionDir( new File( configPartition.getWorkingDirectory() ) );
+
+ configPartition.initialize();
+ }
+
+
+ /**
+ * Initialize the LDAP server
+ */
+ private void initLdap( InstallationLayout layout, InstanceLayout instanceLayout ) throws Exception
+ {
+ LOG.info( "Starting the LDAP server" );
+
+ printBanner( BANNER_LDAP );
+ long startTime = System.currentTimeMillis();
+
+ DirectoryService directoryService = cpReader.createDirectoryService();
+ directoryService.setSchemaManager( schemaManager );
+
+ SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition();
+ schemaPartition.setWrappedPartition( schemaLdifPartition );
+ schemaPartition.setSchemaManager( schemaManager );
+
+ directoryService.addPartition( configPartition );
+
+ directoryService.setWorkingDirectory( instanceLayout.getInstanceDirectory() );
+
+ ldapServer = cpReader.createLdapServer();
+ ldapServer.setDirectoryService( directoryService );
+
+ 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" );
+
+ updateMandatoryOpAttributes( configPartition, directoryService );
+
+ 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" );
+ }
+
+ // And start the server now
+ start();
+
+ if ( LOG.isInfoEnabled() )
+ {
+ LOG.info( "LDAP server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "" );
+ }
+ }
+
+
+ /**
+ * Initialize the NTP server
+ */
+ private void initNtp( InstallationLayout layout ) throws Exception
+ {
+ ntpServer = cpReader.createNtpServer();
+ if ( ntpServer == null )
+ {
+ LOG
+ .info( "Cannot find any reference to the NTP Server in the configuration : the server won't be started" );
+ return;
+ }
+
+ getDirectoryService().startup();
+ ntpServer.setDirectoryService( getDirectoryService() );
+
+ System.out.println( "Starting the NTP server" );
+ LOG.info( "Starting the NTP server" );
+
+ printBanner( BANNER_NTP );
+ long startTime = System.currentTimeMillis();
+
+ ntpServer.start();
+ System.out.println( "NTP Server started" );
+
+ 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 ) + "" );
+ // }
+ // }
+
+ /**
+ * Initialize the KERBEROS server
+ */
+ private void initKerberos( InstallationLayout layout ) throws Exception
+ {
+ kdcServer = cpReader.createKdcServer();
+ 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() );
+
+ System.out.println( "Starting the Kerberos server" );
+ LOG.info( "Starting the Kerberos server" );
+
+ printBanner( BANNER_KERBEROS );
+ long startTime = System.currentTimeMillis();
+
+ kdcServer.start();
+
+ System.out.println( "Kerberos server started" );
+
+ if ( LOG.isInfoEnabled() )
+ {
+ LOG.info( "Kerberos server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "" );
+ }
+ }
+
+
+ /**
+ * Initialize the Change Password server
+ */
+ private void initChangePwd( InstallationLayout layout ) throws Exception
+ {
+
+ changePwdServer = cpReader.createChangePwdServer();
+ if ( changePwdServer == null )
+ {
+ LOG
+ .info( "Cannot find any reference to the Change Password Server in the configuration : the server won't be started" );
+ return;
+ }
+
+ getDirectoryService().startup();
+ changePwdServer.setDirectoryService( getDirectoryService() );
+
+ System.out.println( "Starting the Change Password server" );
+ LOG.info( "Starting the Change Password server" );
+
+ printBanner( BANNER_CHANGE_PWD );
+ long startTime = System.currentTimeMillis();
+
+ changePwdServer.start();
+
+ System.out.println( "Change Password server started" );
+ if ( LOG.isInfoEnabled() )
+ {
+ LOG.info( "Change Password server: started in {} milliseconds", ( System.currentTimeMillis() - startTime )
+ + "" );
+ }
+ }
+
+
+ private void initHttpServer() throws Exception
+ {
+ httpServer = cpReader.createHttpServer();
+ if ( httpServer == null )
+ {
+ LOG
+ .info( "Cannot find any reference to the HTTP Server in the configuration : the server won't be started" );
+ return;
+ }
+
+ if ( httpServer != null )
+ {
+ httpServer.start( getDirectoryService() );
+ }
+ }
+
+
+ public DirectoryService getDirectoryService()
+ {
+ return ldapServer.getDirectoryService();
+ }
+
+
+ public void synch() throws Exception
+ {
+ ldapServer.getDirectoryService().sync();
+ }
+
+
+ public void start()
+ {
+ try
+ {
+ ldapServer.start();
+ }
+ catch ( Exception e )
+ {
+ LOG.error( "Cannot start the server : " + e.getMessage() );
+ }
+ }
+
+
+ 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();
+ }
+
+
+ public void destroy()
+ {
+ }
+
+ 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.getSuffix(), SearchScope.SUBTREE, filter,
+ AliasDerefMode.NEVER_DEREF_ALIASES, new HashSet( MANDATORY_ENTRY_ATOP_MAP.values() ) );
+ cursor.beforeFirst();
+
+ List<Modification> mods = new ArrayList<Modification>();
+
+ while ( cursor.next() )
+ {
+ ClonedServerEntry entry = cursor.get();
+
+ AttributeType atType = MANDATORY_ENTRY_ATOP_MAP.get( SchemaConstants.ENTRY_UUID_AT ).getAttributeType();
+
+ EntryAttribute uuidAt = entry.get( atType );
+ String uuid = ( uuidAt == null ? null : uuidAt.getString() );
+
+ if ( !uuidChecker.isValidSyntax( uuid ) )
+ {
+ uuidAt = new DefaultEntryAttribute( 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();
+ EntryAttribute csnAt = entry.get( atType );
+ String csn = ( csnAt == null ? null : csnAt.getString() );
+
+ if ( !csnChecker.isValidSyntax( csn ) )
+ {
+ csnAt = new DefaultEntryAttribute( 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();
+ EntryAttribute creatorAt = entry.get( atType );
+ String creator = ( creatorAt == null ? "" : creatorAt.getString().trim() );
+
+ if ( ( creator.length() == 0 ) || ( !DN.isValid( creator ) ) )
+ {
+ creatorAt = new DefaultEntryAttribute( atType, adminDn );
+ }
+
+ Modification creatorMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, creatorAt );
+ mods.add( creatorMod );
+
+ atType = MANDATORY_ENTRY_ATOP_MAP.get( SchemaConstants.CREATE_TIMESTAMP_AT ).getAttributeType();
+ EntryAttribute createdTimeAt = entry.get( atType );
+ String createdTime = ( createdTimeAt == null ? null : createdTimeAt.getString() );
+
+ if ( !timeChecker.isValidSyntax( createdTime ) )
+ {
+ createdTimeAt = new DefaultEntryAttribute( 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/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstallationLayout.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstallationLayout.java?rev=997697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstallationLayout.java (added)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstallationLayout.java Thu Sep 16 11:45:02 2010
@@ -0,0 +1,281 @@
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * 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
+{
+ /** The logger*/
+ private final static Logger log = LoggerFactory.getLogger( InstallationLayout.class );
+
+ /** The required directories */
+ private File[] requiredDirectories = new File[]
+ {
+ getInstallationDirectory(),
+ getBinDirectory(),
+ getConfDirectory(),
+ getLibDirectory()
+ };
+
+ /** The required files */
+ private File[] requiredFiles = new File[]
+ {
+ getScriptFile(),
+ getWrapperFile(),
+ getWrapperConfigurationFile()
+ };
+
+ /** The installation directory */
+ private File installationDirectory;
+
+
+ /**
+ * Creates a new instance of InstallationLayout.
+ *
+ * @param installationDirectory
+ * the installation directory
+ */
+ public InstallationLayout( File installationDirectory )
+ {
+ this.installationDirectory = installationDirectory;
+ }
+
+
+ /**
+ * Creates a new instance of InstallationLayout.
+ *
+ * @param installationDirectoryPath
+ * the path to the installation directory
+ */
+ public InstallationLayout( String installationDirectoryPath )
+ {
+ this.installationDirectory = new File( installationDirectoryPath );
+ }
+
+
+ /**
+ * 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 installationDirectory;
+ }
+
+
+ /**
+ * 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" );
+ }
+
+
+ /**
+ * Creates the required directories (if they don't already exist).
+ */
+ public void mkdirs()
+ {
+ for ( File requiredDirectory : requiredDirectories )
+ {
+ if ( !requiredDirectory.exists() )
+ {
+ requiredDirectory.mkdirs();
+ }
+ }
+ }
+
+
+ /**
+ * Verifies the installation by checking required directories and files.
+ */
+ public void verifyInstallation()
+ {
+ log.debug( "Verifying required directories" );
+
+ // Verifying required directories
+ for ( File requiredDirectory : requiredDirectories )
+ {
+ // Exists?
+ if ( !requiredDirectory.exists() )
+ {
+ String message = "The required '" + requiredDirectory + " directory does not exist!";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+
+ // Directory?
+ if ( requiredDirectory.isFile() )
+ {
+ String message = "'" + requiredDirectory + "' is a file when it should be a directory.";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+
+ // Writable?
+ if ( !requiredDirectory.canWrite() )
+ {
+ String message = "'" + requiredDirectory
+ + "' is write protected from the current user '"
+ + System.getProperty( "user.name" ) + "'";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+ }
+
+ log.debug( "Required directories verification finished successfully." );
+
+ log.debug( "Verifying required files" );
+
+ // Verifying required files
+ for ( File requiredFile : requiredFiles )
+ {
+ // Exists?
+ if ( !requiredFile.exists() )
+ {
+ String message = "The required'" + requiredFile + "' file does not exist!";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+
+ // File?
+ if ( requiredFile.isDirectory() )
+ {
+ String message = "'" + requiredFile + "' is a directory when it should be a file.";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+
+ // Writable?
+ if ( !requiredFile.canRead() )
+ {
+ String message = "'" + requiredFile + "' is not readable by the current user '"
+ + System.getProperty( "user.name" ) + "'.";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+ }
+
+ log.debug( "Required files verification finished successfully." );
+ }
+}
Added: directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstanceLayout.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstanceLayout.java?rev=997697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstanceLayout.java (added)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/service/src/main/java/org/apache/directory/server/InstanceLayout.java Thu Sep 16 11:45:02 2010
@@ -0,0 +1,300 @@
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Convenience class to encapsulate paths to various directories and files within
+ * an instance.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InstanceLayout
+{
+ /** The logger*/
+ private final static Logger log = LoggerFactory.getLogger( InstanceLayout.class );
+
+ private static final String LOG_DIR = "apacheds.log.dir";
+ private static final String RUN_DIR = "apacheds.run.dir";
+
+ /** The required directories */
+ private File[] requiredDirectories = new File[]
+ {
+ getInstanceDirectory(),
+ getConfDirectory(),
+ getLdifDirectory(),
+ getLogDirectory(),
+ getPartitionsDirectory(),
+ getRunDirectory()
+ };
+
+ /** The required files */
+ private File[] requiredFiles = new File[]
+ {
+ getWrapperConfigurationFile(),
+ getLogConfigurationFile() /*,
+ getApacheDsConfigurationLdifFile() */// TODO re-activate this when possible.
+ };
+
+ /** The instance directory */
+ private File instanceDirectory;
+
+
+ /**
+ * Creates a new instance of InstanceLayout.
+ *
+ * @param instanceDirectory
+ * the instance directory
+ */
+ public InstanceLayout( File instanceDirectory )
+ {
+ this.instanceDirectory = instanceDirectory;
+ }
+
+
+ /**
+ * Creates a new instance of InstanceLayout.
+ *
+ * @param instanceDirectoryPath
+ * the path to the instance directory
+ */
+ public InstanceLayout( String instanceDirectoryPath )
+ {
+ this.instanceDirectory = new File( instanceDirectoryPath );
+ }
+
+
+ /**
+ * Gets the 'conf' directory.
+ *
+ * @return
+ * the 'conf' directory
+ */
+ public File getConfDirectory()
+ {
+ return new File( getInstanceDirectory(), "conf" );
+ }
+
+
+ /**
+ * Gets the 'ldif' directory.
+ *
+ * @return
+ * the 'ldif' directory
+ */
+ public File getLdifDirectory()
+ {
+ return new File( getInstanceDirectory(), "ldif" );
+ }
+
+
+ /**
+ * Gets the 'log' directory.
+ *
+ * @return
+ * the 'log' directory
+ */
+ public File getLogDirectory()
+ {
+ String logDir = System.getProperty( LOG_DIR );
+
+ if ( logDir != null )
+ {
+ return new File( logDir );
+ }
+
+ return new File( getInstanceDirectory(), "log" );
+ }
+
+
+ /**
+ * Gets the 'partitions' directory.
+ *
+ * @return
+ * the 'partitions' directory
+ */
+ public File getPartitionsDirectory()
+ {
+ return new File( getInstanceDirectory(), "partitions" );
+ }
+
+
+ /**
+ * Gets the 'run' directory in the installation directory.
+ *
+ * @return
+ * the 'run' directory
+ */
+ public File getRunDirectory()
+ {
+ String runDir = System.getProperty( RUN_DIR );
+
+ if ( runDir != null )
+ {
+ return new File( runDir );
+ }
+
+ return new File( getInstanceDirectory(), "run" );
+ }
+
+
+ /**
+ * Gets the instance directory.
+ *
+ * @return
+ * the instance directory
+ */
+ public File getInstanceDirectory()
+ {
+ return instanceDirectory;
+ }
+
+
+ /**
+ * Gets the log configuration file (<em>'/conf/log4j.properties'</em>).
+ *
+ * @return
+ * the log configuration file
+ */
+ public File getLogConfigurationFile()
+ {
+ return new File( getConfDirectory(), "log4j.properties" );
+ }
+
+
+ /**
+ * 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 apacheds configuration ldif file (<em>'/conf/wrapper.conf'</em>).
+ *
+ * @return
+ * the apacheds configuration ldif file
+ */
+ public File getApacheDsConfigurationLdifFile()
+ {
+ return new File( getConfDirectory(), "config.ldif" );
+ }
+
+
+ /**
+ * Creates the required directories (if they don't already exist).
+ */
+ public void mkdirs()
+ {
+ for ( File requiredDirectory : requiredDirectories )
+ {
+ if ( !requiredDirectory.exists() )
+ {
+ requiredDirectory.mkdirs();
+ }
+ }
+ }
+
+
+ /**
+ * Verifies the installation by checking required directories and files.
+ */
+ public void verifyInstallation()
+ {
+ log.debug( "Verifying required directories" );
+
+ // Verifying required directories
+ for ( File requiredDirectory : requiredDirectories )
+ {
+ // Exists?
+ if ( !requiredDirectory.exists() )
+ {
+ String message = "The required '" + requiredDirectory + " directory does not exist!";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+
+ // Directory?
+ if ( requiredDirectory.isFile() )
+ {
+ String message = "'" + requiredDirectory + "' is a file when it should be a directory.";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+
+ // Writable?
+ if ( !requiredDirectory.canWrite() )
+ {
+ String message = "'" + requiredDirectory
+ + "' is write protected from the current user '"
+ + System.getProperty( "user.name" ) + "'";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+ }
+
+ log.debug( "Required directories verification finished successfully." );
+
+ log.debug( "Verifying required files" );
+
+ // Verifying required files
+ for ( File requiredFile : requiredFiles )
+ {
+ // Exists?
+ if ( !requiredFile.exists() )
+ {
+ String message = "The required'" + requiredFile + "' file does not exist!";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+
+ // File?
+ if ( requiredFile.isDirectory() )
+ {
+ String message = "'" + requiredFile + "' is a directory when it should be a file.";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+
+ // Writable?
+ if ( !requiredFile.canRead() )
+ {
+ String message = "'" + requiredFile + "' is not readable by the current user '"
+ + System.getProperty( "user.name" ) + "'.";
+ log.error( message );
+ throw new IllegalStateException( message );
+ }
+ }
+
+ log.debug( "Required files verification finished successfully." );
+ }
+}
Added: directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/pom.xml?rev=997697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/pom.xml (added)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/pom.xml Thu Sep 16 11:45:02 2010
@@ -0,0 +1,49 @@
+<?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>1.5.8-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>apacheds-wrapper</artifactId>
+ <name>ApacheDS Wrapper</name>
+ <packaging>jar</packaging>
+
+ <description />
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apacheds-service</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>tanukisoft</groupId>
+ <artifactId>wrapper</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
+
Added: directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ApacheDsTanukiWrapper.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ApacheDsTanukiWrapper.java?rev=997697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ApacheDsTanukiWrapper.java (added)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ApacheDsTanukiWrapper.java Thu Sep 16 11:45:02 2010
@@ -0,0 +1,113 @@
+/*
+ * 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tanukisoftware.wrapper.WrapperListener;
+import org.tanukisoftware.wrapper.WrapperManager;
+
+
+/**
+ * The bootstrapper used by Tanuki Wrapper.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ApacheDsTanukiWrapper implements WrapperListener
+{
+ private static final Logger log = LoggerFactory.getLogger( ApacheDsTanukiWrapper.class );
+
+ private ApacheDsService service;
+
+
+ private ApacheDsTanukiWrapper()
+ {
+ }
+
+
+ public static void main( String[] args )
+ {
+ WrapperManager.start( new ApacheDsTanukiWrapper(), args );
+ }
+
+
+ public Integer start( String[] args )
+ {
+ service = new ApacheDsService();
+ InstallationLayout installationLayout = new InstallationLayout( ( File ) null ); // TODO
+ InstanceLayout instanceLayout = new InstanceLayout( ( File ) null ); // TODO
+ try
+ {
+ service.init( installationLayout, instanceLayout );
+ }
+ catch ( Exception e )
+ {
+ log.error( "Failed to start", e );
+ System.exit( ExitCodes.START );
+ }
+ service.start();
+ return null;
+ }
+
+
+ public int stop( int exitCode )
+ {
+ log.info( "Attempting graceful shutdown of this server instance" );
+
+ try
+ {
+ service.stop();
+ }
+ catch ( Exception e )
+ {
+ log.error( "Failed to stop", e );
+ System.exit( ExitCodes.STOP );
+ }
+
+ log.info( "Completed graceful shutdown..." );
+
+ return exitCode;
+ }
+
+
+ public void controlEvent( int event )
+ {
+ log.error( "Recvd Event: " + event );
+ if ( WrapperManager.isControlledByNativeWrapper() )
+ {
+ // The Wrapper will take care of this event
+ }
+ else
+ {
+ // We are not being controlled by the Wrapper, so
+ // handle the event ourselves.
+ if ( ( event == WrapperManager.WRAPPER_CTRL_C_EVENT ) ||
+ ( event == WrapperManager.WRAPPER_CTRL_CLOSE_EVENT ) ||
+ ( event == WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT ) )
+ {
+ WrapperManager.stop( 0 );
+ }
+ }
+ }
+}
Added: directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ExitCodes.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ExitCodes.java?rev=997697&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ExitCodes.java (added)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/wrapper/src/main/java/org/apache/directory/server/ExitCodes.java Thu Sep 16 11:45:02 2010
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+
+/**
+ * Exit codes for the bootstrappers.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface ExitCodes
+{
+ int CLASS_LOOKUP = 1;
+ int INSTANTIATION = 2;
+ int METHOD_LOOKUP = 3;
+ int INITIALIZATION = 4;
+ int START = 5;
+ int STOP = 6;
+ int PROPLOAD = 7;
+ int VERIFICATION = 8;
+ int DESTROY = 9;
+ int BAD_ARGUMENTS = 10;
+ int BAD_COMMAND = 11;
+ int UNKNOWN = 12;
+ int INVOCATION = 13;
+}