directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r190061 - in /directory/apacheds/branches/direve-158: core/src/main/java/org/apache/ldap/server/configuration/AttributesPropertyEditor.java main/project.properties main/project.xml main/server.properties main/server.xml main/src/main/java/org/apache/ldap/server/ServerMain.java project.properties
Date Sat, 11 Jun 2005 02:38:57 GMT
Author: trustin
Date: Fri Jun 10 19:38:56 2005
New Revision: 190061

URL: http://svn.apache.org/viewcvs?rev=190061&view=rev
Log:
* Added AttributesPropertyEditor to integrate with Spring Framework
* Finished migrating apacheds/main to Spring Framework
* Set default sourcer version to 1.4


Added:
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/AttributesPropertyEditor.java
  (with props)
    directory/apacheds/branches/direve-158/main/server.xml
Removed:
    directory/apacheds/branches/direve-158/main/server.properties
Modified:
    directory/apacheds/branches/direve-158/main/project.properties
    directory/apacheds/branches/direve-158/main/project.xml
    directory/apacheds/branches/direve-158/main/src/main/java/org/apache/ldap/server/ServerMain.java
    directory/apacheds/branches/direve-158/project.properties

Added: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/AttributesPropertyEditor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/AttributesPropertyEditor.java?rev=190061&view=auto
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/AttributesPropertyEditor.java
(added)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/AttributesPropertyEditor.java
Fri Jun 10 19:38:56 2005
@@ -0,0 +1,149 @@
+package org.apache.ldap.server.configuration;
+
+import java.beans.PropertyEditorSupport;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+
+import org.apache.commons.collections.MultiHashMap;
+import org.apache.ldap.common.ldif.LdifComposer;
+import org.apache.ldap.common.ldif.LdifComposerImpl;
+import org.apache.ldap.common.ldif.LdifParser;
+import org.apache.ldap.common.ldif.LdifParserImpl;
+import org.apache.ldap.common.util.MultiMap;
+
+public class AttributesPropertyEditor extends PropertyEditorSupport
+{
+
+    public AttributesPropertyEditor()
+    {
+        super();
+    }
+
+    public AttributesPropertyEditor( Object source )
+    {
+        super( source );
+    }
+
+    public String getAsText()
+    {
+        LdifComposer composer = new LdifComposerImpl();
+        MultiMap map = new MultiMap()
+        {
+            private final MultiHashMap map = new MultiHashMap();
+
+            public Object remove( Object arg0, Object arg1 )
+            {
+                return map.remove( arg0, arg1 );
+            }
+
+            public int size()
+            {
+                return map.size();
+            }
+
+            public Object get( Object arg0 )
+            {
+                return map.get( arg0 );
+            }
+
+            public boolean containsValue( Object arg0 )
+            {
+                return map.containsValue( arg0 );
+            }
+
+            public Object put( Object arg0, Object arg1 )
+            {
+                return map.put( arg0, arg1 );
+            }
+
+            public Object remove( Object arg0 )
+            {
+                return map.remove( arg0 );
+            }
+
+            public Collection values()
+            {
+                return map.values();
+            }
+
+            public boolean isEmpty()
+            {
+                return map.isEmpty();
+            }
+
+            public boolean containsKey( Object key )
+            {
+                return map.containsKey( key );
+            }
+
+            public void putAll( Map arg0 )
+            {
+                map.putAll( arg0 );
+            }
+
+            public void clear()
+            {
+                map.clear();
+            }
+
+            public Set keySet()
+            {
+                return map.keySet();
+            }
+
+            public Set entrySet()
+            {
+                return map.entrySet();
+            }
+        };
+        
+        Attributes attrs = ( Attributes ) getValue();
+        try
+        {
+            NamingEnumeration e = attrs.getAll();
+            while( e.hasMore() )
+            {
+                Attribute attr = ( Attribute ) e.next();
+                NamingEnumeration e2 = attr.getAll();
+                while( e2.hasMoreElements() )
+                {
+                    Object value = e2.next();
+                    map.put( attr.getID(), value );
+                }
+            }
+
+            return composer.compose( map );
+        }
+        catch( Exception e )
+        {
+            throw new ConfigurationException( e );
+        }
+    }
+
+    public void setAsText( String text ) throws IllegalArgumentException
+    {
+        if( text == null )
+        {
+            text = "";
+        }
+
+        Attributes attrs = new BasicAttributes( true );
+        LdifParser parser = new LdifParserImpl();
+        try
+        {
+            parser.parse( attrs, text.trim() );
+            setValue( attrs );
+        }
+        catch( NamingException e )
+        {
+            throw ( IllegalArgumentException ) new IllegalArgumentException().initCause(
e );
+        }
+    }
+}

