GenericSenderFactory (Siena 2.0.4 API Documentation)
Date: 2015-05-17

siena.comm

## Class GenericSenderFactory

- java.lang.Object
- - siena.comm.GenericSenderFactory

- All Implemented Interfaces:
    PacketSenderFactory

      public class GenericSenderFactory
      extends java.lang.Object
      implements PacketSenderFactory

  generic packet sender factory. This factory recognizes all the receiver's schemas defined by the core Siena implementation ("tcp" for `TCPPacketReceiver`, "udp" for `UDPPacketReceiver`, "ka" for `KAPacketReceiver`, and "ssl" for `SSLPacketReceiver`).

  In addition to the native schemas, this factory allows new schemas to be registered with their specific factory (see `registerFactory(String,PacketSenderFactory)`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericSenderFactory()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PacketSender` | `createPacketSender(java.lang.String handler)` returns a new packet sender based on the external address (i.e., handler or url) of the intended receiver.
    `static void` | `registerFactory(java.lang.String schema, PacketSenderFactory f)` extends this factory by registering new packet sender factories.
    `static void` | `removeFactory(java.lang.String schema)` removes a previously registered factory.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GenericSenderFactory

          public GenericSenderFactory()

  - ### Method Detail

    - #### createPacketSender

          public PacketSender createPacketSender(java.lang.String handler)
                                          throws InvalidSenderException

      returns a new packet sender based on the external address (i.e., handler or url) of the intended receiver.

      This method processes the input handler as follows:

      1. it extracts the schema identifier from the complete handler
      2. it attempts to match the schema with one of Siena's "native" schemas, and to create a corresponding sender
      3. if the given schema does not match any native schema, then this method tries to find a registered factory for that schema
      4. if a matching registered schema is found, the remaining part of the handler (without the ":" character) is passed to the associated factory to create a sender object;
      Specified by:
        `createPacketSender` in interface `PacketSenderFactory`
      Parameters:
        `handler` - receiver's address
      Throws:
        `InvalidSenderException`

    - #### registerFactory

          public static void registerFactory(java.lang.String schema,
                             PacketSenderFactory f)

      extends this factory by registering new packet sender factories. A `GenericSenderFactory` can be extended by registering new `PacketSenderFactory` implementations. Notice that `GenericSenderFactory` will delegate the instantiation of a specific PacketSender to a registered factory by passing it the handler string. See `createPacketSender(String)` for more details on how `GenericSenderFactory` processes handlers.

      Notice that the factory register is static, therefore registration and de-registration will affect every instance of this class.

      Parameters:
        `schema` - schema name
        `f` - schema-specific factory

    - #### removeFactory

          public static void removeFactory(java.lang.String schema)

      removes a previously registered factory.
      See Also:
        `registerFactory(String,PacketSenderFactory)`

Copyright © 2000-2005 University of Colorado.
Copyright © 2005-2011 Antonio Carzaniga.
This documentation is maintained by Antonio Carzaniga