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


Java PersistenceManagerFactoryUtils类代码示例

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


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

示例1: afterCompletion

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
@Override
public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException {
	String participateAttributeName = getParticipateAttributeName();
	Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
	if (count != null) {
		// Do not modify the PersistenceManager: just clear the marker.
		if (count > 1) {
			request.setAttribute(participateAttributeName, count - 1, WebRequest.SCOPE_REQUEST);
		}
		else {
			request.removeAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
		}
	}
	else {
		PersistenceManagerHolder pmHolder = (PersistenceManagerHolder)
				TransactionSynchronizationManager.unbindResource(getPersistenceManagerFactory());
		logger.debug("Closing JDO PersistenceManager in OpenPersistenceManagerInViewInterceptor");
		PersistenceManagerFactoryUtils.releasePersistenceManager(
				pmHolder.getPersistenceManager(), getPersistenceManagerFactory());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:OpenPersistenceManagerInViewInterceptor.java

示例2: preHandle

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
@Override
public void preHandle(WebRequest request) throws DataAccessException {
	if (TransactionSynchronizationManager.hasResource(getPersistenceManagerFactory())) {
		// Do not modify the PersistenceManager: just mark the request accordingly.
		String participateAttributeName = getParticipateAttributeName();
		Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
		int newCount = (count != null ? count + 1 : 1);
		request.setAttribute(getParticipateAttributeName(), newCount, WebRequest.SCOPE_REQUEST);
	}
	else {
		logger.debug("Opening JDO PersistenceManager in OpenPersistenceManagerInViewInterceptor");
		PersistenceManager pm =
				PersistenceManagerFactoryUtils.getPersistenceManager(getPersistenceManagerFactory(), true);
		TransactionSynchronizationManager.bindResource(
				getPersistenceManagerFactory(), new PersistenceManagerHolder(pm));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:OpenPersistenceManagerInViewInterceptor.java

示例3: preHandle

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
public void preHandle(WebRequest request) throws DataAccessException {
	if (TransactionSynchronizationManager.hasResource(getPersistenceManagerFactory())) {
		// Do not modify the PersistenceManager: just mark the request accordingly.
		String participateAttributeName = getParticipateAttributeName();
		Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
		int newCount = (count != null ? count + 1 : 1);
		request.setAttribute(getParticipateAttributeName(), newCount, WebRequest.SCOPE_REQUEST);
	}
	else {
		logger.debug("Opening JDO PersistenceManager in OpenPersistenceManagerInViewInterceptor");
		PersistenceManager pm =
				PersistenceManagerFactoryUtils.getPersistenceManager(getPersistenceManagerFactory(), true);
		TransactionSynchronizationManager.bindResource(
				getPersistenceManagerFactory(), new PersistenceManagerHolder(pm));
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:OpenPersistenceManagerInViewInterceptor.java

示例4: afterCompletion

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException {
	String participateAttributeName = getParticipateAttributeName();
	Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
	if (count != null) {
		// Do not modify the PersistenceManager: just clear the marker.
		if (count > 1) {
			request.setAttribute(participateAttributeName, count - 1, WebRequest.SCOPE_REQUEST);
		}
		else {
			request.removeAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
		}
	}
	else {
		PersistenceManagerHolder pmHolder = (PersistenceManagerHolder)
				TransactionSynchronizationManager.unbindResource(getPersistenceManagerFactory());
		logger.debug("Closing JDO PersistenceManager in OpenPersistenceManagerInViewInterceptor");
		PersistenceManagerFactoryUtils.releasePersistenceManager(
				pmHolder.getPersistenceManager(), getPersistenceManagerFactory());
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:OpenPersistenceManagerInViewInterceptor.java

示例5: doFilterInternal

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
@Override
protected void doFilterInternal(
		HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
		throws ServletException, IOException {

	PersistenceManagerFactory pmf = lookupPersistenceManagerFactory(request);
	boolean participate = false;

	if (TransactionSynchronizationManager.hasResource(pmf)) {
		// Do not modify the PersistenceManager: just set the participate flag.
		participate = true;
	}
	else {
		logger.debug("Opening JDO PersistenceManager in OpenPersistenceManagerInViewFilter");
		PersistenceManager pm = PersistenceManagerFactoryUtils.getPersistenceManager(pmf, true);
		TransactionSynchronizationManager.bindResource(pmf, new PersistenceManagerHolder(pm));
	}

	try {
		filterChain.doFilter(request, response);
	}

	finally {
		if (!participate) {
			PersistenceManagerHolder pmHolder = (PersistenceManagerHolder)
					TransactionSynchronizationManager.unbindResource(pmf);
			logger.debug("Closing JDO PersistenceManager in OpenPersistenceManagerInViewFilter");
			PersistenceManagerFactoryUtils.releasePersistenceManager(pmHolder.getPersistenceManager(), pmf);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:OpenPersistenceManagerInViewFilter.java

示例6: invoke

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	// Invocation on PersistenceManager interface coming in...

	if (method.getName().equals("equals")) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (method.getName().equals("hashCode")) {
		// Use hashCode of PersistenceManager proxy.
		return System.identityHashCode(proxy);
	}
	else if (method.getName().equals("toString")) {
		// Deliver toString without touching a target EntityManager.
		return "Spring PersistenceManager proxy for target factory [" + getPersistenceManagerFactory() + "]";
	}
	else if (method.getName().equals("getPersistenceManagerFactory")) {
		// Return PersistenceManagerFactory without creating a PersistenceManager.
		return getPersistenceManagerFactory();
	}
	else if (method.getName().equals("isClosed")) {
		// Proxy is always usable.
		return false;
	}
	else if (method.getName().equals("close")) {
		// Suppress close method.
		return null;
	}

	// Invoke method on target PersistenceManager.
	PersistenceManager pm = PersistenceManagerFactoryUtils.doGetPersistenceManager(
			getPersistenceManagerFactory(), isAllowCreate());
	try {
		Object retVal = method.invoke(pm, args);
		if (retVal instanceof Query) {
			PersistenceManagerFactoryUtils.applyTransactionTimeout(
					(Query) retVal, getPersistenceManagerFactory());
		}
		return retVal;
	}
	catch (InvocationTargetException ex) {
		throw ex.getTargetException();
	}
	finally {
		PersistenceManagerFactoryUtils.doReleasePersistenceManager(pm, getPersistenceManagerFactory());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:SpringPersistenceManagerProxyBean.java

示例7: invoke

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	// Invocation on PersistenceManager interface coming in...

	if (method.getName().equals("equals")) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (method.getName().equals("hashCode")) {
		// Use hashCode of PersistenceManager proxy.
		return System.identityHashCode(proxy);
	}
	else if (method.getName().equals("toString")) {
		// Deliver toString without touching a target EntityManager.
		return "Spring PersistenceManager proxy for target factory [" + getPersistenceManagerFactory() + "]";
	}
	else if (method.getName().equals("getPersistenceManagerFactory")) {
		// Return PersistenceManagerFactory without creating a PersistenceManager.
		return getPersistenceManagerFactory();
	}
	else if (method.getName().equals("isClosed")) {
		// Proxy is always usable.
		return false;
	}
	else if (method.getName().equals("close")) {
		// Suppress close method.
		return null;
	}

	// Invoke method on target PersistenceManager.
	PersistenceManager pm = PersistenceManagerFactoryUtils.doGetPersistenceManager(
			getPersistenceManagerFactory(), isAllowCreate());
	try {
		Object retVal = method.invoke(pm, args);
		if (retVal instanceof Query) {
			PersistenceManagerFactoryUtils.applyTransactionTimeout(
					(Query) retVal, getPersistenceManagerFactory(), getJdoDialect());
		}
		return retVal;
	}
	catch (InvocationTargetException ex) {
		throw ex.getTargetException();
	}
	finally {
		PersistenceManagerFactoryUtils.doReleasePersistenceManager(pm, getPersistenceManagerFactory());
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:47,代码来源:SpringPersistenceManagerProxyBean.java

示例8: getPersistenceManager

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
/**
 * Get a JDO PersistenceManager, either from the current transaction or
 * a new one. The latter is only allowed if "allowCreate" is true.
 * @param allowCreate if a non-transactional PersistenceManager should be created
 * when no transactional PersistenceManager can be found for the current thread
 * @return the JDO PersistenceManager
 * @throws DataAccessResourceFailureException if the PersistenceManager couldn't be created
 * @throws IllegalStateException if no thread-bound PersistenceManager found and allowCreate false
 * @see org.springframework.orm.jdo.PersistenceManagerFactoryUtils#getPersistenceManager
 */
protected final PersistenceManager getPersistenceManager(boolean allowCreate)
	throws DataAccessResourceFailureException, IllegalStateException {

	return PersistenceManagerFactoryUtils.getPersistenceManager(getPersistenceManagerFactory(), allowCreate);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:JdoDaoSupport.java

示例9: releasePersistenceManager

import org.springframework.orm.jdo.PersistenceManagerFactoryUtils; //导入依赖的package包/类
/**
 * Close the given JDO PersistenceManager, created via this DAO's
 * PersistenceManagerFactory, if it isn't bound to the thread.
 * @param pm PersistenceManager to close
 * @see org.springframework.orm.jdo.PersistenceManagerFactoryUtils#releasePersistenceManager
 */
protected final void releasePersistenceManager(PersistenceManager pm) {
	PersistenceManagerFactoryUtils.releasePersistenceManager(pm, getPersistenceManagerFactory());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:JdoDaoSupport.java


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