??xml version="1.0" encoding="utf-8" standalone="yes"?>久久精品毛片,欧美一区二区三区不卡,日韩精品一区二区三区中文不卡http://www.aygfsteel.com/steeven/category/6473.htmlzh-cnWed, 28 Feb 2007 01:07:53 GMTWed, 28 Feb 2007 01:07:53 GMT60db4oQ没有主键?http://www.aygfsteel.com/steeven/archive/2006/06/19/53836.htmlsteevensteevenMon, 19 Jun 2006 10:15:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/06/19/53836.htmlhttp://www.aygfsteel.com/steeven/comments/53836.htmlhttp://www.aygfsteel.com/steeven/archive/2006/06/19/53836.html#Feedback0http://www.aygfsteel.com/steeven/comments/commentRss/53836.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/53836.htmldb4o目前q没有unique index/primary key机制?5.4)

     public   static   void  main(String[] args)  {
        ObjectContainer db 
=  Db4o.openFile( " test.yap " );
        db.set(
new  User( " abc " , 234 ));
        db.set(
new  User( " abc " , 234 ));
        ObjectSet
< User >  list  =  db.query(User. class );
        System.out.println(list);
        db.close(); 
// halt without this line in 5.2
    }

上面的例子会(x)存储两个同样的User对象?br />仅有的ID是一个存储文件中的ID, l过片整理之后?x)发生变化,昄不适用?br />要实C个auto_increament的主键恐怕要自行实现。或者用已有的UUID实现?br />
可能db4o太年ȝ关系Q目前还没有支援q些功能。徏议用@Annotation来实现。ƈ且控制存储?br />@ID
@Unique
@Index
在EJB3里面已经有现成的定义可以参考?img src ="http://www.aygfsteel.com/steeven/aggbug/53836.html" width = "1" height = "1" />

steeven 2006-06-19 18:15 发表评论
]]>
CSDN Java沙龙上vzdhttp://www.aygfsteel.com/steeven/archive/2006/06/07/51224.htmlsteevensteevenWed, 07 Jun 2006 15:44:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/06/07/51224.htmlhttp://www.aygfsteel.com/steeven/comments/51224.htmlhttp://www.aygfsteel.com/steeven/archive/2006/06/07/51224.html#Feedback4http://www.aygfsteel.com/steeven/comments/commentRss/51224.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/51224.html
零星C一些笔讎ͼҎ(gu)q个ajax门外汉来说收莯是很大。主讲是ajaxcn.org的两位高手。robbin的Rubby讲因ؓ(f)旉关系要改期?br />
1. JS2的一些新Ҏ(gu):(x)class/extend/interface/package/import/块作用域/操作W函? 明年底会(x)有browser开始支持?br />//q脆把java直接搬到browser里面了?br />//以后是不是弄个标准接口允许加载不同语a的脚本引擎?大家׃用受js的鸟气了?br />2. 推荐的ajax框架QDojo/DWR/Prototype/GWT/YUI
//排名有先?br />3. 新技术:(x)
canvas dQ已有多数浏览器支持。据说有人用它实C3D游戏
SVG Zxml的矢量图。据说和canvas都支?dl图?br />E4X: xml的包? firefox支持
4. 技术和需求水涨船?//我们不会(x)׃?br />5. HiJax:
用传l方式快速开发。在传统|页基础上hack成ajax应用?br />对禁用js的浏览器表现Zl网c(din)?br />前期开发和后期攚w独立性很强?br />//后期要改造ؓ(f)完美的ajaxQ对server端要做些的改动来适应?br />6. 推荐用FireFox调试AJAX, 插g三剑客:(x)
firebug/web develope tool/temper data分别用来调试脚本Q观察页面domQ监听通信?br />//js调试的日子好q多了,但不要忘记M效率。。?br />
回来路上和一位tx聊v来ajax在企业中的地位好像不高,他对敏捷开发很有好感,对办公室环境的要求很有趣?br />本次zd的主要心得是Q自助餐很好吃,以后有活动还要去?:)

