[jboss-svn-commits] JBL Code SVN: r9393 - in labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx: jts and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 8 09:01:48 EST 2007


Author: kevin.conner at jboss.com
Date: 2007-02-08 09:01:48 -0500 (Thu, 08 Feb 2007)
New Revision: 9393

Modified:
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerService.java
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerServiceMBean.java
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerServiceMBean.java
Log:
Make properties RW: JBTM-196

Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerService.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerService.java	2007-02-07 21:20:56 UTC (rev 9392)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerService.java	2007-02-08 14:01:48 UTC (rev 9393)
@@ -97,6 +97,8 @@
 	private RecoveryManager _recoveryManager;
     private boolean _runRM = true;
     private int timeout ;
+    private boolean started ;
+    private byte[] startedLock = new byte[0] ;
 
     /**
      * Use the short class name as the default for the service name.
@@ -116,6 +118,10 @@
      */
     protected void startService() throws Exception
     {
+	synchronized(startedLock)
+	{
+	    started = true ;
+	}
 
         this.getLog().info("JBossTS Transaction Service (JTA version) - JBoss Inc.");
 
@@ -298,13 +304,42 @@
      *
      * @param timeout The default timeout in seconds for all transactions created
      * using this transaction manager.
+     * 
+     * @throws IllegalStateException if the MBean has already started.
      */
-    public void setTransactionTimeout(int timeout) throws javax.transaction.SystemException
+    public void setTransactionTimeout(int timeout) throws IllegalStateException
     {
-        this.timeout = timeout ;
+	synchronized(startedLock)
+	{
+            if (started)
+            {
+        	if (this.timeout != timeout)
+        	{
+        	    throw new IllegalStateException("Cannot set transaction timeout once MBean has started") ;
+        	}
+            }
+            else
+            {
+        	this.timeout = timeout ;
+            }
+	}
     }
 
     /**
+     * Get the default transaction timeout used by this transaction manager.
+     *
+     * @return The default timeout in seconds for all transactions created
+     * using this transaction manager.
+     */
+    public int getTransactionTimeout()
+    {
+	synchronized(startedLock)
+	{
+	    return (started ? timeout : TxControl.getDefaultTimeout()) ;
+	}
+    }
+
+    /**
      * Retrieve a reference to the JTA transaction manager.
      *
      * @return A reference to the JTA transaction manager.
@@ -420,24 +455,82 @@
     }
 
     /**
-     * Returns whether the recovery manager should be ran in the same VM as
+     * Set whether the recovery manager should be ran in the same VM as
      * JBoss.  If this is false the Recovery Manager is already expected to
      * be running when JBoss starts.
      * @param runRM
+     * 
+     * @throws IllegalStateException If the MBean has already started.
      */
     public void setRunInVMRecoveryManager(boolean runRM)
+        throws IllegalStateException
     {
-        _runRM = runRM;
+	synchronized(startedLock)
+	{
+            if (started)
+            {
+        	if (this._runRM != runRM)
+        	{
+        	    throw new IllegalStateException("Cannot set run in VM recovery manager once MBean has started") ;
+        	}
+            }
+            else
+            {
+        	_runRM = runRM;
+            }
+	}
     }
+
+    /**
+     * Get whether the recovery manager should be ran in the same VM as
+     * JBoss.  If this is false the Recovery Manager is already expected to
+     * be running when JBoss starts.
+     * 
+     * @return true if the recover manager is running in the same VM, false otherwise.
+     */
+    public boolean getRunInVMRecoveryManager()
+    {
+	synchronized(startedLock)
+	{
+	    return _runRM ;
+	}
+    }
     
     /**
      * Set the object store directory.
      * @param objectStoreDir The object store directory.
+     * 
+     * @throws IllegalStateException if the MBean has already started.
      */
     public void setObjectStoreDir(final String objectStoreDir)
+    	throws IllegalStateException
     {
-	System.setProperty(com.arjuna.ats.arjuna.common.Environment.OBJECTSTORE_DIR, objectStoreDir) ;
+        synchronized(startedLock)
+        {
+            if (started)
+            {
+        	final String currentDir = getObjectStoreDir() ;
+        	final boolean equal = (currentDir == null ? objectStoreDir == null : currentDir.equals(objectStoreDir)) ;
+        	if (!equal)
+        	{
+        	    throw new IllegalStateException("Cannot set object store dir once MBean has started") ;
+        	}
+            }
+            else
+            {
+        	System.setProperty(com.arjuna.ats.arjuna.common.Environment.OBJECTSTORE_DIR, objectStoreDir) ;
+            }
+        }
     }
+    
+    /**
+     * Get the object store directory.
+     * @return objectStoreDir The object store directory.
+     */
+    public String getObjectStoreDir()
+    {
+	return System.getProperty(com.arjuna.ats.arjuna.common.Environment.OBJECTSTORE_DIR) ;
+    }
 
     private void registerNotification()
         throws InstanceNotFoundException

Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerServiceMBean.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerServiceMBean.java	2007-02-07 21:20:56 UTC (rev 9392)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerServiceMBean.java	2007-02-08 14:01:48 UTC (rev 9393)
@@ -50,10 +50,20 @@
      *
      * @param timeout The default timeout in seconds for all transactions created
      * using this transaction manager.
+     * 
+     * @throws IllegalStateException if the MBean has already started.
      */
-    public void setTransactionTimeout(int timeout) throws javax.transaction.SystemException;
+    public void setTransactionTimeout(int timeout) throws IllegalStateException ;
 
     /**
+     * Get the default transaction timeout used by this transaction manager.
+     *
+     * @return The default timeout in seconds for all transactions created
+     * using this transaction manager.
+     */
+    public int getTransactionTimeout() ;
+
+    /**
      * Sets whether the transaction service should collate transaction service statistics.
      *
      * @param enabled
@@ -132,17 +142,37 @@
     public long getRollbackCount();
 
     /**
-     * Returns whether the recovery manager should be ran in the same VM as
+     * Set whether the recovery manager should be ran in the same VM as
      * JBoss.  If this is false the Recovery Manager is already expected to
      * be running when JBoss starts.
      * @param runRM
+     * 
+     * @throws IllegalStateException If the MBean has already started.
      */
-    public void setRunInVMRecoveryManager(boolean runRM);
-    
+    public void setRunInVMRecoveryManager(boolean runRM) throws IllegalStateException ;
+
     /**
+     * Get whether the recovery manager should be ran in the same VM as
+     * JBoss.  If this is false the Recovery Manager is already expected to
+     * be running when JBoss starts.
+     * 
+     * @return true if the recover manager is running in the same VM, false otherwise.
+     */
+    public boolean getRunInVMRecoveryManager() ;
+
+    /**
      * Set the object store directory.
      * @param objectStoreDir The object store directory.
+     * 
+     * @throws IllegalStateException if the MBean has already started.
      */
-    public void setObjectStoreDir(final String objectStoreDir) ;
+    public void setObjectStoreDir(final String objectStoreDir) throws IllegalStateException ;
+    
+    
+    /**
+     * Get the object store directory.
+     * @return objectStoreDir The object store directory.
+     */
+    public String getObjectStoreDir() ;
 }
 

Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java	2007-02-07 21:20:56 UTC (rev 9392)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java	2007-02-08 14:01:48 UTC (rev 9393)
@@ -98,6 +98,8 @@
     private RecoveryManager _recoveryManager;
     private boolean _runRM = true;
     private boolean alwaysPropagateContext = true ;
