org.springframework.core.InfrastructureProxy Java Examples

The following examples show how to use org.springframework.core.InfrastructureProxy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionSynchronizationUtils.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Unwrap the given resource handle if necessary; otherwise return
 * the given handle as-is.
 * @see org.springframework.core.InfrastructureProxy#getWrappedObject()
 */
static Object unwrapResourceIfNecessary(Object resource) {
	Assert.notNull(resource, "Resource must not be null");
	Object resourceRef = resource;
	// unwrap infrastructure proxy
	if (resourceRef instanceof InfrastructureProxy) {
		resourceRef = ((InfrastructureProxy) resourceRef).getWrappedObject();
	}
	if (aopAvailable) {
		// now unwrap scoped proxy
		resourceRef = ScopedProxyUnwrapper.unwrapIfNecessary(resourceRef);
	}
	return resourceRef;
}
 
Example #2
Source File: TransactionSynchronizationUtils.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Unwrap the given resource handle if necessary; otherwise return
 * the given handle as-is.
 * @see InfrastructureProxy#getWrappedObject()
 */
static Object unwrapResourceIfNecessary(Object resource) {
	Assert.notNull(resource, "Resource must not be null");
	Object resourceRef = resource;
	// unwrap infrastructure proxy
	if (resourceRef instanceof InfrastructureProxy) {
		resourceRef = ((InfrastructureProxy) resourceRef).getWrappedObject();
	}
	if (aopAvailable) {
		// now unwrap scoped proxy
		resourceRef = ScopedProxyUnwrapper.unwrapIfNecessary(resourceRef);
	}
	return resourceRef;
}
 
Example #3
Source File: TransactionSynchronizationUtils.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Unwrap the given resource handle if necessary; otherwise return
 * the given handle as-is.
 * @see org.springframework.core.InfrastructureProxy#getWrappedObject()
 */
static Object unwrapResourceIfNecessary(Object resource) {
	Assert.notNull(resource, "Resource must not be null");
	Object resourceRef = resource;
	// unwrap infrastructure proxy
	if (resourceRef instanceof InfrastructureProxy) {
		resourceRef = ((InfrastructureProxy) resourceRef).getWrappedObject();
	}
	if (aopAvailable) {
		// now unwrap scoped proxy
		resourceRef = ScopedProxyUnwrapper.unwrapIfNecessary(resourceRef);
	}
	return resourceRef;
}
 
Example #4
Source File: TransactionSynchronizationUtils.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unwrap the given resource handle if necessary; otherwise return
 * the given handle as-is.
 * @see org.springframework.core.InfrastructureProxy#getWrappedObject()
 */
static Object unwrapResourceIfNecessary(Object resource) {
	Assert.notNull(resource, "Resource must not be null");
	Object resourceRef = resource;
	// unwrap infrastructure proxy
	if (resourceRef instanceof InfrastructureProxy) {
		resourceRef = ((InfrastructureProxy) resourceRef).getWrappedObject();
	}
	if (aopAvailable) {
		// now unwrap scoped proxy
		resourceRef = ScopedProxyUnwrapper.unwrapIfNecessary(resourceRef);
	}
	return resourceRef;
}
 
Example #5
Source File: TransactionSynchronizationUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Unwrap the given resource handle if necessary; otherwise return
 * the given handle as-is.
 * @see org.springframework.core.InfrastructureProxy#getWrappedObject()
 */
static Object unwrapResourceIfNecessary(Object resource) {
	Assert.notNull(resource, "Resource must not be null");
	Object resourceRef = resource;
	// unwrap infrastructure proxy
	if (resourceRef instanceof InfrastructureProxy) {
		resourceRef = ((InfrastructureProxy) resourceRef).getWrappedObject();
	}
	if (aopAvailable) {
		// now unwrap scoped proxy
		resourceRef = ScopedProxyUnwrapper.unwrapIfNecessary(resourceRef);
	}
	return resourceRef;
}
 
Example #6
Source File: LocalSessionFactoryBuilder.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Build the Hibernate {@code SessionFactory} through background bootstrapping,
 * using the given executor for a parallel initialization phase
 * (e.g. a {@link org.springframework.core.task.SimpleAsyncTaskExecutor}).
 * <p>{@code SessionFactory} initialization will then switch into background
 * bootstrap mode, with a {@code SessionFactory} proxy immediately returned for
 * injection purposes instead of waiting for Hibernate's bootstrapping to complete.
 * However, note that the first actual call to a {@code SessionFactory} method will
 * then block until Hibernate's bootstrapping completed, if not ready by then.
 * For maximum benefit, make sure to avoid early {@code SessionFactory} calls
 * in init methods of related beans, even for metadata introspection purposes.
 * @since 4.3
 * @see #buildSessionFactory()
 */
public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) {
	Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null");
	return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(),
			new Class<?>[] {SessionFactoryImplementor.class, InfrastructureProxy.class},
			new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor));
}
 
Example #7
Source File: LocalSessionFactoryBuilder.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Build the Hibernate {@code SessionFactory} through background bootstrapping,
 * using the given executor for a parallel initialization phase
 * (e.g. a {@link org.springframework.core.task.SimpleAsyncTaskExecutor}).
 * <p>{@code SessionFactory} initialization will then switch into background
 * bootstrap mode, with a {@code SessionFactory} proxy immediately returned for
 * injection purposes instead of waiting for Hibernate's bootstrapping to complete.
 * However, note that the first actual call to a {@code SessionFactory} method will
 * then block until Hibernate's bootstrapping completed, if not ready by then.
 * For maximum benefit, make sure to avoid early {@code SessionFactory} calls
 * in init methods of related beans, even for metadata introspection purposes.
 * @since 4.3
 * @see #buildSessionFactory()
 */
public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) {
	Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null");
	return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(),
			new Class<?>[] {SessionFactoryImplementor.class, InfrastructureProxy.class},
			new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor));
}
 
Example #8
Source File: LocalSessionFactoryBuilder.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Build the Hibernate {@code SessionFactory} through background bootstrapping,
 * using the given executor for a parallel initialization phase
 * (e.g. a {@link org.springframework.core.task.SimpleAsyncTaskExecutor}).
 * <p>{@code SessionFactory} initialization will then switch into background
 * bootstrap mode, with a {@code SessionFactory} proxy immediately returned for
 * injection purposes instead of waiting for Hibernate's bootstrapping to complete.
 * However, note that the first actual call to a {@code SessionFactory} method will
 * then block until Hibernate's bootstrapping completed, if not ready by then.
 * For maximum benefit, make sure to avoid early {@code SessionFactory} calls
 * in init methods of related beans, even for metadata introspection purposes.
 * @since 4.3
 * @see #buildSessionFactory()
 */
public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) {
	Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null");
	return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(),
			new Class<?>[] {SessionFactoryImplementor.class, InfrastructureProxy.class},
			new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor));
}