【正文】
r affords the application a seamless view of the entire object model often by extending the virtual memory system. Canonicalization and language independence Objects of the same type in a language should be stored in persistent storage with the same layout, regardless of the order in which their interfaces appear. The processes of transforming an object layout to this mon format are collectively known as canonicalization of object representation. In piled languages with static typing (not Java) objects written in the same language, but piled under different systems, should be identically represented in persistent storage. An extension of canonicalization addresses languageindependent object representation. If objects can be represented in a languageindependent fashion, it will be possible for different representations of the same object to share the same persistent storage. One mechanism to acplish this task is to introduce an additional level of indirection through an interface definition language (IDL). Object database interfaces can be made through the IDL and the corresponding data structures. The downside of IDL style bindings is two fold: First, the extra level of indirection always requires an additional level of translation, which impacts the overall performance of the system。s how to use Java39。 // Step 4. Flush the data to its destination ()。 Foo foo = (Foo)()。s a description of the most important JDBC interfaces: handles the loading of drivers and provides support for new database connections. represents a connection to a particular database. acts as a container for executing an SQL statement on a given connection. controls access to the result set. You can implement a JDBC driver in several ways. The simplest would be to build the driver as a bridge to ODBC. This approach is best suited for tools and applications that do not require high performance. A more extensible design would introduce an extra level of indirection to the DBMS server by providing a JDBC work driver that accesses the DBMS server through a published protocol. The most efficient driver, however, would directly access the DBMS proprietary API. Object databases and Java persistence A number of ongoing projects in the industry offer Java persistence at the object level. However, as of this writing, Object Design39。s transaction semantic You oldtime users of ObjectStore probably will find the database and transaction semantics familiar. There is a systemwide ObjectStore object that initializes the environment and is responsible for systemwide parameters. The Database class offers methods (such as create, open, and close), and the Transaction class has methods to begin, abort, or mit transactions. As with serialization, you need to find an entry point into the object graph. The getRoot and setRoot methods of the Database class serve this function. I think a few examples would be helpful here. This first snippet shows how to initialize ObjectStore: (serverName, null)。 try { foo = (Foo)(fooHead)。持久化被期望用于事務(wù)完整性和更嚴(yán)格的條件(參看文獻(xiàn)部分獲取更多的事務(wù)處理的信息)。對(duì)事物的持久比對(duì)對(duì)象模型的持久要困難,而且我們可以觀察到對(duì)象之間是通過他們之間的關(guān)系關(guān)聯(lián)在一起的。這同樣時(shí)眾所周知的關(guān)系數(shù)據(jù)庫的一個(gè)特性叫做 “數(shù)據(jù)獨(dú)立性 ”。選擇查詢語言是另外一個(gè)值得考慮的方面。例如,假設(shè)一個(gè)賬戶有多種行為組合叫做 isInGoodStanding,這樣所有的 in good standing 的賬戶都將會(huì)返回正確,其它的返回錯(cuò)誤。許多關(guān)系數(shù)據(jù)庫公司,例如 Oracle和 Informix,將很快提供其它的方式,基于 SQL 語法來達(dá)到同樣的效果。 規(guī)范化和語言獨(dú)立 一種語言同一類型的對(duì)象應(yīng)該已同樣的方式儲(chǔ)存到持久的儲(chǔ)存器上,不管它們的表現(xiàn)形式是怎么樣的。如果對(duì)象能以單獨(dú)的一種語言表示,那么同一對(duì)象的不同表現(xiàn)形式就可以共享同一持久化存儲(chǔ)器。 另一種簡(jiǎn)單的策略是通過對(duì) SQL 的擴(kuò)展來實(shí)現(xiàn)對(duì)對(duì)象服務(wù)的支持。值得提醒的是,雖然有商用的第三方庫對(duì)串行化 C++對(duì)象的支持,但是 C++本身并沒有提供對(duì)象串行化的策略。 // Step 4. Flush the data to its destination ()。串行化對(duì)象以繼承結(jié)構(gòu)的每個(gè)類的屬性開始,如下類的實(shí)現(xiàn): // Reading an object from a stream // Step 1. Create an input stream FileInputStream in = new FileInputStream(fooFile)。 對(duì)象串行化和安全 默認(rèn)情況下,串行化寫入流中和從流中讀取的都是非靜態(tài)和非臨時(shí)的屬性。要成為適用的 JDBC,驅(qū)動(dòng)至少要支持 ANSI SQL- 2 entry- level API,它是提供第三方工具和靈活數(shù)據(jù)庫訪問應(yīng)用的廠商。最簡(jiǎn)單的是構(gòu)建 ODBC 橋,這種方法最適合工具和應(yīng)用 不需要很高的性能。對(duì)象設(shè)計(jì)的 PSE(持久性存儲(chǔ)引擎)和 PSE Pro 是唯一完全基于 java 的,可用的面向?qū)ο髷?shù)據(jù)庫軟件包(至少,這是我所知道的)。因?yàn)樵陂_發(fā)過程中這個(gè)不是在連接這步上,開發(fā)者們不得不創(chuàng)建相互獨(dú)立的多個(gè)功能模塊,這樣就形成了更好,更可靠的面向?qū)ο缶幋a。這些產(chǎn)品是我們所稱的 dribbleware ―― 通過插入新的組件來增強(qiáng)軟件發(fā)布版本的功能。從 PSE 的視圖可以看出,在對(duì)象圖中的類不是有可能持久化的就是已知要持久化的。為了能調(diào)用正確的方法,應(yīng)該需要一個(gè)獨(dú)立的方法。 ObjectStore 在 GenericObject 中提供方法,確保你的持久化對(duì)象屬性能調(diào)用正確的方法。該方法必須將所有引用持久化對(duì)象的引用屬性設(shè)置為 null。這些方5 法必須在持久化對(duì)象的內(nèi)容能夠分別的被訪問和修改之前被調(diào)用。有一個(gè)廣泛的系統(tǒng) ObjectStore 對(duì)象來初始化環(huán)境和參數(shù)。第一段代碼顯展現(xiàn)了如何初始化 ObjectStore: (serverName, null)。 try { foo = (Foo)(fooHead)。 不支持傳播事務(wù),備份和恢復(fù),群集,大型數(shù)據(jù)庫,對(duì)象安全等在語言中有用的和任何分配方式。在加入 Sun 之前,他是一名開發(fā)人員和一所財(cái)經(jīng)服務(wù)公司的 IT 顧問。