KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portalImpl > core > InformationProviderServiceFactoryImpl


1 /*
2  * Copyright 2003,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  */

19
20 package org.apache.pluto.portalImpl.core;
21
22 import org.apache.pluto.portalImpl.factory.InformationProviderFactory;
23 import org.apache.pluto.services.information.DynamicInformationProvider;
24 import org.apache.pluto.services.information.InformationProviderService;
25 import org.apache.pluto.services.information.StaticInformationProvider;
26
27 public class InformationProviderServiceFactoryImpl implements InformationProviderFactory, InformationProviderService {
28
29     private javax.servlet.ServletConfig JavaDoc servletConfig;
30
31     // InformationProviderFactory implementation.
32
// InformationProviderService implementation.
33

34     public StaticInformationProvider getStaticProvider()
35     {
36         javax.servlet.ServletContext JavaDoc context = servletConfig.getServletContext();
37
38         StaticInformationProvider provider = (StaticInformationProvider)context.getAttribute(
39             "org.apache.pluto.portalImpl.StaticInformationProvider"
40         );
41
42         if (provider == null) {
43             provider = new StaticInformationProviderImpl(servletConfig);
44             context.setAttribute("org.apache.pluto.portalImpl.StaticInformationProvider", provider);
45         }
46
47         return provider;
48     }
49
50     public DynamicInformationProvider getDynamicProvider(javax.servlet.http.HttpServletRequest JavaDoc request)
51     {
52         DynamicInformationProvider provider =
53         (DynamicInformationProvider)request.getAttribute("org.apache.pluto.portalImpl.DynamicInformationProvider");
54
55         if (provider == null) {
56             provider = new DynamicInformationProviderImpl(request,
57                                                           servletConfig);
58             request.setAttribute("org.apache.pluto.portalImpl.DynamicInformationProvider", provider);
59         }
60
61         return provider;
62     }
63
64
65     // additional methods.
66

67     public void init(javax.servlet.ServletConfig JavaDoc config, java.util.Map JavaDoc properties) throws Exception JavaDoc
68     {
69         servletConfig = config;
70     }
71
72     public void destroy() throws Exception JavaDoc
73     {
74     }
75
76 }
77
Popular Tags