本文整理汇总了Java中javax.management.relation.RoleInfo类的典型用法代码示例。如果您正苦于以下问题:Java RoleInfo类的具体用法?Java RoleInfo怎么用?Java RoleInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RoleInfo类属于javax.management.relation包,在下文中一共展示了RoleInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNotWritable
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例2: testNotRegisteredException
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例3: testNullRelationName
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例4: testNumberOfMBeanLessThanNeed
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例5: testMBeanNotRegistered
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例6: testNotReadable
import javax.management.relation.RoleInfo; //导入依赖的package包/类
public Result testNotReadable() 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, false, true) };
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());
}
}
示例7: testRoleInfoInfinity
import javax.management.relation.RoleInfo; //导入依赖的package包/类
/**
* This test verifies that minimum role value also can be infinite
*/
public Result testRoleInfoInfinity() throws Exception {
try {
new RoleInfo("usualRole", classPath, true, true,
RoleInfo.ROLE_CARDINALITY_INFINITY, 4, "Unit role");
new RoleInfo("usualRole", classPath, true, true,
RoleInfo.ROLE_CARDINALITY_INFINITY,
RoleInfo.ROLE_CARDINALITY_INFINITY, "Unit role");
new RoleInfo("usualRole", classPath, true, true, 0,
RoleInfo.ROLE_CARDINALITY_INFINITY, "Unit role");
} catch (Exception e) {
return failed(e.toString());
}
return passed();
}
示例8: SimplePersonalLibrary
import javax.management.relation.RoleInfo; //导入依赖的package包/类
public SimplePersonalLibrary(String relationTypeName)
{
super(relationTypeName);
try
{
RoleInfo ownerRoleInfo = new RoleInfo("owner",
// the name of the MBean class of which all members must be an instance.
"mx4j.examples.services.relation.SimpleOwner",
true, //read
true, //write
1, // only one owner
1,
"Owner");
addRoleInfo(ownerRoleInfo);
RoleInfo booksRoleInfo = new RoleInfo("books",
"mx4j.examples.services.relation.SimpleBooks",
true,
true,
1, // feeling nasty can only own max 4 books and no fewer than 1
4,
"Books");
addRoleInfo(booksRoleInfo);
}
catch (Exception ex)
{
throw new RuntimeException(ex.getMessage());
}
}
示例9: testMBeansDoNotHaveTo
import javax.management.relation.RoleInfo; //导入依赖的package包/类
/**
* This test verifies that MBeans don't have to be registered before
* creation of role.
*/
public Result testMBeansDoNotHaveTo() throws Exception {
MBeanServer mBeanServer = MBeanServerFactory.createMBeanServer();
// Register Relation Service
RelationService relationService = new RelationService(true);
ObjectName relationServiceName = new ObjectName(
"mBeanServer:type=RelationService,name=rs");
mBeanServer.registerMBean(relationService, relationServiceName);
// Create Role Information Array
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);
ObjectName unit1Name = new ObjectName(
"mBeanServer:type=Unit,name=Unit1");
// Create RoleLists for single unit and double unit relations
ArrayList unitList = new ArrayList();
unitList.add(unit1Name);
Role unitRole = new Role("unitRole", unitList);
return !unitRole.getRoleValue().contains(unit1Name) ? failed("")
: passed();
}
示例10: testRoleNotFound
import javax.management.relation.RoleInfo; //导入依赖的package包/类
public Result testRoleNotFound() 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();
/* role name differs from role info contains */
unitRoles.add(new Role("another role", Collections
.singletonList(unitName)));
/* catch RoleNotFoundException */
try {
rService.createRelation("relation", "relationType", unitRoles);
return failed("");
} catch (RoleNotFoundException e) {
return passed();
} catch (Throwable t) {
return failed(t.toString());
}
}
示例11: testIdAlreadyUsed
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例12: testTheSameRoleName
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例13: testNumberOfMBeanMoreThanNeed
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例14: testDifferentTypeMBean
import javax.management.relation.RoleInfo; //导入依赖的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());
}
}
示例15: testExistenceAfterException
import javax.management.relation.RoleInfo; //导入依赖的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("");
}