commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject cvs commit: jakarta-commons-sandbox/simplestore/docs users-guide.html
Date Sun, 31 Mar 2002 10:46:35 GMT
baliuka     02/03/31 02:46:35

  Added:       simplestore/docs users-guide.html
  Added docs
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/simplestore/docs/users-guide.html
  Index: users-guide.html
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      h3{ color:navy };
      code{ color:navy };
      <TITLE>SimpleStore Usere Guide</TITLE>
    <BODY alink='navy' vlink='navy' >
       <center> <h3>SimpleStore Users Guide</h3></center>
   <h3>What is SimpleStore ?</h3>
      SimpleStore is customizable persistence framework. It defines
      interfaces for Transparent Persistence and provides reference implementation.
      It designed to store objects in Transactionl resource like RDMS, but
      can be used with any kind of storage. It is two storage types
      in reference implementation: RDMS and <a href=''>BTree
file from JDBM</a>.
   <h3 > What can SimpleStore do for me? </h3>
     You can use it to implement persitence aspect in your web application, or
     object model, you can use it as  service for you server like  
       <a href=''>EOB</a> or EJB (CMP,BMP). 
     You can extend it and implement your  persitence framework. 
   <h3> PersitenceManagerFactory </h3>
      This interface is used to implement well known Factory design pattern it
      used to setup singleton PersitenceManager instanse. PersitenceManager is
      the most specific interface in your code:
       <pre >
       DBPersistenceManagerFactory factory = new DBPersistenceManagerFactory();
          factory.setDriver(<span style='color:red'>"org.hsqldb.jdbcDriver"</span>);
          factory.setUrl(<span style='color:red'>"jdbc:hsqldb:sample"</span>);
          factory.setUser(<span style='color:red'>"sa"</span>);
          factory.setPassword(<span style='color:red'>""</span>);
          factory.setMaxConnections(<b style='color:blue'>1</b>);
          factory.setMetaResource(<span style='color:red'>"org/apache/commons/simplestore/storage.xml"</span>);
        PersitenceManager  pm = factory.<b>getPersistenceManager</b>();
     this example setups PersitenceManager to use RDMS as storage.
     <h3 >PersitenceManager</h3>
      PersitenceManager is factory for you beans and transactions, Transaction is
      the last interface you need to know from SimpleStore if you not going to extend
      SimpleStore. You dont need to exdend any specific Class or implement internal
      persitence interfaces, you dont need any code generator. Just design your
      object model, use interfaces and classes, SimpleStore will implement persitence
      aspect for you, but you still need some "Metadata" it very trivial xml file, but 
      it can be writen usin opional tags or generated later. Start to desin beans:
     <pre >
   <b>public abstract class</b> Message 
          public MessageImpl(){}
          public void addReply(Message m) {
            m.setSubmitted(new java.util.Date());
          public int numberOfReplies() {
            return getReplies().size();
       <b>public abstract</b> java.util.Collection <b>getReplies</b>();
       <b>public abstract</b> Date <b>getSubmitted</b>(); 
       <b>public abstract</b> void <b>setSubmitted</b>(Date v);
       <b>public abstract</b> String <b>getContents</b>();
       <b>public abstract</b> void <b>setContents</b>(String v); 
       <b>public abstract</b> String <b>getEmail</b>(); 
       <b>public abstract</b> void <b>setEmail</b>(String v); 
       <b>public abstract</b> String <b>getName</b>(); 
       <b>public abstract</b> void <b>setName</b>(String v);
       <b>public abstract</b> String <b>getSubject</b>(); 
       <b>public abstract</b> void <b>setSubject</b>(String v);
       <b>public abstract</b> void <b>setParent</b>( Message parent
) ;
      This is persistent bean from Jakarta Velocity demo. All abstract methods are implemented

      by SimpleStore, PersitenceManager returns this implementation :
       <pre >
         PersitenceManager  pm = factory.<b>getPersistenceManager</b>();
         Transaction transaction = pm.<b>getTransaction</b>(); 
            Message parent = pm.<b>findInstance</b>(Message.class,parentOid);
            Message msg    = pm.<b>createInstance</b>(Message.class);        
    Last you will need some metadata it helps simplestore to implement your beans:
     &lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
      &lt;!DOCTYPE storage&gt; 
          &lt;mclass  id="<b>Message</b>" name="MESSAGE"&gt;
            &lt;field id="<b>parent</b>" name="parent"&gt;
                &lt;reference mclass="<b>Message</b>"/&gt; 
            &lt;field id="<b>replies</b>"&gt;
            &lt;reference mclass="<b>Message</b>" field="parent"/&gt;

   <h3 >Transaction</h3>
      SimpleStore supports only atomic persistence operations,
      All operations must be in transaction context:
      Transaction transaction = pm.<b>getTransaction</b>(); 
          //    <i> operations </i>
          transaction.<b>commit</b>();// or transaction.<b>rollback</b>();

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message