directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel L├ęcharny <elecha...@apache.org>
Subject Fwd: Re: Triggers
Date Thu, 24 Jun 2010 10:13:33 GMT
Forwarded to the ML

-------- Original Message --------

>  JavaStoredProcUtils.loadStoredProcedureClass()

I'm not initiated to OSGi and eclipse development so i cannot use this
util method in a test environment, but googling for it i found this
awesomely readable source code that completeley gave me a clear vision:

>    env.put("java.naming.provider.url","ldap://localhost:"  + ldapServer.getPort() +"/ou=system"
 );
....
>    <#142>   Attributes spContainer =*new*  BasicAttributes("objectClass","top",*true*
 );
>    <#143>   spContainer.get("objectClass"  ).add("organizationalUnit"  );
>    <#144>   spContainer.put("ou","Stored Procedures"  );
...
>  spCtx = ( LdapContext ) ctx.createSubcontext("ou=Stored Procedures", spContainer
>
.....
>  /**
>  087          * Loads a Java class's stream data as a subcontext of an LdapContext given.
>  088          *
>  089          * @param ctx
>  090          *           The parent context of the Java class entry to be loaded.
>  091          * @param clazz
>  092          *           Class to be loaded.
>  093          * @throws NamingException
>  094          *           If an error occurs during creating the subcontext.
>  095          */
>  096         public static void loadStoredProcedureClass( LdapContext ctx, Class<?>
  clazz ) throws NamingException
>  097         {
>  098             byte[] buf = getClassFileAsStream( clazz );
>  099             String fullClassName = clazz.getName();
>  100
>  101             Attributes attributes = new BasicAttributes( SchemaConstants.OBJECT_CLASS_AT,
SchemaConstants.TOP_OC, true );
>  102             attributes.get( SchemaConstants.OBJECT_CLASS_AT ).add( "storedProcUnit"
);
>  103             attributes.get( SchemaConstants.OBJECT_CLASS_AT ).add( "javaStoredProcUnit"
);
>  104             attributes.put( "storedProcLangId", "Java" );
>  105             attributes.put( "storedProcUnitName", fullClassName );
>  106             attributes.put( "javaByteCode", buf );
>  107
>  108             ctx.createSubcontext( "storedProcUnitName=" + fullClassName , attributes
);
>  109         }

so now i've clear how and where create the LDAP stored procedure
entries, thanks really a lot.

i just hope that i will able to compile the stored procedure class
outside the eclipse project, i'm tring with netbeans with the apacheds
jars added as a java class library.

i will let you know.

Thanks really a lot you saved me a lot of time!

Congraturations for the awesome ApacheDS project! i think it will matter
in the LDAP servers market (not only the opensource one).

Best regards,
Stefano.


Il 24/06/2010 10:59, Emmanuel Lecharny ha scritto:
>  On 6/24/10 10:09 AM, Stefano Gargiulo wrote:
>>  Thank you for the interesting paper,
>>
>>  But i still can't understand how to pratically define a trigger....
>>
>>  e.g after putting
>>
>>  "AFTER Delete
>>  CALL "com.example.ldap.util.sp.BackupTools:backupDeletedUserEntry"
>>  ( $deletedEntry );"
>>
>>  where do i need put the compiled
>>  "com.example.ldap.util.sp.BackupTools" java class?
>
>  There is an utility method that you can use to inject the class into
>  the server :
>
>  JavaStoredProcUtils.loadStoredProcedureClass()
>
>>  i understood (maybe) that i need to put the bytecode of the compiled
>>  class somewhere in an LDAP enty, in a byte attribute... but where in
>>  the tree?  is there a particular apacheds system subtree where i can
>>  put this kind of entries? is there some hello world example with
>>  source class and final LDIF?
>  The best would be to follow the test class I mentionned in my previous
>  mail, if you step through it you'll see that the trigger is associated
>  with a subentry and an administrative point.
>
>  Sorry if I cant get any further at this moment, I'm not the one who
>  wrote this portion of the code, but as we need to review it and
>  improve the documentation in the next couple of months (ie, before
>  2.0), be sure that there will be some improvement soon.
>



Mime
View raw message