35 import org.opensolaris.os.vp.common.panel.MBeanUtil; |
34 import org.opensolaris.os.vp.common.panel.MBeanUtil; |
36 import org.opensolaris.os.vp.panel.common.*; |
35 import org.opensolaris.os.vp.panel.common.*; |
37 import org.opensolaris.os.vp.panel.common.control.*; |
36 import org.opensolaris.os.vp.panel.common.control.*; |
38 import org.opensolaris.os.vp.panel.common.model.*; |
37 import org.opensolaris.os.vp.panel.common.model.*; |
39 import org.opensolaris.os.vp.panel.common.smf.*; |
38 import org.opensolaris.os.vp.panel.common.smf.*; |
40 import org.opensolaris.os.vp.panel.common.time.TimeMXBean; |
39 import org.opensolaris.os.vp.panel.common.time.*; |
41 import org.opensolaris.os.vp.panel.swing.control.PanelFrameControl; |
40 import org.opensolaris.os.vp.panel.swing.control.PanelFrameControl; |
42 import org.opensolaris.os.vp.panel.swing.smf.ServiceSwingPanelDescriptor; |
41 import org.opensolaris.os.vp.panel.swing.smf.ServiceSwingPanelDescriptor; |
43 import org.opensolaris.os.vp.panel.swing.timezone.HasTimeZoneMXBean; |
|
44 import org.opensolaris.os.vp.util.misc.*; |
42 import org.opensolaris.os.vp.util.misc.*; |
45 |
43 |
46 @SuppressWarnings({"serial"}) |
44 @SuppressWarnings({"serial"}) |
47 public class TimePanelDescriptor |
45 public class TimePanelDescriptor |
48 extends ServiceSwingPanelDescriptor<ManagedObject> |
46 extends ServiceSwingPanelDescriptor<ManagedObject> |
49 implements HasTimeZoneMXBean { |
47 implements HasTimeMXBean { |
50 |
48 |
51 // |
49 // |
52 // Static data |
50 // Static data |
53 // |
51 // |
54 |
52 |
79 throws IOException, InstanceNotFoundException, ScfException, |
77 throws IOException, InstanceNotFoundException, ScfException, |
80 InvalidScfDataException, MissingScfDataException { |
78 InvalidScfDataException, MissingScfDataException { |
81 |
79 |
82 super(id, context, SERVICE, INSTANCE); |
80 super(id, context, SERVICE, INSTANCE); |
83 |
81 |
84 setBean(context.getConnectionInfo()); |
82 ObjectName oName = MBeanUtil.makeVPObjectName("panels.time", "Time"); |
|
83 beanTracker = new MXBeanTracker<TimeMXBean>( |
|
84 TimeMXBean.class, context, oName); |
|
85 |
|
86 hasFullPrivs = getTimeMXBean().isSufficientlyPrivileged(); |
85 |
87 |
86 refresh(true); |
88 refresh(true); |
87 control = new PanelFrameControl<TimePanelDescriptor>(this); |
89 control = new PanelFrameControl<TimePanelDescriptor>(this); |
88 control.addChildren(new MainControl(this)); |
90 control.addChildren(new MainControl(this)); |
89 } |
|
90 |
|
91 // |
|
92 // ConnectionListener methods |
|
93 // |
|
94 |
|
95 @Override |
|
96 public void connectionChanged(ConnectionEvent event) { |
|
97 super.connectionChanged(event); |
|
98 setBean(event.getConnectionInfo()); |
|
99 } |
91 } |
100 |
92 |
101 // |
93 // |
102 // HasIcons methods |
94 // HasIcons methods |
103 // |
95 // |
106 public List<? extends Icon> getIcons() { |
98 public List<? extends Icon> getIcons() { |
107 return icons; |
99 return icons; |
108 } |
100 } |
109 |
101 |
110 // |
102 // |
|
103 // HasTimeMXBean methods |
|
104 // |
|
105 |
|
106 @Override |
|
107 public TimeMXBean getTimeMXBean() { |
|
108 return beanTracker.getBean(); |
|
109 } |
|
110 |
|
111 // |
111 // ManagedObject methods |
112 // ManagedObject methods |
112 // |
113 // |
|
114 |
|
115 /** |
|
116 * Stops monitoring the connection to the remote host. |
|
117 */ |
|
118 @Override |
|
119 public void dispose() { |
|
120 beanTracker.dispose(); |
|
121 super.dispose(); |
|
122 } |
113 |
123 |
114 @Override |
124 @Override |
115 public String getName() { |
125 public String getName() { |
116 return Finder.getString("panel.time.name"); |
126 return Finder.getString("panel.time.name"); |
117 } |
127 } |
144 } |
154 } |
145 } catch (ScfException e) { |
155 } catch (ScfException e) { |
146 } |
156 } |
147 return Finder.getString(resource); |
157 return Finder.getString(resource); |
148 } |
158 } |
149 |
|
150 // |
|
151 // HasTimeZoneMXBean |
|
152 // |
|
153 |
|
154 public TimeMXBean getTimeZoneMXBean() { |
|
155 return timebean; |
|
156 } |
|
157 |
|
158 // |
|
159 // TimePanelDescriptor methods |
|
160 // |
|
161 |
|
162 protected TimeMXBean getTimeBean() { |
|
163 return timebean; |
|
164 } |
|
165 |
|
166 // |
|
167 // Private methods |
|
168 // |
|
169 |
|
170 private void setBean(ConnectionInfo info) { |
|
171 try { |
|
172 timebean = JMX.newMXBeanProxy( |
|
173 info.getConnector().getMBeanServerConnection(), |
|
174 MBeanUtil.makeVPObjectName("panels.time", "Time"), |
|
175 TimeMXBean.class); |
|
176 hasFullPrivs = timebean.isSufficientlyPrivileged(); |
|
177 } catch (IOException e) { |
|
178 timebean = null; |
|
179 } |
|
180 } |
|
181 } |
159 } |