baliuka 02/04/03 10:17:08
Modified: simplestore/docs developers-guide.html users-guide.html
simplestore/src/java/org/apache/commons/simplestore/persistence/impl
ContextImpl.java PersistentProxy.java
Added: simplestore/docs ddiagram.gif udiagram.gif
Log:
Added UML diagrams
Revision Changes Path
1.3 +48 -11 jakarta-commons-sandbox/simplestore/docs/developers-guide.html
Index: developers-guide.html
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/docs/developers-guide.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- developers-guide.html 1 Apr 2002 17:08:08 -0000 1.2
+++ developers-guide.html 3 Apr 2002 18:17:08 -0000 1.3
@@ -17,7 +17,7 @@
<center><h2 style='color:navy'> SimpleStore Developers Guide</h2></center>
<a name='toc'><h3>Table of Contents</h3></a>
-<table> <tr><td>
+<table> <tr><td valign='top'>
<ul>
<li><a href='users-guide.html'>Users Guide</a></li>
<li><a href='#about'>About this Guide</a></li>
@@ -41,15 +41,17 @@
</ul>
</td>
- <td align='center' style='font-size:100'>
- TODO: UML
- </td>
+ <td width='100'> </td>
+ <td valign='top' align='center' style='font-size:100'>
+ <img src='ddiagram.gif'>
+ </td>
</tr>
</table>
<a name='about'><h3>About this Guide</h3></a>
<p>
- This guide is intended for service providers.
+ This guide is intended for service providers. This document describes core
interfaces
+ and can be useful for SimpleStore users and Bean providers too.
</p>
<a name='introduction'><h3>Introduction</h3></a>
<p>
@@ -101,8 +103,21 @@
</p>
<a name='pm'><h3>PersitenceManager</h3></a>
<p>
- It is a high level storage neutral interface. Default implementation can be used
- for any <code>Storage</code>.
+ It is a high level interface it doe's not depend on Storage. Default
implementation can be used
+ for any <code>Storage</code> implementation.
+ It is fragment from <code>PersitenceManager</code> implementation.
+ <pre>
+ public Object createInstance( Class aclass ) {
+
+ Persistent p = context.getMetaClass(aclass).newInstance();
+ context.getCache().put( p.getOID(), p );
+ return p;
+ }
+
+ public Object findInstance( Class clasz, Object oid ) throws StorageException {
+ return context.getStorage().retrieveObject( clasz, oid );
+ }
+ </pre>
</p>
<a name='transaction'><h3>TransactionManager</h3></a>
<p>
@@ -123,11 +138,15 @@
<a name='cache'><h3>Cache</h3></a>
<p>
It is recommended to use default SoftMemoryCache implementation, but you can use
any implementation.
+ Cache has no method to remove mapping. Simplestore can return deleted in Storage
object from Cache.
+ Managed methods throw <code>IllegalStateExeption</code> if object is deleted, use
+ <code>PersistenceManager::isDeleted(Object obj)</code> to test object returned
from Cache.
+
</p>
<a name='metaclass'><h3>MetaClass</h3></a>
<p>
<code>MetaClass</code> describes persistent fields and it is factory for
persistent insatnces.
- You can implement <code>MetaClass</code> to change default DTD for metadata or
store it in some
+ You can implement <code>MetaClass</code> to change default DTD for metadata, store
it in some
custom format or database.
</p>
<a name='enhansment'><h3>Enhancment</h3></a>
@@ -135,6 +154,8 @@
SimleStore provides utility for Class enhancement. It used to implement
persistence, but
you can use it for any aspect like logging, authorization or generate dynamic
Proxy for
distributed objects, Object to XML mapping.
+SimpleStore use <a href='http://jakarta.apache.org/bcel'>BCEL</a>
+ to enhance classes and implement Persistent interface.
</p>
<a name='persistent'><h3>Persistent</h3></a>
@@ -147,11 +168,13 @@
<code>PersistentProxy</code> impements <code>MethodInterceptor</code> for
generated Persistent class. It implements methods
to handle persistent object Identity and State.
-
+
</p>
<a name='state'><h3>State</h3></a>
<p>
MetaObject manages persistent object state.
+ <code>Persistent</code> returns this implementation.
+This interface is used by Storage implementation too.
<pre>
public interface MetaObject extends Cloneable {
@@ -193,11 +216,25 @@
<a name='id'><h3>Identity</h3></a>
<p>
Implement <code>OIDGenerator</code> interface for custom OID generation.
- Default implementation returns random number.
+ Default implementation returns random number. Returned object must be unique,
+it is used as key in Cache and as identity in Storage.
+<pre>
+ PersistenceManager.getOID(object1).
+ <b>equals</b>(PersistenceManager.<b>getOID</b>(object2) );
+ <h4> <==> </h4>
+ object1 <b>==</b> object2;
+ <h4> <==> </h4>
+ object1.<b>equals</b>(object2);
+</pre>
+
</p>
<a name='validation'><h3>Validation</h3></a>
<p>
- Use metadata to map <code>Validator</code> and field.
+ Metadata is used to map <code>Validator</code> and field.
+ <code>NotNull</code> validator can be used as example.
+ Persistent throws ValidationException for write methods if
+ <code>isValid()</code> return <code>false</code>, this Exception
+ contains all information for invalid property value.
</p>
<a name='interceptors'><h3>Interceptors</h3></a>
<p>
1.7 +49 -15 jakarta-commons-sandbox/simplestore/docs/users-guide.html
Index: users-guide.html
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/docs/users-guide.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- users-guide.html 1 Apr 2002 17:08:08 -0000 1.6
+++ users-guide.html 3 Apr 2002 18:17:08 -0000 1.7
@@ -29,10 +29,13 @@
<li><a href='#security'>Security</a></li>
<li><a href='developers-guide.html'>Developers Guide </a></li>
<li><a href='api/index.html'>API</a></li>
+ <li><a href='#projects'> Related Projects </a></li>
+
</ul>
- <td align='center' style='font-size:100'>
- TODO: UML
- </td>
+ <td width='100'> </td>
+ <td valign='top' align='center' style='font-size:100'>
+ <img src='udiagram.gif'>
+ </td>
</tr>
</table>
@@ -48,7 +51,7 @@
It defines interfaces for Transparent Persistence and provides reference
implementation.
It designed to store objects in Transactional resource like RDMS, but can be used
with any kind of storage.
It is two storage types in reference implementation:
- RDMS and <a href='http://jdbm.sourceforge.org'>BTree file from JDBM project</a>.
"Transparent" means no Query Language,
+ RDMS and <a href='http://jdbm.sourceforge.net'>BTree file from JDBM project</a>.
"Transparent" means no Query Language,
Code Generation or Storage Specific API. Persistent Object doe's not extend any
specific
class and doe's not implement some interface from SimpleStore API. Users code can
use it,
but must not depend on it( Downcast ). It is recommended to "hide"
PersistentManager
@@ -60,7 +63,7 @@
<p>
You can use it to implement persistency aspect in your web application,
or object model, you can use it as service for your server like
- <a href='http://eob.sourceforge.org'>EOB</a> or EJB (CMP,BMP).
+ <a href='http://eob.sourceforge.net'>EOB</a> or EJB (CMP,BMP).
You can extend it and implement your persistence framework or for some like JDO.
SimpleStore is Open Source and you can use it in commercial projects, see Apache
<a href='http://www.apache.org/foundation/licence-FAQ.htm'> license </a> for
details.
@@ -97,7 +100,7 @@
public MessageImpl(){}
- public void addReply(Message m) {
+ public void addReply( <b>Message</b> m ) {
m.setSubmitted(new java.util.Date());
m.setParent(this);
}
@@ -126,7 +129,7 @@
<b>public abstract</b> void <b>setSubject</b>(String v);
- <b>public abstract</b> void <b>setParent</b>( Message parent );
+ <b>public abstract</b> void <b>setParent</b>( <b>Message</b> parent );
}
</pre>
@@ -175,6 +178,18 @@
// <i> operations </i>
//..........................
transaction.<b>commit</b>();// or transaction.<b>rollback</b>();
+</pre>
+ It is fragment from SimpleStore test, it demonstrates <b>rollback</b>:
+<pre>
+ transaction.begin();
+ TestPersistentClassType object = (TestPersistentClassType) i.next();
+ String val = object.<b>getStrVal</b>();
+ object.<b>setStrVal</b>( i + "");
+ transaction.<b>rollback</b>();
+
+ transaction.begin();
+ assertEquals("After rollback ", val, object.<b>getStrVal</b>());
+ transaction.commit();
</pre>
</p>
<a name='id'><h3>Identity</h3></a>
@@ -182,17 +197,25 @@
All persistent objects have OID, it is recomended to use <code>Serializable</code>
Object for OID,
reference implementaion uses java.lang.Long and default (Random) generator.
It is single persistent instance in SimpleStore with concreate OID.
-<pre>
- PersistenceManager.getOID(object1).
- <b>equals</b>(PersistenceManager.<b>getOID</b>(object2) );
- <h4> <==> </h4>
- object1 <b>==</b> object2;
- <h4> <==> </h4>
- object1.<b>equals</b>(object2);
+<br>
+ Next always evaluates to true :
+<pre>
+ if( pm.<b>findInstance</b>(Message.class, pm.<b>getOID</b>( msg ) ) <b>==</b>
msg ){
+
+ ..................................
+ }
+
</pre>
OID is managed by framework and it is no way to change it for persistent object.
SimpleStore overrides <code>int hashCode()</code> and <code>boolean equals(Object
obj)</code>
- methods in class Object.
+ methods in class Object. <br>
+ Next always evaluates to true :
+<pre>
+ if( pm.<b>findInstance</b>(Message.class, pm.<b>getOID</b>( msg )
).<b>equals</b>( msg ) ){
+
+ ..................................
+ }
+</pre>
</p>
<a name='state'><h3>State</h3></a>
<p>
@@ -218,6 +241,11 @@
<code>Validator</code> interface,
and sample <code>NotNull</code> validator implementation. Persistent object
implementation throws
<code>ValidationException</code> if registread validator returns false for managed
property value.
+ <pre>
+ <field id='propertyName' name='fieldName'>
+ <validator id='ClassName'/>
+ </field>
+ </pre>
</p>
<a name='security'><h3>Security</h3></a>
<p>
@@ -225,6 +253,12 @@
SimpleStore doe's not define any specific Permissions and doe's no security checks.
Read more about customizations see <a href='developers-guide.html'> Developers
Guide </a>.
</p>
+ <a name='#projects'><h3> Related Projects </h3></a>
+<ul>
+ <li><a href='http://www.castor.org'>Castor</a></li>
+ <li><a href='http://objectbridge.sourceforge.net'>ObjectBridge</a></li>
+ <li><a href='http://simper.sourceforge.net'>Simper</a></li>
+</ul>
<hr style='color:navy'>
<div align="center"><font color="#525D76" size="-1"><em>
Copyright © 1999-2002, Apache Software Foundation
1.1 jakarta-commons-sandbox/simplestore/docs/ddiagram.gif
<<Binary file>>
1.1 jakarta-commons-sandbox/simplestore/docs/udiagram.gif
<<Binary file>>
1.4 +9 -3
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/ContextImpl.java
Index: ContextImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/ContextImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ContextImpl.java 23 Mar 2002 14:54:53 -0000 1.3
+++ ContextImpl.java 3 Apr 2002 18:17:08 -0000 1.4
@@ -62,7 +62,7 @@
*
*@author Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]">
* [EMAIL PROTECTED]</a>
- *@version $Id: ContextImpl.java,v 1.3 2002/03/23 14:54:53 baliuka Exp $
+ *@version $Id: ContextImpl.java,v 1.4 2002/04/03 18:17:08 baliuka Exp $
*/
public class ContextImpl implements Context {
@@ -77,14 +77,20 @@
public ContextImpl( MetaClass metaClass,TypeConverter typeConverter,
OIDGenerator generator, Storage storage,
Cache cache,TransactionManager transactionManager ) {
- metaClass.setContext( this );
- storage.setContext( this );
+
this.generator = generator;
this.metaClass = metaClass;
this.storage = storage;
this.cache = cache;
this.transactionManager = transactionManager;
this.typeConverter = typeConverter;
+
+ metaClass.setContext( this );
+ storage.setContext( this );
+ generator.setContext( this );
+ typeConverter.setContext( this );
+ transactionManager.setContext( this );
+
}
public MetaClass getMetaClass(Class clasz) {
1.25 +15 -20
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java
Index: PersistentProxy.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- PersistentProxy.java 20 Mar 2002 19:28:26 -0000 1.24
+++ PersistentProxy.java 3 Apr 2002 18:17:08 -0000 1.25
@@ -77,7 +77,7 @@
* [EMAIL PROTECTED]</a>
*@author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">
* [EMAIL PROTECTED]</a>
- *@version $Id: PersistentProxy.java,v 1.24 2002/03/20 19:28:26 baliuka Exp $
+ *@version $Id: PersistentProxy.java,v 1.25 2002/04/03 18:17:08 baliuka Exp $
*/
public class PersistentProxy
implements MetaObject, org.apache.commons.simplestore.tools.Constants ,
@@ -115,7 +115,6 @@
Context context) {
m_oid = oid;
setState( newCreated, NEW_CREATED );
-
m_context = context;
m_clazz = clazz;
m_metaClass = context.getMetaClass(clazz);
@@ -185,6 +184,7 @@
}
public void setProperty(int index, Object value) {
+
Object old = m_props[ index ];
if (old == null || !old.equals(value)) {
m_context.getTransactionManager().getTransaction().add(this);
@@ -245,24 +245,23 @@
Object retValFromSuper,
Throwable e)
throws Throwable{
- if( DEBUG ){
- System.out.println("Invoked: " + method);
- }
- if(e != null ){
+
+ if( e != null ){
if( DEBUG ){
e.printStackTrace();
}
throw e;
}
- if( invokedSuper )return retValFromSuper;
+ if( invokedSuper ){
+ if( e != null){
+ throw e;
+ }
+ return retValFromSuper;
+ }
return invoke(obj,method,args);
-
-
- }
+
+ }
public boolean invokeSuper(Object obj,Method method,Object[] args,Object
retValFromBefore) throws Throwable{
- if(DEBUG){
- System.out.println("Invoke super:" + method);
- }
if( Enhancer.equals(method, HASH_CODE) ||
Enhancer.equals(method,EQUALS) ||
@@ -285,11 +284,10 @@
} else if ( Enhancer.equals(method,HASH_CODE)) {
if (m_oid == null) {
-
return new Integer(0);
}
return new Integer(m_oid.hashCode());
- } else if (EQUALS.equals(method)) {
+ } else if ( Enhancer.equals( method, EQUALS) ) {
return handleEquals(obj2[0]);
} else {
return handleProperty(obj, method, obj2);
@@ -363,6 +361,7 @@
}
public void assign(MetaObject mo) {
+
System.arraycopy(((PersistentProxy)mo).m_props,0,m_props,0,m_props.length);
m_oid = mo.getOID();
m_object = mo.getObject();
@@ -374,11 +373,7 @@
public boolean isClean() {
return getState(CLEAN);
}
- public void handle( java.lang.reflect.Method m, java.lang.Throwable e ){
- System.out.println("Error in " + m.getName());
- e.printStackTrace();
- throw new SimplestoreException(e.toString());
- }
+
static {
try {
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>