📄 ctinterface.java
字号:
package com.corba.mnq.tool.idl.type;
import com.corba.mnq.main.CorbaMNQ;
import com.corba.mnq.skelstub.DsiImpl;
import com.corba.mnq.tool.EtcProperties;
import com.corba.mnq.tool.GetEtcTool;
import com.corba.mnq.tool.Warehouse;
import com.corba.mnq.tool.idl.IdlInterface;
import com.corba.mnq.ui.ArgsTable;
import java.util.Date;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Logger;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.OutputStream;
import org.omg.PortableServer.Servant;
public class CTInterface extends TypeBase {
// Whether to provide the default valid interface value in client
// input or servant output
public static boolean defaultInf = false;
/** used for java.util.logging */
private static final Logger LOG = Logger.getLogger(CTInterface.class.getName());
private static EtcProperties props;
static {
props = GetEtcTool.getProperties();
defaultInf = props.getProperty("CorbaMNQ.idl.defaultInterface", "false").equalsIgnoreCase(
"true");
}
/**
* @param args
*/
public static void main_(String[] args) {
// TODO Auto-generated method stub
}
public CTInterface() {
super();
// TODO Auto-generated constructor stub
valType = "java.lang.String";
}
public TypeBase cloneType() {
CTInterface t = new CTInterface();
t.disName = disName;
t.dmtn = dmtn;
t.dn = dn;
t.id = id;
t.rdn = rdn;
t.val = val;
return t;
}
public boolean compare(TypeBase t) {
if (!selected)
return true;
if (!type().equal(t.type()))
return false;
if (!match(strval, t.strval))
return false;
return true;
}
private void getDefaultInf() {
try {
IdlInterface in;
LOG.info(dn);
in = (IdlInterface) Warehouse.cname2node.get(dn);
// store the default ior
String ior = "";
// obtain the default ior from the first one
if (in.servants.isEmpty()) {
// create one servant.
String tag = in.createTag();//new Date().toString().replaceAll("\\s+", "_") + rdn;
Servant servant = new DsiImpl(TypeBase.orb, in);
CorbaMNQ.poa.activate_object_with_id(tag.getBytes(), servant);
org.omg.CORBA.Object o = CorbaMNQ.poa.servant_to_reference(servant);
String ior_new = TypeBase.orb.object_to_string(o);
in.servants.put(tag, ior_new);
ior = ior_new;
} else {
// get the first entry
Set entrys = in.servants.keySet();
for (Iterator i = entrys.iterator(); i.hasNext();) {
String tag = (String) i.next();
ior = (String) in.servants.get(tag);
break;
}
}
// set the value to tree
setStrValue(ior);
setValueToTree(ior);
} catch (Exception e) {
// e.printStackTrace();
LOG.severe(e.getMessage());
}
}
public void getValueFromTree() {
ArgsTable table = (ArgsTable) Warehouse.node2table.get(dmtn);
String text = table.getInputValue();
strval = text;
org.omg.CORBA.Object obj;
try {
obj = orb.string_to_object(text);
} catch (Exception ex) {
// update :-)
if (defaultInf) {
getDefaultInf();
}
return;
}
if (obj == null) {
// update :-)
if (defaultInf) {
getDefaultInf();
}
} else {
val = obj;
}
}
public void setStrValue(String str) {
String text = str;
strval = str;
org.omg.CORBA.Object obj;
try {
obj = orb.string_to_object(text);
} catch (Exception ex) {
return;
}
if (obj == null) {
// nothing to do
} else {
val = obj;
}
}
public TypeCode type() {
// TODO Auto-generated method stub
TypeCode __typeCode;
__typeCode = org.omg.CORBA.ORB.init().create_interface_tc(id, rdn);
return __typeCode;
}
/**
* Method: "read"
*
* @param istream
* @return
*/
public Object read(org.omg.CORBA.portable.InputStream istream) {
org.omg.CORBA.Object value = istream.read_Object();
String ret = orb.object_to_string(value);
return ret;
}
public void write(OutputStream ostream, Object value) {
if (value instanceof String) {
org.omg.CORBA.Object obj = null;
try {
obj = orb.string_to_object((String) value);
} catch (Exception ex) {
// nothing to do
}
value = obj;
}
// TODO Auto-generated method stub
ostream.write_Object((org.omg.CORBA.Object) value);
}
}
/* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -