-
1. Re: adding a custom service to jbpm.cfg.xml
mwohlf Jul 22, 2010 11:04 AM (in response to h4rlock)1 of 1 people found this helpfulYou should be able to override the IdentityService with your own Implementation like this:
- extend org.jbpm.pvm.internal.svc.IdentityServiceImpl and add whatever methods you need
- instead of <identity-service /> in jbpm.cfg.xml use this:
<object class="your.custom.identityServiceImpl">
<field name="commandService"><ref object="txRequiredCommandService" /></field>
</object> -
2. Re: adding a custom service to jbpm.cfg.xml
h4rlock Jul 22, 2010 12:28 PM (in response to mwohlf)doesn't seem to work in that way..
-
3. Re: adding a custom service to jbpm.cfg.xml
mwohlf Jul 22, 2010 2:23 PM (in response to h4rlock)1 of 1 people found this helpfulI am overriding RepositoryService and IdentityService this way.
-
4. Re: adding a custom service to jbpm.cfg.xml
rebody Jul 22, 2010 8:37 PM (in response to h4rlock)Hi Macro,
Michael's way is right. Whenever you put a <object> tag into jbpm.cfg.xml. Then you could get this service by processEngine.get(ClassName.class). You said it is not work. could you show us more information? Thank you very much.
-
5. Re: adding a custom service to jbpm.cfg.xml
h4rlock Jul 23, 2010 4:15 AM (in response to rebody)Sorry I must have mispelled something before... I am now able to add some methods to MyCustomIdentityService.
I added a command for my new operation which calls MyCustomIdentitySession (extends IdentitySessionImpl) but i still get a nullpointer exception on hibernate session when calling a method of the parent (ie. findUsers() ).
any hint?
-
6. Re: adding a custom service to jbpm.cfg.xml
rebody Jul 23, 2010 4:30 AM (in response to h4rlock)Hi Macro,
If you want to use Session, Transaction which need open an Environment. You could create a custom Command to achieve that.
processEngine.execute(new Command() {
public Object execute(Environment env) {
//
return null;
}});
-
7. Re: adding a custom service to jbpm.cfg.xml
kelum Aug 25, 2010 9:33 PM (in response to rebody)HI
Using jbpm 4.4. WITH jboss-5.1.0.GA
1 :I am also having this kind of issue at the moment . What i have done was extended IdentitySessionImpl and created my own MyIdentitySession .and i have over right few methods createUser,createGroup what was already there in IdentitySessionImpl.
public class MyIdentitySession extends IdentitySessionImpl
{
/*
* This method will create or update a user
*
* */public String createUser(String userName, String givenName, String familyName, String businessEmail)
{User user = null;
try
{
user = findUserById(userName);
}
catch (Exception ex)
{}
if (user == null)
{
user = new UserImpl(userName, givenName, familyName);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
((UserImpl) user).setDbid(dbid);
}UserImpl userimpl = (UserImpl) user;
userimpl.setBusinessEmail(businessEmail);
userimpl.setFamilyName(familyName);
userimpl.setGivenName(givenName);
userimpl.setId(userName);
session.save(user);return user.getId();
}/*
* This method will create or modify Group
*
* */public String createGroup(String groupName, String groupType, String parentGroupId)
{
GroupImpl group = null;
try
{
group = findGroupById(groupName);
}
catch (Exception ex)
{}
if (group == null)
{
group = new GroupImpl();
String groupId = groupType != null ? groupType + "." + groupName : groupName;
group.setId(groupId);long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
group.setDbid(dbid);
}group.setName(groupName);
group.setType(groupType);if (parentGroupId != null)
{
GroupImpl parentGroup = findGroupById(parentGroupId);
group.setParent(parentGroup);
}session.save(group);
return group.getId();
}public void setSession(Session session)
{
super.setSession(session);
Configuration.getProcessEngine().get()
}}
2: Then i created new MyIdentitySessionBinding by extending WireDescriptorBinding
public class MyIdentitySessionBinding extends WireDescriptorBinding
{
public MyIdentitySessionBinding()
{
super("identity-session");
}public Object parse(Element element, Parse parse, Parser parser)
{
ObjectDescriptor objectDescriptor = new ObjectDescriptor(MyIdentitySession.class);
objectDescriptor.addTypedInjection("session", Session.class);
return objectDescriptor;
}
}3: Then this MyIdentitySessionBinding was registered using jbpm.user.wire.bindings.xml
<wire-bindings>
<!-- sessions -->
<binding class ="dd.ss.ss.MyIdentitySessionBinding" /></wire-bindings>
4: Added this file inside that jbpm-service.sar which inside JBoss deploy directory .
5 : Customised jbpm.cfg.xml as bellow
<jbpm-configuration jndi-name="java:/ProcessEngine">
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.tx.jta.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
<import resource="jbpm.console.cfg.xml" />
<transaction-context>
<object class ="aa.bb.cc.MyIdentitySession" />
</transaction-context></jbpm-configuration>
Whwn i try to use createUser,createGroup methods inside MyIdentitySession, it gives me NullPointer exception when accessing session[Hybranate ].
Hope there should be a configuration issue. Please assist me on this regards
Thank you
-
8. Re: adding a custom service to jbpm.cfg.xml
kelum Aug 25, 2010 9:41 PM (in response to h4rlock)HI
Using jbpm 4.4. WITH jboss-5.1.0.GA
1 :I am also having this kind of issue at the moment . What i have done was extended IdentitySessionImpl and created my own MyIdentitySession .and i have over right few methods createUser,createGroup what was already there in IdentitySessionImpl.
public class MyIdentitySession extends IdentitySessionImpl
{
/*
* This method will create or update a user
*
* */public String createUser(String userName, String givenName, String familyName, String businessEmail)
{User user = null;
try
{
user = findUserById(userName);
}
catch (Exception ex)
{}
if (user == null)
{
user = new UserImpl(userName, givenName, familyName);
long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
((UserImpl) user).setDbid(dbid);
}UserImpl userimpl = (UserImpl) user;
userimpl.setBusinessEmail(businessEmail);
userimpl.setFamilyName(familyName);
userimpl.setGivenName(givenName);
userimpl.setId(userName);
session.save(user);return user.getId();
}/*
* This method will create or modify Group
*
* */public String createGroup(String groupName, String groupType, String parentGroupId)
{
GroupImpl group = null;
try
{
group = findGroupById(groupName);
}
catch (Exception ex)
{}
if (group == null)
{
group = new GroupImpl();
String groupId = groupType != null ? groupType + "." + groupName : groupName;
group.setId(groupId);long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
group.setDbid(dbid);
}group.setName(groupName);
group.setType(groupType);if (parentGroupId != null)
{
GroupImpl parentGroup = findGroupById(parentGroupId);
group.setParent(parentGroup);
}session.save(group);
return group.getId();
}public void setSession(Session session)
{
super.setSession(session);
Configuration.getProcessEngine().get()
}}
2: Then i created new MyIdentitySessionBinding by extending WireDescriptorBinding
public class MyIdentitySessionBinding extends WireDescriptorBinding
{
public MyIdentitySessionBinding()
{
super("identity-session");
}public Object parse(Element element, Parse parse, Parser parser)
{
ObjectDescriptor objectDescriptor = new ObjectDescriptor(MyIdentitySession.class);
objectDescriptor.addTypedInjection("session", Session.class);
return objectDescriptor;
}
}3: Then this MyIdentitySessionBinding was registered using jbpm.user.wire.bindings.xml
<wire-bindings>
<!-- sessions -->
<binding class ="dd.ss.ss.MyIdentitySessionBinding" /></wire-bindings>
4: Added this file inside that jbpm-service.sar which inside JBoss deploy directory .
5 : Customised jbpm.cfg.xml as bellow
<jbpm-configuration jndi-name="java:/ProcessEngine">
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.tx.jta.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
<import resource="jbpm.console.cfg.xml" />
<transaction-context>
<object class ="aa.bb.cc.MyIdentitySession" />
</transaction-context></jbpm-configuration>
Whwn i try to use createUser,createGroup methods inside MyIdentitySession, it gives me NullPointer exception when accessing session[Hybranate ].
Hope there should be a configuration issue. Please assist me on this regards
Thank you
-
9. Re: adding a custom service to jbpm.cfg.xml
mwohlf Aug 26, 2010 6:19 AM (in response to kelum)You try to override the binding for the "identity-session" tag, I don't know if this works that way, but even if it does, you are still using the object tag to configure your identity session so the binding is for sure not used and the setSession method probably never called.
-
10. adding a custom service to jbpm.cfg.xml
lykm02 Jan 27, 2011 3:36 AM (in response to rebody)Hi, doesn't the config like this:
<identity-service>
<object class="your.custom.identityServiceImpl">
<field name="commandService"><ref object="txRequiredCommandService" /></field>
</object></identity-service>