steeven 2006-06-07 23:44 发表评论
]]>
gwt和echo2的对?/title><link>http://www.aygfsteel.com/steeven/archive/2006/06/01/49502.html</link><dc:creator>steeven</dc:creator><author>steeven</author><pubDate>Thu, 01 Jun 2006 03:32:00 GMT</pubDate><guid>http://www.aygfsteel.com/steeven/archive/2006/06/01/49502.html</guid><wfw:comment>http://www.aygfsteel.com/steeven/comments/49502.html</wfw:comment><comments>http://www.aygfsteel.com/steeven/archive/2006/06/01/49502.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/steeven/comments/commentRss/49502.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/steeven/services/trackbacks/49502.html</trackback:ping><description><![CDATA[ <p>前面转脓(chung)Liebeck(echo的主要开发者,我的偶像)关于echo2和gwt的对?http://www.aygfsteel.com/steeven/archive/2006/06/01/49379.html<br /><br />今天仔细做了一些笔讎ͼq且加入了一些自qxQ供选型者参考:(x)<br /><br />l合Ҏ(gu)Q?br />1. 两个都是非传l的b/s框架Q都是用AJAX来构造动态网站。编E过E都和SWT/Swing差不多?br />2. 区别在于一个运行于客户端,一个运行于服务?/p> <div>3. gwt把代码编译ؓ(f)html+js, 目前只支持java1.4规范。echo没这限制?/div> <div>4. gwt可以q行于Q何web server, echo则需要传l的servlet容器。(意义不大Q现在哪有静态网站啊Q后C互肯定还是需要的Q?/div> <div>5. echo2的客L(fng)引擎通过ajax提交用户动作Q对用户界面增量更新?/div> <div> </div> <div>性能Q?/div> <div>1. gwt的页面logic都在览器上Q所以很快。但是如果需要和中间层交互,׃(x)到同样的网l问题?/div> <div>2. echo2的代码跑在server上,所以所有的交互都需要反馈给server。echo2在设计上量减少q种交互Q比如客户对文本的修攚w是gq发送到服务?而服务器只发送页面的变化部分到浏览器?/div> <div>3. gwt应用被编译成一个页面,虽然应用的复杂化Q这个编译结果也随之变得可怕。。?个h认ؓ(f)随着~译器的发展Q不同的面可以做到l(f)azy load)</div> <div>4. echo的js模块是lazy加蝲到浏览器的,界面上呈现哪些控件才d载ƈ且缓存对应的js模块。发送到客户端的不是逻辑代码Q只有用L(fng)态(个h认ؓ(f)echo2现在q于lazyQ导致初始化阶段多次讉Kserver加蝲一些基本的js模块Q应该揉合到一赗另外,因ؓ(f)echo逻辑代码在服务器上,相对来说可以防止盗版Q?/div> <div> </div> <div>中间层和数据讉KQ?/div> <div>1. 如果要访问数据,gwtq是要回Cl的模式Q通过rpc讉Kservlet。gwt提供把远E服务透明的包装v来,中间传送pojo. 管包装了,中间的安全和和校验还是必要开发者考虑?/div> <div>2. echo支持SOAQ但是不必须。大多数情况下安全不是问题,因ؓ(f)数据和逻辑都不?x)暴露到览器上?以前lecho提过Q浏览器用户很可能去模拟一个被disabled按钮提交Q这U问题现在无需考虑Q?/div> <div> </div> <div>q行环境Q?/div> <div>1. gwtq行在浏览器上,q所有的javac都能编译成js. gwt现在只支持java.lang/java.util下面的一个子?版本 1.0.21)Q?7 classes, 11 interfaces, and 18 exception(q让人想起了j2me开?. 一些现有的cd别想了?/div> <div> </div> <div>调试Q?/div> <div>1. gwt调试需要一套和q行时完全不同的环境QHOST模式Q代码作为真正的java在运行?个h认ؓ(f)q里因ؓ(f)是纯java调试Q比echo的web调试要稍微方便一些。做单元试也更方便些,但不是对最lbrowser的测试)(j)</div> <div>2. echo调试是传统的servlet调试?/div> <div> </div> <div>授权Q?/div> <div>1. gwt的api是开源的Q编译器和host模式览器不公开。整体来_(d)(x)free. Q个为,如果要扩充gwt可能?x)遇到麻烦(ch)?j)</div> <div>2. echo2开源,mozilla public license. free(个h认ؓ(f)Qechostudio也free好了。nextapp毕竟要生存)(j)</div> <div> </div> <div>应用Q?/div> <div>1. gwt可以嵌入传统的静态html, 也能作ؓ(f)一个完整应用。做大应用要考虑~译后的重量、本地化、库支持{问题(关于18n, 可以在gwt支持论坛上搜索i18n,g已经有方案)(j)</div> <div>2. echo2成熟得可以适用各种应用Q但是不能作为静态页面的一部分使用。(有点吹牛Q在大访问量下,服务器的压力肯定不会(x))(j)</div> <div> </div> <div> </div> <div> </div> <div> <div>个hl论Q?br />1. 开发方式都很优UQ用Ujava开发b/s<br />2. gwt可用于大型网站,把压力{嫁给客户端?br />3. echo可用于快速开发复杂的企业应用Q把压力丢给服务?企业里面最清闲的就是前台和服务?<br /><br />两个产品都很优秀QGWT?006q的IT飓风QL?qing)后面几q。M$的日子要难过? GOOGLE的确是个令h头痛的对手?br /><div><br />然而,q有比gwt/echo2更美好的未来吗?</div><div>有!把他们的输出变成flashQ用java开发flash应用。去q探索过一D|_(d)原型已经出来Q因为flash开发调试太ugly, 没有l箋下去?br />另外Q微软的WPF(AVALON)相当值得x?br /></div></div> </div> <img src ="http://www.aygfsteel.com/steeven/aggbug/49502.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/steeven/" target="_blank">steeven</a> 2006-06-01 11:32 <a href="http://www.aygfsteel.com/steeven/archive/2006/06/01/49502.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转脓(chung)QComparing the Google Web Toolkit to Echo2 http://www.aygfsteel.com/steeven/archive/2006/06/01/49379.htmlsteevensteevenWed, 31 May 2006 16:55:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/06/01/49379.htmlhttp://www.aygfsteel.com/steeven/comments/49379.htmlhttp://www.aygfsteel.com/steeven/archive/2006/06/01/49379.html#Feedback0http://www.aygfsteel.com/steeven/comments/commentRss/49379.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/49379.html Google Web Toolkit 虽然q是beta版本Q和google的其他品一P刚出生就注定不凡Q也许将影响后面几年的b/s开发?br />
gwt利用了java开发的一切成熟条Ӟ包括Unit test, refactor, IDE(eclipse...)Q传l的b/s framework必将受到重创Q横扫过后,JSF/ECHO{Server side framework可能q存。如果哪天google加上serverside支持Q从包命名上看是留有余地的)(j)。。。虽然gwt目前q是样一个,但是背后站的是重量的googleQ强大的资源和数不完的银子。。。?br />
看到q玩意首先想到的是echo2, 客户端技术都是ajax, ~码都是java. 不同的是gwt发行时编译成HTML+JSQEcho2则是完全的服务器端生?更新。gwt跟server端交互依靠类gws的service把前后台完全区分开?br />
在echo的论坛里面已l有人在讨论q玩意了Qƈ且八卦了一下gwt的前w似乎是Morfik的一部分Q待证实Q?br />从原理上Qecho的开发者作ZҎ(gu)Q这个网站似乎被锁Q这里{贴一?


Q=Q=Q=Q=Q=Q=Q=Q=Q=Q=Q=Q=Q=Q=Q=Q?br />http://echotwo.blogspot.com/ 作者tod liebeck

Comparing the Google Web Toolkit to Echo2
The Google Web Toolkit (GWT) is being compared to Echo2 quite frequently. Some of these comparisons have been fairly accurate, while others contain bits of misinformation. This article, written by the lead developer of Echo2, discusses the similarities and differences between these two frameworks.

Overview

The Google Web Toolkit and Echo2 definitely make for an interesting comparison. Both of these frameworks take a non-traditional approach toward web application development, even considering the latest crop of "AJAX-based frameworks" available today.

The most obvious similarity between GWT and Echo2 is that they both enable the developer to create dynamic, AJAX-driven web user interfaces using only Java. In both projects, UIs are developed in a fashion similar to SWT or Swing: by assembling hierarchies of components and registering event handlers. Neither project requires the developer to work with HTML, JavaScript, or XML.

The most obvious difference between GWT and Echo2 is that all of your GWT code is executed on the client, whereas your Echo2 code is executed on the server. There are advantages and disadvantages to both of these approaches, which will be highlighted throughout the article.

GWT's defining attribute is the Java-to-JavaScript compiler. This compiler allows you to develop the web interface to your application in Java, then compile it to JavaScript. GWT limits the developer to a subset of the Java 1.4 libraries. GWT applications can be served by any web server, such as Apache, without the need for server-side processing.

Echo2 applications are compiled to Java byte code and run on a Java server. Their Java code is executed by Echo2's "Web Application Container" layer, which sits atop a Java Servlet. On the web browser, the Echo2 "Client Engine" communicates user input to the Web Application Container via AJAX requests, with the server responding with directives to perform incremental updates to the state of the client web browser.

User Interface Performance

With GWT, all of your user interface code exists on the client browser. In operations that do not require server communication--that is, that do not require retrieving data from the middle tier--this configuration results in response times that are not dependent on the server. When data must be retrieved from the application's middle tier or business logic layer, the response time is subject to the same criteria as any other AJAX application, i.e., network latency, bandwidth, and server performance.

Echo2 application code is run on the server, so for each user interaction that requires a call to the middle tier or immediate execution of the application's Java code, an AJAX connection is made to the server. Echo2 components are designed to minimize the client/server communication as much as is possible, limiting it to times when the server must be notified immediately of events. For example, simple events such as user input to a TextField component will not result in server contact. The server's response is the minimum set of instructions to incrementally update the client to reflect the new screen state.

GWT applications are served to the client as a single HTML/JavaScript file, containing the entirety of the user interface. The size of this file will be proportional to the size of your user interface code and the toolkit libraries used by your application.

Echo2 JavaScript modules are lazy-loaded to the client, and thereafter cached. A module will be retrieved when a component first appears on-screen that requires it. Application code is never sent to the client, only the state of the user interface.

Middle Tier / Data Retrieval

To access business data or perform a business process, a GWT user interface makes a remote procedure call (RPC) from the browser to a Servlet. GWT provides a mechanism to make the RPC invocation transparent to the developer, allowing the developer to build the application with "Plain Old Java Objects" (POJOs). However, any application that provides an RPC capability is a distributed application -- even when the RPC is accomplished transparently to the developer. Distributed applications in businesses and enterprises usually have security considerations and the remote objects serving the GWT clients must be designed with a focus on security to deflect attacks from imitated or hostile client applications.

Echo2 applications support, but do not require, the use of distributed application logic or a Service Oriented Architecture (SOA). Alternatively, Echo2 applications can be built to run entirely within a single JVM instance, backed by a POJO-based middle tier. This allows Echo2 developers to build applications without the security concerns of distributed application logic -- and leverage the many strong frameworks built around POJO development such as the Spring Framework and Hibernate. Echo2 accomplishes this by keeping the state of a user's web interface on the server so that no remote objects need to be exposed.

Run-time Environment

GWT has some limitations due to the fact that applications are run on the client browser. First, GWT applications are limited to using a subset of the core Java class libraries, consisting of 27 classes, 11 interfaces, and 18 exception types found in the java.util and java.lang packages (as of GWT 1.0.21). This limitation prevents GWT applications from linking to most existing Java libraries. Additionally, all Java code must be compliant with the Java 1.4 specification; 1.5 is not supported. Localization-related portions of the Java API are not provided.

Debugging

GWT provides an alternate deployment environment for applications to facilitate debugging. The environment, called "Hosted Mode", allows a GWT application to be run as Java byte code in a local JVM, to which an IDE's debugger can be connected. In this mode, the application's user interface is displayed in a special web browser (a Mozilla/Firefox derivative).

Echo2 applications may be debugged in the conventional manner, by connecting an IDE's debugger to a JVM running a Servlet container.

Licensing

The primary component of GWT, the Java-to-JavaScript cross-compiler, is proprietary, binary-only software. The Java API libraries are open source software, distributed under the Apache License. The API libraries have essentially no value without the proprietary compiler. The (non-critical) hosted-mode browser is also under the proprietary license. GWT is provided free of charge.

Echo2 is open source software, licensed under the Mozilla Public License, and provided free of charge.

Applicability

GWT can be used as a means of creating AJAX components to embed in traditional web applications (or even in static web pages) as well as for creating complete application user interfaces. There are some issues to using it for the creation of large applications, where downloading an entire application to a client web browser in one shot would not be practical. The lack of localization and full Java API support also presents a problem for larger solutions.

Echo2 is practical for creating web applications of any size. It is however not intended to scale downward to function as a platform for simply creating AJAX components in traditional web frameworks (or static web sites).

More Information

Google Web Toolkit:
Home Page, Example Applications, Getting Started Guide, Developer Guide

Echo2:
Home Page, Example Applications, Tutorial
posted by Tod Liebeck at 5:13 AM | 0 comments  

======================================
毕竟gwtq是baby, 以后怎么发展q难_(d)现在下结论太早。这两天试用一下,有空从细节上Ҏ(gu)一下?br />



steeven 2006-06-01 00:55 发表评论
]]>
EMF之ResourceSet探烦(ch)(4)http://www.aygfsteel.com/steeven/archive/2006/05/26/48271.htmlsteevensteevenFri, 26 May 2006 02:22:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/05/26/48271.htmlhttp://www.aygfsteel.com/steeven/comments/48271.htmlhttp://www.aygfsteel.com/steeven/archive/2006/05/26/48271.html#Feedback1http://www.aygfsteel.com/steeven/comments/commentRss/48271.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/48271.html试一下getResource(URI,boolean):

        System.out.println(EcorePackage.eINSTANCE.eResource());  // 1
        System.out.println(XMLTypePackage.eINSTANCE.eResource());  // 2

        ResourceSet rs 
