private ManagedObjectManager registerGmbal(Object statsProvider, String mbeanName) {
   ManagedObjectManager mom = null;
   try {
     // 1 mom per statsProvider
     mom = ManagedObjectManagerFactory.createFederated(MONITORING_SERVER);
     if (mom != null) {
       mom.setJMXRegistrationDebug(false);
       if (mom.isManagedObject(statsProvider)) {
         mom.stripPackagePrefix();
         if (mbeanName != null && !mbeanName.isEmpty()) {
           if (mbeanName.indexOf('\\') > 0) {
             mbeanName = StringUtils.removeChar(mbeanName, '\\');
           }
           mbeanName = mbeanName.replaceAll(SystemPropertyConstants.SLASH, "/");
           mom.createRoot(statsProvider, mbeanName);
         } else {
           mom.createRoot(statsProvider);
         }
       } else {
         String spName = statsProvider.getClass().getName();
         logger.log(Level.INFO, notaManagedObject, new Object[] {spName});
       }
     }
     // To register hierarchy in mom specify parent ManagedObject, and the ManagedObject itself
     // DynamicMBean mbean = (DynamicMBean)mom.register(parent, obj);
   } catch (Exception e) {
     // createRoot failed - need to return a null mom so we know not to unregister an mbean that
     // does not exist
     mom = null;
     logger.log(Level.SEVERE, gmbalRegistrationFailed, e);
   }
   return mom;
 }
예제 #2
0
  private void stripOperandFromArgs() {
    // remove the domain-name operand
    // it may not be here!
    if (args.length < 2 || !StringUtils.ok(serverName)) return;

    int newlen = args.length - 1;

    if (serverName.equals(args[newlen])) {
      String[] newargs = new String[newlen];
      System.arraycopy(args, 0, newargs, 0, newlen);
      args = newargs;
    }
  }
예제 #3
0
  protected void configureContextXmlAttribute(
      WebappClassLoader cloader, File base, DeploymentContext dc)
      throws XMLStreamException, IOException {

    boolean consistent = true;
    Boolean value = null;

    File warContextXml = new File(base.getAbsolutePath(), WAR_CONTEXT_XML);
    if (warContextXml.exists()) {
      ContextXmlParser parser = new ContextXmlParser(warContextXml);
      value = parser.getClearReferencesStatic();
    }

    if (value == null) {
      Boolean domainCRS = null;
      File defaultContextXml = new File(serverEnvironment.getInstanceRoot(), DEFAULT_CONTEXT_XML);
      if (defaultContextXml.exists()) {
        ContextXmlParser parser = new ContextXmlParser(defaultContextXml);
        domainCRS = parser.getClearReferencesStatic();
      }

      List<Boolean> csrs = new ArrayList<Boolean>();
      HttpService httpService = serverConfig.getHttpService();
      DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
      String vsIDs = params.virtualservers;
      List<String> vsList = StringUtils.parseStringList(vsIDs, " ,");
      if (httpService != null && vsList != null && !vsList.isEmpty()) {
        for (VirtualServer vsBean : httpService.getVirtualServer()) {
          if (vsList.contains(vsBean.getId())) {
            Boolean csr = null;
            Property prop = vsBean.getProperty("contextXmlDefault");
            if (prop != null) {
              File contextXml = new File(serverEnvironment.getInstanceRoot(), prop.getValue());
              if (contextXml.exists()) { // vs context.xml
                ContextXmlParser parser = new ContextXmlParser(contextXml);
                csr = parser.getClearReferencesStatic();
              }
            }

            if (csr == null) {
              csr = domainCRS;
            }
            csrs.add(csr);
          }
        }

        // check that it is consistent
        for (Boolean b : csrs) {
          if (b != null) {
            if (value != null && !b.equals(value)) {
              consistent = false;
              break;
            }
            value = b;
          }
        }
      }
    }

    if (consistent) {
      if (value != null) {
        cloader.setClearReferencesStatic(value);
      }
    } else if (logger.isLoggable(Level.WARNING)) {
      logger.log(Level.WARNING, INCONSISTENT_CLEAR_REFERENCE_STATIC);
    }
  }