Skip to main content
summaryrefslogtreecommitdiffstats
blob: ba4f9750c04c1f71078423dc20cd40ba9f4c8f40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/***************************************************************************
 * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *    Eike Stepper - initial API and implementation
 **************************************************************************/
package org.eclipse.net4j.channel;

import org.eclipse.net4j.ILocationAware;
import org.eclipse.net4j.buffer.IBufferHandler;
import org.eclipse.net4j.connector.ConnectorException;
import org.eclipse.net4j.protocol.IProtocol;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.factory.IFactory;
import org.eclipse.net4j.util.lifecycle.ILifecycle;

import java.util.List;

/**
 * @author Eike Stepper
 */
public interface IChannelMultiplexer extends ILocationAware, IContainer<IChannel>
{
  /**
   * @since 2.0
   */
  public static final long NO_CHANNEL_TIMEOUT = Long.MAX_VALUE;

  /**
   * Indicates to use the timeout that is configured via debug property <code>channel.timeout</code> (see .options file)
   * which has a default of 10 seconds.
   * 
   * @since 2.0
   */
  public static final long DEFAULT_CHANNEL_TIMEOUT = -1L;

  /**
   * Returns a list of currently open channels. Note that the resulting list does not contain <code>null</code> values.
   * Generally the {@link IChannel#getIndex() index} of a channel <b>must not</b> be used as an index into this list.
   * Each call to this method creates a new copy of the internal channels array, so it can safely be modified bz the
   * caller.
   * <p>
   * 
   * @since 2.0
   */
  public List<IChannel> getChannels();

  /**
   * Synchronous request to open a new {@link IChannel} with an undefined channel protocol. Since the peer connector
   * can't lookup a protocol {@link IFactory factory} without a protocol identifier the {@link IBufferHandler} of the
   * peer {@link IChannel} can only be provided by externally provided channel {@link ILifecycle lifecycle}
   * {@link IListener listeners}.
   * <p>
   * 
   * @see #openChannel(String, Object)
   * @see #openChannel(IProtocol)
   * @since 2.0
   */
  public IChannel openChannel() throws ConnectorException;

  /**
   * Synchronous request to open a new {@link IChannel} with a channel protocol defined by a given protocol identifier.
   * The peer connector will lookup a protocol {@link IFactory factory} with the protocol identifier, create a
   * {@link IBufferHandler} and inject it into the peer {@link IChannel}.
   * <p>
   * 
   * @see #openChannel()
   * @see #openChannel(IProtocol)
   * @since 2.0
   */
  public IChannel openChannel(String protocolID, Object infraStructure) throws ConnectorException;

  /**
   * Synchronous request to open a new {@link IChannel} with the given channel protocol . The peer connector will lookup
   * a protocol {@link IFactory factory} with the protocol identifier, create a {@link IBufferHandler} and inject it
   * into the peer channel.
   * <p>
   * 
   * @see #openChannel()
   * @see #openChannel(String, Object)
   * @since 2.0
   */
  public IChannel openChannel(IProtocol<?> protocol) throws ConnectorException;

  /**
   * @since 2.0
   */
  public long getChannelTimeout();

  /**
   * @since 2.0
   */
  public void setChannelTimeout(long channelTimeout);
}

Back to the top