Package com.esri.gpt.control.webharvest.protocol

Examples of com.esri.gpt.control.webharvest.protocol.ProtocolFactories


/**
* Loads protocol factories.
* @param appConfig protocol factories
*/
private void loadProtocolFactories(ApplicationConfiguration appConfig, Document dom, Node root) throws XPathExpressionException {
  ProtocolFactories factories = appConfig.getProtocolFactories();
  XPath xpath = XPathFactory.newInstance().newXPath();

  Node ndProtocols = (Node) xpath.evaluate("protocols", root, XPathConstants.NODE);
  if (ndProtocols!=null) {
    // check 'default' attribute of the 'protcols' node; if present and true than initialize default factories
    boolean defaultValue = Val.chkBool((String) xpath.evaluate("@default", ndProtocols, XPathConstants.STRING),false);
    if (defaultValue) {
        factories.initDefault();
    }
   
    // initilaize explicit protocol factories
    NodeList lstProtocol = (NodeList) xpath.evaluate("protocol", ndProtocols, XPathConstants.NODESET);
    for (Node ndProto : new NodeListAdapter(lstProtocol)) {
      String factoryClass = (String) xpath.evaluate("@factoryClass", ndProto, XPathConstants.STRING);
      try {
        Class fc = Class.forName(factoryClass);
        ProtocolFactory factory = (ProtocolFactory) fc.newInstance();
        ProtocolInitializer.init(factory, ndProto);
        String resourceKey = Val.chkStr((String) xpath.evaluate("@resourceKey", ndProto, XPathConstants.STRING));
        factories.put(factory.getName(), factory, resourceKey);
      } catch (Exception ex) {
        getLogger().log(Level.WARNING, "Error loading protocol: "+factoryClass, ex);
      }
     
      String validatorFactoryClass = Val.chkStr((String) xpath.evaluate("validator/@factoryClass", ndProto, XPathConstants.STRING));
      if (!validatorFactoryClass.isEmpty()) {
        try {
          Class fc = Class.forName(validatorFactoryClass);
          IValidatorFactory factory = (IValidatorFactory) fc.newInstance();
          ValidatorFactory.register(factory);
        } catch (Exception ex) {
          getLogger().log(Level.WARNING, "Error loading protocol validator factory: "+validatorFactoryClass, ex);
        }
      }
    }
  } else {
    factories.initDefault();
  }
}
View Full Code Here


public ArrayList<SelectItem> getProtocols() {
  ArrayList<SelectItem> protocols = new ArrayList<SelectItem>();
  MessageBroker msgBroker = getContextBroker().extractMessageBroker();
  ApplicationContext appCtx = ApplicationContext.getInstance();
  ApplicationConfiguration appCfg = appCtx.getConfiguration();
  ProtocolFactories protocolFactories = appCfg.getProtocolFactories();
  protocols.add(new SelectItem("", msgBroker.retrieveMessage("catalog.harvest.manage.edit.protocol.any")));
  for (String key: protocolFactories.getKeys()) {
    ProtocolFactory pf = protocolFactories.get(key);
    if (pf instanceof AgpProtocolFactory && !AGSProcessorConfig.isAvailable()) continue;
    String resourceKey = protocolFactories.getResourceKey(key);
    SelectItem item = new SelectItem(key.toLowerCase(), msgBroker.retrieveMessage(resourceKey));
    protocols.add(item);
  }
  return protocols;
}
View Full Code Here

/**
* Sets protocol factories.
* @param protocolFactories protocol factories
*/
public void setProtocolFactories(ProtocolFactories protocolFactories) {
  this._protocolFactories = protocolFactories!=null? protocolFactories: new ProtocolFactories();
}
View Full Code Here

  public ArrayList<SelectItem> getProtocols() {
    ArrayList<SelectItem> protocols = new ArrayList<SelectItem>();
    MessageBroker msgBroker = getContextBroker().extractMessageBroker();
    ApplicationContext appCtx = ApplicationContext.getInstance();
    ApplicationConfiguration appCfg = appCtx.getConfiguration();
    ProtocolFactories protocolFactories = appCfg.getProtocolFactories();
    for (String key : protocolFactories.getKeys()) {
      ProtocolFactory pf = protocolFactories.get(key);
      if (pf instanceof AgpProtocolFactory && !AGSProcessorConfig.isAvailable()) {
        continue;
      }
      String resourceKey = protocolFactories.getResourceKey(key);
      SelectItem item = new SelectItem(key.toLowerCase(), msgBroker.retrieveMessage(resourceKey));
      protocols.add(item);
    }
    return protocols;
  }
View Full Code Here

TOP

Related Classes of com.esri.gpt.control.webharvest.protocol.ProtocolFactories

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.