01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.container.services;
07:
08: import java.util.HashMap;
09: import java.util.Map;
10:
11: import org.apache.pluto.services.ContainerService;
12: import org.apache.pluto.services.PortletContainerEnvironment;
13:
14: /**
15: * Implementation of Apache Pluto PortletContainerEnvironment.
16: * @author Ken Weiner, kweiner@unicon.net
17: * @version $Revision: 34757 $
18: */
19: public class PortletContainerEnvironmentImpl implements
20: PortletContainerEnvironment {
21:
22: private Map containerServices = new HashMap();
23:
24: public ContainerService getContainerService(Class service) {
25: return (ContainerService) containerServices.get(service);
26: }
27:
28: // Additional methods.
29:
30: public void addContainerService(ContainerService service) {
31: Class serviceClass = service.getClass();
32: while (serviceClass != null) {
33: Class[] interfaces = serviceClass.getInterfaces();
34: for (int i = 0; i < interfaces.length; i++) {
35: Class[] interfaces2 = interfaces[i].getInterfaces();
36: for (int j = 0; j < interfaces2.length; j++) {
37: if (interfaces2[j].equals(ContainerService.class)) {
38: containerServices.put(interfaces[i], service);
39: }
40: }
41: }
42: serviceClass = serviceClass.getSuperclass();
43: }
44: }
45:
46: }
|