001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.context.event; 018 019import java.lang.reflect.Method; 020 021import org.springframework.context.ApplicationListener; 022import org.springframework.core.Ordered; 023 024/** 025 * Default {@link EventListenerFactory} implementation that supports the 026 * regular {@link EventListener} annotation. 027 * 028 * <p>Used as "catch-all" implementation by default. 029 * 030 * @author Stephane Nicoll 031 * @since 4.2 032 */ 033public class DefaultEventListenerFactory implements EventListenerFactory, Ordered { 034 035 private int order = LOWEST_PRECEDENCE; 036 037 038 public void setOrder(int order) { 039 this.order = order; 040 } 041 042 @Override 043 public int getOrder() { 044 return this.order; 045 } 046 047 048 public boolean supportsMethod(Method method) { 049 return true; 050 } 051 052 @Override 053 public ApplicationListener<?> createApplicationListener(String beanName, Class<?> type, Method method) { 054 return new ApplicationListenerMethodAdapter(beanName, type, method); 055 } 056 057}