+    private boolean started ;
+    private byte[] startedLock = new byte[0] ;
     /**
      * Use the short class name as the default for the service name.
      */
@@ -116,6 +118,11 @@
      */
     protected void startService() throws Exception
     {
+	synchronized(startedLock)
+	{
+	    started = true ;
+	}
+	
         ORB orb = null;
 
         this.getLog().info("JBossTS Transaction Service - JBoss Inc.");
@@ -305,13 +312,47 @@
      *
      * @param timeout The default timeout in seconds for all transactions created
      * using this transaction manager.
+     * 
+     * @throws IllegalStateException if the mbean has already started.
      */
-    public void setTransactionTimeout(int timeout) throws javax.transaction.SystemException
+    public void setTransactionTimeout(int timeout) throws IllegalStateException
     {
-        if (timeout != 0)
+	synchronized(startedLock)
+	{
+            if (started)
+            {
+        	final int currentTimeout = getTransactionTimeout() ;
+        	if (currentTimeout != timeout)
+        	{
+        	    throw new IllegalStateException("Cannot set transaction timeout once MBean has started") ;
+        	}
+            }
+            else
+            {
+        	jtsPropertyManager.propertyManager.setProperty(com.arjuna.ats.jts.common.Environment.DEFAULT_TIMEOUT, Integer.toString(timeout));
+            }
+        }
+    }
+    
+
+    /**
+     * Get the default transaction timeout used by this transaction manager.
+     *
+     * @return The default timeout in seconds for all transactions created
+     * using this transaction manager.
+     */
+    public int getTransactionTimeout()
+    {
+        final String timeout = jtsPropertyManager.propertyManager.getProperty(com.arjuna.ats.jts.common.Environment.DEFAULT_TIMEOUT);
+        if (timeout != null)
         {
-            jtsPropertyManager.propertyManager.setProperty(com.arjuna.ats.jts.common.Environment.DEFAULT_TIMEOUT, Integer.toString(timeout));
+            try
+            {
+        	return Integer.parseInt(timeout) ;
+            }
+            catch (final NumberFormatException nfe) {} // Invalid property
         }
+        return 0 ;
     }
 
     /**
@@ -431,24 +472,82 @@
     }
 
     /**
-     * Returns whether the recovery manager should be ran in the same VM as
+     * Set whether the recovery manager should be ran in the same VM as
      * JBoss.  If this is false the Recovery Manager is already expected to
      * be running when JBoss starts.
      * @param runRM
+     * 
+     * @throws IllegalStateException If the MBean has already started.
      */
     public void setRunInVMRecoveryManager(boolean runRM)
+        throws IllegalStateException
     {
-        _runRM = runRM;
+        synchronized(startedLock)
+        {
+            if (started)
+            {
+        	if (this._runRM != runRM)
+        	{
+        	    throw new IllegalStateException("Cannot set run in VM recovery manager once MBean has started") ;
+        	}
+            }
+            else
+            {
+        	_runRM = runRM;
+            }
+        }
     }
+
+    /**
+     * Get whether the recovery manager should be ran in the same VM as
+     * JBoss.  If this is false the Recovery Manager is already expected to
+     * be running when JBoss starts.
+     * 
+     * @return true if the recover manager is running in the same VM, false otherwise.
+     */
+    public boolean getRunInVMRecoveryManager()
+    {
+	synchronized(startedLock)
+	{
+	    return _runRM ;
+	}
+    }
     
     /**
      * Set the object store directory.
      * @param objectStoreDir The object store directory.
+     * 
+     * @throws IllegalStateException if the MBean has already started
      */
     public void setObjectStoreDir(final String objectStoreDir)
+    	throws IllegalStateException
     {
-	System.setProperty(com.arjuna.ats.arjuna.common.Environment.OBJECTSTORE_DIR, objectStoreDir) ;
+        synchronized(startedLock)
+        {
+            if (started)
+            {
+        	final String currentDir = getObjectStoreDir() ;
+        	final boolean equal = (currentDir == null ? objectStoreDir == null : currentDir.equals(objectStoreDir)) ;
+        	if (!equal)
+        	{
+        	    throw new IllegalStateException("Cannot set object store dir once MBean has started") ;
+        	}
+            }
+            else
+            {
+        	System.setProperty(com.arjuna.ats.arjuna.common.Environment.OBJECTSTORE_DIR, objectStoreDir) ;
+            }
+        }
     }
+    
+    /**
+     * Get the object store directory.
+     * @return objectStoreDir The object store directory.
+     */
+    public String getObjectStoreDir()
+    {
+	return System.getProperty(com.arjuna.ats.arjuna.common.Environment.OBJECTSTORE_DIR) ;
+    }
 
     private void registerNotification()
         throws InstanceNotFoundException
@@ -471,9 +570,37 @@
     /**
      * Set the flag indicating whether the propagation context should always be propagated.
      * @param alwaysPropagateContext true if the context should always be propagated, false if only propagated to OTS transactional objects.
+     * 
+     * @throws IllegalStateException If the MBean has already started.
      */
     public void setAlwaysPropagateContext(final boolean alwaysPropagateContext)
+    	throws IllegalStateException
     {
-	this.alwaysPropagateContext = alwaysPropagateContext ;
+	synchronized(startedLock)
+	{
+            if (started)
+            {
+        	if (this.alwaysPropagateContext != alwaysPropagateContext)
+        	{
+        	    throw new IllegalStateException("Cannot set always propagate context once MBean has started") ;
+        	}
+            }
+            else
+            {
+        	this.alwaysPropagateContext = alwaysPropagateContext ;
+            }
+	}
     }
+
+    /**
+     * Get the flag indicating whether the propagation context should always be propagated.
+     * @return true if the context should always be propagated, false if only propagated to OTS transactional objects.
+     */
+    public boolean getAlwaysPropagateContext()
+    {
+	synchronized(startedLock)
+	{
+	    return alwaysPropagateContext ;
+	}
+    }
 }

Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerServiceMBean.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerServiceMBean.java	2007-02-07 21:20:56 UTC (rev 9392)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerServiceMBean.java	2007-02-08 14:01:48 UTC (rev 9393)
@@ -49,10 +49,20 @@
      *
      * @param timeout The default timeout in seconds for all transactions created
      * using this transaction manager.
