Ejemplo n.º 1
0
 /**
  * Requests transaction with specified {@link JtxTransactionMode mode}. Depending on propagation
  * behavior, it will return either <b>existing</b> or <b>new</b> transaction. Only one transaction
  * can be opened over one scope. The exception may be thrown indicating propagation mismatch.
  */
 public JtxTransaction requestTransaction(JtxTransactionMode mode, Object scope) {
   if (log.isDebugEnabled()) {
     log.debug("Requesting TX " + mode.toString());
   }
   JtxTransaction currentTx = getTransaction();
   if (isNewTxScope(currentTx, scope) == false) {
     return currentTx;
   }
   switch (mode.getPropagationBehavior()) {
     case PROPAGATION_REQUIRED:
       return propRequired(currentTx, mode, scope);
     case PROPAGATION_SUPPORTS:
       return propSupports(currentTx, mode, scope);
     case PROPAGATION_MANDATORY:
       return propMandatory(currentTx, mode, scope);
     case PROPAGATION_REQUIRES_NEW:
       return propRequiresNew(currentTx, mode, scope);
     case PROPAGATION_NOT_SUPPORTED:
       return propNotSupported(currentTx, mode, scope);
     case PROPAGATION_NEVER:
       return propNever(currentTx, mode, scope);
   }
   throw new JtxException(
       "Invalid TX propagation value: " + mode.getPropagationBehavior().value());
 }
Ejemplo n.º 2
0
  /** Creates new Petite container using {@link PetiteContainer provided configuration}. */
  public PetiteContainer(PetiteConfig config) {
    super(config);

    if (JoddPetite.useProxetta) {
      scopedProxyManager = new ScopedProxyManager();
    } else {
      scopedProxyManager = null;
    }

    if (log.isDebugEnabled()) {
      log.debug("Petite container created");

      if (JoddPetite.useProxetta) {
        log.debug("Petite proxy features enabled");
      } else {
        log.debug("Petite proxy features not available");
      }
    }
  }
Ejemplo n.º 3
0
  /** Returns method parameter names. */
  public String[] resolveParamNames(Method actionClassMethod) {
    String[] names;

    if (!JoddMadvoc.useProxetta) {
      if (log.isWarnEnabled()) {
        log.warn(
            "Unable to resolve method names, using type short names instead. Add Proxetta to resolve this.");
      }

      names = convertTypeNames(actionClassMethod);
    } else {
      MethodParameter[] methodParameters = Paramo.resolveParameters(actionClassMethod);
      names = new String[methodParameters.length];

      for (int i = 0; i < methodParameters.length; i++) {
        names[i] = methodParameters[i].getName();
      }
    }

    return names;
  }
Ejemplo n.º 4
0
  private void loadDatatablesXml() {
    String xmlPath = AliceHelper.getInstance().getJoddProps().getValue("datatables.xml.path");
    SAXReader reader = new SAXReader();
    Document document;
    try {
      InputStream in = this.getClass().getResourceAsStream(xmlPath);
      document = reader.read(in);
    } catch (Exception e) {
      LOGGER.error("**** DatatablesHelper -> loadDatatablesXml fail! ****", e);
      return;
    }

    /* reset */
    datatablesMap = new HashMap<String, Datatable>();
    globalValueMap = new HashMap<String, String>();
    languageMap = new HashMap<String, Object>();

    Element root = document.getRootElement();
    for (Iterator iterA = root.elementIterator(); iterA.hasNext(); ) {
      // 获取节点 version/globalValue/datatables
      Element elementA = (Element) iterA.next();
      if (elementA != null && elementA.hasContent()) {
        if ("datatables".equals(elementA.getName())) {
          // 获取节点 datatable
          for (Iterator iterB = elementA.elementIterator(); iterB.hasNext(); ) {
            Element elementB = (Element) iterB.next();
            if (elementB != null && "datatable".equals(elementB.getName())) {
              Attribute attrB_id = elementB.attribute("id");
              Attribute attrB_name = elementB.attribute("name");

              // create datatable
              Datatable datatable = new Datatable(attrB_id.getText(), attrB_name.getText());

              if (elementB.hasContent()) {
                // 获取节点 property
                for (Iterator iterC = elementB.elementIterator(); iterC.hasNext(); ) {
                  Element elementC = (Element) iterC.next();
                  if (elementC != null && "property".equals(elementC.getName())) {

                    Attribute attrC_name = elementC.attribute("name");
                    Attribute attrC_value = elementC.attribute("value");
                    Attribute attrC_url = elementC.attribute("isURL");

                    if (attrC_url != null && "true".equals(attrC_url.getText())) {
                      datatable.setProperty(
                          attrC_name.getText(),
                          BaseFunctions.getBasePath() + attrC_value.getText());
                    } else {
                      datatable.setProperty(attrC_name.getText(), attrC_value.getText());
                    }
                  }
                } // property end
              }
              datatablesMap.put(datatable.getId(), datatable);
            }
          } // datatable end
        } // datatables end
        else if ("language".equals(elementA.getName())) {
          // 获取节点 item
          for (Iterator iterB = elementA.elementIterator(); iterB.hasNext(); ) {
            Element elementB = (Element) iterB.next();
            if (elementB != null) {
              if ("item".equals(elementB.getName())) {
                addItemElementForMap(elementB, languageMap);
              } else if ("paginate".equals(elementB.getName())) {
                Map<String, Item> paginateMap = new HashMap<String, Item>();
                for (Iterator iterC = elementB.elementIterator(); iterC.hasNext(); ) {
                  Element elementC = (Element) iterC.next();
                  if (elementC != null && "item".equals(elementC.getName())) {
                    addItemElementForMap(elementC, paginateMap);
                  }
                }
                languageMap.put("paginateHM", paginateMap);
              }
            }
          } // item end
        }
      } else {
        if (elementA != null) {
          if ("version".equals(elementA.getName())) {
            this.version = elementA.attribute("value").getText();
          } else if ("globalValue".equals(elementA.getName())) {
            addGlobalValueForMap(elementA, globalValueMap);
          }
        }
      }
    }
  }