=   new  ResourceSetImpl();
        rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
                Resource.Factory.Registry.DEFAULT_EXTENSION,
                
new  XMIResourceFactoryImpl());
        String uri 
=   " http://abc.eg/asdf " ;
//         System.out.println(rs.createResource(URI.createURI(uri)));  //  如果创徏q(f)时的Q得到这?br /> //         System.out.println(rs.createResource(URI.createURI(uri)));  //  如果创徏q多个(f)时的Q返回第一个,q个忽略
        rs.getPackageRegistry().put(uri, EcorePackage.eINSTANCE);  // 得到l果?,如果上面取消注释Q本地创建的优先

        System.out.println(rs.getResource(URI.createURI(uri), 
false ));  // ?


createResource每次创徏新的QgetResource则是唯一实例的?/p>

每个生成的XxxPackage.eINSTANCE?x)自行创qResource。如果在插g中修改了EcorePackge.eInstance.eResource()Q会(x)不会(x)天下大ؕ呢?

==================
eclispe~辑器右边的Mark Occurrence很方便,但是安?sh)脑上的q个黄色标记很不清楚。前几天调整了老半天,修改配色Ҏ(gu)Q换昄器驱动,调整昄器对比度、亮度都收效不大。昨天偶然把XP的桌面风格换回传l模式,搞定了?/p>

