how to use modular system of netbeans platform? - netbeans

i m new with netbeans platform , i want to use java class's method of module A into module B, so please suggerst to me how can i do deppendacy , Lookup system , and Service provider?

The NetBeans class loading is partitioned, so each module gets its own class-loader.
In order for you to use a class from module A in module B you need to set the package that your class is in as a public package and add Module A as a dependency for Module B
I would suggest looking at this NetBeans platform quick-start tutorial - it covers the Lookup, module interaction and Service Provider usage.
The Netbeans developer FAQ is also very helpful (For example it has a whole section for what the lookup is, and how to interact with it)

Related

Custom implicit module dependency in WildFly

There's the 3rd-party application bpm.ear that contains the ancient commons-net.jar in its /bpm.war/WEB-INF/lib/.
I need to globally override it with my own version of the jar without patching the files inside the deployment. That is, make this change survive undeployment of the app.
Formerly, when we were using JBoss 4x this was solved by setting the $CLASSPATH env. var before starting the server. Of course, this doesn't work in Wildfly 11.
I want to create a custom module inside ${JBOSS_HOME}/modules (already done) and to create a simple rule to implicitly add this module to all apps deployed on this server.
You can use https://wildscribe.github.io/WildFly/16.0/subsystem/ee/#attr-global-modules to define a list of modules that should be made available to all deployments.

Can I use Eclipse XQDT to debug Marklogic modules/xquery?

Hi Markloggers out there,
I am working now a coupe of months with Marklogic, developping xquery, modules, applications on the ML app server etc etc. I use eclipse a lot, I have XQDT up and running for several marklogic servers. We use the console also.
What I miss is a debug functionality... in Eclispe with XQDT I cannot get the debug function working?
What I need is a nice and clean way to quickly test and develop modelules and functions...
This is my basic lib from the ML example documentation:
xquery version "1.0-ml";
module namespace lib = 'http://www.example.com/lib';
declare function lib:user()
{
xdmp:get-current-user()
};
I have this is my XQDT project in eclipse, I have setup a marklogic XDBC server locally and it works ok.
Now I want to use the above module from a file again in the XQDT project in eclipse. But without going to steps of uploading the module to the db etc etc...:
(: XQuery main module :)
import module namespace lib = 'http://www.example.com/lib' at 'lib.xq';
lib:user()
Gives:
XDMP-MODNOTFOUND: (err:XQST0059) Module /lib.xq not found
Question 1: Is there a way to find the module without putting it in a module root? In the docs it says from a XQDT project I could source a module but I cannot get it to work...
Question 2: I can execute arbitrary xquery to the local Marklogic server but if I set a debug flag anywhere in a xgy file in the XQDT project and press the debug button I get a popup saying "The Debug Engine is not properly configured". Can anyone explain to me if it is possible to use the debug option in eclipse XQDT with Marklogic 7 ?
Regards,
hugo
It's best to limit yourself to one question per SO post. After all you can only accept one answer.
Now I want to use the above module from a file again in the XQDT
project in eclipse. But without going to steps of uploading the module
to the db etc
That's a problem. You can evaluate an ad-hoc query directly. But if it references a library module, that library module needs to be available to the server. You're going to have to copy it to the server sooner or later anyhow, so do it sooner. I don't use an IDE myself, but can't you set it up to do that for you?
Question 1: Is there a way to find the module without putting it in a module root?
Not in the broadest sense of "module root", no. The docs at https://docs.marklogic.com/guide/app-dev/import_modules talk about how this works. Somehow or other, you need to make the library module available to MarkLogic.
I can't address your last question. I don't use an IDE, and even if I did I probably wouldn't use a debugger. Instead I xdmp:log messages to ErrorLog.txt, and occasionally I'll plant an breakpoint-like error() call in my code.

MEF Plugin update strategies for winforms

