锘??xml version="1.0" encoding="utf-8" standalone="yes"?>99久久精品免费看国产小宝寻花 ,翔田千里一区,日产精品久久久久久久性色http://www.aygfsteel.com/sunxiaobo/category/28817.htmlEclipse-Europa http://umlfact.berlios.de/~s_xsun/zh-cnWed, 09 Jan 2008 05:10:01 GMTWed, 09 Jan 2008 05:10:01 GMT60The location of EMF ResourceSethttp://www.aygfsteel.com/sunxiaobo/archive/2007/12/17/168358.htmlXiaobo SunXiaobo SunMon, 17 Dec 2007 14:34:00 GMThttp://www.aygfsteel.com/sunxiaobo/archive/2007/12/17/168358.htmlhttp://www.aygfsteel.com/sunxiaobo/comments/168358.htmlhttp://www.aygfsteel.com/sunxiaobo/archive/2007/12/17/168358.html#Feedback0http://www.aygfsteel.com/sunxiaobo/comments/commentRss/168358.htmlhttp://www.aygfsteel.com/sunxiaobo/services/trackbacks/168358.html

Xiaobo Sun 2007-12-17 22:34 鍙戣〃璇勮
]]>
EMF dynamic -> reflectionhttp://www.aygfsteel.com/sunxiaobo/archive/2007/06/28/126872.htmlXiaobo SunXiaobo SunThu, 28 Jun 2007 09:25:00 GMThttp://www.aygfsteel.com/sunxiaobo/archive/2007/06/28/126872.htmlhttp://www.aygfsteel.com/sunxiaobo/comments/126872.htmlhttp://www.aygfsteel.com/sunxiaobo/archive/2007/06/28/126872.html#Feedback0http://www.aygfsteel.com/sunxiaobo/comments/commentRss/126872.htmlhttp://www.aygfsteel.com/sunxiaobo/services/trackbacks/126872.html The situation where an application simply wants to share data without the need for a generated type-safe API. The reflective EMF API is sometimes all one really needs.

EMF provides a dynamic implementation of the reflective API (that is, the EObject interface) which, although slower than the one provided by the generated classes, implements the exact same behavior. If you don't need a type-safe API, then the only advantage of generating Java classes, as opposed to simply using the dynamic implementation, is that they use less memory and provide faster access to the data. The down-side is that the generated classes have to be maintained as the model evolves, and they have to be deployed along with the application. This is the normal trade-off between dynamic and static implementations.

Dynamic:

================create dynamic models (types)=========================

EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
EcorePackage ecorePackage = EcorePackage.eINSTANCE;

EClass employeeClass = ecoreFactory.createEClass();
employeeClass.setName("Employee");

EAttribute employeeName = ecoreFactory.createEAttribute();
employeeName.setName("name");
employeeName.setEType(ecorePackage.getEString());
employeeClass.getEAttributes().add(employeeName);
EAttribute employeeManager = ecoreFactory.createEAttribute();
employeeManager.setName("manager");
employeeManager.setEType(ecorePackage.getEBoolean());
employeeClass.getEAttributes().add(employeeManager);

EClass departmentClass = ecoreFactory.createEClass();
departmentClass.setName("Department");

EAttribute departmentName = ecoreFactory.createEAttribute();
departmentName.setName("name");
departmentName.setEType(ecorePackage.getEString());
departmentClass.getEAttributes().add(departmentName);

EAttribute departmentNumber = ecoreFactory.createEAttribute();
departmentNumber.setName("number");
departmentNumber.setEType(ecorePackage.getEInt());
departmentClass.getEAttributes().add(departmentNumber);

EReference departmentEmployees = ecoreFactory.createEReference();
departmentEmployees.setName("employees");
departmentEmployees.setEType(employeeClass);
departmentEmployees.setUpperBound(
EStructuralFeature.UNBOUNDED_MULTIPLICITY);
departmentEmployees.setContainment(true);
departmentClass.getEReferences().add(departmentEmployees);

EPackage companyPackage = ecoreFactory.createEPackage();
companyPackage.setName("company");
companyPackage.setNsPrefix("company");
companyPackage.setNsURI("http:///com.example.company.ecore");
companyPackage.getEClassifiers().add(employeeClass);
companyPackage.getEClassifiers().add(departmentClass);

=====================create objects==============================
EFactory companyFactory = companyPackage.getEFactoryInstance();

EObject employee1 = companyFactory.create(employeeClass);
employee1.eSet(employeeName, "John");

EObject employee2 = companyFactory.create(employeeClass);
employee2.eSet(employeeName, "Katherine");
employee2.eSet(employeeManager, Boolean.TRUE);

EObject department = companyFactory.create(departmentClass);
department.eSet(departmentName, "ABC");
department.eSet(departmentNumber, new Integer(123));
((List)department.eGet(departmentEmployees)).add(employee1);
((List)department.eGet(departmentEmployees)).add(employee2);



Xiaobo Sun 2007-06-28 17:25 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 滁州市| 融水| 廊坊市| 澳门| 桓台县| 贵阳市| 平度市| 桐城市| 昌吉市| 郓城县| 榕江县| 吴桥县| 建宁县| 荥经县| 石林| 尚义县| 饶河县| 乐安县| 衡阳县| 阆中市| 都安| 凯里市| 孟连| 沙湾县| 玉树县| 博客| 从江县| 雷山县| 南城县| 泰宁县| 柳林县| 格尔木市| 南陵县| 武邑县| 绵竹市| 鞍山市| 钦州市| 扎赉特旗| 鹤峰县| 抚宁县| 黄冈市|