Package org.mule.context.notification

Examples of org.mule.context.notification.ServerNotificationManager


        return "org/mule/config/spring/parsers/specific/server-notification-manager-test.xml";
    }

    public void testDynamicAttribute()
    {
        ServerNotificationManager manager = muleContext.getNotificationManager();
        assertTrue(manager.isNotificationDynamic());
    }
View Full Code Here


        assertTrue(manager.isNotificationDynamic());
    }

    public void testRoutingConfiguration()
    {
        ServerNotificationManager manager = muleContext.getNotificationManager();
        assertTrue(manager.getInterfaceToTypes().size() > 2);
        Object ifaces = manager.getInterfaceToTypes().get(TestInterface.class);
        assertNotNull(ifaces);
        assertTrue(ifaces instanceof Collection);
        assertTrue(((Collection) ifaces).contains(TestEvent.class));
        ifaces = manager.getInterfaceToTypes().get(TestInterface2.class);
        assertNotNull(ifaces);
        assertTrue(ifaces instanceof Collection);
        assertTrue(((Collection) ifaces).contains(SecurityNotification.class));
    }
View Full Code Here

        assertTrue(((Collection) ifaces).contains(SecurityNotification.class));
    }

    public void testSimpleNotification() throws InterruptedException
    {
        ServerNotificationManager manager = muleContext.getNotificationManager();
        Collection listeners = manager.getListeners();
        //Now all transformers are registered as listeners in order to get a context disposing notification
        assertTrue(listeners.size() > 5);
        TestListener listener = (TestListener) muleContext.getRegistry().lookupObject("listener");
        assertNotNull(listener);
        assertFalse(listener.isCalled());
        manager.fireNotification(new TestEvent());
        Thread.sleep(1000); // asynch events
        assertTrue(listener.isCalled());
    }
View Full Code Here

        assertTrue(listener.isCalled());
    }

    public void testExplicitlyConiguredNotificationListenerRegistration() throws InterruptedException
    {
        ServerNotificationManager manager = muleContext.getNotificationManager();
        assertTrue(manager.getListeners().contains(
            new ListenerSubscriptionPair((ServerNotificationListener) muleContext.getRegistry().lookupObject(
                "listener"), null)));
        assertTrue(manager.getListeners().contains(
            new ListenerSubscriptionPair((ServerNotificationListener) muleContext.getRegistry().lookupObject(
                "listener2"), null)));
        assertTrue(manager.getListeners().contains(
            new ListenerSubscriptionPair((ServerNotificationListener) muleContext.getRegistry().lookupObject(
                "securityListener"), null)));
        assertTrue(manager.getListeners().contains(
            new ListenerSubscriptionPair((ServerNotificationListener) muleContext.getRegistry().lookupObject(
                "listener3"), "*")));
    }
View Full Code Here

                "listener3"), "*")));
    }

    public void testAdhocNotificationListenerRegistrations() throws InterruptedException
    {
        ServerNotificationManager manager = muleContext.getNotificationManager();

        // Not registered asad-hoc listener with null subscription as this is defined
        // explicitly.
        assertFalse(manager.getListeners().contains(
            new ListenerSubscriptionPair((ServerNotificationListener) muleContext.getRegistry().lookupObject(
                "listener3"), null)));

        // Registered as configured
        assertTrue(manager.getListeners().contains(
            new ListenerSubscriptionPair((ServerNotificationListener) muleContext.getRegistry().lookupObject(
                "listener4"), null)));
    }
View Full Code Here

                "listener4"), null)));
    }

    public void testDisabledNotification() throws InterruptedException
    {
        ServerNotificationManager manager = muleContext.getNotificationManager();
        Collection listeners = manager.getListeners();
        //Now all transformers are registered as listeners in order to get a context disposing notification
        assertTrue(listeners.size() > 5);
        TestListener2 listener2 = (TestListener2) muleContext.getRegistry().lookupObject("listener2");
        assertNotNull(listener2);
        assertFalse(listener2.isCalled());
        TestSecurityListener adminListener = (TestSecurityListener) muleContext.getRegistry().lookupObject(
            "securityListener");
        assertNotNull(adminListener);
        assertFalse(adminListener.isCalled());
        manager.fireNotification(new TestSecurityEvent(muleContext));
        Thread.sleep(1000); // asynch events
        assertTrue(listener2.isCalled());
        assertFalse(adminListener.isCalled());
    }
View Full Code Here

        this.muleContext = context;
    }

    public Object getObject() throws Exception
    {
        ServerNotificationManager notificationManager = muleContext.getNotificationManager();
        if (dynamic != null)
        {
            notificationManager.setNotificationDynamic(dynamic.booleanValue());
        }
        if (interfaceToEvents != null)
        {
            notificationManager.setInterfaceToTypes(interfaceToEvents);
        }
        if (interfaces != null)
        {
            notificationManager.setDisabledInterfaces(interfaces);
        }

        // Merge:
        // i) explicitly configured notification listeners,
        // ii) any singleton beans defined in spring that implement ServerNotificationListener.
        Set<ListenerSubscriptionPair> subs = getMergedListeners(notificationManager);
        for (ListenerSubscriptionPair sub : subs)
        {
            // Do this to avoid warnings when the Spring context is refreshed
            if(!notificationManager.isListenerRegistered(sub.getListener()))
            {
                notificationManager.addListenerSubscriptionPair(sub);
            }
        }
        return notificationManager;
    }
View Full Code Here

        return new DefaultWorkListener();
    }

    protected ServerNotificationManager createNotificationManager()
    {
        ServerNotificationManager manager = new ServerNotificationManager();
        manager.addInterfaceToType(MuleContextNotificationListener.class,
                                   MuleContextNotification.class);
        manager.addInterfaceToType(ModelNotificationListener.class, ModelNotification.class);
        manager.addInterfaceToType(RoutingNotificationListener.class, RoutingNotification.class);
        manager.addInterfaceToType(ServiceNotificationListener.class,
                                   ServiceNotification.class);
        manager.addInterfaceToType(SecurityNotificationListener.class,
                                   SecurityNotification.class);
        manager.addInterfaceToType(ManagementNotificationListener.class,
                                   ManagementNotification.class);
        manager.addInterfaceToType(CustomNotificationListener.class, CustomNotification.class);
        manager.addInterfaceToType(ConnectionNotificationListener.class,
                                   ConnectionNotification.class);
        manager.addInterfaceToType(RegistryNotificationListener.class,
                                   RegistryNotification.class);
        manager.addInterfaceToType(ExceptionNotificationListener.class,
                                   ExceptionNotification.class);
        manager.addInterfaceToType(TransactionNotificationListener.class,
                                   TransactionNotification.class);
        return manager;
    }
View Full Code Here

        registerListener(l, null);
    }

    public void registerListener(ServerNotificationListener l, String resourceIdentifier) throws NotificationException
    {
        ServerNotificationManager notificationManager = getNotificationManager();
        if (notificationManager == null)
        {
            throw new MuleRuntimeException(CoreMessages.serverNotificationManagerNotEnabled());
        }
        notificationManager.addListenerSubscription(l, resourceIdentifier);
    }
View Full Code Here

        notificationManager.addListenerSubscription(l, resourceIdentifier);
    }

    public void unregisterListener(ServerNotificationListener l)
    {
        ServerNotificationManager notificationManager = getNotificationManager();
        if (notificationManager != null)
        {
            notificationManager.removeListener(l);
        }
    }
View Full Code Here

TOP

Related Classes of org.mule.context.notification.ServerNotificationManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.