コード例 #1
0
ファイル: Util.java プロジェクト: JSansalone/NetBeansIDE
  /**
   * It only returns string representation of the ModuleType (accorded to the JBoss JMX
   * requirements)
   *
   * @return string representation of the ModuleType
   */
  public static String getModuleTypeString(ModuleType mt) {
    if (mt.equals(ModuleType.EAR)) return "J2EEApplication";
    else if (mt.equals(ModuleType.WAR)) return "WebModule";
    else if (mt.equals(ModuleType.EJB)) return "EJBModule";

    return "undefined";
  }
コード例 #2
0
  @Override
  public TargetModuleID[] getAvailableModules(ModuleType filterType) throws TargetException {
    try {
      List<TargetModuleID> list = new ArrayList<TargetModuleID>();

      final ModelNode operation = new ModelNode();
      operation.get(OP).set(READ_CHILDREN_NAMES_OPERATION);
      operation.get(CHILD_TYPE).set(DEPLOYMENT);
      ModelNode result = modelControllerClient.execute(operation);
      if (FAILED.equals(result.get(OUTCOME).asString()))
        throw new IllegalStateException(MESSAGES.managementRequestFailed(result));

      List<ModelNode> nodeList = result.get(RESULT).asList();
      for (ModelNode node : nodeList) {
        String moduleID = node.asString();
        ModuleType moduleType = null;
        if (moduleID.endsWith(".ear")) {
          moduleType = ModuleType.EAR;
        } else if (moduleID.endsWith(".war")) {
          moduleType = ModuleType.WAR;
        } else if (moduleID.endsWith(".rar")) {
          moduleType = ModuleType.RAR;
        } else if (moduleID.endsWith(".jar")) {
          // [TODO] not every jar is also an ejb jar
          moduleType = ModuleType.EJB;
        }
        if (moduleType == null) {
          ROOT_LOGGER.cannotDetermineModuleType(node);
          continue;
        }
        if (filterType == null || filterType.equals(moduleType)) {
          TargetModuleIDImpl targetModuleID =
              new TargetModuleIDImpl(this, moduleID, null, moduleType);
          Boolean state = runtimeState.get(targetModuleID);
          targetModuleID.setRunning(state != null ? state : Boolean.TRUE);
          list.add(targetModuleID);
        }
      }
      TargetModuleID[] targetModuleIDs = new TargetModuleID[list.size()];
      list.toArray(targetModuleIDs);
      return targetModuleIDs;
    } catch (Exception e) {
      TargetException tex = new TargetException("Failed to get available modules");
      tex.initCause(e);
      throw tex;
    }
  }