Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1171 - in development/laboratory/planet/components/space: . api api/src api/src/main api/src/main/org api/src/main/org/jpos api/src/main/org/jpos/space api/src/main/org/jpos/space/api interceptor interceptor/src interceptor/src/main interceptor/src/main/org interceptor/src/main/org/jpos interceptor/src/main/org/jpos/space interceptor/src/main/org/jpos/space/interceptor jdbm jdbm/src jdbm/src/main jdbm/src/main/org jdbm/src/main/org/jpos jdbm/src/main/org/jpos/space persistent persistent/src persistent/src/main persistent/src/main/org persistent/src/main/org/jpos persistent/src/main/org/jpos/space persistent/src/main/org/jpos/space/persistent proxy proxy/src proxy/src/main proxy/src/main/org proxy/src/main/org/jpos proxy/src/main/org/jpos/space proxy/src/main/org/jpos/space/proxy tiny tiny/src tiny/src/main tiny/src/main/org tiny/src/main/org/jpos tiny/src/main/org/jpos/space tiny/src/main/org/jpos/space/tiny transient transient/src transient/src/main transient/src/main/org transient/src/main/org/jpos transient/src/main/org/jpos/space transient/src/main/org/jpos/space/transiient util util/src util/src/main util/src/main/org util/src/main/org/jpos util/src/main/org/jpos/space util/src/main/org/jpos/space/util

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1171 - in development/laboratory/planet/components/space: . api api/src api/src/main api/src/main/org api/src/main/org/jpos api/src/main/org/jpos/space api/src/main/org/jpos/space/api interceptor interceptor/src interceptor/src/main interceptor/src/main/org interceptor/src/main/org/jpos interceptor/src/main/org/jpos/space interceptor/src/main/org/jpos/space/interceptor jdbm jdbm/src jdbm/src/main jdbm/src/main/org jdbm/src/main/org/jpos jdbm/src/main/org/jpos/space persistent persistent/src persistent/src/main persistent/src/main/org persistent/src/main/org/jpos persistent/src/main/org/jpos/space persistent/src/main/org/jpos/space/persistent proxy proxy/src proxy/src/main proxy/src/main/org proxy/src/main/org/jpos proxy/src/main/org/jpos/space proxy/src/main/org/jpos/space/proxy tiny tiny/src tiny/src/main tiny/src/main/org tiny/src/main/org/jpos tiny/src/main/org/jpos/space tiny/src/main/org/jpos/space/tiny transient transient/src transient/src/main transient/src/main/org transient/src/main/org/jpos transient/src/main/org/jpos/space transient/src/main/org/jpos/space/transiient util util/src util/src/main util/src/main/org util/src/main/org/jpos util/src/main/org/jpos/space util/src/main/org/jpos/space/util
  • Date: Sun, 12 Dec 2004 20:42:44 +0100

Author: niclas
Date: Sun Dec 12 20:42:44 2004
New Revision: 1171

Added:
development/laboratory/planet/components/space/
development/laboratory/planet/components/space/api/
development/laboratory/planet/components/space/api/build.xml (contents,
props changed)
development/laboratory/planet/components/space/api/src/
development/laboratory/planet/components/space/api/src/main/
development/laboratory/planet/components/space/api/src/main/org/
development/laboratory/planet/components/space/api/src/main/org/jpos/
development/laboratory/planet/components/space/api/src/main/org/jpos/space/

development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/

development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/LeasedReference.java
(contents, props changed)

development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/LocalSpace.java
(contents, props changed)

development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/RemoteSpace.java
(contents, props changed)

development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/Space.java
(contents, props changed)

development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/SpaceException.java
(contents, props changed)

development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/SpaceListener.java
(contents, props changed)

development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/Template.java
(contents, props changed)
development/laboratory/planet/components/space/build.xml (contents,
props changed)
development/laboratory/planet/components/space/index.xml (contents,
props changed)
development/laboratory/planet/components/space/interceptor/
development/laboratory/planet/components/space/interceptor/build.xml
(contents, props changed)
development/laboratory/planet/components/space/interceptor/src/
development/laboratory/planet/components/space/interceptor/src/main/
development/laboratory/planet/components/space/interceptor/src/main/org/

development/laboratory/planet/components/space/interceptor/src/main/org/jpos/

development/laboratory/planet/components/space/interceptor/src/main/org/jpos/space/

development/laboratory/planet/components/space/interceptor/src/main/org/jpos/space/interceptor/

development/laboratory/planet/components/space/interceptor/src/main/org/jpos/space/interceptor/SpaceInterceptor.java
(contents, props changed)
development/laboratory/planet/components/space/jdbm/
development/laboratory/planet/components/space/jdbm/build.xml (contents,
props changed)
development/laboratory/planet/components/space/jdbm/src/
development/laboratory/planet/components/space/jdbm/src/main/
development/laboratory/planet/components/space/jdbm/src/main/org/
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/

development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/

development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/Head.java
(contents, props changed)

development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/JDBMSpace.java
(contents, props changed)

development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/MD5Template.java
(contents, props changed)

development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/Ref.java
(contents, props changed)

development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/RefSerializer.java
(contents, props changed)
development/laboratory/planet/components/space/persistent/
development/laboratory/planet/components/space/persistent/build.xml
(contents, props changed)
development/laboratory/planet/components/space/persistent/src/
development/laboratory/planet/components/space/persistent/src/main/
development/laboratory/planet/components/space/persistent/src/main/org/

development/laboratory/planet/components/space/persistent/src/main/org/jpos/

development/laboratory/planet/components/space/persistent/src/main/org/jpos/space/

development/laboratory/planet/components/space/persistent/src/main/org/jpos/space/persistent/

development/laboratory/planet/components/space/persistent/src/main/org/jpos/space/persistent/Data.java
(contents, props changed)

development/laboratory/planet/components/space/persistent/src/main/org/jpos/space/persistent/PersistentSpace.java
(contents, props changed)
development/laboratory/planet/components/space/proxy/
development/laboratory/planet/components/space/proxy/build.xml
(contents, props changed)
development/laboratory/planet/components/space/proxy/src/
development/laboratory/planet/components/space/proxy/src/main/
development/laboratory/planet/components/space/proxy/src/main/org/
development/laboratory/planet/components/space/proxy/src/main/org/jpos/

development/laboratory/planet/components/space/proxy/src/main/org/jpos/space/

development/laboratory/planet/components/space/proxy/src/main/org/jpos/space/proxy/

development/laboratory/planet/components/space/proxy/src/main/org/jpos/space/proxy/SpaceRemoteServer.java
(contents, props changed)
development/laboratory/planet/components/space/tiny/
development/laboratory/planet/components/space/tiny/build.xml (contents,
props changed)
development/laboratory/planet/components/space/tiny/src/
development/laboratory/planet/components/space/tiny/src/main/
development/laboratory/planet/components/space/tiny/src/main/org/
development/laboratory/planet/components/space/tiny/src/main/org/jpos/

development/laboratory/planet/components/space/tiny/src/main/org/jpos/space/

development/laboratory/planet/components/space/tiny/src/main/org/jpos/space/tiny/

development/laboratory/planet/components/space/tiny/src/main/org/jpos/space/tiny/Data.java
(contents, props changed)

development/laboratory/planet/components/space/tiny/src/main/org/jpos/space/tiny/TinySpace.java
(contents, props changed)
development/laboratory/planet/components/space/transient/
development/laboratory/planet/components/space/transient/build.xml
(contents, props changed)
development/laboratory/planet/components/space/transient/src/
development/laboratory/planet/components/space/transient/src/main/
development/laboratory/planet/components/space/transient/src/main/org/
development/laboratory/planet/components/space/transient/src/main/org/jpos/

development/laboratory/planet/components/space/transient/src/main/org/jpos/space/

development/laboratory/planet/components/space/transient/src/main/org/jpos/space/transiient/

development/laboratory/planet/components/space/transient/src/main/org/jpos/space/transiient/Data.java
(contents, props changed)

development/laboratory/planet/components/space/transient/src/main/org/jpos/space/transiient/TransientSpace.java
(contents, props changed)
development/laboratory/planet/components/space/util/
development/laboratory/planet/components/space/util/build.xml (contents,
props changed)
development/laboratory/planet/components/space/util/src/
development/laboratory/planet/components/space/util/src/main/
development/laboratory/planet/components/space/util/src/main/org/
development/laboratory/planet/components/space/util/src/main/org/jpos/

development/laboratory/planet/components/space/util/src/main/org/jpos/space/

development/laboratory/planet/components/space/util/src/main/org/jpos/space/util/

development/laboratory/planet/components/space/util/src/main/org/jpos/space/util/Connector.java
(contents, props changed)

development/laboratory/planet/components/space/util/src/main/org/jpos/space/util/SpaceUtil.java
(contents, props changed)
Log:
Beginning to port the jpos.org Space implementation to the Metro platform.

Added: development/laboratory/planet/components/space/api/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/api/build.xml Sun
Dec 12 20:42:44 2004
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space-api" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/standard.xml"/>
+
+</project>

