1 8 9 package test.javax.management.remote.compliance.serialization.support; 10 11 import java.net.MalformedURLException ; 12 import java.util.HashMap ; 13 import javax.management.remote.JMXConnectionNotification ; 14 import javax.management.remote.JMXPrincipal ; 15 import javax.management.remote.JMXProviderException ; 16 import javax.management.remote.JMXServerErrorException ; 17 import javax.management.remote.JMXServiceURL ; 18 import javax.management.remote.NotificationResult ; 19 import javax.management.remote.SubjectDelegationPermission ; 20 import javax.management.remote.TargetedNotification ; 21 import javax.management.remote.rmi.RMIConnector ; 22 23 26 public class RemoteInstantiator 27 { 28 public JMXConnectionNotification createJMXConnectionNotification() 29 { 30 JMXConnectionNotification jcn = new JMXConnectionNotification (JMXConnectionNotification.OPENED, 31 "Source", "ConnectionID", 32 0L, "Message", "UserData"); 33 return jcn; 34 } 35 36 public JMXPrincipal createJMXPrincipal() 37 { 38 JMXPrincipal jp = new JMXPrincipal (JMXPrincipal .class.getName()); 39 return jp; 40 } 41 42 public JMXProviderException createJMXProviderException() 43 { 44 JMXProviderException ex = new JMXProviderException (); 45 return ex; 46 } 47 48 public JMXServerErrorException createJMXServerErrorException() 49 { 50 JMXServerErrorException see = new JMXServerErrorException ("Message", new Error ()); 51 return see; 52 } 53 54 public JMXServiceURL createJMXServiceURL() 55 { 56 try 57 { 58 JMXServiceURL jsu = new JMXServiceURL ("rmi", "localhost", 1099); 59 return jsu; 60 } 61 catch (MalformedURLException e) 62 { 63 throw new RuntimeException (); 64 } 65 } 66 67 public NotificationResult createNotificationResult() 68 { 69 TargetedNotification [] notifs = 70 {createTargetedNotification()}; 71 NotificationResult result = new NotificationResult (0l, 1l, notifs); 72 return result; 73 } 74 75 public SubjectDelegationPermission createSubjectDelegationPermission() 76 { 77 SubjectDelegationPermission sdp = new SubjectDelegationPermission (SubjectDelegationPermission .class.getName()); 78 return sdp; 79 } 80 81 public TargetedNotification createTargetedNotification() 82 { 83 TargetedNotification tn = new TargetedNotification (createJMXConnectionNotification(), Integer.decode("1")); 84 return tn; 85 } 86 87 public RMIConnector createRMIConnector() 88 { 89 RMIConnector rc = new RMIConnector (createJMXServiceURL(), new HashMap ()); 90 return rc; 91 } 92 } 93 | Popular Tags |