当前位置: 首页 > 工具软件 > MyOODB > 使用案例 >

myoodb快速指南(翻译)

尉迟宣
2023-12-01
myoodb快速指南

myoodb是一个面向对象的数据库,他的许多功能是现有的数据库产品没有的。
myoosdk解决方案由两个部分组成的,myoodb是其中的一部分.
连同MyOOWEB,MyOOSDK能为开发快速,很小但又强大的App/Web应用程序提供一个平台。
是一个真正的面向对象设计应用到App/Web 的开发设计.
这是一个最快的可用的100%java数据库 , myoosdk还提供无缝Web集成.
myoosdk客户代码可以通过应用程序,或浏览器用TCP, TCPS, HTTP, or HTTPS这些协议执行。
MyOODB database technology provides better performance for known database features, as well as, providing features not yet seen.
像其他的数据库解决方案,开发人员myoodb对象数据库.
但是和现有解决方案不同的是,myoodb对象只存在于服务器上.
虽然客户端对象看起来和感觉到是一个对象,实际上还是一个简单的分布式实现.

而MyOODB 提供了一些特点,是其他解决方案没有,其中较引人瞩目的是它的自修复与隔离损坏.
Myoodb数据库技术考虑到一个坏文件系统块或块,以不损坏整个数据库.
每个对象是独立的,所以如果一个对象损坏了, myoodb会尝试重写对象从内存到磁盘.
如果MyOODB 数据库服务器不运行恢复状态,当对象编码使用自恢复设施坏对象参照好对象就可以搞掂(这是一个很好的卖点,对您的经理) .

通过源代码的一个例子,看看如何界定数据库对象:
java 代码
 
  1. //  
  2. // MyOODB Object Interface;  
  3. //  
  4. public interface Person extends org.myoodb.collectable.Collectable  
  5. {  
  6.     @org.myoodb.MyOodbAccess(value="Write")  
  7.     public void setName(String name);  
  8.   
  9.     public String getName();  
  10. }  
  11.   
  12. //  
  13. // MyOODB Object Implementation  
  14. //  
  15. public class PersonDbImpl extends org.myoodb.collectable.CollectableDbImpl implements Person  
  16. {  
  17.     private String m_name;  
  18.   
  19.     public PersonDbImpl()  
  20.     {  
  21.         m_name = null;  
  22.     }  
  23.   
  24.     public void setName(String name)  
  25.     {  
  26.         m_name = name;  
  27.     }  
  28.   
  29.     public String getName()  
  30.     {  
  31.         return m_name;  
  32.     }  
  33. }  
  34.   
  35. 注意这是 @org.myoodb.myoodbacces 的注解.   
  36. 这个宏指令通知MyOODB 修造过程, setName 方法的请求将导致人实例被保存到硬盘。  
  37. 不指明宏指令的话,将把变化存放在内存上。   

存储对象有几种行为。象早先陈述, 客户端对象是真正地分布式的实现(即代理) 。如果你请求一个Write方法没有上下文, 对象状态立刻被存储在内存和硬盘。这称一种隐式事务。


另一类型实现是一种显式事务。
这是一些myoodb的好处开始显现出来.
myoodb真正的分布式对象, 支持多个并发嵌套事务。
一个对象的改变不会引起另一个对象改变,除非明确的事务正在修改一组物体,又显式或隐式的事务要工作.
下列事务的例子是取自源代码:



MyOODB是一个面向对象数据库,真正快速的分布式数据库,支持真正的分布式对象,支持真正的分布式事务,支持隐式/显式事务, 支持无缝高速Web服务访问,支持数据库自我恢复,支持多个并发嵌套事务并且数据库大小只占磁盘很小的空间。

java 代码
 
  1. {  
  2.     MyOodbDatabase db = MyOodbDatabase.open("myoodb://localhost:54321, admin, admin"); 
  3.     MyOodbTransaction tx = db.createTransaction(); 
  4.  
  5.     tx.begin(); // put create in the context of a explicit transaction 
  6.     Person person = db.createObject(PersonDbImpl.class); 
  7.  
  8.     tx.begin(); // put the setName call in a nested explicit transaction 
  9.     person.setName(John Smith); 
  10.  
  11.     tx.rollback(); // undo the setName 
  12.     person.setName(Mary Smith); // put this setName in the context of the first transaction 
  13.  
  14.     tx.commit(); // commit all changes 
  15. } 
  16. 现在重申,所有上述对象都能调用在一个显式事务的上下文之外.  
  17.  
  18.  
  19. MyOOSDK 另外一个强大的特点是能无缝执行客户端代码在HTTP 或HTTPS 连接。使用Java  Applets 或Webstart 技术, 你可以修改上述例子和在网络上修改所有对象。以下例子显示四个方式连接到MyOODB 数据库服务器:  
  20.  
  21. { 
  22.     // app 
  23.     String url = "tcp://localhost:54321";  
  24.     String url = "tcps://localhost:54322"; 
  25.  
  26.     // web 
  27.     String url = "http://localhost:80";  
  28.     String url = "https://localhost:443";  
  29.   
  30.     MyOodbDatabase db = MyOodbDatabase.open(url, admin, admin);  
  31. }  

