Author: adamw Date: 2005-10-29 12:50:28 -0400 (Sat, 29 Oct 2005) New Revision: 1471 Modified: trunk/forge/portal-extensions/forge-service/src/java/org/jboss/forge/service/ForgeTimer.java trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnServiceTimerLocal.java trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ParentTest.java Log: Timers test Modified: trunk/forge/portal-extensions/forge-service/src/java/org/jboss/forge/service/ForgeTimer.java =================================================================== --- trunk/forge/portal-extensions/forge-service/src/java/org/jboss/forge/service/ForgeTimer.java 2005-10-29 12:05:24 UTC (rev 1470) +++ trunk/forge/portal-extensions/forge-service/src/java/org/jboss/forge/service/ForgeTimer.java 2005-10-29 16:50:28 UTC (rev 1471) @@ -35,39 +35,34 @@ import org.jboss.mx.util.MBeanServerLocator; /** - * @author adamw * A timer which, when expires, calls the update method of an instance of * ForgeManagement - this instance is looked up as an mbean. + * @author adamw */ @Stateless @Local(ForgeTimerLocal.class) public class ForgeTimer implements ForgeTimerLocal { private @Resource SessionContext ctx; + private ForgeManagement fm; public void scheduleTimer(long interval) { // ctx.getTimerService().createTimer(new Date(new Date().getTime() + interval), null); - ctx.getTimerService().createTimer(0, interval, null); + ctx.getTimerService().createTimer(interval, interval, null); } @Timeout public void timeoutHandler(Timer timer) { - try { - ForgeManagement fm = - ((ForgeManagement) MBeanProxyExt.create( - ForgeManagement.class, - ForgeHelper.FORGE_SERVICE_NAME, - MBeanServerLocator.locate())); - - fm.update(); - - // Avoiding WARN. - //timer.cancel(); //? -- Maybe this caused the TX exception. - - // Scheduling next timer to timeout after the amount of time that - // is set in forgeManagement. - // scheduleTimer(fm.getTimerInterval()); - } catch (MalformedObjectNameException e) { - e.printStackTrace(); + if (fm == null) { + try { + fm = ((ForgeManagement) MBeanProxyExt.create( + ForgeManagement.class, + ForgeHelper.FORGE_SERVICE_NAME, + MBeanServerLocator.locate())); + } catch (MalformedObjectNameException e) { + e.printStackTrace(); + } } + + fm.update(); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java 2005-10-29 12:05:24 UTC (rev 1470) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java 2005-10-29 16:50:28 UTC (rev 1471) @@ -33,34 +33,34 @@ import org.jboss.mx.util.MBeanServerLocator; import org.jboss.shotoku.svn.SvnService; +/** + * @author adamw + */ @Stateless @Local(SvnServiceTimerLocal.class) public class SvnServiceTimer { //private static final Logger log = Logger.getLogger(SvnServiceTimer.class); private @Resource SessionContext ctx; + private SvnServiceLocal ssi; public void scheduleTimer(long interval) { //ctx.getTimerService().createTimer(new Date(new Date().getTime() + interval), null); - ctx.getTimerService().createTimer(0, interval, null); + ctx.getTimerService().createTimer(interval, interval, null); } @Timeout public void timeoutHandler(Timer timer) { - try { - SvnServiceLocal ssi = - ((SvnServiceLocal) MBeanProxyExt.create( - SvnServiceLocal.class, - SvnService.SVN_SERVICE_NAME, - MBeanServerLocator.locate())); + if (ssi == null) { + try { + ssi = ((SvnServiceLocal) MBeanProxyExt.create( + SvnServiceLocal.class, + SvnService.SVN_SERVICE_NAME, + MBeanServerLocator.locate())); + } catch (MalformedObjectNameException e) { + e.printStackTrace(); + } + } - ssi.update(); - - // Avoiding WARN. - //timer.cancel(); - - //scheduleTimer(ssi.getTimerInterval()); - } catch (MalformedObjectNameException e) { - e.printStackTrace(); - } + ssi.update(); } } Modified: trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnServiceTimerLocal.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnServiceTimerLocal.java 2005-10-29 12:05:24 UTC (rev 1470) +++ trunk/forge/portal-extensions/shotoku/shotoku-svn-service/src/java/org/jboss/shotoku/svn/service/SvnServiceTimerLocal.java 2005-10-29 16:50:28 UTC (rev 1471) @@ -21,6 +21,9 @@ */ package org.jboss.shotoku.svn.service; +/** + * @author adamw + */ public interface SvnServiceTimerLocal { /** * Schedules a timer that updates svn service to timeout after the Modified: trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ParentTest.java =================================================================== --- trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ParentTest.java 2005-10-29 12:05:24 UTC (rev 1470) +++ trunk/forge/portal-extensions/shotoku/shotoku-test/src/java/org/jboss/shotoku/test/ParentTest.java 2005-10-29 16:50:28 UTC (rev 1471) @@ -22,7 +22,6 @@ package org.jboss.shotoku.test; import org.jboss.shotoku.Directory; -import org.jboss.shotoku.exceptions.ResourceDoesNotExist; public class ParentTest extends ShotokuTest { private final static String TEST_DIR1 = "parent-test-1"; @@ -66,7 +65,7 @@ public void tearDown() { try { cm.getDirectory(TEST_DIR1).delete(); - } catch (ResourceDoesNotExist e) { + } catch (Exception e) { } } |