KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > za > org > coefficient > interceptors > ExecuteModuleInterceptor


1 /*
2  * Coefficient - facilitates project based collaboration
3  * Copyright (C) 2003, Dylan Etkin, CSIR icomtek
4  * PO Box 395
5  * Pretoria 0001, RSA
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package za.org.coefficient.interceptors;
21
22 import za.org.coefficient.core.CoefficientInterceptor;
23 import za.org.coefficient.core.CoefficientWebContext;
24 import za.org.coefficient.interfaces.CoefficientContext;
25 import za.org.coefficient.interfaces.Invoker;
26 import za.org.coefficient.util.common.InvokerFactory;
27
28 /**
29  *
30  * @version $Revision: 1.5 $ $Date: 2004/10/20 08:17:28 $
31  * @author <a HREF="mailto:detkin@csir.co.za">Dylan Etkin</a>
32  */

33 public class ExecuteModuleInterceptor extends CoefficientInterceptor {
34     //~ Methods ================================================================
35

36     protected int handleInvoke(CoefficientContext ctx) throws Exception JavaDoc {
37         int retVal = INVOKE_PROCESS_CHILD;
38
39         // Fire the module
40
Invoker mf = InvokerFactory.getRemoteInvoker();
41         Object JavaDoc context = mf.invoke(ctx);
42         if(context instanceof CoefficientContext) {
43             ctx = (CoefficientContext)context;
44         }
45         // Set the last op session variable if not a help call
46
String JavaDoc op = ctx.getParameter("op");
47         String JavaDoc module = ctx.getParameter("module");
48
49         // This is done so we can support online help
50
if (!"showHelp".equals(op) && (module != null && !module.equals(""))) {
51             if (op == null) {
52                 op = (String JavaDoc)mf.invokeMethodOnModule(module, "getMainMethod",
53                                                      null);
54             }
55             ctx.setSessionAttribute(CoefficientWebContext.LAST_NON_HELP_OP, op);
56         }
57         return retVal;
58     }
59 }
60
Popular Tags