ecore.ecoreq个问题很有意思,以前看过schema.xsdQ就是自己定义自己。据说JDK也是用java开发编译出来的。。?br />先有鸡还是现有蛋呢?



steeven 2006-05-26 10:22 发表评论
]]>
EMF之ResourceSet探烦(ch)(3) http://www.aygfsteel.com/steeven/archive/2006/05/26/48249.htmlsteevensteevenThu, 25 May 2006 17:23:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/05/26/48249.htmlhttp://www.aygfsteel.com/steeven/comments/48249.htmlhttp://www.aygfsteel.com/steeven/archive/2006/05/26/48249.html#Feedback0http://www.aygfsteel.com/steeven/comments/commentRss/48249.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/48249.html在RS中同一URI可以createResource多个ResourceQList方式存放。还存在另外一UMap存放方式, getResource(URI,boolean loadOnDemand)是通过q种方式存取Q如果不存在的话创徏。这两个Ҏ(gu)看v来有些冲H。似乎用于不同场合?br />
再来看看怎样通过URL存取EObject:
RS整个相当于一个DataBase, Resource相当于表Q存攄是EObject, 每个EObject可以看成对象或者XML?br />表用URI来区分,URI中的Segment用来定位EObject。URI的例子参见探?1)
getEObject(URL, boolean loadOnDemand)很简单,getResource扑ֈ对应的Resource,在里面根据Segment查找Q就是那?a href="mailto:#///@xxx.n">#///@xxx.n格式的东西,注意Q还有ID方式?br />
getPackageRegistry()用来q回RS的URL->Package注册表,它也是个本地的注册表Q代理了全局的EPackage.Registry.INSTANCE。这个注册表用于取得EPackageQ类型信息)(j)和EFactoryQ创建实例)(j)


