Exemplo n.º 1
0
  /**
   * Builds the context.
   *
   * @param serviceHandler the aoh
   * @param serviceProvider the service provider
   * @param configurations the configurations
   * @return the context
   */
  protected static Context buildContext(
      ServiceHandler serviceHandler, boolean serviceProvider, Configurable... configurations) {

    List<Map<String, Object>> OLArray = new ArrayList<Map<String, Object>>();
    ArrayList<Configurable> cfgInstanceList = new ArrayList<Configurable>();
    for (Configurable config : configurations) {
      try {
        config.setDefinitionManager(serviceHandler.getDefinitionManager());
        // Thực thi các xử lý được chỉ định bởi ATC
        config.initAnnotationConfig();
        cfgInstanceList.add(config);
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      }
      OLArray.add(config.getOptionsList());
    }
    Context result = null;
    if (!serviceProvider) {
      result = new ProviderCoreCreator(serviceHandler, OLArray);
    } else {
      result = new ServiceProviderImpl(serviceHandler, OLArray);
    }
    ((Provider) result).setConfigInstances(cfgInstanceList);
    return result;
  }