KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.HashMap JavaDoc;
23
24 import org.apache.pluto.services.ContainerService;
25
26 public class PortletContainerEnvironment
27 implements org.apache.pluto.services.PortletContainerEnvironment {
28
29     private HashMap JavaDoc services = new HashMap JavaDoc();
30
31     public PortletContainerEnvironment()
32     {
33     }
34
35     // org.apache.pluto.services.PortletContainerEnvironment implementation.
36

37     public ContainerService getContainerService(Class JavaDoc service)
38     {
39         return(ContainerService)services.get(service);
40     }
41
42     // additional methods.
43

44     public void addContainerService(ContainerService service)
45     {
46         Class JavaDoc serviceClass = service.getClass();
47         while (serviceClass!=null) {
48             Class JavaDoc[] interfaces = serviceClass.getInterfaces();
49             for (int i = 0; i < interfaces.length; i++) {
50                 Class JavaDoc[] interfaces2 = interfaces[i].getInterfaces();
51                 for (int ii = 0; ii < interfaces2.length; ii++) {
52                     if (interfaces2[ii].equals(ContainerService.class)) {
53                         services.put(interfaces[i], service);
54                     }
55                 }
56             }
57             serviceClass = serviceClass.getSuperclass();
58         }
59     }
60
61 }
62
Popular Tags