View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.services.information;
18  
19  import java.util.Map;
20  
21  import javax.servlet.ServletConfig;
22  
23  import org.apache.pluto.factory.Factory;
24  import org.apache.pluto.services.information.DynamicInformationProvider;
25  import org.apache.pluto.services.information.InformationProviderService;
26  import org.apache.pluto.services.information.StaticInformationProvider;
27  
28  /***
29   * Factory class for getting Information Provider access
30   *
31   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
32   * @version $Id: InformationProviderServiceImpl.java 517124 2007-03-12 08:10:25Z ate $
33   */
34  public class InformationProviderServiceImpl implements Factory, InformationProviderService
35  {
36      private javax.servlet.ServletConfig servletConfig;
37      private final StaticInformationProvider staticInformationProvider;
38      
39      public InformationProviderServiceImpl(StaticInformationProvider staticInformationProvider, ServletConfig config)
40      {
41          this.staticInformationProvider = staticInformationProvider;
42          
43      }
44  
45      public void init(ServletConfig config, Map properties) throws Exception
46      {
47          // does nothing at all    
48      }
49  
50      public StaticInformationProvider getStaticProvider()
51      {        
52          return staticInformationProvider;
53      }
54  
55      public DynamicInformationProvider getDynamicProvider(javax.servlet.http.HttpServletRequest request)
56      {
57          DynamicInformationProvider provider =
58              (DynamicInformationProvider) request.getAttribute("org.apache.jetspeed.engine.core.DynamicInformationProvider");
59  
60          if (provider == null)
61          {
62              provider = new DynamicInformationProviderImpl(request, servletConfig);
63              request.setAttribute("org.apache.jetspeed.engine.core.DynamicInformationProvider", provider);
64          }
65  
66          return provider;
67      }
68  
69      /***
70       * <p>
71       * destroy
72       * </p>
73       *
74       * @see org.apache.pluto.factory.Factory#destroy()
75       * @throws java.lang.Exception
76       */
77      public void destroy() throws Exception
78      {       
79         // also does nothing
80      }
81  }