KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > kernel > dmf > StartupDMF


1 package org.mr.kernel.dmf;
2
3
4 import java.util.HashMap JavaDoc;
5
6 import org.mr.MantaAgent;
7 import org.mr.core.util.exceptions.CreationException;
8 import org.mr.core.util.patterns.flow.ConfigurationLoader;
9 import org.mr.core.util.patterns.flow.Declaration;
10 import org.mr.core.util.patterns.flow.FlowFramework;
11
12 /*
13  * Copyright 2002 by
14  * <a HREF="http://www.coridan.com">Coridan</a>
15  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
16  *
17  * The contents of this file are subject to the Mozilla Public License Version
18  * 1.1 (the "License"); you may not use this file except in compliance with the
19  * License. You may obtain a copy of the License at
20  * http://www.mozilla.org/MPL/
21  *
22  * Software distributed under the License is distributed on an "AS IS" basis,
23  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
24  * for the specific language governing rights and limitations under the
25  * License.
26  *
27  * The Original Code is "MantaRay" (TM).
28  *
29  * The Initial Developer of the Original Code is Coridan.
30  * Portions created by the Initial Developer are Copyright (C) 2006
31  * Coridan Inc. All Rights Reserved.
32  *
33  * Contributor(s): all the names of the contributors are added in the source
34  * code where applicable.
35  *
36  * Alternatively, the contents of this file may be used under the terms of the
37  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
38  * provisions of LGPL are applicable instead of those above. If you wish to
39  * allow use of your version of this file only under the terms of the LGPL
40  * License and not to allow others to use your version of this file under
41  * the MPL, indicate your decision by deleting the provisions above and
42  * replace them with the notice and other provisions required by the LGPL.
43  * If you do not delete the provisions above, a recipient may use your version
44  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
45  
46  *
47  * This library is free software; you can redistribute it and/or modify it
48  * under the terms of the MPL as stated above or under the terms of the GNU
49  * Lesser General Public License as published by the Free Software Foundation;
50  * either version 2.1 of the License, or any later version.
51  *
52  * This library is distributed in the hope that it will be useful, but WITHOUT
53  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
54  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
55  * License for more details.
56  */

57
58  /**
59  * User: Moti Tal
60  * Date: Mar 13, 2005
61  * Time: 3:26:48 PM
62  *
63  * This class bootstraps the DMF framework, by parsing the configuration file and setting the flow framework.
64  * The configuration file should be could dataManipulationFramework and place under the manta config directory.
65  *
66  * e.g example of a single step in the dmf flow framework.
67  * An empty step form attribute stand for entry point to the flow.
68  * This condition uses the default StringCondition and check if the message is in the way in; If met condition the
69  * plugin will be executed otherwise ignore.
70  * The incoming attribute set automatically by the DMF framework.
71  * <dmf>
72  * <plugins>
73  * <plugin name="transformer" class="org.mr.mt.MantaMessageTransformer"/>
74  * </plugins>
75  * <flow id="">
76  * <step id="s1" from="" to="transformer">
77  * <conditions>
78  * <condition variable="incoming" value="true"/>
79  * </conditions>
80  * </step>
81  * </flow>
82  * </dmf>
83  */

84 public class StartupDMF{
85
86     FlowFramework m_flowFramework = null;
87
88     public StartupDMF() throws CreationException {
89         startup();
90     }
91
92     public void startup() throws CreationException {
93
94         try {
95             //TODO SHOULD be replaced by common XML format using XSLT.
96
HashMap JavaDoc hashMap = new HashMap JavaDoc();
97             //set the declaration tag name as plugin
98
hashMap.put(Declaration.DECLARATION_TAG_NAME, "plugin");
99
100             //load the configuration file using the DMFFlowFramework
101
String JavaDoc configFile = MantaAgent.getInstance().getSingletonRepository().getConfigManager().getStringProperty("plug-ins.dmf.config-file");
102             ConfigurationLoader loader = new ConfigurationLoader(configFile,hashMap){
103                 protected FlowFramework generateEmptyFramework() {
104                     return new DMFFlowFramework();
105                 }
106             };
107             m_flowFramework = loader.loadFramework();
108         } catch (Exception JavaDoc e) {
109             throw new CreationException("Load dataManipulationFramework.xml failed,",e);
110         }
111     }
112
113     public FlowFramework getFlowFramework() {
114         return m_flowFramework;
115     }
116
117 }
118
Popular Tags