001// Licensed under the Apache License, Version 2.0 (the "License"); 002// you may not use this file except in compliance with the License. 003// You may obtain a copy of the License at 004// 005// http://www.apache.org/licenses/LICENSE-2.0 006// 007// Unless required by applicable law or agreed to in writing, software 008// distributed under the License is distributed on an "AS IS" BASIS, 009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 010// See the License for the specific language governing permissions and 011// limitations under the License. 012 013package org.apache.tapestry5.hibernate; 014 015/** 016 * Service that can create an interceptor that wraps around a service implementation. After invoking service methods 017 * marked by {@link org.apache.tapestry5.hibernate.annotations.CommitAfter} the current transaction is committed. 018 * Declared exceptions will also {@linkplain org.apache.tapestry5.hibernate.HibernateSessionManager#commit() commit the 019 * transaction}; runtime exceptions will {@linkplain org.apache.tapestry5.hibernate.HibernateSessionManager#abort() the 020 * transaction}. 021 * 022 * It is recommended that you switch from the use of decoration to the use of advice; use the {@link 023 * org.apache.tapestry5.hibernate.HibernateTransactionAdvisor} (from a service advisor method) instead. 024 */ 025public interface HibernateTransactionDecorator 026{ 027 /** 028 * Builds a transaction interceptor instance around the delegate. 029 * 030 * @param <T> 031 * @param serviceInterface interface implemented by the delegate 032 * @param delegate existing object to be wrapped 033 * @param serviceId id of service 034 * @return a new object implementing the interface that can be used in place of the delegate, providing 035 * transactional behavior 036 */ 037 <T> T build(Class<T> serviceInterface, T delegate, String serviceId); 038}