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.pki.CertService; 031import org.nuxeo.runtime.api.Framework; 032 033/** 034 * CertService provider 035 * 036 * @author <a href="mailto:ws@nuxeo.com">Wojciech Sulejman</a> 037 */ 038 039@Name("certService") 040@Scope(SESSION) 041public class CertServiceBusinessDelegate implements Serializable { 042 043 private static final long serialVersionUID = 2L; 044 045 private static final Log log = LogFactory.getLog(CertServiceBusinessDelegate.class); 046 047 protected CertService certService; 048 049 /** 050 * @return CertService 051 */ 052 @Unwrap 053 public CertService getService() { 054 if (certService == null) { 055 certService = Framework.getService(CertService.class); 056 } 057 return certService; 058 } 059 060 @Destroy 061 public void destroy() { 062 if (certService != null) { 063 certService = null; 064 } 065 log.debug("Destroyed the seam component"); 066 } 067 068}