User: chirino
Date: 01/08/31 20:00:59
Modified: src/main/org/jboss/mq/pm/file PersistenceManager.java
PersistenceManagerMBean.java
Log:
Fixing compile problems due to migration of classes from jboss.util to jboss.system
Revision Changes Path
1.4 +462 -255 jbossmq/src/main/org/jboss/mq/pm/file/PersistenceManager.java
Index: PersistenceManager.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/pm/file/PersistenceManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PersistenceManager.java 2001/08/30 02:34:52 1.3
+++ PersistenceManager.java 2001/09/01 03:00:59 1.4
@@ -1,5 +1,5 @@
/*
- * JBossMQ, the OpenSource JMS implementation
+ * JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -15,6 +15,11 @@
import java.util.TreeSet;
import javax.jms.JMSException;
+
+
+
+
+
import javax.management.*;
import org.jboss.mq.SpyDestination;
@@ -23,7 +28,6 @@
import org.jboss.mq.pm.TxManager;
import org.jboss.mq.server.JMSDestination;
import org.jboss.mq.server.JMSServer;
-
import org.jboss.system.ServiceMBeanSupport;
/**
@@ -31,358 +35,512 @@
* persistence.
*
* @author Paul Kendall ([EMAIL PROTECTED])
- * @created August 16, 2001
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
-public class PersistenceManager extends org.jboss.system.ServiceMBeanSupport
implements PersistenceManagerMBean, org.jboss.mq.pm.PersistenceManager {
+public class PersistenceManager extends ServiceMBeanSupport implements
PersistenceManagerMBean, org.jboss.mq.pm.PersistenceManager
+{
+
+ protected final static int MAX_POOL_SIZE = 50;
protected java.util.ArrayList txPool = new java.util.ArrayList();
- protected long tidcounter = Long.MIN_VALUE;
+ protected long tidcounter = Long.MIN_VALUE;
// The directory where persistence data should be stored
- String dataDirectory;
- URL dataDirURL;
- File dataDirFile;
+ String dataDirectory;
+ URL dataDirURL;
+ File dataDirFile;
//tx manager
org.jboss.mq.pm.TxManager txManager;
// Maps SpyDestinations to SpyMessageLogs
- HashMap messageLogs = new HashMap();
+ HashMap messageLogs = new HashMap();
// Maps (Long)txIds to LinkedList of AddFile tasks
- HashMap transactedTasks = new HashMap();
+ HashMap transactedTasks = new HashMap();
- protected final static int MAX_POOL_SIZE = 50;
-
/**
* PersistenceManager constructor.
*
* @exception javax.jms.JMSException Description of Exception
*/
- public PersistenceManager()
- throws javax.jms.JMSException {
- txManager = new TxManager( this );
+ public PersistenceManager() throws javax.jms.JMSException
+ {
+ txManager = new TxManager(this);
}
- public void setDataDirectory( java.lang.String newDataDirectory ) {
+ /**
+ * Sets the DataDirectory attribute of the PersistenceManager object
+ *
+ * @param newDataDirectory The new DataDirectory value
+ */
+ public void setDataDirectory(java.lang.String newDataDirectory)
+ {
dataDirectory = newDataDirectory;
}
- public String getName() {
+ /**
+ * Gets the Name attribute of the PersistenceManager object
+ *
+ * @return The Name value
+ */
+ public String getName()
+ {
return "JBossMQ-PersistenceManager";
}
- public java.lang.String getDataDirectory() {
+ /**
+ * Gets the DataDirectory attribute of the PersistenceManager object
+ *
+ * @return The DataDirectory value
+ */
+ public java.lang.String getDataDirectory()
+ {
return dataDirectory;
}
- public org.jboss.mq.pm.TxManager getTxManager() {
+ /**
+ * Gets the TxManager attribute of the PersistenceManager object
+ *
+ * @return The TxManager value
+ */
+ public org.jboss.mq.pm.TxManager getTxManager()
+ {
return txManager;
}
- public void initService()
- throws Exception {
-
- //URL configFile = getClass().getClassLoader().getResource( "jboss.jcml" );
- //dataDirURL = new URL( configFile, dataDirectory );
- //dataDirFile = new File( dataDirURL.getFile() );
-
- File homeDir = new File(System.getProperty("jboss.system.home"));
- dataDirFile = new File(homeDir,dataDirectory);
- System.out.println("DATADIRFILE"+ dataDirFile.getAbsolutePath());
- dataDirURL = dataDirFile.toURL();
-
- JMSServer server = ( JMSServer )getServer().invoke( new ObjectName(
org.jboss.mq.server.JBossMQServiceMBean.OBJECT_NAME ), "getJMSServer", new Object[]{},
new String[]{} );
- server.setPersistenceManager( this );
- }
-
- public void startService()
- throws Exception {
- JMSServer server = ( JMSServer )getServer().invoke( new ObjectName(
org.jboss.mq.server.JBossMQServiceMBean.OBJECT_NAME ), "getJMSServer", new Object[]{},
new String[]{} );
- restore( server );
+ /**
+ * #Description of the Method
+ *
+ * @exception Exception Description of Exception
+ */
+ public void initService() throws Exception
+ {
+ URL configFile = getClass().getClassLoader().getResource("jboss.jcml");
+ dataDirURL = new URL(configFile, dataDirectory);
+ dataDirFile = new File(dataDirURL.getFile());
+ JMSServer server = (JMSServer)getServer().invoke(new
ObjectName(org.jboss.mq.server.JBossMQServiceMBean.OBJECT_NAME), "getJMSServer", new
Object[]{}, new String[]{});
+ server.setPersistenceManager(this);
}
- public void restore( JMSServer server )
- throws javax.jms.JMSException {
+ /**
+ * #Description of the Method
+ *
+ * @exception Exception Description of Exception
+ */
+ public void startService() throws Exception
+ {
+ JMSServer server = (JMSServer)getServer().invoke(new
ObjectName(org.jboss.mq.server.JBossMQServiceMBean.OBJECT_NAME), "getJMSServer", new
Object[]{}, new String[]{});
+ restore(server);
+ }
+
+ /**
+ * #Description of the Method
+ *
+ * @param server Description of Parameter
+ * @exception javax.jms.JMSException Description of Exception
+ */
+ public void restore(JMSServer server) throws javax.jms.JMSException
+ {
//reconstruct TXs
TreeSet txs = new TreeSet();
File[] transactFiles = dataDirFile.listFiles();
- for ( int i = 0; i < transactFiles.length; i++ ) {
- try {
- Long tx = new Long( Long.parseLong( transactFiles[i].getName() ) );
- java.util.ArrayList removingMessages = readTxFile( transactFiles[i] );
- if ( testRollBackTx( tx, removingMessages ) ) {
- txs.add( tx );
+ for (int i = 0; i < transactFiles.length; i++)
+ {
+ try
+ {
+ Long tx = new Long(Long.parseLong(transactFiles[i].getName()));
+ java.util.ArrayList removingMessages = readTxFile(transactFiles[i]);
+ if (testRollBackTx(tx, removingMessages))
+ {
+ txs.add(tx);
}
- } catch ( NumberFormatException e ) {
- System.out.println( "Ignoring invalid transaction record file " +
transactFiles[i].getAbsolutePath() );
+ }
+ catch (NumberFormatException e)
+ {
+ System.out.println("Ignoring invalid transaction record file " +
transactFiles[i].getAbsolutePath());
transactFiles[i] = null;
- } catch ( IOException e ) {
- JMSException jmse = new SpyJMSException( "IO Error when restoring." );
- jmse.setLinkedException( e );
+ }
+ catch (IOException e)
+ {
+ JMSException jmse = new SpyJMSException("IO Error when restoring.");
+ jmse.setLinkedException(e);
throw jmse;
}
}
- if ( !txs.isEmpty() ) {
- this.tidcounter = ( ( Long )txs.last() ).longValue() + 1;
+ if (!txs.isEmpty())
+ {
+ this.tidcounter = ((Long)txs.last()).longValue() + 1;
}
HashMap clone;
- synchronized ( messageLogs ) {
- clone = ( HashMap )messageLogs.clone();
+ synchronized (messageLogs)
+ {
+ clone = (HashMap)messageLogs.clone();
}
Iterator iter = clone.values().iterator();
- while ( iter.hasNext() ) {
- LogInfo logInfo = ( LogInfo )iter.next();
- JMSDestination q = server.getJMSDestination( logInfo.destination );
- SpyMessage rebuild[] = logInfo.log.restore( txs );
+ while (iter.hasNext())
+ {
+ LogInfo logInfo = (LogInfo)iter.next();
+ JMSDestination q = server.getJMSDestination(logInfo.destination);
+ SpyMessage rebuild[] = logInfo.log.restore(txs);
//TODO: make sure this lock is good enough
- synchronized ( q ) {
- for ( int i = 0; i < rebuild.length; i++ ) {
- if ( logInfo.destination instanceof org.jboss.mq.SpyTopic ) {
- rebuild[i].durableSubscriberID = ( ( org.jboss.mq.SpyTopic
)logInfo.destination ).getDurableSubscriptionID();
+ synchronized (q)
+ {
+ for (int i = 0; i < rebuild.length; i++)
+ {
+ if (logInfo.destination instanceof org.jboss.mq.SpyTopic)
+ {
+ rebuild[i].durableSubscriberID =
((org.jboss.mq.SpyTopic)logInfo.destination).getDurableSubscriptionID();
}
- q.restoreMessage( rebuild[i] );
+ q.restoreMessage(rebuild[i]);
}
}
}
//all txs now committed or rolled back so delete tx files
- for ( int i = 0; i < transactFiles.length; i++ ) {
- if ( transactFiles[i] != null ) {
- deleteTxFile( transactFiles[i] );
+ for (int i = 0; i < transactFiles.length; i++)
+ {
+ if (transactFiles[i] != null)
+ {
+ deleteTxFile(transactFiles[i]);
}
}
}
- public void initQueue( SpyDestination dest )
- throws javax.jms.JMSException {
- try {
- URL logDir = new URL( dataDirURL, dest.toString() );
- MessageLog log = new MessageLog( logDir.getFile() );
- LogInfo info = new LogInfo( log, dest );
- synchronized ( messageLogs ) {
- messageLogs.put( dest.toString(), info );
+ /**
+ * #Description of the Method
+ *
+ * @param dest Description of Parameter
+ * @exception javax.jms.JMSException Description of Exception
+ */
+ public void initQueue(SpyDestination dest) throws javax.jms.JMSException
+ {
+ try
+ {
+ URL logDir = new URL(dataDirURL, dest.toString());
+ MessageLog log = new MessageLog(logDir.getFile());
+ LogInfo info = new LogInfo(log, dest);
+ synchronized (messageLogs)
+ {
+ messageLogs.put(dest.toString(), info);
}
- } catch ( javax.jms.JMSException e ) {
+ }
+ catch (javax.jms.JMSException e)
+ {
throw e;
- } catch ( Exception e ) {
- javax.jms.JMSException newE = new javax.jms.JMSException( "Invalid
configuration." );
- newE.setLinkedException( e );
+ }
+ catch (Exception e)
+ {
+ javax.jms.JMSException newE = new javax.jms.JMSException("Invalid
configuration.");
+ newE.setLinkedException(e);
throw newE;
}
}
- public void destroyQueue( SpyDestination dest )
- throws javax.jms.JMSException {
- try {
- URL logDir = new URL( dataDirURL, dest.toString() );
- java.io.File file = new java.io.File( logDir.getFile() );
+ /**
+ * #Description of the Method
+ *
+ * @param dest Description of Parameter
+ * @exception javax.jms.JMSException Description of Exception
+ */
+ public void destroyQueue(SpyDestination dest) throws javax.jms.JMSException
+ {
+ try
+ {
+ URL logDir = new URL(dataDirURL, dest.toString());
+ java.io.File file = new java.io.File(logDir.getFile());
LogInfo logInfo;
- synchronized ( messageLogs ) {
- logInfo = ( LogInfo )messageLogs.remove( dest.toString() );
+ synchronized (messageLogs)
+ {
+ logInfo = (LogInfo)messageLogs.remove(dest.toString());
+ }
+ if (logInfo == null)
+ {
+ throw new JMSException("The persistence log was never initialized");
}
- if ( logInfo == null ) {
- throw new JMSException( "The persistence log was never initialized" );
- }
logInfo.log.close();
file.delete();
- } catch ( javax.jms.JMSException e ) {
+ }
+ catch (javax.jms.JMSException e)
+ {
throw e;
- } catch ( Exception e ) {
- javax.jms.JMSException newE = new javax.jms.JMSException( "Invalid
configuration." );
- newE.setLinkedException( e );
+ }
+ catch (Exception e)
+ {
+ javax.jms.JMSException newE = new javax.jms.JMSException("Invalid
configuration.");
+ newE.setLinkedException(e);
throw newE;
}
}
- public void add( org.jboss.mq.SpyMessage message, org.jboss.mq.pm.Tx txId )
- throws javax.jms.JMSException {
+ /**
+ * #Description of the Method
+ *
+ * @param message Description of Parameter
+ * @param txId Description of Parameter
+ * @exception javax.jms.JMSException Description of Exception
+ */
+ public void add(org.jboss.mq.SpyMessage message, org.jboss.mq.pm.Tx txId) throws
javax.jms.JMSException
+ {
LogInfo logInfo;
- synchronized ( messageLogs ) {
- logInfo = ( LogInfo )messageLogs.get(
message.getJMSDestination().toString() );
- }
- if ( logInfo == null ) {
- throw new javax.jms.JMSException( "Destination was not initalized with the
PersistenceManager" );
+ synchronized (messageLogs)
+ {
+ logInfo = (LogInfo)messageLogs.get(message.getJMSDestination().toString());
+ }
+ if (logInfo == null)
+ {
+ throw new javax.jms.JMSException("Destination was not initalized with the
PersistenceManager");
+ }
+ logInfo.log.add(message, txId);
+ if (txId == null)
+ {
+ logInfo.log.finishAdd(message, txId);
}
- logInfo.log.add( message, txId );
- if ( txId == null ) {
- logInfo.log.finishAdd( message, txId );
- } else {
+ else
+ {
TxInfo info;
- synchronized ( transactedTasks ) {
- info = ( TxInfo )transactedTasks.get( txId );
+ synchronized (transactedTasks)
+ {
+ info = (TxInfo)transactedTasks.get(txId);
+ }
+ if (info == null)
+ {
+ throw new javax.jms.JMSException("Transaction is not active 5.");
+ }
+ synchronized (info.tasks)
+ {
+ info.tasks.addLast(new Transaction(true, logInfo, message, txId));
}
- if ( info == null ) {
- throw new javax.jms.JMSException( "Transaction is not active 5." );
- }
- synchronized ( info.tasks ) {
- info.tasks.addLast( new Transaction( true, logInfo, message, txId ) );
- }
}
}
- public void commitPersistentTx( org.jboss.mq.pm.Tx txId )
- throws javax.jms.JMSException {
+ /**
+ * #Description of the Method
+ *
+ * @param txId Description of Parameter
+ * @exception javax.jms.JMSException Description of Exception
+ */
+ public void commitPersistentTx(org.jboss.mq.pm.Tx txId) throws
javax.jms.JMSException
+ {
TxInfo info;
- synchronized ( transactedTasks ) {
- info = ( TxInfo )transactedTasks.remove( txId );
+ synchronized (transactedTasks)
+ {
+ info = (TxInfo)transactedTasks.remove(txId);
}
//ensure record of tx exists
- try {
+ try
+ {
info.raf.close();
- } catch ( IOException e ) {
- JMSException jmse = new SpyJMSException( "IO Error when closing raf for
tx." );
- jmse.setLinkedException( e );
+ }
+ catch (IOException e)
+ {
+ JMSException jmse = new SpyJMSException("IO Error when closing raf for
tx.");
+ jmse.setLinkedException(e);
throw jmse;
}
- synchronized ( info.tasks ) {
+ synchronized (info.tasks)
+ {
Iterator iter = info.tasks.iterator();
- while ( iter.hasNext() ) {
- Transaction task = ( Transaction )iter.next();
+ while (iter.hasNext())
+ {
+ Transaction task = (Transaction)iter.next();
task.commit();
}
}
- deleteTxFile( info.txf );
- releaseTxInfo( info );
+ deleteTxFile(info.txf);
+ releaseTxInfo(info);
}
- public org.jboss.mq.pm.Tx createPersistentTx()
- throws javax.jms.JMSException {
+ /**
+ * #Description of the Method
+ *
+ * @return Description of the Returned Value
+ * @exception javax.jms.JMSException Description of Exception
+ */
+ public org.jboss.mq.pm.Tx createPersistentTx() throws javax.jms.JMSException
+ {
org.jboss.mq.pm.Tx txId = null;
- synchronized ( transactedTasks ) {
- txId = new org.jboss.mq.pm.Tx( tidcounter++ );
- transactedTasks.put( txId, getTxInfo( createTxFile( txId ) ) );
+ synchronized (transactedTasks)
+ {
+ txId = new org.jboss.mq.pm.Tx(tidcounter++);
+ transactedTasks.put(txId, getTxInfo(createTxFile(txId)));
}
return txId;
}
- public void remove( org.jboss.mq.SpyMessage message, org.jboss.mq.pm.Tx txId )
- throws javax.jms.JMSException {
+ /**
+ * #Description of the Method
+ *
+ * @param message Description of Parameter
+ * @param txId Description of Parameter
+ * @exception javax.jms.JMSException Description of Exception
+ */
+ public void remove(org.jboss.mq.SpyMessage message, org.jboss.mq.pm.Tx txId)
throws javax.jms.JMSException
+ {
LogInfo logInfo;
- synchronized ( messageLogs ) {
- logInfo = ( LogInfo )messageLogs.get(
message.getJMSDestination().toString() );
+ synchronized (messageLogs)
+ {
+ logInfo = (LogInfo)messageLogs.get(message.getJMSDestination().toString());
}
- if ( logInfo == null ) {
- throw new javax.jms.JMSException( "Destination was not initalized with the
PersistenceManager" );
+ if (logInfo == null)
+ {
+ throw new javax.jms.JMSException("Destination was not initalized with the
PersistenceManager");
}
- logInfo.log.remove( message, txId );
- if ( txId == null ) {
- logInfo.log.finishRemove( message, txId );
- } else {
+ logInfo.log.remove(message, txId);
+ if (txId == null)
+ {
+ logInfo.log.finishRemove(message, txId);
+ }
+ else
+ {
TxInfo info;
- synchronized ( transactedTasks ) {
- info = ( TxInfo )transactedTasks.get( txId );
- }
- if ( info == null ) {
- throw new javax.jms.JMSException( "Transaction is not active 6." );
- }
- try {
- info.raf.writeUTF( message.getJMSMessageID() );
- } catch ( IOException e ) {
- JMSException jmse = new SpyJMSException( "IO Error when recording
remove in txs raf." );
- jmse.setLinkedException( e );
+ synchronized (transactedTasks)
+ {
+ info = (TxInfo)transactedTasks.get(txId);
+ }
+ if (info == null)
+ {
+ throw new javax.jms.JMSException("Transaction is not active 6.");
+ }
+ try
+ {
+ info.raf.writeUTF(message.getJMSMessageID());
+ }
+ catch (IOException e)
+ {
+ JMSException jmse = new SpyJMSException("IO Error when recording remove
in txs raf.");
+ jmse.setLinkedException(e);
throw jmse;
}
- synchronized ( info.tasks ) {
- info.tasks.addLast( new Transaction( false, logInfo, message, txId ) );
+ synchronized (info.tasks)
+ {
+ info.tasks.addLast(new Transaction(false, logInfo, message, txId));
}
}
}
- public void rollbackPersistentTx( org.jboss.mq.pm.Tx txId )
- throws javax.jms.JMSException {
+ /**
+ * #Description of the Method
+ *
+ * @param txId Description of Parameter
+ * @exception javax.jms.JMSException Description of Exception
+ */
+ public void rollbackPersistentTx(org.jboss.mq.pm.Tx txId) throws
javax.jms.JMSException
+ {
TxInfo info;
- synchronized ( transactedTasks ) {
- info = ( TxInfo )transactedTasks.remove( txId );
+ synchronized (transactedTasks)
+ {
+ info = (TxInfo)transactedTasks.remove(txId);
}
//ensure record of tx exists
- try {
+ try
+ {
info.raf.close();
- } catch ( IOException e ) {
- JMSException jmse = new SpyJMSException( "IO Error when closing raf for
tx." );
- jmse.setLinkedException( e );
+ }
+ catch (IOException e)
+ {
+ JMSException jmse = new SpyJMSException("IO Error when closing raf for
tx.");
+ jmse.setLinkedException(e);
throw jmse;
}
- synchronized ( info.tasks ) {
+ synchronized (info.tasks)
+ {
Iterator iter = info.tasks.iterator();
- while ( iter.hasNext() ) {
- Transaction task = ( Transaction )iter.next();
+ while (iter.hasNext())
+ {
+ Transaction task = (Transaction)iter.next();
task.rollback();
}
}
- deleteTxFile( info.txf );
- releaseTxInfo( info );
+ deleteTxFile(info.txf);
+ releaseTxInfo(info);
}
- protected TxInfo getTxInfo( File f )
- throws JMSException {
+ protected TxInfo getTxInfo(File f) throws JMSException
+ {
TxInfo info;
- synchronized ( txPool ) {
- if ( txPool.isEmpty() ) {
+ synchronized (txPool)
+ {
+ if (txPool.isEmpty())
+ {
info = new TxInfo();
- } else {
- info = ( TxInfo )txPool.remove( txPool.size() - 1 );
+ }
+ else
+ {
+ info = (TxInfo)txPool.remove(txPool.size() - 1);
}
}
- info.setFile( f );
+ info.setFile(f);
return info;
}
- protected void releaseTxInfo( TxInfo info ) {
- synchronized ( txPool ) {
- if ( txPool.size() < MAX_POOL_SIZE ) {
+ protected void releaseTxInfo(TxInfo info)
+ {
+ synchronized (txPool)
+ {
+ if (txPool.size() < MAX_POOL_SIZE)
+ {
info.tasks.clear();
- txPool.add( info );
+ txPool.add(info);
}
}
}
- protected boolean testRollBackTx( Long tx, java.util.ArrayList removingMessages )
- throws IOException {
+ protected boolean testRollBackTx(Long tx, java.util.ArrayList removingMessages)
throws IOException
+ {
//checks to see if this tx was in the middle of committing.
//If it was finish commit and return false else return true.
HashMap clone;
- synchronized ( messageLogs ) {
- clone = ( HashMap )messageLogs.clone();
+ synchronized (messageLogs)
+ {
+ clone = (HashMap)messageLogs.clone();
}
java.util.ArrayList files = new java.util.ArrayList();
boolean foundAll = true;
- for ( int i = 0; i < removingMessages.size(); i++ ) {
- String fileName = removingMessages.get( i ) + "." + tx;
+ for (int i = 0; i < removingMessages.size(); i++)
+ {
+ String fileName = removingMessages.get(i) + "." + tx;
boolean found = false;
- for ( Iterator it = clone.keySet().iterator(); !found && it.hasNext(); ) {
- String dirName = ( String )it.next();
- File dir = new File( dataDirFile, dirName );
+ for (Iterator it = clone.keySet().iterator(); !found && it.hasNext(); )
+ {
+ String dirName = (String)it.next();
+ File dir = new File(dataDirFile, dirName);
File[] messageFiles = dir.listFiles();
- for ( int j = 0; j < messageFiles.length; ++j ) {
- if ( messageFiles[j].getName().equals( fileName ) ) {
+ for (int j = 0; j < messageFiles.length; ++j)
+ {
+ if (messageFiles[j].getName().equals(fileName))
+ {
found = true;
- files.add( messageFiles[j] );
+ files.add(messageFiles[j]);
break;
}
}
}
- if ( !found ) {
+ if (!found)
+ {
foundAll = false;
}
}
- if ( !foundAll ) {
+ if (!foundAll)
+ {
//tx being committed so need to finish it by deleting files.
- for ( int i = 0; i < files.size(); ++i ) {
- File f = ( File )files.get( i );
- if ( !f.delete() ) {
+ for (int i = 0; i < files.size(); ++i)
+ {
+ File f = (File)files.get(i);
+ if (!f.delete())
+ {
Thread.yield();
//try again
- if ( !f.delete() ) {
- throw new IOException( "Could not delete file " +
f.getAbsolutePath() );
+ if (!f.delete())
+ {
+ throw new IOException("Could not delete file " +
f.getAbsolutePath());
}
}
}
@@ -392,121 +550,170 @@
}
- protected void deleteTxFile( File file )
- throws javax.jms.JMSException {
- if ( !file.delete() ) {
+
+ protected void deleteTxFile(File file) throws javax.jms.JMSException
+ {
+ if (!file.delete())
+ {
Thread.yield();
- if ( file.exists() && !file.delete() ) {
- throw new javax.jms.JMSException( "Unable to delete committing
transaction record." );
+ if (file.exists() && !file.delete())
+ {
+ throw new javax.jms.JMSException("Unable to delete committing
transaction record.");
}
}
}
- protected java.util.ArrayList readTxFile( File file )
- throws javax.jms.JMSException {
- try {
+ protected java.util.ArrayList readTxFile(File file) throws javax.jms.JMSException
+ {
+ try
+ {
java.util.ArrayList result = new java.util.ArrayList();
- java.io.RandomAccessFile raf = new java.io.RandomAccessFile( file, "r" );
- try {
- while ( true ) {
- result.add( raf.readUTF() );
+ java.io.RandomAccessFile raf = new java.io.RandomAccessFile(file, "r");
+ try
+ {
+ while (true)
+ {
+ result.add(raf.readUTF());
}
- } catch ( java.io.EOFException e ) {
+ }
+ catch (java.io.EOFException e)
+ {
}
raf.close();
return result;
- } catch ( IOException e ) {
- JMSException newE = new SpyJMSException( "Unable to read committing
transaction record." );
- newE.setLinkedException( e );
+ }
+ catch (IOException e)
+ {
+ JMSException newE = new SpyJMSException("Unable to read committing
transaction record.");
+ newE.setLinkedException(e);
throw newE;
}
}
- protected File createTxFile( org.jboss.mq.pm.Tx txId )
- throws javax.jms.JMSException {
- try {
- File file = new File( dataDirFile, txId.toString() );
- if ( !file.createNewFile() ) {
- throw new javax.jms.JMSException( "Error creating tx file." );
+ protected File createTxFile(org.jboss.mq.pm.Tx txId) throws
javax.jms.JMSException
+ {
+ try
+ {
+ File file = new File(dataDirFile, txId.toString());
+ if (!file.createNewFile())
+ {
+ throw new javax.jms.JMSException("Error creating tx file.");
}
return file;
- } catch ( IOException e ) {
- JMSException newE = new SpyJMSException( "Unable to create committing
transaction record." );
- newE.setLinkedException( e );
+ }
+ catch (IOException e)
+ {
+ JMSException newE = new SpyJMSException("Unable to create committing
transaction record.");
+ newE.setLinkedException(e);
throw newE;
}
}
/**
- * @created August 16, 2001
+ * #Description of the Class
*/
- class TxInfo {
- File txf;
+ class TxInfo
+ {
+ File txf;
java.io.RandomAccessFile raf;
- LinkedList tasks = new LinkedList();
+ LinkedList tasks = new LinkedList();
- TxInfo()
- throws JMSException {
+ TxInfo() throws JMSException
+ {
}
- void setFile( File f )
- throws JMSException {
+ void setFile(File f) throws JMSException
+ {
txf = f;
- try {
- raf = new java.io.RandomAccessFile( txf, "rw" );
- } catch ( IOException e ) {
- JMSException jmse = new SpyJMSException( "IO Error create raf for
txinfo." );
- jmse.setLinkedException( e );
+ try
+ {
+ raf = new java.io.RandomAccessFile(txf, "rw");
+ }
+ catch (IOException e)
+ {
+ JMSException jmse = new SpyJMSException("IO Error create raf for
txinfo.");
+ jmse.setLinkedException(e);
throw jmse;
}
}
}
/**
- * @created August 16, 2001
+ * #Description of the Class
*/
- class LogInfo {
- MessageLog log;
+ class LogInfo
+ {
+ MessageLog log;
SpyDestination destination;
- LogInfo( MessageLog log, SpyDestination destination ) {
+ LogInfo(MessageLog log, SpyDestination destination)
+ {
this.log = log;
this.destination = destination;
}
}
+
+
+
/**
- * @created August 16, 2001
+ * #Description of the Class
*/
- class Transaction {
+ class Transaction
+ {
private LogInfo logInfo;
private SpyMessage message;
private org.jboss.mq.pm.Tx txId;
private boolean add;
- public Transaction( boolean add, LogInfo logInfo, SpyMessage message,
org.jboss.mq.pm.Tx txId ) {
+ /**
+ * Constructor for the Transaction object
+ *
+ * @param add Description of Parameter
+ * @param logInfo Description of Parameter
+ * @param message Description of Parameter
+ * @param txId Description of Parameter
+ */
+ public Transaction(boolean add, LogInfo logInfo, SpyMessage message,
org.jboss.mq.pm.Tx txId)
+ {
this.add = add;
this.logInfo = logInfo;
this.message = message;
this.txId = txId;
}
- public void commit()
- throws JMSException {
- if ( add ) {
- logInfo.log.finishAdd( message, txId );
- } else {
- logInfo.log.finishRemove( message, txId );
+ /**
+ * #Description of the Method
+ *
+ * @exception JMSException Description of Exception
+ */
+ public void commit() throws JMSException
+ {
+ if (add)
+ {
+ logInfo.log.finishAdd(message, txId);
+ }
+ else
+ {
+ logInfo.log.finishRemove(message, txId);
}
}
- public void rollback()
- throws JMSException {
- if ( add ) {
- logInfo.log.undoAdd( message, txId );
- } else {
- logInfo.log.undoRemove( message, txId );
+ /**
+ * #Description of the Method
+ *
+ * @exception JMSException Description of Exception
+ */
+ public void rollback() throws JMSException
+ {
+ if (add)
+ {
+ logInfo.log.undoAdd(message, txId);
+ }
+ else
+ {
+ logInfo.log.undoRemove(message, txId);
}
}
}
1.4 +17 -34
jbossmq/src/main/org/jboss/mq/pm/file/PersistenceManagerMBean.java
Index: PersistenceManagerMBean.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/pm/file/PersistenceManagerMBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PersistenceManagerMBean.java 2001/08/30 02:35:54 1.3
+++ PersistenceManagerMBean.java 2001/09/01 03:00:59 1.4
@@ -1,51 +1,34 @@
-package org.jboss.mq.pm.file;
-
-/*
- * jBoss, the OpenSource EJB server
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-/*
- * jBoss, the OpenSource EJB server
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-/*
- * jBoss, the OpenSource EJB server
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
/*
- * jBoss, the OpenSource EJB server
+ * JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
+package org.jboss.mq.pm.file;
-/*
- * jBoss, the OpenSource EJB server
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+import org.jboss.system.ServiceMBean;
/**
* <description>MBean interface for the JBossMQ JMX service.
*
* @author Vincent Sheffer ([EMAIL PROTECTED])
- * @created August 16, 2001
* @see <related>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public interface PersistenceManagerMBean
- extends org.jboss.system.ServiceMBean {
+ extends ServiceMBean
+{
+ /**
+ * Gets the DataDirectory attribute of the PersistenceManagerMBean object
+ *
+ * @return The DataDirectory value
+ */
public java.lang.String getDataDirectory();
- public void setDataDirectory( java.lang.String newDataDirectory );
+ /**
+ * Sets the DataDirectory attribute of the PersistenceManagerMBean object
+ *
+ * @param newDataDirectory The new DataDirectory value
+ */
+ public void setDataDirectory(java.lang.String newDataDirectory);
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development