Package org.mule.context.notification

Examples of org.mule.context.notification.ServerNotificationManager


     * @throws UnsupportedOperationException if the notification fired is not a
     *                                       {@link org.mule.context.notification.CustomNotification}
     */
    public void fireNotification(ServerNotification notification)
    {
        ServerNotificationManager notificationManager = getNotificationManager();
        if (notificationManager != null)
        {
            notificationManager.fireNotification(notification);
        }
        else if (logger.isDebugEnabled())
        {
            logger.debug("MuleEvent Manager is not enabled, ignoring notification: " + notification);
        }
View Full Code Here


    protected void configureMuleContext(MuleContextBuilder builder)
    {
        super.configureMuleContext(builder);

        // Configure EndpointMessageNotificationListener for notifications test
        ServerNotificationManager notificationManager = new ServerNotificationManager();
        notificationManager.addInterfaceToType(EndpointMessageNotificationListener.class,
            EndpointMessageNotification.class);
        notificationManager.addInterfaceToType(SecurityNotificationListener.class, SecurityNotification.class);

        builder.setNotificationManager(notificationManager);
    }
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


    @Override
    public MuleEvent execute(MessageProcessor messageProcessor, MuleEvent event) throws MessagingException
    {
        ServerNotificationManager notificationManager = event.getMuleContext().getNotificationManager();
        boolean fireNotification = event.isNotificationsEnabled();
        if (fireNotification)
        {
            fireNotification(notificationManager, event.getFlowConstruct(), event, messageProcessor,
                             null, MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE);
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(ExceptionStrategyNotificationListener.class,
                                   ExceptionStrategyNotification.class);
        manager.addInterfaceToType(TransactionNotificationListener.class,
                                   TransactionNotification.class);
        manager.addInterfaceToType(PipelineMessageNotificationListener.class,
                                   PipelineMessageNotification.class);
        manager.addInterfaceToType(AsyncMessageNotificationListener.class,
                                   AsyncMessageNotification.class);
        manager.addInterfaceToType(ClusterNodeNotificationListener.class, ClusterNodeNotification.class);
        return manager;
    }
View Full Code Here

    protected void configureMuleContext(MuleContextBuilder builder)
    {
        super.configureMuleContext(builder);

        // Configure EndpointMessageNotificationListener for notifications test
        ServerNotificationManager notificationManager = new ServerNotificationManager();
        notificationManager.addInterfaceToType(EndpointMessageNotificationListener.class,
            EndpointMessageNotification.class);
        notificationManager.addInterfaceToType(SecurityNotificationListener.class, SecurityNotification.class);

        builder.setNotificationManager(notificationManager);
    }
View Full Code Here

    }

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

    }

    @Test
    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

    }

    @Test
    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

    }

    @Test
    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

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.