View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/client/src/java/org/astrogrid/community/client/ant/ServiceStatusTask.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/06/18 13:45:19 $</cvs:date>
5    * <cvs:version>$Revision: 1.3 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: ServiceStatusTask.java,v $
9    *   Revision 1.3  2004/06/18 13:45:19  dave
10   *   Merged development branch, dave-dev-200406081614, into HEAD
11   *
12   *   Revision 1.2.60.1  2004/06/17 13:38:58  dave
13   *   Tidied up old CVS log entries
14   *
15   * </cvs:log>
16   *
17   *
18   */
19  package org.astrogrid.community.client.ant ;
20  
21  import java.net.URL;
22  
23  import org.apache.tools.ant.Task ;
24  import org.apache.tools.ant.BuildException ;
25  
26  import org.astrogrid.community.common.service.data.ServiceStatusData ;
27  
28  import org.astrogrid.community.common.policy.service.PolicyService ;
29  import org.astrogrid.community.common.policy.service.PolicyServiceService ;
30  import org.astrogrid.community.common.policy.service.PolicyServiceServiceLocator ;
31  
32  /***
33   * An Ant task to check our service status.
34   * 
35   */
36  public class ServiceStatusTask
37      extends Task
38      {
39      /***
40       * Our debug flag.
41       *
42       */
43      private static final boolean DEBUG_FLAG = true ;
44  
45      /***
46       * Public constructor.
47       *
48       */
49      public ServiceStatusTask()
50          {
51          //
52          // Initialise our base class.
53          super() ;
54          }
55  
56      /***
57       * Public constructor.
58       *
59       */
60      public ServiceStatusTask(Task parent)
61          {
62          //
63          // Initialise our base class.
64          super() ;
65          //
66          // Set our project.
67          setProject(parent.getProject()) ;
68          }
69  
70      /***
71       * Initialise our Task.
72       *
73       */
74      public void init()
75          throws BuildException
76          {
77          if (DEBUG_FLAG) log("----\"----");
78          if (DEBUG_FLAG) log("ServiceStatusTask.init()");
79          }
80  
81      /***
82       * The service type to test.
83       *
84       */
85      private String type ;
86  
87      /***
88       * Get the service type.
89       *
90       */
91      public String getType()
92          {
93          return this.type ;
94          }
95  
96      /***
97       * Set the service type.
98       *
99       */
100     public void setType(String value)
101         {
102         this.type = value ;
103         }
104 
105     /***
106      * The service endpoint address.
107      *
108      */
109     private String address ;
110 
111     /***
112      * Get the service endpoint.
113      *
114      */
115     public String getAddress()
116         {
117         return this.address ;
118         }
119 
120     /***
121      * Set the service endpoint address.
122      *
123      */
124     public void setAddress(String value)
125         {
126         this.address = value ;
127         }
128 
129     /***
130      * Execute our Task.
131      *
132      */
133     public void execute()
134         throws BuildException
135         {
136         if (DEBUG_FLAG) log("----\"----");
137         if (DEBUG_FLAG) log("ServiceStatusTask.execute()");
138         if (DEBUG_FLAG) log("  Address : " + this.getAddress());
139         //
140         // Assume a policy service for now ...
141         try {
142             //
143             // Create our service locator.
144             PolicyServiceService locator = new PolicyServiceServiceLocator();
145             //
146             // Create our URL.
147             URL endpoint = new URL(address) ;
148             //
149             // Create our service.
150             PolicyService service = locator.getPolicyService(endpoint);
151             //
152             // Get the service status.
153             ServiceStatusData status = service.getServiceStatus() ;
154             //
155             // Print out the status.
156             log("Service status") ;
157             log("  Config path   : " + status.getConfigPath()) ;
158             log("  Database name : " + status.getDatabaseName()) ;
159 /*
160  *
161  *
162  */
163             }
164         catch (Exception ouch)
165             {
166             throw new BuildException(ouch) ;
167             }
168         }
169     }
170