KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jbi > management > task > DeployServiceAssemblyTask


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.jbi.management.task;
18
19 import java.io.File JavaDoc;
20
21 import org.apache.servicemix.jbi.framework.AdminCommandsServiceMBean;
22 import org.apache.tools.ant.BuildException;
23
24 /**
25  * Install an Assembly
26  *
27  * @version $Revision: 427204 $
28  */

29 public class DeployServiceAssemblyTask extends JbiTask {
30     
31     private String JavaDoc file; //archivePath to install
32

33     /**
34      * @return Returns the archivePath.
35      */

36     public String JavaDoc getFile() {
37         return file;
38     }
39     /**
40      * @param file The archivePath to set.
41      */

42     public void setFile(String JavaDoc file) {
43         this.file = file;
44     }
45     
46     /**
47      * execute the task
48      * @throws BuildException
49      */

50     public void doExecute(AdminCommandsServiceMBean acs) throws Exception JavaDoc {
51         if (file == null){
52             throw new BuildException("null file - file should be an archive");
53         }
54         if (!file.endsWith(".zip") && !file.endsWith(".jar")) {
55             throw new BuildException("file: " + file + " is not an archive");
56         }
57         File JavaDoc archive = new File JavaDoc(file);
58         String JavaDoc location = archive.getAbsolutePath();
59         if (!archive.isFile()) {
60             // if it's not a file, assume it's a url and pass it along
61
location = file;
62         }
63         acs.deployServiceAssembly(location);
64     }
65     
66 }
Popular Tags