001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (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 *     Nuxeo - initial API and implementation
016 *
017 * $Id:ContentHistoryBusinessDelegate.java 3895 2006-10-11 19:12:47Z janguenot $
018 */
019
020package org.nuxeo.ecm.platform.audit.ws.delegate;
021
022import javax.naming.InitialContext;
023import javax.naming.NamingException;
024
025import org.apache.commons.logging.Log;
026import org.apache.commons.logging.LogFactory;
027import org.nuxeo.ecm.platform.audit.ws.api.WSAudit;
028
029/**
030 * EJB Factory.
031 *
032 * @author <a href="mailto:ja@nuxeo.com">Julien Anguenot</a>
033 */
034public class EJBFactory {
035
036    private static final Log log = LogFactory.getLog(EJBFactory.class);
037
038    // Utility class.
039    private EJBFactory() {
040    }
041
042    private static InitialContext getInitialContext() throws NamingException {
043        return new InitialContext();
044    }
045
046    public static WSAudit getWSAuditRemote() throws NamingException {
047        String beanRemoteLocation = JNDILocations.nxauditWsAuditRemoteLocation;
048        if (log.isDebugEnabled()) {
049            log.debug("Trying to get the remote EJB with JNDI location :" + beanRemoteLocation);
050        }
051        InitialContext ctx = getInitialContext();
052        return (WSAudit) ctx.lookup(beanRemoteLocation);
053    }
054
055}