KickJava   Java API By Example, From Geeks To Geeks.

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


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 a shared library
26  * @version $Revision: 359151 $
27  */

28 public class InstallSharedLibraryTask extends JbiTask {
29     
30     private String JavaDoc file; //shared library URI to install
31

32     /**
33      * @return Returns the file.
34      */

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

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

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