当前位置: 首页>>代码示例>>Java>>正文


Java RoleList.add方法代码示例

本文整理汇总了Java中javax.management.relation.RoleList.add方法的典型用法代码示例。如果您正苦于以下问题:Java RoleList.add方法的具体用法?Java RoleList.add怎么用?Java RoleList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.relation.RoleList的用法示例。


在下文中一共展示了RoleList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNotWritable

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testNotWritable() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        server.registerMBean(new Unit(), unitName);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        /* Role is not readable */
        RoleInfo[] rInfo = { new RoleInfo("role", classPath, true, false) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));

        try {
            rService.createRelation("relation", "relationType", unitRoles);
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:25,代码来源:StructureTest.java

示例2: testNotRegisteredException

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testNotRegisteredException() throws Exception {

        /* Initialisation without registering */
        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        server.registerMBean(new Unit(), unitName);

        RelationService rService = new RelationService(true);
        RoleInfo[] rInfo = { new RoleInfo("role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));

        /* catch RelationServiceNotRegisteredException */
        try {
            rService.createRelation("relation", "relationType", unitRoles);
            return failed("");
        } catch (RelationServiceNotRegisteredException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:StructureTest.java

示例3: testNullRelationName

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testNullRelationName() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        server.registerMBean(new Unit(), unitName);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleInfo[] rInfo = { new RoleInfo("role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));

        /* set null relation name */
        try {
            rService.createRelation(null, "relationType", unitRoles);
            return failed("");
        } catch (IllegalArgumentException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:27,代码来源:StructureTest.java

示例4: testNullRelationType

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testNullRelationType() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        server.registerMBean(new Unit(), unitName);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleList unitRoles = new RoleList();
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));

        /* set null relation type */
        try {
            rService.createRelation("relation", null, unitRoles);
            return failed("");
        } catch (IllegalArgumentException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:24,代码来源:StructureTest.java

示例5: testUnknownRelationType

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testUnknownRelationType() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        server.registerMBean(new Unit(), unitName);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleList unitRoles = new RoleList();
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));

        /* Try to create relation with unknown relation type */
        try {
            rService.createRelation("relation", "relationType", unitRoles);
            return failed("");
        } catch (RelationTypeNotFoundException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:24,代码来源:StructureTest.java

示例6: testNumberOfMBeanLessThanNeed

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testNumberOfMBeanLessThanNeed() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        server.registerMBean(new Unit(), unitName);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleInfo[] rInfo = { new RoleInfo("role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        /* The Number of MBeans is less than default (1) */
        unitRoles.add(new Role("role", new ArrayList()));
        try {
            rService.createRelation("relation", "relationType", unitRoles);
            return failed("");
        } catch (InvalidRoleValueException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:StructureTest.java

示例7: testMBeanNotRegistered

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testMBeanNotRegistered() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleInfo[] rInfo = { new RoleInfo("role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();

        /* Referenced MBean hasn't registered */
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));

        try {
            rService.createRelation("relation", "relationType", unitRoles);
            return failed("");
        } catch (InvalidRoleValueException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:27,代码来源:StructureTest.java

示例8: testIdAlreadyUsed

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testIdAlreadyUsed() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        server.registerMBean(new Unit(), unitName);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleInfo[] rInfo = { new RoleInfo("role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));

        rService.createRelation("relation", "relationType", unitRoles);

        /* now try to create another relation with the same name */
        /* create another relation type for clearance */
        rService.createRelationType("another relationType", rInfo);

        try {
            rService.createRelation("relation", "another relationType",
                    unitRoles);
            return failed("");
        } catch (InvalidRelationIdException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:33,代码来源:StructureTest.java

示例9: testTheSameRoleName

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testTheSameRoleName() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        ObjectName unitName2 = new ObjectName("a:b=c2");
        server.registerMBean(new Unit(), unitName);
        server.registerMBean(new Unit(), unitName2);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleInfo[] rInfo = { new RoleInfo("role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();

        /* Add 2 roles with the same name */
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));
        unitRoles.add(new Role("role", Collections.singletonList(unitName2)));

        try {
            rService.createRelation("relation", "relationType", unitRoles);
            return failed("");
        } catch (InvalidRoleValueException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:31,代码来源:StructureTest.java

示例10: testNumberOfMBeanMoreThanNeed

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testNumberOfMBeanMoreThanNeed() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        ObjectName unitName2 = new ObjectName("a:b=c2");
        server.registerMBean(new Unit(), unitName);
        server.registerMBean(new Unit(), unitName2);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleInfo[] rInfo = { new RoleInfo("role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        /* The Number of MBeans is more than default (1) */
        ArrayList units = new ArrayList();
        units.add(unitName);
        units.add(unitName2);

        unitRoles.add(new Role("role", units));

        try {
            rService.createRelation("relation", "relationType", unitRoles);
            return failed("");
        } catch (InvalidRoleValueException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:33,代码来源:StructureTest.java

示例11: testDifferentTypeMBean

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testDifferentTypeMBean() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        /* MBean class is NotUnit */
        server.registerMBean(new NotUnit(), unitName);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleInfo[] rInfo = { new RoleInfo("role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();

        /* Referenced MBean hasn't registered */
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));

        try {
            rService.createRelation("relation", "relationType", unitRoles);
            return failed("");
        } catch (InvalidRoleValueException e) {
            return passed();
        } catch (Throwable t) {
            return failed(t.toString());
        }
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:29,代码来源:StructureTest.java

示例12: testExistenceAfterException

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testExistenceAfterException() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName unitName = new ObjectName("a:b=c");
        server.registerMBean(new Unit(), unitName);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        RoleInfo[] rInfo = { new RoleInfo("role", classPath),
                new RoleInfo("another role", classPath) };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        /*
         * "anotherRole is incorrect - the number of MBeans is less than
         * default"
         */
        unitRoles.add(new Role("role", Collections.singletonList(unitName)));
        unitRoles.add(new Role("another role", new ArrayList()));

        try {
            rService.createRelation("relation", "relationType", unitRoles);
            System.out.println("existenceAfterExceptions test failed");
        } catch (InvalidRoleValueException e) {
            /* this exception should be caught */
        } catch (Throwable t) {
            System.out.println("existenceAfterExceptions test failed: "
                    + t.toString());
        }

        /* now verify is relation exists */
        if (!rService.getAllRelationIds().contains("relation")) {
            return passed();
        }
        return failed("");
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:39,代码来源:StructureTest.java

示例13: testPurgeRemoves

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testPurgeRemoves() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName[] unitNames = { new ObjectName("a:b=c"),
                new ObjectName("a:b=c2") };

        server.registerMBean(new Unit(), unitNames[0]);
        server.registerMBean(new Unit(), unitNames[1]);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        /* This role remains after unregister one of unit */
        RoleInfo[] rInfo = { new RoleInfo("role", classPath, true, true, 2, 2,
                "role") };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        Role role = new Role("role", Arrays.asList(unitNames));
        unitRoles.add(role);

        rService.createRelation("relation", "relationType", unitRoles);

        /* now remove one of MBeans */
        server.unregisterMBean(unitNames[0]);

        /* verify relation is exist */
        if (rService.getAllRelationIds().contains("relation")) {
            return failed("");
        }
        return passed();
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:34,代码来源:StructureTest.java

示例14: testPurgeRemains

import javax.management.relation.RoleList; //导入方法依赖的package包/类
public Result testPurgeRemains() throws Exception {

        MBeanServer server = MBeanServerFactory.createMBeanServer();

        ObjectName[] unitNames = { new ObjectName("a:b=c"),
                new ObjectName("a:b=c2") };

        server.registerMBean(new Unit(), unitNames[0]);
        server.registerMBean(new Unit(), unitNames[1]);

        RelationService rService = new RelationService(true);
        server.registerMBean(rService, new ObjectName("a:b=d"));

        /* This role remains after unregister one of unit */
        RoleInfo[] rInfo = { new RoleInfo("role", classPath, true, true, 1, 2,
                "role") };
        rService.createRelationType("relationType", rInfo);

        RoleList unitRoles = new RoleList();
        Role role = new Role("role", Arrays.asList(unitNames));
        unitRoles.add(role);

        rService.createRelation("relation", "relationType", unitRoles);

        /* now remove one of MBeans */
        server.unregisterMBean(unitNames[0]);

        /* verify relation is exist */
        if (!rService.getAllRelationIds().contains("relation")) {
            return failed("");
        }
        return passed();
    }
 
开发者ID:freeVM,项目名称:freeVM,代码行数:34,代码来源:StructureTest.java

示例15: testRemovalNotification

import javax.management.relation.RoleList; //导入方法依赖的package包/类
/**
 * This testcase verifies MBeanToUnregister field in notifications.
 */

public Result testRemovalNotification() throws Exception {

    incorrectNotificationFlag = false;

    MBeanServer mBeanServer = MBeanServerFactory.createMBeanServer();

    RelationService relationService = new RelationService(true);
    ObjectName relationServiceName = new ObjectName(
            "mBeanServer:type=RelationService,name=rs");
    mBeanServer.registerMBean(relationService, relationServiceName);

    NotificationFilterSupport filter = new NotificationFilterSupport();
    filter.enableType("jmx.relation");
    relationService.addNotificationListener(this, filter, null);
    checkNotifications = true;

    RoleInfo[] roleInfo = new RoleInfo[1];
    roleInfo[0] = new RoleInfo("unitRole", classPath, true, true, 1, 2,
            "Unit role");

    // Creating an Internal Relation Type
    relationService.createRelationType("internalRelationType", roleInfo);

    UnitMBean unit = new Unit();
    ObjectName unitName = new ObjectName("mBeanServer:type=Unit,name=Unit");
    mBeanServer.registerMBean(unit, unitName);

    ArrayList unitList = new ArrayList();
    unitList.add(unitName);

    Role unitRole = new Role("unitRole", unitList);
    RoleList unitRoles = new RoleList();
    unitRoles.add(unitRole);

    // Now Create relations between unit MBeans

    // Notification Data
    relationNotification = new RelationNotificationForCompare(
            "jmx.relation.creation.basic", relationService, 1, 10,
            "Creation of relation internalRelation", "internalRelation",
            "internalRelationType", null, null);

    relationService.createRelation("internalRelation",
            "internalRelationType", unitRoles);

    // Notification Data
    relationNotification = new RelationNotificationForCompare(
            "jmx.relation.removal.basic", relationService, 2, 10,
            "Removal of relation internalRelation", "internalRelation",
            "internalRelationType", null, new ArrayList());

    relationService.removeRelation("internalRelation");

    if (incorrectNotificationFlag) {
        return failed("IncorrectNotifications (see log for more information)");
    }
    return passed();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:63,代码来源:StructureTest.java


注:本文中的javax.management.relation.RoleList.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。