Search in sources :

Example 16 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class StatsProviderManagerDelegateImpl method createTreeForStatsProvider.

private List<String> createTreeForStatsProvider(TreeNode parentNode, Object statsProvider) {
    /* construct monitoring tree at PluginPoint using subTreePath */
    List<String> childNodeNames = new ArrayList();
    /* Check for custom reset method and store for later to be called instead of
         standard reset methods on Statistic classes*/
    for (Method m : statsProvider.getClass().getMethods()) {
        ManagedAttribute ma = m.getAnnotation(ManagedAttribute.class);
        Reset resetMeth = m.getAnnotation(Reset.class);
        if (resetMeth != null) {
            StatsProviderRegistryElement spre = this.statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);
            spre.setResetMethod(m);
        }
        if (ma != null) {
            String methodName = m.getName();
            String id = ma.id();
            if ((id == null) || id.isEmpty()) {
                // if id not specified, derive from method name
                String methodNameLower = methodName.toLowerCase(Locale.ENGLISH);
                if (methodNameLower.startsWith("get") && methodNameLower.length() > 3) {
                    id = methodNameLower.substring(3);
                }
            }
            TreeNode attrNode = TreeNodeFactory.createMethodInvoker(id, statsProvider, id, m);
            parentNode.addChild(attrNode);
            childNodeNames.add(attrNode.getName());
        }
    }
    return childNodeNames;
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode) Method(java.lang.reflect.Method) Reset(org.glassfish.external.statistics.annotations.Reset) StatsProviderRegistryElement(org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement) ManagedAttribute(org.glassfish.gmbal.ManagedAttribute)

Example 17 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class StatsProviderManagerDelegateImpl method constructServerPP.

private TreeNode constructServerPP() {
    TreeNode srvrNode = mrdr.get(instanceName);
    if (srvrNode != null) {
        return srvrNode;
    }
    srvrNode = TreeNodeFactory.createTreeNode(instanceName, null, instanceName);
    srvrNode.setEnabled(false);
    mrdr.add(instanceName, srvrNode);
    return srvrNode;
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode)

Example 18 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class TreeNodeFactory method createMethodInvoker.

public static TreeNode createMethodInvoker(String name, Object instance, String category, Method m) {
    TreeNode tn = new MethodInvokerImpl();
    tn.setName(name);
    ((MethodInvoker) tn).setInstance(instance);
    ((MethodInvoker) tn).setMethod(m);
    tn.setCategory(category);
    tn.setEnabled(true);
    return tn;
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode) MethodInvokerImpl(org.glassfish.flashlight.datatree.impl.MethodInvokerImpl) MethodInvoker(org.glassfish.flashlight.datatree.MethodInvoker)

Example 19 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class TreeNodeFactory method createTreeNode.

public static TreeNode createTreeNode(String name, Object instance, String category) {
    TreeNode tn = new TreeNodeImpl(name, category);
    tn.setEnabled(true);
    return tn;
}
Also used : TreeNodeImpl(org.glassfish.flashlight.datatree.impl.TreeNodeImpl) TreeNode(org.glassfish.flashlight.datatree.TreeNode)

Example 20 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class AbstractTreeNode method getNode.

@Override
public TreeNode getNode(String completeName) {
    if (completeName == null) {
        return null;
    }
    completeName = encodePath(completeName);
    Pattern pattern = Pattern.compile(AbstractTreeNode.REGEX);
    String[] tokens = pattern.split(completeName);
    TreeNode n = findNodeInTree(tokens);
    if (n == null)
        n = findNodeInTreeNormalized(completeName);
    return n;
}
Also used : Pattern(java.util.regex.Pattern) TreeNode(org.glassfish.flashlight.datatree.TreeNode)

Aggregations

TreeNode (org.glassfish.flashlight.datatree.TreeNode)23 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 Pattern (java.util.regex.Pattern)2 StatsProviderRegistryElement (org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement)2 ProbeClientMethodHandle (org.glassfish.flashlight.client.ProbeClientMethodHandle)2 Domain (com.sun.enterprise.config.serverbeans.Domain)1 Server (com.sun.enterprise.config.serverbeans.Server)1 PropertyVetoException (java.beans.PropertyVetoException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Matcher (java.util.regex.Matcher)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 PathSegment (javax.ws.rs.core.PathSegment)1