KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > adl > PrecompilerCompiler


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
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  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Matthieu Leclercq
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.adl;
26
27 import java.util.Map JavaDoc;
28
29 import org.objectweb.fractal.adl.ADLException;
30 import org.objectweb.fractal.adl.Compiler;
31 import org.objectweb.fractal.adl.Definition;
32 import org.objectweb.fractal.adl.TaskMap;
33 import org.objectweb.fractal.api.NoSuchInterfaceException;
34 import org.objectweb.fractal.api.control.BindingController;
35 import org.objectweb.fractal.api.control.IllegalBindingException;
36 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
37
38 /**
39  * A simple compiler with two {@link org.objectweb.fractal.adl.Compiler }client
40  * interfaces :<code>precompile</code> and <code>compile</code>. These two
41  * interfaces are called sequencialy.
42  */

43 public class PrecompilerCompiler implements BindingController, Compiler JavaDoc
44 {
45
46   /** The name of the client interface used to precompile */
47   public static final String JavaDoc PRECOMPILE_ITF_NAME = "pre-compiler";
48   /** The name of the client interface used to compile */
49   public static final String JavaDoc COMPILE_ITF_NAME = "post-compiler";
50
51   protected Compiler JavaDoc precompileItf;
52   protected Compiler JavaDoc compileItf;
53
54   /**
55    * @see org.objectweb.fractal.adl.Compiler#compile(org.objectweb.fractal.adl.Definition,
56    * org.objectweb.fractal.adl.TaskMap, java.util.Map)
57    */

58   public void compile(Definition definition, TaskMap tasks, Map JavaDoc context)
59       throws ADLException
60   {
61     precompileItf.compile(definition, tasks, context);
62     compileItf.compile(definition, tasks, context);
63   }
64
65   // --------------------------------------------------------------------------
66
// Implementation of the BindingController interface
67
// --------------------------------------------------------------------------
68

69   /**
70    * @see org.objectweb.fractal.api.control.BindingController#listFc()
71    */

72   public String JavaDoc[] listFc()
73   {
74     return new String JavaDoc[]{PRECOMPILE_ITF_NAME, COMPILE_ITF_NAME};
75   }
76
77   /**
78    * @see org.objectweb.fractal.api.control.BindingController#lookupFc(java.lang.String)
79    */

80   public Object JavaDoc lookupFc(String JavaDoc clientItfName) throws NoSuchInterfaceException
81   {
82     if (PRECOMPILE_ITF_NAME.equals(clientItfName))
83     {
84       return precompileItf;
85     }
86     else if (COMPILE_ITF_NAME.equals(clientItfName))
87     {
88       return compileItf;
89     }
90     else
91     {
92       return null;
93     }
94   }
95
96   /**
97    * @see org.objectweb.fractal.api.control.BindingController#bindFc(java.lang.String,
98    * java.lang.Object)
99    */

100   public void bindFc(String JavaDoc clientItfName, Object JavaDoc serverItf)
101       throws NoSuchInterfaceException, IllegalBindingException,
102       IllegalLifeCycleException
103   {
104     if (PRECOMPILE_ITF_NAME.equals(clientItfName))
105     {
106       precompileItf = (Compiler JavaDoc) serverItf;
107     }
108     else if (COMPILE_ITF_NAME.equals(clientItfName))
109     {
110       compileItf = (Compiler JavaDoc) serverItf;
111     }
112   }
113
114   /**
115    * @see org.objectweb.fractal.api.control.BindingController#unbindFc(java.lang.String)
116    */

117   public void unbindFc(String JavaDoc clientItfName) throws NoSuchInterfaceException,
118       IllegalBindingException, IllegalLifeCycleException
119   {
120     if (PRECOMPILE_ITF_NAME.equals(clientItfName))
121     {
122       precompileItf = null;
123     }
124     else if (COMPILE_ITF_NAME.equals(clientItfName))
125     {
126       compileItf = null;
127     }
128   }
129
130 }
Popular Tags