第九章 Advanced Solutions_2

Exercise 9-2: Implement a Listener Service
Objectives
● Implement a listener service.
Scenario
The customer needs to log all CustomerOrder objects created each day as input to an external ERP system. For this exercise, implement the listener service design pattern and add all appropriate coding and properties to log the creation of the CustomerOrder objects.
Step 1. Identify the appropriate event.
a. The event occurs after creation, so POST_STORE should be used.
Step 2. Model a listener service.
a. Create a new package com.customer.services.
b. Inside com.customer.services, model CustomerOrderService as a RemoteInterface that extends nothing
c. Model StandardCustomerOrderService that extends nothing but implements both CustomerOrderService and wt.services.StandardManager.
Example:
d. For StandardCustomerOrderService, copy the operations performStartupProcess() and performShutdownProcess() from Standard Manager.
e. Save the sub units.
f. System generate.
Step 3. Edit the Java code.
a. Edit WT_HOME/src/com/customer/services/StandardCustomerOrderService.java.
b. Find the “user.operations” block.
c. Set “preserve” equal to yes. Add the following code:
d. Still inside StandardCustomerOrderService.java, override the performStartupProcess() method:
e. Compile, 3 Java files total.
Step 4. Edit properties and propagate.
a. Examine wt.properties to find an available service number and verify that this number is available using xconfmanager:
b. Add a new service entry to wt.properties to automatically start the service:
c.
Step 5. Test.
a. Restart Tomcat and the Method Server.
b. Create a CustomerOrder.
Exercise 9-3: API Programs
Objectives
● Implement a API program to search.
● Implement a API program to create a custom Part.
Scenario
The customer has several requirements for nightly programs. These programs will be used to generate data for input to an ERP system. In this exercise, you will need to build the required programs using the API as reference.
Detailed Description
1. Search for all CustomerOrder objects.
2. Search for specific custom Part objects, by name.
3. Create a custom Part.
Step 1. Search for all CustomerOrder objects.
a. Create a Java application com.customer.utils.CustomerUtility with a Main method.
b. Add a method getAllOrders(). Call this method from the Main method.
c. Add a package statement.
d. Implement a wt.fc.QueryResult object to represent the results of a search.
e. Implement a wt.query.QuerySpec object to identify the class being searched (CustomerOrder).
f. Add the wt.fc.PersistenceHelper.manager.find() method to execute the search.
g. Loop through the results of the QueryResult and print out name and number of the objects found.
h. Use the default “get” and “set” methods automatically generated for each attribute to also print out attribute information.
i. Some of the APIs will require a try/catch block. Figure out what exceptions are thrown by testing or through the API for QuerySpec, QueryResult and PersistenceHelper. In the example below, “co” represents a CustomerOrder object.
j. Run the program, then use the OOTB search UI to verify the results.
Step 2. Search for specific custom Part objects by name.
a. Create a Java application com.customer.utils.CustomerUtility with a Main method.
b. Add a method getPartsByName(). Call this method from the Main method.
c. Add a package statement and import statements.
d. In addition to the wt.fc.QueryResult and wt.query.QuerySpec objects, a SearchCondition will need to be added to limit the objects returned. In the example, “qs” is a QuerySpec object:
e. Add the wt.fc.PersistenceHelper.manager.find() method to execute the search.
f. Loop through the results of the QueryResult — it’s an extension of java.util.Enumeration —and print out the name and number of the custom Parts.
g. Use the default get and set methods automatically generated for each attribute to also print out attribute information.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值