java - How to register a netbeans custom DataLoader -
hello have created custom multifileloader
, wondering how register dataloaderpool
when creating netbeans plugin.
https://alvinalexander.com/java/jwarehouse/netbeans-src/java/src/org/netbeans/modules/java/javadataloader.java.shtml http://netbeans-org.1045718.n5.nabble.com/multifileloader-being-called-multiple-times-for-same-file-td3026758.html
i don't know if there way @annotation or if have add netbeans layers.xml
.
according references found on web, there no annotation. correct way either:
- use manifest/services register (see dataloader faq )
- use layer.xml (see intviewer plugin site )
the documentation doesn't give lot of details. hereunder more detailed explanation:
manifest approach
easy implements inefficient. dataloader methods called fileobject encountered netbeans. mean file on disk files in virtual filesystems layer filesystem.
how to:
- create file in directory meta-inf/services in src directory of project called org.openide.loaders.dataloader
- write in qualified class name of dataloader.
layer.xml approach
the layer approach lot more complicated lot more powerful. relying on mime type, can tie more functionalities specific dataobject custom actions, editors...
the required elements in layer xml are:
- registration of specific mimeresolver : recognize file , assign mime type it.
- entry in loaders filesystem : instruct netbeans use custom dataloader when encounter file specific mime type.
example
- suppose define xml file format mime type text/brain+xml namespace http://foo.bar.brain
- the custom data loader called foo.bar.brain.braindataloader
- the custom data object called foo.bar.brain.braindataobject
your xml file start tag
<brain xmlns="http://foo.bar.brain" name="sample brain 1"/>
foo.bar.brain.braindataobject file start following annotations:
@messages({ "lbl_brain_loader=files of brain" }) @mimeresolver.namespaceregistration( displayname = "#lbl_brain_loader", mimetype = "text/brain+xml", elementns = {"http://foo.bar.brain"} )
your layer.xml file (only relevant part shown):
<filesystem> <folder name="loaders"> <folder name="text"> <folder name="brain+xml"> <folder name="factories"> <file name="foo-bar-brain-braindataloader.instance"> </file> </folder> </folder> </folder> </folder> </filesystem>
Comments
Post a Comment