cancel
Showing results for 
Search instead for 
Did you mean: 

Exchange IdentityService (or other services)

bernd_ruecker
Champ in-the-making
Champ in-the-making
Hey guys.

I just had a look in the wiring with the use case: How can I exchange the IdentityService (since I maybe want to use my own implementation or LDAP or whatever). But the wiring is done in the ProcessEngineConfiguration() constructor by "identityService = new IdentityServiceImpl();".

Is there already a plan how we can exchange that by configuration of the engine (without copying the ProcessEngineConfiguration class or create your own ProcessEngineBuilder)? Or do I miss anything?

Thanks and cheers
Bernd
5 REPLIES 5

cstettler
Champ in-the-making
Champ in-the-making
Hi Bernd,

we had the very same requirement, too. We wanted Activiti to base on an already existing proprietary user database instead of its own one.

There is a ProcessEngineConfiguration.setIdentitySession() API that allows for setting a custom implementation of the identity service (although, the default implementation is then created unnecessary).

The problem here is: Activiti accesses the IdentitySession (not IdentityService) implementation internally from many places (via commandContext.getIdentitySession()), so it was of no help to customize the IdentityService, but we had to implement our custom IdentitySession instead. Otherwise, Activiti would still use the default implementation which accesses the user/group information from the Activiti database in many places.

In order to configure the custom IdentitySession, we extended the ProcessEngineFactoryBean (since we use Spring to configure the engine) and set the custom IdentitySession using the following "hack":

    @Override
    public ProcessEngine getObject() throws Exception {
        processEngineConfiguration.getSessionFactories().put(IdentitySession.class, new SessionFactory() {
            @Override
            public Session openSession() {
                return (Session) identitySession;
            }
        });
       return super.getObject();
    }

In my opinion, we should streamline not only the configuration, but also the concept of the services and the sessions so that customizing one implementation and configuring it via a proper way is possible. This could be done, e.g.

a) by providing a clean way to configure a custom IdentitySession and keep Activiti accessing the IdentitySession directly
b) keep the current configuration option for the IdentityService, but make sure Acitivit never accesses the IdentitySession directly
c) any other clean way that works  😉

(Disclaimer: all information bases on 5.0.beta1 and might have changed since)

I hope this helps.

Regards,
Christian

jbarrez
Star Contributor
Star Contributor
@Christian: changing the IdentitySession by adding it to the sessionFactories is indeed the way to go.
What makes you feel this is hacky? I assume you want to have a 'setIdentitySession()' methode there ?

a) is the way the go and how it is intended: internally the session should be used always.

So Imo following things need to happen:

- Have a way in Spring to add a Session
- Find out why it is possible to set the services on the processEngineConfiguration, this is indeed strange from the point of view that the sessions should be used.

tombaeyens
Champ in-the-making
Champ in-the-making
for now, the simplest way to customize the identity session could be to overwrite the identity session factory after the process engine has been built.

the approach that i think we should pursue is this:  add parsing of this kind of line to ConfigurationParse:
<session class="the.SessionClass" factory="the.FactoryClass" />and that should call
processEngineConfiguration.getSessionFactories().put(sessionClass, sessionFactoryObject);

anyone interested in contributing? then create a jira for it and assign it to you.

falko_menge
Champ in-the-making
Champ in-the-making
There is a related discussion in the user forum: http://forums.activiti.org/en/viewtopic.php?f=3&t=345
There we also came to the conclusion that the ProcessEngineFactoryBean for Spring needs the ability of configuring sessions, but no JIRA issue was raised for it.

mondhs
Champ in-the-making
Champ in-the-making
Hi,

I hope this helps to someone else.
I managed integrate customer user management services with Activiti. Results I posted to http://forums.activiti.org/en/viewtopic.php?f=6&t=345&p=23461#p23461

mondhs