@@ -0,0 +1,2351 @@
+/*%0A * Copyright (c) 2008-2012 akquinet tech@spree GmbH%0A *%0A * This file is part of Hibersap.%0A *%0A * Hibersap is free software: you can redistribute it and/or modify it under the terms of the GNU%0A * Lesser General Public License as published by the Free Software Foundation, either version 3 of%0A * the License, or (at your option) any later version.%0A *%0A * Hibersap is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without%0A * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public License along with Hibersap. If%0A * not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage org.hibersap.ejb.util;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0Aimport org.hibersap.HibersapException;%0Aimport org.hibersap.session.SessionManager;%0A%0Aimport javax.annotation.PostConstruct;%0Aimport javax.annotation.PreDestroy;%0Aimport javax.naming.Context;%0Aimport javax.naming.InitialContext;%0Aimport javax.naming.NamingException;%0A%0Apublic class JndiUtil%0A%7B%0A    private static final Log LOG = LogFactory.getLog( JndiUtil.class );%0A%0A    private JndiUtil()%0A    %7B%0A        // use static utility methods%0A    %7D%0A%0A    @PostConstruct%0A    public static void rebindSessionManager( SessionManager sessionManager, String jndiName )%0A    %7B%0A        LOG.info( %22Binding Hibersap SessionManager '%22 + sessionManager.getConfig().getName()%0A                + %22' to JNDI name '%22 + jndiName + %22'%22 );%0A%0A        try%0A        %7B%0A            Context ctx = new InitialContext();%0A            ctx.rebind( jndiName, sessionManager );%0A        %7D%0A        catch ( NamingException e )%0A        %7B%0A            throw new HibersapException( %22Failed binding Hibersap SessionManager to JNDI name %5B%22 + jndiName + %22%5D%22, e );%0A        %7D%0A    %7D%0A%0A    @PreDestroy%0A    public static void unbindSessionManager( String jndiName )%0A    %7B%0A        LOG.info( %22Unbinding Hibersap SessionManager from JNDI name '%22 + jndiName + %22'%22 );%0A%0A        try%0A        %7B%0A            Context ctx = new InitialContext();%0A            ctx.unbind( jndiName );%0A        %7D%0A        catch ( NamingException e )%0A        %7B%0A            LOG.warn( %22Failed to unbind Hibersap SessionManager binding for JNDI name %5B%22 + jndiName + %22%5D%22, e );%0A        %7D%0A    %7D%0A%7D%0A

add JndiUtil