1 /****************************************************************************
2 * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the LGPL License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 ****************************************************************************/
8 /*
9 * DefaultServiceUnitManager.java
10 *
11 */
12
13 package it.imolinfo.jbi4corba.jbi.component.runtime;
14
15 import javax.jbi.component.ServiceUnitManager;
16
17 /**
18 * Default Service Unit Manager implementation. Component's supporting the
19 * deployment should extend this class to support the service unit deployment.
20 *
21 * @see javax.jbi.ServiceUnitManager
22 *
23 * @author <a href="mailto:mpiraccini@imolinfo.it">Marco Piraccini</a>
24 */
25 public abstract class DefaultServiceUnitManager implements ServiceUnitManager {
26
27 /**
28 * Component runtime as context
29 */
30 @SuppressWarnings("unused")
31 private ComponentRuntime mContext;
32
33
34 /**
35 * constructor that takes the compoent runtime
36 */
37 public DefaultServiceUnitManager(ComponentRuntime ctx) {
38 this.mContext = ctx;
39 }
40
41 ///////////////////////////////////////////////////////////////////////////
42 // Helper methods
43 ///////////////////////////////////////////////////////////////////////////
44 /**
45 * Helper method to create result message in management message xml.
46 * @param message message string to return
47 * @param isSuccess true to format a sucess result, false to format a failed result.
48 * @return XML string.
49 */
50 protected String createComponentTaskResultXML(String message, boolean isSuccess) {
51
52 String taskResult = isSuccess ? "SUCCESS" : "FAILED";
53 String msgType = isSuccess ? "INFO" : "ERROR";
54 String componentName = RuntimeHelper.getComponentName();
55
56 String xmlResult =
57 "<component-task-result xmlns=\"http://java.sun.com/xml/ns/jbi/management-message\" >" +
58 " <component-name>" + componentName + "</component-name>" +
59 " <component-task-result-details >" +
60 " <task-result-details>" +
61 " <task-id>deployment</task-id>" +
62 " <task-result>" + taskResult + "</task-result>" +
63 " <message-type>" + msgType + "</message-type>" +
64 " <task-status-msg>" +
65 " <msg-loc-info>" +
66 " <loc-token>MSG_ID_000</loc-token>" +
67 " <loc-message>" + message + "</loc-message>" +
68 " </msg-loc-info>" +
69 " </task-status-msg>" +
70 " </task-result-details>" +
71 " </component-task-result-details>" +
72 "</component-task-result>";
73
74 return xmlResult;
75 }
76
77 }