KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > portal > portlets > viewprocessor > ViewProcessorFactory


1 /*
2  * Copyright 2000-2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16  
17 /*
18  * ViewProcessorFactory.java
19  *
20  * Created on January 27, 2003, 5:16 PM
21  */

22 package org.apache.jetspeed.portal.portlets.viewprocessor;
23
24 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
25 import org.apache.jetspeed.services.logging.JetspeedLogger;
26
27 /**
28  * Creates the appropriate ViewProcessor to process the template
29  *
30  * @author tkuebler
31  * @version $Id: ViewProcessorFactory.java,v 1.1.2.2 2003/02/24 21:52:27 tkuebler Exp $
32  * @stereotype factory
33  *
34  */

35 public class ViewProcessorFactory
36 {
37     /**
38      * Static initialization of the logger for this class
39      */

40     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(ViewProcessorFactory.class.getName());
41     
42     /** Creates a new instance of ViewProcessorFactory */
43     public ViewProcessorFactory()
44       {
45
46         // load the type -> processor map
47
// this should probably be a turbine service...
48
}
49
50     public static ViewProcessor getViewProcessor(String JavaDoc viewType)
51       {
52
53         ViewProcessor viewProcessor;
54
55         // figure out the type of portlet based on the map
56
// will use properties file or xreg based map later
57
// create and return appropriate processor
58
// hardcoded for now, will use some config file map in future
59
if (viewType.equals("Velocity"))
60           {
61             logger.info("ViewProcessorFactory - creating Velocity processor");
62             viewProcessor = new VelocityViewProcessor();
63           }
64         else if (viewType.equals("JSP"))
65           {
66             logger.info("ViewProcessorFactory - creating JSP processor");
67             viewProcessor = new JSPViewProcessor();
68           }
69         else if (viewType.equals("XSL"))
70           {
71             logger.info("ViewProcessorFactory - creating XSL processor");
72             viewProcessor = new XSLViewProcessor();
73           }
74         else if (viewType.equals("RSS"))
75           {
76             logger.info("ViewProcessorFactory - creating RSS processor");
77             viewProcessor = new RSSViewProcessor();
78           }
79         else
80           {
81             logger.error("ViewProcessorFactory - problem figuring out what view processor type you want - " +
82                       viewType);
83             logger.error("ViewProcessorFactory - returing a JSP processor");
84             viewProcessor = new JSPViewProcessor();
85           }
86
87         return viewProcessor;
88       }
89 }
90
Popular Tags