Search in sources :

Example 61 with EventListener

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

the class ProjectController method fireObjEntityDisplayEvent.

public void fireObjEntityDisplayEvent(EntityDisplayEvent e) {
    boolean changed = e.getEntity() != currentState.objEntity;
    if (!e.isRefired()) {
        e.setEntityChanged(changed);
        if (changed) {
            clearState();
            currentState.domain = e.getDomain();
            currentState.node = e.getDataNode();
            currentState.map = e.getDataMap();
            currentState.objEntity = (ObjEntity) e.getEntity();
        }
    }
    if (changed) {
        saveState(e);
    }
    for (EventListener listener : listenerList.getListeners(ObjEntityDisplayListener.class)) {
        ObjEntityDisplayListener temp = (ObjEntityDisplayListener) listener;
        temp.currentObjEntityChanged(e);
    }
}
Also used : EventListener(java.util.EventListener) ObjEntityDisplayListener(org.apache.cayenne.modeler.event.ObjEntityDisplayListener)

Example 62 with EventListener

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

the class ProjectController method fireObjAttributeDisplayEvent.

public void fireObjAttributeDisplayEvent(AttributeDisplayEvent e) {
    boolean changed = !Arrays.equals(e.getAttributes(), currentState.objAttrs);
    if (changed) {
        if (e.getEntity() != currentState.objEntity) {
            clearState();
            currentState.domain = e.getDomain();
            currentState.map = e.getDataMap();
            currentState.objEntity = (ObjEntity) e.getEntity();
        }
        currentState.objAttrs = new ObjAttribute[e.getAttributes().length];
        System.arraycopy(e.getAttributes(), 0, currentState.objAttrs, 0, currentState.objAttrs.length);
    }
    EventListener[] list = listenerList.getListeners(ObjAttributeDisplayListener.class);
    for (EventListener listener : list) {
        ObjAttributeDisplayListener temp = (ObjAttributeDisplayListener) listener;
        temp.currentObjAttributeChanged(e);
    }
}
Also used : ObjAttributeDisplayListener(org.apache.cayenne.modeler.event.ObjAttributeDisplayListener) EventListener(java.util.EventListener)

Example 63 with EventListener

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

the class ProjectController method fireEmbeddableAttributeDisplayEvent.

public void fireEmbeddableAttributeDisplayEvent(EmbeddableAttributeDisplayEvent ev) {
    boolean changed = !Arrays.equals(ev.getEmbeddableAttributes(), currentState.embAttrs);
    if (changed) {
        if (ev.getEmbeddable() != currentState.embeddable) {
            clearState();
            currentState.domain = ev.getDomain();
            currentState.map = ev.getDataMap();
            currentState.embeddable = ev.getEmbeddable();
        }
        currentState.embAttrs = new EmbeddableAttribute[ev.getEmbeddableAttributes().length];
        System.arraycopy(ev.getEmbeddableAttributes(), 0, currentState.embAttrs, 0, currentState.embAttrs.length);
    }
    EventListener[] list = listenerList.getListeners(EmbeddableAttributeDisplayListener.class);
    for (EventListener listener : list) {
        EmbeddableAttributeDisplayListener temp = (EmbeddableAttributeDisplayListener) listener;
        temp.currentEmbeddableAttributeChanged(ev);
    }
}
Also used : EmbeddableAttributeDisplayListener(org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayListener) EventListener(java.util.EventListener)

Example 64 with EventListener

use of java.util.EventListener in project Payara by payara.

the class StandardContext method fireRequestInitializedEvent.

@Override
public void fireRequestInitializedEvent(ServletRequest request) {
    List<EventListener> listeners = getApplicationEventListeners();
    ServletRequestEvent event = null;
    if (!listeners.isEmpty()) {
        event = new ServletRequestEvent(getServletContext(), request);
        // create pre-service event
        Iterator<EventListener> iter = listeners.iterator();
        while (iter.hasNext()) {
            EventListener eventListener = iter.next();
            if (!(eventListener instanceof ServletRequestListener)) {
                continue;
            }
            ServletRequestListener listener = (ServletRequestListener) eventListener;
            // START SJSAS 6329662
            fireContainerEvent(ContainerEvent.BEFORE_REQUEST_INITIALIZED, listener);
            // END SJSAS 6329662
            try {
                listener.requestInitialized(event);
            } catch (Throwable t) {
                String msg = MessageFormat.format(rb.getString(LogFacade.REQUEST_INIT_EXCEPTION), listener.getClass().getName());
                log.log(Level.WARNING, msg, t);
                request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
            // START SJSAS 6329662
            } finally {
                fireContainerEvent(ContainerEvent.AFTER_REQUEST_INITIALIZED, listener);
            // END SJSAS 6329662
            }
        }
    }
}
Also used : ServletRequestListener(javax.servlet.ServletRequestListener) ServletRequestEvent(javax.servlet.ServletRequestEvent) EventListener(java.util.EventListener)

Example 65 with EventListener

use of java.util.EventListener in project Payara by payara.

the class StandardContext method fireRequestDestroyedEvent.

@Override
public void fireRequestDestroyedEvent(ServletRequest request) {
    List<EventListener> listeners = getApplicationEventListeners();
    if (!listeners.isEmpty()) {
        // create post-service event
        ServletRequestEvent event = new ServletRequestEvent(getServletContext(), request);
        int len = listeners.size();
        for (int i = 0; i < len; i++) {
            EventListener eventListener = listeners.get((len - 1) - i);
            if (!(eventListener instanceof ServletRequestListener)) {
                continue;
            }
            ServletRequestListener listener = (ServletRequestListener) eventListener;
            // START SJSAS 6329662
            fireContainerEvent(ContainerEvent.BEFORE_REQUEST_DESTROYED, listener);
            // END SJSAS 6329662
            try {
                listener.requestDestroyed(event);
            } catch (Throwable t) {
                String msg = MessageFormat.format(rb.getString(LogFacade.REQUEST_DESTROY_EXCEPTION), listener.getClass().getName());
                log.log(Level.WARNING, msg, t);
                request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
            // START SJSAS 6329662
            } finally {
                fireContainerEvent(ContainerEvent.AFTER_REQUEST_DESTROYED, listener);
            // END SJSAS 6329662
            }
        }
    }
}
Also used : ServletRequestListener(javax.servlet.ServletRequestListener) ServletRequestEvent(javax.servlet.ServletRequestEvent) EventListener(java.util.EventListener) SecurityConstraint(org.apache.catalina.deploy.SecurityConstraint)

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