01: /*
02: * Coefficient - facilitates project based collaboration
03: * Copyright (C) 2003, Dylan Etkin, CSIR icomtek
04: * PO Box 395
05: * Pretoria 0001, RSA
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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.Constants;
23: import za.org.coefficient.core.CoefficientInterceptor;
24: import za.org.coefficient.interfaces.CoefficientContext;
25: import za.org.coefficient.util.common.InvokerFactory;
26:
27: import javax.naming.Context;
28: import javax.naming.NameClassPair;
29: import javax.naming.NamingEnumeration;
30:
31: /**
32: *
33: * @version $Revision: 1.6 $ $Date: 2004/10/20 08:17:28 $
34: * @author <a href="mailto:detkin@csir.co.za">Dylan Etkin</a>
35: */
36: public class PermanentModuleInterceptor extends CoefficientInterceptor {
37: //~ Static fields/initializers =============================================
38:
39: //~ Methods ================================================================
40:
41: protected int handleInvoke(CoefficientContext ctx) throws Exception {
42: int retVal = INVOKE_PROCESS_CHILD;
43:
44: // try to get the names of all the permanent modules
45: Context initialContext = za.org.coefficient.util.common.ContextUtil
46: .getContext();
47: try {
48: for (NamingEnumeration ne = initialContext
49: .list(Constants.JNDI_CONTEXT + "/" + "permanent"); ne
50: .hasMore();) {
51: NameClassPair bind = (NameClassPair) ne.next();
52:
53: // Fire the module
54: Object context = InvokerFactory.getRemoteInvoker()
55: .invokeOpOnModule(bind.getName(), null, ctx);
56: if (context instanceof CoefficientContext) {
57: ctx = (CoefficientContext) context;
58: }
59: }
60: } catch (Exception e) {
61: e.printStackTrace();
62: } finally {
63: initialContext.close();
64: }
65:
66: return retVal;
67: }
68: }
|