Package de.danet.an.workflow.spis.aii

Examples of de.danet.an.workflow.spis.aii.ToolAgent


                logger.error (e.getMessage(), e);
                throw new IllegalStateException
                    ("Cannot find application class " + agentClassName
                     + " from ApplicationDefinition with Id = " + id + ".");
            }
            agentCache = new ToolAgent () {
                public void invoke
                    (Activity activity,
                     FormalParameter[] formalParameters, Map actualParameters)
                    throws RemoteException, CannotExecuteException {
                    throw new IllegalStateException
                    ("Application class " + agentClassName
                     + " from ApplicationDefinition with Id = " + id
                     + " is not locally available.");
                }

                public void terminate(Activity activity)
                        throws ApplicationNotStoppedException, RemoteException {
                    throw new ApplicationNotStoppedException
                        ("Cannot stop tool agent in other deployment unit.");
                }
            };
            return agentCache;
        }
        try {
      // initialize agent before putting it in cache as we do
      // not synchronize here (and creating the agent twice
      // doesn't really hurt)
      ToolAgent agent = (ToolAgent)appClass.newInstance();
      // set properties
      for (Iterator itr = agentProps.keySet().iterator();
     itr.hasNext();) {
    String param = (String)itr.next();
    Object value = agentProps.get(param);
View Full Code Here


     */
    public InvocationResult invoke
            (ToolAgentContext agentContext,
             de.danet.an.workflow.api.Activity activity, Map params)
  throws ToolInvocationException, RemoteException {
  ToolAgent agent = agent();
  if (agent == null) {
      return null;
  }
  // maybe convert DOM trees
  if (xmlParameterMode == XMLArgumentTypeProvider.XML_AS_W3C_DOM) {
      DOMOutputter domOutputter = new DOMOutputter();
      for (Iterator i = params.keySet().iterator(); i.hasNext();) {
    String pn = (String)i.next();
    Object v = params.get (pn);
    if (v instanceof SAXEventBuffer) {
        try {
      DOMResult domResult = new DOMResult();
      TransformerHandler th = newTransformerHandler();
      th.setResult(domResult);
      convertWithTempRoot(th, (SAXEventBuffer)v);
      org.w3c.dom.Document w3cDoc
          = (org.w3c.dom.Document)domResult.getNode();
      org.w3c.dom.DocumentFragment frag
          = w3cDoc.createDocumentFragment();
      org.w3c.dom.Element w3cTempRoot
          = w3cDoc.getDocumentElement();
      while (true) {
          org.w3c.dom.Node n = w3cTempRoot.getFirstChild();
          if (n == null) {
        break;
          }
          frag.appendChild(n);
      }
      params.put (pn, frag);
        } catch (SAXException e) {
      String m = "Cannot convert JDOM to W3C DOM: "
          + e.getMessage ();
      logger.error (m, e);
      throw new ToolInvocationException (m);
        } catch (TransformerConfigurationException e) {
      String m = "Cannot convert JDOM to W3C DOM: "
          + e.getMessage ();
      logger.error (m, e);
      throw new ToolInvocationException (m);
        }
    }
      }
  } else if (xmlParameterMode == XMLArgumentTypeProvider.XML_AS_JDOM) {
      for (Iterator i = params.keySet().iterator(); i.hasNext();) {
    String pn = (String)i.next();
    Object v = params.get (pn);
    if (v instanceof SAXEventBuffer) {
        try {
      SAXHandler sh = new SAXHandler ();
      convertWithTempRoot(sh, (SAXEventBuffer)v);
      Element temporaryRoot
          = sh.getDocument().getRootElement();
      params.put (pn, temporaryRoot.getChildren());
        } catch (SAXException e) {
      logger.error (e.getMessage(), e);
      throw new ToolInvocationException (e.getMessage());
        }
    }
      }
  }
  // invoke
  if (agent instanceof ContextRequester) {
      ((ContextRequester)agent).setToolAgentContext (agentContext);
  }
  if (logger.isDebugEnabled()) {
      logger.debug ("Invoking " + this.toString()
                    + " with " + formalParameters
                    + " and " + params);
  }
  try {
      agent.invoke(activity, formalParameters, params);
  } catch (CannotExecuteException e) {
      if (logger.isDebugEnabled()) {
          logger.debug ("Invocation resulted in: " + e.toString());
      }
      // try to find mapping
View Full Code Here

TOP

Related Classes of de.danet.an.workflow.spis.aii.ToolAgent

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.