It's all about the answers!

Ask a question

AbstractService getService() calling scope


Fausto Lemos (16811518) | asked Mar 28 '12, 4:21 p.m.
Hi,

i have a few operation Participants (server side) and for reasons like maintenance and easy learning (for me and others developers) i'm trying to create global layers (i.e SCMUtils, WIUtils).

So, when i try to split those operations through diferent classes i found a problem that stopped whole work...

Today my code looks like this:

public class DefaultFolderStructureParticipant extends AbstractService implements 	IOperationParticipant {


public void run(AdvisableOperation operation,
IProcessConfigurationElement participantConfig,
IParticipantInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {

IRepositoryItemService itemService = getService(IRepositoryItemService.class);
itemService.doSomething()...
}

public void checkSomething() {
IRepositoryItemService itemService = getService(IRepositoryItemService.class);
itemService.doSomethingElse()...
}
}
..............



The first thing i try to do was declaring "IRepositoryItemService itemService" as an instance variable just to avoid redeclaring inside methods...


public class DefaultFolderStructureParticipant extends AbstractService implements IOperationParticipant {


IRepositoryItemService itemService = getService(IRepositoryItemService.class);

public void run(AdvisableOperation operation,
IProcessConfigurationElement participantConfig,
IParticipantInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {

itemService.doSomething()...
}

public void checkSomething() {
itemService.doSomethingElse()...
}
}


This second scenario doesn't work, and the "Check <prerequisites> in plugin.xml" error appears, but my plugin.xml have all the prerequisites because the first code works.. it seems that for architectural/performance reasons, the services i need are only avaiable when the run() method is called.. not at class instantiation..

I would like to know if anyone has a suggestion/solution for this problem, such as a plugin configuration (dependencies, etc..)

tks all!

Be the first one to answer this question!


Register or 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.