Package se.arkalix

Class ArSystem.Builder

  • Enclosing interface:
    ArSystem

    public static class ArSystem.Builder
    extends java.lang.Object
    Builder useful for creating ArSystem instances.
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • name

        public ArSystem.Builder name​(java.lang.String name)
        Sets system name.

        If running this Arrowhead system in secure mode, the name should either be left unspecified or match the least significant part of the Common Name (CN) in the system certificate. For example, if the CN is "system1.cloud1.arrowhead.eu", then the name must be "system1" or not be set at all. Note that the Arrowhead standard demands that the common name is a dot-separated hierarchical name. If not set, then the least significant part of the certificate provided via identity(OwnedIdentity) is used as name.

        If not running in secure mode, the name must be specified explicitly. Avoid picking names that contain whitespace or anything but alphanumeric ASCII characters and dashes, as mandated for DNS names by RFC 1035, Section 2.3.1.

        Parameters:
        name - Name of this system.
        Returns:
        This builder.
        See Also:
        More about Arrowhead certifiate names, RFC 1035, Section 2.3.1
      • localAddress

        public ArSystem.Builder localAddress​(java.net.InetAddress address)
        Sets the network interface and socket port number to be used by this system when providing its services.

        If a socket address and/or port has been set previously with any of the other builder setters, only the address is updated by this method.

        If no socket address or port is specified, the wildcard network interface will be used and a random port will be selected by the system.

        Parameters:
        address - Internet address associated with the preferred network interface.
        Returns:
        This builder.
      • localSocketAddress

        public ArSystem.Builder localSocketAddress​(java.net.InetSocketAddress socketAddress)
        Sets the network interface and socket port number to be used by this system when providing its services.

        If no socket address or port is specified, the wildcard network interface will be used and a random port will be selected by the system.

        Parameters:
        socketAddress - Internet socket address associated with the preferred network interface.
        Returns:
        This builder.
      • localAddressPort

        public ArSystem.Builder localAddressPort​(java.net.InetAddress address,
                                                 int port)
        Sets the network interface by socketAddress and socket port number to be used by this system when providing its services.

        If no socket address or port is specified, the wildcard network interface will be used and a random port will be selected by the system.

        Parameters:
        address - Internet address associated with the preferred network interface.
        port - Socket port number. If 0 is provided, the system will choose a random port.
        Returns:
        This builder.
      • localHostnamePort

        public ArSystem.Builder localHostnamePort​(java.lang.String hostname,
                                                  int port)
        Sets the network interface by hostname and socket port number to be used by this system when providing its services.

        Calling this method with a non-null hostname will cause a blocking hostname resolution attempt to take place.

        If no socket hostname or port is specified, the wildcard network interface will be used and a random port will be selected by the system.

        Parameters:
        hostname - DNS hostname associated with preferred network interface.
        port - Socket port number. If 0 is provided, the system will choose a random port.
        Returns:
        This builder.
      • localPort

        public ArSystem.Builder localPort​(int port)
        Sets the socket port number to be used by this system when providing its services.

        If a socket address has been set previously with any of the other builder setters, only the port number is updated by this method.

        If no socket address or port is specified, the wildcard network interface will be used and a random port will be selected by the system.

        Parameters:
        port - Socket port number. If 0 is provided, the system will choose a random port.
        Returns:
        This builder.
      • identity

        public final ArSystem.Builder identity​(OwnedIdentity identity)
        Sets owned identity to use for representing the created system and its services.

        An ArSystem either must have or must not have an owned identity, depending on whether it is running in secure mode or not, respectively.

        Parameters:
        identity - Owned identity to use.
        Returns:
        This builder.
      • trustStore

        public final ArSystem.Builder trustStore​(TrustStore trustStore)
        Sets trust store to use for determining what systems are trusted to be communicated by the created system.

        An ArSystem either must have or must not have a trust store, depending on whether it is running in secure mode or not, respectively.

        Parameters:
        trustStore - Trust store to use.
        Returns:
        This builder.
      • insecure

        public final ArSystem.Builder insecure()
        Explicitly enables insecure mode for this Arrowhead system.

        In insecure mode, no cryptography is used to establish identities or connections between systems. Usage of this mode is not advised for most kinds of production scenarios.

        It is an error to provide an owned identity or a trust store via identity(OwnedIdentity) or trustStore(TrustStore) if insecure mode is enabled.

        Returns:
        This builder.
      • plugins

        public ArSystem.Builder plugins​(Plugin... plugins)
        Sets plugins to be used by this system.

        Plugins are useful for listening and reacting to system life-cycle event, and can be used to inject security functionality into services, automatically spin up services, among other things.

        Parameters:
        plugins - Desired system plugins.
        Returns:
        This builder.
      • plugins

        public ArSystem.Builder plugins​(java.util.Collection<Plugin> plugins)
        Sets plugins to be used by this system.

        Plugins are useful for listening and reacting to system life-cycle event, and can be used to inject security functionality into services, automatically spin up services, among other things.

        Parameters:
        plugins - Desired system plugins.
        Returns:
        This builder.
      • build

        public ArSystem build()
        Finalizes construction of new ArSystem and then blocks the current thread until all of its plugins have been attached.
        Returns:
        New ArSystem.
      • buildAsync

        public Future<ArSystem> buildAsync()
        Finalizes construction of new ArSystem and then attaches all of its plugins asynchronously.
        Returns:
        Future completed with a new ArSystem if such could be constructed and its plugins attached.