Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2011, Red Hat, Inc., and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 
 package org.jboss.as.connector.dynamicresource.descriptionproviders;
 
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ACCESS_TYPE;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ATTRIBUTES;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CHILDREN;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATIONS;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ONLY;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUIRED;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TYPE;
 
 import java.util.List;
 import java.util.Map;
 
org.jboss.as.controller.descriptions.DescriptionProvider or org.jboss.as.controller.descriptions.OverrideDescriptionProvider for a resource whose contents include attributes provided by a list of org.jboss.jca.core.spi.statistics.StatisticsPlugins. Use the org.jboss.as.controller.descriptions.DescriptionProvider API if the resource only includes the statistics attributes; use org.jboss.as.controller.descriptions.OverrideDescriptionProvider if the resource is an override resource that adds resource-specific statistics to a generic resource.

Deprecated:
must be replaced with RD
Author(s):
Brian Stansberry (c) 2011 Red Hat Inc.
 
 public class StatisticsDescriptionProvider implements DescriptionProvider {
 
     private final String bundleName;
     private final String resourceDescriptionKey;
     private final List<StatisticsPluginplugins;

    
Constructor for the org.jboss.as.controller.descriptions.OverrideDescriptionProvider case. Internationalization support is not provided.

Parameters:
plugins the statistics plugins
 
     public StatisticsDescriptionProvider(final StatisticsPlugin... plugins) {
         this(nullnullplugins);
     }

    
Constructor for the org.jboss.as.controller.descriptions.DescriptionProvider case.

Parameters:
bundleName name to pass to java.util.ResourceBundle.getBundle(java.lang.String)
resourceDescriptionKey key to use for looking up the resource's description in the bundle
plugins the statistics plugins
 
     public StatisticsDescriptionProvider(final String bundleNamefinal String resourceDescriptionKeyfinal StatisticsPlugin... plugins) {
         this. = bundleName;
         this. = resourceDescriptionKey;
         this. = Arrays.asList(plugins);
     }
 
     @Override
     public ModelNode getModelDescription(Locale locale) {
         final ResourceBundle bundle = getResourceBundle(locale);
 
         final ModelNode subsystem = new ModelNode();
         subsystem.get().set(bundle.getString());
 
         ModelNode attrs = subsystem.get();
         final Map<StringModelNodeattributeDescriptions = getAttributeOverrideDescriptions(locale);
         for (Map.Entry<StringModelNodeentry : attributeDescriptions.entrySet()) {
             attrs.get(entry.getKey()).set(entry.getValue());
         }
 
         subsystem.get(); // placeholder
        subsystem.get().setEmptyObject(); // no children
        return subsystem;
    }
        Map<StringModelNodeattributes = new HashMap<StringModelNode>();
        for (StatisticsPlugin plugin : ) {
            for (String name : plugin.getNames()) {
                ModelNode node = new ModelNode();
                node.get().set(plugin.getDescription(name));
                ModelType modelType = .;
                if (plugin.getType(name) == int.class) {
                    modelType = .;
                }
                if (plugin.getType(name) == long.class) {
                    modelType = .;
                }
                node.get().set(modelType);
                node.get().set(false);
                node.get().set(true);
                attributes.put(namenode);
            }
        }
        return attributes;
    }
    private ResourceBundle getResourceBundle(Locale locale) {
        if (locale == null) {
            locale = Locale.getDefault();
        }
        return ResourceBundle.getBundle(locale);
    }
New to GrepCode? Check out our FAQ X