第九章 Advanced Solutions

Advanced Solutions
Objectives
Upon successful completion of this module, you will be able to:
• Perform tasks in the Engineer Component element of the Application Solution Development module of the System RVP work stream.
• Implement a custom link.
• Implement a listener service.
Exercise 9-1: Implement a Custom Link
Objectives
● Implement a custom link class.
Scenario
The customer needs to store information dependent on a relationship (link). In this exercise,you will model a custom link, selecting an appropriate design pattern.
Detailed Description
1. Each CustomerOrder can be connected to 0 to many CustomParts.
2. For each CustomPart related to a CustomerOrder, a quantity can be specified.
3. A CustomPart can be used on several different CustomerOrders, so quantity is relationship-specific.
Step 1. Refer to the wt.part.WTPartUsageLink and wt.part.WTPartDescribeLink as patterns.
Step 2. Clean up previous customization.
Step 3. Model a link between a custom Part and a custom Document.
Step 4. System generate.
Step 5. Recompile.
Step 6. Restart Tomcat and the Method Server.
Step 7. Test.
Listener Service
Windchill services provide functionality in two particular areas:
1. A mechanism for clients to call server side methods (which are invoked and processed on the server) to take advantage of server performance and centralized resources
2. A mechanism for Windchill to “listen” for, and in turn respond to, system events such as:
• Check in
• Check out
• State change
• Update
• Delete
Service Types
• Listener service
– Invoked and processed whenever a specific type of event is dispatched
– Does not require direct interaction from the client
– Automatically started by the Method Server
– May dispatch events
••
Business service
– Invoked and processed whenever a method provided by the service is called
– Automatically started by the Method Server
– May also be a listener service
– May dispatch events

• Lightweight service
– Is not automatically started by the Method Server
– May dispatch events
Summary of Services
第一行How Invoked,Automatically started by Method Server,Helper, Can Dispatch Events?
Listener, When a specific type of event is dispatched,Yes ,Not ,required ,Yes
Business, When a method provided by the service is called,Yes, Yes, Yes
Lightweight ,When a method provided by the service is called,No ,Not ,required ,Yes
Listener Service
A listener service is not called directly by clients or other services, but rather registers one or more “listener” objects that correspond and respond to a specific type of event respectively.
Modeling a listener service follows the same standard modeling design pattern as for all other types of service. However, a helper abstraction is not necessary and the service abstraction has no operations defined in its RemoteInterface or Interface, as no direct interaction will occur.
Service Events
Service event classes can be found in the API Javadoc as extensions of “KeyedEvent”.
There are 2 general types of events:
1. Vetoable
• These events can be vetoed or rolled back by the listener of the event
2. Non-vetoable
• These events cannot be vetoed by the listener of the event and merely a notification
A listener vetoes an event by throwing an exception (such as a .WTException) back to the original dispatcher of the event, which must in turn roll back any database updates that were made prior the event as part of a block managing a transaction.
Implementing Event Listeners
A listener inner class is implemented in the StandardManager extension.
The listener inner class must implement the wt.events.KeyedEventListener interface.
wt.services.ServiceEventListenerAdapter already does this, so it can be extended instead.
Registering Event Listeners
A listener service subscribes to specific service events by registering an instance of a listener class in a specialized performStartupProcess() method. For example:
This method instantiates a listener object and associates it with a specified event when the service is automatically started by the Method Server. A service entry property is required.
Registering Service Events
A listener service registers specific custom service events that it may emit with the StandardManagerService in a specialized registerEvents() method, for example:
Automatic Service Startup
Windchill properties specify which services should be started automatically when the Method Server is launched. For example:
Entries specify the Interface or RemoteInterface, followed by the StandardManager extension.
Automatic Service Startup and Shutdown
The following two methods are inherited from StandardManager and are intended to be overridden to specialize startup and shutdown processing:
1. performStartupProcess()
2. performShutdownProcess()

你可能感兴趣的:(tomcat,UP,performance)