Creating data objects
BOFactory boFactory = (BOFactory)ServiceManager.INSTANCE.locateService("com/ibm/websphere/bo/BOFactory");
The following code snippet shows how you can determine the type of a process variable and create a new data object of that type:
Type type = getVariableType("Output");
Output = boFactory.createByType(type);
To create a nested data object, you can use the createDataObject method of the DataObject:
DataObject nested = Output.createDataObject("processBusinessObject");
You can also create a data object using the create method of the BOFactory service. You have to specify name and namespace:
MyBO = factory.create(" http://JavaSnippets/bpc/samples","BO");
Copying data objects
BOCopy copyService = (BOCopy)ServiceManager.INSTANCE.locateService("com/ibm/websphere/bo/BOCopy");
The BOCopy service offers to methods to create a deep copy of data objects: copy and copyInto. The copy method returns a copy of the original DataObject and the copyInto method allows to copy the original DataObject into the structure of an existing DataObject.
Copy:
DataObject dataObject = copyService.copy(ProcessBusinessObject);
CopyInto:
copyService.copyInto(ProcessBO, Output, "processBO");
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@page import="com.ibm.websphere.sca.ServiceManager"%>
<%@page import="com.ibm.websphere.bo.BOFactory"%>
<%@page import="commonj.sdo.DataObject"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<%
ServiceManager serviceManager = ServiceManager.INSTANCE;
//Create the Business Object factory to create business object at runtime
BOFactory boFactory = (BOFactory)serviceManager.locateService("com/ibm/websphere/bo/BOFactory");
%>
Initialization for BO Factory is done.
<br>
<%
//Create Customer business object
//Use BOFactory.create() method to create the data object, because the business object is created by the Business Object editor
//First parameter is the namespace of the business object. You can find it from the Namespace field of the properties view in the Business Object Editor.
//Second parameter is the name of the business object. It can be found in the Name field of the properties view in the Business Object Editor.
DataObject customer = boFactory.create("http://BankModule/com/bank/eMerged", "Customer");
//set values for the simple-typed attributes
customer.setString("customerName", "John Smith");
customer.setString("customerId", "11111111");
//The customer business object has an attribute of type Address, which is another business object.
//To set value on this attribute, create a business object using DataObject.createDataObject().
//However, because this method will overwrite any existing value, add isSet() to make sure the attribute is not already set.
if (!customer.isSet("address")){
DataObject address = customer.createDataObject("address");
address.setString("wholeAddress", "8200 Warden Avenue");
//The only attribute left is the "accounts" attribute. A customer business object contains a list of accounts.
//First, create the data object for the Account business object. And set the values for the attributes
DataObject ac1 = boFactory.create("http://BankModule/com/bank/eMerged", "Account");
ac1.setString("accountNum", "ABC12345");
ac1.setFloat("balance", 5678.9f);
DataObject ac2 = boFactory.create("http://BankModule/com/bank/eMerged", "Account");
ac2.setString("accountNum", "DEF34567");
ac2.setFloat("balance", 100.3f);
//Second, prepare the list for adding the account data object
ArrayList acList = new ArrayList();
acList.add(ac1);
acList.add(ac2);
//Third, set the "accounts" attribute to be the list.
customer.setList("accounts", acList);
}
%>
Customer business object has been created.
<br>
<br>
Printing customer information...
<br>
<!-- Retrieve customer name -->
Customer name: <%= customer.getString("customerName") %>
<br>
<%
//Retrieve customer address object
DataObject address2 = customer.getDataObject("address");
%>
Customer address: <%= address2.getString("wholeAddress") %>
<br>
Customer's account list which is an array:
<%
//Retrieve the list of customer accounts
List list = customer.getList("accounts");
DataObject a1 = (DataObject)list.get(0);
%>
<br>
Account 1 : <%= a1.getString("accountNum")%>
</body>
</html>
分享到:
相关推荐
SOA SCA/SDO编程模型PPT 为什么要SOA SOA的编程模型 SCA/SDO介绍 为什么使用SCA/SDO
SOA编程模型_SCA_SDO SOA编程模型_SCA_SDO
CANopen PDO-SDO应用实例讲解,看完之后对于CANopen协议中的对象数据,PDO,SDO能有比较全面的认识,协助进行编程。
emf-sdo-xsd-SDK-2.4.0.zip emf是Eclipse modeling framework组建框架的缩写;SDO是服务数据对象的缩写,它是Java程序的一种数据编程框架;emf-sdo-xsd-SDK-2.4.0.zip是Eclipse编程器的组成员之一。
eclipse 3.3的可视化编程利器——VE,需要的几个插件之一,全部需要的插件列表:emf-sdo-runtime-2.2.0,GEF-runtime-3.2,VE-runtime-1.2.3_jem,VE-SDK-1.2,注意版本!
eclipse下可视化编程插件,有它可以让你的编程得心应手,专业工具让你更专业
IBM-SOA编程模型指南 内容: 为什么要SOA SOA的编程模型 SCA/SDO介绍 为什么使用SCA/SDO
教你安装可视化编程 Eclipse Tool Project 主要用到Graphical Editor Framework (GEF) Project, EMF, VE,我算是吃尽苦头.........emf-sdo-runtime-2.2.0 GEF-runtime-3.2 VE-runtime-1.2.3 VE-SDK-1.2
数据编程的编程模型规范,它提供了对常见应用模式的有力支持,并允许应用程 序、工具和框架更轻松地查询、查看、绑定、更新和内省数据。本白皮书讨论了 SDO背后的驱动因素,呈现了SDO架构,并讨论了提供给业内供应...
这是图形化界面编程的三个插件,这里一起提供了免得到处去搜索了··
IBM的SOA编程模型培训ppt,关于SCA和SDO。
人工智能编程范例(pt-br) 葡萄牙语编程入门(pt-br)做人工智能编程范式:彼得·诺维格(Peter Norvig,1992)的“普通Lisp案例研究” 。 在麻省理工学院就读的学生的自动授课资格。 VOCE颇得tambémquerer ...
java编程所用到的组件,有需要的自己下吧,找的很辛苦的
IBM 关于SOA编程模型(SCA)的最新介绍
出于积累Verilog编程和调试经验的需求,用这个东西练手 使用的是正点原子领航者zynq的板子 实验环境过于优越了 导致进度慢就会很自责 写个总结算是对得起我这两天的debug, eeprom 用的是板子上自带的AT24C64 inout...
Attiny13,重置保险丝和芯片,使用高压(HV)串行编程模式 使用5V-12V升压电路提供12V +/- 0.5V VPP进入HV模式。 周围没有可用的12V电源 修改固件,启用重置开关可单独工作以重置保险丝,LED结束时快速闪烁,以完成...
2个装Lomboz3.2要用到插件(最好装在eclipse3.2上)。 本来要把GUI编程的4个插件全上传,可惜有限制上传文件大小,只能传其中2个,这两个插件装Lomboz3.2的时候也是必要的。
本书立足于技术底层,试图指引读者理解构建SOA的基础编程模式。这一技术模式也并非耳熟能详 的Web服务,而是新兴的SOA技术标准——服务组件架构(Service Component Architecture, SCA)、 服务数据对象(Service ...
本书立足于技术底层,试图指引读者理解构建SOA的基础编程模式。这一技术模式也并非耳熟能详 的Web服务,而是新兴的SOA技术标准——服务组件架构(Service Component Architecture, SCA)、 服务数据对象(Service ...
本书立足于技术底层,试图指引读者理解构建SOA的基础编程模式。这一技术模式也并非耳熟能详 的Web服务,而是新兴的SOA技术标准——服务组件架构(Service Component Architecture, SCA)、 服务数据对象(Service ...