Propchange: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/AttributesPropertyEditor.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/apacheds/branches/direve-158/main/project.properties
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/main/project.properties?rev=190061&r1=190060&r2=190061&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/main/project.properties (original)
+++ directory/apacheds/branches/direve-158/main/project.properties Fri Jun 10 19:38:56 2005
@@ -1,5 +1,4 @@
 
-
 #
 # Javaapp plugin properties
 #

Modified: directory/apacheds/branches/direve-158/main/project.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/main/project.xml?rev=190061&r1=190060&r2=190061&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/main/project.xml (original)
+++ directory/apacheds/branches/direve-158/main/project.xml Fri Jun 10 19:38:56 2005
@@ -151,6 +151,12 @@
       <version>1.2.1</version>
       <url>http://www.springframework.com/</url>
     </dependency>
+    <dependency>
+      <groupId>springframework</groupId>
+      <artifactId>spring-context</artifactId>
+      <version>1.2.1</version>
+      <url>http://www.springframework.com/</url>
+    </dependency>
   </dependencies>
 
   <reports>

Added: directory/apacheds/branches/direve-158/main/server.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/main/server.xml?rev=190061&view=auto
==============================================================================
--- directory/apacheds/branches/direve-158/main/server.xml (added)
+++ directory/apacheds/branches/direve-158/main/server.xml Fri Jun 10 19:38:56 2005
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
+  "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+  <bean id="environment" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+    <property name="properties">
+    	<props>
+    		<prop key="asn.1.berlib.provider">org.apache.ldap.common.berlib.asn1.SnickersProvider</prop>
+    		<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="java.naming.ldap.attributes.binary"></prop>
+    		-->
+    	</props>
+    </property>
+  </bean>
+  
+  <bean id="configuration" class="org.apache.ldap.server.configuration.MutableServerStartupConfiguration">
+    <property name="workingDirectory"><value>apache.org</value></property>
+    <property name="allowAnonymousAccess"><value>false</value></property>
+    <property name="ldapPort"><value>10389</value></property>
+    <property name="contextPartitionConfigurations">
+      <set>
+        <ref bean="apachePartitionConfiguration"/>
+      </set>
+    </property>
+    <property name="bootstrapSchemas">
+      <set>
+        <bean class="org.apache.ldap.server.schema.bootstrap.AutofsSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.CorbaSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.CoreSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.CosineSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.ApacheSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.InetorgpersonSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.JavaSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.Krb5kdcSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.NisSchema"/>
+        <bean class="org.apache.ldap.server.schema.bootstrap.SystemSchema"/>
+      </set>
+    </property>
+  </bean>
+  
+  <bean id="apachePartitionConfiguration" class="org.apache.ldap.server.configuration.MutableContextPartitionConfiguration">
+    <property name="name"><value>apache</value></property>
+    <property name="suffix"><value>dc=apache,dc=org</value></property>
+    <property name="indexedAttributes">
+      <set>
+        <value>objectClass</value>
+        <value>ou</value>
+        <value>uid</value>
+      </set>
+    </property>
+    <property name="contextEntry">
+      <value>
+        objectClass: top
+        objectClass: domain
+        objectClass: extensibleObject
+        dc: apache
+      </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.ldap.server.configuration.AttributesPropertyEditor"/>
+        </entry>
+      </map>
+   </property>
+  </bean>
+</beans>
\ No newline at end of file

