<!-- <questionid="arch-what"when="init"> Whatisthisprojectgoodfor? <hint> Pleaseprovidehereafewlinesdescribingtheproject, whatproblemitshouldsolve,providelinkstodocumentation, specifications,etc. </hint> </question>
-->
<answer id="arch-what">
The implementation of the <code>MimeDataProvider</code> interface that serves
data from the folder hierarchy underneath the Editor/ folder on the system
filesystem.
</answer>
<p>The module implements <code>MimeDataProvider</code> and registers this implementation
in the default Lookup via META-INF/services. The implementation relies on
<code>ProxyLookup</code> and <code>AbsrtactLookup</code> classes, which are used
for looking up data (i.e. settings, services and other objects) from the
hierarchy of folders on the system filesystem.
</p>
<p>The hierarchy starts in the Editors/ folder and uses subfolders for each
part of MimePath, for which a user wants to get Lookup. Therefore, when
asking for Lookup for 'text/x-java' MimePath the lookup will contain objects
registered underneath the 'Editors/text/x-java' folder.</p>
</answer>
<!-- <questionid="arch-quality"when="init"> Howwillthe<ahref="http://www.netbeans.org/community/guidelines/q-evangelism.html">quality</a> ofyourcodebetestedand howarefutureregressionsgoingtobeprevented? <hint> Whatkindoftestingdo youwanttouse?Howmuchfunctionality,inwhichareas, shouldbecoveredbythetests? </hint> </question>
-->
<answer id="arch-quality">
Unit tests are available.
</answer>
<usecase id="known-clients-summary" name="Known clients summary">
<b>Fold Manager Factories</b>
<br/>
The editor/fold module clients are expected to register fold manager factories
(<code>org.netbeans.spi.editor.fold.FoldManagerFactory</code> classes)
in the <b>Editors/<mime-path>/FoldManager</b> layer folder.
<br/>
<br/>
<b>Completion Providers</b>
<br/>
The editor/completion module clients are expected to register completion providers
(<code>org.netbeans.spi.editor.completion.CompletionProvider</code> classes)
in the <b>Editors/<mime-path>/CompletionProviders</b> layer folder.
<br/>
<br/>
<b>Editor Context Menu Actions</b>
<br/>
The editor module clients are expected to register popup menu actions
(<code>javax.swing.Action</code> classes or names of actions
(i.e. value of Action.NAME attribute) present in editor kit e.g. "goto-source")
in the <b>Editors/<mime-path>/Popup</b> layer folder.
<br/>
<br/>
<b>Side Bars</b>
<br/>
The editor/lib module clients are expected to register factories for components
to be placed on the sides of the editor component (<code>org.netbeans.editor.SideBarFactory</code> classes)
in the <b>Editors/<mime-path>/SideBar</b> layer folder.
<br/>
<br/>
<b>Hyperlink Providers</b>
<br/>
The editor/lib module clients are expected to register hyperlink providers
(<code>org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider</code> classes)
in the <b>Editors/<mime-path>/HyperlinkProviders</b> layer folder.
<br/>
<br/>
<b>Code Template Processors</b>
<br/>
The editor/codetemplates module clients are expected to register factories for
code template processors
(<code>org.netbeans.lib.editor.codetemplates.spi.CodeTemplateProcessorFactory</code> classes)
in the <b>Editors/<mime-path>/CodeTemplateProcessorFactories</b> layer folder.
<br/>
<br/>
<b>Hints Providers</b>
<br/>
The editor/hints module clients are expected to register editor hints providers
(<code>org.netbeans.modules.editor.hints.spi.HintsProvider</code> classes)
in the <b>Editors/<mime-path>/Hints</b> layer folder.
</usecase>
<br/>
<br/>
<br/>
<b>
SPI Use Cases
</b>
<hr/>
<usecase id="declare-mime-type-specific-object-in-layer" name="Declare the mime specific object via xml layer">
This is the simpliest way of declaring, it is suitable for objects stored directly in mime specific
folders:
<pre>
<filesystem>
<folder name="Editors">
<folder name="text">
<folder name="x-java">
<file name="org-netbeans-modules-editor-mimelookuptest-MimeSpecificObject.instance"/>
</folder>
</folder>
</folder>
</filesystem>
</pre>
Lookup of this object will look like:
<pre>
MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java");
MimeSpecificObject mso = (MimeSpecificObject) lookup.lookup(MimeSpecificObject.class);
</pre>
</usecase>
<usecase id="declare-mime-type-specific-folder-in-layer" name="Declare the object via xml layer in some specific folder using Class2LayerFolder.">
<p/>
Some objects are connected to some specific folder in mime specific layer folders, e.g.
FoldManagerFactory.class is placed in <b>FoldManager</b>
subfolder in the <b>Editors/<mime-type>/</b>.
Such objects can be registered
to the specific folder using interface <code>Class2LayerFolder</code>.
Let's register FoldManagerFactory.class to <b>FoldManager</b> folder.
First we need to implement the interface:
<pre> public class FoldManagerClass2LayerFolder implements Class2LayerFolder{
public FoldManagerClass2LayerFolder {
}
/* declaring the class */ public Class getClazz(){
return FoldManagerFactory.class;
}
/* assigning the declared class to folder */ public String getLayerFolderName(){
return "FoldManager";
}
/* we will not support InstanceProvider */ public org.netbeans.spi.editor.mimelookup.InstanceProvider getInstanceProvider() {
return null;
}
}
</pre>
Then we need to register it to default lookup via META-INF/services registration. We need to create
a folder structure <code>META-INF/services</code> and place there a file <code>org.netbeans.spi.editor.mimelookup.Class2LayerFolder</code>
with the content <code>FoldManagerClass2LayerFolder</code>
<p/>
having this we can register appropriate object to specific folder:
Lookup of this object will look like:
<pre>
MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java");
FoldManagerFactory foldManagerFactory = (FoldManagerFactory) lookup.lookup(FoldManagerFactory.class);
</pre>
or, if there should be more instances of the FoldManagerFactory:
<pre>
MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java");
Collection foldManagerFactories = lookup.lookup(new Lookup.Template(FoldManagerFactory.class)).allInstances();
</pre>
Notice, that the FoldManagerFactory object is found in "FoldManager" folder. It is not necessary for client
of the API to know about some folder structure.
<p/>
</usecase>
<usecase id="mime-lookup-initializer" name="Providing implemented MimeLookupInitializer">
It is the general way of adding mime specific object into the <code>MimeLookup</code>. Implementation of <code>MimeLookupInitializer</code> should be created and
registered to default lookup via <code>META-INF/services</code> registration.
For details, please look at the simplified
<code>TestMimeLookupInitializer</code>
in <code>mimelookup/test/unit</code> or <code>LayerMimeLookupInitializer</code>.
<b> Usage of MimeLookupInitializer is deprecated, please use MimeDataProvider instead in similar way </b>
</usecase>
<usecase id="instance-provider" name="Using InstanceProvider for declaration of compound folder objects and inheritance">
Demonstration of <code>InstanceProvider</code> and inheritance will be used together in one use case. Example of
editor context menu construction will be used. Each module can register its actions to
editor context menu via xml layer. As context menu is mime type sensitive (java editor has
different menu items than plain editor) the actions are registered into mime specific layer folders
to subfolder "Popup". When the context menu is constructing, the xml layer is scanned for the
action items located in the "Popup" subfolder of specific mime folder. In addition to
this there is inheritance mechanism used to share global actions (like Cut, Copy, Paste) over all mime
types context menus, thus not only the action items from actual mime type are considered. All
underlaying mime types are scanned also and the result is context menu with merged action items.
<p/>
For example JSP scriplet context menu should be merged from action items gathered over:
<ol>
<li> Editors/Popup - this is base level for global actions like Cut, Copy, Paste</li>
<li> Editors/text/x-jsp/Popup - items from jsp mime type</li>
<li> Editors/text/x-jsp/text/x-java/Popup - items specific to java scriplet in JSP document</li>
</ol>
<p/>
Construction mechanism is implemented in editor module in NbEditorKit class. The code
responsible for construction uses MimeLookup and supports also embeded mime-types.
<code>MimeLookup</code> solves embeding and the gathering of the context menu items such simply as:
<p/>
<pre>
MimePath path = MimePath.parse("text/x-jsp/text/x-java");
Lookup lookup = MimeLookup.getLookup(path);
PopupActions actions = (PopupActions) lookup.lookup(PopupActions.class);
List popupActions = actions.getPopupActions();
</pre>
where PopupActions is implementation of <code>InstanceProvider</code> and PopupActions.class needs to be
registered to "Popup" subfolder using <code>Class2LayerFolder</code> implementation. Let's register
this step by step.
<p/>
Because action items are instances of various objects like:
<ol>
<li>javax.swing.Action</li>
<li>javax.swing.JSeparator</li>
<li>org.openide.util.actions.SystemAction</li>
<li>java.lang.String</li>
</ol>
the <code>InstanceProvider</code> needs to be created for this:
<pre> public class PopupActions implements InstanceProvider{
List ordered;
public PopupActions(){
}
public PopupActions(List ordered){
this.ordered = ordered;
}
public List getPopupActions(){
List retList = new ArrayList();
for (int i = 0; i<ordered.size(); i++){
DataObject dob = (DataObject) ordered.get(i);
InstanceCookie ic = (InstanceCookie)dob.getCookie(InstanceCookie.class);
if (ic!=null){
try{
if (String.class.isAssignableFrom(ic.instanceClass()) ||
Action.class.isAssignableFrom(ic.instanceClass()) ||
SystemAction.class.isAssignableFrom(ic.instanceClass()) ||
JSeparator.class.isAssignableFrom(ic.instanceClass())){
Object instance = ic.instanceCreate();
retList.add(instance);
}
}catch(IOException ioe){
ioe.printStackTrace();
}catch(ClassNotFoundException cnfe){
cnfe.printStackTrace();
}
} else{
retList.add(dob.getName());
}
}
return retList;
}
public Object createInstance(List ordered) {
return new PopupActions(ordered);
}
}
</pre>
This <code>InstanceProvider</code> needs to be declared in <code>Class2LayerFolder</code> implementation:
<pre> public class PopupInitializer implements Class2LayerFolder{
public PopupInitializer() {
}
public Class getClazz(){
return PopupActions.class;
}
public String getLayerFolderName(){
return "Popup"; //NOI18N
}
public InstanceProvider getInstanceProvider() {
return new PopupActions();
}
}
</pre>
Now, we just need to register PopupInitializer into default lookup via META-INF/services
registration and the initialization is done.
<!-- <questionid="format-types"when="impl"> Whichprotocolsandfileformats(ifany)doesyourmodulereadorwriteondisk, ortransmitorreceiveoverthenetwork? </question>
-->
<answer id="format-types">
No files read or written to the disk.
</answer>
<!-- <questionid="lookup-lookup"when="init"> Doesyourmoduleuse<code>org.openide.util.Lookup</code> oranysimilartechnologytofindanycomponentstocommunicatewith?Whichones? <hint> Pleasedescribetheinterfacesyouaresearchingfor,where aredefined,whetheryouaresearchingforjustoneormoreofthem, iftheorderisimportant,etc.Alsoclassifythestabilityofsuch APIcontract. </hint> </question>
-->
<answer id="lookup-lookup">
Yes. The module searches for implementations of the <code>Class2LayerFolder</code>
interface in the default Lookup.
</answer>
<!-- <questionid="lookup-register"when="final"> Doyouregisteranythingintolookupforothercodetofind? <hint> Doyouregisterusinglayerfileorusing<code>META-INF/services</code>? Whoissupposedtofindyourcomponent? </hint> </question>
-->
<answer id="lookup-register">
Yes. The module registers an implementation of the <code>MimeDataProvider</code>
interface via META-INF/services in the default Lookup.
</answer>
<!-- <questionid="perf-scale"when="init"> Whichexternalcriteriainfluencetheperformanceofyour program(sizeoffileineditor,numberoffilesinmenu, insourcedirectory,etc.)andhowwellyourcodescales? <hint> Pleaseincludesomeestimates,thereareothermoredetailed questionstoanswerinlaterphasesofimplementation. </hint> </question>
-->
<answer id="perf-scale">
The number of Lookups that have been requested for different MimePaths and
the number of objects (i.e. settings, services, etc.) registered in those
lookups.
</answer>
<!-- <questionid="perf-spi"when="init"> Howtheperformanceofthepluggedincodewillbeenforced? <hint> Ifyouallowforeigncodetobepluggedintoyourownmodule,how doyouenforcethatitwillbehavecorrectlyandquicklyandwillnot negativelyinfluencetheperformanceofyourownmodule? </hint> </question>
-->
<answer id="perf-spi">
The clients code is not enforced in any way to perform well. However, the
implementation of the module uses caching and lazy loading wherever it is
possible to minimize the number of objects loaded in memory.
</answer>
<api group="layer" name="EditorsRegistry"type="export" category="official">
The module expects all mime type sensitive settings to be
placed in the subfolders hierarchy under the "Editors" folder on the default filesystem.
</api>
</answer>
<!-- <questionid="arch-where"when="init"> Whereonecanfindsourcesforyourmodule? <hint> PleaseprovidelinktotheCVSwebclientat http://www.netbeans.org/download/source_browse.html orjustusetagdefaultanswergenerate='here' </hint> </question>
-->
<answer id="arch-where">
Sources can be found in editor/mimelookup/impl module.
</answer>
<!-- <questionid="compat-deprecation"when="init"> Howtheintroductionofyourprojectinfluencesfunctionality providedbypreviousversionoftheproduct? <hint> Ifyouareplanningtodeprecate/remove/changeanyexistingAPIs, listthemhereaccompaniedwiththereasonexplainingwhyyou aredoingso. </hint> </question>
-->
<answer id="compat-deprecation">
As the module's API/SPI has been naturaly evolving over the time the module contains
several deprecated classes. All of them are still fully supported and the
module remains backward compatible.
</answer>
</api-answers>
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.26Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.