-
Notifications
You must be signed in to change notification settings - Fork 6
/
InfoResource.java
63 lines (49 loc) · 2.38 KB
/
InfoResource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Licensed Materials - Property of IBM */
/* */
/* SAMPLE */
/* */
/* (c) Copyright IBM Corp. 2016 All Rights Reserved */
/* */
/* US Government Users Restricted Rights - Use, duplication or disclosure */
/* restricted by GSA ADP Schedule Contract with IBM Corp */
/* */
package com.ibm.cicsdev.restapp;
import java.util.Calendar;
import java.util.TimeZone;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import com.ibm.cicsdev.restapp.bean.CICSEnvironment;
import com.ibm.cicsdev.restapp.bean.CICSInformation;
@Path("cicsinfo")
@Produces( MediaType.APPLICATION_JSON )
public class InfoResource {
/**
* Formatting string used to produce an ISO-8601 standard timestamp.
*/
private static final String ISO8601_FORMAT = "%tFT%<tT.%<tLZ";
/**
* RESTful web application that returns information about the CICS environment.
*/
@GET
public CICSInformation getCICSInformation() {
// Establish the CICS environment bean
CICSEnvironment env = new CICSEnvironment();
// Initialise with system property values
env.setProd(System.getProperty("com.ibm.cics.jvmserver.cics.product.name", "Not available prior to V5.3"));
env.setCicsVer(System.getProperty("com.ibm.cics.jvmserver.cics.product.version", "Not available prior to V5.3"));
// Establish the CICS information bean
CICSInformation info = new CICSInformation();
// Initialise with system property values
info.setApplid(System.getProperty("com.ibm.cics.jvmserver.applid"));
info.setJvmServer(System.getProperty("com.ibm.cics.jvmserver.name"));
// Format the current time to ISO 8601 standards
Calendar nowUTC = Calendar.getInstance(TimeZone.getTimeZone("Z"));
info.setTime(String.format(ISO8601_FORMAT, nowUTC));
// Add the environment information
info.setEnv(env);
// Return to the user
return info;
}
}