< Day Day Up > |
As you saw in Chapter 3, "WebLogic Workshop Application Development Basics," controls are objects that encapsulate business logic or provide access to resources. Controls provide an elegant, consistent, and straightforward mechanism to access resources and logic, as though they were simple Java objects. Control Runtime ArchitectureControls are supported by a runtime architecture covering two key areas: method dispatch and invocation . During dispatch, the correct code is located to run, and then during invocation, the code is called with the appropriate wrapping context. In general, dispatch requires that a client request be sent to the correct method within some control. Dispatching clients could be JavaServer Pages (JSPs), in the case of Web applications, controls, or other components , such as Web services. Behind the scenes, all dispatch requests are handled by an EJB runtime made up of three EJBs in the com.bea.wlw.runtime. core .bean package. SyncDispatcherBean , a stateless session bean, handles dispatch requests for synchronous methods . AsyncDispatcherBean , a message-driven bean, handles dispatch requests for asynchronous methods, and AsyncErrorBean , a message-driven bean, supports notification of asynchronous delivery failures via the onAsynchFailure callback. Invocation, the second step in any method call, is performed after the correct method has been determined. From a client perspective, there's no difference in calling a method directly; however, three areas are involved in the method invocation:
The control container provides a number of services to the control, including initialization, event and callback support, and dispatch services. Figure 6.1 shows how a client method invocation actually occurs and should be familiar to anyone with a Remote Procedure Call (RPC) background. Figure 6.1. Method invocation.
Component TypesWebLogic Workshop components are, for all practical purposes, either Java classes or Java interfaces but with specialized file name extensions that tell Workshop what the component is. Table 6.1 describes the major component types and their extensions. Note that this table focuses only on components and controls and omits other similar functionality, such as Java Page Flows (JFPs). Table 6.1. Workshop Component Types
Control UnderpinningsCompiling a control in WebLogic Workshop is more than just creating the appropriate bytecode. Because of annotations, you might need specialized background resources, specialized support code, or other mechanisms to support a specific control. WebLogic Workshop code is compiled in two ways: automatically or on demand via the Build menu. Except when you're producing a final version of an application or a project, Workshop's automatic compile mechanism is sufficient for application development. Control MethodsBefore you begin developing controls, a more detailed examination of control functionality is necessary. As discussed in Chapter 3, control methods can be synchronous, asynchronous, or callback. Figure 6.2 shows a simple JCS that contains all three possible methods. Figure 6.2. Methods within a Workshop control.
From a consumer perspective, synchronous and asynchronous methods are similar, with the exception of return values. Both synchronous and asynchronous methods can take traditional Java parameters as input. Synchronous methods can return any Java primitives or complex data types, whereas asynchronous methods (often referred to as buffered ) must always return void .
WebLogic Workshop supports a mechanism known as a callback . Figure 6.3 depicts a callback method. Callbacks are not a new concept; however, the ease with which they can be created and used in Workshop is certainly new. In a control, a callback method is indicated with a left-pointing blue arrow. When a control is added to another control, a Web service, or a Java business process, any callback methods are shown in blue. When you click on a callback definition, the method call is automatically added to the new control's definition. Workshop then opens the control in Source View and places the cursor at the beginning of the newly added callback method. You can then code the callback method to do whatever is required with the parameters the called control returns. Figure 6.3. Callback within a Java control.
|
< Day Day Up > |