Saturday, 3 December 2022

Retrieve context value from context file

Compile java code like below

$ javac GetContext.java
$ cp –p GetContext.class $JAVA_TOP/oracle/apps/ad/context/
$ java oracle.apps.ad.context.GetContext
[you will see the usage syntax]

-bash-5.1$ java oracle.apps.ad.context.GetContext $CONTEXT_FILE s_ohs_instance

EBS_web_OHS1

Here is the java code:
package oracle.apps.ad.context;
import java.io.File;
import java.io.PrintStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import oracle.apps.ad.util.SystemCheck;
public class GetContext
{
public GetContext() {
}
public GetContext(String param) throws Exception {
if (param == null)
throw new IllegalArgumentException("sVars cannot be null/empty");
OAVars oavars = new OAVars(param);
AppsContext appscontext = new AppsContext(param);
String s4 = oavars.getVal("s_at");
System.out.println("Appl Top = " + s4);
}
public GetContext(String ctxFile, String param) {
if (param == null)
throw new IllegalArgumentException("sVars cannot be null/empty");
if (ctxFile == null)
throw new IllegalArgumentException("sVars cannot be null/empty");
OAVars oavars = new OAVars(ctxFile);
AppsContext appscontext = new AppsContext(ctxFile);
String s4 = oavars.getVal(param);
System.out.println(param + " = " + s4);
}
public static void main(String args[])
{
if(args.length == 2)
{
try
{
new GetContext(args[0], args[1]);
}
catch(Exception exception)
{
exception.printStackTrace();
}
System.exit(0);
return;
}
else if(args.length == 1)
{
try
{
new GetContext(args[0]);
}
catch(Exception exception)
{
exception.printStackTrace();
}
System.exit(0);
return;
}
else
{
exitWithUsage();
return;
}
}
public static void exitWithUsage()
{
System.out.println("nnusage:n");
System.out.println(" java oracle.apps.ad.context.GetContext");
System.out.println(" CONTEXT NAME n");
System.out.println(" where:");
System.out.println(" CONTEXT = the path to the Oracle Applications Context file");
System.out.println(" NAME = the name of the variable whose value is required");
System.exit(1);
}
}

No comments:

Post a Comment