001/*
002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Wojciech Sulejman
016 *
017 */
018package org.nuxeo.ecm.platform.signature.web.sign;
019
020import static org.jboss.seam.ScopeType.SESSION;
021
022import java.io.Serializable;
023
024import org.apache.commons.logging.Log;
025import org.apache.commons.logging.LogFactory;
026import org.jboss.seam.annotations.Destroy;
027import org.jboss.seam.annotations.Name;
028import org.jboss.seam.annotations.Scope;
029import org.jboss.seam.annotations.Unwrap;
030import org.nuxeo.ecm.platform.signature.api.user.CUserService;
031import org.nuxeo.runtime.api.Framework;
032
033/**
034 * UserInfo service provider
035 *
036 * @author <a href="mailto:ws@nuxeo.com">Wojciech Sulejman</a>
037 */
038
039@Name("cUserService")
040@Scope(SESSION)
041public class CUserServiceBusinessDelegate implements Serializable {
042
043    private static final long serialVersionUID = 3L;
044
045    private static final Log log = LogFactory.getLog(CUserServiceBusinessDelegate.class);
046
047    protected CUserService cUserService;
048
049    @Unwrap
050    public CUserService getService() {
051        if (cUserService == null) {
052            cUserService = Framework.getService(CUserService.class);
053        }
054        return cUserService;
055    }
056
057    @Destroy
058    public void destroy() {
059        if (cUserService != null) {
060            cUserService = null;
061        }
062        log.debug("Destroyed the seam component");
063    }
064}