This chapter from BEA WebLogic Workshop 8.1 (Kick Start series, from Sams Publishers, by Albert J. Saganich, Jr., et al., 2004. ISBN: 0-672-32622-1) explores the WebLogic Workshop programming model and introduces enterprise application development.
WebLogic Workshop Application Development Basics - Workshop Applications Breakdown (Page 5 of 7 )
Workshop Web applications are divided into three major sections. One major section is the Web application itself, named yournameWeb by default, which contains
-Controller.jpf—A default Page Flow used as the starting point of application development. Error.jsp and Index.jsp are two default pages used by the Page Flow.
resources—A folder containing a set of images, header and template JSP files, and associated stylesheets that can be used as the basis of a common look for a Web application. Note that template.jsp and header.jsp have a simplified look and feel and should not be confused with a portal look and feel.
WEB-INF—A folder containing all the XML-based application deployment descriptors, tag libraries, and XML definitions required to support Page Flows. Workshop manages almost all files in the WEB-INF folder, and these files should not be edited by hand.
Another major section is the default Schema project, which contains the following:
Schemas—A folder used to house any XML Schema files. Schemas can be added to this project by drag and drop. Newly added schemas are compiled, and then the generated XML Beans are added to the application's libraries folder. Application developers can use the generated XML Bean classes to create, delete, update, or otherwise manage associated XML.
The last major section is supporting libraries and security definitions common to the application folders:
Libraries—A folder containing all support libraries. You can add libraries to a project by dragging them into the Libraries folder, which maps to the APP-INF\lib directory of an enterprise application.
Modules—A folder containing all deployed J2EE enterprise resources. The Modules folder contains the application.xml and weblogic-application.xml files, which Workshop manages automatically. This folder maps to the META-INF folder of an enterprise application.
Security Roles—A folder containing application-defined security roles. The roles defined in an application are normally mapped to WebLogic Server groups. Security entries map to Security-role definitions in the application.xml file.
As we saw in Chapter 2, workshop applications contain one or more projects. These are the most common project types:
Web Application—These projects are standard Web applications packaged as Web Application Archive (WAR) files. Web Application projects contain a default Page Flow and support for creating new Page Flows, accessing existing controls, and creating new controls. Typically, Web projects are used to make Web applications available for use with browsers, but the application's functionality can also be made available via Web services.
Web Service—These projects are targeted at making application functionality available as a Web service using WSDL and are packaged into WAR files. Note that Web Service projects can contain Page Flows as well as Web services.
Control—Control projects consist solely of control classes, which are designed to be used by other developers to create portals, Web applications, and so forth. Control projects are packaged into Java archive (JAR) files and can be dropped into another application's lib directory.
EJB—EJB projects consist solely of EJBs and any support classes. EJB projects are packaged into JAR files and can also be used by being dropped directly into another application's lib directory.
Schema—Schema projects contain XML Schema files. Schema files are then compiled into XML Beans, a generated set of classes for managing XML documents. XML Beans are an exciting new BEA technology for creating, accessing, and working with XML. XML Beans are examined in detail in Chapter 10, "Handling Data in WebLogic Workshop: Working with Schemas and XML Beans."
Java Project—These projects contain packages of Java classes. Java projects are used to create reuseable class libraries and are packaged in JAR files.
In addition, if you have purchased or downloaded WebLogic Workshop Platform Edition, you can create other project types, such as
Process—Process projects consist of a default business process definition and compile into a JAR file that other projects or applications can access. Process projects can also be made available as Web services and accessed by other Web services platforms.
Portal and Datasync—Portal projects contain all the required infrastructure for creating portal applications. Creating a portal project results in the creation of a parallel datasync project containing rules, campaigns, placeholders, and other portal-specific features. Portal applications are packaged into EAR files.
To create a new project, select File, New, Project from the Workshop menu. Alternatively, select your application in the Application tab, right-click, and choose New Project. In the New Project dialog box (see Figure 10), select the type of project you would like to add. The type of project list, labeled (D) in Figure 10, displays subsets of the project types in the pane labeled (E). The All option displays all project types, and the other options display subsets of project types. Select the type, labeled (D), and the subtype, labeled (E), and enter your new project name in the space labeled (F). A new project is then added to Workshop, and corresponding entries are added in the underlying XML deployment descriptors.
Application Default Services - Applications are created supporting a default set of services. For example, Web applications do not support portal functionality by default. You can add portal or other project support to applications or projects by selecting the project, right-clicking, and choosing Install, support service from the menu. Support service could be WebLogic Portal or some other new service you want to use in your application. In this way, you can later add Portal or Integration support to a core Web application. Note that you might also need to select a new server because the core server might not include the runtime services required to support the new additions.
Figure 10 - The New Project dialog box.
With all the Workshop project types, the question is "When do you use one project type versus another?" When you need to build a portal project, the answer is clear. However, as a rule of thumb, you should use a different project whenever you are creating reuseable units of functionality or to separate unrelated functional areas. As we examine controls, portals, integration and other project and application types we will also examine when it is appropriate to create a new project or application, and when to extend the current application.
Installing Application Functionality - WebLogic Workshop is flexible in what kind of project to create. Web applications, portal projects, and process projects are the norm. However, what happens if you want a combination project, one that perhaps spans portals and workflows? One of the simplest ways to add functionality to a project is to select the root project, right-click, and choose Install. For example, you can insert portal support into a Web application by choosing Install, Portal.
Unfortunately, installing new support into an existing application is somewhat of a problem. Depending on the combination of resources, not everything works as planned, and it's never clear what the root cause is. So how can you create a project and be sure it will support the features you want? Practice has shown that the best way to develop an application is to start with the simplest project that supports the job at hand. In practice, that means creating controls (EJB, business process, or general) within their own projects, unit testing in an application that supports only those features you want, and then ultimately creating an overall application that supports all the features previously tested as standalone and integrates them together.
Use the following guidelines:
Create custom, rowset, and EJB controls in control projects. Unit test in Web applications.
Create business process controls in business process control projects. Delegate all background processing to custom controls. Place business logic only in business process controls.
Create portals and portlets in portal projects. Add only tested controls to portal projects.
Create overall applications that start with portal or business process support. Install other functionality to the application as required. Add tested logic via controls projects.
This chapter is from BEA WebLogic Workshop 8.1, by Albert J. Saganich, Jr., et al. (Apress, 2004, ISBN: 0-672-32622-1). Check it out at your favorite bookstore today. Buy this book now.