Class OperationAgentManager

java.lang.Object
org.zkoss.zats.mimic.impl.OperationAgentManager

public class OperationAgentManager extends Object

This class maintains a mapping registry between ZK components (in specific version range) and OperationAgentBuilder. It registers all entries in the constructor and retrieve them when ValueResolver requests.

We design the registration mechanism in order to deal with the issue: one component might have different behaviors in different versions. This mechanism has several features: Later registered entry overwrite previous one with the same key. When get OperationAgentBuilder, it will keeping search ZK component's class and its parent class until it finds a match or fails to match.
Author:
pao, dennis
  • Constructor Details

    • OperationAgentManager

      public OperationAgentManager()
  • Method Details

    • getInstance

      public static OperationAgentManager getInstance()
    • registerBuilder

      public <O extends OperationAgent> void registerBuilder(String startVersion, String endVersion, String delegateeClass, String builderClazz)
      Register a operation builder mapping to component and operation. We can specify zk version worked on. The version text could be normal version format (e.g. 6.0.0 or 5.0.7.1) or "*" sign means no specify. If specify version range doesn't include current zk version at runtime, this register will be ignored.

      Use this API if the component is only in a particular zk version only to avoid initial exception.

      Parameters:
      startVersion - start version (include)
      endVersion - end version (include)
      delegateeClass - the component class that builder maps to ( *notice: it should not specify interface)
      builderClazz - operation builder
    • registerBuilder

      public <O extends OperationAgent, C> void registerBuilder(String startVersion, String endVersion, Class<C> delegateeClass, OperationAgentBuilder<? extends Agent,O> builder)
      register a operation builder mapping to component and operation. We can specify zk version worked on. The version text could be normal version format (e.g 6.0.0 or 5.0.7.1) or "*" sign means no specify. If specify version range doesn't include current zk version at runtime, this register will be ignored.
      Parameters:
      startVersion - start version (include)
      endVersion - end version (include)
      delegateeClass - the component class that builder maps to ( *notice: it should not specify interface)
      builder - operation builder
    • getBuilder

      public <O extends OperationAgent> OperationAgentBuilder<Agent,O> getBuilder(Object delegatee, Class<O> operation)
      Return a corresponding OperationAgentBuilder for delegatee supported operation class. It will search in registry with delegatee's class first. If not found, it keeps searching with delegatee's parent class until found or failed.
      Parameters:
      delegatee -
      operation -
      Returns:
      the operation agent builder