Re: Optional Module Dependency

"Ingleby, Graeme" <[email protected]> Wed, 8 Nov 2017 07:01:48 +0000
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <45F55A2F088AA84FB3FBCEAE1C8EE99302371982@SATLRCCDLMB510.delta.rl.delta.com>
It's a bit of a hack and probably breaks all kinds of NB best practices and=
 only works once the application is installed (you can't run from within th=
e IDE) but I did get  something that seems to fit your original request wor=
king.

I've posted a blog entry that describes the approach in detail along with a=
 video of the application in action.

http://gingleby.com/2017/11/08/netbeans-application-with-optional-module/

Going back to the Service Provider approach:

I know you said ServiceProvider wouldn't work because your other Module is =
from a vendor but depending on the number of classes you want to interact w=
ith and the complexity of those classes you might be able to use ServicePro=
vider as a proxy.

In other words, define a service interface in Module I.   Define a service =
implementation in Module B (which has a dependency  on Module V - your vend=
or Module and Module I).  The class in Module B simply invokes the methods =
on the vendor class from Module V.

Now your App (Module A with a dependency on Module I) should be able to inv=
oke code from Module B which in turn invokes the vendor code in Module V.

...or is your issue one where you have two vendor libraries that can use ea=
ch other and Module A requires actual instances of the Module V classes to =
work?


-----Original Message-----
From: cobusve [mailto:[email protected]]=20
Sent: Tuesday, November 07, 2017 11:04 AM
To: [email protected]
Subject: [platform-dev] Re: Optional Module Dependency

Yes I did consider the service provider, but since the other module is not =
under my control that option does not work, as I would have to convince the=
 vendor to ship their interface as a separate module.

What you describe with the SystemClass Loader is exactly what I did to make=
 it work using reflection, but I generally try to avoid reflection like the=
 plague.

I was hoping that I was missing some secret sauce, that I am just not using=
 OpenIDE-Module-Recommends  correctly, because from the description that is=
 exactly what I need.

From the Modules API documentation "Moreover there is also OpenIDE-Module-R=
ecommends which is even weaker version as it creates a conditional dependen=
cy - e.g. enables the module providing the token only if it is available, h=
owever if it is not, no dependency is broken."

So this seemed like it will do exactly what I need - load the dependency wh=
en it exists and continue if it does not, and it does this when installing =
the module, but when you activate the module it fails activation, which get=
s me only halfway. If only the activation also paid attention to the OpenID=
E-Module-Recommends ?



--
Sent from: http://netbeans-org.1045718.n5.nabble.com/Netbeans-RCP-Platform-=
Users-Open-API-f3018772.html