Resource׃说了Q主要load,save, 一些具体子c,比如XmlResourceImpl可以直接使用Q指定Encoding之类?br />
看看ResourceSet对EMF了解了很多~



steeven 2006-05-26 01:23 发表评论
]]>
EMF之ResourceSet探烦(ch)(2) http://www.aygfsteel.com/steeven/archive/2006/05/26/48242.htmlsteevensteevenThu, 25 May 2006 16:02:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/05/26/48242.htmlhttp://www.aygfsteel.com/steeven/comments/48242.htmlhttp://www.aygfsteel.com/steeven/archive/2006/05/26/48242.html#Feedback0http://www.aygfsteel.com/steeven/comments/commentRss/48242.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/48242.html1. getResourceFactoryRegistry()
  public Resource.Factory.Registry getResourceFactoryRegistry()
  
{
    
if (resourceFactoryRegistry == null)
    
{//可以自行Set一个注册表实现Q没有的话用pȝ~省注册?/span>
      resourceFactoryRegistry =
        
new ResourceFactoryRegistryImpl()
        
{
          
public Resource.Factory delegatedGetFactory(URI uri)
          
{
            
return Resource.Factory.Registry.INSTANCE.getFactory(uri);
          }

        }
//代理pȝ注册表,注意q个应该是正宗的?/span>
    }

    
return resourceFactoryRegistry;
  }

所以自己new 出来的ResourceSet可以向注册表中Q意添加工厂实现?br />2. 调用注册表的getFactory(URI), 实现如下Q?br />
 public Resource.Factory getFactory(URI uri)
  
{
    String protocol 
= uri.scheme();
    Object resourceFactory 
=  protocolToFactoryMap.get(protocol); //先根据protocol查找
    if (resourceFactory == null)
    
{
      String extension 
= uri.fileExtension();
      resourceFactory 
= extensionToFactoryMap.get(extension); //找不到再Ҏ(gu)扩展名查?/span>
      if (resourceFactory == null)
      
{
        resourceFactory 
= extensionToFactoryMap.get("*"); //试查找~省扩展
        if (resourceFactory == null)
        
{
          resourceFactory 
= delegatedGetFactory(uri); //自行实现可以扩展此方法解析?/span>
        }

      }

    }


    
//Descriptor可以用于~程使用
    return 
      resourceFactory 
instanceof Resource.Factory.Descriptor ?
        ((Resource.Factory.Descriptor)resourceFactory).createFactory() :
        (Resource.Factory)resourceFactory;
  }

查找一个工厂居然这么复杂!正因么复杂,才能支持platform/file/fttp{众多千奇百怪的URI
不同cd的工厂加工出不同cd的Resource, 才会(x)输出为XSD/XML/XMI/....

如果直接操作pȝ注册表要心。EMF中定义了几个扩展点,可以实现cM目的?br />已知的ResourceFactory实现有:(x)XSD/ECore/EMOF/XML/XMIQXSD的输出方法的介绍可以参考Eclipse Development using the Graphical Editing Framework and the Eclipse Modeling Framework?sh)子书?br />




steeven 2006-05-26 00:02 发表评论
]]>
EMF之ResourceSet探烦(ch)(1)http://www.aygfsteel.com/steeven/archive/2006/05/25/48229.htmlsteevensteevenThu, 25 May 2006 14:40:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/05/25/48229.htmlhttp://www.aygfsteel.com/steeven/comments/48229.htmlhttp://www.aygfsteel.com/steeven/archive/2006/05/25/48229.html#Feedback0http://www.aygfsteel.com/steeven/comments/commentRss/48229.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/48229.html先看看现象,以EMF例子Library.ecoreZ, 试代码如下Q?br />
public class Test {
    
public static void main(String[] args) throws IOException {
        ResourceSet rs 
= new ResourceSetImpl();
        rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
                Resource.Factory.Registry.DEFAULT_EXTENSION,
                
new XMIResourceFactoryImpl()); //outside eclipse
        Resource resource 
= rs.createResource(URI
                .createURI(EXTLibraryPackage.eNS_URI));
        
//step a
        Library library = EXTLibraryFactory.eINSTANCE.createLibrary();
        library.setName(
"some lib");
        resource.getContents().add(library);
        
//step b
//        Book book = EXTLibraryFactory.eINSTANCE.createBook();
//        book.setTitle("some book");
//        Employee employee = EXTLibraryFactory.eINSTANCE.createEmployee();
//        employee.setFirstName("some one");
        
//step c
//        library.getBooks().add(book);
//        library.getEmployees().add(employee);
        
//step d
//        resource.getContents().add(book);
    
//        System.out.println(EcoreUtil.getURI(employee));
//        System.out.println(EcoreUtil.getURI(book));
        resource.save(System.out, null);
    }

}


