package oracle.demo.topdownrpc.service;
import javax.xml.rpc.holders.StringHolder;
import javax.xml.rpc.holders.IntHolder;
import javax.xml.rpc.holders.FloatHolder;
import java.rmi.RemoteException;
import java.util.logging.*;
import java.io.StringWriter;
import java.io.PrintWriter;
import oracle.demo.topdownrpc.types.*;
public class RpcLitTopdownImpl implements SoapTestPortTypeRpc{
private Logger m_logger;
public RpcLitTopdownImpl(){
m_logger = Logger.getAnonymousLogger
("oracle.demo.topdownrpc.service.RpcLitTopdownImpl");
m_logger.setLevel(Level.ALL);
SimpleFormatter formatter = getFormatter();
m_logger.setUseParentHandlers(false);
m_logger.addHandler(new StreamHandler(System.out,formatter){
public synchronized void publish(LogRecord record){
super.publish(record);
flush();
}
});
}
private SimpleFormatter getFormatter() {
return new SimpleFormatter(){
public synchronized String format(LogRecord record){
StringBuffer sb = new StringBuffer();
String message = formatMessage(record);
sb.append(record.getLevel().getLocalizedName());
sb.append(": ");
sb.append(message);
sb.append(System.getProperty("line.separator"));
if(record.getThrown() != null){
try{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
record.getThrown().printStackTrace(pw);
pw.close();
}
catch(Exception ex){
}
}
return sb.toString();
}
};
}
public SOAPStruct echoStruct(SOAPStruct inputStruct) throws
RemoteException {
String floatVal = "" + inputStruct.getVarFloat();
String intVal = "" + inputStruct.getVarInt();
String sVal = "" + inputStruct.getVarString();
m_logger.log(Level.INFO,"demo.structdata.msg",new Object[]{floatVal,intVal,sVal});
return inputStruct;
}
public ArrayOfSOAPStruct echoStructArray(ArrayOfSOAPStruct inputStructArray) throws
RemoteException {
SOAPStruct[] structs = inputStructArray.getStructItem();
Integer count = new Integer(structs.length);
m_logger.log(Level.INFO, "demo.echoStructArray.count",count);
for(int i = 0; i < structs.length;i++){
m_logger.log(Level.INFO,"demo.echoStructArray.msg",new Object[]{
new String() + i,
new String() + structs[i].getVarFloat(),
new String() + structs[i].getVarInt(),
structs[i].getVarString()
});
}
return inputStructArray;
}
public void echoStructAsSimpleTypes(SOAPStruct inputStruct,
StringHolder outputString,
IntHolder outputInteger,
FloatHolder outputFloat)
throws RemoteException {
m_logger.log(Level.INFO, "demo.structdata.msg",new Object[]{
"" + inputStruct.getVarFloat(),
"" + inputStruct.getVarInt(),
"" + inputStruct.getVarString()
});
outputString.value = inputStruct.getVarString();
outputInteger.value = inputStruct.getVarInt();
outputFloat.value = inputStruct.getVarFloat();
}
public SOAPStruct echoSimpleTypesAsStruct(String inputString,
int inputInteger,
float inputFloat)
throws RemoteException {
m_logger.log(Level.INFO, "demo.structdata.msg",new Object[]{
"" + inputFloat,
"" + inputInteger,
inputString
});
return new SOAPStruct(inputString,inputInteger,inputFloat);
}
public SOAPStructStruct echoNestedStruct(SOAPStructStruct inputStruct)
throws RemoteException {
m_logger.log(Level.INFO, "demo.structdata.msg1",new Object[]{
"top level stuct data",
"" + inputStruct.getVarFloat(),
"" + inputStruct.getVarInt(),
inputStruct.getVarString()
});
m_logger.log(Level.INFO, "demo.structdata.msg1",new Object[]{
"nested level stuct data",
"" + inputStruct.getStructItem().getVarFloat(),
"" + inputStruct.getStructItem().getVarInt(),
inputStruct.getStructItem().getVarString()
});
return inputStruct;
}
public SOAPArrayStruct echoNestedArray(SOAPArrayStruct inputStruct) throws
RemoteException {
m_logger.log(Level.INFO, "demo.structdata.msg",new Object[]{
"" + inputStruct.getVarFloat(),
"" + inputStruct.getVarInt(),
inputStruct.getVarString()
});
ArrayOfstring aos = inputStruct.getVarArray();
String array[] = aos.getStringItem();
for(int i = 0; i < array.length;i++){
m_logger.log(Level.INFO, "demo.stringarraydata.msg",new Object[]{
"String",
"" + i,
array[i]
});
}
return inputStruct;
}
public ArrayOfstring echoStringArray(ArrayOfstring inputStringArray) throws
RemoteException {
String array[] = inputStringArray.getStringItem();
for(int i = 0; i < array.length;i++){
m_logger.log(Level.INFO, "demo.stringarraydata.msg",new Object[]{
"String",
"" + i,
array[i]
});
}
return inputStringArray;
}
public ArrayOfint echoIntegerArray(ArrayOfint inputIntegerArray)
throws RemoteException {
int array[] = inputIntegerArray.getInteger();
for(int i = 0; i < array.length;i++){
m_logger.log(Level.INFO, "demo.stringarraydata.msg",new Object[]{
"Integer",
"" + i,
"" + array[i]
});
}
return inputIntegerArray;
}
public boolean echoBoolean(boolean inputBoolean) throws RemoteException {
m_logger.log(Level.INFO,"demo.echoData.msg",new Object[]{
"boolean",
"" + inputBoolean
});
return inputBoolean;
}
public String echoString(String inputString) throws
RemoteException {
m_logger.log(Level.INFO,"demo.echoData.msg",new Object[]{
"String",
inputString
});
return inputString;
}
}
|