javax.management.relation.Role Java Examples
The following examples show how to use
javax.management.relation.Role.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RelationServiceExample.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private void testAllAccessQueries(String relationId) { Logger logger = getLogger(); // retrieve all roles try { Object[] params = {relationId}; String[] signature = {"java.lang.String"}; RoleResult roleResult = (RoleResult)(m_server.invoke(m_relationObjectName, "getAllRoles", params, signature)); RoleList roleList = roleResult.getRoles(); for (Iterator i = roleList.iterator(); i.hasNext();) { Role currentRole = (Role)i.next(); System.out.println(">>>> role name: " + currentRole.getRoleName()); System.out.println(">>>> role values: " + currentRole.getRoleValue().toString()); } System.out.println("No unresolved Roles roleUnresolved size: " + roleResult.getRolesUnresolved().size()); } catch (Exception ex) { logger.error("Exception printing the results from relationId: " + relationId); System.out.println("Printing the Exception message to validate exception: " + ex.getMessage()); } }
Example #2
Source File: RelationServiceExample.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void borrowBooks(String relationId, String roleName, ObjectName bookToAdd) { Logger logger = getLogger(); try { // get the old values ArrayList oldRoleValue = getRoleValue(relationId, roleName); ArrayList newRoleValue = (ArrayList)oldRoleValue.clone(); newRoleValue.add(bookToAdd); // now we update the values Role role = new Role(roleName, newRoleValue); Object[] params1 = {relationId, role}; String[] signature1 = {"java.lang.String", "javax.management.relation.Role"}; m_server.invoke(m_relationObjectName, "setRole", params1, signature1); } catch (Exception ex) { logger.error("Unable to add a book"); ex.printStackTrace(); } }
Example #3
Source File: RelationNotificationSeqNoTest.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #4
Source File: RoleControllerTest.java From webcurator with Apache License 2.0 | 4 votes |
@Test public final void testProcessFormSubmission() { try { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); BindException aError = new BindException(new RoleCommand(), RoleCommand.ACTION_EDIT); this.testSetAgencyUserManager(); this.testSetAuthorityManager(); this.testSetMessageSource(); RoleCommand aCommand = new RoleCommand(); aCommand.setAction(RoleCommand.ACTION_NEW); aCommand.setOid(new Long(3000)); ModelAndView mav = testInstance.processFormSubmission(request, response, aCommand, aError); assertTrue(mav != null); assertTrue(mav.getViewName().equals("AddRole")); List<Agency> agencies = (List<Agency>)mav.getModel().get("agencies"); assertTrue(agencies != null); assertTrue(agencies.size() > 0); aCommand = new RoleCommand(); aCommand.setAction(RoleCommand.ACTION_VIEW); aCommand.setOid(new Long(3000)); mav = testInstance.processFormSubmission(request, response, aCommand, aError); assertTrue(mav != null); assertTrue(mav.getViewName().equals("AddRole")); agencies = (List<Agency>)mav.getModel().get("agencies"); assertTrue(agencies != null); assertTrue(agencies.size() > 0); RoleCommand newCommand = (RoleCommand)mav.getModel().get("command"); assertTrue(newCommand != null); assertTrue(newCommand.getViewOnlyMode()); aCommand = new RoleCommand(); aCommand.setAction(RoleCommand.ACTION_EDIT); aCommand.setOid(new Long(3000)); mav = testInstance.processFormSubmission(request, response, aCommand, aError); assertTrue(mav != null); assertTrue(mav.getViewName().equals("AddRole")); agencies = (List<Agency>)mav.getModel().get("agencies"); assertTrue(agencies != null); assertTrue(agencies.size() > 0); newCommand = (RoleCommand)mav.getModel().get("command"); assertTrue(newCommand != null); assertFalse(newCommand.getViewOnlyMode()); aCommand = new RoleCommand(); aCommand.setAction(RoleCommand.ACTION_SAVE); aCommand.setRoleName("New Test Role"); aCommand.setAgency(AuthUtil.getRemoteUserObject().getAgency().getOid()); String[] scopedPrivileges = {}; aCommand.setScopedPrivileges(scopedPrivileges); mav = testInstance.processFormSubmission(request, response, aCommand, aError); assertTrue(mav != null); assertTrue(mav.getViewName().equals("Roles")); List<Role> roles = (List<Role>)mav.getModel().get("roles"); assertTrue(roles != null); assertTrue(roles.size() > 0); aCommand = new RoleCommand(); aCommand.setAction(RoleCommand.ACTION_FILTER); String agencyFilter = "Dummy"; aCommand.setAgencyFilter(agencyFilter); mav = testInstance.processFormSubmission(request, response, aCommand, aError); assertTrue(mav != null); assertTrue(mav.getViewName().equals("Roles")); RoleCommand command = (RoleCommand)mav.getModel().get("command"); assertTrue(command != null); assertTrue(agencyFilter.equals(command.getAgencyFilter())); assertTrue(agencyFilter.equals((String)request.getSession().getAttribute(RoleCommand.PARAM_AGENCY_FILTER))); } catch (Exception e) { String message = e.getClass().toString() + " - " + e.getMessage(); log.debug(message); fail(message); } }
Example #5
Source File: RelationNotificationSeqNoTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #6
Source File: RelationNotificationSeqNoTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #7
Source File: RelationNotificationSeqNoTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #8
Source File: RelationNotificationSeqNoTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #9
Source File: RelationNotificationSeqNoTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #10
Source File: RelationNotificationSeqNoTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #11
Source File: RelationNotificationSeqNoTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #12
Source File: RelationNotificationSeqNoTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #13
Source File: RelationNotificationSeqNoTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #14
Source File: RelationNotificationSeqNoTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #15
Source File: RelationNotificationSeqNoTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #16
Source File: RelationNotificationSeqNoTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #17
Source File: CrossTransfer.java From jforgame with Apache License 2.0 | votes |
public abstract void afterLoginCross(Role player);