Fórumok

Indexer and WorkflowHandler classes in ServiceImpl

Morad Ahmad, módosítva 9 év-val korábban

Indexer and WorkflowHandler classes in ServiceImpl

Junior Member Bejegyzések: 71 Csatlakozás dátuma: 2010.06.16. Legújabb bejegyzések
Hallo,

I define the indexer and workflow handler implementation in the liferay-portlet.xml file:
...
<indexer-class>de.kanaaneh.portango.portlets.locations.TangolocationsIndexer</indexer-class>
<workflow-handler>de.kanaaneh.portango.portlets.locations.TangolocationWorkflowHandler</workflow-handler>
..

In the LocalServiceImpl class I want to user these implementations. For example to index a new entry:

Indexer indexer = IndexerRegistryUtil.getIndexer(Tangolocation.class.getName());
...
indexer.reindex(tangolocation);

If the service methods are called from a portlet(Action) method the Indexer implementation will be found and every think works well.
However if I call the service methods from a hook during init phase to insert some base data then the indexer impl (and workflow handler impl) will return "null"

I guess these because the declaration is "portlet specific"? Any help?

Thank you.
thumbnail
David H Nebinger, módosítva 9 év-val korábban

RE: Indexer and WorkflowHandler classes in ServiceImpl

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
You shouldn't be using 'init phase'. Instead you use a startup action. It will get invoked when everything is ready, and you can then invoke the service. And this hook can be in the same plugin as the portlet so you don't have to worry about whether it is ready yet.
Morad Ahmad, módosítva 9 év-val korábban

RE: Indexer and WorkflowHandler classes in ServiceImpl

Junior Member Bejegyzések: 71 Csatlakozás dátuma: 2010.06.16. Legújabb bejegyzések
Thanks David,

yes I call the service within a start action in a hook in the same plugin of the portlet project. I don't understand why

Indexer indexer = IndexerRegistryUtil.getIndexer(Tangolocation.class.getName());

returns NULL if I call from start action methods, but not if I call the same method from the Portlet class methods!
thumbnail
David H Nebinger, módosítva 9 év-val korábban

RE: Indexer and WorkflowHandler classes in ServiceImpl

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
Hmm, try invoking your service util instead; it should be properly constructed and ready to go, and that may get you around the issue.