Articles and Tips: article
Senior Software Engineer
Web Application Servers
01 Dec 1999
Intoduces Novell's component model and development framework for IBM WebSphere for NetWare. Identifies foundational JavaBeans that abstract Novell services, and introduces the MCV model for building applications with discrete components that execute business logic, format output, and model data.
IBM WebSphere offers one of the most complete Web application platforms on the market today for development, deployment, and management of Web applications. IBM Websphere for NetWare takes advantage of NetWare's efficient design to enhance server-side Java development and facilitate development and management of Web E-commerce solutions. In addition, IBM WebSphere for NetWare supports the Novell Web Application Framework, a comprehensive set of abstracted Novell services represented as servlets, Java Server Pages (JSP), JavaBeans and Enterprise Java Beans (EJB). These development components abstract Novell services including Novell Directory Services (NDS) to make it easier to assemble server-side Java applications and E-commerce Web solutions that are robust, quick to build, and cost effective.
This Developer Note is an introduction to Novell's component model and development framework for IBM WebSphere for NetWare. It identifies foundational JavaBeans that abstract Novell services, and introduces the MVC model for building applications with discrete components that execute business logic, format output, and model data. Complete technical details are available at the Web sites listed at the end of this article.
Novell Web Application Framework
IBM WebSphere for NetWare affords a component framework for developing Web applications that leverage NDS and other Novell services. This article focuses on the interaction between HTML clients and Web application servers. IBM WebSphere uses JavaBeans extensively within its infrastructure and as a development tool. Before discussing each element of the MVC framework, you need to understand the JavaBean component model.
Web applications typically consist of requests made from Web browsers or client applications to Web application servers. These request use standard Internet protocols such as HTTP or other standard protocols. A key difference between a Web application and a stand-alone client application is that the Web application relies on the server and not on the client's workstation for execution of most of the business logic. HTML clients make HTTP requests to a Web application server and receive HTML pages as a response. The HTML is generated by components or services that are executed on a Web application server in response to the HTTP requests coming from the client. The HTML pages can be static HTML pages or dynamically generated HTML pages.
The interaction between a Web application server and a Web client begins with an HTML page displayed in a Web browser. A user submits a form or clicks on a link, which is sent to the Web application server. The request is processed on the Web application server and the results are returned as a new HTML page to the client. The architecture and components used to handle the interactions between a Web client and a Web application server can be constructed using a model/view/controller (MVC) pattern as follows:
Model the components that expose the business logic for a particular Web application or service.
View the components that construct HTML pages that are returned to a user by a Web application in response to HTTP requests.
Controller the components or services that drive the Model and View components.
The components that make up the WebSphere MVC framework are shown in Figure 1.
Figure 1: Components of the WebSphere MVC.
JavaBeans are defined as Java classes that expose functionality and state using properties, events and methods. Properties can be set on an instance of a bean to put it into a desired state prior to processing. Methods can then be called on the instance of the bean to cause the desired action to take place. Events are "fired" as the specific state of the bean changes, and event handlers "catch" events that are thrown from the event sources. At this point, property values can be retrieved from the instance of the bean that reflect the state of the bean as a result of processing.
An instance of a bean can be saved to a file or database using a process called "serialization." As a result, the user of a bean can create an instance of the bean, customize it by setting the desired properties, serialize the bean, and save the results. The serialized bean can be instantiated and the properties set previously by the user can then be restored.
Foundation Beans define the primary layer between NetWare services and Web applications. Novell provides foundation JavaBeans that encapsulate a majority of the NetWare services. These foundation beans abstract and expose Novell services using familiar Java classes and types such as enumerations, collections, Strings, and so forth. The foundation beans currently include a Directory bean (exposing NDS), a Session bean, a Volume Administration bean and others. Future beans include LDAP beans, licensing beans, security administration beans, and NetWare operating system control beans.
As stated previously, the responsibility of the controller components is to drive the Model and View components. Controller components are embodied in either Java Servlets/ServletBeans or Java Server Pages (JSP).
Java Servlets. Java servlets can be defined as dynamically loaded extensions to a Java-enabled Web server that process HTTP requests and responses. Since Java servlets are simply Java classes, they can interact with other Java components using property "getters" and "setters," method calls, and event handlers. Servlet beans are Java servlets that adhere to the JavaBeans specification. Novell will provide a complete set of servlets and servlet beans that expose NetWare services and run in the IBM WebSphere application server environment.
JSP. Java Server Pages (JSP) introduce a set of HTML tags that allow a Web page designer to merge inline Java code into an HTML script file. JSP files are interpreted by the IBM WebSphere application server and translated into Java Servlets when executed. This process enables a Web application developer with modest HTML and Java scripting skills to construct HTML pages that are interpreted by an IBM WebSphere application server and converted to powerful servlets.
Model components define the business logic of a Web application. IBM WebSphere implements model components as"Command Beans." Command beans are discrete components that encapsulate a single business logic task.
Command Beans. A Command bean is a Java Bean that not only encapsulates a single business logic task, but also provides a stable boundary between the business logic and the user interface. A Command bean creates a bean, initializes the state of the bean by setting specific properties of the bean, executes the bean's "perform" method, and gets the values of the bean's properties. This programming model helps to isolate changes in the Web application by factoring the business logic into fine-grained components that are easily managed and less reliant on other components. This model also allows easier distribution of processing using serialization to send the bean over IIOP, HTTP, and other protocols to a remote server that executes and returns with the results.
The Command interface provides the primary interface for the command bean. It consists of three methods: isReadyToCallPerform, perform and reset. A Command bean can be in one of the following states during its lifecycle:
New The Command bean is in this state immediately after creation. In this state, the isReadyToCallPerformmethod will return FALSE and the get methods should not be called.
Initialized The Command bean is in this state after all required input properties have been set. In this state, the isReadyToCallPerformmethod will return TRUE and the get methods should not be called.
Executed The Command bean is in this state after the perform method has been called. In this state, the isReadyToCallPerformmethod will return TRUE and the get methods can be called.
Command beans that execute locally (i.e., in the same JVM as the Web application) implement the Command interface. If a Command bean is to execute remotely on another server, it implements the TargetableCommand interface. This interface is an extension of the Command interface to allow for remote execution. This interface implementation is accomplished by extending the TagetableCommandImplclass. Whether the command bean executes locally or remotely, the JSP/servlet executes the command bean in the same way. The steps in a command bean's execution from a JSP are:
The JSP/servlet instantiates the command bean. It then sets the command bean's input properties. Finally, the JSP/servlet calls the perform method on the command bean. If the Command bean executes locally, skip to step 2 below. Otherwise, these additional steps occur:
The perform method determines the target environment for the Command bean.
The perform method calls the executeCommandmethod on the CommandTargetobject, passing itself (the Command bean) as an input argument. This step may entail serializing the command bean and sending it via some protocol (such as the IIOP protocol) to the target server for execution.
The command target, after potentially de-serializing the Command bean, then calls the Command bean's executePerformmethod, which encapsulates the business logic.
The performmethod, if successful, returns a copy of the Command bean with its output properties set to the results of the underlying business logic task.
Control flows to the JSP/Servlet, which is now free to query the output properties of the Command bean.
Command Beans for NetWare. Novell will offer a comprehensive set of Command beans that will encapsulate functionality for Directory Services, NetWare File System, NetWare Storage Services, NCP Server Administration, Distributed Print Services, SNMP, Queue Services Administration, NetWare Operating System Services, and other services. Also included will be beans defining the soon to be released Directory Services Access Model (DSAM).
The view components of a Web application are responsible for generating the HTML page that will be returned to the client. When one or more Command Beans have been driven to the executed state, data can be retrieved from them and formatted for viewing in an HTML page. Simple data formatting can be done using standard HTML tags. More complex data formatting is done using Format beans to take the data set and return formatted HTML.
JSP Format Beans. Format beans help format various types of dynamic content. Complex data formatting is easily done using one or more Format beans.
Formatting is usually specific to the characteristics of the user, such as the locale of the user. For this reason, each Format bean provides two formatting methods: One takes the servlet request object as a parameter, and one does not. When the request object is provided, the method will extract information from the request object to customize the formatting operation. When the request object is not provided, the method will use default values and/or server-wide values such as the default locale.
Most of the formatting beans produce locale specific results. By convention, they determine the locale from the request context value "JSPLocale" which must be a java.util.Localevalue. If "JSPLocale" is not set in the request context or the request context is not available then the system's default locale will be used. Each of the formatting beans also allow the locale to be configured. In this case, the configured locale will take precedent over the JSPLocale value.
An example of the interaction between Command beans and Format beans to produce an HTML tree view of an NDS context from a JSP page follows:
<% NWCmdDSBrowse dsBrowse = new NWCmdDSBrowse(); dsBrowse.setFullName(?NDS:\\\\myTree\\myOrg\\myOrgUnit?); dsBrowse.perform(); NWTreeFormat treeFormat = new NWTreeFormat(); %> <%= treeFormat.format(request, dsBrowse.getContextData()) %>
Format Beans for IBM. IBM provides a comprehensive set of Format beans that allow easy formatting of generic data types for different locales. IBM's JSPTableFormat bean is a good example of the practicality of a Format bean. To produce a table, you configure a set of properties on the JSPTableFormat bean. With JSPTableFormatCustomizer, you can produce a sophisticated table by modifying a single line of code.
Beans in IBM's Format Bean Suite include:
Format Beans for NetWare. Novell will provide a comprehensive set of Format Beans that allow easy formatting of NetWare specific data types. These will include beans for all NDS Syntax types, NetWare File System types, tree views for NDS browsing, and NetWare File System browsing. Also included will be beans defining the soon to be released Directory Services Access Model (DSAM).
Novell's integration of Foundation Beans, EJBs, MVC Beans, Servlets and Java Server Pages provides a complete component framework to build Web applications that expose NetWare services. Figure 2 illustrates the relationship of each layer of the framework.
Figure 2: WebSphere component framework.
Novell's Web application framework for IBM WebSphere provides a comprehensive platform for developing Web applications that expose NetWare services. This framework simplifies Web application development and deployment by factoring NetWare services into manageable components that work within WebSphere's Java-based application environment.
* Originally published in Novell AppNotes
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.