001: /*
002: * This file is part of the WfMOpen project.
003: * Copyright (C) 2001-2004 Danet GmbH (www.danet.de), GS-AN.
004: * All rights reserved.
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * $Id: ToolAgentBase.java,v 1.3 2006/10/10 15:37:17 drmlipp Exp $
021: *
022: * $Log: ToolAgentBase.java,v $
023: * Revision 1.3 2006/10/10 15:37:17 drmlipp
024: * Made TimerHandlerEJB local.
025: *
026: * Revision 1.2 2006/09/29 12:32:10 drmlipp
027: * Consistently using WfMOpen as projct name now.
028: *
029: * Revision 1.1.1.1 2004/08/18 15:17:39 drmlipp
030: * Update to 1.2
031: *
032: * Revision 1.4 2004/04/01 09:32:07 lipp
033: * Improved tool agent context implementtaion.
034: *
035: * Revision 1.3 2004/03/31 20:48:14 lipp
036: * Cleaned up.
037: *
038: * Revision 1.2 2004/02/21 21:31:01 lipp
039: * Some more refactoring to resolve cyclic dependencies.
040: *
041: * Revision 1.1 2004/02/20 18:56:35 lipp
042: * Renamed package waittool to timing (much better ;-)).
043: *
044: * Revision 1.2 2004/02/19 21:14:48 lipp
045: * Several WaitTool fixes.
046: *
047: * Revision 1.1 2004/02/19 17:55:55 lipp
048: * Initial version of waittool.
049: *
050: */
051: package de.danet.an.workflow.tools.timing;
052:
053: import de.danet.an.util.EJBUtil;
054: import de.danet.an.util.ResourceNotAvailableException;
055:
056: import de.danet.an.workflow.spis.aii.ContextRequester;
057: import de.danet.an.workflow.spis.aii.ToolAgentContext;
058: import de.danet.an.workflow.tools.util.SimpleApplicationAgent;
059:
060: /**
061: * This class provides provides some base functionallity for the wait
062: * tool agents.
063: *
064: * @author <a href="mailto:lipp@danet.de">Michael Lipp</a>
065: * @version $Revision: 1.3 $
066: */
067:
068: public abstract class ToolAgentBase extends SimpleApplicationAgent
069: implements ContextRequester {
070:
071: /** The cached waiting directory. */
072: private TimerHandlerLocal timerHandlerCache = null;
073:
074: /** The cached workflow engine context. */
075: private ThreadLocal ctx = new ThreadLocal();
076:
077: /**
078: * Makes an engine context available to the tool agent.
079: * @param context the engine context
080: */
081: public void setToolAgentContext(ToolAgentContext context) {
082: ctx.set(context);
083: }
084:
085: /**
086: * Return the waiting directory.
087: * @return waiting directory
088: * @throws ResourceNotAvailableException if a system level error occurs
089: */
090: protected TimerHandlerLocal timerHandler()
091: throws ResourceNotAvailableException {
092: if (timerHandlerCache == null) {
093: timerHandlerCache = (TimerHandlerLocal) EJBUtil
094: .createSession(TimerHandlerLocalHome.class,
095: "java:comp/env/ejb/TimerHandlerLocal");
096: }
097: return timerHandlerCache;
098: }
099:
100: /**
101: * Return the engine context.
102: * @return the engine context
103: */
104: protected ToolAgentContext toolAgentContext() {
105: return (ToolAgentContext) ctx.get();
106: }
107: }
|