org.springframework.context.event.ApplicationListenerMethodAdapter Java Examples

The following examples show how to use org.springframework.context.event.ApplicationListenerMethodAdapter. 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: ApplicationListenerMethodTransactionalAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public TransactionSynchronizationEventAdapter(ApplicationListenerMethodAdapter listener,
		ApplicationEvent event, TransactionPhase phase) {

	this.listener = listener;
	this.event = event;
	this.phase = phase;
}
 
Example #2
Source File: ApplicationListenerMethodTransactionalAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
public TransactionSynchronizationEventAdapter(ApplicationListenerMethodAdapter listener,
		ApplicationEvent event, TransactionPhase phase) {

	this.listener = listener;
	this.event = event;
	this.phase = phase;
}
 
Example #3
Source File: ApplicationListenerMethodTransactionalAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public TransactionSynchronizationEventAdapter(ApplicationListenerMethodAdapter listener,
		ApplicationEvent event, TransactionPhase phase) {

	this.listener = listener;
	this.event = event;
	this.phase = phase;
}
 
Example #4
Source File: PublicationTargetIdentifier.java    From spring-domain-events with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link PublicationTargetIdentifier} for the given listener instance.
 *
 * @param listener
 * @return
 */
public static PublicationTargetIdentifier forListener(Object listener) {

	return IDENTIFIERS.computeIfAbsent(listener, it -> {

		if (it instanceof ApplicationListenerMethodAdapter) {

			Method method = (Method) ReflectionUtils.getField(LISTENER_METHOD_FIELD, it);
			return PublicationTargetIdentifier.forMethod(method);
		}

		throw new IllegalStateException("Unsupported listener implementation!");
	});
}
 
Example #5
Source File: ApplicationListenerMethodTransactionalAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public TransactionSynchronizationEventAdapter(ApplicationListenerMethodAdapter listener,
		ApplicationEvent event, TransactionPhase phase) {

	this.listener = listener;
	this.event = event;
	this.phase = phase;
}
 
Example #6
Source File: ApplicationListenerMethodTransactionalAdapterTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private void supportsEventType(boolean match, Method method, ResolvableType eventType) {
	ApplicationListenerMethodAdapter adapter = createTestInstance(method);
	assertEquals("Wrong match for event '" + eventType + "' on " + method,
			match, adapter.supportsEventType(eventType));
}
 
Example #7
Source File: ApplicationListenerMethodTransactionalAdapterTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private void supportsEventType(boolean match, Method method, ResolvableType eventType) {
	ApplicationListenerMethodAdapter adapter = createTestInstance(method);
	assertEquals("Wrong match for event '" + eventType + "' on " + method,
			match, adapter.supportsEventType(eventType));
}
 
Example #8
Source File: ApplicationListenerMethodTransactionalAdapterTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private void supportsEventType(boolean match, Method method, ResolvableType eventType) {
	ApplicationListenerMethodAdapter adapter = createTestInstance(method);
	assertEquals("Wrong match for event '" + eventType + "' on " + method,
			match, adapter.supportsEventType(eventType));
}
 
Example #9
Source File: PersistentApplicationEventMulticaster.java    From spring-domain-events with Apache License 2.0 3 votes vote down vote up
private static boolean isTransactionalApplicationEventListener(ApplicationListener<?> listener) {

		Class<?> targetClass = AopUtils.getTargetClass(listener);

		return TX_EVENT_LISTENERS.computeIfAbsent(targetClass, it -> {

			if (!ApplicationListenerMethodAdapter.class.isAssignableFrom(targetClass)) {
				return false;
			}

			Method method = (Method) ReflectionUtils.getField(LISTENER_METHOD_FIELD, listener);

			return AnnotatedElementUtils.hasAnnotation(method, TransactionalEventListener.class);
		});
	}