Example usage for javax.management.openmbean ArrayType ArrayType

List of usage examples for javax.management.openmbean ArrayType ArrayType

Introduction

In this page you can find the example usage for javax.management.openmbean ArrayType ArrayType.

Prototype

public ArrayType(SimpleType<?> elementType, boolean primitiveArray) throws OpenDataException 

Source Link

Document

Constructs a unidimensional ArrayType instance for the supplied SimpleType .

Usage

From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java

@Test
public void arrayType() throws OpenDataException, ParseException {
    ArrayType type = new ArrayType(2, STRING);
    String json = "[ \"hello\", \"world\" ]";
    for (Object element : new Object[] { json, new JSONParser().parse(json) }) {
        Object[] data = (Object[]) converter.convertToObject(type, element);
        assertEquals(data.length, 2);//w w w .  j  a  va 2  s.c  o  m
        assertEquals(data[0], "hello");
        assertEquals(data[1], "world");
    }
}

From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*JSONArray.*")
public void arrayTypeWithWrongJson() throws OpenDataException {
    converter.convertToObject(new ArrayType(2, STRING), "{ \"hello\": \"world\"}");
}

From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java

@Test
public void arrayTypeWithCompositeElementType() throws OpenDataException {
    CompositeTypeAndJson taj = new CompositeTypeAndJson(STRING, "verein", "FCN"

    );//from w ww .  j  a  v  a2s  .  com
    CompositeData[] result = (CompositeData[]) converter.convertToObject(new ArrayType(2, taj.getType()),
            "[" + taj.getJsonAsString() + "]");
    assertEquals(result[0].get("verein"), "FCN");
    assertEquals(result.length, 1);
}

From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java

@Test(expectedExceptions = UnsupportedOperationException.class, expectedExceptionsMessageRegExp = ".*Unsupported.*")
public void arrayTypeWithWrongElementType() throws OpenDataException {
    TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "verein" },
            new CompositeTypeAndJson(STRING, "verein", "fcn", BOOLEAN, "absteiger", false));
    JSONArray array = new JSONArray();
    array.add(taj.getJson());/*from   www  .jav a2 s  .c  o  m*/
    converter.convertToObject(new ArrayType(2, taj.getType()), array);
}

From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java

/***
 * Virtual host information are needed in the constructor to evaluate user permissions for
 * queue management actions.(e.g. purge)
 *
 * @param vHostMBean Used to access the virtual host information
 * @throws NotCompliantMBeanException/*from w  ww .j  av  a 2  s  . c  om*/
 */
public QueueManagementInformationMBean(VirtualHostImpl.VirtualHostMBean vHostMBean)
        throws NotCompliantMBeanException, OpenDataException {
    super(QueueManagementInformation.class, QueueManagementInformation.TYPE);

    andesChannel = Andes.getInstance().createChannel(new FlowControlListener() {
        @Override
        public void block() {
            restoreBlockedByFlowControl = true;
        }

        @Override
        public void unblock() {
            restoreBlockedByFlowControl = false;
        }

        @Override
        public void disconnect() {
            // Do nothing. since its not applicable.
        }
    });

    VirtualHost virtualHost = vHostMBean.getVirtualHost();

    queueRegistry = virtualHost.getQueueRegistry();
    disablePubAck = new DisablePubAckImpl();

    _msgContentAttributeTypes[0] = SimpleType.STRING; // For message properties
    _msgContentAttributeTypes[1] = SimpleType.STRING; // For content type
    _msgContentAttributeTypes[2] = new ArrayType(1, SimpleType.STRING); // For message content
    _msgContentAttributeTypes[3] = SimpleType.STRING; // For JMS message id
    _msgContentAttributeTypes[4] = SimpleType.BOOLEAN; // For redelivered
    _msgContentAttributeTypes[5] = SimpleType.LONG; // For JMS timeStamp
    _msgContentAttributeTypes[6] = SimpleType.STRING; // For dlc message destination
    _msgContentAttributeTypes[7] = SimpleType.LONG; // For andes message metadata id
    _msgContentType = new CompositeType("Message Content", "Message content for queue browse",
            VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC
                    .toArray(new String[VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.size()]),
            VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.toArray(
                    new String[VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.size()]),
            _msgContentAttributeTypes);
    lz4CompressionHelper = new LZ4CompressionHelper();
}

From source file:com.alibaba.dragoon.stat.WebURIStatistic.java

public static CompositeType getCompositeType() throws JMException {

    OpenType<?>[] indexTypes = new OpenType<?>[] {
            ///*from   www .  j  a  v  a2s. c  o  m*/
            SimpleType.LONG, SimpleType.STRING, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.LONG, // count
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, // LastErrorClass
            SimpleType.STRING, SimpleType.DATE, SimpleType.STRING, SimpleType.DATE, SimpleType.STRING // LastErrorUser
            , SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, // LastErrorUser
            SimpleType.LONG, new ArrayType<Long>(SimpleType.LONG, true),
            new ArrayType<CompositeType>(1, Profiler.EntryStatistic.getCompositeType())//
            , SimpleType.STRING //
            //
            , SimpleType.LONG, SimpleType.LONG, SimpleType.LONG//
            //
            , SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
            , SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG//
            , SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
            , new ArrayType<Integer>(SimpleType.INTEGER, true), SimpleType.LONG };

    String[] indexNames = { //
            //
            "ID", "URI", "RunningCount", "ConcurrentMax", "Count", //
            "ErrorCount", "TotalTime", "MaxTime", "LastErrorMessage", "LastErrorClass" //
            , "LastErrorStackTrace", "LastErrorTime", "LastErrorReferer", "LastAccessedTime", "LastErrorUser" //
            , "JdbcExecuteCount", "JdbcFetchRowCount", "JdbcFetchRowPeak", "JdbcUpdateCount", "JdbcCommitCount" //
            , "JdbcRollbackCount", "Histogram", "ProfileEntries", "LastErrorUrl" // added by wangye

            , "OSMacOSXCount", "OSWindowsCount", "OSLinuxCount", "BrowserIE6Count", "BrowserIE7Count",
            "BrowserIE8Count", "BrowserIE9Count", "BrowserIE10Count", "BrowserIECount", "BrowserFirefoxCount",
            "BrowserChromeCount", "BrowserSafariCount", "BrowserOperaCount", "DeviceAndroidCount",
            "DeviceIpadCount", "DeviceIphoneCount", "DeviceWindowsPhoneCount" //
            , "IP", "JdbcTransactionMillis" };
    String[] indexDescriptions = indexNames;
    return new CompositeType("URIStatistic", "URI Statistic", indexNames, indexDescriptions, indexTypes);
}