步骤 输出
a ----------------
<?xml version="1.0" encoding="ASCII"?>
<extlib:Library xmi:version="2.0" xmlns:xmi="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0" name="some lib"/>
#//
#//
<?xml version="1.0" encoding="ASCII"?>
<extlib:Library xmi:version="2.0" xmlns:xmi="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0" name="some lib"/>
c http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0#//@employees.0
#//
<?xml version="1.0" encoding="ASCII"?>
<extlib:Library xmi:version="2.0" xmlns:xmi="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0" name="some lib">
  <employees firstName="some one"/>
</extlib:Library>
d http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0#/0/@employees.0
http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0#/1
<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0">
  <extlib:Library name="some lib">
    <employees firstName="some one"/>
  </extlib:Library>
  <extlib:Book title="some book"/>
</xmi:XMI>

可以看到Q没有加入lib的时候,employee/book实例的URI都是#//, employee加入以后有了#//@employees.0, book依旧?br />在book加入resource以后有了#/1的URI, employee/book在containment定义分别是true,falseQ所以employee加入lib以后随lib加入resourceQ实例容器)(j)。book则要单独加入?br />
另外一个有的现象是Resource可以容纳多个实例Q在step d可以看到输出的根节点由lib变成匿名容器?br />
如果lib不加入resource又如何呢Q?br />
步骤 输出
a ----------------
#//
#//
c #///@employees.0
#//
d ----------------
没加入resource之前QURI是未知的Q知道的只是相对父节点的相对segment.



steeven 2006-05-25 22:40 发表评论
]]>
EMF验证扩展Q自定义验证规则http://www.aygfsteel.com/steeven/archive/2006/05/19/47107.htmlsteevensteevenFri, 19 May 2006 11:03:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/05/19/47107.htmlhttp://www.aygfsteel.com/steeven/comments/47107.htmlhttp://www.aygfsteel.com/steeven/archive/2006/05/19/47107.html#Feedback0http://www.aygfsteel.com/steeven/comments/commentRss/47107.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/47107.html因ؓ(f)比较?yu),所以这里ȝ一下?br />
验证的定义有两种方式Q?br />1. 生成验证Ҏ(gu)框架Q代码自己实现。参?a >EMF Overview:
  dAnnotatio, Source=http://www.eclipse.org/emf/2002/Ecore, 然后dDetailsEntryQkey=constraints, Value=validateXxx
  EDataType,EClass支持Q属性不支持?br />2. 定义cMSchema的FacetQ自动生成对应的验证代码Q用于验证简单数据类型:(x)
  dAnnotatio, Source=http:///org/eclipse/emf/ecore/util/ExtendedMetaData, 然后dDetailsEntryQkey=maxLength, Value=2
  支持的facet参见ExtendedMetaData?br />  仅EDataType支持Q属性不支持?br />
CZEcore:

新生成SqlmodelValidator.java, 代码如下Q?br />
可见Table_ValidateC, MyLabel_ValidateA,MyLabel_validateB都自动生成,修改里面的if(false)为需要的业务判断逻辑?br />validateMyLabel_MaxLength()Ҏ(gu)是根据ExtendedMetaData自动生成的,无需修改?br />
ȝQ?br />1. EMF验证利用了Annotation扩展Q这U机制很灉|Q但是给用户带来不便?br />2. Attribute属性不能生成验证规则(eclipse3.2rc3Q,可以定义为单独的EDataTypeQ然后引用之?br />3. Constraints+Facet+本n的结构验证可以构成很强的验证规则Qƈ且属于Model层,数据本n卛_验证自n?br />4. EObjectValidator.DynamicEDataTypeValidatorg可用于动态验证,有知道用法的朋友l讲解一下~



steeven 2006-05-19 19:03 发表评论
]]>
~程使用SDO[EMF兄弟]http://www.aygfsteel.com/steeven/archive/2006/05/15/46266.htmlsteevensteevenMon, 15 May 2006 11:00:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/05/15/46266.htmlhttp://www.aygfsteel.com/steeven/comments/46266.htmlhttp://www.aygfsteel.com/steeven/archive/2006/05/15/46266.html#Feedback0http://www.aygfsteel.com/steeven/comments/commentRss/46266.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/46266.html主要特点Q(个h理解Q?br />可验?br />强类?br />可取出完整数据和差异?br />
生成SDO代码和EMF大同异Q主要是在my.genmodel的第一个节点的右键菜单中选择QSet SDO defaults.

