1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.panel.common.smf; |
|
27 |
|
28 import java.math.BigInteger; |
|
29 import java.util.*; |
|
30 import com.oracle.solaris.rad.client.RadObjectException; |
|
31 import com.oracle.solaris.scf.common.ScfException; |
|
32 import com.oracle.solaris.vp.panel.common.api.smf_old.*; |
|
33 |
|
34 /** |
|
35 * ServiceBeanAdaptor wraps a ServiceInfoBean and provides an |
|
36 * old-style ServiceBean interface. Because the use of the |
|
37 * ServiceBean interface and the ScfExceptions is so widespread, |
|
38 * it is simpler to make the bridge from ObjectExceptions here |
|
39 * rather than at the site of each use. |
|
40 * <br/> |
|
41 * For classloading reasons this mapping can never be completely |
|
42 * automatic. It might prove fruitful to create an generic wrapper |
|
43 * using {@code Proxy}, though. |
|
44 */ |
|
45 public class ServiceBeanAdaptor implements ServiceBean { |
|
46 |
|
47 ServiceInfo sibean_; |
|
48 |
|
49 public ServiceBeanAdaptor(ServiceInfo sibean) { |
|
50 sibean_ = sibean; |
|
51 } |
|
52 |
|
53 public String getFmri() throws ScfException { |
|
54 try { |
|
55 return sibean_.getfmri(); |
|
56 } catch (RadObjectException e) { |
|
57 throw new ScfException(e); |
|
58 } |
|
59 } |
|
60 |
|
61 public List<String> getMethodNames() throws ScfException { |
|
62 try { |
|
63 return sibean_.getmethodNames(); |
|
64 } catch (RadObjectException e) { |
|
65 throw new ScfException(e); |
|
66 } |
|
67 } |
|
68 |
|
69 public List<String> getDependencyNames() throws ScfException { |
|
70 try { |
|
71 return sibean_.getdependencyNames(); |
|
72 } catch (RadObjectException e) { |
|
73 throw new ScfException(e); |
|
74 } |
|
75 } |
|
76 |
|
77 @Override |
|
78 public Dependency getDependency(String name) throws ScfException { |
|
79 try { |
|
80 return sibean_.getDependency(name); |
|
81 } catch (RadObjectException e) { |
|
82 throw new ScfException(e); |
|
83 } |
|
84 } |
|
85 |
|
86 @Override |
|
87 public List<String> getPropertyNames(String pg_name) throws ScfException { |
|
88 try { |
|
89 return sibean_.getPropertyNames(pg_name); |
|
90 } catch (RadObjectException e) { |
|
91 throw new ScfException(e); |
|
92 } |
|
93 } |
|
94 |
|
95 @Override |
|
96 public PropertyType getPropertyType(String pg_name, String prop_name) |
|
97 throws ScfException { |
|
98 |
|
99 try { |
|
100 return sibean_.getPropertyType(pg_name, prop_name); |
|
101 } catch (RadObjectException e) { |
|
102 throw new ScfException(e); |
|
103 } |
|
104 } |
|
105 |
|
106 @Override |
|
107 public List<String> getPropertyValues(String pg_name, String prop_name) |
|
108 throws ScfException { |
|
109 |
|
110 try { |
|
111 return sibean_.getPropertyValues(pg_name, prop_name); |
|
112 } catch (RadObjectException e) { |
|
113 throw new ScfException(e); |
|
114 } |
|
115 } |
|
116 |
|
117 @Override |
|
118 public List<String> getSnapshotPropertyValues(String snap_name, |
|
119 String pg_name, String prop_name) throws ScfException { |
|
120 |
|
121 try { |
|
122 return sibean_.getSnapshotPropertyValues(snap_name, pg_name, |
|
123 prop_name); |
|
124 } catch (RadObjectException e) { |
|
125 throw new ScfException(e); |
|
126 } |
|
127 } |
|
128 |
|
129 @Override |
|
130 public void setPropertyValues(String pg_name, String prop_name, |
|
131 List<String> values) throws ScfException { |
|
132 |
|
133 try { |
|
134 sibean_.setPropertyValues(pg_name, prop_name, values); |
|
135 } catch (RadObjectException e) { |
|
136 throw new ScfException(e); |
|
137 } |
|
138 } |
|
139 |
|
140 @Override |
|
141 public void createPropertyGroup(String pg_name, String pg_type) |
|
142 throws ScfException { |
|
143 |
|
144 try { |
|
145 sibean_.createPropertyGroup(pg_name, pg_type); |
|
146 } catch (RadObjectException e) { |
|
147 throw new ScfException(e); |
|
148 } |
|
149 } |
|
150 |
|
151 @Override |
|
152 public void deletePropertyGroup(String pg_name) throws ScfException { |
|
153 try { |
|
154 sibean_.deletePropertyGroup(pg_name); |
|
155 } catch (RadObjectException e) { |
|
156 throw new ScfException(e); |
|
157 } |
|
158 } |
|
159 |
|
160 @Override |
|
161 public void createProperty(String pg_name, String prop_name, |
|
162 PropertyType type) throws ScfException { |
|
163 |
|
164 try { |
|
165 sibean_.createProperty(pg_name, prop_name, type); |
|
166 } catch (RadObjectException e) { |
|
167 throw new ScfException(e); |
|
168 } |
|
169 } |
|
170 |
|
171 @Override |
|
172 public void deleteProperty(String pg_name, String prop_name) |
|
173 throws ScfException { |
|
174 |
|
175 try { |
|
176 sibean_.deleteProperty(pg_name, prop_name); |
|
177 } catch (RadObjectException e) { |
|
178 throw new ScfException(e); |
|
179 } |
|
180 } |
|
181 |
|
182 public List<PropertyGroup> getPropertyGroups() throws ScfException { |
|
183 try { |
|
184 return sibean_.getpropertyGroups(); |
|
185 } catch (RadObjectException e) { |
|
186 throw new ScfException(e); |
|
187 } |
|
188 } |
|
189 |
|
190 @Override |
|
191 public Template getPropertyTemplate(String pg_name, String prop_name, |
|
192 String locale) throws ScfException { |
|
193 |
|
194 try { |
|
195 return sibean_.getPropertyTemplate(pg_name, prop_name, locale); |
|
196 } catch (RadObjectException e) { |
|
197 throw new ScfException(e); |
|
198 } |
|
199 } |
|
200 |
|
201 @Override |
|
202 public String getCommonName(String locale) throws ScfException { |
|
203 try { |
|
204 return sibean_.getCommonName(locale); |
|
205 } catch (RadObjectException e) { |
|
206 throw new ScfException(e); |
|
207 } |
|
208 } |
|
209 |
|
210 @Override |
|
211 public String getDescription(String locale) throws ScfException { |
|
212 try { |
|
213 return sibean_.getDescription(locale); |
|
214 } catch (RadObjectException e) { |
|
215 throw new ScfException(e); |
|
216 } |
|
217 } |
|
218 |
|
219 @Override |
|
220 public LogInfo getLogInfo(int max_size) throws ScfException { |
|
221 try { |
|
222 return sibean_.getLogInfo(max_size); |
|
223 } catch (RadObjectException e) { |
|
224 throw new ScfException(e); |
|
225 } |
|
226 } |
|
227 |
|
228 public List<Manpage> getManpages() throws ScfException { |
|
229 try { |
|
230 return sibean_.getmanpages(); |
|
231 } catch (RadObjectException e) { |
|
232 throw new ScfException(e); |
|
233 } |
|
234 } |
|
235 |
|
236 public List<String> getDoclinks() throws ScfException { |
|
237 try { |
|
238 return sibean_.getdoclinks(); |
|
239 } catch (RadObjectException e) { |
|
240 throw new ScfException(e); |
|
241 } |
|
242 } |
|
243 |
|
244 @Override |
|
245 public void maintain(boolean immediate) throws ScfException { |
|
246 try { |
|
247 sibean_.maintain(immediate); |
|
248 } catch (RadObjectException e) { |
|
249 throw new ScfException(e); |
|
250 } |
|
251 } |
|
252 |
|
253 @Override |
|
254 public void clear() throws ScfException { |
|
255 try { |
|
256 sibean_.clear(); |
|
257 } catch (RadObjectException e) { |
|
258 throw new ScfException(e); |
|
259 } |
|
260 } |
|
261 |
|
262 @Override |
|
263 public void degrade(boolean immediate) throws ScfException { |
|
264 try { |
|
265 sibean_.degrade(immediate); |
|
266 } catch (RadObjectException e) { |
|
267 throw new ScfException(e); |
|
268 } |
|
269 } |
|
270 |
|
271 @Override |
|
272 public void restart() throws ScfException { |
|
273 try { |
|
274 sibean_.restart(); |
|
275 } catch (RadObjectException e) { |
|
276 throw new ScfException(e); |
|
277 } |
|
278 } |
|
279 |
|
280 @Override |
|
281 public void refresh() throws ScfException { |
|
282 try { |
|
283 sibean_.refresh(); |
|
284 } catch (RadObjectException e) { |
|
285 throw new ScfException(e); |
|
286 } |
|
287 } |
|
288 |
|
289 public boolean isPersistentlyEnabled() throws ScfException { |
|
290 try { |
|
291 return sibean_.ispersistentlyEnabled(); |
|
292 } catch (RadObjectException e) { |
|
293 throw new ScfException(e); |
|
294 } |
|
295 } |
|
296 |
|
297 public void setPersistentlyEnabled(boolean enabled) throws ScfException { |
|
298 try { |
|
299 sibean_.setpersistentlyEnabled(enabled); |
|
300 } catch (RadObjectException e) { |
|
301 throw new ScfException(e); |
|
302 } |
|
303 } |
|
304 |
|
305 public boolean isTemporarilyEnabled() throws ScfException { |
|
306 try { |
|
307 return sibean_.istemporarilyEnabled(); |
|
308 } catch (RadObjectException e) { |
|
309 throw new ScfException(e); |
|
310 } |
|
311 } |
|
312 |
|
313 public boolean isEnabled() throws ScfException { |
|
314 try { |
|
315 return sibean_.isenabled(); |
|
316 } catch (RadObjectException e) { |
|
317 throw new ScfException(e); |
|
318 } |
|
319 } |
|
320 |
|
321 public boolean isInstance() throws ScfException { |
|
322 try { |
|
323 return sibean_.isinstance(); |
|
324 } catch (RadObjectException e) { |
|
325 throw new ScfException(e); |
|
326 } |
|
327 } |
|
328 |
|
329 public String getRestarter() throws ScfException { |
|
330 try { |
|
331 return sibean_.getrestarter(); |
|
332 } catch (RadObjectException e) { |
|
333 throw new ScfException(e); |
|
334 } |
|
335 } |
|
336 |
|
337 public SmfState getState() throws ScfException { |
|
338 try { |
|
339 return sibean_.getstate(); |
|
340 } catch (RadObjectException e) { |
|
341 throw new ScfException(e); |
|
342 } |
|
343 } |
|
344 |
|
345 public SmfState getNextState() throws ScfException { |
|
346 try { |
|
347 return sibean_.getnextState(); |
|
348 } catch (RadObjectException e) { |
|
349 throw new ScfException(e); |
|
350 } |
|
351 } |
|
352 |
|
353 public Date getSTime() throws ScfException { |
|
354 try { |
|
355 return sibean_.getstime(); |
|
356 } catch (RadObjectException e) { |
|
357 throw new ScfException(e); |
|
358 } |
|
359 } |
|
360 |
|
361 public BigInteger getContractID() throws ScfException { |
|
362 try { |
|
363 return BigInteger.valueOf(sibean_.getcontractID()); |
|
364 } catch (RadObjectException e) { |
|
365 throw new ScfException(e); |
|
366 } |
|
367 } |
|
368 |
|
369 public String getAuxiliaryState() throws ScfException { |
|
370 try { |
|
371 return sibean_.getauxiliaryState(); |
|
372 } catch (RadObjectException e) { |
|
373 throw new ScfException(e); |
|
374 } |
|
375 } |
|
376 |
|
377 public String getReason() throws ScfException { |
|
378 try { |
|
379 return sibean_.getreason(); |
|
380 } catch (RadObjectException e) { |
|
381 throw new ScfException(e); |
|
382 } |
|
383 } |
|
384 } |
|