I'm developing an extensible application with MEF. The application will have many types of plugins to collect and process data in different ways.
I'm thinking about building a versioned online repository for the plugins, that will enable the user to download new versions of the plugins when they become available.
It would be nice if MEF could load different versions of the same plugin simultaneously, though from what I understand this isn't possible (correct me if I'm wrong).
So I've resigned myself to the fact I will need to update the plugin and archive the previous version.
What would be the best strategy for doing this?
Example 1
The Application downloads a new version of a loaded running plugin. I can't place the plugin in the plugin directory as there is already DLL with the same name. So I could rename the new plugin with a version suffix. I can't load the same assembly, so I guess I'll have to force a restart. So on restart, it achieves the old plugin and loads the new one.
--- This seems solutions seems a little messy
Example 2
The Application downloads a new version of a loaded running plugin.
The plugin is encased in some type of installer.
The installer closes the host gracefully and archives the existing plugin.
The installer installs new plugin and restarts the host app.
--- this also seems a little messy
I am seeking any correction of my assumptions, or any insight into a successful strategy to my achieve my goal.
The .NET Framework has a fearure called Shadow Copy which allows you to update loaded assebmlies. Basically it copies the assemblies to a temp folder and loads them from there. This way the assemblies located in your application's installation folder will not be locked by the OS and you will be able to replace them. ASP.NET, unit test framweorks and many other applications use shadow copying.
To enable this feature you will need to load your application in a new AppDomain since you cannot enable shadow copying on the main AppDomain. You can create a simple loader that will create an AppDomain and execute your application there. This is very straight forward. For an example of MEF + Shadow Copy have a look at Glenn Block's Way of MEF and in particullar the PartUpdatesInPlace sample.
Now as far as versioning is concerned you will need to be able to have two or more versions of an assembly loaded at the same time in the same application domain. There are two ways to do this:
Strong named assemblies in the GAC.
Assemblies with the version included in their name (like Plugin.v1.dll). Strong naming is optional in this case but a good idea nonetheless. The advantage of this approach is that two or more versions of a plugin can coexist in the same directory.
Have a look at this answer for an example of MEF + Versioning.
You can even use the recomposition feature of MEF and have your plugin container updated after:
A new plugin assembly is added
A plugin assembly is deleted
A plugin assembly is replaced
Have a look at this question for an example.

GWT sharing services between several modules

I have a project where depending on the user role he's being redirected to completely different UIs right after logging in. I'm planning to separate the project structure into several GWT modules like this:
1. Base module
2. Login module
3. Module for role1
4. Module for role2
...
I will have all the modules except the Login module extend the Base module where I'll store the common UI components I'll need everywhere. (like profile editing and stuff like that). Login module will act like a bootloader and its task will be just to load the correct module right after user aunenticates.
The problem is that all my server-side services which GWT modules invoke are nearly the same for all modules. I have lots of lookup information providing services and in many other cases one user just fills in the information and the other moderates it, so it's also the same service.
As i understand GWT does the calls to the server using urls pattern like this: gwtModuleName/myServiceUrl so in a way the services are gwt module dependent. How can i "share" a single service between several GWT modules?
Very Easy, just put all your client-side service files in the base-module:
com.proj.client.base
com.proj.client.base.request
--- MyService
--- MyServiceAsync
com.proj.client.modA
com.proj.client.modB
com.proj.server.request
-- MyServiceImpl
I use a similar structure for a single app with 10+ modules all sharing the same services.
Just import the service from within the different modules

Equinox launcher

What is the big difference between launching Equinox via java -jar plugins/org.eclipse.osgi_3.6.0.v20100517.jar and using org.eclipse.equinox.launcher (basically, java -jar plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar)?
I suppose that org.eclipse.equinox.launcher provides some added value, but what exactly?
equinox.launcher processes special arguments before starting osgi framework. If you want to know more, the best way is reading the source code of equinox.launcher.
Well. The class which is used by both methods to start equinox framework is org.eclipse.core.runtime.adaptor.EclipseStarter. It's located in the org.eclipse.osgi_version.jar.
They use the same class. So, basically, they are the same.
However, the equinox.launcher provides more additional features. For example, a default splash banner, checking security and installation path, some more debug information etc.
The equinox.launcher is intended to be used as an application launcher of the framework/application.
If you directly run the org.eclipse.osgi_3.6.0.v20100517.jar file by invoking java -jar plugins/org.eclipse.osgi_3.6.0.v20100517.jar. It actually calls the main method in the EclipseStarter class.
This class is intended to be used as a programmable starter of the framework. That means you should use this class if you want to start the equinox framework from your code.
Generally speaking, you should use equinox.launcher for launching your OSGi application from command line or other similar means.
Hope this helps.