org.eclnt.jsfserver.managedbean

## Class DefaultDispatcher

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - java.util.HashMap<java.lang.String,java.lang.Object>
    - - org.eclnt.jsfserver.managedbean.DefaultDispatcher

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>, IDispatcher
  Direct Known Subclasses:
    WorkpageDispatcher

      public abstract class DefaultDispatcher
      extends java.util.HashMap<java.lang.String,java.lang.Object>
      implements java.io.Serializable, IDispatcher

  Dispatcher that manages managed beans inside a hash map - so that for each managed bean class exactly one object instance is kept. The following beans are managed:
  (1) Beans, that are resided in the package in which your inheriting class is placed. The access expression for these classes is their class name (without package!).
  (2) Beans, that are registered in the xml registration file. This file has the name "dispatcherinfo.xml" and must be placed in the same directory as the class that inherits from this DefaultDispatcher class.
  (3) Beans, that are explicitly registered by calling the method registerBean.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DefaultDispatcher.DispatchedBeanInfo` Interface from tools (layout editor - bean browser) into the application.
    `static class` | `DefaultDispatcher.DispatcherInfo` Interface from tools (layout editor - bean browser) into the application.

    - ### Nested classes/interfaces inherited from class java.util.AbstractMap

      `java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>`

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `java.util.Map.Entry<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultDispatcher()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addDispatcherExtension(IDispatcherExtension dispatcherExtension)`
    `boolean` | `checkIfDispatchedBeanIsLoaded(java.lang.Class dispatchedBeanClass)`
    `boolean` | `checkIfDispatchedBeanIsLoaded(java.lang.String dispatchedBeanName)`
    `ModalPopup` | `createModalPopup()` Create a modal popup instance within the context of this dispatcher.
    `ModelessPopup` | `createModelessPopup()` Create a modeless popup instance within the context of this dispatcher.
    `protected java.lang.Object` | `createObjectInstance(java.lang.Class resultClass)` After resolving the class for a given name, an object needs to be created for the class.
    `int` | `createSubDispatcherIndex()`
    `IDispatcher` | `createSubDispatcherInstance()` Creates a sub dispatcher instance: the class of the instance is the current class of this instance.
    `IDispatcher` | `createSubDispatcherInstance(java.lang.Class subDispatcherClass)` Creates a sub dispatcher instance of the class that is passed as argument.
    `void` | `destroy()` Destroys the dispatcher and its contained objects.
    `java.lang.Object` | `get(java.lang.Object key)`
    `java.util.List<IDispatcher>` | `getChildDispatchers()` A dispatcher may be hierarchized.
    `java.lang.String` | `getContentReplace()` Returns the content replace statement that is passed to included pages.
    `static IDispatcher` | `getDialogSessionInstance()` Returns the root dispatcher instance within the current dialog session.
    `java.lang.Object` | `getDispatchedBean(java.lang.Class dispatchedBeanClass)` Find managed bean for class.
    `java.lang.Object` | `getDispatchedBean(java.lang.String dispatchedBeanName)` Find managed bean for name.
    `java.lang.String` | `getExpressionBase()` Each dispatcher is the entry point to its managed beans.
    `java.lang.String` | `getMyExpression(java.lang.Class cl)` Returns the expression for the object that is managed inside the dispatcher.
    `java.lang.String` | `getMyExpression(java.lang.Object o)` Returns the expression for the object that is managed inside the dispatcher.
    `IDispatcher` | `getOwner()` Passes back the dispatcher above.
    `protected java.lang.Class` | `getPreferredConstructorArguentClass()` Preferred constructor argument for creation of managed beans.
    `protected java.lang.String` | `getRootExpression()` Override if NOT using "#{d}" as root dispatcher..
    `static DefaultDispatcher.DispatcherInfo` | `getStaticDispatcherInfo()`
    `IDispatcher` | `getTopOwner()` Passes back the top owner of the dispatcher hierarchy.
    `protected void` | `initDispatcher()`
    `protected java.util.List<DefaultDispatcher.DispatchedBeanInfo>` | `initRegisteredBeanInfos(java.util.List<DefaultDispatcher.DispatchedBeanInfo> infos)` This method is called one time during first initialization of the dispatcher.
    `protected java.util.List<java.lang.String>` | `initRegisteredPackages(java.util.List<java.lang.String> packageNames)` This method is called one time during first initialization of the dispatcher.
    `protected void` | `outputLogInfoWhenNoClassWasResolved(java.lang.String key)` The default method `readObject(String)` tries to resolve a class for a key that is passed.
    `protected void` | `prepareObject(java.lang.Object object)` After the creation of the object (default: `readObject(String)` this method is called.
    `protected java.lang.Object` | `readObject(java.lang.String key)` This is the method that is called internally in order to read a dispatched object - which is not in the hashtable of dispatched objects yet.
    `protected void` | `registerSubDispatcherInstance(IDispatcher subDispatcher)`
    `void` | `removeDispatchedBean(java.lang.Class dispatchedBeanClass)` Removes dispatched bean from dispatcher.
    `void` | `removeDispatchedBean(java.lang.String dispatchedBeanName)` Removes dispatched bean from dispatcher.
    `static void` | `removeDispatcherExtension(IDispatcherExtension dispatcherExtension)`
    `java.lang.Class` | `resolveClass(java.lang.String key)` Resolves the class for a binding key.
    `void` | `setOwner(IDispatcher owner)`
    `java.lang.String` | `toString()`
    `void` | `unregisterSubDispatcherInstance(IDispatcher subDispatcher)`
    `java.lang.String` | `updateExpression(java.lang.String expression)` Within the bean processing you may create components in a dynamic way, e.g. using the feature "componentbinding".

    - ### Methods inherited from class java.util.HashMap

      `clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values`

    - ### Methods inherited from class java.util.AbstractMap

      `equals, hashCode`

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

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Map

      `clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values`

- - ### Constructor Detail

    - #### DefaultDispatcher

          public DefaultDispatcher()

  - ### Method Detail

    - #### getDialogSessionInstance

          public static IDispatcher getDialogSessionInstance()

      Returns the root dispatcher instance within the current dialog session. There is one dispatcher within each dialog session.
      This method must only be called within some http session context!

    - #### getRootExpression

          protected java.lang.String getRootExpression()

      Override if NOT using "#{d}" as root dispatcher..

    - #### addDispatcherExtension

          public static void addDispatcherExtension(IDispatcherExtension dispatcherExtension)

    - #### removeDispatcherExtension

          public static void removeDispatcherExtension(IDispatcherExtension dispatcherExtension)

    - #### getStaticDispatcherInfo

          public static DefaultDispatcher.DispatcherInfo getStaticDispatcherInfo()

    - #### createSubDispatcherIndex

          public int createSubDispatcherIndex()

      Specified by:
        `createSubDispatcherIndex` in interface `IDispatcher`

    - #### setOwner

          public void setOwner(IDispatcher owner)

      Specified by:
        `setOwner` in interface `IDispatcher`

    - #### getDispatchedBean

          public java.lang.Object getDispatchedBean(java.lang.String dispatchedBeanName)

      Description copied from interface: `IDispatcher`
      Find managed bean for name. If the bean already exists then the beans is returned. If it does not exist yet then a new instance will be created.
      Specified by:
        `getDispatchedBean` in interface `IDispatcher`
      Parameters:
        `dispatchedBeanName` - Name of the beans - this is the name that is used for binding the bean within the user interface, as well. E.g. if the bean's binding is "#{d.AbcdeUI. ...} then you may access the bean by passing "AbcdeUI".

    - #### removeDispatchedBean

          public void removeDispatchedBean(java.lang.String dispatchedBeanName)

      Description copied from interface: `IDispatcher`
      Removes dispatched bean from dispatcher.
      Specified by:
        `removeDispatchedBean` in interface `IDispatcher`

    - #### get

          public java.lang.Object get(java.lang.Object key)

      Specified by:
        `get` in interface `java.util.Map<java.lang.String,java.lang.Object>`
      Overrides:
        `get` in class `java.util.HashMap<java.lang.String,java.lang.Object>`

    - #### readObject

          protected java.lang.Object readObject(java.lang.String key)
                                         throws java.lang.Exception

      This is the method that is called internally in order to read a dispatched object - which is not in the hashtable of dispatched objects yet. Extensions of DefaultDispatche may override this method and add own ways how to resolve dispatched beans.
      Inside the method first the class is resolved using the method `resolveClass(String)`. Then a "best fitting" constructor is searched and an object is created.
      Throws:
        `java.lang.Exception`

    - #### createObjectInstance

          protected java.lang.Object createObjectInstance(java.lang.Class resultClass)
                                                   throws java.lang.Exception

      After resolving the class for a given name, an object needs to be created for the class. This is done by this method.
      In this implementation first a constructor with a preferred argument (typically the `IDispatcher` or the `IWorkpageDispatcher` instance) is checked. If this does not exsit, then a constructor without parameters is called.
      Throws:
        `java.lang.Exception`

    - #### prepareObject

          protected void prepareObject(java.lang.Object object)

      After the creation of the object (default: `readObject(String)` this method is called. Here you can add own preparation logic.

    - #### outputLogInfoWhenNoClassWasResolved

          protected void outputLogInfoWhenNoClassWasResolved(java.lang.String key)

      The default method `readObject(String)` tries to resolve a class for a key that is passed. If does not find one it throws an error and outputs corresponding log information. The output of log information is done in this method. You may override this method in case you override the readObject-method - sometimes you want to implement your readObject-method in a way that you first want to test if the default object resolution is successful, and only in case of an error perform your own resolution. In this case you do not want the default mechanism to produce huge error log messages.

    - #### resolveClass

          public java.lang.Class resolveClass(java.lang.String key)

      Resolves the class for a binding key. This method may be overridden by implementations of DefaultDispatcher. Returns null if the class cannot be resolved.
      The resolution is done in two ways within this default implementation: (a) the class is resolved in the same package as the dispatcher, (b) the class is resolved using the "dispatcherinfo.xml" file, that needs to be located in the same package as the dispatcher implementation.
      In case of overriding this method you must FIRST resolve the class with your own resolution strategy before calling this implementation.

    - #### checkIfDispatchedBeanIsLoaded

          public boolean checkIfDispatchedBeanIsLoaded(java.lang.Class dispatchedBeanClass)

      Specified by:
        `checkIfDispatchedBeanIsLoaded` in interface `IDispatcher`

    - #### checkIfDispatchedBeanIsLoaded

          public boolean checkIfDispatchedBeanIsLoaded(java.lang.String dispatchedBeanName)

      Specified by:
        `checkIfDispatchedBeanIsLoaded` in interface `IDispatcher`

    - #### getDispatchedBean

          public java.lang.Object getDispatchedBean(java.lang.Class dispatchedBeanClass)

      Description copied from interface: `IDispatcher`
      Find managed bean for class. If the bean already exists then the bean is returned. If it does not exist yet then a new instance will be created.
      Specified by:
        `getDispatchedBean` in interface `IDispatcher`

    - #### removeDispatchedBean

          public void removeDispatchedBean(java.lang.Class dispatchedBeanClass)

      Description copied from interface: `IDispatcher`
      Removes dispatched bean from dispatcher.
      Specified by:
        `removeDispatchedBean` in interface `IDispatcher`

    - #### createSubDispatcherInstance

          public IDispatcher createSubDispatcherInstance()

      Creates a sub dispatcher instance: the class of the instance is the current class of this instance.
      Specified by:
        `createSubDispatcherInstance` in interface `IDispatcher`

    - #### createSubDispatcherInstance

          public IDispatcher createSubDispatcherInstance(java.lang.Class subDispatcherClass)

      Creates a sub dispatcher instance of the class that is passed as argument. The class must provide a constructor without parameters.
      If overriding this class: after creating the instance you need to call the method resgisterSubDispatcherInstance() with passing the newly created dispatcher instance as parameter.

    - #### registerSubDispatcherInstance

          protected void registerSubDispatcherInstance(IDispatcher subDispatcher)

    - #### getExpressionBase

          public java.lang.String getExpressionBase()

      Description copied from interface: `IDispatcher`
      Each dispatcher is the entry point to its managed beans. Dispatchers themselves may be nested. This method returns the expression of this dispatcher instance.
      Specified by:
        `getExpressionBase` in interface `IDispatcher`

    - #### destroy

          public void destroy()

      Description copied from interface: `IDispatcher`
      Destroys the dispatcher and its contained objects.
      Specified by:
        `destroy` in interface `IDispatcher`

    - #### unregisterSubDispatcherInstance

          public void unregisterSubDispatcherInstance(IDispatcher subDispatcher)

      Specified by:
        `unregisterSubDispatcherInstance` in interface `IDispatcher`

    - #### updateExpression

          public java.lang.String updateExpression(java.lang.String expression)

      Description copied from interface: `IDispatcher`
      Within the bean processing you may create components in a dynamic way, e.g. using the feature "componentbinding". When assigning expression to component you need to pay attention that the binding fits to the dispatcher environment in which your bean resides.
      This method builds an expression that is relative to the current dispatcher.
      Specified by:
        `updateExpression` in interface `IDispatcher`
      Parameters:
        `expression` - The normal expression, e.g. "#{d.Car}".
      Returns:
        The relative expression, e.g. "#{d.d_1.Car}".

    - #### getContentReplace

          public java.lang.String getContentReplace()

      Description copied from interface: `IDispatcher`
      Returns the content replace statement that is passed to included pages. Returns a value like "#{d.:#{d.d_1.".
      Specified by:
        `getContentReplace` in interface `IDispatcher`

    - #### getOwner

          public IDispatcher getOwner()

      Description copied from interface: `IDispatcher`
      Passes back the dispatcher above. Null is returned if the current instance is the top dispatcher
      Specified by:
        `getOwner` in interface `IDispatcher`

    - #### getTopOwner

          public IDispatcher getTopOwner()

      Description copied from interface: `IDispatcher`
      Passes back the top owner of the dispatcher hierarchy. If the current dispatcher is the top owner itself, then the current dispatcher is returned.
      Specified by:
        `getTopOwner` in interface `IDispatcher`

    - #### getMyExpression

          public java.lang.String getMyExpression(java.lang.Object o)

      Description copied from interface: `IDispatcher`
      Returns the expression for the object that is managed inside the dispatcher.
      Specified by:
        `getMyExpression` in interface `IDispatcher`
      Returns:
        Expression of object: "#{d.xyz}"

    - #### getMyExpression

          public java.lang.String getMyExpression(java.lang.Class cl)

      Description copied from interface: `IDispatcher`
      Returns the expression for the object that is managed inside the dispatcher.
      Specified by:
        `getMyExpression` in interface `IDispatcher`
      Returns:
        Expression of object: "#{d.xyz}"

    - #### createModalPopup

          public ModalPopup createModalPopup()

      Create a modal popup instance within the context of this dispatcher. The contentdrilldown that you normally have to do when creating a popup is done automatically.
      Specified by:
        `createModalPopup` in interface `IDispatcher`

    - #### createModelessPopup

          public ModelessPopup createModelessPopup()

      Create a modeless popup instance within the context of this dispatcher. The contentdrilldown that you normally have to do when creating a popup is done automatically.
      Specified by:
        `createModelessPopup` in interface `IDispatcher`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.util.AbstractMap<java.lang.String,java.lang.Object>`

    - #### getChildDispatchers

          public java.util.List<IDispatcher> getChildDispatchers()

      A dispatcher may be hierarchized.
      Specified by:
        `getChildDispatchers` in interface `IDispatcher`

    - #### initDispatcher

          protected void initDispatcher()

    - #### initRegisteredPackages

          protected java.util.List<java.lang.String> initRegisteredPackages(java.util.List<java.lang.String> packageNames)

      This method is called one time during first initialization of the dispatcher. The dispatcher has a certain list of packages that it uses for searching for dispatched beans. This list on the one hand includes the dispatcher package itself but also includes additional packages defined in disptacherinfo.xml. You may update this list of packages by overriding this method.
      In the default implementation the packageNames that are passed as parameter are directly passed back. There is no further activity.
      Parameters:
        `packageNames` - List of used packages.
      Returns:
        Updated list of packages to be used.

    - #### initRegisteredBeanInfos

          protected java.util.List<DefaultDispatcher.DispatchedBeanInfo> initRegisteredBeanInfos(java.util.List<DefaultDispatcher.DispatchedBeanInfo> infos)

      This method is called one time during first initialization of the dispatcher. The dispatcher tries to find/create an object for a name. For this reason it allows to specify explicit name=>class definitions, which are typically defined in diespatcherinfo.xml. In this method you receive the list of already defined infos and can update the list.
      In the default implementation the infos are directly returned. There is no further activity.
      Parameters:
        `infos` - List of dispatched bean infos.
      Returns:
        Updated list of dispatched bean infos to be used.

    - #### getPreferredConstructorArguentClass

          protected java.lang.Class getPreferredConstructorArguentClass()

      Preferred constructor argument for creation of managed beans. To be overridden by subclasses.

Copyright © CaptainCasa Gmbh. All Rights Reserved.