KickJava   Java API By Example, From Geeks To Geeks.

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


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 with life cycle controller implementing
36  * {@link org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator}
37  * interface. <br>
38  * <br>
39  * <b>Requirements </b>
40  * <ul>
41  * <li>this mixin requires the
42  * {@link org.objectweb.fractal.julia.UseComponentMixin }mixin.</li>
43  * <li>this mixin requires the
44  * {@link org.objectweb.dream.control.logger.UseLoggerControllerMixin }mixin.
45  * </li>
46  * <li>the component to which this controller belongs should provide the
47  * {@link org.objectweb.dream.control.logger.LoggerInternalBaseName }interface.
48  * </li>
49  * </ul>
50  */

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

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

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

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

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

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

106   public abstract boolean _super_setFcStarted()
107       throws IllegalLifeCycleException;
108
109 }
Popular Tags