Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to invoke a IChangeEventHandler by server side programmatically

We would try to invoke an our IChangeEventHandler implementation by server side.
How could we create that IChangeEventHandler instance to be adviced by the change event manager (e.g., internal API)?
IChangeEvent event = IChangeEvent.FACTORY.newInstance(null);
// event.set???(???);
IServerProcess serverProcess = processService.getServerProcess(prjArea);
serverProcess.handleChangeEvent(event, prjArea);
Thanks in advance.

0 votes



4 answers

Permanent link
As far as I  can tell, you don't do that. You extend the event handler extension point and then your event handler is called, once you configure it for the project.


0 votes

Comments

I think his question was, what causes the event to fire, that would invoke his handler.
and can he manually cause whatever it was to start the event handler chain

1 vote


Permanent link
You can configure event handler here:

 
There is a built in (hard to find) event for all of these.

I don't know if you can cause events yourself.

0 votes


Permanent link

We already extended the event handler extension point "com.ibm.team.workitem.event.stateChanged" with our implementation and it works like a charm.

Also, we created a REST command to be able to simulate the invocation of that implementation and it works like a charm, too.

We are looking for the right way to generate the IChangeEvent instance to be used for that invocation:

IChangeEvent event = IChangeEvent.FACTORY.newInstance(null);

event.setCategory(StateChangeNotifier.ID_STATE_CHANGED_EVENT_CATEGORY);
event.setOwnerNamespace(IWorkItem.ITEM_TYPE.getName());
event.setContextId(???);
event.setProcessArea(prjArea);
event.setAuthor(getAuthenticatedContributor());
event.setTime(timeService.getCurrentTimestamp());
changeService.save(event);

For instance, we do not know how to set a correct contextId...

Thanks in advance.

Cheers.

0 votes


Permanent link
I suppose you have extended com.ibm.team.process.service.eventHandlers and configured it with eventCategory="com.ibm.team.workitem.event.stateChanged" to intercept a workitem state transition.

In my opinion the contextId is the context UUID of the Workitem
	IWorkItem workitem ....
        
event.setContextId(workitem.getContextId()); event.setItem(workitem)

or if you do not need it you can use for example:
	event.setContextId(IContext.PUBLIC) 

0 votes

Comments

We would be able to invoke our event handler implementation even without a real work-item state transition. So, in this case, we will not be able to retrieve the context UUID from the item...

We will now try to set the context UUID as 'IContext.PUBLIC'.
Thanks for the advice.
Cheers.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,936

Question asked: Mar 21 '16, 10:46 a.m.

Question was seen: 3,248 times

Last updated: Jun 10 '16, 4:04 a.m.

Confirmation Cancel Confirm