1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.astrogrid.deployment ;
15
16 import java.io.File ;
17 import java.net.URL ;
18
19 import org.apache.tools.ant.Task ;
20 import org.apache.tools.ant.BuildException ;
21
22 import org.astrogrid.registry.client.admin.RegistryAdminService ;
23 import org.astrogrid.registry.client.admin.UpdateRegistry;
24
25 /***
26 * An Ant task to load a registry entry to a remote Registry.
27 * @author Paul Harrison (pah@jb.man.ac.uk) 13-Jul-2004
28 * @version $Name: $
29 * @since iteration5
30 */
31 public class RegistryLoaderTask
32 extends Task
33 {
34 public RegistryLoaderTask()
35 {
36 super() ;
37 }
38
39 /***
40 * Public constructor.
41 *
42 */
43 public RegistryLoaderTask(Task parent)
44 {
45 super() ;
46 setProject(parent.getProject()) ;
47 }
48
49 /***
50 * Initialise our Task.
51 *
52 */
53 public void init()
54 throws BuildException
55 {
56
57 }
58
59 /***
60 * Our Registry service endpoint.
61 *
62 */
63 private String registry ;
64
65 /***
66 * Get our Registry service endpoint.
67 *
68 */
69 public String getRegistry()
70 {
71 return this.registry ;
72 }
73
74 /***
75 * Set our Registry service endpoint.
76 *
77 */
78 public void setRegistry(String value)
79 {
80 this.registry = value ;
81 }
82
83 /***
84 * Our Registry data file.
85 *
86 */
87 private String data ;
88
89 /***
90 * Get our Registry data file.
91 *
92 */
93 public String getData()
94 {
95 return this.data ;
96 }
97
98 /***
99 * Set our Registry data file.
100 *
101 */
102 public void setData(String value)
103 {
104 this.data = value ;
105 }
106
107 /***
108 * Execute our Task.
109 *
110 */
111 public void execute()
112 throws BuildException
113 {
114
115 try {
116
117 log("sending "+data+" - to registry at "+ registry);
118
119 RegistryAdminService registry = new UpdateRegistry(
120 new URL(
121 this.registry
122 )
123 ) ;
124
125
126 registry.updateFromFile(
127 new File(
128 this.data
129 )
130 ) ;
131 }
132 catch (Exception ouch)
133 {
134 throw new BuildException(ouch) ;
135 }
136 }
137 }
138