KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portal > PortalSessionInitializer


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portal;
6
7 import org.exoplatform.container.SessionContainer;
8 import org.exoplatform.portal.session.RequestInfo;
9 import org.exoplatform.container.SessionContainerInitializer;
10 import org.exoplatform.services.log.LogUtil;
11 import org.exoplatform.services.organization.OrganizationService;
12 import org.exoplatform.services.organization.UserProfile;
13 import org.exoplatform.portal.session.ExoPortal ;
14 import org.exoplatform.portal.faces.component.UIPortal ;
15 import org.exoplatform.portal.faces.component.PortalComponentCache ;
16 /**
17  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
18  * @since Jan 11, 2005
19  * @version $Id$
20  */

21 public class PortalSessionInitializer implements SessionContainerInitializer {
22   
23   public void initialize(SessionContainer container) {
24     try {
25       // register user profile to the session container
26
OrganizationService orgService =
27         (OrganizationService) container.getComponentInstanceOfType(OrganizationService.class) ;
28       UserProfile userProfile = orgService.findUserProfileByName(container.getOwner());
29       if(userProfile == null) userProfile = orgService.createUserProfileInstance() ;
30       container.registerComponentInstance(userProfile.getClass(), userProfile) ;
31       
32       container.registerComponentInstance(new RequestInfo()) ;
33       container.registerComponentImplementation(PortalComponentCache.class) ;
34       container.registerComponentImplementation(ExoPortal.class, UIPortal.class) ;
35     } catch (Exception JavaDoc ex) {
36       LogUtil.getLog(getClass()).error("Error in PortalSessionInitializer", ex) ;
37     }
38   }
39 }
40
Popular Tags