Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
************************************************************************************ http://code.google.com/a/apache-extras.org/p/camel-extra This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/licenses/gpl-2.0-standalone.html *************************************************************************************
 
 package org.apacheextras.camel.component.esper;
 
 
An endpoint for working with Esper

Version:
$Revision: 1.1 $
 
 public class EsperEndpoint extends DefaultEndpoint {
 
   private final EsperComponent component;
   private final String name;
   private boolean mapEvents;
   private boolean configured = false;
   private String pattern;
   private String eql;
   private EPStatement statement;
   private final AtomicInteger consumers = new AtomicInteger(0);
 
   public EsperEndpoint(String uriEsperComponent componentString name) {
     super(uricomponent);
     this. = component;
     this. = name;
   }
 
   @Override
   public boolean isSingleton() {
     return true;
   }
 
   @Override
   public EsperProducer createProducer() throws Exception {
     return new EsperProducer(this);
   }
 
   @Override
   public EsperConsumer createConsumer(Processor processorthrows Exception {
     EPStatement stat = getStatement();
     return new EsperConsumer(thisprocessor);
   }
 
   @Override
     EPStatement stat = getStatement();
     return new EsperPollingConsumer(this);
   }
 
   private EPStatement getStatement() {
     if ( == null) {
        = createStatement();
       //statement.start();
     }
     return ;
   }
 
   protected EPStatement createStatement() {
     if ( != null) {
     } else {
       ObjectHelper.notNull("eql or pattern");
       return getEsperAdministrator().createEPL();
    }
  }
  public synchronized void removeConsumer() {
    if (0 == .decrementAndGet()) {
      .stop();
      .destroy();
    }
  }

  
Creates a Camel org.apache.camel.Exchange from an Esper com.espertech.esper.client.EventBean instance

Parameters:
newEventBean
oldEventBean
statement
Returns:
Exchange
  public Exchange createExchange(EventBean newEventBeanEventBean oldEventBeanEPStatement statement) {
    Message in = new EsperMessage(newEventBeanoldEventBean);
    in.setHeader("CamelEsperName");
    in.setHeader("CamelEsperStatement"statement);
    if ( != null) {
      in.setHeader("CamelEsperPattern");
    }
    if ( != null) {
      in.setHeader("CamelEsperEql");
    }
    exchange.setIn(in);
    return exchange;
  }
  // Properties
  //-------------------------------------------------------------------------
  public String getName() {
    return ;
  }
  public EPRuntime getEsperRuntime() {
  }
  }
  }
  public boolean isMapEvents() {
    return ;
  }

  
Should we use Map events (the default approach) containing all the message headers and the message body in the "body" entry, or should we just send the body of the message as the event.

Parameters:
mapEvents whether or not we should send map events.
  public void setMapEvents(boolean mapEvents) {
    this. = mapEvents;
  }
  public String getEql() {
    return ;
  }

  
Sets the EQL statement used for consumers

Parameters:
eql
  public void setEql(String eql) {
    this. = eql;
  }
  public String getPattern() {
    return ;
  }

  
Sets the Esper pattern used for consumers

Parameters:
pattern
  public void setPattern(String pattern) {
    this. = pattern;
  }
  public boolean isConfigured() {
    return ;
  }
  public void setConfigured(boolean configured) {
    this. = configured;
  }
New to GrepCode? Check out our FAQ X