All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bitronix.tm.resource.ehcache.EhCacheXAResourceHolder Maven / Gradle / Ivy

There is a newer version: 62
Show newest version
/*
 * Copyright (C) 2006-2013 Bitronix Software (http://www.bitronix.be)
 *
 * 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 bitronix.tm.resource.ehcache;

import bitronix.tm.resource.common.AbstractXAResourceHolder;
import bitronix.tm.resource.common.ResourceBean;

import javax.transaction.xa.XAResource;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * Ehcache implementation of BTM's XAResourceHolder.
 * 

* Copyright 2003-2010 Terracotta, Inc. *

* * @author Ludovic Orban */ public class EhCacheXAResourceHolder extends AbstractXAResourceHolder { private static final String EHCACHE_CANT_BE_USED = "EhCacheXAResourceHolder cannot be used with an XAPool"; private final XAResource resource; private final ResourceBean bean; /** * Create a new EhCacheXAResourceHolder for a particular XAResource * * @param resource * the required XAResource * @param bean * the required ResourceBean */ public EhCacheXAResourceHolder(XAResource resource, ResourceBean bean) { this.resource = resource; this.bean = bean; } /** * {@inheritDoc} */ @Override public XAResource getXAResource() { return resource; } /** * {@inheritDoc} */ @Override public ResourceBean getResourceBean() { return bean; } /** * {@inheritDoc} */ @Override public List getXAResourceHolders() { return Collections.singletonList(this); } /** * {@inheritDoc} */ @Override public Object getConnectionHandle() throws Exception { throw new UnsupportedOperationException(EHCACHE_CANT_BE_USED); } /** * {@inheritDoc} */ @Override public void close() throws Exception { throw new UnsupportedOperationException(EHCACHE_CANT_BE_USED); } /** * {@inheritDoc} */ @Override public Date getLastReleaseDate() { throw new UnsupportedOperationException(EHCACHE_CANT_BE_USED); } /** * Method getXAResourceHolderForXaResource ... * * @param xaResource * of type XAResource * * @return EhCacheXAResourceHolder */ public EhCacheXAResourceHolder getXAResourceHolderForXaResource(XAResource xaResource) { if (xaResource == resource) { return this; } return null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy