Registry
Date: 2013-02-16

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gcube.dir.master.contexts
Class Registry

    java.lang.Object
      org.gcube.dir.master.contexts.Registry

    public class Registry

extends java.lang.Object

Registry of `Prototyped` processors for runtime input binding.

Author:
  Fabio Simeoni (University of Strathclyde)

Nested Class Summary
`static class` | `Registry.ProcessorNotFoundException`

Constructor Summary
`Registry()`

Method Summary
`static
`<PROCESSOR> java.util.List<PROCESSOR>`
` | `findProcessor(java.lang.Class<PROCESSOR> processorClass, java.lang.Object input)` Returns one or more objects of a given type that can process another given object.
`static void` | `registerProcessor(java.lang.Class<? extends Prototyped<?>> processorClass)` Registers a class as a processor for another class, with the implication that instances of the processor class have one or more methods which take instances of the input class as one of their parameters.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Registry

    public Registry()

Method Detail

### registerProcessor

    public static void registerProcessor(java.lang.Class<? extends Prototyped<?>> processorClass)
                                  throws java.lang.Exception

  Registers a class as a processor for another class, with the implication that instances of the processor class have one or more methods which take instances of the input class as one of their parameters.

  The existence of such method or the details of its signature rest with the caller and are neither checked nor of relevance to the registration process. The only requirements for the processor class are: (i) to be reflectively instantiable, and (ii) to implement the `Prototyped` interface and thus return a prototypical example of its input.

  Parameters:
    `processorClass` - the class of a processor which implements the `Prototyped` interface.
  Throws:
    `Registry.ProcessorNotFoundException` - if the processor class cannot be reflectively instantiated.
    `java.lang.Exception`

### findProcessor

    public static <PROCESSOR> java.util.List<PROCESSOR> findProcessor(java.lang.Class<PROCESSOR> processorClass,
                                                                      java.lang.Object input)
                                                   throws Registry.ProcessorNotFoundException,
                                                          java.lang.Exception

  Returns one or more objects of a given type that can process another given object.

  The implication is that each processor object has one or more methods which can take the input object as one of their parameters. The existence of such methods or the details of their signature rest with the caller and are neither checked nor of relevance to the retrieval process.

  The retrieval fails unless: (i) (the class of) each processor has been previously registered with `registerProcessor(Class)`, (ii) the runtime type of its prototypical object is the same type or a supertype of the runtime type of the input object. All the processors which match these conditions are returned in type order, from the most to the least specifically typed. Th If many suitable processors classes have previously registered, one is chosen in order of registration.

  Type Parameters:
    `PROCESSOR` - the type of required processors.
  Parameters:
    `processorClass` - the class of the required processor type.
    `input` - the input object.
  Returns:
    the processors, ordered from the most to the least specific typed.
  Throws:
    `Registry.ProcessorNotFoundException` - if no processor could be found for the input.
    `java.lang.Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD