I. development components
Before introducing how to deploy the PB component to the Jaguar CTS server, we will first introduce how to develop a component using PowerBuilder 7. This step is very important because many options need to be set here, and these options directly affect the deployment of PB components.
The jauar component developed by PB is a special PB non-visual object NVO with some special events and attributes ). In addition to writing code and setting some attributes in PB, this object also needs to set some special options in jaruar to control the behavior of components, these options can be set manually or a large part of them can be set through the PB of the sample uar component wizard.
To create a component using the Jaguar component wizard, you need to answer a series of questions and set some options. Understanding these settings and options is very important, because it directly affects the behavior of components deployed on the jaruar server.
Generally, the Juguar component wizard is used when you use PowerBuilder to create a jauar component. This wizard guides you through a series of settings to create a new one. The values entered during the Wizard guide will finally affect the events, attributes, and deployment options of the component. Therefore, you must pay attention to the options and attribute values during the wizard process. Next we will start to use the component wizard step by step to create a jauar component, which will detail all the options and attributes involved.
Select the "File | New" menu or directly select "New" in the toolbar ". A dialog box consisting of multiple tags is displayed in PowerBuilder. Select the "Start Wizards" tab, select "Jaguar Component", and click "OK" to Start the Jaguar Component wizard. The preceding steps are required when you create a component for the first time. Once a component application is created using the wizard, you only need to create another component under the "Object" label.
The first screen of the wizard first describes the features of the wizard and how to access the Jaugar object through the client application. Click "Next" to display the Next dialog box. This dialog box summarizes all the information required by the wizard and the questions to be answered. Click "Next". The dialog box shown in 1 appears. This dialog box prompts you to enter the application name and library path. Here, you can take an application name that reflects the component function, or select the default name "genapp". Finally, confirm the library path and click "Next. The library path is displayed on the Next screen. If necessary, you can change the path and click "Next". The Dialog Box 2 is displayed. This dialog box requires you to enter the name and description of the non-visual component of PowerBuilder. By default, the system prefix "n _" is added before the application name. Click "Next" to bring up the Next dialog box. In this dialog box, you must enter a component name, which is the same as the name of the PowerBuilder object by default, but you can change the component name. Click "Next". On the Next screen, ask the user to enter information about the connection to the Jaguar server, as shown in 3. When a component is deployed to the jauar server, PowerBuilder needs this information to connect to the server. If the Jaguar component Server runs on a local machine, enter localhost in "Server name". If the component Server is not running locally, enter the Server name or its IP address. The port number is the listener port number specified during the creation of the jaruar server, which is saved as 9000. The default Logon account is jaradmin, and the default password is null. The administrator of the error code returned when changing the default Logon account and password. Click "Next.
Figure 1 New Application name and Library
Figure 2 Specify the new application name and Library
Figure 3 specify the new application name and Library
The next screen requires you to specify a package name for the component. What is a package? Generally, a package is a set of function-related objects. A package name is required for all components deployed on the jaruar server. Here, you can manually enter a package name or an existing package name on the Jaguar server. Click "Next.
The next screen requires you to select the component type. There are three types to choose from: Standard common components), shared instances) and service-type services are imported at server startup to provide backend services for the jaruar client or component ). The "sharing" attribute of a shared component is set to TRUE. Service components are not only marked as shared, but also have other methods, such as running, starting, and stopping. Select the required component type and click "Next.
The next screen is used to specify the instance buffer options. If "not supported)" is selected, you can add code to the component "CanBePooled" event to change the component instance to support buffering. You can also change the buffer attribute of the component in the jauar manager. Select the required buffer attribute and click "Next.
Figure 4 New Application name and Library
The next screen is used to specify whether transactions Support Transaction Support) and automatic Demarcation/automatic clearing of Auto Demarcation/Deactivation) options. These two attributes can also be directly set through Jaugar manager. Next we will explain several transactions separately.
- "Not Supported)": indicates that the component is executed outside the scope of the transaction;
- "Supports Transaction support)" means that if a Transaction is being executed, the component will execute in this Transaction; otherwise, the component will execute outside the Transaction.
- "Requires Transaction request Transaction)" indicates that the component will be executed within a Transaction all the time. If the client sends a service request to a component, a new transaction starts. If a component is requested by another component that is already running in a transaction, the component uses the transaction of another component.
- "Requires New Transaction request New Transaction)" indicates that a New Transaction starts after a component is initialized.
If the "Automatic demarcation/clearing" option is selected, the component is automatically inactive after any of its methods are called; otherwise, the component is not active until it receives a SetAbort or SetComplete call. After the selection is complete, click "Next" and the Next screen is used to specify Interface Options. These options allow you to modify the component interface method. Here, unless you have special requirements for components or have a clear understanding of these options, we generally recommend that you do not change these options and keep the default values. Click "Next.
The next screen is used to select remote debugging for remote debugging) and live editing for field editing ). The remote debugging option is very useful during development, but do not select this option when the code is finally released. Otherwise, you can see your component code. On-site editing means that Powerbuilder will automatically deploy the component to the Jaguar every time it changes and saves the component canvas. Select the required option and click "Next.
Some options for PBD generation will be selected below. If you select the first option, PowerBuilder will create a single merged PBD from the PBD in the list of all databases, and then specify some options for the merged PBD. If there are some dynamic references in the component's data window, such as the data window), you should select the second option include unreferenced objects ). Enter the name of a merged PBD and the name of the resource file PBR used. This resource file enables the component to have the same functions as the Powerbuilder application in the general sense. Click "Next.
Finally, the wizard displays all the options and generates a "work plan to_do) List" for this component. Click the "Finish" button. At this point, the component will be generated.
2. Modify the PB object as a component
Sometimes you need to upgrade an existing PB object to a component. In this case, you need to add some events and create a project for deploying the component.
1. Add events
To upgrade a traditional PB object to a Jaguar component, you need to add other events, including activate, deactivate, and optional canBePooled events.
- Activate-this event maps to "pbm_component_activate ". The Event code is executed every time the component is activated. Note that the ing event is "pbm_component_activate" rather than pbm_activate, which is usually very familiar.
- Deactivate-this event maps to "pbm_component_deactivate ". This event is activated when the component is not active.
- CanBePooled-this event is mapped to "pbm_component_canbepooled ". It is used to buffer instances of program control components. When 1 is returned, instance buffering is allowed. If 0 is returned, instance buffering is prohibited.
2. Create a deployment project
Once a traditional PowerBuilder object is upgraded to a jaruar component, you need to create another deployment project, which will be discussed in detail in the next section.
3. deployment process and options
Before using a component for a client application, you must deploy the component to an application server. In Powerbuilder 7, you can use the integration features of PB and jaruar to directly deploy the components to the jaruar server every time you modify and save the components in PB. This feature is called Live Editing in PB, which is very helpful in the development and test environments, but cannot be applied to the actual application environment.
1. Composition of PB Components
- PowerBuilder PBDs
A deployed PowerBuilder component has many elements. The first is the compiled PB code, which is stored in one or more pbds. In the operating system, you must specify the path of these component libraries so that the PowerBuilder PBDs can be accessed by the PowerBuilder Runtime Library engine in Jaugar.
- IDL
In addition to the PowerBuilder code, you also need an interface description, which is used when the client application requests the service from the component on the server. These interface information is described in the Interface Definition Language (IDL.
- Resources
A resource is a bitmap or data window required by a dynamic component application. These resources are stored in the PBR file.