Esempio n. 1
0
 public Object makeObject(Object key) throws Exception {
   ImmutableEndpoint ep = (ImmutableEndpoint) key;
   MulticastSocket socket = (MulticastSocket) super.makeObject(key);
   socket.setLoopbackMode(((MulticastConnector) ep.getConnector()).isLoopback());
   int ttl = ((MulticastConnector) ep.getConnector()).getTimeToLive();
   if (ttl != Connector.INT_VALUE_NOT_SET) {
     socket.setTimeToLive(ttl);
   }
   return socket;
 }
Esempio n. 2
0
  /**
   * Packages a mule event for the current request
   *
   * @param message the event payload
   * @param uri the destination endpointUri
   * @param synchronous whether the event will be synchronously processed
   * @return the MuleEvent
   * @throws MuleException in case of Mule error
   */
  protected MuleEvent getEvent(MuleMessage message, String uri, boolean synchronous)
      throws MuleException {
    ImmutableEndpoint endpoint =
        manager.getRegistry().lookupEndpointFactory().getOutboundEndpoint(uri);
    // Connector connector = endpoint.getConnector();

    //        if (!connector.isStarted() && manager.isStarted())
    //        {
    //            connector.start();
    //        }

    try {
      MuleSession session =
          new DefaultMuleSession(
              message, ((AbstractConnector) endpoint.getConnector()).getSessionHandler());

      if (credentials != null) {
        message.setProperty(MuleProperties.MULE_USER_PROPERTY, "Plain " + credentials.getToken());
      }

      return new DefaultMuleEvent(message, endpoint, session, synchronous);
    } catch (Exception e) {
      throw new DispatchException(
          CoreMessages.failedToCreate("Client event"), message, endpoint, e);
    }
  }
  public void close() throws IOException {
    if (logger.isDebugEnabled()) {
      logger.debug("Closing the stream for the file " + fileName);
    }
    try {
      super.close();

      if (autoDelete && !errorOccured) {
        client.deleteFile(fileName);
      }
    } catch (IOException e) {
      logger.error("Error occured while closing file " + fileName, e);
      throw e;
    } finally {
      // We should release the connection from the pool even if some error
      // occurs here
      try {
        ((SftpConnector) endpoint.getConnector()).releaseClient(endpoint, client);
      } catch (Exception e) {
        logger.error(e.getMessage(), e);
      }
    }
  }
Esempio n. 4
0
 public Connector getConnector() {
   return endpoint.getConnector();
 }
Esempio n. 5
0
 public AbstractConnectable(ImmutableEndpoint endpoint) {
   this.endpoint = endpoint;
   this.connector = (AbstractConnector) endpoint.getConnector();
 }