KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jsf > application > ApplicationImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2
11  * as published by the Free Software Foundation.
12  *
13  * Resin Open Source is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
16  * of NON-INFRINGEMENT. See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Resin Open Source; if not, write to the
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.jsf.application;
30
31 import java.util.*;
32
33 import javax.el.*;
34
35 import javax.faces.*;
36 import javax.faces.application.*;
37 import javax.faces.component.*;
38 import javax.faces.component.html.*;
39 import javax.faces.context.*;
40 import javax.faces.convert.*;
41 import javax.faces.el.*;
42 import javax.faces.event.*;
43 import javax.faces.validator.*;
44
45 import com.caucho.config.*;
46 import com.caucho.util.*;
47
48 public class ApplicationImpl extends Application
49 {
50   private static final L10N L = new L10N(ApplicationImpl.class);
51   
52   private ActionListener _actionListener;
53   private ViewHandler _viewHandler;
54   private PropertyResolver _propertyResolver;
55
56   private ExpressionFactory _jsfExpressionFactory;
57
58   private HashMap<String JavaDoc,Class JavaDoc> _componentClassMap
59     = new HashMap<String JavaDoc,Class JavaDoc>();
60
61   public ApplicationImpl()
62   {
63     _jsfExpressionFactory = new JsfExpressionFactoryImpl();
64
65     addComponent(HtmlOutputText.COMPONENT_TYPE,
66          "javax.faces.component.html.HtmlOutputText");
67
68     addComponent(HtmlPanelGrid.COMPONENT_TYPE,
69          "javax.faces.component.html.HtmlPanelGrid");
70
71     addComponent(HtmlForm.COMPONENT_TYPE,
72          "javax.faces.component.html.HtmlForm");
73   }
74   
75   public ActionListener getActionListener()
76   {
77     return _actionListener;
78   }
79
80   public void setActionListener(ActionListener listener)
81   {
82     _actionListener = listener;
83   }
84
85   public Locale getDefaultLocale()
86   {
87     throw new UnsupportedOperationException JavaDoc();
88   }
89
90   public void setDefaultLocale(Locale locale)
91   {
92     throw new UnsupportedOperationException JavaDoc();
93   }
94
95   public String JavaDoc getDefaultRenderKitIt()
96   {
97     throw new UnsupportedOperationException JavaDoc();
98   }
99
100   public void setDefaultRenderKitId(String JavaDoc renderKitId)
101   {
102     throw new UnsupportedOperationException JavaDoc();
103   }
104
105   public String JavaDoc getMessageBundle()
106   {
107     throw new UnsupportedOperationException JavaDoc();
108   }
109
110   public void setMessageBundle(String JavaDoc bundle)
111   {
112     throw new UnsupportedOperationException JavaDoc();
113   }
114
115   public NavigationHandler getNavigationHandler()
116   {
117     throw new UnsupportedOperationException JavaDoc();
118   }
119
120   public void setNavigationHandler(NavigationHandler handler)
121   {
122     throw new UnsupportedOperationException JavaDoc();
123   }
124
125   @Deprecated JavaDoc
126   public PropertyResolver getPropertyResolver()
127   {
128     return _propertyResolver;
129   }
130
131   @Deprecated JavaDoc
132   public void setPropertyResolver(PropertyResolver resolver)
133   {
134     _propertyResolver = resolver;
135   }
136
137   @Deprecated JavaDoc
138   public VariableResolver getVariableResolver()
139   {
140     throw new UnsupportedOperationException JavaDoc();
141   }
142
143   @Deprecated JavaDoc
144   public void setVariableResolver(VariableResolver resolver)
145   {
146     throw new UnsupportedOperationException JavaDoc();
147   }
148
149   /**
150    * @Since 1.2
151    */

152   public ExpressionFactory getExpressionFactory()
153   {
154     return _jsfExpressionFactory;
155   }
156
157   public ViewHandler getViewHandler()
158   {
159     if (_viewHandler == null)
160       _viewHandler = new JspViewHandler();
161     
162     return _viewHandler;
163   }
164
165   public void setViewHandler(ViewHandler handler)
166   {
167     _viewHandler = handler;
168   }
169
170   public StateManager getStateManager()
171   {
172     throw new UnsupportedOperationException JavaDoc();
173   }
174
175   public void setStateManager(StateManager manager)
176   {
177     throw new UnsupportedOperationException JavaDoc();
178   }
179
180   public void addComponent(String JavaDoc componentType,
181                String JavaDoc componentClass)
182   {
183     synchronized (_componentClassMap) {
184       try {
185     ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
186     
187     Class JavaDoc cl = Class.forName(componentClass, false, loader);
188
189     Config.validate(cl, UIComponent.class);
190
191     _componentClassMap.put(componentType, cl);
192       } catch (RuntimeException JavaDoc e) {
193     throw e;
194       } catch (Exception JavaDoc e) {
195     throw new FacesException(e);
196       }
197     }
198   }
199
200   public UIComponent createComponent(String JavaDoc componentType)
201     throws FacesException
202   {
203     if (componentType == null)
204       throw new NullPointerException JavaDoc();
205     
206     Class JavaDoc cl = null;
207     
208     synchronized (_componentClassMap) {
209       cl = _componentClassMap.get(componentType);
210     }
211
212     if (cl == null)
213       throw new FacesException(L.l("'{0}' is an unknown UI componentType to create",
214                    componentType));
215
216     try {
217       return (UIComponent) cl.newInstance();
218     } catch (RuntimeException JavaDoc e) {
219       throw e;
220     } catch (Exception JavaDoc e) {
221       throw new FacesException(e);
222     }
223   }
224
225   
226   @Deprecated JavaDoc
227   public UIComponent createComponent(ValueBinding componentBinding,
228                      FacesContext context,
229                      String JavaDoc componentType)
230     throws FacesException
231   {
232     throw new UnsupportedOperationException JavaDoc();
233   }
234
235   public Iterator<String JavaDoc> getComponentTypes()
236   {
237     throw new UnsupportedOperationException JavaDoc();
238   }
239
240   public void addConverter(String JavaDoc converterId,
241                     String JavaDoc converterClass)
242   {
243     throw new UnsupportedOperationException JavaDoc();
244   }
245
246   public void addConverter(Class JavaDoc targetClass,
247                     String JavaDoc converterClass)
248   {
249     throw new UnsupportedOperationException JavaDoc();
250   }
251
252   public Converter createConverter(String JavaDoc converterId)
253     throws FacesException
254   {
255     throw new UnsupportedOperationException JavaDoc();
256   }
257
258   public Converter createConverter(Class JavaDoc targetClass)
259     throws FacesException
260   {
261     throw new UnsupportedOperationException JavaDoc();
262   }
263
264   public Iterator<String JavaDoc> getConverterIds()
265   {
266     throw new UnsupportedOperationException JavaDoc();
267   }
268
269   public Iterator<Class JavaDoc> getConverterTypes()
270   {
271     throw new UnsupportedOperationException JavaDoc();
272   }
273
274   @Deprecated JavaDoc
275   public MethodBinding createMethodBinding(String JavaDoc ref,
276                        Class JavaDoc []param)
277     throws ReferenceSyntaxException
278   {
279     throw new UnsupportedOperationException JavaDoc();
280   }
281
282   public Iterator<Locale> getSupportedLocales()
283   {
284     throw new UnsupportedOperationException JavaDoc();
285   }
286
287   public void setSupportedLocales(Collection<Locale> locales)
288   {
289     throw new UnsupportedOperationException JavaDoc();
290   }
291
292   public void addValidator(String JavaDoc validatorId, String JavaDoc validatorClass)
293   {
294     throw new UnsupportedOperationException JavaDoc();
295   }
296
297   public Validator createValidator(String JavaDoc validatorId)
298     throws FacesException
299   {
300     throw new UnsupportedOperationException JavaDoc();
301   }
302
303   public Iterator<String JavaDoc> getValidatorIds()
304   {
305     throw new UnsupportedOperationException JavaDoc();
306   }
307
308   @Deprecated JavaDoc
309   public ValueBinding createValueBinding(String JavaDoc ref)
310     throws ReferenceSyntaxException
311   {
312     throw new UnsupportedOperationException JavaDoc();
313   }
314
315   public String JavaDoc toString()
316   {
317     return "ApplicationImpl[]";
318   }
319 }
320
Popular Tags