|
There are multiple IDE modules that need access to definition of web module. On one side there are modules that provide wizards, edititing, debugging etc. for JSPs, web.xml, servlets, and similar. On the other side there are also multiple project types that can contain web modules in them. This API/SPI exists for communication between these two types of modules.
Question (arch-overall): Describe the overall architecture. Answer:WebModuleAPI - The API part provides access to web module properties and defines constants for use web module projects (such as action commands or source types). The SPI part can be implemented by modules that provide web module "project" support. It can be implemented with project APIs but other implementations are also possible. There is also an SPI which allows implementors to provides support for web frameworks such as Struts and JSF.
Question (arch-usecases): Describe the main use cases of the new API. Who will use it under what circumstances? What kind of code would typically need to be written to use the module? Answer:
The WebModule
class, which encapsulates a web module, has methods
for retrieving the module's properties:
FileObject myServlet = ...; WebModule wm1 = WebModule.getWebModule (myServlet); String version = wm1.getJ2eePlatformVersion (); System.out.println ("Servlet is in version:" + version + " web module");
Most often the web module is implemented inside a project:
public class MyProjectType implements Project { Lookup getLookup () { return Lookups.fixed(new Object[] { new MyProvider (), ... } } private class MyProvider implements WebModuleProvider { WebModule findWebModule(FileObject file) { if (isMyFile (file)) { WebModule wm; synchronized (this) { wm = cachedWebModule (file); if (wm == null) { wm = WebModuleFactory.createWebModule (new WebModuleImpl ()); cache (file, wm); } } return wm; } } boolean isMyFile (FileObject file) {...} WebModule cachedWebModule (FileObject file) {...} cache (FileObject file, WebModule wm) {...} } private class WebModuleImpl implements WebModuleImplementation { ... } }
It is also possible to implement web modules backed by other means than
a project by implementing a WebModuleProvider
and registering
it in the default lookup.
Support for web frameworks, such as Struts and JSF, can
extend a WebModule
with framework-specific features, such as configuration files. An implementor
wanting to provide such support implements WebFrameworkProvider
and registers it in the
j2ee/webtier/framework
in the default file system.
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
These modules are required in project.xml:
There are 2 public packages that are both specified in manifest:
Nothing.
This module does not deprecate any existing APIs.
java.io.File
directly?
Answer:
No.
Question (resources-layer):
Does your module provide own layer? Does it create any files or
folders in it? What it is trying to communicate by that and with which
components?
Answer:
No.
Question (resources-read):
Does your module read any resources from layers? For what purpose?
Answer:
No.
Question (resources-mask):
Does your module mask/hide/override any resources provided by other modules in
their layers?
Answer:
No.
Question (resources-preferences):
Does your module uses preferences via Preferences API? Does your module use NbPreferences or
or regular JDK Preferences ? Does it read, write or both ?
Does it share preferences with other modules ? If so, then why ?
Answer:
No.
org.openide.util.Lookup
or any similar technology to find any components to communicate with? Which ones?
Answer:
The module is looking for org.netbeans.spi.web.webmodule.WebModuleProvider
instances
and uses them to resolve org.netbeans.api.web.webmodule.WebModule.getWebModule()
query.
The module registers an instance of org.netbeans.spi.web.webmodule.WebModuleProvider
that implements the query based on projects - it delegates to WebModuleProvider
instances found in lookup of the project that owns the given file.
System.getProperty
) property?
On a similar note, is there something interesting that you
pass to java.util.logging.Logger
? Or do you observe
what others log?
Answer:
No.
Question (exec-component):
Is execution of your code influenced by any (string) property
of any of your components?
Answer:
No.
Question (exec-ant-tasks):
Do you define or register any ant tasks that other can use?
Answer:
No
Question (exec-classloader): Does your code create its own class loader(s)? Answer: No. Question (exec-reflection): Does your code use Java Reflection to execute other code? Answer: No. Question (exec-privateaccess): Are you aware of any other parts of the system calling some of your methods by reflection? Answer: No. Question (exec-process): Do you execute an external process from your module? How do you ensure that the result is the same on different platforms? Do you parse output? Do you depend on result code? Answer: No. Question (exec-introspection): Does your module use any kind of runtime type information (instanceof
,
work with java.lang.Class
, etc.)?
Answer:
No.
Question (exec-threading):
What threading models, if any, does your module adhere to? How the
project behaves with respect to threading?
Answer:
None.
Question (security-policy):
Does your functionality require modifications to the standard policy file?
Answer:
No
Question (security-grant): Does your code grant additional rights to some other code? Answer:No
java.awt.datatransfer.Transferable
?
Answer:
Not applicable.
No
Question (perf-progress): Does your module execute any long-running tasks? Answer: No. Question (perf-huge_dialogs): Does your module contain any dialogs or wizards with a large number of GUI controls such as combo boxes, lists, trees, or text areas? Answer: No. Question (perf-menus): Does your module use dynamically updated context menus, or context-sensitive actions with complicated and slow enablement logic? Answer: No. Question (perf-spi): How the performance of the plugged in code will be enforced? Answer:WebModuleProvider.findWebModule()
is the critical method for SPI performance
(both time and memory). It is expected that implementations will cache the results
and that the implementation will be reasonably fast.