Class KRHub

java.lang.Object
com.appscend.hub.KRHub
Direct Known Subclasses:
APSMediaPlayer

public class KRHub extends Object
A KRHub object can easily become a container of references to other objects or classes, organized in groups. To be able to register themselves with a KRHub, objects must implement the KRAdapter protocol. Within a single group there can not be more objects that declare the same type.
  • Field Details

  • Constructor Details

    • KRHub

      public KRHub()
  • Method Details

    • adaptersForGroup

      public HashMap<String,Object> adaptersForGroup(String group)
      Returns the list of available registered objects for a specified group.
      Parameters:
      group - The required group.
      Returns:
      A dictionary containing all objects registered for the required group. The dictionary keys are the types, as specified by the objects.
    • registerClassInGroup

      public void registerClassInGroup(Class<?> _class, String group, String type)
      Registers a class to a specific group and a specific type. Upon requesting a new object from this group and type, a new object of the registered class will be instantiated and returned.
      Parameters:
      _class - The class to register.
      group - The group to register the call into.
      type - The type of the registered class.
    • registerClass

      public void registerClass(Class<?> _class, String type)
      Registers a class to the default group, under a specific type. Upon requesting a new object from this type from the default group, a new object of the registered class will be instantiated and returned.
      Parameters:
      _class - The class to register
      type - The type of the registered class.
    • registerAdapterInGroup

      public void registerAdapterInGroup(Object adapter, String group)
      Registers a new adapter to a specific group
      Parameters:
      adapter - The adapter to be registered. The object needs to implement KRAdapter.
      group - The group to register the adapter into.
    • registerAdapter

      public void registerAdapter(Object adapter)
      Registers a new adapter to the default group.
      Parameters:
      adapter - The adapter to be registered. The object needs to implement KRAdapter.
    • adapterForTypeInGroup

      public Object adapterForTypeInGroup(String type, String group)
      Returns an object of the specified type, if such an object is currently registered in the specified group.
      Parameters:
      type - The required object type.
      group - The required group.
      Returns:
      An object if any is registered, null otherwise.
    • adapterForType

      public Object adapterForType(String type)
      Returns an object of the specified type, if such an object is currently registered in the default group.
      Parameters:
      type - The required object type.
      Returns:
      An object if any is registered, null otherwise.