01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: 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: /**
24: * @version $Revision: 1.6 $
25: */
26: public class RemoteInstantiator {
27: public JMXConnectionNotification createJMXConnectionNotification() {
28: JMXConnectionNotification jcn = new JMXConnectionNotification(
29: JMXConnectionNotification.OPENED, "Source",
30: "ConnectionID", 0L, "Message", "UserData");
31: return jcn;
32: }
33:
34: public JMXPrincipal createJMXPrincipal() {
35: JMXPrincipal jp = new JMXPrincipal(JMXPrincipal.class.getName());
36: return jp;
37: }
38:
39: public JMXProviderException createJMXProviderException() {
40: JMXProviderException ex = new JMXProviderException();
41: return ex;
42: }
43:
44: public JMXServerErrorException createJMXServerErrorException() {
45: JMXServerErrorException see = new JMXServerErrorException(
46: "Message", new Error());
47: return see;
48: }
49:
50: public JMXServiceURL createJMXServiceURL() {
51: try {
52: JMXServiceURL jsu = new JMXServiceURL("rmi", "localhost",
53: 1099);
54: return jsu;
55: } catch (MalformedURLException e) {
56: throw new RuntimeException();
57: }
58: }
59:
60: public NotificationResult createNotificationResult() {
61: TargetedNotification[] notifs = { createTargetedNotification() };
62: NotificationResult result = new NotificationResult(0l, 1l,
63: notifs);
64: return result;
65: }
66:
67: public SubjectDelegationPermission createSubjectDelegationPermission() {
68: SubjectDelegationPermission sdp = new SubjectDelegationPermission(
69: SubjectDelegationPermission.class.getName());
70: return sdp;
71: }
72:
73: public TargetedNotification createTargetedNotification() {
74: TargetedNotification tn = new TargetedNotification(
75: createJMXConnectionNotification(), Integer.decode("1"));
76: return tn;
77: }
78:
79: public RMIConnector createRMIConnector() {
80: RMIConnector rc = new RMIConnector(createJMXServiceURL(),
81: new HashMap());
82: return rc;
83: }
84: }
|