View Javadoc

1   /*
2    * Created on Jul 5, 2006 by scott
3    *
4    * Copyright (c) 2006 Regents of the University of California (Regents). Created
5    * by TELS, Graduate School of Education, University of California at Berkeley.
6    *
7    * This software is distributed under the GNU Lesser General Public License, v2.
8    *
9    * Permission is hereby granted, without written agreement and without license
10   * or royalty fees, to use, copy, modify, and distribute this software and its
11   * documentation for any purpose, provided that the above copyright notice and
12   * the following two paragraphs appear in all copies of this software.
13   *
14   * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15   * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16   * PURPOSE. THE SOFTWAREAND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
17   * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
18   * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
19   *
20   * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
21   * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
22   * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
23   * REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24   */
25  
26  package net.sf.sail.core.service.impl;
27  
28  import net.sf.sail.core.beans.SessionContext;
29  import net.sf.sail.core.bundle.Bundle;
30  import net.sf.sail.core.service.ServiceContext;
31  import net.sf.sail.core.service.SessionContextService;
32  
33  /**
34   * @author scott
35   *
36   */
37  public class SessionContextServiceImpl implements Bundle, SessionContextService {
38  	private Class<? extends SessionContext> sessionContextClass = SessionContext.class;
39  	
40  	public void setSessionContextClass(Class<? extends SessionContext> contextClass) {
41  		sessionContextClass = contextClass;
42  	}
43  	
44  	public void initializeBundle(ServiceContext serviceContext) {
45  		// TODO Auto-generated method stub
46  
47  	}
48  
49  	public void registerServices(ServiceContext serviceContext) {
50  		serviceContext.addService(SessionContextService.class, this);
51  
52  	}
53  
54  	public SessionContext createSessionContext() {
55  		try {
56  			return sessionContextClass.newInstance();
57  		} catch (InstantiationException e) {
58  			e.printStackTrace();
59  			return null;
60  		} catch (IllegalAccessException e) {
61  			e.printStackTrace();
62  			return null;
63  		}
64  	}
65  
66  }