Class Net4jUtil

java.lang.Object
org.eclipse.net4j.Net4jUtil

public final class Net4jUtil extends Object
A utility class with various static factory and convenience methods.
Author:
Eike Stepper
  • Field Details

  • Method Details

    • getExecutorService

      public static ExecutorService getExecutorService(org.eclipse.net4j.util.container.IManagedContainer container)
    • getBufferProvider

      public static IBufferProvider getBufferProvider(org.eclipse.net4j.util.container.IManagedContainer container)
    • getAcceptor

      public static IAcceptor getAcceptor(org.eclipse.net4j.util.container.IManagedContainer container, String type, String description)
    • getConnector

      public static IConnector getConnector(org.eclipse.net4j.util.container.IManagedContainer container, String type, String description, long timeout)
      Since:
      4.0
    • getConnector

      public static IConnector getConnector(org.eclipse.net4j.util.container.IManagedContainer container, String type, String description)
    • getConnector

      public static IConnector getConnector(org.eclipse.net4j.util.container.IManagedContainer container, String description)
    • getLocalAcceptor

      public static IAcceptor getLocalAcceptor(org.eclipse.net4j.util.container.IManagedContainer container)
      Since:
      4.18
    • getLocalConnector

      public static IConnector getLocalConnector(org.eclipse.net4j.util.container.IManagedContainer container)
      Since:
      4.18
    • createBufferFactory

      public static IBufferProvider createBufferFactory(short bufferCapacity)
    • createBufferFactory

      public static IBufferProvider createBufferFactory()
    • createBufferPool

      public static IBufferPool createBufferPool(IBufferProvider factory)
    • createBufferPool

      public static IBufferPool createBufferPool(short bufferCapacity)
    • createBufferPool

      public static IBufferPool createBufferPool()
    • getProvidedBuffers

      public static long getProvidedBuffers(IBufferProvider bufferProvider)
    • getRetainedBuffers

      public static long getRetainedBuffers(IBufferProvider bufferProvider)
    • getPooledBuffers

      public static int getPooledBuffers(IBufferPool bufferPool)
    • copyTransportConfig

      public static ITransportConfig copyTransportConfig(org.eclipse.net4j.util.lifecycle.ILifecycle lifecycle, ITransportConfig source)
      Since:
      2.0
    • getProtocolID

      public static String getProtocolID(IProtocol<?> protocol)
      Since:
      4.2
    • getProtocolVersion

      public static int getProtocolVersion(IProtocol<?> protocol)
      Since:
      4.2
    • prepareForSending

      public static ByteBuffer prepareForSending(IBuffer buffer)
      Encodes the Net4j header of an outgoing buffer and returns a view of the complete message.

      The payload is not copied. The returned view has position zero and a limit equal to the message length. The original buffer's state, position, and limit are unchanged; the header is written through a duplicate view of its backing storage.

      The returned view shares storage with the original IBuffer. The sender must retain ownership of the buffer until asynchronous transmission has completed or definitively failed. While the transport provider is using the returned view, the buffer must not be released, cleared, reused, or otherwise mutated. This method neither transfers ownership nor releases the buffer.

      Parameters:
      buffer - An outgoing buffer in PUTTING state.
      Returns:
      A view of the encoded message, including its four-byte header.
      Throws:
      IllegalArgumentException - If the buffer has an invalid channel ID, capacity, or payload length.
      IllegalStateException - If the buffer is not in PUTTING state or violates its state invariants.
      Since:
      4.23
    • wrapBuffer

      public static IBuffer wrapBuffer(ByteBuffer message, Runnable release)
      Wraps one complete encoded Net4j message without copying its payload.

      The input's current position and limit delimit the message. Ownership of the release action transfers to this method when it is invoked. If validation or wrapper construction fails, the action is invoked once before the failure is rethrown.

      Parameters:
      message - Storage containing exactly one complete Net4j message between its current position and limit.
      release - The action that releases the supplied storage; may be null when no action is required.
      Returns:
      A getting buffer over the original message storage.
      Throws:
      IllegalArgumentException - If the message is incomplete, oversized, malformed, or has an invalid channel ID.
      Since:
      4.23
    • prepareContainer

      @Deprecated public static void prepareContainer(org.eclipse.net4j.util.container.IManagedContainer container)
      Deprecated.
      Containers created via ContainerUtil.createInitializedContainer() or OMPlatform.createManagedContainer() are initialized automatically. Advanced callers configuring a raw container can use OMBundle.prepareContainer(IManagedContainer).