Cayenne, open source orm Feast of another delicacy, 2nd part

Source: Internet
Author: User
Tags java web

Using Cayenne Remote Object persistence (Cayenne ROP)

ROP (remote object persistence) remote object persistence is a unique feature of Cayenne, which provides a lightweight remote object persistence and querying capability by using WEB service technology. By using this feature, the client program can access a remote database using a Cayenne API similar to accessing the local database (the remote database can be any database that can be accessed over a network connection). Figure 1 is a schematic diagram of the Cayenne Remote Object persistence. When a client program performs an access operation on a remote data object, the Cayenne Connection object in the client program automatically invokes the Cayenne Web Service (CWS) running on the remote server, and CWS uses the Cayenne DataContext performs the appropriate database operations and returns the results of the operation to the client program through a Web Service.

Figure 1. The principle structure diagram of Cayenne Remote Object persistence

The concept and configuration of the Cayenne Web Service (CWS)

CWS is a core component of Cayenne Remote Object Persistence, a regular Java Web application that uses Hessian as the Web Service engine. The Java classes used by Cayenne mapping files and persisted objects are included in this application. When you deploy this program to a Java EE application server that supports servlet functionality, you can support the use of remote object persistence through the Web Service provided by Hessian.

The CWS configuration is simple, just place the Java class of the Cayenne mapping file and the persisted object on the Java classPath of the CWS Web program, and configure a web.xml in Hessianservlet. Listing 1 is a typical file structure for a CWS Web application.

Listing 1. CWS WEB Application Typical file structure

CayenneCWSServer/
  WEB-INF/
    web.xml
    lib/
     cayenne.jar
     hessian-3.0.13.jar
     databaseb-driver.jar
     otherJars......
    classes/
     cayenne.xml
     DataMap.map.xml
     DataNode.driver.xml
     // 服务器端持久化对象
     com/cn/ibm/PersistentObject.class
     com/cn/ibm/auto/_PersistentObject.class
     ......
     // 客户端远程访问持久化对象
     com/cn/ibm/client/PersistentObject.class
     com/cn/ibm/client/auto/_PersistentObject.class
     ...... 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.