Class GrpcServer

java.lang.Object
org.saidone.unrest.platform.GrpcServer

public final class GrpcServer extends Object
Owns the lifecycle of the embedded Alfresco gRPC listener.

The module's Spring context invokes start() after repository services are available and stop() during shutdown. One bounded worker pool serves all registered repository adapters. Each adapter uses the same TicketInterceptor; only credential authentication bypasses the ticket check. Content downloads use a separate bounded pool, with at most one active transfer per configured repository worker.

A certificate and private key enable server-side TLS. Plaintext listeners are restricted to loopback addresses unless explicitly enabled for isolated benchmarks. Lifecycle methods are synchronized and repeated start/stop calls are safe.

  • Constructor Summary

    Constructors
    Constructor
    Description
    GrpcServer(org.alfresco.service.ServiceRegistry services, boolean enabled, String host, int port, int threads, int maxMessageSize, String certificate, String privateKey)
    Creates a listener configuration; no network socket or worker pool is allocated until start is called.
    GrpcServer(org.alfresco.service.ServiceRegistry services, org.alfresco.repo.rendition2.SynchronousTransformClient transforms, org.alfresco.repo.node.archive.NodeArchiveService archive, boolean enabled, String host, int port, int threads, int maxMessageSize, String certificate, String privateKey)
    Creates a listener configuration; no network socket or worker pool is allocated until start is called.
    GrpcServer(org.alfresco.service.ServiceRegistry services, org.alfresco.repo.rendition2.SynchronousTransformClient transforms, org.alfresco.repo.node.archive.NodeArchiveService archive, boolean enabled, String host, int port, int threads, int maxMessageSize, String certificate, String privateKey, boolean allowInsecureRemote)
    Creates a listener with an explicit plaintext exception for isolated benchmark networks.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Starts the listener unless disabled or already running.
    void
    Stops the listener and its worker pool.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GrpcServer

      public GrpcServer(org.alfresco.service.ServiceRegistry services, boolean enabled, String host, int port, int threads, int maxMessageSize, String certificate, String privateKey)
      Creates a listener configuration; no network socket or worker pool is allocated until start is called.
      Parameters:
      services - Alfresco service registry; repository work uses its secured services
      enabled - whether the listener should start when requested
      host - bind hostname or IP address; plaintext requires a resolved loopback address
      port - TCP port in 1..65535
      threads - positive worker count for the bounded execution pool
      maxMessageSize - maximum inbound message size in bytes, at least 1024
      certificate - PEM certificate path, or blank for plaintext
      privateKey - PEM private-key path, or blank for plaintext
    • GrpcServer

      public GrpcServer(org.alfresco.service.ServiceRegistry services, org.alfresco.repo.rendition2.SynchronousTransformClient transforms, org.alfresco.repo.node.archive.NodeArchiveService archive, boolean enabled, String host, int port, int threads, int maxMessageSize, String certificate, String privateKey)
      Creates a listener configuration; no network socket or worker pool is allocated until start is called.
      Parameters:
      services - Alfresco service registry; repository work uses its secured services
      transforms - synchronous text-transform client, or null to disable non-plain-text extraction
      archive - node archive service, or null to disable the trashcan service
      enabled - whether the listener should start when requested
      host - bind hostname or IP address; plaintext requires a resolved loopback address
      port - TCP port in 1..65535
      threads - positive worker count for the bounded execution pool
      maxMessageSize - maximum inbound message size in bytes, at least 1024
      certificate - PEM certificate path, or blank for plaintext
      privateKey - PEM private-key path, or blank for plaintext
    • GrpcServer

      public GrpcServer(org.alfresco.service.ServiceRegistry services, org.alfresco.repo.rendition2.SynchronousTransformClient transforms, org.alfresco.repo.node.archive.NodeArchiveService archive, boolean enabled, String host, int port, int threads, int maxMessageSize, String certificate, String privateKey, boolean allowInsecureRemote)
      Creates a listener with an explicit plaintext exception for isolated benchmark networks.
      Parameters:
      services - secured Alfresco services
      transforms - optional transform client
      archive - optional archive service
      enabled - whether to start the listener
      host - bind address
      port - listener port
      threads - repository worker count
      maxMessageSize - maximum inbound message bytes
      certificate - TLS certificate path, or blank
      privateKey - TLS private-key path, or blank
      allowInsecureRemote - explicitly allow remote plaintext for isolated benchmarks; default false
  • Method Details

    • start

      public void start() throws Exception
      Starts the listener unless disabled or already running. Validates configuration, allocates a bounded worker pool and registers every repository adapter with ticket interception.

      TLS requires both a certificate and key. Without TLS, the resolved bind address must be loopback unless the isolated-benchmark exception is explicitly enabled. Startup failures after executor allocation shut down that executor before propagating the error.

      Throws:
      IllegalArgumentException - if listener limits or TLS settings are invalid, or plaintext binds outside loopback without the explicit exception
      Exception - if address resolution, TLS setup or listener startup fails
    • stop

      public void stop()
      Stops the listener and its worker pool. Allows up to ten seconds for graceful server termination, then forces shutdown. Restores the interrupt flag if interrupted and clears lifecycle state so another start is possible.