Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java 27 Sep 2006 02:32:16 -0000 1.1 @@ -0,0 +1,60 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id: AdminServiceProxy.java,v 1.1 2006/09/27 02:32:16 jliew Exp $ */ +package org.lamsfoundation.lams.admin.service; + +import javax.servlet.ServletContext; + +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.MessageService; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * @author jliew + * + * Common class to make it easier to get the Spring beans. + */ +public class AdminServiceProxy { + + private static IUserManagementService manageService; + private static MessageService messageService; + + public static final IUserManagementService getService(ServletContext servletContext){ + if (manageService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + return (IUserManagementService) ctx.getBean("userManagementServiceTarget"); + } else { + return manageService; + } + } + + public static final MessageService getMessageService(ServletContext servletContext){ + if (messageService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + return (MessageService)ctx.getBean("adminMessageService"); + } else { + return messageService; + } + } +}