directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Re: AW: Exploring triggers
Date Wed, 08 Feb 2017 09:54:44 GMT
<snip>


Le 07/02/2017 à 23:34, Humbi a écrit :

> Hm. Sorry, I don't have a working trigger that actually alters things on the LDAP server.
What do you want to alter? Entries (with Apache DS LDAP API od JNDI) ?

The version that *was* working years ago was based on JNDI. We have
switched to LDAP API in teh server, for every parts of it *but*
triggers. That would mst certainly require some review.

The involved code is not that big, it's a set of 10 classes in the
apacheds-trigger-interceptor module
(http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/)

The core class is the triggerInterceptor class, where each update LDAP
operations are handled by a separate method. Modify, for instance is
handled by :

    /**
     * {@inheritDoc}
     */
    public void modify( ModifyOperationContext modifyContext ) throws
LdapException
    {
        // Bypass trigger handling if the service is disabled.
        if ( !enabled )
        {
            next( modifyContext );
            return;
        }

        Dn normName = modifyContext.getDn();

        // Gather supplementary data.
        Entry originalEntry = modifyContext.getEntry();

        StoredProcedureParameterInjector injector = new
ModifyStoredProcedureParameterInjector( modifyContext );

        // Gather Trigger Specifications which apply to the entry being
modified.
        List<TriggerSpecification> triggerSpecs = new
ArrayList<TriggerSpecification>();
        addPrescriptiveTriggerSpecs( modifyContext, triggerSpecs,
normName, originalEntry );
        addEntryTriggerSpecs( triggerSpecs, originalEntry );

        Map<ActionTime, List<TriggerSpecification>> triggerMap =
getActionTimeMappedTriggerSpecsForOperation(
            triggerSpecs, LdapOperation.MODIFY );

        next( modifyContext );

        triggerSpecCache.subentryModified( modifyContext, originalEntry );

        // Fire AFTER Triggers.
        List<TriggerSpecification> afterTriggerSpecs = triggerMap.get(
ActionTime.AFTER );
        executeTriggers( modifyContext, afterTriggerSpecs, injector );
    }


Once we have fetched the SP to use from the subentry, and called the
underlaying update (the 'next' call), we can process the trigger, which
is done by the last line. At the end, it calls the StoredProcedure.

It's easy to put a breakpoint in this part of the code, and to run the
server from teh debugger (or to attach it to a debugger) : you just have
to start the org.apache.directory.server.UberjarMain class, in the
apacheds-service module, passing "./target/instance" as an argument, and
the following VM arguments :

-Dlog4j.configuration=file:./log4j.properties
-Dapacheds.log.dir=./target/instance/log
-Dapacheds.controls=org.apache.directory.api.ldap.codec.controls.cascade.CascadeFactory,org.apache.directory.api.ldap.codec.controls.manageDsaIT.ManageDsaITFactory,org.apache.directory.api.ldap.codec.controls.proxiedauthz.ProxiedAuthzFactory,org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeFactory,org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsFactory,org.apache.directory.api.ldap.codec.controls.search.persistentSearch.PersistentSearchFactory,org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory,org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory,org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncFactory
-Dapacheds.extendedOperations=org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.CertGenerationFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown.GracefulShutdownFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.storedProcedure.StoredProcedureFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory


-- 
Emmanuel Lecharny

Symas.com
directory.apache.org



Mime
View raw message