directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <akaras...@gmail.com>
Subject Re: Using DirectoryServiceFactory correcty
Date Fri, 26 Mar 2010 13:22:21 GMT
Yes I too agree that the standard way with smart defaults is best.  But it's
also nice to have this option for tests.  This way you can easily see in the
annotations what conifigruation changes were made and are being tested.

Different approaches have different strengths.  But I am +1 on the use of
smart defaults to make this new ApacheDS() call the easiest and simplest way
to create ApacheDS then a call to start to start it.

Alex

On Fri, Mar 26, 2010 at 1:03 AM, Stefan Zoerner <stefan@labeo.de> wrote:

> Hi Emmanuel!
>
> Thanks for your quick response.
>
>
> Emmanuel Lecharny wrote:
>
>> I will respond in detail to you mail, but first, why not using the
>> annotations to start a server ?
>>
>> It's way easier, you don't have to worry about what's going on and what
>> needs to be initialized first.
>>
>> I'm also wondering if this should not be the standard way to start the
>> server.
>>
>
> I am not 100% convinced by this approach. IMHO the standard way should be
>
> ApacheDS myServer = new ApacheDS();
> myServer.start();
>
> (simplified ;-)
>
> Although annotations are technically interesting, IMHO using annotations in
> this place will make it more difficult for people who simply try to embed
> the server. Within spring configurations, within Groovy scripts, etc. Too
> much magic.
>
> If a user plans to extend the server (like the simple custom partition in
> the example, or a custom interceptor), the JavaBeans approach will always
> work. It is possible to readjust the Spring config etc.
>
> I guess, it is not possible to add a custom partition with the current
> annotations. And if it would be, you start to reimplement Google Guice.
>
> Greetings from Bielefeld,
>    StefanZ
>
>
>
>
>
>  Let me give you an example :
>>
>> package org.apache.directory.server.factory;
>>
>> import org.apache.commons.io.FileUtils;
>> import org.apache.directory.server.core.DirectoryService;
>> import org.apache.directory.server.core.annotations.CreateDS;
>> import org.apache.directory.server.core.factory.DSAnnotationProcessor;
>>
>> public class MyServer
>> {
>>
>>    @CreateDS( name = "myServer" )
>>    public static void main( String[] args ) throws Exception
>>    {
>>        DirectoryService service =
>> DSAnnotationProcessor.getDirectoryService();
>>
>>        if ( service.isStarted() )
>>        {
>>            System.out.println( "Service started !" );
>>        }
>>
>>        service.shutdown();
>>        FileUtils.deleteDirectory( service.getWorkingDirectory() );
>>    }
>> }
>>
>> That should be enough to start a server.
>>
>> You can of course define some more elements :
>>
>> package org.apache.directory.server.factory;
>>
>> import org.apache.commons.io.FileUtils;
>> import org.apache.directory.server.core.DirectoryService;
>> import org.apache.directory.server.core.annotations.CreateDS;
>> import org.apache.directory.server.core.factory.DSAnnotationProcessor;
>>
>> public class MyBetterServer
>> {
>>
>>    @CreateDS(
>>        name = "MethodDSWithPartition",
>>        partitions =
>>        {
>>            @CreatePartition(
>>                name = "example",
>>                suffix = "dc=example,dc=com",
>>                contextEntry = @ContextEntry(
>>                    entryLdif =
>>                        "dn: dc=example,dc=com\n" +
>>                        "dc: example\n" +
>>                        "objectClass: top\n" +
>>                        "objectClass: domain\n\n" ),
>>                indexes =
>>                {
>>                    @CreateIndex( attribute = "objectClass" ),
>>                    @CreateIndex( attribute = "dc" ),
>>                    @CreateIndex( attribute = "ou" )
>>                } )
>>        } )
>>    @CreateLdapServer (
>>        transports =
>>        {
>>            @CreateTransport( protocol = "LDAP" ),
>>            @CreateTransport( protocol = "LDAPS" )
>>        })
>>    public static void main( String[] args ) throws Exception
>>    {
>>        DirectoryService service =
>> DSAnnotationProcessor.getDirectoryService();
>>
>>        if ( service.isStarted() )
>>        {
>>            System.out.println( "Service started !" );
>>        }
>>
>>        service.shutdown();
>>        FileUtils.deleteDirectory( service.getWorkingDirectory() );
>>    }
>> }
>>
>>
>> Does this sound good to you ?
>>
>>
>
>


-- 
Alex Karasulu
My Blog :: http://www.jroller.com/akarasulu/
Apache Directory Server :: http://directory.apache.org
Apache MINA :: http://mina.apache.org
To set up a meeting with me: http://tungle.me/AlexKarasulu

Mime
View raw message