Modified: directory/apacheds/branches/direve-158/main/src/main/java/org/apache/ldap/server/ServerMain.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/main/src/main/java/org/apache/ldap/server/ServerMain.java?rev=190061&r1=190060&r2=190061&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/main/src/main/java/org/apache/ldap/server/ServerMain.java
(original)
+++ directory/apacheds/branches/direve-158/main/src/main/java/org/apache/ldap/server/ServerMain.java
Fri Jun 10 19:38:56 2005
@@ -17,14 +17,17 @@
 package org.apache.ldap.server;
 
 
-import java.io.File;
 import java.util.Properties;
 
 import javax.naming.Context;
-import javax.naming.NamingException;
 import javax.naming.directory.InitialDirContext;
 
-import org.apache.ldap.common.util.PropertiesUtils;
+import org.apache.ldap.server.configuration.MutableServerStartupConfiguration;
+import org.apache.ldap.server.configuration.ServerStartupConfiguration;
+import org.apache.ldap.server.configuration.SyncConfiguration;
+import org.apache.ldap.server.jndi.ServerContextFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
 
 
 /**
@@ -42,39 +45,31 @@
      *
      * @param args the arguments
      */
-    public static void main( String[] args )
+    public static void main( String[] args ) throws Exception
     {
         long startTime = System.currentTimeMillis();
         Properties env;
+        ServerStartupConfiguration cfg;
 
         if ( args.length > 0 )
         {
-            System.out.println( "server: loading properties from " + args[0] );
-            env = PropertiesUtils.getProperties( new File( args[0] ) );
+            System.out.println( "server: loading settings from " + args[0] );
+            ApplicationContext factory = new FileSystemXmlApplicationContext( args[0] );
+            cfg = ( ServerStartupConfiguration ) factory.getBean( "configuration" );
+            env = ( Properties ) factory.getBean( "environment" );
         }
         else
         {
-            System.out.println( "server: using default properties ..." );
+            System.out.println( "server: using default settings ..." );
             env = new Properties();
-        }
-
-        if ( ! env.containsKey( EnvKeys.LDAP_PORT ) )
-        {
-            int port = LDAP_PORT;
-            env.setProperty( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+            cfg = new MutableServerStartupConfiguration();
         }
 
         env.setProperty( Context.PROVIDER_URL, "ou=system" );
-        env.setProperty( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory"
);
+        env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName()
);
+        env.putAll( cfg.toJndiEnvironment() );
 
-        try
-        {
-            new InitialDirContext( env );
-        }
-        catch ( NamingException e )
-        {
-            e.printStackTrace();
-        }
+        new InitialDirContext( env );
 
         System.out.println( "server: started in "
                 + ( System.currentTimeMillis() - startTime )
@@ -86,21 +81,13 @@
             {
                 // this is a big time cludge for now to just play
                 Thread.sleep( 20000 );
-
-                try
-                {
-                    env.setProperty( EnvKeys.SYNC, "true" );
-                    new InitialDirContext( env );
-                }
-                catch ( NamingException e )
-                {
-                    e.printStackTrace();
-                }
             }
             catch ( InterruptedException e )
             {
-                e.printStackTrace();
             }
+
+            env.putAll( new SyncConfiguration().toJndiEnvironment() );
+            new InitialDirContext( env );
         }
     }
 }

Modified: directory/apacheds/branches/direve-158/project.properties
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/project.properties?rev=190061&r1=190060&r2=190061&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/project.properties (original)
+++ directory/apacheds/branches/direve-158/project.properties Fri Jun 10 19:38:56 2005
@@ -1,3 +1,6 @@
+maven.compile.source = 1.4
+maven.compile.target = 1.4
+
 maven.junit.fork=yes
 
 maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory



Mime
View raw message