⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transactioncontextinitializer.java

📁 Jencks是一个轻量级的JCA容器。它可以轻松部署到Spring中以提供消息驱动的POJOs.此外Jencks通过使用类似于JMS,JAX-RPC,JBI与JCA CCI的API来提供对inboun
💻 JAVA
字号:
/* * Copyright 2002-2005 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.jencks.interceptor;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.geronimo.transaction.DefaultInstanceContext;import org.apache.geronimo.transaction.InstanceContext;import org.apache.geronimo.transaction.TrackedConnectionAssociator;import org.springframework.beans.factory.DisposableBean;import org.springframework.beans.factory.InitializingBean;import java.util.HashSet;import java.util.Set;/** * This bean is used to configure a transactional context for * applications that work only within a single thread. * <p/> * At the beginning, it makes enter the application in a new * context and, at the end, exit of it. * * @author Thierry Templier * @see TrackedConnectionAssociator#enter(InstanceContext) * @see TrackedConnectionAssociator#exit(InstanceContext) * @see InstanceContext * @see DefaultInstanceContext */public class TransactionContextInitializer implements InitializingBean, DisposableBean {    private TrackedConnectionAssociator associator;    private InstanceContext oldContext;    protected transient Log logger = LogFactory.getLog(getClass());    public void afterPropertiesSet() throws Exception {        Set unshareableResources = new HashSet();        Set applicationManagedSecurityResources = new HashSet();        this.oldContext = associator.enter(                new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources));        logger.info("Geronimo transaction context set.");    }    public void destroy() throws Exception {        associator.exit(oldContext);        logger.info("Geronimo transaction context unset.");    }    /**     * Set the TrackedConnectionAssociator instance to allow the bean     * to enter and exit a transactional context.     */    public void setAssociator(TrackedConnectionAssociator associator) {        this.associator = associator;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -