Ejemplo n.º 1
0
  @Override
  public void setComponentValue(String name, Object value) {

    if (name.equals("tipiCodeBase")) {
      try {
        tipiCodeBase = (String) value;
        stc.getContext().setTipiResourceLoader(tipiCodeBase);
      } catch (MalformedURLException e) {
        logger.error("Error: ", e);
      }
    }
    if (name.equals("resourceCodeBase")) {
      try {
        resourceCodeBase = (String) value;
        stc.getContext().setGenericResourceLoader(resourceCodeBase);
      } catch (MalformedURLException e) {
        logger.error("Error: ", e);
      }
    }
    if (name.equals("binaryCodeBase")) {
      Binary b = (Binary) value;
      ZipResourceLoader tr;
      try {
        tr = new ZipResourceLoader(b);
        stc.getContext().setTipiResourceLoader(new TmlResourceLoader(tr, "tipi/"));
        stc.getContext().setGenericResourceLoader(new TmlResourceLoader(tr, "resource/"));
      } catch (IOException e) {
        logger.error("Error: ", e);
      }
    }

    super.setComponentValue(name, value);
  }
Ejemplo n.º 2
0
 private void loadNavajo(Navajo n, String method) {
   try {
     stc.getContext().loadNavajo(n.copy(), method);
   } catch (TipiBreakException e) {
     logger.error("Error: ", e);
   }
 }
Ejemplo n.º 3
0
 public void disposeComponent() {
   super.disposeComponent();
   stc.shutDownTipi();
 }
Ejemplo n.º 4
0
 private void parseLocation(String loc, ExtensionDefinition ed) throws IOException, TipiException {
   logger.info("Parsing: " + loc);
   InputStream tipiResourceStream = stc.getContext().getTipiResourceStream(loc);
   stc.getContext().parseStream(tipiResourceStream, ed);
 }
Ejemplo n.º 5
0
  protected void performComponentMethod(
      final String name, final TipiComponentMethod compMeth, TipiEvent event) {
    if ("loadDefinition".equals(name)) {
      try {
        if (resourceCodeBase == null) {
          stc.getContext().setGenericResourceLoader(myContext.getGenericResourceLoader());
        }
        if (tipiCodeBase == null) {
          stc.getContext().setTipiResourceLoader(myContext.getTipiResourceLoader());
        }
        Operand oo = compMeth.getEvaluatedParameter("location", event);
        String loc = (String) oo.value;
        parseLocation(loc, getParentExtension());
      } catch (Exception e) {
        logger.error("Error: ", e);
      }
    }
    if ("switch".equals(name)) {
      try {
        if (resourceCodeBase == null) {
          stc.getContext().setGenericResourceLoader(myContext.getGenericResourceLoader());
        }
        if (tipiCodeBase == null) {
          stc.getContext().setTipiResourceLoader(myContext.getTipiResourceLoader());
        }
        Operand oo = compMeth.getEvaluatedParameter("definition", event);
        String nameVal = (String) oo.value;

        switchToDefinition(nameVal);
      } catch (Exception e) {
        logger.error("Error: ", e);
      }
    }
    if ("addStartupProperty".equals(name)) {
      try {
        Operand nameOperand = compMeth.getEvaluatedParameter("propertyName", event);
        String nameVal = (String) nameOperand.value;
        Operand valueOperand = compMeth.getEvaluatedParameter("value", event);
        String vakueVal = (String) valueOperand.value;
        logger.debug("Adding: " + nameVal + " value: " + vakueVal);
        stc.getContext().setSystemProperty(nameVal, vakueVal);
        // ((Container) getContainer()).add((Component)
        // stc.getContext().getTopLevel(), BorderLayout.CENTER);
      } catch (Exception e) {
        logger.error("Error: ", e);
      }
    }
    if ("loadNavajo".equals(name)) {
      try {
        Operand navajoOperand = compMeth.getEvaluatedParameter("navajo", event);
        Navajo navajo = (Navajo) navajoOperand.value;
        Operand methodOperand = compMeth.getEvaluatedParameter("method", event);
        String method = (String) methodOperand.value;
        loadNavajo(navajo, method);
        // ((Container) getContainer()).add((Component)
        // stc.getContext().getTopLevel(), BorderLayout.CENTER);
      } catch (Exception e) {
        logger.error("Error: ", e);
      }
    }
    if ("loadAllNavajo".equals(name)) {
      try {
        Operand messageOperand = compMeth.getEvaluatedParameter("message", event);
        Message arrayMessage = (Message) messageOperand.value;
        List<Message> elements = arrayMessage.getAllMessages();
        for (int i = 0; i < elements.size(); i++) {
          Message current = elements.get(i);
          Property ob = current.getProperty("Navajo");
          Binary b = (Binary) ob.getTypedValue();
          Navajo n = NavajoFactory.getInstance().createNavajo(b.getDataAsStream());
          loadNavajo(n, n.getHeader().getRPCName());
        }
      } catch (Exception e) {
        logger.error("Error: ", e);
      }
    }
  }