01: /*
02: * This file is part of the WfMOpen project.
03: * Copyright (C) 2001-2006 Danet GmbH (www.danet.de), BU BTS.
04: * All rights reserved.
05: *
06: * This program is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU General Public License as published by
08: * the Free Software Foundation; either version 2 of the License, or
09: * (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * $Id: GenericSimpleApplicationTool.java,v 1.1 2006/10/25 21:43:03 mlipp Exp $
21: *
22: * $Log: GenericSimpleApplicationTool.java,v $
23: * Revision 1.1 2006/10/25 21:43:03 mlipp
24: * Sample tool for testing and evaluation.
25: *
26: */
27: package de.danet.an.workflow.tools;
28:
29: import java.rmi.RemoteException;
30: import java.util.Map;
31:
32: import de.danet.an.workflow.api.Activity;
33: import de.danet.an.workflow.api.FormalParameter;
34: import de.danet.an.workflow.spis.aii.CannotExecuteException;
35: import de.danet.an.workflow.tools.util.SimpleApplicationAgent;
36:
37: /**
38: * This class provides a generic tool agent for creating an entry
39: * in the <code>SimpleApplicationDirectory</code>. This implementation
40: * is intended for testing and evaluation purposes.
41: *
42: * @author Michael Lipp
43: *
44: */
45: public class GenericSimpleApplicationTool extends
46: SimpleApplicationAgent {
47:
48: private String applicationName = null;
49:
50: /**
51: * @return Returns the applicationName.
52: */
53: public String getApplicationName() {
54: return applicationName;
55: }
56:
57: /**
58: * @param applicationName The applicationName to set.
59: */
60: public void setApplicationName(String applicationName) {
61: this .applicationName = applicationName;
62: }
63:
64: /* (non-Javadoc)
65: * @see de.danet.an.workflow.spis.aii.ToolAgent#invoke
66: */
67: public void invoke(Activity activity,
68: FormalParameter[] formalParameters, Map actualParameters)
69: throws RemoteException, CannotExecuteException {
70: if (applicationName == null) {
71: throw new CannotExecuteException(
72: "Application name not configured");
73: }
74: if (formalParameters.length > 0
75: && formalParameters[0].id().equals("key")
76: && actualParameters.get("key") instanceof String) {
77: applicationDirectory()
78: .registerInstance(
79: applicationName,
80: (String) actualParameters.get("key"),
81: activity,
82: new Object[] { formalParameters,
83: actualParameters }, true);
84: } else {
85: applicationDirectory()
86: .registerInstance(
87: applicationName,
88: activity,
89: new Object[] { formalParameters,
90: actualParameters }, true);
91: }
92: }
93: }
|