体验Q?br />1. 生成Editor后,执行生成的Editor Plugin
2. 新徏Example EMF Model Creation Wizards->Data Graph Model
3. 在Changes节点上Start Loggin, 然后~辑数据卛_看到自动生成的差异?br />
|上手工操作SDO的示例代码比较少Q这里简单demo如下Q?br />
import java.util.Iterator;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.sdo.EDataGraph;
import org.eclipse.emf.ecore.sdo.SDOFactory;
import org.steeven.family.FamilyFactory;
import org.steeven.family.个h;
import org.steeven.family.家庭;

import commonj.sdo.ChangeSummary;
import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;

public class Server {

    
public static void main(String[] args) {
        
// client side
        EDataGraph graph = loadGraph();
        graph.getChangeSummary().beginLogging(); // important!
        家庭 family 
= (家庭) graph.getRootObject();
        family.setTitle(
"my family");
        个h baby 
= FamilyFactory.INSTANCE.create个h();
        baby.set姓名(
"sophie");
        family.get兔崽?).add(baby);
        graph.getChangeSummary().endLogging();
        saveGraph(graph);
        update(graph);
    }


    
//server side
    public static EDataGraph loadGraph() {
        家庭 family 
= FamilyFactory.INSTANCE.create家庭(); // or load from
        
// database
        EDataGraph graph = SDOFactory.eINSTANCE.createEDataGraph();
        graph.setERootObject((EObject) family);
        
return graph;
    }


    
//server side full save
    public static void saveGraph(EDataGraph graph) {
        System.out.println(graph.getRootObject());
    }


    
//server side update changed objects
    public static void update(DataGraph dataGraph) {
        ChangeSummary changeSummary 
= dataGraph.getChangeSummary();
        
for (Iterator it = changeSummary.getChangedDataObjects().iterator(); it
                .hasNext();) 
{
            DataObject changedObject 
= (DataObject) it.next();
            System.out.println(
"Update for " + changedObject);
            
for (Iterator settingIt = changeSummary.getOldValues(changedObject)
                    .iterator(); settingIt.hasNext();) 
{
                ChangeSummary.Setting changeSetting 
= (ChangeSummary.Setting) settingIt
                        .next();
                System.out.println(
" (changed "
                        
+ changeSetting.getProperty().getName() + " from \""
                        + changeSetting.getValue() + "\" to \""
                        
+ changedObject.get(changeSetting.getProperty())
                        
+ "\")");
            }

        }

    }

}

输出Q?br />
org.steeven.family.impl.家庭Impl@9664a1 (title: my family)
Update for org.steeven.family.impl.个hImpl@1729854 (姓名: sophie, 性别: ?
Update for org.steeven.family.impl.家庭Impl@9664a1 (title: my family)
 (changed title from "null" to "my family")
 (changed 兔崽子 from "[]" to "[org.steeven.family.impl.个hImpl@1729854 (姓名: sophie, 性别: ?]")

SDO生成的代码似乎更加纯净一点,没有很多的eXxxx()Ҏ(gu)Q有需要的也可以取刎ͼ(j)?br />据说log的开销比较大,不徏议对大量数据使用?img src ="http://www.aygfsteel.com/steeven/aggbug/46266.html" width = "1" height = "1" />

steeven 2006-05-15 19:00 发表评论
]]>
EMF~程使用http://www.aygfsteel.com/steeven/archive/2006/05/14/46129.htmlsteevensteevenSun, 14 May 2006 13:27:00 GMThttp://www.aygfsteel.com/steeven/archive/2006/05/14/46129.htmlhttp://www.aygfsteel.com/steeven/comments/46129.htmlhttp://www.aygfsteel.com/steeven/archive/2006/05/14/46129.html#Feedback3http://www.aygfsteel.com/steeven/comments/commentRss/46129.htmlhttp://www.aygfsteel.com/steeven/services/trackbacks/46129.html看到eclipse3.2里面的GMF, 觉得比较有趣,底层q是用到了EMF. ׃两天旉仔细研究了以下EMF,的确是个好东?

EMFҎ(gu)ecore建模(可以和schema的xsd怺转换)生成强类型的EMF代码. q个强类型更强的地方是可以取得meta信息,从而可以用于校验和界面辅助信息的生?cM于动态bean,属性也可以Ҏ(gu)名称动态取?

以前考虑q用xsd描述界面, 但是数据载体只能是xml, 即利用apache的schema~译工具生成强类型的c?后台代码也是xml. 不利于持久化. emf在代码生成引擎比较智?可以标记出用户代码和自动生成代码.不会(x)有生成覆盖问?

q里做个单示?
1. Ecore:
可以新徏Ecore, 建立好以后用GMF可视化编?Eclipse3.2RC2)

2. 生成Model:
点击my.ecore文g,菜单:File->New->Other->Eclipse Modeling Framework->EMF Model
3. 打开生成的my.genmodel, 选择?wi)顶点?Generate Model Code
生成的代码里面会(x)有一个编译错? 是中文编E的问题, 中文没有大小?先天不?,l果性别q个成员变量和性别cdh,出错.在错误代码前面加上包全名卛_.
4. 利用生成的代码构Z个家?输出xmlq且校验?