不要难过,如果您从未设定过web服务器或写过任何web应用。源码可以展示关于怎样设置一台web服务器的例子。试验这个例子,将花费你5分钟。

一旦你下载了源代码, 请看一看在以下部分以便您能立刻运行程序。发行被划分成三个部分:
1) source
源文件
2) extensions
扩展
3) examples
示例

请首先看例子, 但不要忘记在MyOODB 根目录build 。唯一需要你做的事是设置Java binary 在 your PATH和JAVA_HOME 环境变量指向您的Java 库。下列是有用的例子帮助您的工作:
1) simple
2) simpleSsl
3) simpleWeb
4) simpleSslWeb
5) ajaxWeb
6) admin ( Shows how to remotely create/delete/change users )
7) transactions
8) jython ( Dont forget play with runJython script. A command line interface )
9) jythonWeb
10) events
11) xml ( See how you can also have XML as the database backing store )
12) bean
13) callbacks
14) mi ( Multi-Inheritance through object delegation. See the README file )
16) performance
16) deactivation
17) selfHealing
17) verifyDatabase
18) defragDatabase
19) evolveDatabase ( i.e. Schema Migration )
20) backup/Restore
21) gaming
my







Quick Tutorial

MyOODB is an Object-Oriented Database with many features not available in existing database products. MyOODB is one part of a two part SDK solution. Together with MyOOWEB, MyOOSDK provides a development environment for software hackers who desire small fast but powerful applications. It is the foundation that puts the power of true Object-Oriented Design back into App/Web development.


The fastest 100% Java OODB available (IMHO), MyOOSDK also provides seamless web integration. MyOOSDK client code can run as an application or in a web browser over the following protocols: TCP, TCPS, HTTP, or HTTPS. MyOODB database technology provides better performance for known database features, as well as, providing features not yet seen.




Like other OODB solutions, MyOODB developer objects are the database. But unlike existing solutions, MyOODB objects only exist on the server. Though client objects look and feel like the actually object, in actuality its a simple distributed reference.


While MyOODB provides some features other solutions do not have, one of the more notable ones is its self-healing and corruption-isolation properties. MyOODB database technology allows for a bad file system block or blocks to not corrupt the entire database. Each object is self contained, so if an object on a block goes bad, MyOODB will try to rewrite the object in memory back to disk. And if the MyOODB Database Server is not running to restore state, when objects are coded to use the self-healing facilities, bad object references in good objects can be fixed up (A good selling point for your manager).

 


Taking an example from the source distribution, the following code is how one defines a database object:


Notice the @org.myoodb.MyOodbAcces annotation. This macro informs the MyOODB build process that the invocation of the setName method will cause the instance of Person to be saved to disk. Not specifying the macro simply will store the change in memory.




The storing of objects has a few behaviors. Like previously stated, client objects are really just distributed references (i.e. proxies). If one invokes a Write method without the context of a transactions, the object state is immediately stored in memory and on disk. This is called an implicit transaction.

The other type of transaction is an explicit transaction. Here is where some of MyOODB power starts to show. A result of MyOODB object clustering technology, MyOODB supports multi-concurrent nested transactions with rollback. No one object change will block another object change unless an explicit transaction is modifying a group of objects that yet another implicit or explicit transaction wants to work on. The following transaction example is taken from the source distribution:



To reiterate, all the above object calls can be performed outside the context of an explicit transaction.


Yet another powerful feature of MyOOSDK is the ability to seamlessly run client code over HTTP or HTTPS connections. Using Java Applets or Webstart technology, one can change the above example and tunnel all object modifications over the web. The following example shows the four ways to connect to the MyOODB Database Server:



Do not fret if you have never set up a web server or written any web applications. The source distribution comes with a web server and examples on how to set it up. Itll take 5 minutes, really it will.

Once you pull down the source distributed, please take a look at the following areas so that you can get up and running in no time. The distribution is divided into three sections:

Please first take a look in examples, but do not forget to build MyOODB from the root directory. The only thing you will need is the java binary in your PATH and the JAVA_HOME environment variable pointing to your java distribution. The following are useful examples to model your work around:

Thats it. Start showing off your new found productivity ;-)

MyOoSDK ( MyOoDB / MyOoXML / MyOoWEB ) ? 20
 类似资料: