i trying create netbeans module whould work upon standard maven java projects. there better way how adviced in: how can project type on netbeans platform? seems pretty dependent on implmenetation (note *impl postfix of implementing class found in lookup). couldn't find standard method in project api. ideas? or safe rely on "nbmavenprojectimpl" string?
currently going way:
project mainproject = openprojects.getdefault().getmainproject(); if (mainproject == null) { return; } string projecttype = mainproject.getclass().getname(); if (projecttype.equals("nbmavenprojectimpl")) { // action project here }
one approach be
if (mainproject.getlookup().lookup(nbmavenproject.class) != null) { // stuff }
another one, should preferred, register business logic maven project lookup eg. using annotation
@projectserviceprovider(service=myservice.class, projecttype="org-netbeans-modules-maven") public class myserviceimpl implements myservice { @override public void doit() { } }
and accessing business logic like
myservice ms = mainproject.getlookup().lookup(myservice.class); if (ms != null) { ms.doit() }
that way can decouple api implementation , bonus can share same business logic between more project types, if appropriate.
Comments
Post a Comment