Subversion Repositories XServices

Rev

Rev 87 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 87 Rev 97
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
package net.brutex.xservices.ws.impl;
17
package net.brutex.xservices.ws.impl;
18
 
18
 
19
import java.util.Enumeration;
-
 
Line 20... Line 19...
20
import java.util.Properties;
19
import java.util.Enumeration;
-
 
20
import java.util.Properties;
21
import java.util.UUID;
21
 
22
 
-
 
23
import javax.jws.WebService;
22
import javax.jws.WebService;
24
import net.brutex.xservices.types.HostConnection;
23
import net.brutex.xservices.types.FileSetResource;
25
import net.brutex.xservices.types.HostinfoType;
-
 
26
import net.brutex.xservices.types.MailMimeType;
-
 
27
import net.brutex.xservices.types.ReturnCode;
24
import net.brutex.xservices.types.HostConnection;
28
import net.brutex.xservices.types.RuntimeInfoType;
25
import net.brutex.xservices.types.MailMimeType;
29
import net.brutex.xservices.types.ant.FileSetResource;
26
import net.brutex.xservices.types.ReturnCode;
Line 30... Line 27...
30
import net.brutex.xservices.util.BrutexNamespaces;
27
import net.brutex.xservices.util.BrutexNamespaces;
Line 36... Line 33...
36
import org.apache.tools.ant.taskdefs.HostInfo;
33
import org.apache.tools.ant.taskdefs.HostInfo;
37
import org.apache.tools.ant.taskdefs.Sleep;
34
import org.apache.tools.ant.taskdefs.Sleep;
38
import org.apache.tools.ant.taskdefs.email.EmailTask;
35
import org.apache.tools.ant.taskdefs.email.EmailTask;
Line 39... Line 36...
39
 
36
 
40
/**
-
 
41
 * Implements the web service
37
/**
42
 * 
38
 * 
43
 * @author Brian Rosenberger, bru@brutex.de
39
 * @author Brian Rosenberger, bru@brutex.de
-
 
40
 */
-
 
41
@WSDLDocumentationCollection({
-
 
42
		@WSDLDocumentation("My portType documentation"),
-
 
43
		@WSDLDocumentation(value = "My top level documentation", placement = WSDLDocumentation.Placement.TOP),
-
 
44
		@WSDLDocumentation(value = "My binding doc", placement = WSDLDocumentation.Placement.BINDING) })
44
 */
45
@WebService(
45
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, 
46
		targetNamespace = BrutexNamespaces.WS_XSERVICES, 
46
		endpointInterface = "net.brutex.xservices.ws.MiscService", 
47
		endpointInterface = "net.brutex.xservices.ws.MiscService", 
-
 
48
		serviceName = "MiscService"
47
		serviceName = "MiscService")
49
			)
Line 48... Line 50...
48
public class MiscServiceImpl implements MiscService {
50
public class MiscServiceImpl implements MiscService {
49
 
-
 
50
	public HostinfoType getHostinfo(String hostname) {
-
 
51
		HostInfo info = new HostInfo();
-
 
52
		info.setTaskName("HostInfo");
51
 
53
		RunTask runner = new RunTask(info);
-
 
54
		info.setHost(hostname);
-
 
55
		// info.setPrefix(prefix);
52
	@WSDLDocumentation(value = "Get information about a host.")
56
		// TODO: Does not work for IP Addresses?
-
 
57
		ReturnCode ret = runner.postTask();
-
 
58
		HostinfoType infotype = new HostinfoType(
-
 
59
				ret.getProperty("NAME"),
-
 
60
				ret.getProperty("DOMAIN"), 
-
 
61
				ret.getProperty("ADDR4"),
-
 
62
				ret.getProperty("ADDR6"));
53
	public ReturnCode getHostinfo(String hostname) {
63
		return infotype;
54
		return antGetHostinfo(hostname, null);
-
 
55
	}
64
	}
56
	
65
 
57
	@WSDLDocumentation(value = "Get XService information.")
66
	public ReturnCode getInfo() {
58
	public ReturnCode getInfo() {
67
		ReturnCode r = new ReturnCode();
59
		ReturnCode r = new ReturnCode();
68
		r.returnCode = 0;
60
		r.returnCode = 0;
Line 69... Line 61...
69
		// Get all system properties
61
		// Get all system properties
70
		Properties props = System.getProperties();
-
 
71
 
62
		Properties props = System.getProperties();
72
		// Enumerate all system properties
63
 
73
		@SuppressWarnings("unchecked")
64
		// Enumerate all system properties
74
		Enumeration<String> e = (Enumeration<String>) props.propertyNames();
65
		Enumeration<String> e = (Enumeration<String>) props.propertyNames();
75
		for (; e.hasMoreElements();) {
66
		for (; e.hasMoreElements(); ) {
76
			// Get property name
67
		    // Get property name
77
			String propName = (String) e.nextElement();
68
		    String propName = (String)e.nextElement();
78
 
69
 
79
			// Get property value
70
		    // Get property value
Line 80... Line 71...
80
			String propValue = (String) props.get(propName);
71
		    String propValue = (String)props.get(propName);
81
			r.stdOut = r.stdOut + propName + ": " + propValue + "\n";
72
		    r.stdOut = r.stdOut + propName + ": " + propValue + "\n";
Line -... Line 73...
-
 
73
		}
82
		}
74
 
83
 
75
		return r;
84
		return r;
76
	}
85
	}
77
 
86
 
78
 
Line 110... Line 102...
110
 
102
 
111
	public ReturnCode sleep(int minutes, int seconds) {
103
	public ReturnCode sleep(int minutes, int seconds) {
112
		return sleep(0, minutes, seconds, 0);
104
		return sleep(0, minutes, seconds, 0);
Line -... Line 105...
-
 
105
	}
113
	}
106
 
-
 
107
	private ReturnCode antGetHostinfo(String hostname, String prefix) {
-
 
108
		HostInfo info = new HostInfo();
-
 
109
		info.setTaskName("HostInfo");
-
 
110
		RunTask runner = new RunTask(info);
114
 
111
		info.setHost(hostname);
115
	public String generateUUID() {
112
		// info.setPrefix(prefix);
Line 116... Line 113...
116
		return UUID.randomUUID().toString();
113
		return runner.postTask();
117
	}
114
	}
118
 
115
 
Line 154... Line 151...
154
		sleep.setMinutes(minutes);
151
		sleep.setMinutes(minutes);
155
		sleep.setSeconds(seconds);
152
		sleep.setSeconds(seconds);
156
		sleep.setMilliseconds(milliseconds);
153
		sleep.setMilliseconds(milliseconds);
157
		return runner.postTask();
154
		return runner.postTask();
158
	}
155
	}
159
 
-
 
160
	public RuntimeInfoType getMemory() {
-
 
161
		return new RuntimeInfoType();
-
 
162
	}
-
 
163
}
156
}