use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class AlarmSystemAdvancedContainerServices method getAny.
@Override
public Any getAny() {
ORB orb = getORB();
org.omg.CORBA.Any any = orb.create_any();
if (any == null) {
// should never happen, but we check just in case,
// since there is a difficult to verify NPE when Any is created by MC for sending alarms.
String msg = "Failed to create org.omg.CORBA.Any";
logger.warning(msg);
throw new NullPointerException(msg);
}
return any;
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class LaserComponent method fromBusinessAlarm.
/**
* Helper method which converts EJB business Alarm to CORBA Alarm structure.
* @param alarm
* @return
*/
private Alarm fromBusinessAlarm(cern.laser.business.data.Alarm alarm) {
cern.laser.business.data.Triplet bt = alarm.getTriplet();
cern.laser.business.data.Location bl = alarm.getLocation();
if (bl.getBuilding() == null) {
bl.setBuilding(new Building("", "", 1, ""));
}
cern.laser.business.data.Status bs = alarm.getStatus();
// Build the properties
Property[] props;
if (alarm.getStatus().getProperties() != null) {
props = new Property[alarm.getStatus().getProperties().size()];
Set keys = alarm.getStatus().getProperties().keySet();
int t = 0;
for (Object key : keys) {
String name = (String) key;
String value = alarm.getStatus().getProperties().getProperty(name);
Any any = corbaServer.getORB().create_any();
any.insert_string(value);
props[t++] = new Property(name, any);
}
} else {
props = new Property[0];
}
Alarm newAlarm = new Alarm(alarm.getAlarmId(), new Triplet(bt.getFaultFamily(), bt.getFaultMember(), bt.getFaultCode().intValue()), getString(alarm.getSystemName()), getString(alarm.getIdentifier()), getString(alarm.getProblemDescription()), alarm.getPriority().intValue(), getString(alarm.getCause()), getString(alarm.getAction()), getString(alarm.getConsequence()), fromBusinessSource(alarm.getSource()), getString(alarm.getHelpURL().toExternalForm()), getString(alarm.getPiquetGSM()), getString(alarm.getPiquetEmail()), fromBusinessResponsiblePerson(alarm.getResponsiblePerson()), new Location(bl.getLocationId(), bl.getFloor(), bl.getRoom(), bl.getPosition(), bl.getMnemonic(), bl.getBuilding().getBuildingNumber(), bl.getBuilding().getSite(), bl.getBuilding().getZone().intValue(), bl.getBuilding().getMap()), fromBusinessCategoryCollection(alarm.getCategories()), new Status(bs.getActive().booleanValue(), bs.getMasked().booleanValue(), bs.getReduced().booleanValue(), new Timestamp(bs.getSourceTimestamp().getTime(), bs.getSourceTimestamp().getNanos()), bs.getSourceHostname(), new Timestamp(bs.getUserTimestamp().getTime(), bs.getUserTimestamp().getNanos()), new Timestamp(bs.getSystemTimestamp().getTime(), bs.getSystemTimestamp().getNanos()), props), alarm.getInstant().booleanValue(), alarm.hasNodeParents(), alarm.hasMultiplicityParents(), alarm.hasNodeChildren(), alarm.hasMultiplicityChildren());
return newAlarm;
}
use of org.omg.CORBA.Any in project cxf by apache.
the class CorbaConduit method getArguments.
public NVList getArguments(CorbaMessage message) {
if (orb == null) {
prepareOrb();
}
// Build the list of DII arguments, returns, and exceptions
NVList list = null;
if (message.getStreamableArguments() != null) {
CorbaStreamable[] arguments = message.getStreamableArguments();
list = orb.create_list(arguments.length);
for (CorbaStreamable argument : arguments) {
Any value = CorbaAnyHelper.createAny(orb);
argument.getObject().setIntoAny(value, argument, true);
list.add_value(argument.getName(), value, argument.getMode());
}
} else {
list = orb.create_list(0);
}
return list;
}
use of org.omg.CORBA.Any in project cxf by apache.
the class CorbaConduit method getReturn.
public NamedValue getReturn(CorbaMessage message) {
if (orb == null) {
prepareOrb();
}
CorbaStreamable retVal = message.getStreamableReturn();
NamedValue ret = null;
if (retVal != null) {
Any returnAny = CorbaAnyHelper.createAny(orb);
retVal.getObject().setIntoAny(returnAny, retVal, false);
ret = orb.create_named_value(retVal.getName(), returnAny, org.omg.CORBA.ARG_OUT.value);
} else {
// for some reason, some ORBs do not like to
// have a null NamedValue return value. Create this 'empty'
// one if a void return type is used.
ret = orb.create_named_value("return", orb.create_any(), org.omg.CORBA.ARG_OUT.value);
}
return ret;
}
use of org.omg.CORBA.Any in project cxf by apache.
the class CorbaStreamInInterceptor method prepareDIIArgsList.
protected NVList prepareDIIArgsList(CorbaMessage corbaMsg, BindingOperationInfo boi, CorbaStreamable[] streamables, List<ParamType> paramTypes, CorbaTypeMap map, ORB orb, ServiceInfo service) {
try {
// Build the list of DII arguments, returns, and exceptions
NVList list = orb.create_list(streamables.length);
OperationInfo opInfo = boi.getOperationInfo();
MessageInfo input = opInfo.getInput();
MessageInfo output = opInfo.getOutput();
String inWrapNSUri = null;
String outWrapNSUri = null;
boolean wrap = false;
if (boi.isUnwrappedCapable()) {
wrap = true;
if (input != null) {
inWrapNSUri = getWrappedParamNamespace(input);
if (!CorbaUtils.isElementFormQualified(service, inWrapNSUri)) {
inWrapNSUri = "";
}
}
if (output != null) {
outWrapNSUri = getWrappedParamNamespace(output);
if (!CorbaUtils.isElementFormQualified(service, outWrapNSUri)) {
outWrapNSUri = "";
}
}
}
int inMsgIndex = 0;
int outMsgIndex = 0;
for (int i = 0; i < paramTypes.size(); i++) {
ParamType param = paramTypes.get(i);
QName paramIdlType = param.getIdltype();
QName paramName;
ModeType paramMode = param.getMode();
if (paramMode.value().equals("in")) {
if (wrap) {
paramName = new QName(inWrapNSUri, param.getName());
} else {
paramName = getMessageParamQName(input, param.getName(), inMsgIndex);
inMsgIndex++;
}
} else {
if (wrap) {
paramName = new QName(outWrapNSUri, param.getName());
} else {
paramName = getMessageParamQName(output, param.getName(), outMsgIndex);
outMsgIndex++;
}
}
CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, paramIdlType, map, service);
streamables[i] = corbaMsg.createStreamableObject(obj, paramName);
Any value = CorbaAnyHelper.createAny(orb);
if (paramMode.value().equals("in")) {
streamables[i].setMode(org.omg.CORBA.ARG_IN.value);
streamables[i].getObject().setIntoAny(value, streamables[i], false);
} else if (paramMode.value().equals("out")) {
streamables[i].setMode(org.omg.CORBA.ARG_OUT.value);
streamables[i].getObject().setIntoAny(value, streamables[i], true);
} else {
streamables[i].setMode(org.omg.CORBA.ARG_INOUT.value);
streamables[i].getObject().setIntoAny(value, streamables[i], false);
}
list.add_value(streamables[i].getName(), value, streamables[i].getMode());
corbaMsg.addStreamableArgument(streamables[i]);
}
return list;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
Aggregations