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: * @(#)ExtensionComponent.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package extension;
030:
031: import com.sun.jbi.framework.AbstractComponent;
032:
033: import java.util.logging.Logger;
034: import javax.jbi.component.Bootstrap;
035: import javax.jbi.component.ComponentContext;
036:
037: /**
038: * This component is used to test the extension classloader in the Java
039: * SE framework. The class extends AbstractComponent, but does not include
040: * it in its installation archive. Instead, the base class should be added
041: * to the lib/ext directory.
042: *
043: * @author Sun Microsystems, Inc.
044: */
045: public class ExtensionComponent extends AbstractComponent implements
046: Bootstrap {
047:
048: /* ######### Component Life Cycle SPI Methods ########## */
049:
050: /**
051: * Initialize the Binding Component.
052: * @param context the JBI component context created by the JBI framework.
053: * @throws javax.jbi.JBIException if an error occurs.
054: */
055: public void init(ComponentContext context)
056: throws javax.jbi.JBIException {
057: mContext = context;
058: }
059:
060: /* ################# Bootstrap SPI Methods ################# */
061:
062: public void onUninstall() throws javax.jbi.JBIException {
063: }
064:
065: public void onInstall() throws javax.jbi.JBIException {
066:
067: }
068:
069: public void init(
070: javax.jbi.component.InstallationContext installationContext)
071: throws javax.jbi.JBIException {
072:
073: }
074:
075: public void cleanUp() throws javax.jbi.JBIException {
076:
077: }
078:
079: public javax.management.ObjectName getExtensionMBeanName() {
080: return null;
081: }
082:
083: /* ############# ServiceUnitManager SPI Methods ############# */
084:
085: /**
086: * Deploy a Service Unit.
087: * @param serviceUnitName the name of the Service Unit being deployed.
088: * @param serviceUnitRootPath the full path to the Service Unit artifact
089: * root directory.
090: * @return a deployment status message.
091: * @throws javax.jbi.management.DeploymentException if the deployment
092: * operation is unsuccessful.
093: */
094: public String deploy(String serviceUnitName,
095: String serviceUnitRootPath)
096: throws javax.jbi.management.DeploymentException {
097: return createDeployResult("deploy", true);
098: }
099:
100: /**
101: * Undeploy a Service Unit from the component.
102: * @param serviceUnitName the name of the Service Unit being undeployed.
103: * @param serviceUnitRootPath the full path to the Service Unit artifact
104: * root directory.
105: * @return an undeployment status message.
106: * @throws javax.jbi.management.DeploymentException if the undeployment
107: * operation is unsuccessful.
108: */
109: public String undeploy(String serviceUnitName,
110: String serviceUnitRootPath)
111: throws javax.jbi.management.DeploymentException {
112: return createDeployResult("undeploy", true);
113: }
114:
115: /* ##################### Utility Methods #################### */
116:
117: /** Creates a (un)deployment result string.
118: * @param task 'deploy' or 'undeploy'
119: */
120: protected String createDeployResult(String task, boolean isSuccess) {
121: return "<component-task-result xmlns=\"http://java.sun.com/xml/ns/jbi/management-message\">"
122: + "<component-name>"
123: + mComponentName
124: + "</component-name>"
125: + "<component-task-result-details>"
126: + "<task-result-details>"
127: + "<task-id>"
128: + task
129: + "</task-id>"
130: + "<task-result>"
131: + (isSuccess ? "SUCCESS" : "FAILED")
132: + "</task-result>"
133: + "</task-result-details>"
134: + "</component-task-result-details>"
135: + "</component-task-result>";
136: }
137:
138: /** Creates a component failure response with a configurable message.
139: * @param task 'deploy' or 'undeploy'
140: */
141: protected String createErrorResult(String task, String msg) {
142: return "<component-task-result xmlns=\"http://java.sun.com/xml/ns/jbi/management-message\">"
143: + "<component-name>"
144: + mComponentName
145: + "</component-name>"
146: + "<component-task-result-details>"
147: + "<task-result-details>"
148: + "<task-id>"
149: + task
150: + "</task-id>"
151: + "<task-result>"
152: + "FAILED"
153: + "</task-result>"
154: + "<message-type>ERROR</message-type>"
155: + "<task-status-msg>"
156: + "<msg-loc-info>"
157: + "<loc-token>JBIWHOOPS</loc-token>"
158: + "<loc-message>"
159: + msg
160: + "</loc-message>"
161: + "</msg-loc-info>"
162: + "</task-status-msg>"
163: + "</task-result-details>"
164: + "</component-task-result-details>"
165: + "</component-task-result>";
166: }
167: }
|