You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by jc...@apache.org on 2006/12/08 23:23:53 UTC
svn commit: r484824 - in /directory/sandbox/jconlon/osgi-apacheds/core-osgi:
./ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/directory/
src/main/java/org/apache/directory/osgi/ src/main/java/org/ap...
Author: jconlon
Date: Fri Dec 8 14:23:50 2006
New Revision: 484824
URL: http://svn.apache.org/viewvc?view=rev&rev=484824
Log:
added core OSGi subproject
Added:
directory/sandbox/jconlon/osgi-apacheds/core-osgi/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/pom.xml
directory/sandbox/jconlon/osgi-apacheds/core-osgi/server.properties
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/BackendStartupConfiguration.java
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/InitialContextFactoryImpl.java
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/FileFactoryBean.java
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/SchemaFactoryBean.java
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server-osgi.xml
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server.xml
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/directory/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/directory/osgi/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/directory/osgi/backend/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/directory/osgi/backend/IntegrationTest.java
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/log4j.properties
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/nonspecific.ldif
directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/osgiMockServer.xml
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/pom.xml?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/pom.xml (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/pom.xml Fri Dec 8 14:23:50 2006
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>build</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>apacheds-core-osgi</artifactId>
+ <name>${pom.artifactId} bundle</name>
+ <packaging>bundle</packaging>
+ <description>The ApacheDS JNDI Backing Store packaged as an OSGi bundle.</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Spring-Context>*;publish-context:=false</Spring-Context>
+ <Export-Package>!META-INF.*,!jdbm,!jdbm.*,*</Export-Package>
+ <Import-Package>!javax.swing,!javax.swing.*,!jdbm,!jdbm.*,*</Import-Package>
+ <DynamicImport-Package>antlr</DynamicImport-Package>
+ <!--Specify to include the jdbm packages as private packages, because the jdbm
+ libraries are required to load apacheds classes. The alternate was
+ to create a wrapped jdbm bundle and allow it to import apacheds classes.-->
+ <Private-Package>jdbm,jdbm.*</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-core</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-core-shared</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.shared</groupId>
+ <artifactId>shared-asn1</artifactId>
+ <version>0.9.6-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.shared</groupId>
+ <artifactId>shared-ldap</artifactId>
+ <version>0.9.6-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>jdbm</groupId>
+ <artifactId>jdbm</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-mock</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.0-rc5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>nlog4j</artifactId>
+ <version>1.2.19</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>2.7.2</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/server.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/server.properties?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/server.properties (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/server.properties Fri Dec 8 14:23:50 2006
@@ -0,0 +1,4 @@
+#serverWorkingDirectory.fileName=verticon.com
+examplePartitionConfiguration.name=verticon
+examplePartitionConfiguration.suffix=dc=verticon,dc=com
+examplePartitionConfiguration.contextEntry=objectClass: top objectClass: domain objectClass: extensibleObject dc: verticon
\ No newline at end of file
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/BackendStartupConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/BackendStartupConfiguration.java?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/BackendStartupConfiguration.java (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/BackendStartupConfiguration.java Fri Dec 8 14:23:50 2006
@@ -0,0 +1,88 @@
+/*
+ * 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.osgi.backend;
+
+
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+
+
+/**
+ *
+ * BackendStartupConfiguration is an Apache Directory Configuration for
+ * starting up the Backend. Mannaged by the Spring IOC.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BackendStartupConfiguration extends MutableStartupConfiguration
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5772825210553991483L;
+ private static final long DEFAULT_SYNC_PERIOD_MILLIS = 20000;
+ private long synchPeriodMillis = DEFAULT_SYNC_PERIOD_MILLIS;
+
+
+ /**
+ *
+ * Creates a new instance of BackendStartupConfiguration.
+ *
+ */
+ public BackendStartupConfiguration()
+ {
+ super();
+ }
+
+
+ /**
+ *
+ * Creates a new instance of BackendStartupConfiguration.
+ *
+ * @param arg0
+ */
+ public BackendStartupConfiguration( String arg0 )
+ {
+ super( arg0 );
+ }
+
+
+ /**
+ *
+ * @return synchPeriodMillis
+ */
+ public long getSynchPeriodMillis()
+ {
+ return synchPeriodMillis;
+ }
+
+
+ /**
+ *
+ *
+ * @param synchPeriodMillis
+ */
+ public void setSynchPeriodMillis( long synchPeriodMillis )
+ {
+ this.synchPeriodMillis = synchPeriodMillis;
+ }
+
+}
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/InitialContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/InitialContextFactoryImpl.java?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/InitialContextFactoryImpl.java (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/backend/InitialContextFactoryImpl.java Fri Dec 8 14:23:50 2006
@@ -0,0 +1,179 @@
+/*
+ * 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.osgi.backend;
+
+
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.InitialDirContext;
+import javax.naming.spi.InitialContextFactory;
+
+import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.directory.server.core.configuration.SyncConfiguration;
+import org.apache.directory.server.core.jndi.CoreContextFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ *
+ * InitialContextFactoryImpl is a InitialContextFactory OSGi service implemenation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InitialContextFactoryImpl implements InitialContextFactory
+{
+ private static final Logger log = LoggerFactory.getLogger( InitialContextFactoryImpl.class );
+ private final Map<String, String> immutableProperties;
+ private final BackendStartupConfiguration cfg;
+ private volatile boolean hasStarted = false;
+ private ScheduledExecutorService exec = null;
+
+
+ /**
+ *
+ * Creates a new instance of InitialContextFactoryImpl.
+ *
+ * @param configuration
+ * @param environment
+ */
+ public InitialContextFactoryImpl( BackendStartupConfiguration configuration, Properties environment )
+ {
+ super();
+ cfg = configuration;
+ immutableProperties = new ConcurrentHashMap( environment );
+
+ }
+
+
+ /**
+ *
+ * Spring init-method.
+ *
+ */
+ public void init()
+ {
+ long startTime = System.currentTimeMillis();
+ Hashtable env = new Hashtable( immutableProperties );
+ env.put( Context.PROVIDER_URL, "" );
+ env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
+ env.putAll( cfg.toJndiEnvironment() );
+ try
+ {
+ new InitialDirContext( env );
+ }
+ catch ( NamingException e1 )
+ {
+ log.error( "Failed to start the server.", e1 );
+ return;
+ }
+
+ hasStarted = true;
+ if ( log.isInfoEnabled() )
+ {
+ log.info( "server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "" );
+ }
+ if ( cfg.getSynchPeriodMillis() > 0 )
+ {
+ exec = Executors.newScheduledThreadPool( 1 );
+
+ Runnable command = new Runnable()
+ {
+ public void run()
+ {
+
+ synch();
+ }
+ };
+
+ exec.scheduleAtFixedRate( command, 10, cfg.getSynchPeriodMillis(), TimeUnit.MILLISECONDS );
+ log.info( "syncing server: scheduled for {} milliseconds", cfg.getSynchPeriodMillis() );
+ }
+ else
+ {
+ log.info( "syncing server: not scheduled" );
+ }
+ }
+
+
+ /**
+ *
+ * Spring destroy-method.
+ *
+ */
+ public void destroy() throws Exception
+ {
+ if ( exec != null )
+ {
+ exec.shutdownNow();
+ }
+ log.info( "Shuting down server." );
+ new InitialDirContext( new ShutdownConfiguration().toJndiEnvironment() );
+ log.info( "Server shutdown." );
+
+ }
+
+
+ /**
+ *
+ * Called by scheduler to sync backend.
+ *
+ */
+ private void synch()
+ {
+ log.debug( "Syncing backend." );
+ Properties env = new Properties();
+ env.putAll( immutableProperties );
+ env.putAll( new SyncConfiguration().toJndiEnvironment() );
+ try
+ {
+ new InitialDirContext( env );
+ }
+ catch ( NamingException e )
+ {
+ log.error( "Failed to sync the backend.", e );
+ }
+ }
+
+
+ public Context getInitialContext( Hashtable environment ) throws NamingException
+ {
+ if ( !hasStarted )
+ {
+ throw new IllegalStateException( "Component is not Started." );
+ }
+ CoreContextFactory factory = new CoreContextFactory();
+ Hashtable env = new Hashtable( immutableProperties );
+ if ( environment != null )
+ {
+ env.putAll( environment );
+ }
+ return factory.getInitialContext( env );
+ }
+}
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/FileFactoryBean.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/FileFactoryBean.java?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/FileFactoryBean.java (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/FileFactoryBean.java Fri Dec 8 14:23:50 2006
@@ -0,0 +1,72 @@
+/*
+ * 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.osgi.spring;
+
+
+import java.io.File;
+
+
+/**
+ *
+ * FileFactoryBean is a Spring instance factory bean is used to create File objects.
+ * Using a instance factory in a spring configuration allows Files to be configured with
+ * a org.springframework.beans.factory.config.PropertyOverrideConfigurer and external
+ * property files.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class FileFactoryBean
+{
+
+ private File file;
+
+
+ /**
+ *
+ * Creates a new instance of FileFactoryBean.
+ *
+ */
+ public FileFactoryBean()
+ {
+ super();
+ }
+
+
+ /**
+ * factory-method
+ * @return the file
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+
+ /**
+ * property setter
+ * @param file
+ */
+ public void setFileName( String file )
+ {
+ this.file = new File( file );
+ }
+
+}
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/SchemaFactoryBean.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/SchemaFactoryBean.java?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/SchemaFactoryBean.java (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/java/org/apache/directory/osgi/spring/SchemaFactoryBean.java Fri Dec 8 14:23:50 2006
@@ -0,0 +1,85 @@
+/*
+ * 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.osgi.spring;
+
+
+import java.util.Set;
+
+import org.apache.directory.server.core.schema.bootstrap.BootstrapSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ *
+ * SchemaFactoryBean a Spring instance factory bean is used to create Sets of schema
+ * class names. Using this instance factory in a spring configuration allows dependencies
+ * to be merged with base with a
+ * org.springframework.beans.factory.config.PropertyOverrideConfigurer and external
+ * property files.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaFactoryBean
+{
+ /** the log for this class */
+ private static final Logger log = LoggerFactory.getLogger( SchemaFactoryBean.class );
+ private Set<BootstrapSchema> schemas;
+
+
+ public SchemaFactoryBean( Set<BootstrapSchema> baseSchemas )
+ {
+ schemas = baseSchemas;
+ }
+
+
+ /**
+ * factory-method
+ * @return the file
+ */
+ public Set<BootstrapSchema> getSchemas()
+ {
+ return schemas;
+ }
+
+
+ /**
+ * property setter
+ * @param file
+ */
+ public void setCustomSchemas( Set<BootstrapSchema> customSchemas )
+ {
+ log.info( "Locating custom schemas ..." );
+ try
+ {
+ for ( BootstrapSchema schema : customSchemas )
+ {
+ schemas.add( schema );
+ log.info( "Found Schema: " + schema.getClass().getName() );
+ }
+ }
+ catch ( RuntimeException e )
+ {
+ log.info( "Found no custom schemas." );
+ }
+ }
+
+}
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server-osgi.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server-osgi.xml?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server-osgi.xml (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server-osgi.xml Fri Dec 8 14:23:50 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+
+ <!-- Find OSGi BootstrapSchema services. This OSGi reference is not used at this time
+ because spring-osgi does not implement optional osgi:reference functionality.
+ <osgi:reference id="osgiSchemas"
+ interface="org.apache.directory.server.core.schema.bootstrap.BootstrapSchema"
+ cardinality="0..n"/>
+ -->
+
+ <!-- Register the InitialContextFactoryImpl bean (defined in a separate
+ config file in this case) as an OSGi service -->
+ <osgi:service id="initialContextFactory" ref="initialContextFactoryService"
+ interface="javax.naming.spi.InitialContextFactory" />
+
+</beans>
\ No newline at end of file
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server.xml?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server.xml (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/main/resources/META-INF/spring/server.xml Fri Dec 8 14:23:50 2006
@@ -0,0 +1,434 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+
+ <!-- This configuration file will reside within the bundle. To change the configuration
+ an external properties file called server.properties in the working directory
+ can be used to override the exposed property values. -->
+ <bean id="propertyConfigurer"
+ class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
+ <property name="location">
+ <bean class="org.springframework.core.io.FileSystemResource">
+ <constructor-arg value="server.properties"/>
+ </bean>
+ </property>
+ <property name="ignoreInvalidKeys" value="true"/>
+ </bean>
+
+ <!-- Spring OSGi places restrictions on how file resources are specified and retrieved from
+ the filesystem. This factory bean, containing a property named fileName, can be
+ configured with an external properties file to change the workingDirectory of the server.
+ -->
+ <bean id="serverWorkingDirectory"
+ class="org.apache.directory.osgi.spring.FileFactoryBean">
+ <property name="fileName"
+ value="server-work"/>
+ </bean>
+
+ <!-- This factory combines the base set of schemas with those that are found on the
+ OSGi runtime. Referenced by configuration.bootstrapSchemas.
+ -->
+ <bean id="serverBootstrapSchemas"
+ class="org.apache.directory.osgi.spring.SchemaFactoryBean">
+ <constructor-arg>
+ <set>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.AutofsSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.CorbaSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.CoreSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.CosineSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.ApacheSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.CollectiveSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.InetorgpersonSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.JavaSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.Krb5kdcSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.NisSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.SystemSchema"/>
+ <bean class="org.apache.directory.server.core.schema.bootstrap.ApachednsSchema"/>
+ </set>
+ </constructor-arg>
+ <!-- This OSGi dependency is not used at this time because spring-osgi does not implement
+ optional osgi:reference functionality.
+ <property name="customSchemas" ref="osgiSchemas"/>
+ -->
+ </bean>
+
+ <!-- This is the primary OSGi service implemenation. It will be created by the context
+ and register as an InitialContextFactory service.-->
+ <bean name="initialContextFactoryService"
+ class="org.apache.directory.osgi.backend.InitialContextFactoryImpl"
+ destroy-method="destroy"
+ init-method="init">
+ <constructor-arg ref="environment"/>
+ <constructor-arg ref="configuration"/>
+ </bean>
+
+ <bean id="environment" class="org.springframework.beans.factory.config.PropertiesFactoryBean" >
+ <property name="properties">
+ <props>
+ <prop key="java.naming.security.authentication">simple</prop>
+ <prop key="java.naming.security.principal">uid=admin,ou=system</prop>
+ <prop key="java.naming.security.credentials">secret</prop>
+ <!--<prop key="kdc.entryBaseDn">ou=users,dc=example,dc=com</prop>-->
+ <!--<prop key="kdc.java.naming.security.credentials">secret</prop>-->
+ <!--<prop key="changepw.entryBaseDn">ou=users,dc=example,dc=com</prop>-->
+ <!--<prop key="changepw.java.naming.security.credentials">secret</prop>-->
+
+ </props>
+ </property>
+ </bean>
+
+ <bean id="configuration"
+ class="org.apache.directory.osgi.backend.BackendStartupConfiguration" >
+
+ <!-- Could hard code the servers working directory with a File class but then we
+ cant change the name from an external properties file.
+ <property name="workingDirectory">
+ <bean class="java.io.File">
+ <constructor-arg type="java.lang.String" value="example.com"/>
+ </bean>
+ </property>
+ -->
+ <!-- Use the factory instead.-->
+ <property name="workingDirectory">
+ <bean
+ factory-bean="serverWorkingDirectory"
+ factory-method="getFile"/>
+ </property>
+
+
+
+ <!--Disable the shutdownhook. The server will be stopped if the context is destroyed.-->
+ <property name="shutdownHookEnabled">
+ <value>false</value>
+ </property>
+
+ <property name="systemPartitionConfiguration">
+ <ref bean="systemPartitionConfiguration"/>
+ </property>
+
+ <property name="contextPartitionConfigurations">
+ <set>
+ <ref bean="examplePartitionConfiguration"/>
+ </set>
+ </property>
+ <property name="bootstrapSchemas">
+ <bean
+ factory-bean="serverBootstrapSchemas"
+ factory-method="getSchemas"/>
+ </property>
+
+ <!-- the number of milliseconds before issuing a synch (flush to disk) -->
+ <!-- which writes out dirty pages back to disk. To turn off synchs all -->
+ <!-- together simply set this value to <= 0. Make sure you turn on -->
+ <!-- synchOnWrite for all partitions if you do choose to do this or else-->
+ <!-- writes may never persist to disk. -->
+ <property name="synchPeriodMillis"><value>10000</value></property>
+
+ <!-- limits searches by non-admin users to a max time of 15000 -->
+ <!-- milliseconds and has a default value of 10000 -->
+ <property name="maxTimeLimit">
+ <value>15000</value>
+ </property>
+ <!-- limits searches to max size of 1000 entries: default value is 100 -->
+ <property name="maxSizeLimit">
+ <value>1000</value>
+ </property>
+ <!-- maximum number of threads used by mina is set to 8: default is 4 -->
+ <property name="maxThreads">
+ <value>8</value>
+ </property>
+ <property name="allowAnonymousAccess">
+ <value>false</value>
+ </property>
+ <property name="accessControlEnabled">
+ <value>false</value>
+ </property>
+ <!--
+ It's more efficient to keep this feature turned off but you may not like
+ having the creatorsName and modifiersName contain OIDs instead of short
+ attributeType names instead. So if you want the creatorsName to change
+ from the normalized form which is the internal representation of
+
+ '0.9.2342.19200300.100.1.1=admin,2.5.4.11=system'
+
+ to a more human readabile form like:
+
+ 'uid=admin,ou=system'
+
+ then set this property to true.
+ -->
+ <property name="denormalizeOpAttrsEnabled">
+ <value>true</value>
+ </property>
+
+ <property name="interceptorConfigurations">
+ <list>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>normalizationService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.normalization.NormalizationService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>authenticationService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.authn.AuthenticationService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>referralService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.referral.ReferralService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>authorizationService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.authz.AuthorizationService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>defaultAuthorizationService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.authz.DefaultAuthorizationService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>exceptionService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.exception.ExceptionService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>schemaService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.schema.SchemaService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>subentryService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.subtree.SubentryService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>operationalAttributeService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.operational.OperationalAttributeService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>collectiveAttributeService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.collective.CollectiveAttributeService"/>
+ </property>
+ </bean>
+ <bean class="org.apache.directory.server.core.configuration.MutableInterceptorConfiguration">
+ <property name="name">
+ <value>eventService</value>
+ </property>
+ <property name="interceptor">
+ <bean class="org.apache.directory.server.core.event.EventService"/>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ <!-- use the following partitionConfiguration to override defaults for -->
+ <!-- the system partition -->
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration" id="systemPartitionConfiguration">
+ <property name="name">
+ <value>system</value>
+ </property>
+ <property name="cacheSize">
+ <value>100</value>
+ </property>
+ <property name="suffix">
+ <value>ou=system</value>
+ </property>
+ <!-- the optimizer is enabled by default but may not always be what -->
+ <!-- you want if your queries are really simple -->
+ <property name="optimizerEnabled">
+ <value>true</value>
+ </property>
+ <!--
+ Synchronization on writes does not wait for synch operations
+ to flush dirty pages. Writes persist immediately to disk at
+ a cost to performance with increased data integrity. Otherwise
+ the periodic synch operation will flush dirty pages using the
+ synchPeriodMillis parameter in the main configuration.
+ -->
+ <property name="synchOnWrite">
+ <value>true</value>
+ </property>
+ <property name="indexedAttributes">
+ <set>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.1</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.2</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.3</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.4</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.5</value></property>
+ <property name="cacheSize"><value>10</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.6</value></property>
+ <property name="cacheSize"><value>10</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.7</value></property>
+ <property name="cacheSize"><value>10</value></property>
+ </bean>
+
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>ou</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>uid</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>objectClass</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ </set>
+ </property>
+ <property name="contextEntry">
+ <value>
+ objectClass: top
+ objectClass: organizationalUnit
+ objectClass: extensibleObject
+ ou: system
+ </value>
+ </property>
+ </bean>
+ <bean id="examplePartitionConfiguration"
+ class="org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration" >
+ <property name="name">
+ <value>example</value>
+ </property>
+ <property name="cacheSize">
+ <value>100</value>
+ </property>
+ <property name="suffix">
+ <value>dc=example,dc=com</value>
+ </property>
+ <!-- the optimizer is enabled by default but may not always be what -->
+ <!-- you want if your queries are really simple -->
+ <property name="optimizerEnabled">
+ <value>true</value>
+ </property>
+ <!--
+ Synchronization on writes does not wait for synch operations
+ to flush dirty pages. Writes persist immediately to disk at
+ a cost to performance with increased data integrity. Otherwise
+ the periodic synch operation will flush dirty pages using the
+ synchPeriodMillis parameter in the main configuration.
+ -->
+ <property name="synchOnWrite">
+ <value>true</value>
+ </property>
+ <property name="indexedAttributes">
+ <set>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.1</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.2</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.3</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.4</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.5</value></property>
+ <property name="cacheSize"><value>10</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.6</value></property>
+ <property name="cacheSize"><value>10</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>1.3.6.1.4.1.18060.0.4.1.2.7</value></property>
+ <property name="cacheSize"><value>10</value></property>
+ </bean>
+
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>dc</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>ou</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>krb5PrincipalName</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>uid</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ <bean class="org.apache.directory.server.core.partition.impl.btree.MutableIndexConfiguration">
+ <property name="attributeId"><value>objectClass</value></property>
+ <property name="cacheSize"><value>100</value></property>
+ </bean>
+ </set>
+ </property>
+ <property name="contextEntry">
+ <value>
+ objectClass: top
+ objectClass: domain
+ objectClass: extensibleObject
+ dc: example
+ </value>
+ </property>
+ </bean>
+ <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
+ <property name="customEditors">
+ <map>
+ <entry key="javax.naming.directory.Attributes">
+ <bean class="org.apache.directory.server.core.configuration.AttributesPropertyEditor"/>
+ </entry>
+ </map>
+ </property>
+ </bean>
+</beans>
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/directory/osgi/backend/IntegrationTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/directory/osgi/backend/IntegrationTest.java?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/directory/osgi/backend/IntegrationTest.java (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/java/org/apache/directory/osgi/backend/IntegrationTest.java Fri Dec 8 14:23:50 2006
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2006 the original author or authors.
+ *
+ * Licensed 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.osgi.backend;
+
+
+import java.io.File;
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.spi.InitialContextFactory;
+
+import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
+import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.PropertiesFactoryBean;
+import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
+
+/**
+ * Integration test the service locally (outside of OSGi).
+ * Use AbstractOsgiTests and a separate integration test project
+ * for testing inside of OSGi.
+ *
+ *
+ */
+public class IntegrationTest extends AbstractDependencyInjectionSpringContextTests {
+ /** the log for this class */
+ private static final Logger log = LoggerFactory
+ .getLogger(IntegrationTest.class);
+ private PropertiesFactoryBean propertyFactoryBean;
+ private MutableStartupConfiguration configuration;
+ private InitialContextFactoryImpl initialContextFactoryImpl;
+ private MutableBTreePartitionConfiguration examplePartitionConfiguration;
+
+
+ public IntegrationTest() {
+ super();
+// this.setAutowireMode(AUTOWIRE_BY_NAME);
+ }
+
+
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i=0; i<children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+
+ protected String[] getConfigLocations() {
+ return new String[] {"osgiMockServer.xml","META-INF/spring/server.xml"
+ };
+ }
+
+ public void setEnvironment(PropertiesFactoryBean service) {
+ this.propertyFactoryBean = service;
+ }
+
+ public void setConfiguration(MutableStartupConfiguration mutableServerStartupConfiguration) {
+ this.configuration = mutableServerStartupConfiguration;
+ }
+
+
+ public void setInitialContextFactoryService(
+ InitialContextFactoryImpl initialContextFactoryImpl) {
+ this.initialContextFactoryImpl=initialContextFactoryImpl;
+ }
+
+
+
+// public void setExamplePartitionConfiguration(
+// MutableBTreePartitionConfiguration examplePartitionConfiguration) {
+// this.examplePartitionConfiguration = examplePartitionConfiguration;
+// }
+
+ /* ==================================== Tests ===================================================*/
+ public void testEnvironment() throws BeansException, Exception {
+ assertNotNull(propertyFactoryBean);
+ assertTrue(
+ propertyFactoryBean.isSingleton());
+
+ Object o = this.applicationContext.getBean("examplePartitionConfiguration");
+ assertNotNull(o);
+ }
+ public void testExamplePartitionConfiguration() {
+ Object o = this.applicationContext.getBean("examplePartitionConfiguration");
+ assertNotNull(o);
+ assertTrue(o instanceof MutableBTreePartitionConfiguration);
+ MutableBTreePartitionConfiguration conf = (MutableBTreePartitionConfiguration) o;
+ assertEquals("verticon", conf.getName());
+ assertEquals("dc=verticon,dc=com", conf.getSuffix());
+ Attributes atts = conf.getContextEntry();
+ System.out.println("*******************" +atts.toString());
+ }
+
+ public void testConfiguration() {
+ assertNotNull(configuration);
+ }
+
+ public void testInitialContextFactoryImpl() {
+ assertNotNull(initialContextFactoryImpl);
+ assertTrue(initialContextFactoryImpl instanceof InitialContextFactory);
+
+ InitialContextFactory factory = initialContextFactoryImpl;
+
+ Context context = null;
+ try {
+ context = factory.getInitialContext(null);
+ } catch (NamingException e1) {
+ fail(e1.toString());
+ }
+ assertNotNull(context);
+
+ assertTrue(context instanceof DirContext);
+
+ DirContext dirContext = (DirContext) context;
+
+ SearchControls sc = new SearchControls();
+ sc.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+ NamingEnumeration ne = null;
+ try {
+ ne = dirContext
+ .search("ou=system", "(objectclass=*)", sc);
+ } catch (NamingException e) {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ assertNotNull(ne);
+ int count = 0;
+ try {
+
+ while (ne.hasMore()) {
+ count++;
+ SearchResult sr = (SearchResult) ne.next();
+ log.debug('\n' + sr.toString());
+// assertEquals("uid=admin,ou=system", sr.getName());
+ }
+ } catch (NamingException e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ try {
+ ne.close();
+ } catch (NamingException e) {
+ fail(e.toString());
+ }
+ }
+ assertEquals(5
+ ,count);
+ try {
+ initialContextFactoryImpl.destroy();
+ } catch (Exception e) {
+ fail(e.toString());
+ }
+
+ }
+
+
+
+
+ public void testExamplePartition() {
+ assertNotNull(initialContextFactoryImpl);
+ assertTrue(initialContextFactoryImpl instanceof InitialContextFactory);
+
+ InitialContextFactory factory = initialContextFactoryImpl;
+
+ Context context = null;
+ try {
+ context = factory.getInitialContext(null);
+ } catch (NamingException e1) {
+ fail(e1.toString());
+ }
+ assertNotNull(context);
+
+ assertTrue(context instanceof DirContext);
+
+ DirContext dirContext = (DirContext) context;
+
+ SearchControls sc = new SearchControls();
+ sc.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+ NamingEnumeration ne = null;
+ try {
+ ne = dirContext
+ .search("dc=verticon,dc=com", "(objectclass=*)", sc);
+ } catch (NamingException e) {
+ e.printStackTrace();
+ fail(e.toString());
+
+ } finally {
+ try {
+ ne.close();
+ } catch (NamingException e) {
+ fail(e.toString());
+ }
+ }
+
+ try {
+ initialContextFactoryImpl.destroy();
+ } catch (Exception e) {
+ fail(e.toString());
+ }
+
+ }
+
+
+
+
+}
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/log4j.properties?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/log4j.properties (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/log4j.properties Fri Dec 8 14:23:50 2006
@@ -0,0 +1,15 @@
+# RootCategory all other categories inherit from this
+log4j.rootCategory=WARN,console
+
+# Production classes that use logging
+log4j.category.org.apache.ldap.server=DEBUG
+log4j.category.org.apache.directory.osgi.backend=DEBUG
+log4j.category.org.apache.directory.osgi.spring=INFO
+log4j.category.org.apache.directory.server.core.configuration=DEBUG
+log4j.category.org.apache.directory.server.protocol.shared.store=DEBUG
+
+# Console Appender
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.target=System.out
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%-5p %l - %m%n
\ No newline at end of file
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/nonspecific.ldif
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/nonspecific.ldif?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/nonspecific.ldif (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/nonspecific.ldif Fri Dec 8 14:23:50 2006
@@ -0,0 +1,14 @@
+dn: cn=person0,dc=example,dc=com
+objectClass: person
+cn: cn_person0
+sn: sn_person0
+
+dn: cn=person1,dc=example,dc=com
+objectClass: organizationalPerson
+cn: cn_person1
+sn: sn_person1
+
+dn: cn=person2,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: cn_person2
+sn: sn_person2
Added: directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/osgiMockServer.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/osgiMockServer.xml?view=auto&rev=484824
==============================================================================
--- directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/osgiMockServer.xml (added)
+++ directory/sandbox/jconlon/osgi-apacheds/core-osgi/src/test/resources/osgiMockServer.xml Fri Dec 8 14:23:50 2006
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+
+ <bean id="osgiSchemas" class="org.springframework.beans.factory.config.SetFactoryBean">
+ <property name = "sourceSet">
+ <set/>
+ </property>
+ </bean>
+
+</beans>