[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sandesha-dev
Subject:    [Patch]Add cleaner interfaces to storage beans
From:       Sanka Samaranayake <ssanka () gmail ! com>
Date:       2005-09-07 4:19:56
Message-ID: 431E6A6C.8090807 () gmail ! com
[Download RAW message or body]

Dear Sandesha Committers,

Please accept the patch which adds cleaner interfaces to storage beans ..

Thanks,
--Sanka

["StorageChanges" (text/plain)]

Index: storage/inmemory/InMemSequencePropretyBeanMgr.java
===================================================================
--- storage/inmemory/InMemSequencePropretyBeanMgr.java	(revision 0)
+++ storage/inmemory/InMemSequencePropretyBeanMgr.java	(revision 0)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.inmemory;
+
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class InMemSequencePropretyBeanMgr implements SequencePropertyBeanMgr {
+	private static Hashtable table = new Hashtable();
+
+	/**
+	 * 
+	 */
+	public InMemSequencePropretyBeanMgr() {
+	}
+
+	public boolean delete(String sequenceId, String name) {
+		return table.remove(sequenceId +":" + name) != null;
+	}
+
+	public SequencePropertyBean retrieve(String sequenceId, String name) {
+		return (SequencePropertyBean) table.get(sequenceId + ":" + name);
+	}
+
+	public ResultSet selectRS(String query) {
+		throw new UnsupportedOperationException("selectRS() is not supported");
+	}
+
+	public Collection selectTO(SequencePropertyBean bean) {
+		ArrayList beans = new ArrayList();
+		Iterator iterator = table.values().iterator();
+		SequencePropertyBean temp;
+		
+		while (iterator.hasNext()) {
+			temp = (SequencePropertyBean) iterator.next();
+			
+			if ((bean.getSequenceId() != null 
+					&& bean.getSequenceId().equals(temp.getSequenceId()))
+					&& (bean.getName() != null 
+					&& bean.getName().equals(temp.getName()))
+					&& (bean.getValue() != null 
+					&& bean.getValue().equals(temp.getValue()))) {
+				
+				beans.add(temp);				
+			}
+		}
+		return beans;
+	}
+
+	public boolean update(SequencePropertyBean bean) {
+		return table.put(getId(bean), bean) != null;
+		
+	}
+	
+	private String getId(SequencePropertyBean bean) {
+		return bean.getSequenceId() + ":" + bean.getName();
+	}
+
+}
\ No newline at end of file
Index: storage/inmemory/InMemStorageMapBeanMgr.java
===================================================================
--- storage/inmemory/InMemStorageMapBeanMgr.java	(revision 0)
+++ storage/inmemory/InMemStorageMapBeanMgr.java	(revision 0)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.inmemory;
+
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
+import org.apache.sandesha2.storage.beans.StorageMapBean;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class InMemStorageMapBeanMgr implements StorageMapBeanMgr {
+	private static Hashtable table = new Hashtable();
+	
+	/**
+	 * 
+	 */
+	public InMemStorageMapBeanMgr() {
+	}
+
+	public boolean delete(String key) {
+		return table.remove(key) != null; 
+	}
+
+	public StorageMapBean retrieve(String key) {
+		return (StorageMapBean) table.get(key);
+	}
+
+	public ResultSet selectRS(String query) {
+		throw new UnsupportedOperationException("selectRS() is not implemented");
+	}
+	
+	public Collection selectTO(StorageMapBean bean) {
+		ArrayList beans = new ArrayList();
+		Iterator iterator = table.values().iterator();
+		
+		StorageMapBean temp = new StorageMapBean();
+		while (iterator.hasNext()) {
+			temp = (StorageMapBean) iterator.next();
+			if ((bean.getKey() != null 
+					&& bean.getKey().equals(temp.getKey()))
+					&& (bean.getMsgNo() != -1 
+					&& bean.getMsgNo() == temp.getMsgNo())
+					&& (bean.getSequenceId() != null 
+					&& bean.getSequenceId().equals(temp.getSequenceId()))) {
+				
+				beans.add(temp);
+			}
+		}
+		return beans;
+	}
+	
+	public boolean update(StorageMapBean bean) {
+		return table.put(bean.getKey(), bean) != null;
+	}
+
+}
Index: storage/inmemory/InMemRetransmitterBeanMgr.java
===================================================================
--- storage/inmemory/InMemRetransmitterBeanMgr.java	(revision 0)
+++ storage/inmemory/InMemRetransmitterBeanMgr.java	(revision 0)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.inmemory;
+
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
+import org.apache.sandesha2.storage.beans.RetransmitterBean;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class InMemRetransmitterBeanMgr implements RetransmitterBeanMgr {
+	private static Hashtable table = new Hashtable();
+	
+	/**
+	 * 
+	 */
+	public InMemRetransmitterBeanMgr() {
+	}
+
+	public boolean delete(String MessageId) {
+		return table.remove(MessageId) != null;
+	}
+	
+	public RetransmitterBean retrieve(String MessageId) {
+		return (RetransmitterBean) table.get(MessageId);
+	}
+
+	public boolean insert(RetransmitterBean bean) {
+		table.put(bean.getMessageId(), bean);
+		return true;
+	}
+
+	public ResultSet selectRS(String query) {
+		throw new UnsupportedOperationException("selectRS() is not supported");
+	}
+
+	public Collection selectTO(RetransmitterBean bean) {
+		ArrayList beans = new ArrayList();
+		Iterator iterator = table.values().iterator();
+		
+		RetransmitterBean temp;
+		while (iterator.hasNext()) {
+			temp = (RetransmitterBean) iterator.next();
+			if (!(bean.getMessageId() != null 
+					&& bean.getMessageId().equals(temp.getMessageId()))
+					&& (bean.getCreateSeqMsgId() != null
+					&& bean.getCreateSeqMsgId().equals(temp.getCreateSeqMsgId()))
+					&& (bean.getKey() != null 
+					&& bean.getKey().equals(temp.getKey()))
+					&& (bean.getLastSentTime() != -1 
+					&& bean.getLastSentTime() == temp.getLastSentTime())){
+				
+				beans.add(temp);				
+			}
+		}
+		
+		return beans;
+	}
+
+	public boolean update(RetransmitterBean bean) {
+		return table.put(bean.getMessageId(), bean) != null;
+	}
+
+}
Index: storage/inmemory/InMemNextMsgBeanMgr.java
===================================================================
--- storage/inmemory/InMemNextMsgBeanMgr.java	(revision 0)
+++ storage/inmemory/InMemNextMsgBeanMgr.java	(revision 0)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.inmemory;
+
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
+import org.apache.sandesha2.storage.beans.NextMsgBean;
+
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class InMemNextMsgBeanMgr implements NextMsgBeanMgr {
+
+	private static Hashtable table = new Hashtable();
+	/**
+	 * 
+	 */
+	public InMemNextMsgBeanMgr() {
+	}
+
+	public boolean delete(String sequenceId) {
+		return table.remove(sequenceId) != null;
+	}
+
+	public NextMsgBean retrieve(String sequenceId) {
+		return (NextMsgBean) table.get(sequenceId);
+	}
+
+	public boolean insert(NextMsgBean bean) {
+		table.put(bean.getSequenceId(), bean);
+		return true;
+	}
+
+	public ResultSet selectRS(String query) {
+		throw new UnsupportedOperationException("selectRS() is not supported");
+	}
+
+	public Collection selectTO(NextMsgBean bean) {
+		ArrayList beans = new ArrayList();
+		Iterator iterator = table.values().iterator();
+		
+		NextMsgBean temp;
+		while (iterator.hasNext()) {
+			temp = (NextMsgBean) iterator.next();
+			
+			if ((bean.getSequenceId() != null 
+					&& bean.getSequenceId().equals(temp.getSequenceId()))
+					&& (bean.getNextMsgNoToProcess() != null
+					&& bean.getNextMsgNoToProcess().equals(temp.getNextMsgNoToProcess()))) {
+				
+				beans.add(temp);			
+			}
+			
+		}
+		return beans;
+	}
+
+	public boolean update(NextMsgBean bean) {
+		return table.put(bean.getSequenceId(), bean) != null ;
+	}
+
+}
Index: storage/inmemory/InMemBeanMgrFactory.java
===================================================================
--- storage/inmemory/InMemBeanMgrFactory.java	(revision 0)
+++ storage/inmemory/InMemBeanMgrFactory.java	(revision 0)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.inmemory;
+
+import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class InMemBeanMgrFactory extends AbstractBeanMgrFactory {
+
+	public CreateSeqBeanMgr getCreateSeqBeanMgr() {
+		return new InMemCreateSeqBeanMgr();
+	}
+
+	public NextMsgBeanMgr getNextMsgBean() {
+		return new InMemNextMsgBeanMgr();
+	}
+
+	public RetransmitterBeanMgr getRetransmitterBeanMgr() {
+		return new InMemRetransmitterBeanMgr();
+	}
+
+	public SequencePropertyBeanMgr getSequencePropretyBeanMgr() {
+		return new InMemSequencePropretyBeanMgr();
+	}
+	
+	public StorageMapBeanMgr getStorageMapBeanMgr() {
+		return new InMemStorageMapBeanMgr();
+	}
+
+}
Index: storage/inmemory/InMemCreateSeqBeanMgr.java
===================================================================
--- storage/inmemory/InMemCreateSeqBeanMgr.java	(revision 0)
+++ storage/inmemory/InMemCreateSeqBeanMgr.java	(revision 0)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.inmemory;
+
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beans.CreateSeqBean;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+
+public class InMemCreateSeqBeanMgr implements CreateSeqBeanMgr {
+	
+	private static Hashtable table = new Hashtable();
+
+	/**
+	 * 
+	 */
+	public InMemCreateSeqBeanMgr() {
+	}
+
+	public boolean insert(CreateSeqBean bean) {
+		table.put(bean.getCreateSeqMsgId(), bean);
+		return true;
+	}
+
+	public boolean delete(String msgId) {
+		return table.remove(msgId) != null;
+	}
+
+	public CreateSeqBean retrieve(String msgId) {
+		return (CreateSeqBean) table.get(msgId);
+	}
+
+	public boolean update(CreateSeqBean bean) {
+		return table.put(bean.getCreateSeqMsgId(), bean) != null;
+	}
+
+	public Collection selectTO(CreateSeqBean bean) {
+		ArrayList beans = new ArrayList();		
+		Iterator iterator = table.values().iterator();
+		
+		CreateSeqBean temp;		
+		while (iterator.hasNext()) {
+			temp = (CreateSeqBean) iterator.next();
+			if ( (bean.getCreateSeqMsgId() != null 
+						&& bean.getCreateSeqMsgId().equals(temp.getCreateSeqMsgId()))
+						&& (bean.getSequenceId() != null 
+						&& bean.getSequenceId().equals(bean.getSequenceId()))) {
+				beans.add(temp);
+				
+			}
+		}
+		return beans;
+	}
+
+	public ResultSet selectRS(String query) {
+		throw new UnsupportedOperationException("selectRS() is not supported");
+	}
+
+}
Index: storage/persistent/PersistentStorageMapBeanMgr.java
===================================================================
--- storage/persistent/PersistentStorageMapBeanMgr.java	(revision 0)
+++ storage/persistent/PersistentStorageMapBeanMgr.java	(revision 0)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.persistent;
+
+import java.sql.ResultSet;
+import java.util.Collection;
+
+import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
+import org.apache.sandesha2.storage.beans.StorageMapBean;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class PersistentStorageMapBeanMgr implements StorageMapBeanMgr {
+
+	public boolean delete(String key) {
+		throw new UnsupportedOperationException();
+	}
+	
+	public StorageMapBean retrieve(String key) {
+		throw new UnsupportedOperationException();
+	}
+	
+	public ResultSet selectRS(String query) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public Collection selectTO(StorageMapBean bean) {
+		throw new UnsupportedOperationException();
+	}
+
+	public boolean update(StorageMapBean bean) {
+		throw new UnsupportedOperationException();
+	}
+
+}
Index: storage/persistent/PersistentRetransmitterBeanMgr.java
===================================================================
--- storage/persistent/PersistentRetransmitterBeanMgr.java	(revision 0)
+++ storage/persistent/PersistentRetransmitterBeanMgr.java	(revision 0)
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.persistent;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
+import org.apache.sandesha2.storage.beans.RetransmitterBean;
+
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class PersistentRetransmitterBeanMgr implements RetransmitterBeanMgr {
+	
+	public boolean delete(String messageId) {
+		String query = "DELETE FROM Retransmitter WHERE RKey = '" + messageId + "'" ;
+		
+		try {
+			getStatement().executeUpdate(query);
+			return true;
+			
+		} catch (SQLException ex) {
+			//TODO
+			ex.printStackTrace();
+			
+		}
+		return false;
+	}
+	
+	public boolean insert(RetransmitterBean bean) {
+		String query = ("INSERT INTO Retransmitter VALUES ( " 
+				+ "'" + bean.getMessageId() + "', "
+				+ "'" + bean.getKey() + "', " 
+				+ bean.getLastSentTime() +", "
+				+ ((bean.isSend().booleanValue()) ? "'T'" : "'F'") + ", "
+				+ "'" + bean.getCreateSeqMsgId() + "'"
+				+ ")");
+		try {
+			getStatement().executeUpdate(query);
+			return true;
+		} catch (SQLException ex) {
+			//TODO logs the error .. 
+			ex.printStackTrace();
+		}
+		return false;
+	}
+	
+	public RetransmitterBean retrieve(String messageId) {
+		String query = "SELECT * FROM Retransmitter WHERE MessageId = '" + messageId + \
"'"; +
+		try {
+			RetransmitterBean bean = new RetransmitterBean();
+			ResultSet rs = getStatement().executeQuery(query);
+			rs.next();
+			bean.setCreateSeqMsgId(rs.getString("CreateSeqMsgId"));
+			bean.setKey(rs.getString("RKey"));
+			bean.setLastSentTime(rs.getLong("LastSentTime"));
+			bean.setMessageId(rs.getString("MessageId"));
+			bean.setSend(new Boolean(rs.getBoolean("Send")));
+				
+			return bean;
+			
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+			ex.printStackTrace();					
+		}
+		return null;
+	}
+
+	public ResultSet selectRS(String query) {
+		try {
+			getStatement().executeUpdate(query);
+			ResultSet rs = getStatement().executeQuery(query);
+			return rs;
+		} catch (SQLException ex) {
+			// TODO logs the error .. 
+			ex.printStackTrace();
+		}	
+		return null;
+	}
+	
+	public Collection selectTO(RetransmitterBean bean) {
+		StringBuffer query = new StringBuffer();
+		
+		query.append("SELECT * FROM Retransmitter WHERE");
+		
+		query.append((bean.getMessageId() != null) 
+				? (query.toString().indexOf("=") != -1) ? " AND MessageId = " + \
bean.getMessageId()  +														: " MessageId = " + bean.getMessageId()
+				: "");
+		query.append((bean.getCreateSeqMsgId() != null) 
+				? (query.toString().indexOf("=") != -1) ? " AND CreateSequenceMsgId = " + \
bean.getCreateSeqMsgId() +														: " CreateSequenceMsgId = " + \
bean.getCreateSeqMsgId() +				: "");
+		query.append((bean.getKey() != null) 
+				? (query.toString().indexOf("=") != -1) ? " AND RKey = " + bean.getKey()
+														: " RKey = " + bean.getKey()
+				: "");
+		query.append((bean.getLastSentTime() != -1) 
+				? (query.toString().indexOf("=") != -1) ? " AND LastSentTime = " + \
bean.getLastSentTime() +														: " LastSentTime = " + bean.getLastSentTime()
+				: "");
+		query.append((bean.isSend() != null) 
+				? (query.toString().indexOf("=") != -1) ? " AND Send = '" + \
bean.isSend().booleanValue() + "'" +														: " Send = '" + \
bean.isSend().booleanValue() + "'" +				: "");
+		
+		String queryString = query.toString();
+		
+		if (queryString.indexOf("=") == -1) {
+			query.replace(queryString.indexOf("WHERE"), queryString.length(), "");
+		}
+			
+		try {
+			ResultSet rs = getStatement().executeQuery(query.toString().trim());
+			ArrayList beans = new ArrayList();
+			RetransmitterBean nbean;
+			while (rs.next()) {
+				nbean = new RetransmitterBean();
+				nbean.setMessageId(rs.getString("MessageId"));
+				nbean.setCreateSeqMsgId(rs.getString("CreateSeqMsgId"));
+				nbean.setKey(rs.getString("RKey"));
+				nbean.setLastSentTime(rs.getLong("LastSentTime"));
+				nbean.setSend(new Boolean(rs.getBoolean("Send")));
+				beans.add(nbean);
+			}			
+			return beans;
+		
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+			ex.printStackTrace();
+		}
+		return null;
+	}
+	
+	public boolean update(RetransmitterBean bean) {
+		String query = "UPDATE Retransmitter SET " 
+			+ "MessageId = '" + bean.getMessageId() + "', "
+			+ "RKey = '" + bean.getKey() + "', " 
+			+ "LastSentTime = "+ bean.getLastSentTime() +", "
+			+ "Send = " + ((bean.isSend().booleanValue()) ? "'T'" : "'F'") + ", "
+			+ "CreateSeqMsgId = '" + bean.getCreateSeqMsgId() + "'";
+		
+		try {
+			getStatement().executeUpdate(query);
+			return true;
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+			ex.printStackTrace();
+		}
+		return false;
+	}
+	
+	private Statement getStatement() throws SQLException {
+		return PersistentBeanMgrFactory.getConnection().createStatement();
+	}
+}
Index: storage/persistent/PersistentNextMsgBeanMgr.java
===================================================================
--- storage/persistent/PersistentNextMsgBeanMgr.java	(revision 0)
+++ storage/persistent/PersistentNextMsgBeanMgr.java	(revision 0)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.persistent;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
+import org.apache.sandesha2.storage.beans.NextMsgBean;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class PersistentNextMsgBeanMgr implements NextMsgBeanMgr {
+
+	public boolean delete(String sequenceId) {
+		String query = "DELETE FROM NextMsgSequence WHERE NextMsgSequence = '" + \
sequenceId + "'" ; +		
+		try {
+			getStatement().executeUpdate(query);
+			return true;
+			
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+			ex.printStackTrace();
+		}		
+		return false;
+	}
+
+	public NextMsgBean retrieve(String sequenceId) {
+		String query = "SELECT * FROM NextMsgSequence WHERE  SequenceId = '" 
+			+ sequenceId + "'";
+			
+		try {
+			NextMsgBean bean = new NextMsgBean();
+			ResultSet rs = getStatement().executeQuery(query);
+			rs.next();
+			bean.setSequenceId(rs.getString("SequenceId"));
+			bean.setNextMsgNoToProcess(rs.getString("NextMsgToProcess"));
+			return bean;
+			
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+			ex.printStackTrace();			
+		}
+		return null;
+	}
+
+	public boolean insert(NextMsgBean bean) {
+		String query = ("INSERT INTO NextMsgSequence VALUES ( "
+				+ "'" + bean.getSequenceId() + "', " 
+				+ "'" + bean.getNextMsgNoToProcess() + "')");
+		
+		try {
+			getStatement().executeUpdate(query);
+			return true;
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+			ex.printStackTrace();
+		}
+		return false;
+	}
+
+	public ResultSet selectRS(String query) {
+		try {
+			getStatement().executeUpdate(query);
+			ResultSet rs = getStatement().executeQuery(query);
+			return rs;
+		} catch (SQLException ex) {
+			// TODO logs the error .. 
+			ex.printStackTrace();
+		}	
+		return null;
+	}
+
+	public Collection selectTO(NextMsgBean bean) {
+		StringBuffer query = new StringBuffer();
+		
+		query.append("SELECT * FROM NextMsgSequence WHERE");
+		
+		query.append((bean.getSequenceId() != null) 
+				? (query.toString().indexOf("=") != -1) ? " AND SequenceId = " + \
bean.getSequenceId()  +														: " SequenceId = " + bean.getSequenceId()
+				: "");
+		query.append((bean.getSequenceId() != null) 
+				? (query.toString().indexOf("=") != -1) ? " AND NextMsgToProcess = " + \
bean.getNextMsgNoToProcess() +														: " NextMsgToProcess = " + \
bean.getNextMsgNoToProcess() +				: "");	
+		String queryString = query.toString();
+		
+		if (queryString.indexOf("=") == -1) {
+			query.replace(queryString.indexOf("WHERE"), queryString.length(), "");
+		}
+			
+		try {
+			ResultSet rs = getStatement().executeQuery(query.toString().trim());
+			ArrayList beans = new ArrayList();
+			NextMsgBean nbean;
+			while (rs.next()) {
+				nbean =new NextMsgBean();
+				nbean.setSequenceId(rs.getString("SequenceId"));
+				nbean.setNextMsgNoToProcess(rs.getString("NextMsgToProcess"));
+				beans.add(nbean);
+			}			
+			return beans;
+		
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+			ex.printStackTrace();
+		}
+		return null;
+	}
+	
+	public boolean update(NextMsgBean bean) {
+		String query = ("UPDATE NextMsgSequence SET " 
+				+ "SequenceId = '" + bean.getSequenceId() + "', "
+				+ "NextMsgToProcess = '" + bean.getNextMsgNoToProcess() + "'");
+		try {
+			getStatement().executeUpdate(query);
+			return true;
+		} catch (SQLException ex) {
+			ex.printStackTrace();
+			throw new RuntimeException(ex.getMessage());
+		}
+		
+	}
+	
+	private Statement getStatement() throws SQLException {
+		return PersistentBeanMgrFactory.getConnection().createStatement();		
+	}
+
+}
Index: storage/persistent/PersistentBeanMgrFactory.java
===================================================================
--- storage/persistent/PersistentBeanMgrFactory.java	(revision 0)
+++ storage/persistent/PersistentBeanMgrFactory.java	(revision 0)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.persistent;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+
+import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class PersistentBeanMgrFactory extends AbstractBeanMgrFactory {
+	
+	private static String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
+	private static String PROTOCOL = "jdbc:derby:";
+	private static String SANDESHA2_DB = "sandesha2_db";
+	
+	private static String CREATE_SEQUENCE_TABLE = "CREATE TABLE \
CreateSequence(CreateSeqMsgId VARCHAR(200), SequenceId VARCHAR(200))"; +	private \
static String CREATE_NEXT_MSG_TABLE = "CREATE TABLE NextMsgSequence(SequenceId \
VARCHAR(200), NextMsgToProcess VARCHAR(200))"; +	private static String \
CREATE_RETRANSMITTER_TABLE = "CREATE TABLE Retransmitter(MessageId VARCHAR(200), RKey \
VARCHAR(200), LastSentTime BIGINT, Send CHAR(1), CreateSeqMsgId VARCHAR(200))"; \
+	private static String CREATE_STORAGE_MAP_TABLE = "CREATE TABLE StorageMap(SKey \
VARCHAR(200),MsgNo INTEGER, SequenceId VARCHAR(200))"; +	private static String \
CREATE_SEQUENCE_PROPERTY_TABLE = "CREATE TABLE SequenceProperty(SequenceId \
VARCHAR(200), Name VARCHAR(50), Value VARCHAR(200))"; +	
+	private static Connection connection = null;
+	
+	static {
+		try {
+			Class.forName(DRIVER);
+		} catch (Exception ex) {
+			throw new RuntimeException("cannot load the driver", ex);
+		}
+		
+		try {
+			connection = DriverManager.getConnection(PROTOCOL + SANDESHA2_DB);
+			connection.setAutoCommit(false);
+			
+		} catch (Exception ex) {
+			// db might not exist ..
+			try {
+				String str = PROTOCOL + SANDESHA2_DB + ";create=true";
+				connection = DriverManager.getConnection(str);
+				Statement statement = connection.createStatement();
+				statement.executeUpdate(CREATE_SEQUENCE_TABLE);
+				statement.executeUpdate(CREATE_NEXT_MSG_TABLE);
+				statement.executeUpdate(CREATE_RETRANSMITTER_TABLE);
+				statement.executeUpdate(CREATE_STORAGE_MAP_TABLE);
+				statement.executeUpdate(CREATE_SEQUENCE_PROPERTY_TABLE);
+				
+				connection.setAutoCommit(false);
+			} catch (Exception e) {
+				
+				throw new RuntimeException("cannot create the db", e);
+			}
+			
+		}
+	}
+	
+	public static Connection getConnection() {
+		return connection;
+	}
+
+	public CreateSeqBeanMgr getCreateSeqBeanMgr() {
+		return new PersistentCreateSeqBeanMgr();
+	}
+	
+	public NextMsgBeanMgr getNextMsgBean() {
+		return new PersistentNextMsgBeanMgr();
+	}
+	
+	public RetransmitterBeanMgr getRetransmitterBeanMgr() {
+		return new PersistentRetransmitterBeanMgr();
+	}
+	
+	public SequencePropertyBeanMgr getSequencePropretyBeanMgr() {
+		return new PersistentSequencePropretyBeanMgr();
+	}
+
+	public StorageMapBeanMgr getStorageMapBeanMgr() {
+		return new PersistentStorageMapBeanMgr();
+	}
+}
Index: storage/persistent/PersistentCreateSeqBeanMgr.java
===================================================================
--- storage/persistent/PersistentCreateSeqBeanMgr.java	(revision 0)
+++ storage/persistent/PersistentCreateSeqBeanMgr.java	(revision 0)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.persistent;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beans.CreateSeqBean;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class PersistentCreateSeqBeanMgr implements CreateSeqBeanMgr {
+	
+	public boolean delete(String msgId) {
+		String query = "DELETE FROM CreateSequence WHERE CreateSeqMsgId = '" + msgId + "'" \
; +		
+		try {
+			getStatement().executeUpdate(query);
+			return true;
+			
+		} catch (SQLException ex) {
+			//TODO log this error
+			ex.printStackTrace();			
+		}
+		return false;
+	}
+	
+	public CreateSeqBean retrieve(String msgId) {
+		String query = "SELECT * FROM CreateSequence WHERE  CreateSeqMsgId = '" 
+			+ msgId + "'";
+			
+		try {
+			CreateSeqBean bean = new CreateSeqBean();
+			ResultSet rs = getStatement().executeQuery(query);
+			rs.next();
+			bean.setCreateSeqMsgId(rs.getString("CreateSeqMsgId"));
+			bean.setSequenceId(rs.getString("SequenceId"));
+			
+			return bean;
+		
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+		}
+		return null;
+	}
+	
+	public boolean insert(CreateSeqBean bean) {
+		String query = ("INSERT INTO CreateSequence VALUES ( " 
+				+ "'" + bean.getCreateSeqMsgId() + "', "
+				+ "'" + bean.getSequenceId() + "')");
+		
+		try {
+			getStatement().executeUpdate(query);
+			ResultSet executeQuery = getStatement().executeQuery("select * from \
CreateSequence"); +			
+			return true;
+		} catch (SQLException ex) {
+			// TODO logs the error .. 
+		}	
+		return false;
+	}
+
+	public ResultSet selectRS(String query) {
+		try {
+			getStatement().executeUpdate(query);
+			ResultSet rs = getStatement().executeQuery(query);
+			return rs;
+		} catch (SQLException ex) {
+			// TODO logs the error .. 
+			ex.printStackTrace();
+		}	
+		return null;
+	}
+	
+	public Collection selectTO(CreateSeqBean bean) {
+		StringBuffer query = new StringBuffer();
+		
+		query.append("SELECT * FROM CreateSequence WHERE");
+		
+		query.append((bean.getCreateSeqMsgId() != null) 
+				? (query.toString().indexOf("=") != -1) ? " AND CreateMsgSeqId = " + \
bean.getCreateSeqMsgId()  +														: " CreateMsgSeqId = " + \
bean.getCreateSeqMsgId() +				: "");
+		query.append((bean.getSequenceId() != null) 
+				? (query.toString().indexOf("=") != -1) ? " AND SequenceId = " + \
bean.getSequenceId() +														: " SequenceId = " + bean.getSequenceId()
+				: "");	
+		String queryString = query.toString();
+		
+		if (queryString.indexOf("=") == -1) {
+			query.replace(queryString.indexOf("WHERE"), queryString.length(), "");
+		}
+			
+		try {
+			ResultSet rs = getStatement().executeQuery(query.toString().trim());
+			ArrayList beans = new ArrayList();
+			CreateSeqBean nbean;
+			while (rs.next()) {
+				nbean =new CreateSeqBean();
+				nbean.setCreateSeqMsgId(rs.getString("CreateSeqMsgId"));
+				nbean.setSequenceId(rs.getString("SequenceId"));
+				beans.add(nbean);
+			}			
+			return beans;
+		
+		} catch (SQLException ex) {
+			//TODO logs the error ..
+		}
+		return null;
+	}
+
+	public boolean update(CreateSeqBean bean) {
+		String query = "UPDATE CreateSequence SET CreateSeqMsgId = '" + \
bean.getCreateSeqMsgId() + "', " +				+ "SequenceId = '" + bean.getSequenceId() + "' \
" +				+ "WHERE CreateSeqMsgId = '" + bean.getCreateSeqMsgId() + "'";
+		try {
+			getStatement().executeUpdate(query);
+			return true;
+		} catch (SQLException ex) {
+			//TODO log the error ..
+			ex.printStackTrace();
+		}
+		
+		return false;
+	}
+	
+	private Statement getStatement() throws SQLException {
+		return PersistentBeanMgrFactory.getConnection().createStatement();
+	}
+}
Index: storage/persistent/PersistentSequencePropretyBeanMgr.java
===================================================================
--- storage/persistent/PersistentSequencePropretyBeanMgr.java	(revision 0)
+++ storage/persistent/PersistentSequencePropretyBeanMgr.java	(revision 0)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage.persistent;
+
+import java.sql.ResultSet;
+import java.util.Collection;
+
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public class PersistentSequencePropretyBeanMgr implements SequencePropertyBeanMgr {
+
+	public boolean delete(String sequenceId, String name) {
+		throw new UnsupportedOperationException();
+	}
+
+	public SequencePropertyBean retrieve(String sequenceId, String name) {
+		throw new UnsupportedOperationException();
+	}
+
+	public ResultSet selectRS(String query) {
+		throw new UnsupportedOperationException();
+	}
+
+	public Collection selectTO(SequencePropertyBean bean) {
+		throw new UnsupportedOperationException();
+	}
+
+	public boolean update(SequencePropertyBean bean) {
+		throw new UnsupportedOperationException();
+	}
+
+}
Index: storage/beanmanagers/RetransmitterBeanMgr.java
===================================================================
--- storage/beanmanagers/RetransmitterBeanMgr.java	(revision 278977)
+++ storage/beanmanagers/RetransmitterBeanMgr.java	(working copy)
@@ -1,57 +1,37 @@
 /*
- * Copyright  1999-2004 The Apache Software Foundation.
+ * Copyright 2004,2005 The Apache Software Foundation.
  *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
  */
-
 package org.apache.sandesha2.storage.beanmanagers;
 
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.StorageManagerFactory;
-import org.apache.sandesha2.storage.beans.RMBean;
+import java.sql.ResultSet;
+import java.util.Collection;
+
 import org.apache.sandesha2.storage.beans.RetransmitterBean;
 
 /**
- * @author 
- * 
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
  */
-public class RetransmitterBeanMgr implements CRUD {
+public interface RetransmitterBeanMgr {
+	public boolean delete(String MessageId);
+	public RetransmitterBean retrieve(String MessageId);
+	public boolean insert(RetransmitterBean bean);
+	public ResultSet selectRS(String query);
+	public Collection selectTO(RetransmitterBean bean);
+	public boolean update(RetransmitterBean bean);
 	
-	private StorageManager storageMgr;
-	
-	public RetransmitterBeanMgr(int storageType) {
-		storageMgr = StorageManagerFactory.getStorageManager(storageType);
-	}
-	public boolean create(RMBean bean) {
-		if (!(bean instanceof RetransmitterBean)) {
-			throw new IllegalArgumentException();			
-		}
-		return storageMgr.createRetransmitterBean((RetransmitterBean) bean);	
-	}
-	
-	public boolean delete(String key) {
-		return storageMgr.deleteRetransmitterBean(key);
-	}
-	
-	public RMBean retrieve(String key) {
-		return storageMgr.retrieveRetransmitterBean(key);
-	}
-	
-	public boolean update(RMBean bean) {
-		if (!(bean instanceof RetransmitterBean)) {
-			throw new IllegalArgumentException();
-		}
-		return storageMgr.updateRetransmitterBean((RetransmitterBean) bean);
-	}
+
 }
Index: storage/beanmanagers/NextMsgBeanMgr.java
===================================================================
--- storage/beanmanagers/NextMsgBeanMgr.java	(revision 278977)
+++ storage/beanmanagers/NextMsgBeanMgr.java	(working copy)
@@ -1,58 +1,35 @@
 /*
- * Copyright  1999-2004 The Apache Software Foundation.
+ * Copyright 2004,2005 The Apache Software Foundation.
  *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
  */
-
 package org.apache.sandesha2.storage.beanmanagers;
 
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.StorageManagerFactory;
+import java.sql.ResultSet;
+import java.util.Collection;
+
 import org.apache.sandesha2.storage.beans.NextMsgBean;
-import org.apache.sandesha2.storage.beans.RMBean;
 
 /**
- * @author 
- * 
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
  */
-public class NextMsgBeanMgr implements CRUD {
-	
-	private StorageManager storageMgr;
-	
-	public NextMsgBeanMgr(int storageType) {
-		storageMgr = StorageManagerFactory.getStorageManager(storageType);		
-	}
-
-	public boolean create(RMBean bean) {
-		if (!(bean instanceof NextMsgBean)) {
-			throw new IllegalArgumentException();
-		}
-		return storageMgr.createNextMsg((NextMsgBean) bean);
-	}	
-	
-	public boolean delete(String key) {
-		return storageMgr.deleteNextMsgBean(key);
-	}
-	
-	public RMBean retrieve(String key) {
-		return storageMgr.retrieveNextMsgBean(key);
-	}
-	
-	public boolean update(RMBean bean) {
-		if (!(bean instanceof NextMsgBean)) {
-			throw new IllegalArgumentException();
-		}
-		return storageMgr.updateNextMsgBean((NextMsgBean) bean);
-	}
+public interface NextMsgBeanMgr {
+	public boolean delete(String sequenceId);
+	public NextMsgBean retrieve(String sequenceId);
+	public boolean insert(NextMsgBean bean);
+	public ResultSet selectRS(String query);
+	public Collection selectTO(NextMsgBean bean);
+	public boolean update(NextMsgBean bean);
 }
Index: storage/beanmanagers/CreateSeqBeanMgr.java
===================================================================
--- storage/beanmanagers/CreateSeqBeanMgr.java	(revision 278977)
+++ storage/beanmanagers/CreateSeqBeanMgr.java	(working copy)
@@ -1,55 +1,35 @@
 /*
- * Copyright  1999-2004 The Apache Software Foundation.
+ * Copyright 2004,2005 The Apache Software Foundation.
  *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
  */
-
 package org.apache.sandesha2.storage.beanmanagers;
 
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.StorageManagerFactory;
+import java.sql.ResultSet;
+import java.util.Collection;
+
 import org.apache.sandesha2.storage.beans.CreateSeqBean;
-import org.apache.sandesha2.storage.beans.RMBean;
 
 /**
- * @author 
- * 
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
  */
-public class CreateSeqBeanMgr implements CRUD {
-	
-	private StorageManager storageMgr;
-	
-	public CreateSeqBeanMgr(int storageType) {
-		storageMgr = StorageManagerFactory.getStorageManager(storageType);
-	}
-	
-	public boolean create(RMBean bean) {
-		if (!(bean instanceof CreateSeqBean)) {
-			throw new IllegalArgumentException("argument should be CreateSeqBean type");
-		}
-		return storageMgr.createCreateSeq((CreateSeqBean) bean);
-	}
-
-	public boolean delete(String key) {
-		return storageMgr.deleteCreateSeq(key);
-	}
-	
-	public RMBean retrieve(String key) {
-		return storageMgr.retrieveCreateSeq(key);
-	}
-	
-	public boolean update(RMBean bean) {
-		return storageMgr.updateCreateSeq((CreateSeqBean) bean);
-	}
+public interface CreateSeqBeanMgr {
+	public boolean insert(CreateSeqBean bean);
+	public boolean delete(String msgId);
+	public CreateSeqBean retrieve(String msgId);
+	public boolean update(CreateSeqBean bean);
+	public Collection selectTO(CreateSeqBean bean);
+	public ResultSet selectRS(String query);
 }
Index: storage/beanmanagers/SequencePropertyBeanMgr.java
===================================================================
--- storage/beanmanagers/SequencePropertyBeanMgr.java	(revision 278977)
+++ storage/beanmanagers/SequencePropertyBeanMgr.java	(working copy)
@@ -16,52 +16,20 @@
  */
 package org.apache.sandesha2.storage.beanmanagers;
 
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.StorageManagerFactory;
-import org.apache.sandesha2.storage.beans.RMBean;
+import java.sql.ResultSet;
+import java.util.Collection;
+
 import org.apache.sandesha2.storage.beans.SequencePropertyBean;
 
 /**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
  * @author Sanka Samaranayake <ssanka@gmail.com>
  */
-public class SequencePropertyBeanMgr implements CRUD {
-
-	private StorageManager storageMgr;
+public interface SequencePropertyBeanMgr {
+	public boolean delete(String sequenceId, String name);
+	public SequencePropertyBean retrieve(String sequenceId, String name);
+	public ResultSet selectRS(String query);
+	public Collection selectTO(SequencePropertyBean bean); 
+	public boolean update(SequencePropertyBean bean);
 	
-	public SequencePropertyBeanMgr(int storageType){
-		storageMgr = StorageManagerFactory.getStorageManager(storageType);
-	}
-	
-	public boolean create(RMBean key) {
-		if (!(key instanceof SequencePropertyBean)) {
-			throw new IllegalArgumentException();
-		}
-		return storageMgr.createSequencePropertyBean((SequencePropertyBean) key);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.sandesha2.storage.beanmanagers.CRUD#retrieve(java.lang.String)
-	 */
-	public RMBean retrieve(String key) {
-		return storageMgr.retrieveSequencePropertyBean(key);
-	}
-	
-	public RMBean retrieve(String sequenceId, String name) {
-		return retrieve(sequenceId + name);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.sandesha2.storage.beanmanagers.CRUD#update(org.apache.sandesha2.storage.beans.RMBean)
                
-	 */
-	public boolean update(RMBean bean) {
-		if (!(bean instanceof SequencePropertyBean)) {
-			throw new IllegalArgumentException();
-		}
-		return storageMgr.updateSequencePropertyBean((SequencePropertyBean) bean);
-	}
-
-	public boolean delete(String key) {
-		return storageMgr.deleteSequencePropertyBean(key);
-	}
-
-}
+}
\ No newline at end of file
Index: storage/beanmanagers/StorageMapBeanMgr.java
===================================================================
--- storage/beanmanagers/StorageMapBeanMgr.java	(revision 278977)
+++ storage/beanmanagers/StorageMapBeanMgr.java	(working copy)
@@ -1,57 +1,35 @@
 /*
- * Copyright  1999-2004 The Apache Software Foundation.
+ * Copyright 2004,2005 The Apache Software Foundation.
  *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
  */
-
 package org.apache.sandesha2.storage.beanmanagers;
 
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.StorageManagerFactory;
-import org.apache.sandesha2.storage.beans.RMBean;
+import java.sql.ResultSet;
+import java.util.Collection;
+
 import org.apache.sandesha2.storage.beans.StorageMapBean;
 
+
 /**
- * @author 
- * 
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
  */
-public class StorageMapBeanMgr implements CRUD {
-	private StorageManager storageMgr;
-	
-	public StorageMapBeanMgr(int storageType) {
-		storageMgr = StorageManagerFactory.getStorageManager(storageType);
-	}
-
-	public boolean create(RMBean object) {
-		if (!(object instanceof StorageMapBean)) {
-			throw new IllegalArgumentException();
-		} 
-		return storageMgr.createStorageMapBean((StorageMapBean) object);
-	}
-	
-	public boolean delete(String primaryKey) {
-		return storageMgr.deleteStorageMapBean(primaryKey);
-	}
-		
-	public RMBean retrieve(String primaryKey) {
-		return storageMgr.retrieveStorageMapBean(primaryKey);
-	}
-	
-	public boolean update(RMBean bean) {
-		if (!(bean instanceof StorageMapBean)) {
-			throw new IllegalArgumentException();
-		}
-		return storageMgr.updateStorageMapBean((StorageMapBean) bean);
-	}
+public interface StorageMapBeanMgr {
+	public boolean delete(String key);
+	public StorageMapBean retrieve(String key);
+	public ResultSet selectRS(String query);
+	public Collection selectTO(StorageMapBean bean);
+	public boolean update(StorageMapBean bean);
 }
Index: storage/AbstractBeanMgrFactory.java
===================================================================
--- storage/AbstractBeanMgrFactory.java	(revision 0)
+++ storage/AbstractBeanMgrFactory.java	(revision 0)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.sandesha2.storage;
+
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
+import org.apache.sandesha2.storage.inmemory.InMemBeanMgrFactory;
+import org.apache.sandesha2.storage.persistent.PersistentBeanMgrFactory;
+
+/**
+ * @author Chamikara Jayalath <chamikara@wso2.com>
+ * @author Sanka Samaranayake <ssanka@gmail.com>
+ */
+public abstract class AbstractBeanMgrFactory {
+	public static final int PERSISTENT_STORAGE_TYPE = 1;
+	public static final int IN_MEMORY_STORAGE_TYPE = 2;
+	
+	public abstract CreateSeqBeanMgr getCreateSeqBeanMgr();
+	
+	public abstract NextMsgBeanMgr getNextMsgBean();
+	
+	public abstract RetransmitterBeanMgr getRetransmitterBeanMgr();
+	
+	public abstract SequencePropertyBeanMgr getSequencePropretyBeanMgr();
+	
+	public abstract StorageMapBeanMgr getStorageMapBeanMgr();
+		
+	public static AbstractBeanMgrFactory getBeanMgrFactory (int whichFactory) {
+		switch (whichFactory) {
+			case PERSISTENT_STORAGE_TYPE:
+				return new PersistentBeanMgrFactory();
+			case IN_MEMORY_STORAGE_TYPE:
+				return new  InMemBeanMgrFactory();
+			default: 
+				return null;
+		}
+	}
+}
Index: storage/beans/CreateSeqBean.java
===================================================================
--- storage/beans/CreateSeqBean.java	(revision 278977)
+++ storage/beans/CreateSeqBean.java	(working copy)
@@ -1,28 +1,6 @@
-/*
- * Copyright  1999-2004 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
 package org.apache.sandesha2.storage.beans;
 
-/**
- * @author 
- * 
- */
-
-public class CreateSeqBean implements RMBean {
+public class CreateSeqBean {
 	private String CreateSeqMsgId;
 	private String SequenceId;
 	
@@ -50,4 +28,4 @@
 	public void setSequenceId(String sequenceId) {
 		SequenceId = sequenceId;
 	}
-}
+}
\ No newline at end of file
Index: storage/beans/SequencePropertyBean.java
===================================================================
--- storage/beans/SequencePropertyBean.java	(revision 278977)
+++ storage/beans/SequencePropertyBean.java	(working copy)
@@ -19,7 +19,7 @@
 /**
  * @author Sanka Samaranayake <ssanka@gmail.com>
  */
-public class SequencePropertyBean implements RMBean{
+public class SequencePropertyBean {
 
 	private String sequenceId;
 	private String name;
Index: storage/beans/StorageMapBean.java
===================================================================
--- storage/beans/StorageMapBean.java	(revision 278977)
+++ storage/beans/StorageMapBean.java	(working copy)
@@ -21,7 +21,7 @@
  * @author 
  * 
  */
-public class StorageMapBean implements RMBean {
+public class StorageMapBean {
 
 	private String Key;
 	private int MsgNo;
Index: storage/beans/RetransmitterBean.java
===================================================================
--- storage/beans/RetransmitterBean.java	(revision 278977)
+++ storage/beans/RetransmitterBean.java	(working copy)
@@ -21,12 +21,12 @@
  * @author 
  * 
  */
-public class RetransmitterBean implements RMBean{
+public class RetransmitterBean {
 
-	private String MessageId;
-	private String Key;
+	private String messageId;
+	private String key;
 	private long LastSentTime;
-	private boolean Send; 
+	private Boolean Send; 
 	private String CreateSeqMsgId;
 	
 	
@@ -46,13 +46,13 @@
 	 * @return Returns the key.
 	 */
 	public String getKey() {
-		return Key;
+		return key;
 	}
 	/**
 	 * @param key The key to set.
 	 */
 	public void setKey(String key) {
-		Key = key;
+		this.key = key;
 	}
 	/**
 	 * @return Returns the lastSentTime.
@@ -70,24 +70,24 @@
 	 * @return Returns the messageId.
 	 */
 	public String getMessageId() {
-		return MessageId;
+		return messageId;
 	}
 	/**
 	 * @param messageId The messageId to set.
 	 */
 	public void setMessageId(String messageId) {
-		MessageId = messageId;
+		this.messageId = messageId;
 	}
 	/**
 	 * @return Returns the send.
 	 */
-	public boolean isSend() {
+	public Boolean isSend() {
 		return Send;
 	}
 	/**
 	 * @param send The send to set.
 	 */
-	public void setSend(boolean send) {
-		Send = send;
+	public void setSend(Boolean send) {
+		this.Send = send;
 	}
 }
Index: storage/beans/NextMsgBean.java
===================================================================
--- storage/beans/NextMsgBean.java	(revision 278977)
+++ storage/beans/NextMsgBean.java	(working copy)
@@ -21,7 +21,7 @@
  * @author 
  * 
  */
-public class NextMsgBean implements RMBean {
+public class NextMsgBean {
 	private String SequenceId;
 	private String NextMsgNoToProcess;
 	



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic