KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > tools > ant > managers > InstallerAntTaskAbstract


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: AntTaskInstaller.java 09:02:38 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.tools.ant.managers;
23
24 import java.net.URL JavaDoc;
25
26 import javax.management.MBeanServerConnection JavaDoc;
27
28 import org.apache.tools.ant.BuildException;
29 import org.objectweb.petals.tools.ant.util.JBIJMXConnectorUtil;
30
31 /**
32  * This class is used to install or deploy a JBI component, shared library or
33  * service assembly
34  *
35  * @author ddesjardins - eBMWebsourcing
36  */

37 public abstract class InstallerAntTaskAbstract extends JBIAntTaskAbstract {
38
39     /**
40      * Action : installSharedLibrary
41      */

42     protected static final String JavaDoc INSTALL_SHARED_LIBRARY = "installSharedLibrary";
43
44     /**
45      * Action : loadNewInstaller
46      */

47     protected static final String JavaDoc LOAD_NEW_INSTALLED = "loadNewInstaller";
48
49     /**
50      * Fully qualified installation file path name
51      */

52     protected String JavaDoc file;
53
54     /**
55      * Perform a Install or Deploy action
56      *
57      * @param action
58      * @return
59      * @throws Exception
60      */

61     protected Object JavaDoc performInstall(MBeanServerConnection JavaDoc connection,
62             String JavaDoc action) throws Exception JavaDoc {
63         if (file == null) {
64             throw new BuildException("Required attribute : file");
65         }
66         // Test if the provided file name is a correct URL
67
new URL JavaDoc(file);
68         Object JavaDoc[] objects = new Object JavaDoc[1];
69         objects[0] = file;
70         String JavaDoc[] strings = new String JavaDoc[1];
71         strings[0] = "java.lang.String";
72         Object JavaDoc result = connection.invoke(JBIJMXConnectorUtil
73                 .getInstallationServiceMBeanName(connection), action, objects,
74                 strings);
75         return result;
76     }
77
78     public void setFile(String JavaDoc file) {
79         this.file = file;
80     }
81
82 }
83
Popular Tags