KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > browser > plugins > fractal > context > DefaultFractalContext


1 /*====================================================================
2  
3  Objectweb Browser framework
4  Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5  Contact: openccm@objectweb.org
6  
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or any later version.
11  
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16  
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  USA
21  
22  Initial developer(s): Jerome Moroy.
23  Contributor(s): ______________________________________.
24  
25  ---------------------------------------------------------------------
26  $Id: DefaultFractalContext.java,v 1.1 2004/04/20 16:37:26 moroy Exp $
27  ====================================================================*/

28
29 package org.objectweb.util.browser.plugins.fractal.context;
30
31 import org.objectweb.fractal.api.NoSuchInterfaceException;
32 import org.objectweb.fractal.api.control.LifeCycleController;
33 import org.objectweb.util.browser.api.Context;
34 import org.objectweb.util.browser.api.Entry;
35 import org.objectweb.util.browser.api.Wrapper;
36 import org.objectweb.util.browser.plugins.fractal.FcBrowser;
37 import org.objectweb.util.browser.plugins.fractal.api.FractalContext;
38
39 /**
40  * Basic implementation of a Fractal context.
41  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
42  * @version 0.2
43  */

44 public abstract class DefaultFractalContext
45            implements Context,
46                       Wrapper,
47                       FractalContext
48 {
49     
50     //==================================================================
51
//
52
// No internal state.
53
//
54
//==================================================================
55

56     /** The associated object. */
57     protected Object JavaDoc object_;
58     
59     //==================================================================
60
//
61
// No constructor.
62
//
63
//==================================================================
64

65     //==================================================================
66
//
67
// Internal methods.
68
//
69
//==================================================================
70

71     //==================================================================
72
//
73
// Public methods for Context interface.
74
//
75
//==================================================================
76

77     /**
78      * Overriding methods
79      * @see org.objectweb.util.browser.api.Context#getEntries()
80      */

81     public Entry[] getEntries() {
82         LifeCycleController lcc = null;
83         try {
84              lcc = FcBrowser.getLifeCycleController(FcBrowser.getComponent(object_));
85         } catch (NoSuchInterfaceException e2) {
86             try {
87                 return getStartedEntries();
88             } catch (Exception JavaDoc e1) {
89                 return getStoppedEntries();
90             }
91         }
92         if (lcc.getFcState().equals(LifeCycleController.STARTED))
93             return getStartedEntries();
94         else
95             return getStoppedEntries();
96     }
97     
98     //==================================================================
99
//
100
// Public methods for FractalContext interface.
101
//
102
//==================================================================
103

104     /**
105      * Called when the Fractal component is started.
106      * @return An array of entries contained into the Context.
107      */

108     public abstract Entry[] getStartedEntries() ;
109     
110     /**
111      * Called when the Fractal component is stopped.
112      * @return An array of entries contained into the Context.
113      */

114     public Entry[] getStoppedEntries() {
115         return new Entry[0];
116     }
117     
118     //==================================================================
119
//
120
// Public methods for Wrapper interface.
121
//
122
//==================================================================
123

124     /**
125      * Sets the wrapped object.
126      * @param object The object to wrap.
127      */

128     public void setWrapped(Object JavaDoc object) {
129         object_ = object;
130     }
131     
132     /**
133      * Gets the wrapped object.
134      * @return The wrapped object.
135      */

136     public Object JavaDoc getWrapped() {
137         return object_;
138     }
139 }
Popular Tags