A P P E N D I X A |
Component Library Structure |
Sun ONE Application Framework components are packaged and distributed in ordinary JAR files. The JAR file must contain:
Optionally, a Sun ONE Application Framework component library JAR may contain:
The contents of the /webapp directory are called the "Additional Files". This is a Sun ONE Application Framework IDE toolset value add feature that allows developers to distribute arbitrary additional files inside their component library JAR. The Sun ONE Application Framework Sun ONE Application Framework IDE toolset will "unpack" these additional files into the Web application development environment. See Automated Unpacking of "Additional Files" below.
The contents of a Sun ONE Application Framework component library JAR must be structured as follows:
Sun ONE Application Framework requires that each component library JAR contain a special Sun ONE Application Framework component library manifest file. The component library manifest file is a simple XML document that describes the collection of components within the library. A component library manifest may declare any number of components and associated Sun ONE Application Framework component model resources.
The IDE toolset automatically introspects each JAR file mounted in an Sun ONE Application Framework application's WEB-INF/lib directory. It specifically looks inside the JAR for the component library manifest file. If the IDE toolset finds a valid component library manifest file in the prescribed location within the JAR file, the IDE toolset will expose any properly declared components for design time utilization within the IDE toolset. If it does not find the component library manifest file in the expected location within the JAR file, or if the component library manifest is invalid, the IDE toolset will not recognize the JAR as a component library.
The component library manifest must comply with the following strict rules:
jato-component-library_1_0.dtd
As part of a Sun ONE Application Framework component library, a library developer may provide one or more tag libraries to support rendering of the library's View components. Tag libraries are declared in the component library's component manifest file, and when the IDE toolset recognizes the component library, its tag library descriptors (.tld files) are automatically unpacked from the library JAR file for use by the application. In addition, the IDE toolset automatically adds tag library entries to the web.xml file.
Tag library descriptor files are unpacked to a special location under the application's WEB-INF/tld directory based on the name of the library to ensure that same-named files from different libraries do not conflict. In this scheme, library names are converted to directory names by replacing dots (".") with underscores ("_"). For example, the Sun ONE Application Framework Component Library's internal library name is "com.iplanet.jato", which is translated to "com_iplanet_jato" when unpacking the tag library descriptor. The SCL's tag descriptor file ultimately appears under the WEB-INF/tld/com_iplanet_jato directory in your application.
The tag descriptor's derived physical directory name is automatically registered to a logical resource name in the web.xml file for use by the application. This logical name is chosen by the component library author and specified in the component library manifest. In the SCL's case, the descriptor is registered as the resource /WEB-INF/jato.tld.
The tag descriptor unpacking mechanism makes use of timestamps to determine if an existing file should be overwritten when a new version of the library is added to an application. This feature ensures that upgrading of an application's component libraries is just a single step for a developer.
Referring to the example "mycomponents" library described in this guide. The library author has created a tag library tld file called mycomplib.tld and arbitrarily placed it in the mycomponents package. Therefore, looking into the mycomponents.jar file, the tld appears physically located as follows:
Inside of the complib.xml, the component author has declared a taglib element as follows:
<taglib-uri>/WEB-INF/mycomplib.tld</taglib-uri> <taglib-resource>/mycomponents/mycomplib.tld</taglib-resource> |
Based on the configuration described by the taglib element, whenever the mycomponens.jar is deployed into a Sun ONE Application Framework Web application's WEB-INF/lib directory, the IDE toolset will automatically perform the following steps. These steps will allow the run-time JSP engine to properly locate the tag library. This frees the application developer from having to perform any configuration.
Also, at design-time, as the developer builds application Views, the IDE toolset will perform the following:
Sun ONE Application Framework recognizes that taglib prefix is a JSP page specific directive. J2EE allows each page to declare arbitrary prefixes for the included tag libraries via the tablib directive. The IDE toolset will always utilize the current taglib directive declared prefix as it parses the JSP looking for tags, or whenever it automatically inserts additional tags into the JSP in conjunction with the developer's View design decisions. The IDE toolset merely utilizes the complib.xml specified taglib "prefix" to insert an initial taglib directive into the application JSP files. Application developers can subsequently manually change the prefix declared in the page specific taglib directive. The IDE toolset thereafter utilizes the newly declared prefix for any additional tags, but it will not automatically change any already declared tags to coincide with the adjusted prefix. This is an application developer issue. It is mentioned here so that component authors fully understand the design-time usage of complib.xml's taglib element.
Optionally, a Sun ONE Application Framework component library JAR might contain arbitrary "Additional Files" arranged hierarchically underneath the /webapp directory.
Do not confuse a Sun ONE Application Framework component library JAR's internal /webapp directory with the common servlet container directory called "webapps". There is absolutely no relationship between the two.
The hierarchical arrangement of the files within the Sun ONE Application Framework component library JAR's /webapp root is totally up to the discretion of the component library author. As a value added feature, the Sun ONE Application Framework IDE tools will "unpack" these additional files into the Web application development environment in direct correspondence to the additional files location relative to the /webapp root.
For example, consider a mycomponents.jar that contains the following /webapp structure:
/webapp/mycomponents/images/banner.gif /webapp/WEB-INF/jato/templates/jsp/MyViewBeanJSP.jsp /webapp/WEB-INF/jato/templates/jsp/FooContainerViewJSP.jsp /webapp/WEB-INF/lib/helper.jar |
When the mycomponents.jar, with the above content, is deployed into a Sun ONE Application Framework application, the IDE toolset will extract the /webapp content into the particular Sun ONE Application Framework application's structure.
For example, consider a Sun ONE Application Framework application called "AppOne" which has the following initial structure created by the Sun ONE Application Framework IDE toolset.
AppOne/WEB-INF/jato/templates/jsp/DefaultViewBeanJSP.jsp AppOne/WEB-INF/jato/templates/jsp/DefaultContainerViewJSP.jsp |
After "deploying" the mycomponents.jar (for example, dropping it into AppOne/Web-INF/lib), the IDE toolset will discover that it is a Sun ONE Application Framework component library and extract the "additional files" which will result in the creation of the following integrated structure:
Component library authors can leverage the Additional Files Feature to provide any arbitrary resources which they consider appropriate for extraction. Examples of common Additional Files are (but not limited to):
For example, assume that the component library relies on a custom XML parsing library. The component author can "bundle" that JAR inside the component library JAR. This is potentially a more convenient distribution model than requiring the application developer to deploy these extra libraries manually.
For example suppose the component author designs a set of components which support extra configuration via arbitrary configuration file(s). These configuration files can be "bundled" with the component library and extracted into the appropriate location via the Additional Files mechanism.
Note - The automated extraction of the component library tld file(s) is handled via a different mechanism. The component library tld file(s) should not be located under the /webapp root, but rather placed in their normal "resource" appropriate location within the component library JAR (for example, mycomplib.tld above). See Automated Unpacking of Component Tag Libraries (TLD) Files shown in this Chapter A, Component Library Structure. |
Copyright © 2003, Sun Microsystems, Inc. All rights reserved.