Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
I'm new to Esper and am interested in using it to send event data via a network so consequently interested in the EsperIOSocketAdapter It appears that SocketAdapter can only bind to a specific port which is fine if there is only one network adapter but is it possible to configure the SocketAdapter to bind to a specific network adapter too by specifying its IP address?
Copyright (C) 2006-2015 EsperTech Inc. All rights reserved. * http://esper.codehaus.org * http://www.espertech.com * ---------------------------------------------------------------------------------- * The software in this package is published under the terms of the GPL license * a copy of which has been included with this distribution in the license.txt file. * /
  
  package com.espertech.esperio.socket;
 
 
 import java.util.Map;
 import java.util.Set;
 
 public class EsperIOSocketAdapter
 {
     private static Log log = LogFactory.getLog(EsperIOSocketAdapter.class);
 
     private final ConfigurationSocketAdapter config;
     private final String engineURI;
 
     private final Map<StringEsperSocketServicesockets = new HashMap<StringEsperSocketService>();

    
Quickstart constructor.

Parameters:
config configuration
 
     public EsperIOSocketAdapter(ConfigurationSocketAdapter configString engineURI)
     {
         this. = config;
         this. = engineURI;
     }

    
Re-initialize.
 
     public void initialize()
     {
     }

    
Start the socket endpoint.
 
     public synchronized void start()
     {
         if (.isInfoEnabled())
         {
             .info("Starting EsperIO Socket Adapter for engine URI '" +  + "'");
         }
 
         EPServiceProviderSPI engineSPI = (EPServiceProviderSPI) EPServiceProviderManager.getExistingProvider();
 
         // Configure sockets (input adapter)
         Set<Integerports = new HashSet<Integer>();
         for (Map.Entry<StringSocketConfigentry : .getSockets().entrySet()) {
             if (.containsKey(entry.getKey())) {
                 throw new ConfigurationException("A socket by name '" + entry.getKey() + "' has already been configured.");
             }
 
             int port = entry.getValue().getPort();
             if (ports.contains(port)) {
                 throw new ConfigurationException("A socket for port '" + port + "' has already been configured.");
             }
             ports.add(port);
 
             EsperSocketService socketService = new EsperSocketService(entry.getKey(), entry.getValue());
             .put(entry.getKey(), socketService);
         }
 
         // Start sockets
         for (Map.Entry<StringEsperSocketServiceentry : .entrySet()) {
             try {
                 entry.getValue().start(entry.getKey(), engineSPI);
             }
             catch (IOException e) {
                 String message = "Error starting socket '" + entry.getKey() + "' port " + entry.getValue().getPort() + " :" + e.getMessage();
                 .error(messagee);
                 throw new EPException(messagee);
             }
         }
 
         if (.isInfoEnabled())
         {
             .info("Completed starting EsperIO Socket Adapter for engine URI '" +  + "'.");
         }
     }

    
Destroy the adapter.
    public synchronized void destroy()
    {
        if (.isDebugEnabled())
        {
            .debug("Destroying Esper Socket Adapter");
        }
        for (EsperSocketService service : .values()) {
            try {
                service.destroy();
            } catch (Throwable t) {
                .info("Error destroying service '" + service.getServiceName() + "' :" + t.getMessage());
            }
        }
        .clear();
    }
New to GrepCode? Check out our FAQ X