KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > context > lib > Factory


1 /*====================================================================
2
3 Objectweb Explorer 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, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.util.explorer.context.lib;
27
28 import org.objectweb.fractal.api.NoSuchInterfaceException;
29 import org.objectweb.util.explorer.api.Context;
30 import org.objectweb.util.explorer.context.api.ContextContainerFactory;
31 import org.objectweb.util.explorer.context.api.ContextPropertiesProvider;
32 import org.objectweb.util.explorer.context.api.Decoder;
33 import org.objectweb.util.explorer.core.common.api.ContextContainer;
34 import org.objectweb.util.explorer.core.common.lib.BindingFeature;
35 import org.objectweb.util.explorer.core.common.lib.DefaultContextContainer;
36
37 /**
38  *
39  *
40  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
41  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
42  *
43  * @version 0.1
44  */

45 public class Factory
46      extends BindingFeature
47   implements ContextContainerFactory
48 {
49
50     //==================================================================
51
//
52
// Internal States.
53
//
54
// ==================================================================
55

56     // ==================================================================
57
//
58
// Constructors.
59
//
60
// ==================================================================
61

62     // ==================================================================
63
//
64
// Internal methods.
65
//
66
// ==================================================================
67

68     protected ContextPropertiesProvider getPropertiesFeeder(){
69         try {
70             return (ContextPropertiesProvider)lookupFc(ContextPropertiesProvider.CONTEXT_PROPERTIES_PROVIDER);
71         } catch (NoSuchInterfaceException e) {
72             getTrace().warn(ContextPropertiesProvider.CONTEXT_PROPERTIES_PROVIDER + ": interface not found!");
73             return null;
74         }
75     }
76     
77     // ==================================================================
78
//
79
// Public methods for BindingFeature abstract class.
80
//
81
// ==================================================================
82

83     /* (non-Javadoc)
84      * @see org.objectweb.util.explorer.core.common.lib.BindingFeature#clientFc()
85      */

86     public String JavaDoc[] clientFc() {
87         return new String JavaDoc[]{ContextPropertiesProvider.CONTEXT_PROPERTIES_PROVIDER};
88     }
89
90     // ==================================================================
91
//
92
// Public methods for ContextContainerFactory interface.
93
//
94
// ==================================================================
95

96     /* (non-Javadoc)
97      * @see org.objectweb.util.explorer.context.api.ContextContainerFactory#create()
98      */

99     public ContextContainer create() {
100         return create(new DefaultContextContainer());
101     }
102
103     /* (non-Javadoc)
104      * @see org.objectweb.util.explorer.context.api.ContextContainerFactory#create(org.objectweb.util.explorer.core.common.api.ContextContainer)
105      */

106     public ContextContainer create(ContextContainer context) {
107         Decoder decoder = getPropertiesFeeder().getDecoder();
108         if(decoder!=null){
109             DecoderContextContainer cc = new DecoderContextContainer(context);
110             cc.setDecoder(decoder);
111             return cc;
112         } else {
113             return context;
114         }
115     }
116     
117     /* (non-Javadoc)
118      * @see org.objectweb.util.explorer.context.api.ContextContainerFactory#create(org.objectweb.util.explorer.api.Context)
119      */

120     public Context create(Context context) {
121         Decoder decoder = getPropertiesFeeder().getDecoder();
122         if(decoder!=null){
123             DecoderContext cc = new DecoderContext(context);
124             cc.setDecoder(decoder);
125             return cc;
126         } else {
127             return context;
128         }
129     }
130     
131 }
132
133
Popular Tags