KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > control > logger > LoggerLifeCycleMixin


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.control.logger;
26
27 import org.objectweb.fractal.api.Component;
28 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
29 import org.objectweb.fractal.julia.Util;
30
31 /**
32  * Change the base name of component loggers at startup to reflect the
33  * component's path. This is done only if the base name was not assigned with
34  * the {@link LoggerController#setBaseName(String) }method. <br>
35  * This mixin should be used only with life cycle controller that does not
36  * implement
37  * {@link org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator}
38  * interface. <br>
39  * <br>
40  * <b>Requirements </b>
41  * <ul>
42  * <li>this mixin requires the
43  * {@link org.objectweb.fractal.julia.UseComponentMixin }mixin.</li>
44  * <li>this mixin requires the
45  * {@link org.objectweb.dream.control.logger.UseLoggerControllerMixin }mixin.
46  * </li>
47  * <li>the component to which this controller belongs should provide the
48  * {@link org.objectweb.dream.control.logger.LoggerInternalBaseName }interface.
49  * </li>
50  * </ul>
51  */

52 public abstract class LoggerLifeCycleMixin
53 {
54
55   // -------------------------------------------------------------------------
56
// Fields and methods added and overriden by the mixin class
57
// -------------------------------------------------------------------------
58

59   /**
60    * Calls the overriden method and then sets the activityLogger and
61    * activityLogger factory of the user component encapsulated in this component
62    * (if there is one).
63    *
64    * @see org.objectweb.fractal.api.control.LifeCycleController#startFc()
65    */

66   public void startFc() throws IllegalLifeCycleException
67   {
68     StringBuffer JavaDoc path = new StringBuffer JavaDoc();
69     Util.toString(_this_weaveableC, path);
70     String JavaDoc s = path.toString().substring(1).replace('/', '.');
71     if (_this_weaveableOptLogC instanceof LoggerInternalBaseName)
72     {
73       ((LoggerInternalBaseName) _this_weaveableOptLogC).internalSetBaseName(s);
74     }
75     else
76     {
77       _this_weaveableOptLogC.setBaseName(s);
78     }
79     _super_startFc();
80   }
81
82   // ---------------------------------------------------------------------------
83
// Fields and methods required by the mixin class in the base class
84
// ---------------------------------------------------------------------------
85

86   /**
87    * The <tt>weaveableC</tt> field required by this mixin. This field is
88    * supposed to reference the {@link Component }interface of the component to
89    * which this controller object belongs.
90    */

91   public Component _this_weaveableC;
92
93   /**
94    * The <tt>weaveableOptLogC</tt> field required by this mixin. This field is
95    * supposed to reference the {@link LoggerController }interface of the
96    * component to which this controller object belongs.
97    */

98   public LoggerController _this_weaveableOptLogC;
99
100   /**
101    * The {@link org.objectweb.fractal.api.control.LifeCycleController#startFc()}
102    * method overriden by this mixin.
103    *
104    * @see org.objectweb.fractal.api.control.LifeCycleController#startFc()
105    */

106   public abstract void _super_startFc() throws IllegalLifeCycleException;
107
108 }
Popular Tags