KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > common > AbstractDeployer


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.common;
18
19 import org.apache.commons.logging.Log;
20
21 import javax.jbi.JBIException;
22 import javax.jbi.management.DeploymentException;
23
24 /**
25  * Base classes for custom artifacts deployers.
26  *
27  * @author Guillaume Nodet
28  * @version $Revision: 434135 $
29  * @since 3.0
30  */

31 public abstract class AbstractDeployer implements Deployer {
32
33     protected final transient Log logger;
34     
35     protected BaseComponent component;
36     
37     public AbstractDeployer(BaseComponent component) {
38         this.component = component;
39         this.logger = component.logger;
40     }
41     
42     protected DeploymentException failure(String JavaDoc task, String JavaDoc info, Throwable JavaDoc e) {
43         ManagementSupport.Message msg = new ManagementSupport.Message();
44         msg.setComponent(component.getComponentName());
45         msg.setTask(task);
46         msg.setResult("FAILED");
47         msg.setType("ERROR");
48         msg.setMessage(info);
49         msg.setException(e);
50         return new DeploymentException(ManagementSupport.createComponentMessage(msg));
51     }
52
53     public void undeploy(ServiceUnit su) throws DeploymentException {
54         // Force a shutdown of the SU
55
// There is no initialized state, so after deployment, the SU
56
// is shutdown but may need a cleanup.
57
try {
58             su.shutDown();
59         } catch (JBIException e) {
60             throw new DeploymentException("Unable to shutDown service unit", e);
61         }
62     }
63
64 }
65
Popular Tags