当前位置: 首页>>代码示例>>Java>>正文


Java Interceptor类代码示例

本文整理汇总了Java中org.hibernate.Interceptor的典型用法代码示例。如果您正苦于以下问题:Java Interceptor类的具体用法?Java Interceptor怎么用?Java Interceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Interceptor类属于org.hibernate包,在下文中一共展示了Interceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onFlushDirty

import org.hibernate.Interceptor; //导入依赖的package包/类
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previuosState,String[] propertyNames, Type[] types) throws CallbackException {
	
	boolean bool = Boolean.FALSE;
	if(null!=interceptors && !interceptors.isEmpty()){
		Iterator it = interceptors.iterator();
		while(it.hasNext()){
			Interceptor interceptor = (Interceptor) it.next();
			boolean temp=false;
			if(interceptor!=null){
				temp= interceptor.onFlushDirty(entity, id, currentState, previuosState, propertyNames, types);
				if(temp) bool = true;
			}
			}
	}
	return bool;
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:17,代码来源:GenericSecurityInterceptor.java

示例2: getEntityInterceptor

import org.hibernate.Interceptor; //导入依赖的package包/类
/**
 * Return the current Hibernate entity interceptor, or {@code null} if none.
 * Resolves an entity interceptor bean name via the bean factory,
 * if necessary.
 * @throws IllegalStateException if bean name specified but no bean factory set
 * @throws BeansException if bean name resolution via the bean factory failed
 * @see #setEntityInterceptor
 * @see #setEntityInterceptorBeanName
 * @see #setBeanFactory
 */
public Interceptor getEntityInterceptor() throws IllegalStateException, BeansException {
	if (this.entityInterceptor instanceof Interceptor) {
		return (Interceptor) entityInterceptor;
	}
	else if (this.entityInterceptor instanceof String) {
		if (this.beanFactory == null) {
			throw new IllegalStateException("Cannot get entity interceptor via bean name if no bean factory set");
		}
		String beanName = (String) this.entityInterceptor;
		return this.beanFactory.getBean(beanName, Interceptor.class);
	}
	else {
		return null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:HibernateTransactionManager.java

示例3: openSession

import org.hibernate.Interceptor; //导入依赖的package包/类
/**
 * Note method sets user session information in the database and opens a connection for this.
 */
public Session openSession(Connection connection, Interceptor interceptor) {
  // NOTE: workaround for this issue:
  // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529
  final Session session = delegateSessionFactory.openSession(connection, interceptor);
  final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
  try {
    Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader());
    Connection conn = ((SessionImplementor) session).connection();
    SessionInfo.initDB(conn, OBPropertiesProvider.getInstance().getOpenbravoProperties()
        .getProperty("bbdd.rdbms"));
    SessionInfo.setDBSessionInfo(conn);
  } finally {
    Thread.currentThread().setContextClassLoader(currentLoader);
  }
  return session;
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:20,代码来源:DalSessionFactory.java

示例4: JDBCContext

import org.hibernate.Interceptor; //导入依赖的package包/类
public JDBCContext(Context owner, Connection connection, Interceptor interceptor) {
	this.owner = owner;
	this.connectionManager = new ConnectionManager(
	        owner.getFactory(),
	        this,
	        owner.getConnectionReleaseMode(),
	        connection,
	        interceptor
		);

	final boolean registerSynchronization = owner.isAutoCloseSessionEnabled()
	        || owner.isFlushBeforeCompletionEnabled()
	        || owner.getConnectionReleaseMode() == ConnectionReleaseMode.AFTER_TRANSACTION;
	if ( registerSynchronization ) {
		registerSynchronizationIfPossible();
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:JDBCContext.java

示例5: deserialize

import org.hibernate.Interceptor; //导入依赖的package包/类
/**
 * Custom deserialization routine used during deserialization of a
 * Session/PersistenceContext for increased performance.
 *
 * @param ois The stream from which to read the entry.
 * @throws IOException
 */
public static JDBCContext deserialize(
		ObjectInputStream ois,
        Context context,
        Interceptor interceptor) throws IOException {
	JDBCContext jdbcContext = new JDBCContext();
	jdbcContext.owner = context;
	jdbcContext.connectionManager = ConnectionManager.deserialize(
			ois,
			context.getFactory(),
	        interceptor,
	        context.getConnectionReleaseMode(),
	        jdbcContext
	);
	return jdbcContext;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:JDBCContext.java

示例6: ConnectionManager

import org.hibernate.Interceptor; //导入依赖的package包/类
/**
 * Constructs a ConnectionManager.
 * <p/>
 * This is the form used internally.
 * 
 * @param factory The SessionFactory.
 * @param callback An observer for internal state change.
 * @param releaseMode The mode by which to release JDBC connections.
 * @param connection An externally supplied connection.
 */ 
public ConnectionManager(
        SessionFactoryImplementor factory,
        Callback callback,
        ConnectionReleaseMode releaseMode,
        Connection connection,
        Interceptor interceptor) {
	this.factory = factory;
	this.callback = callback;

	this.interceptor = interceptor;
	this.batcher = factory.getSettings().getBatcherFactory().createBatcher( this, interceptor );

	this.connection = connection;
	wasConnectionSupplied = ( connection != null );

	this.releaseMode = wasConnectionSupplied ? ConnectionReleaseMode.ON_CLOSE : releaseMode;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:28,代码来源:ConnectionManager.java

示例7: openSession

import org.hibernate.Interceptor; //导入依赖的package包/类
private SessionImpl openSession(
	Connection connection,
    boolean autoClose,
    long timestamp,
    Interceptor sessionLocalInterceptor
) {
	return new SessionImpl(
	        connection,
	        this,
	        autoClose,
	        timestamp,
	        sessionLocalInterceptor == null ? interceptor : sessionLocalInterceptor,
	        settings.getDefaultEntityMode(),
	        settings.isFlushBeforeCompletionEnabled(),
	        settings.isAutoCloseSessionEnabled(),
	        settings.getConnectionReleaseMode()
		);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:19,代码来源:SessionFactoryImpl.java

示例8: interceptor

import org.hibernate.Interceptor; //导入依赖的package包/类
@Override
protected Interceptor interceptor() {
    return new EmptyInterceptor() {
        private Long startNanos;

        @Override
        public void preFlush(Iterator entities) {
            startNanos = System.nanoTime();
        }

        @Override
        public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
            if (enableMetrics) {
                timer.update(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
            }
            return false;
        }
    };
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:20,代码来源:BytecodeEnhancementDirtyCheckingPerformanceTest.java

示例9: onDelete

import org.hibernate.Interceptor; //导入依赖的package包/类
@Override
public void onDelete(Object entity, Serializable id, Object[] state,
        String[] propertyNames, Type[] types) {
    for(Interceptor i: interceptors) {
        i.onDelete(entity, id, state, propertyNames, types);
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:8,代码来源:CompoundInterceptor.java

示例10: testEntityInterceptor

import org.hibernate.Interceptor; //导入依赖的package包/类
@Test
public void testEntityInterceptor() throws Exception {
  List<Interceptor> interceptors = getValue(entityInterceptorService, "interceptors");
  assertEquals(2, interceptors.size());

  boolean containsAuditTrailInterceptor = false;
  boolean containsIdBucketInterceptor = false;

  for (Interceptor interceptor : interceptors) {
    containsAuditTrailInterceptor = containsAuditTrailInterceptor
        || interceptor.getClass().equals(AuditTrailInterceptor.class);
    containsIdBucketInterceptor = containsIdBucketInterceptor
        || interceptor.getClass().equals(IdBucketInterceptor.class);
  }

  assertTrue(containsAuditTrailInterceptor);
  assertTrue(containsIdBucketInterceptor);
}
 
开发者ID:tunguski,项目名称:matsuo-core,代码行数:19,代码来源:TestDatabase.java

示例11: newSessionFactory

import org.hibernate.Interceptor; //导入依赖的package包/类
private SessionFactory newSessionFactory() {
    Properties properties = getProperties();
    Configuration configuration = new Configuration().addProperties(properties);
    for(Class<?> entityClass : entities()) {
        configuration.addAnnotatedClass(entityClass);
    }
    String[] packages = packages();
    if(packages != null) {
        for(String scannedPackage : packages) {
            configuration.addPackage(scannedPackage);
        }
    }
    Interceptor interceptor = interceptor();
    if(interceptor != null) {
        configuration.setInterceptor(interceptor);
    }
    return configuration.buildSessionFactory(
            new StandardServiceRegistryBuilder()
                    .applySettings(properties)
                    .build()
    );
}
 
开发者ID:vladmihalcea,项目名称:hibernate-master-class,代码行数:23,代码来源:AbstractTest.java

示例12: onFlushDirty

import org.hibernate.Interceptor; //导入依赖的package包/类
@Override
public boolean onFlushDirty(Object entity,
                            Serializable id,
                            Object[] currentState,
                            Object[] previousState,
                            String[] propertyNames,
                            Type[] types) {
    if (!isExists())
        return false;

    if (isTraceEnabled)
        log.trace("인터셉터의 onFlush 메소드를 멀티캐스트로 수행합니다.");

    for (final Interceptor interceptor : interceptors) {
        interceptor.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
    }

    return false;
}
 
开发者ID:debop,项目名称:debop4j,代码行数:20,代码来源:MultiInterceptor.java

示例13: onSave

import org.hibernate.Interceptor; //导入依赖的package包/类
@Override
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
    if (!isExists())
        return false;

    if (isTraceEnabled)
        log.trace("인터셉터의 onSave 메소드를 멀티캐스트로 수행합니다.");

    List<FutureTask<Boolean>> tasks = Lists.newLinkedList();

    for (final Interceptor interceptor : interceptors) {
        interceptor.onSave(entity, id, state, propertyNames, types);
    }

    return false;
}
 
开发者ID:debop,项目名称:debop4j,代码行数:17,代码来源:MultiInterceptor.java

示例14: HibernateHelper

import org.hibernate.Interceptor; //导入依赖的package包/类
/**
     * Constructor to build the hibernate helper.
     * @param namingStrategy the name strategy, if one is needed, null otherwise.
     * @param interceptor the interceptor, if one is needed, null otherwise.
     */
    public HibernateHelper(NamingStrategy namingStrategy, Interceptor interceptor) {
        try {
            configuration = new AnnotationConfiguration();
            initializeConfig(namingStrategy, interceptor);
            configuration = configuration.configure();
            // We call buildSessionFactory twice, because it appears that the annotated classes are
            // not 'activated' in the config until we build. The filters required the classes to
            // be present, so we throw away the first factory and use the second. If this is
            // removed, you'll likely see a NoClassDefFoundError in the unit tests
            configuration.buildSessionFactory();
            sessionFactory = configuration.buildSessionFactory();
        } catch (HibernateException e) {
//            LOG.error(e.getMessage(), e);
//            throw new ExceptionInInitializerError(e);
            LOG.warn("Failed to initialize HibernateHelper using hibernate.cfg.xml.  "
                    + "This is expected behavior during unit testing." , e);
            e.printStackTrace();
        }
    }
 
开发者ID:NCIP,项目名称:labviewer,代码行数:25,代码来源:HibernateHelper.java

示例15: getNewSession

import org.hibernate.Interceptor; //导入依赖的package包/类
/**
 * Get a new Hibernate Session from the given SessionFactory.
 * Will return a new Session even if there already is a pre-bound
 * Session for the given SessionFactory.
 * <p>Within a transaction, this method will create a new Session
 * that shares the transaction's JDBC Connection. More specifically,
 * it will use the same JDBC Connection as the pre-bound Hibernate Session.
 * @param sessionFactory Hibernate SessionFactory to create the session with
 * @param entityInterceptor Hibernate entity interceptor, or {@code null} if none
 * @return the new Session
 */
@SuppressWarnings("deprecation")
public static Session getNewSession(SessionFactory sessionFactory, Interceptor entityInterceptor) {
	Assert.notNull(sessionFactory, "No SessionFactory specified");

	try {
		SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
		if (sessionHolder != null && !sessionHolder.isEmpty()) {
			if (entityInterceptor != null) {
				return sessionFactory.openSession(sessionHolder.getAnySession().connection(), entityInterceptor);
			}
			else {
				return sessionFactory.openSession(sessionHolder.getAnySession().connection());
			}
		}
		else {
			if (entityInterceptor != null) {
				return sessionFactory.openSession(entityInterceptor);
			}
			else {
				return sessionFactory.openSession();
			}
		}
	}
	catch (HibernateException ex) {
		throw new DataAccessResourceFailureException("Could not open Hibernate Session", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:SessionFactoryUtils.java


注:本文中的org.hibernate.Interceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。