It's all about the answers!

Ask a question

Getting hold of an AbstractService instance from op. part.


Dan Rivett (1211115) | asked Jun 04 '09, 9:21 a.m.
Hi,
It's probably a really dumb question, but I am writing a WorkItem save Operation Participant, and I want to get hold of an ITeamBuildRequestService instance. Now I know AbstractService.getService() will give me that but I don't know how to get hold of an AbstractService implementing object from inside the participant.

Currently I'm doing something similar to the following, but it's deprecated so I'd like to do it the intended way but unable to work out how to get an AbstractService instance.

public void run(final AdvisableOperation operation, final IProcessConfigurationElement participantConfig, final IParticipantInfoCollector collector, final IProgressMonitor monitor)

throws TeamRepositoryException
{
final ISaveParameter saveParameter = (ISaveParameter) operation.getData();
final IAuditableCommon auditableCommon = saveParameter.getSaveOperationParameter().getAuditableCommon();
final IWorkItemServer = auditableCommon.getPeer(IWorkItemServer.class); // deprecated call
final IAuditableServer auditableServer = workItemServer.getAuditableServer();
final ITeamBuildRequestService buildService = auditableServer.getService(ITeamBuildRequestService.class) // deprecated call

// ...
}


Any help would be appreciated as I'm sure the answer is obvious - I had thought about having my OperationPartipant extend AbstractService, but that doesn't seem right as the participant isn't a service.

Thanks,
Dan

2 answers



permanent link
Dan Rivett (1211115) | answered Jun 04 '09, 9:29 a.m.
Maybe I answered my own question as there are server side operation participants in the Jazz source which extend AbstractService (com.ibm.team.reports.service.internal.process.ReportsProjectParticipant, and all of the ones in package com.ibm.team.process.internal.definitions.server) so seems that's how it should be done.

Just seems odd from as I hadn't thought of Operation Participants as Jazz Services, and I thought the Operation Participant would be passed an instance as a parameter rather than just extending AbstractService - I guess it's because I'm just used to the old way of getting passed an IAuditableCommon. Time to adjust to the new way...

permanent link
Jamie Berry (14013077) | answered Oct 26 '10, 12:14 p.m.
Did you get this to work? I tried extending AbstractService for an Operation Advisor and every time I try using the getService(IWorkItemServer.class) call, I get an exception. I am trying to use getPeer, but don't want to rely on that since it is deprecated. Thanks for any help you can provide.


Maybe I answered my own question as there are server side operation participants in the Jazz source which extend AbstractService (com.ibm.team.reports.service.internal.process.ReportsProjectParticipant, and all of the ones in package com.ibm.team.process.internal.definitions.server) so seems that's how it should be done.

...

Your answer


Register or to post your answer.