+     * 
+     * @throws IllegalStateException if the mbean has already started.
      */
-    public void setTransactionTimeout(int timeout) throws javax.transaction.SystemException;
+    public void setTransactionTimeout(int timeout) throws IllegalStateException ;
 
     /**
+     * Get the default transaction timeout used by this transaction manager.
+     *
+     * @return The default timeout in seconds for all transactions created
+     * using this transaction manager.
+     */
+    public int getTransactionTimeout() ;
+
+    /**
      * Sets whether the transaction service should collate transaction service statistics.
      *
      * @param enabled
@@ -131,23 +141,50 @@
     public long getRollbackCount();
 
     /**
-     * Returns whether the recovery manager should be ran in the same VM as
+     * Set whether the recovery manager should be ran in the same VM as
      * JBoss.  If this is false the Recovery Manager is already expected to
      * be running when JBoss starts.
      * @param runRM
+     * 
+     * @throws IllegalStateException If the MBean has already started.
      */
-    public void setRunInVMRecoveryManager(boolean runRM);
+    public void setRunInVMRecoveryManager(boolean runRM) throws IllegalStateException ;
     
     /**
+     * Get whether the recovery manager should be ran in the same VM as
+     * JBoss.  If this is false the Recovery Manager is already expected to
+     * be running when JBoss starts.
+     * 
+     * @return true if the recover manager is running in the same VM, false otherwise.
+     */
+    public boolean getRunInVMRecoveryManager() ;
+    
+    /**
      * Set the object store directory.
      * @param objectStoreDir The object store directory.
+     * 
+     * @throws IllegalStateException if the MBean has already started
      */
-    public void setObjectStoreDir(final String objectStoreDir) ;
+    public void setObjectStoreDir(final String objectStoreDir) throws IllegalStateException ;
+    
+    /**
+     * Get the object store directory.
+     * @return objectStoreDir The object store directory.
+     */
+    public String getObjectStoreDir() ;
 
     /**
      * Set the flag indicating whether the propagation context should always be propagated.
      * @param alwaysPropagateContext true if the context should always be propagated, false if only propagated to OTS transactional objects.
+     * 
+     * @throws IllegalStateException If the MBean has already started.
      */
-    public void setAlwaysPropagateContext(final boolean alwaysPropagateContext) ;
+    public void setAlwaysPropagateContext(final boolean alwaysPropagateContext) throws IllegalStateException ;
+
+    /**
+     * Get the flag indicating whether the propagation context should always be propagated.
+     * @return true if the context should always be propagated, false if only propagated to OTS transactional objects.
+     */
+    public boolean getAlwaysPropagateContext() ;
 }
 




More information about the jboss-svn-commits mailing list