Package org.drools.runtime

Examples of org.drools.runtime.Channel


    @Override
    public Map<String, Channel> getChannels() {
        Map<String, Channel> channels = new HashMap<String, Channel>();
        for (final Map.Entry<String, org.kie.api.runtime.Channel> entry : delegate.getChannels().entrySet()) {
            channels.put(entry.getKey(), new Channel() {
                @Override
                public void send(Object object) {
                    entry.getValue().send(object);
                }
            });
View Full Code Here


    @Test
    public void testChannels() throws IOException, ClassNotFoundException {
        KnowledgeBase kbase = getKnowledgeBase( "test_Channels.drl" );
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
       
        Channel someChannel = mock( Channel.class );
        ksession.registerChannel( "someChannel", someChannel );
       
        ksession.insert( new Cheese( "brie", 30 ) );
        ksession.insert( new Cheese( "stilton", 5 ) );
       
View Full Code Here

        clientKBase.addKnowledgePackages( kbuilder.getKnowledgePackages() );       

        final StatefulKnowledgeSession serverKsession = serverKBase.newStatefulKnowledgeSession();       
        final StatefulKnowledgeSession clientKsession = clientKBase.newStatefulKnowledgeSession();
       
        serverKsession.getChannels().put( "sensors", new Channel() {           
            public void send(Object object) {
                clientKsession.insert( object );
                clientKsession.fireAllRules();
            }
        } );
       
        clientKsession.getChannels().put( "commands", new Channel() {           
            public void send(Object object) {
                serverKsession.insert( object );
                serverKsession.fireAllRules();
            }
        } );       
View Full Code Here

       
        JLabel lblScore = new JLabel("Score");
        scorePanel.add(lblScore);
       
        final JTextField txtScore = new JTextField();
        gameView.getKsession().getChannels().put( "score", new Channel() {           
            public void send(Object object) {
                txtScore.setText( "" + ((Score ) object).getValue() );
            }
        } );
       
View Full Code Here

     
      Map<String,Channel> channel_map = RuleServiceCallHelper.getChannels(config);
      assertNotNull(channel_map);
      assertTrue(channel_map.size() == 3);
     
      Channel channel_1 = channel_map.get("channel_1");
      assertNotNull(channel_1);
      channel_1.send("test_1");
      assertEquals(1, TestChannel.count);
     
      Channel channel_2 = channel_map.get("channel_2");
      assertNotNull(channel_2);
      channel_2.send("test_2");
      assertEquals(4, TestChannel.count);
     
      Channel channel_3 = channel_map.get("channel_3");
      assertNotNull(channel_3);
      assertTrue(channel_3 instanceof ServiceChannel);
      Service service_3 = ((ServiceChannel)channel_3).getService();
      assertNotNull(service_3);
      assertEquals("category_3", service_3.getCategory());
View Full Code Here

    if (channel_map != null)
    {
      for (Entry<String,Channel> channel_entry : channel_map.entrySet())
      {
        String channel_name = channel_entry.getKey();
        Channel channel = channel_entry.getValue();
        if (channel_name != null && channel != null)
        {
          session.registerChannel(channel_name, channel);
        }
      }
View Full Code Here

        {
          channel_list = new ArrayList<Channel>();
          channel_list_map.put(channel_name, channel_list);
        }
        String channel_class_name = send_to_cfg.getAttribute("channel-class", ServiceChannel.class.getName());
        Channel channel;
        try
        {
          Class<Channel> channel_class = (Class<Channel>)ClassUtil.forName(channel_class_name, RuleServiceCallHelper.class);
          channel = channel_class.newInstance();
          if (channel instanceof Configurable)
          {
            ((Configurable)channel).setConfiguration(send_to_cfg);
          }
          channel_list.add(channel);
        }
        catch (ClassNotFoundException cnfe)
        {
          throw new ConfigurationException("could not find channel-class: " + channel_class_name, cnfe);
        }
        catch (Exception nsme)
        {
          throw new ConfigurationException("problem instantiating channel-class: " + channel_class_name, nsme);
        }
      }
      Map<String,Channel> channel_map = new HashMap<String,Channel>();
      for (Entry<String,List<Channel>> entry : channel_list_map.entrySet())
      {
        String channel_name = entry.getKey();
        final List<Channel> channel_list = entry.getValue();
        int channel_list_size = channel_list.size();
        if (channel_list_size == 1)
        {
          channel_map.put(channel_name, channel_list.get(0));
        }
        else if (channel_list_size > 1)
        {
          channel_map.put(channel_name, new Channel() {
            public void send(Object object) {
              for (Channel channel : channel_list) {
                channel.send(object);
              }
            }
          });
        }
      }
View Full Code Here

    @Override
    public Map<String, Channel> getChannels() {
        Map<String, Channel> channels = new HashMap<String, Channel>();
        for (final Map.Entry<String, org.kie.api.runtime.Channel> entry : delegate.getChannels().entrySet()) {
            channels.put(entry.getKey(), new Channel() {
                @Override
                public void send(Object object) {
                    entry.getValue().send(object);
                }
            });
View Full Code Here

    @Override
    public Map<String, Channel> getChannels() {
        Map<String, Channel> channels = new HashMap<String, Channel>();
        for (final Map.Entry<String, org.kie.api.runtime.Channel> entry : delegate.getChannels().entrySet()) {
            channels.put(entry.getKey(), new Channel() {
                @Override
                public void send(Object object) {
                    entry.getValue().send(object);
                }
            });
View Full Code Here

   
    public void testChannels() throws IOException, ClassNotFoundException {
        KnowledgeBase kbase = getKnowledgeBase( "test_Channels.drl" );
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
       
        Channel someChannel = mock( Channel.class );
        ksession.registerChannel( "someChannel", someChannel );
       
        ksession.insert( new Cheese( "brie", 30 ) );
        ksession.insert( new Cheese( "stilton", 5 ) );
       
View Full Code Here

TOP

Related Classes of org.drools.runtime.Channel

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.