Search in sources :

Example 51 with EventListener

use of java.util.EventListener in project spring-boot by spring-projects.

the class ServletContextInitializerBeans method addServletContextInitializerBean.

private void addServletContextInitializerBean(String beanName, ServletContextInitializer initializer, ListableBeanFactory beanFactory) {
    if (initializer instanceof ServletRegistrationBean) {
        Servlet source = ((ServletRegistrationBean<?>) initializer).getServlet();
        addServletContextInitializerBean(Servlet.class, beanName, initializer, beanFactory, source);
    } else if (initializer instanceof FilterRegistrationBean) {
        Filter source = ((FilterRegistrationBean<?>) initializer).getFilter();
        addServletContextInitializerBean(Filter.class, beanName, initializer, beanFactory, source);
    } else if (initializer instanceof DelegatingFilterProxyRegistrationBean) {
        String source = ((DelegatingFilterProxyRegistrationBean) initializer).getTargetBeanName();
        addServletContextInitializerBean(Filter.class, beanName, initializer, beanFactory, source);
    } else if (initializer instanceof ServletListenerRegistrationBean) {
        EventListener source = ((ServletListenerRegistrationBean<?>) initializer).getListener();
        addServletContextInitializerBean(EventListener.class, beanName, initializer, beanFactory, source);
    } else {
        addServletContextInitializerBean(ServletContextInitializer.class, beanName, initializer, beanFactory, initializer);
    }
}
Also used : Filter(jakarta.servlet.Filter) Servlet(jakarta.servlet.Servlet) EventListener(java.util.EventListener)

Example 52 with EventListener

use of java.util.EventListener in project spring-boot by spring-projects.

the class ServletContextInitializerBeans method addAdaptableBeans.

@SuppressWarnings("unchecked")
protected void addAdaptableBeans(ListableBeanFactory beanFactory) {
    MultipartConfigElement multipartConfig = getMultipartConfig(beanFactory);
    addAsRegistrationBean(beanFactory, Servlet.class, new ServletRegistrationBeanAdapter(multipartConfig));
    addAsRegistrationBean(beanFactory, Filter.class, new FilterRegistrationBeanAdapter());
    for (Class<?> listenerType : ServletListenerRegistrationBean.getSupportedTypes()) {
        addAsRegistrationBean(beanFactory, EventListener.class, (Class<EventListener>) listenerType, new ServletListenerRegistrationBeanAdapter());
    }
}
Also used : MultipartConfigElement(jakarta.servlet.MultipartConfigElement) EventListener(java.util.EventListener)

Example 53 with EventListener

use of java.util.EventListener in project hazelcast by hazelcast.

the class MapProxySupport method getListenerImplOrNull.

@SuppressWarnings("unchecked")
private <T extends EventListener> T getListenerImplOrNull(ListenerConfig listenerConfig) {
    EventListener implementation = listenerConfig.getImplementation();
    if (implementation != null) {
        return (T) implementation;
    }
    String className = listenerConfig.getClassName();
    if (className != null) {
        try {
            ClassLoader configClassLoader = getNodeEngine().getConfigClassLoader();
            return ClassLoaderUtil.newInstance(configClassLoader, className);
        } catch (Exception e) {
            throw rethrow(e);
        }
    }
    // returning null to preserve previous behavior
    return null;
}
Also used : EventListener(java.util.EventListener)

Example 54 with EventListener

use of java.util.EventListener in project hazelcast by hazelcast.

the class MultiMapProxyImpl method initialize.

@Override
public void initialize() {
    NodeEngine nodeEngine = getNodeEngine();
    List<EntryListenerConfig> listenerConfigs = config.getEntryListenerConfigs();
    for (EntryListenerConfig listenerConfig : listenerConfigs) {
        EntryListener listener = null;
        if (listenerConfig.getImplementation() != null) {
            EventListener impl = listenerConfig.getImplementation();
            listener = checkInstanceOf(EntryListener.class, impl, impl + " should be an instance of EntryListener");
        } else if (listenerConfig.getClassName() != null) {
            try {
                listener = ClassLoaderUtil.newInstance(nodeEngine.getConfigClassLoader(), listenerConfig.getClassName());
            } catch (Exception e) {
                throw ExceptionUtil.rethrow(e);
            }
        }
        if (listener != null) {
            if (listener instanceof HazelcastInstanceAware) {
                ((HazelcastInstanceAware) listener).setHazelcastInstance(nodeEngine.getHazelcastInstance());
            }
            if (listenerConfig.isLocal()) {
                addLocalEntryListener(listener);
            } else {
                addEntryListener(listener, listenerConfig.isIncludeValue());
            }
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) EventListener(java.util.EventListener) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) EntryListener(com.hazelcast.core.EntryListener) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware)

Example 55 with EventListener

use of java.util.EventListener in project cayenne by apache.

the class ProjectController method fireProcedureParameterEvent.

/**
 * Informs all listeners of the ProcedureEvent. Does not send the event to
 * its originator.
 */
public void fireProcedureParameterEvent(ProcedureParameterEvent e) {
    setDirty(true);
    EventListener[] list = listenerList.getListeners(ProcedureParameterListener.class);
    for (EventListener eventListener : list) {
        ProcedureParameterListener listener = (ProcedureParameterListener) eventListener;
        switch(e.getId()) {
            case MapEvent.ADD:
                listener.procedureParameterAdded(e);
                break;
            case MapEvent.CHANGE:
                listener.procedureParameterChanged(e);
                break;
            case MapEvent.REMOVE:
                listener.procedureParameterRemoved(e);
                break;
            default:
                throw new IllegalArgumentException("Invalid ProcedureParameterEvent type: " + e.getId());
        }
    }
}
Also used : ProcedureParameterListener(org.apache.cayenne.configuration.event.ProcedureParameterListener) EventListener(java.util.EventListener)

Aggregations

EventListener (java.util.EventListener)71 Test (org.junit.Test)11 ListenerInfo (io.undertow.servlet.api.ListenerInfo)5 ServletRequestListener (javax.servlet.ServletRequestListener)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ServletContextListener (javax.servlet.ServletContextListener)3 HttpSessionListener (javax.servlet.http.HttpSessionListener)3 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)3 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)3 Bundle (org.osgi.framework.Bundle)3 BundleContext (org.osgi.framework.BundleContext)3 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 EventObject (java.util.EventObject)2 List (java.util.List)2 NamingException (javax.naming.NamingException)2 ServletRequestEvent (javax.servlet.ServletRequestEvent)2 HttpSessionIdListener (javax.servlet.http.HttpSessionIdListener)2