Interface IsSingleton

  • All Known Subinterfaces:
    ApiEndpoint, AsyncEndpoint, AsyncProducer, BrowsableEndpoint, DelegateEndpoint, Endpoint, InterceptSendToEndpoint, Producer

    public interface IsSingleton
    Used for defining if a given class is singleton or not. If the class is a singleton, then a single instance will be shared (and hence should be treated as immutable and be used in a thread-safe manner).

    This interface is not implemented as a marker interface (i.e., it's necessary to read isSingleton() instead of instanceof(IsSingleton)). This allows for subclasses to have a singleton status different from a parent and for objects to have this value dynamically changed.

    Camel component are very often singleton based, only a few components are not.

    • Method Detail

      • test

        static boolean test​(Object instance)
        Test if the given instance is a singleton or not.
        Parameters:
        instance - the instance ot check
        Returns:
        true if the given instance is a singleton
      • isSingleton

        boolean isSingleton()
        Whether this class supports being singleton or not.
        Returns:
        true to be a singleton shared instance, false to create new instances.