[jboss-cvs] jboss-jms/src/main/org/jboss/messaging/util ...
Timothy Fox
tim.fox at jboss.com
Mon Jul 17 13:14:49 EDT 2006
User: timfox
Date: 06/07/17 13:14:49
Added: src/main/org/jboss/messaging/util Future.java
RotatingPool.java
Log:
Many changes including implementation of prefetch, SEDAisation of server, changing of recovery
Revision Changes Path
1.1 date: 2006/07/17 17:14:49; author: timfox; state: Exp;jboss-jms/src/main/org/jboss/messaging/util/Future.java
Index: Future.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.messaging.util;
import org.jboss.logging.Logger;
/**
* A Future
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision: 1.1 $</tt>
*
* $Id: Future.java,v 1.1 2006/07/17 17:14:49 timfox Exp $
*
*/
public class Future
{
private static final Logger log = Logger.getLogger(Future.class);
private Object result;
private boolean isException;
private boolean resultSet;
public synchronized Object getResult()
{
while (!resultSet)
{
try
{
wait();
}
catch (InterruptedException e)
{
log.warn("Thread interrupted", e);
}
}
return result;
}
public synchronized void setResult(Object theResult)
{
result = theResult;
resultSet = true;
notify();
}
public synchronized void setException(Throwable t)
{
result = t;
isException = true;
resultSet = true;
notify();
}
public boolean isException()
{
return isException;
}
}
1.1 date: 2006/07/17 17:14:49; author: timfox; state: Exp;jboss-jms/src/main/org/jboss/messaging/util/RotatingPool.java
Index: RotatingPool.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.messaging.util;
import java.util.HashMap;
import java.util.Map;
import org.jboss.logging.Logger;
/**
* A RotatingPool
*
* This class makes sure requests on the same key always get the same value, and
* values for a specific key are obtained from a fixed size array of instances in
* a rotating fashion
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision: 1.1 $</tt>
*
* $Id: RotatingPool.java,v 1.1 2006/07/17 17:14:49 timfox Exp $
*
*/
public abstract class RotatingPool
{
private static final Logger log = Logger.getLogger(RotatingPool.class);
private int maxSize;
private int pos;
private Object[] entries;
private Map keyMappings;
public RotatingPool(int maxSize)
{
this.maxSize = maxSize;
this.entries = new Object[maxSize];
this.keyMappings = new HashMap();
}
public synchronized Object get(Object key)
{
//Does the mapping already exist?
Object entry = keyMappings.get(key);
if (entry == null)
{
//Create a new entry allocating from the rotating pool
entry = entries[pos];
if (entry == null)
{
entry = entries[pos] = createEntry();
}
keyMappings.put(key, entry);
pos++;
if (pos == maxSize)
{
pos = 0;
}
}
return entry;
}
protected abstract Object createEntry();
}
More information about the jboss-cvs-commits
mailing list