1
<?xml version="1.0" encoding="UTF-8"?><!-- -*- sgml-indent-step: 1 -*- -->
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5
Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
8
The contents of this file are subject to the terms of either the GNU
9
General Public License Version 2 only ("GPL") or the Common
10
Development and Distribution License("CDDL") (collectively, the
11
"License"). You may not use this file except in compliance with the
12
License. You can obtain a copy of the License at
13
http://www.netbeans.org/cddl-gplv2.html
14
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15
specific language governing permissions and limitations under the
16
License. When distributing the software, include this License Header
17
Notice in each file and include the License file at
18
nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
19
particular file as subject to the "Classpath" exception as provided
20
by Sun in the GPL Version 2 section of the License file that
21
accompanied this code. If applicable, add the following below the
22
License Header, with the fields enclosed by brackets [] replaced by
23
your own identifying information:
24
"Portions Copyrighted [year] [name of copyright owner]"
28
The Original Software is NetBeans. The Initial Developer of the Original
29
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30
Microsystems, Inc. All Rights Reserved.
32
If you wish your version of this file to be governed by only the CDDL
33
or only the GPL Version 2, indicate your decision by adding
34
"[Contributor] elects to include this software in this distribution
35
under the [CDDL or GPL Version 2] license." If you do not indicate a
36
single choice of license, a recipient has the option to distribute
37
your version of this file under either the CDDL, the GPL Version 2 or
38
to extend the choice of license to its licensees as provided above.
39
However, if you add GPL Version 2 code and therefore, elected the GPL
40
Version 2 license, then the option applies only if the new code is
41
made subject to such option by the copyright holder.
43
<!DOCTYPE api-answers PUBLIC "-//NetBeans//DTD Arch Answers//EN" "../../nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd" [
44
<!ENTITY api-questions SYSTEM "../../nbbuild/antsrc/org/netbeans/nbbuild/Arch-api-questions.xml">
48
question-version="1.26"
49
author="cwebster@netbeans.org"
56
<question id="arch-overall" when="init">
57
Describe the overall architecture.
60
<a href="http://openide.netbeans.org/tutorial/api-design.html#design.apiandspi">
61
clients and what support API</a>?
62
What parts will be pluggable?
63
How will plug-ins be registered? Please use <code><api type="export"/></code>
64
to describe your general APIs.
65
If possible please provide
70
<answer id="arch-overall">
72
XDM (XML Document Model) provides a XAM based full fidelity XML model which
73
implements the org.w3c.dom interfaces. The intention is not to provide an
74
an alternate implementation of the dom interfaces but only to reuse part of
75
the api where it makes sense and more importantly provide a foundation on
76
which to provide a model basis for graphical multi way editors.
78
This module was developed to support the following requirements:
80
<li>Full document fidelity. This allows the original document to be
81
preserved and only changes the actual sections of the document which
82
were mutated (i.e. the transformation is lossless).</li>
83
<li>Support for undo/redo in a memory efficient way</li>
84
<li>Support for diff to allow changes to be detected in
85
the underlying source</li>
86
<li>Visitor support</li>
88
<api name="org.netbeans.modules.xml.xdm" category="friend" type="export" group="java">
89
This package provides API's for obtaining an XDM document and mutating
92
<api name="org.netbeans.modules.xml.xdm.diff" category="friend" type="export" group="java">
93
XML diff capabilities are exposed through this package.
95
<api name="org.netbeans.modules.xml.xdm.nodes" category="friend" type="export" group="java">
96
XDM based implementation of DOM interfaces.
98
<api name="org.netbeans.modules.xml.xdm.xam" category="friend" type="export" group="java">
99
XAM model and component abstractions based on XDM tree. This is the
100
basis for XML language models (like WSDL, Schema, and BPEL).
102
<api name="org.netbeans.modules.xml.xdm.visitor" category="friend" type="export" group="java">
103
Visitors for operations over the XDM such as generating XPath
104
expressions, calculatin document position and finding elements by
112
<question id="arch-quality" when="init">
113
How will the <a href="http://www.netbeans.org/community/guidelines/q-evangelism.html">quality</a>
114
of your code be tested and
115
how are future regressions going to be prevented?
117
What kind of testing do
118
you want to use? How much functionality, in which areas,
119
should be covered by the tests?
123
<answer id="arch-quality">
125
This module is covered by JUnit tests and findBugs has been incorporated into
126
the development process. This module is the core of most of the domain
127
models and is extensively covered.
134
<question id="arch-time" when="init">
135
What are the time estimates of the work?
137
Please express your estimates of how long the design, implementation,
138
stabilization are likely to last. How many people will be needed to
139
implement this and what is the expected milestone by which the work should be
144
<answer id="arch-time">
146
This module is implementation complete, but will require additional effort
147
for ongoing maintenence in conjunction with the other modules.
154
<question id="arch-usecases" when="init">
156
Content of this answer will be displayed as part of page at
157
http://www.netbeans.org/download/dev/javadoc/usecases.html
158
You can use tags <usecase name="name> regular html description </usecase>
159
and if you want to use an URL you can prefix if with @TOP@ to begin
160
at the root of your javadoc
163
Describe the main <a href="http://openide.netbeans.org/tutorial/api-design.html#usecase">
164
use cases</a> of the new API. Who will use it under
165
what circumstances? What kind of code would typically need to be written
169
<answer id="arch-usecases">
171
The typical client of XDM would be a tool author supporting an XML language
172
who wants to provide a custom client API. A concrete example of this is the XML
173
Schema model. The XML Schema model starts by subclassing AbstractXDMModel and
174
providing the component updater, which is called in conjunction with sync
175
to mutate the model according to changes in the underlying source.
177
<usecase id="uc1" name="WSDL model">
178
The WSDL model is based on the XDM model and relies on the XDM capabilities
179
to provide the infrastructure necessary for providing a XAM based model.
181
<usecase id="uc2" name="Schema model">
182
The Schema model is based on the XDM model and relies on the XDM capabilities
183
to provide the infrastructure necessary for providing a XAM based model.
185
<usecase id="uc3" name="BPEL model">
186
The BPEL model is based on the XDM model and relies on the XDM capabilities
187
to provide the infrastructure necessary for providing a XAM based model.
190
The XDM model can be used in standalone mode.
192
BaseDocument sd = ...;
194
Lookup lookup = Lookups.singleton(sd);
196
// create an editable ModelSource with base document
198
// in the lookup (this is required)
200
ModelSource ms = new ModelSource(lookup, true);
202
// create an XDMModel
204
XDMModel model = new XDMModel(ms);
206
// sync the XDM model with the underlying source
210
// create customer element, same as dom
212
Element customer = model.getDocument().createElement("customer");
214
// add to the model as 0th child of employee element, not shown
216
model.add(employee,customer,0);
225
<question id="arch-what" when="init">
226
What is this project good for?
228
Please provide here a few lines describing the project,
229
what problem it should solve, provide links to documentation,
234
<answer id="arch-what">
235
The XDM module provides a basis for tool ready XML language models that require full
236
document fidelity, undo/redo, and the ability to sync with the underlying source.
237
<p>List of the main features:</p>
239
<li>Support for full document fidelity. The users text including spacing and
240
comments are preserved.</li>
241
<li>Undo / Redo is supported using the concept of an immutable tree. XDM nodes
242
do not have parent pointers (only a pointer to the model). Thus a node can
243
be in multiple trees, where each tree is a version. When a mutation to the tree
244
occurs a clone is made of each node in the parent path from the root to the mutated
245
node. All unchanged nodes are simply referenced and thus will live in multiple
246
trees. Thus an undo / redo is simply a reference change. The cost of storing
247
multiple tree is minimized as only the diffs are stored in each version of the
249
<li>The visitor pattern is used in addition to the DOM interfaces which allows
250
easier tree walking</li>
251
<li>An XML diff visitor supports XML difference. Element identity can be
252
supplied by the client.</li>
259
<question id="arch-where" when="init">
260
Where one can find sources for your module?
262
Please provide link to the CVS web client at
263
http://www.netbeans.org/download/source_browse.html
264
or just use tag defaultanswer generate='here'
268
<answer id="arch-where">
269
<defaultanswer generate='here' />
275
<question id="compat-i18n" when="impl">
276
Is your module correctly internationalized?
278
Correct internationalization means that it obeys instructions
279
at <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/i18n-branding.html">
280
NetBeans I18N pages</a>.
284
<answer id="compat-i18n">
293
<question id="compat-standards" when="init">
294
Does the module implement or define any standards? Is the
295
implementation exact or does it deviate somehow?
298
<answer id="compat-standards">
300
This module implements the DOM interfaces but is not intended to be a
301
replacement for DOM. This module has special semantics surrounding mutation
302
and thus the full DOM interfaces are not supported.
309
<question id="compat-version" when="impl">
310
Can your module coexist with earlier and future
311
versions of itself? Can you correctly read all old settings? Will future
312
versions be able to read your current settings? Can you read
313
or politely ignore settings stored by a future version?
316
Very helpful for reading settings is to store version number
317
there, so future versions can decide whether how to read/convert
318
the settings and older versions can ignore the new ones.
322
<answer id="compat-version">
324
no settings or user visible features.
331
<question id="dep-jre" when="final">
332
Which version of JRE do you need (1.2, 1.3, 1.4, etc.)?
334
It is expected that if your module runs on 1.x that it will run
335
on 1.x+1 if no, state that please. Also describe here cases where
336
you run different code on different versions of JRE and why.
340
<answer id="dep-jre">
349
<question id="dep-jrejdk" when="final">
350
Do you require the JDK or is the JRE enough?
353
<answer id="dep-jrejdk">
362
<question id="dep-nb" when="init">
363
What other NetBeans projects and modules does this one depend on?
365
If you want, describe such projects as imported APIs using
366
the <code><api name="identification" type="import or export" category="stable" url="where is the description" /></code>
371
<defaultanswer generate='here' />
377
<question id="dep-non-nb" when="init">
378
What other projects outside NetBeans does this one depend on?
381
Some non-NetBeans projects are packaged as NetBeans modules
382
(see <a href="http://libs.netbeans.org/">libraries</a>) and
383
it is preferred to use this approach when more modules may
384
depend on such third-party library.
388
<answer id="dep-non-nb">
397
<question id="dep-platform" when="init">
398
On which platforms does your module run? Does it run in the same
401
If your module is using JNI or deals with special differences of
402
OSes like filesystems, etc. please describe here what they are.
406
<answer id="dep-platform">
408
100% java, no platform requirement.
415
<question id="deploy-dependencies" when="final">
416
What do other modules need to do to declare a dependency on this one?
418
Provide a sample of the actual lines you would add to a module manifest
419
to declare a dependency, for example using OpenIDE-Module-Module-Dependencies
420
or OpenIDE-Module-Requires. You may use the magic token @SPECIFICATION-VERSION@
421
to represent the current specification version of the module.
425
<answer id="deploy-dependencies">
427
This module is only exposing friend api's, thus a friend entry must be added
428
to this module before use.
435
<question id="deploy-jar" when="impl">
436
Do you deploy just module JAR file(s) or other files as well?
438
Usually a module consist of one JAR file (perhaps with Class-Path
439
extensions) and also a configuration file that enables it. If you
440
have any other files, use
441
<api group="java.io.File" name="yourname" type="export" category="friend">...</api>
442
to define the location, name and stability of your files (of course
443
changing "yourname" and "friend" to suit your needs).
445
If it uses more than one JAR, describe where they are located, how
446
they refer to each other.
447
If it consist of module JAR(s) and other files, please describe
448
what is their purpose, why other files are necessary. Please
449
make sure that installation/uninstallation leaves the system
450
in state as it was before installation.
454
<answer id="deploy-jar">
463
<question id="deploy-nbm" when="impl">
464
Can you deploy an NBM via the Update Center?
470
<answer id="deploy-nbm">
479
<question id="deploy-packages" when="init">
480
Are packages of your module made inaccessible by not declaring them
484
NetBeans module system allows restriction of access rights to
485
public classes of your module from other modules. This prevents
486
unwanted dependencies of others on your code and should be used
487
whenever possible (<a href="http://www.netbeans.org/download/javadoc/OpenAPIs/org/openide/doc-files/upgrade.html#3.4-public-packages">
489
</a>). If you do not restrict access to your classes you are
490
making it too easy for other people to misuse your implementation
491
details, that is why you should have good reason for not
492
restricting package access.
496
<answer id="deploy-packages">
498
currently friends support is being used, thus all clients are known.
505
<question id="deploy-shared" when="final">
506
Do you need to be installed in the shared location only, or in the user directory only,
507
or can your module be installed anywhere?
509
Installation location shall not matter, if it does explain why.
510
Consider also whether <code>InstalledFileLocator</code> can help.
514
<answer id="deploy-shared">
523
<question id="exec-ant-tasks" when="impl">
524
Do you define or register any ant tasks that other can use?
527
If you provide an ant task that users can use, you need to be very
528
careful about its syntax and behaviour, as it most likely forms an
529
API for end users and as there is a lot of end users, their reaction
530
when such API gets broken can be pretty strong.
534
<answer id="exec-ant-tasks">
543
<question id="exec-classloader" when="impl">
544
Does your code create its own class loader(s)?
546
A bit unusual. Please explain why and what for.
550
<answer id="exec-classloader">
559
<question id="exec-component" when="impl">
560
Is execution of your code influenced by any (string) property
561
of any of your components?
564
Often <code>JComponent.getClientProperty</code>, <code>Action.getValue</code>
565
or <code>PropertyDescriptor.getValue</code>, etc. are used to influence
566
a behavior of some code. This of course forms an interface that should
567
be documented. Also if one depends on some interface that an object
568
implements (<code>component instanceof Runnable</code>) that forms an
573
<answer id="exec-component">
582
<question id="exec-introspection" when="impl">
583
Does your module use any kind of runtime type information (<code>instanceof</code>,
584
work with <code>java.lang.Class</code>, etc.)?
586
Check for cases when you have an object of type A and you also
587
expect it to (possibly) be of type B and do some special action. That
588
should be documented. The same applies on operations in meta-level
589
(Class.isInstance(...), Class.isAssignableFrom(...), etc.).
593
<answer id="exec-introspection">
595
The casting is documented. This needs to be reviewed and cleaned up. We need
596
to look at each instanceof, AssignableFrom, and cast to see if we can eliminate
597
this using a) visitor b) JDK 1.5 return value override
604
<question id="exec-privateaccess" when="final">
605
Are you aware of any other parts of the system calling some of
606
your methods by reflection?
608
If so, describe the "contract" as an API. Likely private or friend one, but
609
still API and consider rewrite of it.
613
<answer id="exec-privateaccess">
622
<question id="exec-process" when="impl">
623
Do you execute an external process from your module? How do you ensure
624
that the result is the same on different platforms? Do you parse output?
625
Do you depend on result code?
627
If you feed an input, parse the output please declare that as an API.
631
<answer id="exec-process">
640
<question id="exec-property" when="impl">
641
Is execution of your code influenced by any environment or
642
Java system (<code>System.getProperty</code>) property?
645
If there is a property that can change the behavior of your
646
code, somebody will likely use it. You should describe what it does
647
and the <a href="http://openide.netbeans.org/tutorial/api-design.html#life">stability category</a>
648
of this API. You may use
650
<api type="export" group="property" name="id" category="private" url="http://...">
651
description of the property, where it is used, what it influence, etc.
657
<answer id="exec-property">
666
<question id="exec-reflection" when="impl">
667
Does your code use Java Reflection to execute other code?
669
This usually indicates a missing or insufficient API in the other
670
part of the system. If the other side is not aware of your dependency
671
this contract can be easily broken.
675
<answer id="exec-reflection">
684
<question id="exec-threading" when="impl">
685
What threading models, if any, does your module adhere to?
687
If your module calls foreign APIs which have a specific threading model,
688
indicate how you comply with the requirements for multithreaded access
689
(synchronization, mutexes, etc.) applicable to those APIs.
690
If your module defines any APIs, or has complex internal structures
691
that might be used from multiple threads, declare how you protect
692
data against concurrent access, race conditions, deadlocks, etc.,
693
and whether such rules are enforced by runtime warnings, errors, assertions, etc.
694
Examples: a class might be non-thread-safe (like Java Collections); might
695
be fully thread-safe (internal locking); might require access through a mutex
696
(and may or may not automatically acquire that mutex on behalf of a client method);
697
might be able to run only in the event queue; etc.
698
Also describe when any events are fired: synchronously, asynchronously, etc.
699
Ideas: <a href="http://core.netbeans.org/proposals/threading/index.html#recommendations">Threading Recommendations</a> (in progress)
703
<answer id="exec-threading">
705
This model has been synchronized for thread safety. Thread safety is supported
706
by allowing only a single model mutation (using java synchronized keyword). The
707
immutable nature of the model only requires synchronization when updating the
708
tree thus synchronization of nodes which are not yet in the tree is not thread
716
<question id="format-clipboard" when="impl">
717
Which data flavors (if any) does your code read from or insert to
718
the clipboard (by access to clipboard on means calling methods on <code>java.awt.datatransfer.Transferable</code>?
721
Often Node's deal with clipboard by usage of <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
722
Check your code for overriding these methods.
726
<answer id="format-clipboard">
735
<question id="format-dnd" when="impl">
736
Which protocols (if any) does your code understand during Drag & Drop?
738
Often Node's deal with clipboard by usage of <code>Node.drag, Node.getDropType</code>.
739
Check your code for overriding these methods. Btw. if they are not overridden, they
740
by default delegate to <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
744
<answer id="format-dnd">
753
<question id="format-types" when="impl">
754
Which protocols and file formats (if any) does your module read or write on disk,
755
or transmit or receive over the network? Do you generate an ant build script?
756
Can it be edited and modified?
760
Files can be read and written by other programs, modules and users. If they influence
761
your behaviour, make sure you either document the format or claim that it is a private
762
api (using the <api> tag).
766
If you generate an ant build file, this is very likely going to be seen by end users and
767
they will be attempted to edit it. You should be ready for that and provide here a link
768
to documentation that you have for such purposes and also describe how you are going to
769
understand such files during next release, when you (very likely) slightly change the
775
<answer id="format-types">
777
This module is designed to read and write XML files through a swing document.
784
<question id="lookup-lookup" when="init">
785
Does your module use <code>org.openide.util.Lookup</code>
786
or any similar technology to find any components to communicate with? Which ones?
789
Please describe the interfaces you are searching for, where
790
are defined, whether you are searching for just one or more of them,
791
if the order is important, etc. Also classify the stability of such
792
API contract. For that use <api group=&lookup& /> tag.
796
<answer id="lookup-lookup">
805
<question id="lookup-register" when="final">
806
Do you register anything into lookup for other code to find?
808
Do you register using layer file or using <code>META-INF/services</code>?
809
Who is supposed to find your component?
813
<answer id="lookup-register">
822
<question id="lookup-remove" when="final">
823
Do you remove entries of other modules from lookup?
825
Why? Of course, that is possible, but it can be dangerous. Is the module
826
your are masking resource from aware of what you are doing?
830
<answer id="lookup-remove">
839
<question id="perf-exit" when="final">
840
Does your module run any code on exit?
843
<answer id="perf-exit">
852
<question id="perf-huge_dialogs" when="final">
853
Does your module contain any dialogs or wizards with a large number of
854
GUI controls such as combo boxes, lists, trees, or text areas?
857
<answer id="perf-huge_dialogs">
866
<question id="perf-limit" when="init">
867
Are there any hard-coded or practical limits in the number or size of
868
elements your code can handle?
871
<answer id="perf-limit">
873
no. This module is able to parse large schemas > 1MB.
880
<question id="perf-mem" when="final">
881
How much memory does your component consume? Estimate
882
with a relation to the number of windows, etc.
885
<answer id="perf-mem">
887
A basic populated model is about 8000 bytes, this depends on how many components
888
and the size of the file.
895
<question id="perf-menus" when="final">
896
Does your module use dynamically updated context menus, or
897
context-sensitive actions with complicated and slow enablement logic?
899
If you do a lot of tricks when adding actions to regular or context menus, you can significantly
900
slow down display of the menu, even when the user is not using your action. Pay attention to
901
actions you add to the main menu bar, and to context menus of foreign nodes or components. If
902
the action is conditionally enabled, or changes its display dynamically, you need to check the
903
impact on performance. In some cases it may be more appropriate to make a simple action that is
904
always enabled but does more detailed checks in a dialog if it is actually run.
908
<answer id="perf-menus">
917
<question id="perf-progress" when="final">
918
Does your module execute any long-running tasks?
920
<hint>Long running tasks should never block
921
AWT thread as it badly hurts the UI
922
<a href="http://performance.netbeans.org/responsiveness/issues.html">
924
Tasks like connecting over
925
network, computing huge amount of data, compilation
926
be done asynchronously (for example
927
using <code>RequestProcessor</code>), definitively it should
928
not block AWT thread.
932
<answer id="perf-progress">
934
This module is used by clients and thus does not react directly to user
942
<question id="perf-scale" when="init">
943
Which external criteria influence the performance of your
944
program (size of file in editor, number of files in menu,
945
in source directory, etc.) and how well your code scales?
947
Please include some estimates, there are other more detailed
948
questions to answer in later phases of implementation.
952
<answer id="perf-scale">
954
The size of the XML file both in terms of the number of bytes as well as
955
the number of elements and attributes.
962
<question id="perf-spi" when="init">
963
How the performance of the plugged in code will be enforced?
965
If you allow foreign code to be plugged into your own module, how
966
do you enforce that it will behave correctly and quickly and will not
967
negatively influence the performance of your own module?
971
<answer id="perf-spi">
973
Client code providing element identity may impact the performance of sync.
974
However, invoking sync is done by the client as thus the impact will be
975
reflected in the client module. There is no direct user interaction in
983
<question id="perf-startup" when="final">
984
Does your module run any code on startup?
987
<answer id="perf-startup">
996
<question id="perf-wakeup" when="final">
997
Does any piece of your code wake up periodically and do something
998
even when the system is otherwise idle (no user interaction)?
1001
<answer id="perf-wakeup">
1010
<question id="resources-file" when="final">
1011
Does your module use <code>java.io.File</code> directly?
1014
NetBeans provide a logical wrapper over plain files called
1015
<code>org.openide.filesystems.FileObject</code> that
1016
provides uniform access to such resources and is the preferred
1017
way that should be used. But of course there can be situations when
1018
this is not suitable.
1022
<answer id="resources-file">
1031
<question id="resources-layer" when="final">
1032
Does your module provide own layer? Does it create any files or
1033
folders in it? What it is trying to communicate by that and with which
1037
NetBeans allows automatic and declarative installation of resources
1038
by module layers. Module register files into appropriate places
1039
and other components use that information to perform their task
1040
(build menu, toolbar, window layout, list of templates, set of
1045
<answer id="resources-layer">
1054
<question id="resources-mask" when="final">
1055
Does your module mask/hide/override any resources provided by other modules in
1059
If you mask a file provided by another module, you probably depend
1060
on that and do not want the other module to (for example) change
1061
the file's name. That module shall thus make that file available as an API
1062
of some stability category.
1066
<answer id="resources-mask">
1075
<question id="resources-read" when="final">
1076
Does your module read any resources from layers? For what purpose?
1079
As this is some kind of intermodule dependency, it is a kind of API.
1080
Please describe it and classify according to
1081
<a href="http://openide.netbeans.org/tutorial/api-design.html#categories">
1082
common stability categories</a>.
1086
<answer id="resources-read">
1095
<question id="security-grant" when="final">
1096
Does your code grant additional rights to some other code?
1097
<hint>Avoid using a class loader that adds extra
1098
permissions to loaded code unless really necessary.
1099
Also note that your API implementation
1100
can also expose unneeded permissions to enemy code by
1101
calling AccessController.doPrivileged().</hint>
1104
<answer id="security-grant">
1113
<question id="security-policy" when="final">
1114
Does your functionality require modifications to the standard policy file?
1115
<hint>Your code might pass control to third-party code not
1116
coming from trusted domains. This could be code downloaded over the
1117
network or code coming from libraries that are not bundled
1118
with NetBeans. Which permissions need to be granted to which domains?</hint>
1121
<answer id="security-policy">