Added:
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/LeasedReference.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/LeasedReference.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.api;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * LeasedReference references an object for a limited amount of time
+ * @author Alejandro Revilla
+ * @version $Revision: 1.5 $ $Date: 2003/10/13 10:46:15 $
+ */
+public class LeasedReference extends TimerTask
+{
+ private Object referent;
+ private long expiration;
+
+ private static Timer timer = new Timer (true);
+
+ private LeasedReference ()
+ {
+ }
+
+ public LeasedReference (Object referent, long duration)
+ {
+ super();
+ this.referent = referent;
+ this.expiration = System.currentTimeMillis() + duration;
+ timer.schedule( this, duration );
+ }
+
+ public synchronized Object get()
+ {
+ if( isValid() )
+ return this.referent;
+ this.referent = null;
+ this.expiration = 0;
+ super.cancel();
+ return null;
+ }
+
+ public synchronized long getExpiration()
+ {
+ return expiration;
+ }
+
+ public synchronized boolean discard()
+ {
+ if( isValid() )
+ {
+ this.referent = null;
+ this.expiration = 0;
+ super.cancel();
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized long renew( long duration )
+ {
+ if( isExpired () )
+ return -1;
+ expiration = System.currentTimeMillis() + duration;
+ return( expiration );
+ }
+
+ public synchronized boolean isExpired()
+ {
+ return expiration <= System.currentTimeMillis();
+ }
+
+ public synchronized boolean isValid()
+ {
+ return expiration > System.currentTimeMillis();
+ }
+
+ public void run()
+ {
+ long duration = expiration - System.currentTimeMillis();
+ if( duration < 0 )
+ discard();
+ }
+}
+

Added:
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/LocalSpace.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/LocalSpace.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.api;
+
+import java.util.Set;
+
+/**
+ * @author Kris, Bharavi, Alejandro
+ * @version $Revision: 1.2 $ $Date: 2003/10/01 13:15:15 $
+ *
+ * @metro.service type="org.jpos.space.api.LocalSpace" version="1.0"
+ */
+public interface LocalSpace extends Space
+{
+ /**
+ * add a SpaceListener associated with a given key
+ * @param key Entry's key
+ * @param listener a SpaceListener
+ */
+ public void addListener( Object key, SpaceListener listener );
+
+ /**
+ * removes a SpaceListener associated with a given key
+ * @param key Entry's key
+ * @param listener the SpaceListener
+ */
+ public void removeListener( Object key, SpaceListener listener );
+
+ /**
+ * @return Set containing all keys in Space
+ */
+ public Set getKeySet();
+
+ /**
+ * @return number of entries in a given key
+ */
+ public int size( Object key );
+}

Added:
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/RemoteSpace.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/RemoteSpace.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.api;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * RMI based Space proxy
+ *
+ * @author Alejandro Revilla
+ * @version $Revision: 1.2 $ $Date: 2002/08/06 14:26:32 $
+ * @since 2.0
+ * @see Space
+ *
+ * @metro.service type="org.jpos.space.api.RemoteSpace" version="1.0"
+ */
+
+public interface RemoteSpace extends Remote
+{
+
+ /**
+ * Write a new entry into the Space
+ * @param key Entry's key
+ * @param value Object value
+ * @throws RemoteException
+ */
+ public void out( Serializable key, Serializable value )
+ throws RemoteException;
+
+
+ /**
+ * Write a new leased entry into the Space. Entry will remain valid
+ * for a limited amount of time.
+ * @see LeasedReference
+ * @param key Entry's key
+ * @param value Object value
+ * @param timeout entry valid time
+ * @throws RemoteException
+ */
+ public void out( Serializable key, Serializable value, long timeout )
+ throws RemoteException;
+
+ /**
+ * Take an entry from the space, waiting forever until one exists.
+ * @param key Entry's key
+ * @return value
+ * @throws RemoteException
+ */
+ public Serializable in( Serializable key )
+ throws RemoteException;
+
+ /**
+ * Read an entry from the space, waiting forever until one exists.
+ * @param key Entry's key
+ * @return value
+ * @throws RemoteException
+ */
+ public Serializable rd( Serializable key )
+ throws RemoteException;
+
+ /**
+ * Take an entry from the space, waiting a limited amount of time
+ * until one exists.
+ * @param key Entry's key
+ * @param timeout millis to wait
+ * @return value or null
+ * @throws RemoteException
+ */
+ public Serializable in( Serializable key, long timeout )
+ throws RemoteException;
+
+
+ /**
+ * Read an entry from the space, waiting a limited amount of time
+ * until one exists.
+ * @param key Entry's key
+ * @param timeout millis to wait
+ * @return value or null
+ * @throws RemoteException
+ */
+ public Serializable rd( Serializable key, long timeout )
+ throws RemoteException;
+
+ /**
+ * In probe takes an entry from the space if one exists,
+ * return null otherwise.
+ * @param key Entry's key
+ * @return value or null
+ * @throws RemoteException
+ */
+ public Serializable inp( Serializable key )
+ throws RemoteException;
+
+ /**
+ * Read probe reads an entry from the space if one exists,
+ * return null otherwise.
+ * @param key Entry's key
+ * @return value or null
+ * @throws RemoteException
+ */
+ public Serializable rdp( Serializable key )
+ throws RemoteException;
+
+}
+

Added:
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/Space.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/Space.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.api;
+
+
+/**
+ * <p><b>Space</b> uses concepts described in the Linda Coordination
Language
+ * that eases the implementation of other jPOS components (such as
+ * Channels, Muxes, etc.), but it is not by any means an attempt to provide
+ * a full implementation.</p>
+ *
+ * <p>jPOS's Space is basically a Map where each entry is a LinkedList
+ * of values that can be used as a BlockingQueue</p>
+ *
+ * <p>One can place entries on a queue by calling Space.out, take them
+ * by calling Space.in and read (without taking) by calling Space.rd</p>
+ *
+ * @author Alejandro Revilla
+ * @version $Revision: 1.6 $ $Date: 2003/10/01 13:17:49 $
+ * @since 2.0
+ * @see LeasedReference
+ * @see TransientSpace
+ * @see SpaceError
+ * @see <a href="http://www.cs.yale.edu/Linda/linda-lang.html";>The Linda
Coordination Language</a>
+ *
+ * @metro.service type="org.jpos.space.api.Space" version="1.0"
+ */
+
+public interface Space
+{
+ /**
+ * Write a new entry into the Space
+ * @param key Entry's key
+ * @param value Object value
+ */
+ void out( Object key, Object value);
+
+ /**
+ * Write a new entry into the Space, with an timeout value
+ * @param key Entry's key
+ * @param value Object value
+ * @param timeout timeout value
+ */
+ void out( Object key, Object value, long timeout);
+
+ /**
+ * Take an entry from the space, waiting forever until one exists.
+ * @param key Entry's key
+ * @return value
+ */
+ Object in( Object key);
+
+ /**
+ * Read an entry from the space, waiting forever until one exists.
+ * @param key Entry's key
+ * @return value
+ */
+ Object rd( Object key);
+
+ /**
+ * Take an entry from the space, waiting a limited amount of time
+ * until one exists.
+ * @param key Entry's key
+ * @param timeout millis to wait
+ * @return value or null
+ */
+ Object in( Object key, long timeout);
+
+
+ /**
+ * Read an entry from the space, waiting a limited amount of time
+ * until one exists.
+ * @param key Entry's key
+ * @param timeout millis to wait
+ * @return value or null
+ */
+ Object rd( Object key, long timeout);
+
+
+ /**
+ * In probe takes an entry from the space if one exists,
+ * return null otherwise.
+ * @param key Entry's key
+ * @return value or null
+ */
+ Object inp( Object key);
+
+
+ /**
+ * Read probe reads an entry from the space if one exists,
+ * return null otherwise.
+ * @param key Entry's key
+ * @return value or null
+ */
+ Object rdp( Object key);
+}
+

Added:
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/SpaceException.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/SpaceException.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+package org.jpos.space.api;
+
+/**
+ * org.jpos.space.Space operations do not declare any checked exceptions.
+ *
+ * Persistent space implementations can raise some exceptions that
+ * are wrapped around this unchecked SpaceException that we recommend to
+ * catch.
+ *
+ * @author Alejandro Revilla
+ * @version $Revision: 1.3 $ $Date: 2003/10/13 10:46:16 $
+ * @since 1.4.7
+ */
+public class SpaceException extends RuntimeException
+{
+ public SpaceException()
+ {
+ super();
+ }
+
+ public SpaceException(String message)
+ {
+ super(message);
+ }
+
+ public SpaceException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public SpaceException(Throwable cause)
+ {
+ super(cause);
+ }
+}

Added:
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/SpaceListener.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/SpaceListener.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.api;
+
+/**
+ * @author Alejandro Revilla
+ * @version $Revision: 1.2 $ $Date: 2002/08/06 14:26:32 $
+ * @since 2.0
+ * @see Space
+ */
+public interface SpaceListener
+{
+ /**
+ * <p>Called by Space implementation whenever an object
+ * with the given key is being placed in the Space.</p>
+ *
+ * @param key Object's key
+ * @param value Object's value
+ */
+ public void notify (Object key, Object value);
+}
+

Added:
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/Template.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/api/src/main/org/jpos/space/api/Template.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.api;
+
+public interface Template
+{
+ public Object getKey ();
+
+ public boolean equals (Object obj);
+}
+

Added: development/laboratory/planet/components/space/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/build.xml Sun Dec 12
20:42:44 2004
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space" default="default" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/reactor.xml"/>
+
+</project>

Added: development/laboratory/planet/components/space/index.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/index.xml Sun Dec 12
20:42:44 2004
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<index>
+ <import uri="artifact:module:dpml/metro/tools/dpml-metro-tools#SNAPSHOT" />
+ <import uri="artifact:module:dpml/metro/public/dpml-metro-public#SNAPSHOT"
/>
+
+ <resource>
+ <info>
+ <name>jdbm</name>
+ <group>jdbm</group>
+ <version>0.20-dev</version>
+ </info>
+ </resource>
+
+ <project basedir="api" >
+ <info>
+ <name>jpos-space-api</name>
+ <group>jpos/space</group>
+ <version>2.0</version>
+ </info>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
+ <project basedir="interceptor" >
+ <info>
+ <name>jpos-space-interceptor</name>
+ <group>jpos/space</group>
+ <version>2.0.0</version>
+ </info>
+ <dependencies>
+ <include key="jpos-space-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
+ <project basedir="jdbm" >
+ <info>
+ <name>jpos-space-jdbm</name>
+ <group>jpos/space</group>
+ <version>2.0.0</version>
+ </info>
+ <dependencies>
+ <include key="jpos-space-api" />
+ <include key="jdbm" />
+ <include key="dpml-parameters-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
+ <project basedir="persistent" >
+ <info>
+ <name>jpos-space-persistent</name>
+ <group>jpos/space</group>
+ <version>2.0.0</version>
+ </info>
+ <dependencies>
+ <include key="jpos-space-api" />
+ <include key="dpml-parameters-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
+ <project basedir="proxy" >
+ <info>
+ <name>jpos-space-proxy</name>
+ <group>jpos/space</group>
+ <version>2.0.0</version>
+ </info>
+ <dependencies>
+ <include key="dpml-activity-api" />
+ <include key="dpml-logging-api" />
+ <include key="dpml-parameters-api" />
+ <include key="dpml-service-api" />
+ <include key="jpos-space-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
+ <project basedir="tiny" >
+ <info>
+ <name>jpos-space-tiny</name>
+ <group>jpos/space</group>
+ <version>2.0.0</version>
+ </info>
+ <dependencies>
+ <include key="jpos-space-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
+ <project basedir="transient" >
+ <info>
+ <name>jpos-space-transient</name>
+ <group>jpos/space</group>
+ <version>2.0.0</version>
+ </info>
+ <dependencies>
+ <include key="jpos-space-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+
+ <project basedir="util" >
+ <info>
+ <name>jpos-space-util</name>
+ <group>jpos/space</group>
+ <version>2.0.0</version>
+ </info>
+ <dependencies>
+ <include key="jpos-space-api" />
+ <include key="dpml-parameters-api" />
+ <include key="dpml-service-api" />
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ </project>
+</index>

Added: development/laboratory/planet/components/space/interceptor/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/interceptor/build.xml
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space-interceptor" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/standard.xml"/>
+
+</project>

Added:
development/laboratory/planet/components/space/interceptor/src/main/org/jpos/space/interceptor/SpaceInterceptor.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/interceptor/src/main/org/jpos/space/interceptor/SpaceInterceptor.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.interceptor;
+
+import org.jpos.space.api.Space;
+
+/**
+ * Intercepts space operations.
+ *
+ * @author Alejandro Revilla
+ * @since 1.4.7
+ */
+public class SpaceInterceptor
+ implements Space
+{
+ protected Space sp;
+
+ public SpaceInterceptor( Space sp )
+ {
+ super();
+ this.sp = sp;
+ }
+
+ public void out( Object key, Object value )
+ {
+ sp.out( key, value );
+ }
+
+ public void out( Object key, Object value, long timeout )
+ {
+ sp.out( key, value, timeout );
+ }
+
+ public Object in( Object key )
+ {
+ return sp.in( key );
+ }
+
+ public Object rd( Object key )
+ {
+ return sp.rd( key );
+ }
+
+ public Object in( Object key, long timeout )
+ {
+ return sp.in( key, timeout );
+ }
+
+ public Object rd( Object key, long timeout )
+ {
+ return sp.rd( key, timeout );
+ }
+
+ public Object inp( Object key )
+ {
+ return sp.inp( key );
+ }
+
+ public Object rdp( Object key )
+ {
+ return sp.rdp( key );
+ }
+}
+

Added: development/laboratory/planet/components/space/jdbm/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/jdbm/build.xml Sun
Dec 12 20:42:44 2004
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space-jdbm" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/standard.xml"/>
+
+ <target name="build" depends="standard.build">
+ <x:block name="jdbm-space">
+ <x:service type="org.jpos.space.api.Space" source="space-impl" />
+ <x:component name="space-impl" class="org.jpos.space.jdbm.JDBMSpace" >
+ <x:parameters>
+ <x:parameter name="auto-commit" value="true" />
+ <x:parameter name="cache-size" value="512" />
+ <x:parameter name="store-filename" value="space-jdbm.records" />
+ </x:parameters>
+ </x:component>
+ </x:block>
+ </target>
+
+</project>

Added:
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/Head.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/Head.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.jdbm;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+
+final class Head
+ implements Externalizable
+{
+ static final long serialVersionUID = 3L;
+
+ long first;
+ long last;
+ long count;
+
+ Head()
+ {
+ first = -1;
+ last = -1;
+ }
+
+ public void writeExternal( ObjectOutput out )
+ throws IOException
+ {
+ out.writeLong( first );
+ out.writeLong( last );
+ out.writeLong( count );
+ }
+
+ public void readExternal( ObjectInput in )
+ throws IOException
+ {
+ first = in.readLong();
+ last = in.readLong();
+ count = in.readLong();
+ }
+
+ public String toString()
+ {
+ return getClass().getName()
+ + "@" + Integer.toHexString( hashCode() )
+ + ":[first=" + first
+ + ",last=" + last
+ + "]";
+ }
+}

Added:
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/JDBMSpace.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/JDBMSpace.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,626 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.jdbm;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import jdbm.RecordManager;
+import jdbm.RecordManagerFactory;
+import jdbm.RecordManagerOptions;
+
+import jdbm.helper.FastIterator;
+import jdbm.helper.Serializer;
+
+import jdbm.htree.HTree;
+
+import net.dpml.parameters.ParameterException;
+import net.dpml.parameters.Parameters;
+
+import org.jpos.space.api.Space;
+import org.jpos.space.api.SpaceException;
+import org.jpos.space.api.Template;
+
+/**
+ * JDBM based persistent space implementation
+ *
+ * @author Alejandro Revilla
+ * @author Kris Leite
+ * @version $Revision: 1.6 $ $Date: 2004/04/18 15:39:12 $
+ * @since 1.4.7
+ *
+ * @metro.component name="jdbm-space" lifestyle="singleton"
+ * @metro.service type="org.jpos.space.api.Space"
+ */
+final public class JDBMSpace
+ implements Space
+{
+ private HTree m_HTree;
+ private RecordManager m_RecordManager;
+
+ private boolean m_AutoCommit;
+ private Serializer m_RefSerializer;
+
+ public JDBMSpace( Parameters params )
+ throws ParameterException
+ {
+ m_AutoCommit = params.getParameterAsBoolean( "auto-commit" );
+ String filename = params.getParameter( "store-filename" );
+ int cachesize = params.getParameterAsInteger( "cache-size" );
+ m_RefSerializer = new RefSerializer();
+ try
+ {
+ Properties props = new Properties();
+ props.put( RecordManagerOptions.CACHE_SIZE, Integer.toString(
cachesize ) );
+ m_RecordManager = RecordManagerFactory.createRecordManager(
filename, props );
+ long recid = m_RecordManager.getNamedObject( "space" );
+ if( recid != 0 )
+ {
+ m_HTree = HTree.load( m_RecordManager, recid );
+ }
+ else
+ {
+ m_HTree = HTree.createInstance( m_RecordManager );
+ m_RecordManager.setNamedObject( "space", m_HTree.getRecid()
);
+ }
+ m_RecordManager.commit();
+ } catch( IOException e )
+ {
+ throw new SpaceException(e);
+ }
+ }
+
+ /**
+ * Use with utmost care and at your own risk.
+ *
+ * If you are to perform several operations on the space you
+ * should synchronize on the space, i.e:
+ * <pre>
+ * synchronized (sp) {
+ * sp.setAutoCommit (false);
+ * sp.out (..., ...)
+ * sp.out (..., ...)
+ * ...
+ * ...
+ * sp.inp (...);
+ * sp.commit (); // or sp.rollback ();
+ * sp.setAutoCommit (true);
+ * }
+ * </pre>
+ * @param b true or false
+ */
+ public void setAutoCommit( boolean b )
+ {
+ this.m_AutoCommit = b;
+ }
+
+ /**
+ * force commit
+ * @see setAutoCommit(boolean)
+ */
+ public void commit()
+ {
+ try
+ {
+ m_RecordManager.commit();
+ this.notifyAll();
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+
+ /**
+ * force rollback
+ * @see setAutoCommit(boolean)
+ */
+ public void rollback()
+ {
+ try
+ {
+ m_RecordManager.rollback();
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+
+ /**
+ * close this space - use with care
+ */
+ public void close()
+ {
+ synchronized( this )
+ {
+ try
+ {
+ m_RecordManager.close();
+ m_RecordManager = null;
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+ }
+
+ /**
+ * Write a new entry into the Space
+ * @param key Entry's key
+ * @param value Object value
+ */
+ public void out( Object key, Object value )
+ {
+ out( key, value, -1 );
+ }
+
+ /**
+ * Write a new entry into the Space
+ * The entry will timeout after the specified period
+ * @param key Entry's key
+ * @param value Object value
+ * @param timeout entry timeout in millis
+ */
+ public void out( Object key, Object value, long timeout )
+ {
+ try
+ {
+ synchronized( this )
+ {
+ long recid = m_RecordManager.insert( value );
+ long expiration;
+ if( timeout == -1 )
+ expiration = Long.MAX_VALUE;
+ else
+ expiration = System.currentTimeMillis() + timeout;
+
+ Ref dataRef = new Ref( recid, expiration );
+ long dataRefRecId = m_RecordManager.insert( dataRef,
m_RefSerializer );
+
+ Head head = (Head) m_HTree.get( key );
+ if( head == null )
+ {
+ head = new Head();
+ head.first = dataRefRecId;
+ head.last = dataRefRecId;
+ head.count = 1;
+ } else
+ {
+ long previousLast = head.last;
+ Ref lastRef = (Ref) m_RecordManager.fetch( previousLast,
m_RefSerializer );
+ lastRef.next = dataRefRecId;
+ head.last = dataRefRecId;
+ head.count++;
+ m_RecordManager.update( previousLast, lastRef,
m_RefSerializer );
+ }
+ m_HTree.put( key, head );
+ if( m_AutoCommit )
+ {
+ m_RecordManager.commit();
+ this.notifyAll();
+ }
+ }
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+
+ /**
+ * Read probe reads an entry from the space if one exists,
+ * return null otherwise.
+ * @param key Entry's key
+ * @return value or null
+ */
+ public synchronized Object rdp( Object key )
+ {
+ try
+ {
+ if( key instanceof Template )
+ return getObject( (Template) key, false );
+
+ Object obj = null;
+ Ref ref = getFirst( key, false );
+ if( ref != null )
+ obj = m_RecordManager.fetch( ref.recid );
+ if( m_AutoCommit )
+ m_RecordManager.commit();
+ return obj;
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+
+ /**
+ * In probe takes an entry from the space if one exists,
+ * return null otherwise.
+ * @param key Entry's key
+ * @return value or null
+ */
+ public synchronized Object inp( Object key )
+ {
+ try
+ {
+ if (key instanceof Template)
+ return getObject ((Template) key, true);
+
+ Object obj = null;
+ Ref ref = getFirst( key, true );
+ if( ref != null )
+ {
+ obj = m_RecordManager.fetch( ref.recid );
+ m_RecordManager.delete( ref.recid );
+ }
+ if( m_AutoCommit )
+ m_RecordManager.commit();
+ return obj;
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+
+ public synchronized Object in( Object key )
+ {
+ Object obj = inp( key );
+ while( obj == null )
+ {
+ try
+ {
+ this.wait();
+ } catch( InterruptedException e )
+ {}
+ obj = inp( key );
+ }
+ return obj;
+ }
+
+ /**
+ * Take an entry from the space, waiting forever until one exists.
+ * @param key Entry's key
+ * @return value
+ */
+ public synchronized Object in( Object key, long timeout )
+ {
+ Object obj = inp( key );
+ long now = System.currentTimeMillis();
+ long end = now + timeout;
+ while( obj == null && now < end )
+ {
+ try
+ {
+ this.wait( end - now );
+ } catch (InterruptedException e)
+ {}
+ obj = inp( key );
+ now = System.currentTimeMillis();
+ }
+ return obj;
+ }
+
+ /**
+ * Read an entry from the space, waiting forever until one exists.
+ * @param key Entry's key
+ * @return value
+ */
+ public synchronized Object rd( Object key )
+ {
+ Object obj = rdp( key );
+ while( obj == null )
+ {
+ try
+ {
+ this.wait();
+ } catch( InterruptedException e )
+ {}
+ obj = rdp( key );
+ }
+ return obj;
+ }
+
+ /**
+ * Read an entry from the space, waiting a limited amount of time
+ * until one exists.
+ * @param key Entry's key
+ * @param timeout millis to wait
+ * @return value or null
+ */
+ public synchronized Object rd( Object key, long timeout )
+ {
+ Object obj = rdp( key );
+ long now = System.currentTimeMillis();
+ long end = now + timeout;
+ while( obj == null && now < end )
+ {
+ try
+ {
+ this.wait( end - now );
+ } catch (InterruptedException e)
+ {}
+ obj = rdp( key );
+ now = System.currentTimeMillis();
+ }
+ return obj;
+ }
+
+ /**
+ * @return aproximately queue size
+ */
+ public long size( Object key )
+ {
+ try
+ {
+ Head head = (Head) m_HTree.get( key );
+ if( head == null )
+ return 0;
+ return head.count;
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+
+ private void purge( Object key )
+ throws IOException
+ {
+ Head head = (Head) m_HTree.get( key );
+ Ref ref;
+ Ref previousRef = null;
+ if( head != null )
+ {
+ for( long recid = head.first ; recid >= 0 ; )
+ {
+ Ref r = (Ref) m_RecordManager.fetch( recid, m_RefSerializer
);
+ if( r.isExpired() )
+ {
+ m_RecordManager.delete( r.recid );
+ m_RecordManager.delete( recid );
+ head.count--;
+ if( previousRef == null )
+ {
+ head.first = r.next;
+ } else
+ {
+ previousRef.next = r.next;
+ m_RecordManager.update( head.last, previousRef,
m_RefSerializer );
+ }
+ } else
+ {
+ previousRef = r;
+ head.last = recid;
+ }
+ recid = r.next;
+ }
+ if( head.first == -1 )
+ {
+ m_HTree.remove (key);
+ }
+ else
+ {
+ m_HTree.put( key, head );
+ }
+ }
+ }
+
+ /**
+ * garbage collector.
+ * removes expired entries
+ */
+ public void gc()
+ {
+ final String GCKEY = "GC$" + Integer.toString( hashCode() );
+ final long TIMEOUT = 24 * 3600 * 1000;
+ try
+ {
+ FastIterator iter = m_HTree.keys();
+ Object obj = Boolean.TRUE;
+
+ // avoid ConcurrentModificationException in Head
+ out( GCKEY, obj, TIMEOUT );
+
+ obj = iter.next();
+ while( obj != null)
+ {
+ out( GCKEY, obj, TIMEOUT );
+ Thread.yield();
+ obj = iter.next();
+ }
+ obj = inp( GCKEY );
+ while( obj != null )
+ {
+ synchronized( this )
+ {
+ purge( obj );
+ m_RecordManager.commit();
+ }
+ Thread.yield();
+ obj = inp( GCKEY );
+ }
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+
+ public String getKeys()
+ {
+ StringBuffer sb = new StringBuffer();
+ try
+ {
+ FastIterator iter = m_HTree.keys();
+ Object obj = iter.next();
+ while ( obj != null)
+ {
+ if( sb.length() > 0 )
+ sb.append( ' ' );
+ sb.append( obj.toString() );
+ obj = iter.next();
+ }
+ } catch( IOException e )
+ {
+ throw new SpaceException( e );
+ }
+ return sb.toString();
+ }
+
+ private Ref getFirst( Object key, boolean remove )
+ throws IOException
+ {
+ Head head = (Head) m_HTree.get( key );
+ Ref ref = null;
+ if( head != null )
+ {
+ long recid;
+ for( recid = head.first ; recid >= 0 ; )
+ {
+ Ref r = (Ref) m_RecordManager.fetch( recid, m_RefSerializer
);
+ if( r.isExpired() )
+ {
+ m_RecordManager.delete( r.recid );
+ m_RecordManager.delete( recid );
+ recid = r.next;
+ head.count--;
+ } else
+ {
+ ref = r;
+ if (remove)
+ {
+ m_RecordManager.delete( recid );
+ recid = ref.next;
+ head.count--;
+ }
+ break;
+ }
+ }
+ if( head.first != recid )
+ {
+ if( recid < 0 )
+ m_HTree.remove( key );
+ else
+ {
+ head.first = recid;
+ m_HTree.put( key, head );
+ }
+ }
+ }
+ return ref;
+ }
+
+ private void unlinkRef
+ ( long recid, Head head, Ref r, Ref previousRef, long previousRecId
)
+ throws IOException
+ {
+ m_RecordManager.delete( r.recid );
+ m_RecordManager.delete( recid );
+ head.count--;
+ if( previousRef == null )
+ head.first = r.next;
+ else
+ {
+ previousRef.next = r.next;
+ m_RecordManager.update( previousRecId, previousRef,
m_RefSerializer );
+ }
+ }
+
+ private Object getObject( Template tmpl, boolean remove )
+ throws IOException
+ {
+ Object obj = null;
+ Object key = tmpl.getKey();
+ Head head = (Head) m_HTree.get( key );
+ Ref ref;
+ Ref previousRef = null;
+ long previousRecId = 0;
+ int unlinkCount = 0;
+ if( head != null )
+ {
+ for( long recid = head.first ; recid >= 0 ; )
+ {
+ Ref r = (Ref) m_RecordManager.fetch( recid, m_RefSerializer
);
+ if( r.isExpired() )
+ {
+ unlinkRef( recid, head, r, previousRef, previousRecId );
+ unlinkCount++;
+ } else
+ {
+ Object o = m_RecordManager.fetch( r.recid );
+ if( o != null )
+ {
+ if( tmpl.equals( o ) )
+ {
+ obj = o;
+ if( remove )
+ {
+ unlinkRef( recid, head, r, previousRef,
previousRecId );
+ unlinkCount++;
+ }
+ break;
+ }
+ }
+ previousRef = r;
+ previousRecId = recid;
+ }
+ recid = r.next;
+ }
+ if( unlinkCount > 0 )
+ {
+ if( head.first == -1 )
+ {
+ m_HTree.remove( key );
+ }
+ else
+ {
+ m_HTree.put( key, head );
+ }
+ }
+ }
+ return obj;
+ }
+}

Added:
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/MD5Template.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/MD5Template.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.jdbm;
+
+import java.util.Arrays;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.io.Serializable;
+
+import jdbm.helper.DefaultSerializer;
+
+import org.jpos.space.api.SpaceException;
+import org.jpos.space.api.Template;
+
+
+public class MD5Template
+ implements Template, Serializable
+{
+ private byte[] digest;
+ private Object key;
+
+ public MD5Template( Object key, Object value )
+ {
+ super();
+ this.key = key;
+ this.digest = digest( value );
+ }
+
+ public MD5Template( Object key, byte[] digest )
+ {
+ super();
+ this.key = key;
+ this.digest = digest;
+ }
+
+ public static byte[] digest( Object obj )
+ {
+ try
+ {
+ MessageDigest md = MessageDigest.getInstance( "MD5" );
+ return md.digest( DefaultSerializer.INSTANCE.serialize( obj ) );
+ } catch( Exception e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+
+ public boolean equals( Object obj )
+ {
+ return Arrays.equals( digest( obj ), digest );
+ }
+
+ public Object getKey()
+ {
+ return key;
+ }
+}
+

Added:
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/Ref.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/Ref.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.jdbm;
+
+final class Ref
+{
+ long recid;
+ long expires;
+ long next;
+
+ public Ref( long recid, long expires )
+ {
+ this.recid = recid;
+ this.expires = expires;
+ this.next = -1;
+ }
+
+ public boolean isExpired()
+ {
+ return expires < System.currentTimeMillis();
+ }
+
+ public String toString()
+ {
+ return getClass().getName()
+ + "@" + Integer.toHexString( hashCode() )
+ + ":[recid=" + recid
+ + ",next=" + next
+ + ",expired=" + isExpired()
+ + "]";
+ }
+}

Added:
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/RefSerializer.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/jdbm/src/main/org/jpos/space/RefSerializer.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.jdbm;
+
+import java.io.IOException;
+
+import jdbm.helper.Serializer;
+
+final class RefSerializer
+ implements Serializer
+{
+ public byte[] serialize( Object obj )
+ throws IOException
+ {
+ Ref d = (Ref) obj;
+
+ byte[] buf = new byte[ 24 ];
+ putLong( buf, 0, d.recid );
+ putLong( buf, 8, d.next );
+ putLong( buf, 16, d.expires );
+ return buf;
+ }
+
+ public Object deserialize( byte[] serialized )
+ throws IOException
+ {
+ long recid = getLong( serialized, 0 );
+ long next = getLong( serialized, 8 );
+ long expires = getLong( serialized, 16 );
+ Ref d = new Ref( recid, expires );
+ d.next = next;
+ return d;
+ }
+
+ private void putLong( byte[] b, int off, long val )
+ {
+ b[ off + 7 ] = (byte) ( val >>> 0 );
+ b[ off + 6 ] = (byte) ( val >>> 8 );
+ b[ off + 5 ] = (byte) ( val >>> 16 );
+ b[ off + 4 ] = (byte) ( val >>> 24 );
+ b[ off + 3 ] = (byte) ( val >>> 32 );
+ b[ off + 2 ] = (byte) ( val >>> 40 );
+ b[ off + 1 ] = (byte) ( val >>> 48 );
+ b[ off + 0 ] = (byte) ( val >>> 56 );
+ }
+
+ private long getLong( byte[] b, int off )
+ {
+ return ( ( b[ off + 7 ] & 0xFFL ) << 0 ) +
+ ( ( b[ off + 6 ] & 0xFFL ) << 8 ) +
+ ( ( b[ off + 5 ] & 0xFFL ) << 16 ) +
+ ( ( b[ off + 4 ] & 0xFFL ) << 24 ) +
+ ( ( b[ off + 3 ] & 0xFFL ) << 32 ) +
+ ( ( b[ off + 2 ] & 0xFFL ) << 40 ) +
+ ( ( b[ off + 1 ] & 0xFFL ) << 48 ) +
+ ( ( b[ off + 0 ] & 0xFFL ) << 56 );
+ }
+}

Added: development/laboratory/planet/components/space/persistent/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/persistent/build.xml Sun
Dec 12 20:42:44 2004
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space-persistent" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/standard.xml"/>
+
+ <target name="build" depends="standard.build" >
+ <x:block name="persistent-space" >
+ <x:service type="org.jpos.space.Space" source="space-impl" />
+ <x:component name="space-impl"
class="org.jpos.space.persistent.PersistentSpace" >
+ <x:parameters>
+ <x:parameter name="cache-size" value="16" />
+ </x:parameters>
+ </x:component>
+ </x:block>
+ </target>
+</project>

Added:
development/laboratory/planet/components/space/persistent/src/main/org/jpos/space/persistent/Data.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/persistent/src/main/org/jpos/space/persistent/Data.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.persistent;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilenameFilter;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jpos.space.api.LeasedReference;
+import org.jpos.space.api.SpaceException;
+import org.jpos.space.api.SpaceListener;
+
+final class Data
+{
+ private LinkedList data;
+ private LinkedList stored;
+ private LinkedList listeners;
+ private File dir;
+ private int m_CacheSize;
+
+ protected Data( Object name, int cachesize )
+ {
+ super();
+ m_CacheSize = cachesize;
+ data = new LinkedList();
+ stored = new LinkedList();
+ listeners = null;
+ String n = "space" + File.separatorChar;
+ if( name instanceof String )
+ n += name;
+ else
+ n += "H" + name.hashCode();
+ dir = new File( n );
+ dir.mkdirs();
+ FilenameFilter filter = new FilenameFilter()
+ {
+ public boolean accept( File f, String name )
+ {
+ return name.toUpperCase().startsWith( "S" );
+ }
+ };
+ File file[] = dir.listFiles( filter );
+ Arrays.sort( file );
+ for( int i = 0; file.length > i; i++ )
+ {
+ if( m_CacheSize > data.size() )
+ {
+ Object value = readValue( file[i].getAbsolutePath() );
+ if( value == null )
+ {
+ file[i].getAbsoluteFile().delete();
+ } else
+ {
+ stored.add( file[i].getAbsolutePath() );
+ data.add( value );
+ }
+ } else
+ {
+ stored.add( file[i].getAbsolutePath() );
+ }
+ }
+ }
+
+ private Object readValue( String f )
+ {
+ Object value = null;
+ ObjectInputStream ois = null;
+ try
+ {
+ FileInputStream fis = new FileInputStream( f );
+ BufferedInputStream bis = new BufferedInputStream( fis );
+ ois = new ObjectInputStream( bis );
+ value = ois.readObject();
+ } catch (Exception e)
+ {
+ throw new SpaceException( e );
+ } finally
+ {
+ if( ois != null )
+ {
+ try
+ {
+ ois.close();
+ } catch( Exception e )
+ {
+ throw new SpaceException( e );
+ }
+ }
+ }
+ return value;
+ }
+
+ protected File createTempFile( String prefex, File dir )
+ {
+ long t = System.currentTimeMillis();
+ File f = null;
+ do
+ {
+ String fn = prefex + Long.toHexString(t);
+ t = t + 1;
+ f = new File( dir, fn );
+ } while( f.exists() );
+ return f;
+ }
+
+ protected void add( Object value )
+ {
+ File f = null;
+ FileOutputStream fos = null;
+ try
+ {
+ f = createTempFile( "S", dir );
+ fos = new FileOutputStream( f );
+ BufferedOutputStream bos = new BufferedOutputStream( fos );
+ ObjectOutputStream fout = new ObjectOutputStream( bos );
+ fout.writeObject( value );
+ fout.flush();
+ fos.getFD().sync();
+ } catch( Exception e )
+ {
+ throw new SpaceException( e );
+ } finally
+ {
+ if( fos != null )
+ {
+ try
+ {
+ fos.close();
+ } catch( Exception e )
+ {
+ throw new SpaceException( e );
+ };
+ }
+ }
+ stored.add( f.getAbsolutePath() );
+ /* fill cache */
+ if( m_CacheSize > data.size () )
+ {
+ if( ( data.size() + 1 ) == stored.size () )
+ {
+ data.add( value );
+ }
+ }
+ }
+
+ protected Object get( Object value )
+ {
+ Object obj = null;
+ while( size() > 0 )
+ {
+ obj = getFirst();
+ if( obj instanceof LeasedReference )
+ obj = ((LeasedReference) obj).get();
+ if( obj == null )
+ {
+ data.removeFirst();
+ String filename = (String) stored.removeFirst();
+ File f = new File( filename );
+ f.delete();
+ continue;
+ }
+ break;
+ }
+ return obj;
+ }
+
+ protected Object getFirst()
+ {
+ Object object = null;
+ if( data.size() > 0 )
+ {
+ object = data.getFirst();
+ } else if( stored.size() > 0 )
+ {
+ object = readValue( (String) stored.getFirst() );
+ }
+ return object;
+ }
+
+ protected int size()
+ {
+ return stored.size();
+ }
+
+ protected Object remove()
+ {
+ Object obj = null;
+ File f = null;
+ while( size() > 0 )
+ {
+ obj = getFirst();
+ if( data.size () > 0 )
+ data.removeFirst();
+ String filename = (String) stored.removeFirst();
+ f = new File( filename );
+ f.delete();
+ if( obj instanceof LeasedReference )
+ {
+ LeasedReference ref = (LeasedReference) obj;
+ obj = ref.get ();
+ if( obj == null )
+ {
+ continue;
+ }
+ ref.discard();
+ }
+ break;
+ }
+ return obj;
+ }
+
+ protected boolean isEmpty()
+ {
+ return stored.isEmpty() && listeners == null;
+ }
+
+ protected void addListener( SpaceListener listener )
+ {
+ if( listeners == null )
+ listeners = new LinkedList();
+ listeners.add( listener );
+ }
+
+ protected void removeListener( SpaceListener listener )
+ {
+ if( listeners != null )
+ {
+ listeners.remove( listener );
+ if( listeners.isEmpty() )
+ listeners = null;
+ }
+ }
+
+ protected List getListeners ()
+ {
+ return listeners;
+ }
+}
+
+

Added:
development/laboratory/planet/components/space/persistent/src/main/org/jpos/space/persistent/PersistentSpace.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/persistent/src/main/org/jpos/space/persistent/PersistentSpace.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.persistent;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import net.dpml.parameters.ParameterException;
+import net.dpml.parameters.Parameters;
+
+import org.jpos.space.api.LeasedReference;
+import org.jpos.space.api.LocalSpace;
+import org.jpos.space.api.SpaceException;
+import org.jpos.space.api.SpaceListener;
+
+/**
+ * Persistent Space implementation
+ * @author Alejandro Revilla, modified by Kris Leite for Persistent
+ * @version $Revision: 1.13 $ $Date: 2003/10/01 13:50:37 $
+ * @since 2.0
+ *
+ * @metro.component name="persistent-space" lifestyle="singleton"
+ * @metro.service type="org.jpos.space.api.LocalSpace"
+ * @metro.service type="org.jpos.space.api.Space"
+ */
+final public class PersistentSpace
+ implements LocalSpace
+{
+ private HashMap m_Map;
+ private int m_CacheSize;
+
+ public PersistentSpace( Parameters params )
+ throws ParameterException
+ {
+ m_Map = new HashMap();
+ m_CacheSize = params.getParameterAsInteger( "cache-size" );
+ }
+
+ public synchronized void setCacheSize( int cacheSize )
+ {
+ m_CacheSize = cacheSize;
+ }
+
+ public void out( Object key, Object value )
+ {
+ List listeners;
+ synchronized( this )
+ {
+ Data data = (Data) m_Map.get( key );
+ if( data == null )
+ {
+ data = new Data( key, m_CacheSize );
+ m_Map.put( key, data );
+ }
+ data.add( value );
+ listeners = data.getListeners();
+ this.notifyAll ();
+ }
+ if( listeners != null )
+ {
+ Iterator iter = listeners.iterator();
+ while( iter.hasNext() )
+ {
+ SpaceListener listener = (SpaceListener) iter.next();
+ listener.notify( key, value );
+ }
+ }
+ }
+
+ public void out( Object id, Object value, long timeout )
+ {
+ LeasedReference ref = new LeasedReference( value, timeout );
+ out( id, ref );
+ }
+
+ public synchronized int size( Object key )
+ {
+ Data data = (Data) m_Map.get( key );
+ if( data == null )
+ {
+ data = new Data( key, m_CacheSize );
+ m_Map.put( key, data );
+ }
+ return data.size();
+ }
+
+ public synchronized Object rdp( Object key )
+ {
+ Data data = (Data) m_Map.get( key );
+ if( data == null )
+ {
+ data = new Data( key, m_CacheSize );
+ m_Map.put( key, data );
+ }
+ return data.get( key );
+ }
+
+ public synchronized Object inp( Object key )
+ {
+ Data data = (Data) m_Map.get( key );
+ if( data == null )
+ {
+ data = new Data( key, m_CacheSize );
+ m_Map.put( key, data );
+ }
+ return data.remove();
+ }
+
+ public synchronized Object in( Object key )
+ {
+ Object obj = inp( key );
+ while( obj == null)
+ {
+
+ try
+ {
+ this.wait();
+ } catch( InterruptedException e )
+ {}
+ obj = inp( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object in( Object key, long timeout )
+ {
+ Object obj = inp( key );
+ long now = System.currentTimeMillis();
+ long end = now + timeout;
+
+ while( obj == null && now < end )
+ {
+ try
+ {
+ this.wait( end - now );
+ } catch( InterruptedException e )
+ {}
+ obj = inp (key);
+ now = System.currentTimeMillis();
+ }
+ return obj;
+ }
+
+ public synchronized Object rd( Object key )
+ {
+ Object obj = rdp( key );
+ while( obj == null )
+ {
+ try
+ {
+ this.wait();
+ } catch( InterruptedException e )
+ {}
+ obj = rdp( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object rd( Object key, long timeout )
+ {
+ Object obj = rdp( key );
+ long now = System.currentTimeMillis();
+ long end = now + timeout;
+
+ while( obj == null && now < end )
+ {
+ try
+ {
+ this.wait( end - now );
+ } catch( InterruptedException e )
+ {}
+ obj = rdp( key );
+ now = System.currentTimeMillis();
+ }
+ return obj;
+ }
+
+ public synchronized void addListener( Object key, SpaceListener listener
)
+ {
+ Data data = (Data) m_Map.get( key );
+ if( data == null )
+ {
+ data = new Data( key, m_CacheSize );
+ m_Map.put( key, data );
+ }
+ data.addListener( listener );
+ }
+
+ public synchronized void removeListener( Object key, SpaceListener
listener)
+ {
+ Data data = (Data) m_Map.get( key );
+ if (data != null)
+ data.removeListener( listener );
+ }
+
+ public Set getKeySet()
+ {
+ synchronized( this )
+ {
+ return m_Map.keySet();
+ }
+ }
+
+ public String getKeys()
+ {
+ StringBuffer sb = new StringBuffer();
+ Iterator iter = m_Map.keySet().iterator();
+ boolean first = true;
+ while( iter.hasNext() )
+ {
+ if( ! first )
+ sb.append( ' ' );
+ else
+ first = false;
+ sb.append( iter.next().toString() );
+ }
+ return sb.toString();
+ }
+
+ public void write( String key, String value )
+ {
+ out( key, value );
+ }
+
+ public String read( String key )
+ {
+ Object o = inp( key );
+ if( o == null )
+ return "null";
+ return o.toString();
+ }
+}

Added: development/laboratory/planet/components/space/proxy/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/proxy/build.xml Sun
Dec 12 20:42:44 2004
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space-proxy" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/standard.xml"/>
+
+</project>

Added:
development/laboratory/planet/components/space/proxy/src/main/org/jpos/space/proxy/SpaceRemoteServer.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/proxy/src/main/org/jpos/space/proxy/SpaceRemoteServer.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.proxy;
+
+import java.io.Serializable;
+
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.ExportException;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteServer;
+import java.rmi.server.RemoteStub;
+import java.rmi.server.UnicastRemoteObject;
+
+import java.util.Set;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import net.dpml.activity.Startable;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.parameters.ParameterException;
+import net.dpml.parameters.Parameters;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+
+import org.jpos.space.api.Space;
+import org.jpos.space.api.RemoteSpace;
+
+/**
+ * RMI Space Proxy
+ * @author Alejandro Revilla
+ * @version $Revision: 1.7 $ $Date: 2003/10/18 12:44:55 $
+ * @since 2.0
+ *
+ * @metro.component name="space-proxy" lifestyle="singleton"
+ * @metro.service type="org.jpos.space.api.RemoteSpace"
+ */
+public class SpaceRemoteServer extends RemoteServer
+ implements RemoteSpace, Startable
+{
+ private Space m_Space;
+ private String m_ContextName;
+ private Logger m_Logger;
+ private RemoteRef m_RemoteRef;
+
+ /**
+ * @metro.dependency type="org.jpos.space.api.Space" key="space"
+ */
+ public SpaceRemoteServer( Parameters params, Logger logger,
ServiceManager man )
+ throws RemoteException, ServiceException, ParameterException
+ {
+ m_ContextName = params.getParameter( "name" );
+ m_Space = (Space) man.lookup( "space" );
+ m_Logger = logger;
+ }
+
+ public void start()
+ throws RemoteException
+ {
+ RemoteStub stub = UnicastRemoteObject.exportObject( this );
+ m_RemoteRef = stub.getRef();
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ ctx.rebind( m_ContextName, stub );
+ } catch( NamingException e )
+ {
+ m_Logger.error( "Unable to bind the RemoteSpace.", e );
+ }
+ }
+
+ public void stop()
+ {
+ try
+ {
+ boolean success = UnicastRemoteObject.unexportObject( this,
false );
+ if( success )
+ return;
+ Thread.sleep (5000);
+ UnicastRemoteObject.unexportObject( this, true );
+ } catch( Exception e )
+ {
+ // nothing to do .. we're shutting down ...
+ }
+ }
+
+ public void out( Serializable key, Serializable value )
+ {
+ m_Space.out( key, value );
+ }
+
+ public void out( Serializable key, Serializable value, long timeout )
+ {
+ m_Space.out( key, value, timeout );
+ }
+
+ public Serializable in( Serializable key )
+ {
+ return (Serializable) m_Space.in( key );
+ }
+
+ public Serializable rd( Serializable key )
+ {
+ return (Serializable) m_Space.rd( key );
+ }
+
+ public Serializable in( Serializable key, long timeout )
+ {
+ return (Serializable) m_Space.in( key, timeout );
+ }
+
+ public Serializable rd( Serializable key, long timeout )
+ {
+ return (Serializable) m_Space.rd( key, timeout );
+ }
+
+ public Serializable inp( Serializable key )
+ {
+ return (Serializable) m_Space.inp( key );
+ }
+
+ public Serializable rdp( Serializable key )
+ {
+ return (Serializable) m_Space.rdp( key );
+ }
+}
+

Added: development/laboratory/planet/components/space/tiny/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/tiny/build.xml Sun
Dec 12 20:42:44 2004
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space-tiny" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/standard.xml"/>
+
+ <target name="build" depends="standard.build">
+ <x:block name="tiny-space">
+ <x:service type="org.jpos.space.api.LocalSpace" source="space-impl" />
+ <x:component name="space-impl" class="org.jpos.space.tiny.Tinypace" />
+ </x:block>
+ </target>
+
+</project>

Added:
development/laboratory/planet/components/space/tiny/src/main/org/jpos/space/tiny/Data.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/tiny/src/main/org/jpos/space/tiny/Data.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.tiny;
+
+import java.util.LinkedList;
+
+import org.jpos.space.api.LeasedReference;
+
+final class Data
+{
+ LinkedList data;
+
+ Data()
+ {
+ super();
+ data = new LinkedList();
+ }
+
+ protected Data( Object value )
+ {
+ this ();
+ add (value);
+ }
+
+ protected void add( Object value )
+ {
+ data.add (value);
+ }
+
+ protected Object get( Object value )
+ {
+ Object obj = null;
+ while( size() > 0 )
+ {
+ obj = data.getFirst();
+ if( obj instanceof LeasedReference )
+ {
+ LeasedReference ref = (LeasedReference) obj;
+ obj = ref.get();
+ if( obj == null )
+ {
+ data.removeFirst();
+ continue;
+ }
+ }
+ break;
+ }
+ return obj;
+ }
+
+ protected int size()
+ {
+ return data.size();
+ }
+
+ protected Object remove()
+ {
+ Object obj = null;
+ while( size() > 0 )
+ {
+ obj = data.removeFirst();
+ if( obj instanceof LeasedReference )
+ {
+ LeasedReference ref = (LeasedReference) obj;
+ obj = ref.get();
+ if( obj == null )
+ {
+ continue;
+ }
+ ref.discard();
+ }
+ break;
+ }
+ return obj;
+ }
+
+ protected boolean isEmpty()
+ {
+ return data.isEmpty();
+ }
+}
+

Added:
development/laboratory/planet/components/space/tiny/src/main/org/jpos/space/tiny/TinySpace.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/tiny/src/main/org/jpos/space/tiny/TinySpace.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.tiny;
+
+import java.util.HashMap;
+
+import java.io.Serializable;
+
+import org.jpos.space.api.LeasedReference;
+import org.jpos.space.api.Space;
+
+/**
+ * Tiny Space implementation
+ *
+ * @author Alejandro Revilla
+ * @version $Revision: 1.2 $ $Date: 2003/12/30 21:19:26 $
+ * @since 1.4.7
+ *
+ * @metro.component name="tiny-space" lifestyle="singleton"
+ * @metro.service type="org.jpos.space.api.Space"
+ */
+public class TinySpace
+ implements Space, Serializable
+{
+ protected HashMap map = new HashMap();
+
+ public TinySpace()
+ {
+ super();
+ }
+
+ public void out( Object key, Object value )
+ {
+ synchronized( this )
+ {
+ Object v = map.get( key );
+ if( v == null )
+ map.put( key, value );
+ else if( v instanceof Data )
+ ((Data) v).add( value );
+ else
+ {
+ Data data = new Data();
+ data.add( v );
+ data.add( value );
+ map.put( key, data );
+ }
+ this.notifyAll();
+ }
+ }
+
+ public void out( Object id, Object value, long timeout )
+ {
+ LeasedReference ref = new LeasedReference( value, timeout );
+ out( id, ref );
+ }
+
+ public synchronized Object rdp( Object key )
+ {
+ Object obj = map.get( key );
+ if( obj instanceof Data )
+ {
+ Data data = (Data) obj;
+ obj = data.get( key );
+ }
+ else if( obj instanceof LeasedReference )
+ {
+ LeasedReference ref = (LeasedReference) obj;
+ obj = ref.get();
+ }
+ return obj;
+ }
+
+ public synchronized Object inp( Object key )
+ {
+ Object obj = map.get( key );
+ if( obj instanceof Data )
+ {
+ Data data = (Data) obj;
+ obj = data.remove();
+ if( data.isEmpty () )
+ map.remove( key );
+ } else if( obj != null )
+ {
+ if( obj instanceof LeasedReference )
+ {
+ LeasedReference ref = (LeasedReference) obj;
+ obj = ref.get();
+ }
+ map.remove( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object in( Object key )
+ {
+ Object obj = inp( key );
+ while( obj == null)
+ {
+ try
+ {
+ this.wait();
+ } catch( InterruptedException e )
+ {}
+ obj = inp( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object in( Object key, long timeout )
+ {
+ Object obj = inp( key );
+ long now = System.currentTimeMillis();
+ long end = now + timeout;
+ while( obj == null && now < end )
+ {
+ try
+ {
+ this.wait( end - now );
+ } catch( InterruptedException e )
+ {}
+ obj = inp( key );
+ now = System.currentTimeMillis();
+ }
+ return obj;
+ }
+
+ public synchronized Object rd( Object key )
+ {
+ Object obj = rdp( key );
+ while( obj == null )
+ {
+ try
+ {
+ this.wait();
+ } catch( InterruptedException e )
+ {}
+ obj = rdp( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object rd( Object key, long timeout )
+ {
+ Object obj = rdp( key );
+ long now = System.currentTimeMillis();
+ long end = now + timeout;
+ while( obj == null && now < end )
+ {
+ try
+ {
+ this.wait( end - now );
+ } catch( InterruptedException e )
+ {}
+ obj = rdp( key );
+ now = System.currentTimeMillis();
+ }
+ return obj;
+ }
+}
+

Added: development/laboratory/planet/components/space/transient/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/transient/build.xml Sun
Dec 12 20:42:44 2004
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space-transient" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/standard.xml"/>
+
+ <target name="build" depends="standard.build">
+ <x:block name="transient-space">
+ <x:service type="org.jpos.space.api.LocalSpace" source="space-impl" />
+ <x:component name="space-impl"
class="org.jpos.space.transiient.TransientSpace" />
+ </x:block>
+ </target>
+</project>

Added:
development/laboratory/planet/components/space/transient/src/main/org/jpos/space/transiient/Data.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/transient/src/main/org/jpos/space/transiient/Data.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.transiient;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jpos.space.api.LeasedReference;
+import org.jpos.space.api.SpaceListener;
+
+final class Data
+{
+ private LinkedList data;
+ private LinkedList listeners;
+
+ Data()
+ {
+ super();
+ data = new LinkedList();
+ listeners = null;
+ }
+
+ void add( Object value )
+ {
+ data.add( value );
+ }
+
+ Object get( Object value )
+ {
+ Object obj = null;
+ while( size() > 0 )
+ {
+ obj = data.getFirst();
+ if( obj instanceof LeasedReference )
+ {
+ LeasedReference ref = (LeasedReference) obj;
+ obj = ref.get();
+ if( obj == null )
+ {
+ data.removeFirst();
+ continue;
+ }
+ }
+ break;
+ }
+ return obj;
+ }
+
+ int size()
+ {
+ return data.size();
+ }
+
+ Object remove()
+ {
+ Object obj = null;
+ while( size() > 0 )
+ {
+ obj = data.removeFirst();
+ if( obj instanceof LeasedReference )
+ {
+ LeasedReference ref = (LeasedReference) obj;
+ obj = ref.get();
+ if( obj == null )
+ {
+ continue;
+ }
+ ref.discard();
+ }
+ break;
+ }
+ return obj;
+ }
+
+ boolean isEmpty()
+ {
+ return data.isEmpty() && listeners == null;
+ }
+
+ void addListener( SpaceListener listener )
+ {
+ if (listeners == null)
+ listeners = new LinkedList();
+ listeners.add( listener );
+ }
+
+ void removeListener( SpaceListener listener )
+ {
+ if( listeners != null )
+ {
+ listeners.remove( listener );
+ if( listeners.isEmpty() )
+ listeners = null;
+ }
+ }
+
+ List getListeners()
+ {
+ return listeners;
+ }
+}
+

Added:
development/laboratory/planet/components/space/transient/src/main/org/jpos/space/transiient/TransientSpace.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/transient/src/main/org/jpos/space/transiient/TransientSpace.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,289 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.transiient;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.jpos.space.api.LeasedReference;
+import org.jpos.space.api.LocalSpace;
+import org.jpos.space.api.SpaceListener;
+
+/**
+ * Transient Space implementation
+ * @author Alejandro Revilla
+ * @version $Revision: 1.10 $ $Date: 2003/10/01 13:15:44 $
+ * @since 2.0
+ * @jmx:mbean description "TransientSpace"
+ *
+ * @metro.component name="transient-space" lifestyle="singleton"
+ * @metro.service type="org.jpos.space.api.LocalSpace"
+ * @metro.service type="org.jpos.space.api.Space"
+ */
+public class TransientSpace
+ implements LocalSpace //, TransientSpaceMBean Niclas: Doesn't exist
+{
+ protected HashMap map;
+
+ /**
+ * @jmx:managed-constructor description="Default Constructor"
+ */
+ public TransientSpace()
+ {
+ map = new HashMap();
+ }
+
+ public void out( Object key, Object value )
+ {
+ List listeners;
+ synchronized( this )
+ {
+ Data data = (Data) map.get( key );
+ if( data == null )
+ {
+ data = new Data();
+ map.put( key, data );
+ }
+ data.add( value );
+ this.notifyAll();
+ listeners = data.getListeners();
+ }
+ if( listeners != null )
+ {
+ Iterator iter = listeners.iterator();
+ while( iter.hasNext() )
+ {
+ SpaceListener listener = (SpaceListener) iter.next();
+ listener.notify( key, value );
+ }
+ }
+ }
+
+ public void out( Object id, Object value, long timeout )
+ {
+ LeasedReference ref = new LeasedReference( value, timeout );
+ out( id, ref );
+ }
+
+ public synchronized Object rdp( Object key )
+ {
+ Object obj = null;
+ Data data = (Data) map.get( key );
+ if( data != null )
+ {
+ return data.get( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object inp( Object key )
+ {
+ Object obj = null;
+ Data data = (Data) map.get( key );
+ if( data != null )
+ {
+ obj = data.remove();
+ if( data.isEmpty() )
+ map.remove( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object in( Object key )
+ {
+ Object obj = inp( key );
+ while( obj == null )
+ {
+ try
+ {
+ this.wait();
+ } catch( InterruptedException e )
+ {}
+ obj = inp( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object in( Object key, long timeout )
+ {
+ Object obj = inp( key );
+ long now = System.currentTimeMillis();
+ long end = now + timeout;
+ while( obj == null && now < end )
+ {
+ try
+ {
+ this.wait( end - now );
+ } catch( InterruptedException e )
+ {}
+ obj = inp( key );
+ now = System.currentTimeMillis();
+ }
+ return obj;
+ }
+
+ public synchronized Object rd( Object key )
+ {
+ Object obj = rdp( key );
+ while( obj == null )
+ {
+ try
+ {
+ this.wait();
+ } catch( InterruptedException e )
+ {}
+ obj = rdp( key );
+ }
+ return obj;
+ }
+
+ public synchronized Object rd( Object key, long timeout )
+ {
+ Object obj = rdp( key );
+ long now = System.currentTimeMillis();
+ long end = now + timeout;
+ while( obj == null && now < end )
+ {
+ try
+ {
+ this.wait( end - now );
+ } catch( InterruptedException e )
+ {}
+ obj = rdp( key );
+ now = System.currentTimeMillis();
+ }
+ return obj;
+ }
+
+ public synchronized void addListener( Object key, SpaceListener listener
)
+ {
+ Data data = (Data) map.get( key );
+ if( data == null )
+ {
+ data = new Data();
+ map.put( key, data );
+ }
+ data.addListener( listener );
+ }
+
+ public synchronized void removeListener( Object key, SpaceListener
listener )
+ {
+ Data data = (Data) map.get( key );
+ if( data != null )
+ data.removeListener( listener );
+ }
+
+ /**
+ * @return set of keys present in the Space
+ * @jmx:managed-attribute description="Keys in Space"
+ */
+ public Set getKeySet()
+ {
+ synchronized(this)
+ {
+ return map.keySet();
+ }
+ }
+
+ public String getKeys()
+ {
+ StringBuffer sb = new StringBuffer ();
+ Iterator iter = map.keySet().iterator ();
+ boolean first = true;
+ while( iter.hasNext() )
+ {
+ if( ! first )
+ sb.append( ' ' );
+ else
+ first = false;
+ sb.append( iter.next().toString() );
+ }
+ return sb.toString();
+ }
+
+ /**
+ * same as Space.out (key,value)
+ * @param key Key
+ * @param value value
+ * @jmx:managed-operation description="Write value to key"
+ * @jmx:managed-operation-parameter position="0" name="key"
description="Space Key"
+ * @jmx:managed-operation-parameter position="1" name="value"
description="Value to write"
+ */
+ public void write( String key, String value )
+ {
+ out( key, value );
+ }
+
+ /**
+ * same as Space.rd (key)
+ * @param key Key
+ * @return value.toString()
+ * @jmx:managed-operation description="Read value from key"
+ * @jmx:managed-operation-parameter position="0" name="key"
description="Space Key"
+ */
+ public String read( String key )
+ {
+ Object obj = inp( key );
+ if( obj == null )
+ return "null";
+ return obj.toString();
+ }
+
+ public int size( Object key )
+ {
+ Data data = (Data) map.get( key );
+ if( data == null )
+ return 0;
+ return data.size();
+ }
+}
+

Added: development/laboratory/planet/components/space/util/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/planet/components/space/util/build.xml Sun
Dec 12 20:42:44 2004
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="jpos-space-util" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit" xmlns:x="antlib:net.dpml.magic" >
+
+ <transit:init/>
+ <import file="${dpml.templates}/standard.xml"/>
+
+</project>

Added:
development/laboratory/planet/components/space/util/src/main/org/jpos/space/util/Connector.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/util/src/main/org/jpos/space/util/Connector.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.util;
+
+import net.dpml.parameters.ParameterException;
+import net.dpml.parameters.Parameters;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+
+import org.jpos.space.api.LocalSpace;
+import org.jpos.space.api.SpaceListener;
+
+/**
+ * @author Alejandro Revilla
+ * @version $Revision: 1.4 $ $Date: 2003/05/16 04:11:58 $
+ * @since 2.0
+ */
+public class Connector
+ implements SpaceListener
+{
+ private LocalSpace m_LocalSpace;
+ private String m_From;
+ private String m_To;
+
+ public Connector( ServiceManager man, Parameters params )
+ throws ServiceException, ParameterException
+ {
+ super ();
+ m_LocalSpace = (LocalSpace) man.lookup( "space" );
+ m_From = params.getParameter( "from" );
+ m_To = params.getParameter( "to" );
+ m_LocalSpace.addListener( m_From, this );
+ }
+
+ public void notify( Object key, Object value )
+ {
+ Object o = m_LocalSpace.inp( key );
+ if( o != null )
+ m_LocalSpace.out( m_To, o );
+ }
+}
+

Added:
development/laboratory/planet/components/space/util/src/main/org/jpos/space/util/SpaceUtil.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/space/util/src/main/org/jpos/space/util/SpaceUtil.java
Sun Dec 12 20:42:44 2004
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2000 jPOS.org. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the jPOS project
+ * (http://www.jpos.org/)". Alternately, this acknowledgment may
+ * appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * 4. The names "jPOS" and "jPOS.org" must not be used to endorse
+ * or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * license AT jpos.org.
+ *
+ * 5. Products derived from this software may not be called "jPOS",
+ * nor may "jPOS" appear in their name, without prior written
+ * permission of the jPOS project.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the jPOS Project. For more
+ * information please see <http://www.jpos.org/>.
+ */
+
+package org.jpos.space.util;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jpos.space.api.Space;
+
+/**
+ * Space related helper methods
+ *
+ * @author Alejandro Revilla
+ * @version $Revision: 1.2 $ $Date: 2004/04/10 21:23:31 $
+ * @since 1.4.7
+ */
+
+public class SpaceUtil
+{
+ /**
+ * return all entries under a given key
+ *
+ * @param sp the Space
+ * @param key Entry's key
+ * @return array containing all entries under key
+ */
+ public static Object[] inpAll( Space sp, Object key )
+ {
+ List list = new ArrayList();
+ Object value;
+ do
+ {
+ value = sp.inp (key);
+ if (value != null)
+ {
+ list.add (value);
+ }
+ } while (value != null);
+ return list.toArray();
+ }
+
+ /**
+ * Remove all entries under key
+ *
+ * @param sp the Space
+ * @param key Entry's key
+ */
+ public static void wipe( Space sp, Object key )
+ {
+ while( sp.inp( key ) != null )
+ ;
+ }
+
+ public static long nextLong( Space sp, Object key )
+ {
+ long l = 0L;
+ synchronized( sp )
+ {
+ Object obj = sp.inp( key );
+ wipe( sp, key ); // just in case
+ if( obj instanceof Long )
+ l = ( (Long) obj ).longValue();
+ sp.out( key, new Long( ++l ) );
+ }
+ return l;
+ }
+}
+



  • svn commit: r1171 - in development/laboratory/planet/components/space: . api api/src api/src/main api/src/main/org api/src/main/org/jpos api/src/main/org/jpos/space api/src/main/org/jpos/space/api interceptor interceptor/src interceptor/src/main interceptor/src/main/org interceptor/src/main/org/jpos interceptor/src/main/org/jpos/space interceptor/src/main/org/jpos/space/interceptor jdbm jdbm/src jdbm/src/main jdbm/src/main/org jdbm/src/main/org/jpos jdbm/src/main/org/jpos/space persistent persistent/src persistent/src/main persistent/src/main/org persistent/src/main/org/jpos persistent/src/main/org/jpos/space persistent/src/main/org/jpos/space/persistent proxy proxy/src proxy/src/main proxy/src/main/org proxy/src/main/org/jpos proxy/src/main/org/jpos/space proxy/src/main/org/jpos/space/proxy tiny tiny/src tiny/src/main tiny/src/main/org tiny/src/main/org/jpos tiny/src/main/org/jpos/space tiny/src/main/org/jpos/space/tiny transient transient/src transient/src/main transient/src/main/org transient/src/main/org/jpos transient/src/main/org/jpos/space transient/src/main/org/jpos/space/transiient util util/src util/src/main util/src/main/org util/src/main/org/jpos util/src/main/org/jpos/space util/src/main/org/jpos/space/util, niclas, 12/12/2004

Archive powered by MHonArc 2.6.24.

Top of Page