001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)DeploymentServiceImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.esb.management.impl.deployment;
030:
031: import java.io.Serializable;
032: import java.util.Map;
033:
034: import javax.management.MBeanServerConnection;
035: import javax.management.ObjectName;
036:
037: import com.sun.esb.management.api.deployment.DeploymentService;
038: import com.sun.esb.management.base.services.BaseServiceImpl;
039: import com.sun.esb.management.common.ManagementRemoteException;
040:
041: /**
042: * Defines client operations for common deployment/undeployment services
043: * for the client
044: *
045: * @author graj
046: */
047: public class DeploymentServiceImpl extends BaseServiceImpl implements
048: Serializable, DeploymentService {
049:
050: static final long serialVersionUID = -1L;
051:
052: /** Constructor - Constructs a new instance of DeploymentServiceImpl */
053: public DeploymentServiceImpl() {
054: super (null, false);
055: }
056:
057: /**
058: * Constructor - Constructs a new instance of DeploymentServiceImpl
059: *
060: * @param serverConnection
061: */
062: public DeploymentServiceImpl(MBeanServerConnection serverConnection) {
063: super (serverConnection, false);
064: }
065:
066: /**
067: * Constructor - Constructs a new instance of DeploymentServiceImpl
068: *
069: * @param serverConnection
070: * @param isRemoteConnection
071: */
072: public DeploymentServiceImpl(
073: MBeanServerConnection serverConnection,
074: boolean isRemoteConnection) {
075: super (serverConnection, isRemoteConnection);
076: }
077:
078: /**
079: * deploys service assembly
080: *
081: * @return result as a management message xml text
082: * @param zipFilePath
083: * file path
084: * @return result as a management message xml text string.
085: * @throws ManagementRemoteException
086: * on error
087: *
088: * @see com.sun.esb.management.api.deployment.DeploymentService#deployServiceAssembly(java.lang.String, java.lang.String)
089: */
090: public String deployServiceAssembly(String zipFilePath,
091: String targetName) throws ManagementRemoteException {
092: String result = null;
093: ObjectName mbeanName = this
094: .getDeploymentServiceMBeanObjectName();
095: Object resultObject = null;
096:
097: if (this .isRemoteConnection() == true) {
098: zipFilePath = uploadFile(zipFilePath);
099: }
100:
101: Object[] params = new Object[2];
102: params[0] = zipFilePath;
103: params[1] = targetName;
104:
105: String[] signature = new String[2];
106: signature[0] = "java.lang.String";
107: signature[1] = "java.lang.String";
108:
109: resultObject = this .invokeMBeanOperation(mbeanName,
110: "deployServiceAssembly", params, signature);
111:
112: this .removeUploadedFile(); // if uploaded
113:
114: result = resultObject.toString();
115:
116: return result;
117: }
118:
119: /**
120: * deploys service assembly
121: *
122: * @param zipFilePath
123: * fie path
124: * @param targetNames
125: * @return result as a management message xml text [targetName,xmlString]
126: * map
127: * @throws ManagementRemoteException
128: * on error
129: *
130: * @see com.sun.esb.management.api.deployment.DeploymentService#deployServiceAssembly(java.lang.String, java.lang.String[])
131: */
132: @SuppressWarnings("unchecked")
133: public Map<String, String> deployServiceAssembly(
134: String zipFilePath, String[] targetNames)
135: throws ManagementRemoteException {
136: Map<String, String> result = null;
137: ObjectName mbeanName = this
138: .getDeploymentServiceMBeanObjectName();
139:
140: if (this .isRemoteConnection() == true) {
141: zipFilePath = uploadFile(zipFilePath);
142: }
143:
144: Object[] params = new Object[2];
145: params[0] = zipFilePath;
146: params[1] = targetNames;
147:
148: String[] signature = new String[2];
149: signature[0] = "java.lang.String";
150: signature[1] = targetNames.getClass().getName();
151:
152: result = (Map<String, String>) this .invokeMBeanOperation(
153: mbeanName, "deployServiceAssembly", params, signature);
154:
155: this .removeUploadedFile(); // if uploaded
156:
157: return result;
158: }
159:
160: /**
161: * deploys service assembly from domain target
162: *
163: * @param assemblyName
164: * service assembly name
165: * @param targetName
166: * name of the target for this operation
167: * @return result as a management message xml text string.
168: * @throws ManagementRemoteException
169: * on error
170: *
171: * @see com.sun.esb.management.api.deployment.DeploymentService#deployServiceAssemblyFromDomain(java.lang.String, java.lang.String)
172: */
173: public String deployServiceAssemblyFromDomain(String assemblyName,
174: String targetName) throws ManagementRemoteException {
175: String result = null;
176: ObjectName mbeanName = this
177: .getDeploymentServiceMBeanObjectName();
178:
179: Object[] params = new Object[2];
180: params[0] = assemblyName;
181: params[1] = targetName;
182:
183: String[] signature = new String[2];
184: signature[0] = "java.lang.String";
185: signature[1] = "java.lang.String";
186:
187: result = (String) this .invokeMBeanOperation(mbeanName,
188: "deployServiceAssemblyFromDomain", params, signature);
189:
190: return result;
191: }
192:
193: /**
194: * deploys service assembly
195: *
196: * @param assemblyName
197: * name of the service assembly
198: * @param targetName
199: * name of the target for this operation
200: * @return Map of targetName and management message xml text strings.
201: * @throws ManagementRemoteException
202: * on error
203: *
204: * @see com.sun.esb.management.api.deployment.DeploymentService#deployServiceAssemblyFromDomain(java.lang.String, java.lang.String[])
205: */
206: @SuppressWarnings("unchecked")
207: public Map<String, String> deployServiceAssemblyFromDomain(
208: String assemblyName, String[] targetNames)
209: throws ManagementRemoteException {
210: Map<String, String> result = null;
211: ObjectName mbeanName = this
212: .getDeploymentServiceMBeanObjectName();
213:
214: Object[] params = new Object[2];
215: params[0] = assemblyName;
216: params[1] = targetNames;
217:
218: String[] signature = new String[2];
219: signature[0] = "java.lang.String";
220: signature[1] = targetNames.getClass().getName();
221:
222: result = (Map<String, String>) this .invokeMBeanOperation(
223: mbeanName, "deployServiceAssemblyFromDomain", params,
224: signature);
225:
226: return result;
227: }
228:
229: /**
230: * forcibly undeploys service assembly with option to retain it in domain
231: *
232: * @param serviceAssemblyName
233: * name of the service assembly
234: * @param forceDelete
235: * forces deletion of the assembly if true, false if not
236: * @param retainInDomain
237: * true to not delete it from the domain target, false to also
238: * delete it from the domain target.
239: * @param targetName
240: * name of the target for this operation
241: * @return result as a management message xml text string.
242: * @throws ManagementRemoteException
243: * on error
244: *
245: * @see com.sun.esb.management.api.deployment.DeploymentService#undeployServiceAssembly(java.lang.String, boolean, boolean, java.lang.String)
246: */
247: public String undeployServiceAssembly(String serviceAssemblyName,
248: boolean forceDelete, boolean retainInDomain,
249: String targetName) throws ManagementRemoteException {
250: String result = null;
251: ObjectName mbeanName = this
252: .getDeploymentServiceMBeanObjectName();
253:
254: Object[] params = new Object[4];
255: params[0] = serviceAssemblyName;
256: params[1] = Boolean.valueOf(forceDelete);
257: params[2] = Boolean.valueOf(retainInDomain);
258: params[3] = targetName;
259:
260: String[] signature = new String[4];
261: signature[0] = "java.lang.String";
262: signature[1] = "boolean";
263: signature[2] = "boolean";
264: signature[3] = "java.lang.String";
265:
266: result = (String) this .invokeMBeanOperation(mbeanName,
267: "undeployServiceAssembly", params, signature);
268:
269: return result;
270: }
271:
272: /**
273: * forcibly undeploys service assembly
274: *
275: * @param serviceAssemblyName
276: * name of the service assembly
277: * @param forceDelete
278: * forces deletion of the assembly if true, false if not
279: * @param targetName
280: * name of the target for this operation
281: * @return result as a management message xml text string.
282: * @throws ManagementRemoteException
283: * on error
284: *
285: * @see com.sun.esb.management.api.deployment.DeploymentService#undeployServiceAssembly(java.lang.String, boolean, java.lang.String)
286: */
287: public String undeployServiceAssembly(String serviceAssemblyName,
288: boolean forceDelete, String targetName)
289: throws ManagementRemoteException {
290: String result = null;
291: ObjectName mbeanName = this
292: .getDeploymentServiceMBeanObjectName();
293:
294: Object[] params = new Object[3];
295: params[0] = serviceAssemblyName;
296: params[1] = Boolean.valueOf(forceDelete);
297: params[2] = targetName;
298:
299: String[] signature = new String[3];
300: signature[0] = "java.lang.String";
301: signature[1] = "boolean";
302: signature[2] = "java.lang.String";
303:
304: result = (String) this .invokeMBeanOperation(mbeanName,
305: "undeployServiceAssembly", params, signature);
306:
307: return result;
308: }
309:
310: /**
311: * forcibly undeploys service assembly
312: *
313: * @param serviceAssemblyName
314: * name of the service assembly
315: * @param targetName
316: * name of the target for this operation
317: * @return result as a management message xml text string.
318: * @throws ManagementRemoteException
319: * on error
320: *
321: * @see com.sun.esb.management.api.deployment.DeploymentService#undeployServiceAssembly(java.lang.String, java.lang.String)
322: */
323: public String undeployServiceAssembly(String serviceAssemblyName,
324: String targetName) throws ManagementRemoteException {
325: String result = null;
326: ObjectName mbeanName = this
327: .getDeploymentServiceMBeanObjectName();
328:
329: Object[] params = new Object[2];
330: params[0] = serviceAssemblyName;
331: params[1] = targetName;
332:
333: String[] signature = new String[2];
334: signature[0] = "java.lang.String";
335: signature[1] = "java.lang.String";
336:
337: result = (String) this .invokeMBeanOperation(mbeanName,
338: "undeployServiceAssembly", params, signature);
339:
340: return result;
341: }
342:
343: /**
344: * undeploys service assembly
345: *
346: * @param serviceAssemblyName
347: * name of the service assembly
348: * @param targetNames
349: * @return result as a management message xml text as [targetName, string]
350: * map
351: * @throws ManagementRemoteException
352: * on error
353: *
354: * @see com.sun.esb.management.api.deployment.DeploymentService#undeployServiceAssembly(java.lang.String, java.lang.String[])
355: */
356: @SuppressWarnings("unchecked")
357: public Map<String, String> undeployServiceAssembly(
358: String serviceAssemblyName, String[] targetNames)
359: throws ManagementRemoteException {
360: Map<String, String> result = null;
361: ObjectName mbeanName = this
362: .getDeploymentServiceMBeanObjectName();
363:
364: Object[] params = new Object[2];
365: params[0] = serviceAssemblyName;
366: params[1] = targetNames;
367:
368: String[] signature = new String[2];
369: signature[0] = "java.lang.String";
370: signature[1] = targetNames.getClass().getName();
371:
372: result = (Map<String, String>) this
373: .invokeMBeanOperation(mbeanName,
374: "undeployServiceAssembly", params, signature);
375:
376: return result;
377: }
378:
379: /**
380: * undeploys service assembly
381: *
382: * @param serviceAssemblyName
383: * name of the service assembly
384: * @param forceDelete
385: * true to delete, false to not
386: * @param targetName
387: * name of the target for this operation
388: * @return Map of targetName and result as a management message xml text
389: * strings.
390: * @throws ManagementRemoteException
391: * on error
392: *
393: * @see com.sun.esb.management.api.deployment.DeploymentService#undeployServiceAssembly(java.lang.String, boolean, java.lang.String[])
394: */
395: @SuppressWarnings("unchecked")
396: public Map<String, String> undeployServiceAssembly(
397: String serviceAssemblyName, boolean forceDelete,
398: String[] targetNames) throws ManagementRemoteException {
399: ObjectName mbeanName = this
400: .getDeploymentServiceMBeanObjectName();
401: Map<String, String> resultObject = null;
402:
403: Object[] params = new Object[3];
404: params[0] = serviceAssemblyName;
405: params[1] = forceDelete;
406: params[2] = targetNames;
407:
408: String[] signature = new String[3];
409: signature[0] = "java.lang.String";
410: signature[1] = "boolean";
411: signature[2] = targetNames.getClass().getName();
412:
413: resultObject = (Map<String, String>) this
414: .invokeMBeanOperation(mbeanName,
415: "undeployServiceAssembly", params, signature);
416:
417: return resultObject;
418: }
419:
420: /**
421: * undeploys service assembly
422: *
423: * @param serviceAssemblyName
424: * name of the service assembly
425: * @param forceDelete
426: * forces deletion of the assembly if true, false if not
427: * @param retainInDomain
428: * true to not delete it from the domain target, false to also
429: * delete it from the domain target.
430: * @param targetNames
431: * array of targets for this operation
432: * @return Map of targetName and result as a management message xml text
433: * strings.
434: * @throws ManagementRemoteException
435: * on error
436: *
437: * @see com.sun.esb.management.api.deployment.DeploymentService#undeployServiceAssembly(java.lang.String, boolean, boolean, java.lang.String[])
438: */
439: @SuppressWarnings("unchecked")
440: public Map<String, String> undeployServiceAssembly(
441: String serviceAssemblyName, boolean forceDelete,
442: boolean retainInDomain, String[] targetNames)
443: throws ManagementRemoteException {
444: ObjectName mbeanName = this
445: .getDeploymentServiceMBeanObjectName();
446: Map<String, String> resultObject = null;
447:
448: Object[] params = new Object[4];
449: params[0] = serviceAssemblyName;
450: params[1] = forceDelete;
451: params[2] = retainInDomain;
452: params[3] = targetNames;
453:
454: String[] signature = new String[4];
455: signature[0] = "java.lang.String";
456: signature[1] = "boolean";
457: signature[2] = "boolean";
458: signature[3] = targetNames.getClass().getName();
459:
460: resultObject = (Map<String, String>) this
461: .invokeMBeanOperation(mbeanName,
462: "undeployServiceAssembly", params, signature);
463:
464: return resultObject;
465: }
466:
467: }
|