import  java.io.IOException;
import  java.util.Iterator;

import  org.eclipse.emf.common.util.Diagnostic;
import  org.eclipse.emf.common.util.URI;
import  org.eclipse.emf.ecore.EObject;
import  org.eclipse.emf.ecore.resource.Resource;
import  org.eclipse.emf.ecore.util.Diagnostician;
import  org.eclipse.emf.ecore.xmi.XMLResource;
import  org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
import  org.steeven.family.FamilyFactory;
import  org.steeven.family.人物;
import  org.steeven.family.家庭;
import  org.steeven.family.性别;

public   class  TestMy  {

    
public   static   void  main(String[] args)  throws  IOException  {
        testFamily();
    }


    
private   static   void  testFamily()  throws  IOException  {
        家庭 family 
=  FamilyFactory.eINSTANCE.create家庭();
        family.setTitle(
" steeven?/span> " );
        family.set老公(FamilyFactory.eINSTANCE.create人物());
        family.get老公().set姓名(
" steeven " );
        family.set老婆(FamilyFactory.eINSTANCE.create人物());
        family.get老婆().set姓名(
" stella " );
        family.get老婆().set性别(性别.女_LITERAL);
        人物 sophie 
=  FamilyFactory.eINSTANCE.create人物();
        sophie.set姓名(
" sophie " );
        sophie.set性别(性别.女_LITERAL);
        family.get兔崽?).add(sophie);
        dump(family);
        validate(family);
    }


    
private   static   void  validate(EObject family)  {
        Diagnostic diagnostic 
=  Diagnostician.INSTANCE.validate(family);
        System.out.println(diagnostic);
        
for  (Iterator it  =  diagnostic.getChildren().iterator(); it.hasNext();)  {
            Diagnostic diag 
=  (Diagnostic) it.next();
            System.out.println(diag.getMessage());
        }

    }


    
private   static  Resource dump(EObject objs)  throws  IOException  {
        
//  ResourceSet rs = new ResourceSetImpl();
        
//  rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
        
//  Resource.Factory.Registry.DEFAULT_EXTENSION,
        
//  new XMIResourceFactoryImpl());
        
//  Resource resource = rs.createResource(URI
        
//  .createFileURI("c:\\temp\\test.xml"));
        XMLResource resource  =   new  XMLResourceImpl(URI
                .createFileURI(
" c:\\temp\\test.xml " ));
        resource.setEncoding(
" GBK " );
        
for  (EObject obj : objs)
            resource.getContents().add(obj); 
//  目前版本不加入resource验证?x)报singling异常
        resource.save(System.out,  null );
        
return  resource;
    }

}

q行l果如下:

<? xml version="1.0" encoding="GBK" ?>
< family: 家庭 xmlns:family ="http://org.steeven/family"  title ="steeven?  老公 ="/"  老婆 ="/"  兔崽?/span> ="/" />
Diagnostic ERROR 
The feature '老公' of 'org.steeven.family.impl.家庭Impl@f6a746{file:/c:/temp/test.xml#/}' contains a dangling reference 'org.steeven.family.impl.人物Impl@6eb38a{#//}'
The feature '老婆' of 'org.steeven.family.impl.家庭Impl@f6a746{file:/c:/temp/test.xml#/}' contains a dangling reference 'org.steeven.family.impl.人物Impl@1cd2e5f{#//}'
The feature '兔崽? of 'org.steeven.family.impl.家庭Impl@f6a746{file:/c:/temp/test.xml#/}' contains a dangling reference 'org.steeven.family.impl.人物Impl@19f953d{#//}'

可见输出的xml中没有包含h物的具体信息. 修改my.ecore中老公/老婆/兔崽子属性的containment属性ؓ(f)true,重新生成代码后运行结果如?
<?xml version="1.0" encoding="GBK"?>
<family:家庭 xmlns:family="http://org.steeven/family" title="steeven?>
  
<老公 姓名="steeven"/>
  
<老婆 性别="? 姓名="stella"/>
  
<兔崽子 性别="? 姓名="sophie"/>
</family:家庭>
Diagnostic OK


====================
EMF单独q行成功~

q里ECOREg不支持嵌套定?不像schema那样一个complexType声明里面可以定义的很复杂, 也不像Java的内部类. g被作了简? 更像关系数据库表之间的关p?

待求证问?
1. EMF的校验信息是否支持国际化.
2. EMF数据的能否更方便的保存到数据.

EMF的灵zd强大已经验证q? 用于C/Sq是B/S应该都不是问?


steeven 2006-05-14 21:27 发表评论
]]>
վ֩ģ壺 | | | ݶ| ͭ| ϲ| ľ| Ϫ| | ɽ| | | ɽ| | ˫Ѽɽ| | | | | Ƕ| | | ï| | ɽ| | | ͡| ݳ| | | | | μ| ׶| γ| ͨ| ˮ| | ½| ɽ|