下面列出了怎么用org.omg.CORBA.NamedValue的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* See RequestInfoImpl for javadoc.
*/
public Any result (){
checkAccess( MID_RESULT );
if( cachedResult == null ) {
if( request == null ) {
throw stdWrapper.piOperationNotSupported5() ;
}
// Get the result from the DII request data.
NamedValue nvResult = request.result( );
if( nvResult == null ) {
throw wrapper.piDiiResultIsNull() ;
}
cachedResult = nvResult.value();
}
// Good citizen: In the interest of efficiency, we assume that
// interceptors will not modify the contents of the result Any.
// Otherwise, we would need to create a deep copy of the Any.
return cachedResult;
}
/** This is called from the ORB after the DynamicImplementation.invoke
* returns. Here we marshal the return value and inout/out params.
*/
public void marshalReplyParams(OutputStream os)
{
// marshal the operation return value
_resultAny.write_value(os);
// marshal the inouts/outs
NamedValue arg = null;
for (int i=0; i < _arguments.count() ; i++) {
try {
arg = _arguments.item(i);
} catch (Bounds e) {}
if ((arg.flags() == org.omg.CORBA.ARG_OUT.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
arg.value().write_value(os);
}
}
}
/** This is called from the ORB after the DynamicImplementation.invoke
* returns. Here we marshal the return value and inout/out params.
*/
public void marshalReplyParams(OutputStream os)
{
// marshal the operation return value
_resultAny.write_value(os);
// marshal the inouts/outs
NamedValue arg = null;
for (int i=0; i < _arguments.count() ; i++) {
try {
arg = _arguments.item(i);
} catch (Bounds e) {}
if ((arg.flags() == org.omg.CORBA.ARG_OUT.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
arg.value().write_value(os);
}
}
}
/**
* See RequestInfoImpl for javadoc.
*/
public Any result (){
checkAccess( MID_RESULT );
if( cachedResult == null ) {
if( request == null ) {
throw stdWrapper.piOperationNotSupported5() ;
}
// Get the result from the DII request data.
NamedValue nvResult = request.result( );
if( nvResult == null ) {
throw wrapper.piDiiResultIsNull() ;
}
cachedResult = nvResult.value();
}
// Good citizen: In the interest of efficiency, we assume that
// interceptors will not modify the contents of the result Any.
// Otherwise, we would need to create a deep copy of the Any.
return cachedResult;
}
/**
* See RequestInfoImpl for javadoc.
*/
public Any result (){
checkAccess( MID_RESULT );
if( cachedResult == null ) {
if( request == null ) {
throw stdWrapper.piOperationNotSupported5() ;
}
// Get the result from the DII request data.
NamedValue nvResult = request.result( );
if( nvResult == null ) {
throw wrapper.piDiiResultIsNull() ;
}
cachedResult = nvResult.value();
}
// Good citizen: In the interest of efficiency, we assume that
// interceptors will not modify the contents of the result Any.
// Otherwise, we would need to create a deep copy of the Any.
return cachedResult;
}
/** This is called from the ORB after the DynamicImplementation.invoke
* returns. Here we marshal the return value and inout/out params.
*/
public void marshalReplyParams(OutputStream os)
{
// marshal the operation return value
_resultAny.write_value(os);
// marshal the inouts/outs
NamedValue arg = null;
for (int i=0; i < _arguments.count() ; i++) {
try {
arg = _arguments.item(i);
} catch (Bounds e) {}
if ((arg.flags() == org.omg.CORBA.ARG_OUT.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
arg.value().write_value(os);
}
}
}
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;
}
/** This is called from the ORB after the DynamicImplementation.invoke
* returns. Here we marshal the return value and inout/out params.
*/
public void marshalReplyParams(OutputStream os)
{
// marshal the operation return value
_resultAny.write_value(os);
// marshal the inouts/outs
NamedValue arg = null;
for (int i=0; i < _arguments.count() ; i++) {
try {
arg = _arguments.item(i);
} catch (Bounds e) {}
if ((arg.flags() == org.omg.CORBA.ARG_OUT.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
arg.value().write_value(os);
}
}
}
/**
* See RequestInfoImpl for javadoc.
*/
public Any result (){
checkAccess( MID_RESULT );
if( cachedResult == null ) {
if( request == null ) {
throw stdWrapper.piOperationNotSupported5() ;
}
// Get the result from the DII request data.
NamedValue nvResult = request.result( );
if( nvResult == null ) {
throw wrapper.piDiiResultIsNull() ;
}
cachedResult = nvResult.value();
}
// Good citizen: In the interest of efficiency, we assume that
// interceptors will not modify the contents of the result Any.
// Otherwise, we would need to create a deep copy of the Any.
return cachedResult;
}
/**
* See RequestInfoImpl for javadoc.
*/
public Any result (){
checkAccess( MID_RESULT );
if( cachedResult == null ) {
if( request == null ) {
throw stdWrapper.piOperationNotSupported5() ;
}
// Get the result from the DII request data.
NamedValue nvResult = request.result( );
if( nvResult == null ) {
throw wrapper.piDiiResultIsNull() ;
}
cachedResult = nvResult.value();
}
// Good citizen: In the interest of efficiency, we assume that
// interceptors will not modify the contents of the result Any.
// Otherwise, we would need to create a deep copy of the Any.
return cachedResult;
}
@Test
public void testBuildReturn() throws Exception {
Message msg = new MessageImpl();
CorbaMessage message = new CorbaMessage(msg);
QName objName = new QName("returnName");
QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
CorbaStreamable arg = message.createStreamableObject(obj1, objName);
CorbaConduit conduit = setupCorbaConduit(false);
NamedValue ret = conduit.getReturn(message);
assertNotNull("Return should not be null", ret != null);
assertEquals("name should be equal", ret.name(), "return");
message.setStreamableReturn(arg);
NamedValue ret2 = conduit.getReturn(message);
assertNotNull("Return2 should not be null", ret2 != null);
assertEquals("name should be equal", ret2.name(), "returnName");
}
/** This is called from the ORB after the DynamicImplementation.invoke
* returns. Here we marshal the return value and inout/out params.
*/
public void marshalReplyParams(OutputStream os)
{
// marshal the operation return value
_resultAny.write_value(os);
// marshal the inouts/outs
NamedValue arg = null;
for (int i=0; i < _arguments.count() ; i++) {
try {
arg = _arguments.item(i);
} catch (Bounds e) {}
if ((arg.flags() == org.omg.CORBA.ARG_OUT.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
arg.value().write_value(os);
}
}
}
/** This is called from the ORB after the DynamicImplementation.invoke
* returns. Here we marshal the return value and inout/out params.
*/
public void marshalReplyParams(OutputStream os)
{
// marshal the operation return value
_resultAny.write_value(os);
// marshal the inouts/outs
NamedValue arg = null;
for (int i=0; i < _arguments.count() ; i++) {
try {
arg = _arguments.item(i);
} catch (Bounds e) {}
if ((arg.flags() == org.omg.CORBA.ARG_OUT.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
arg.value().write_value(os);
}
}
}
public void unmarshalReply(InputStream is)
{
// First unmarshal the return value if it is not void
if ( _result != null ) {
Any returnAny = _result.value();
TypeCode returnType = returnAny.type();
if ( returnType.kind().value() != TCKind._tk_void )
returnAny.read_value(is, returnType);
}
// Now unmarshal the out/inout args
try {
for ( int i=0; i<_arguments.count() ; i++) {
NamedValue nv = _arguments.item(i);
switch( nv.flags() ) {
case ARG_IN.value:
break;
case ARG_OUT.value:
case ARG_INOUT.value:
Any any = nv.value();
any.read_value(is, any.type());
break;
}
}
}
catch ( org.omg.CORBA.Bounds ex ) {
// Cannot happen since we only iterate till _arguments.count()
}
}
public Request create_request(org.omg.CORBA.Object obj,
Context ctx,
String operation,
NVList arg_list,
NamedValue result,
ExceptionList exclist,
ContextList ctxlist)
{
return new RequestImpl(orb, obj, ctx, operation, arg_list, result,
exclist, ctxlist);
}
public void unmarshalReply(InputStream is)
{
// First unmarshal the return value if it is not void
if ( _result != null ) {
Any returnAny = _result.value();
TypeCode returnType = returnAny.type();
if ( returnType.kind().value() != TCKind._tk_void )
returnAny.read_value(is, returnType);
}
// Now unmarshal the out/inout args
try {
for ( int i=0; i<_arguments.count() ; i++) {
NamedValue nv = _arguments.item(i);
switch( nv.flags() ) {
case ARG_IN.value:
break;
case ARG_OUT.value:
case ARG_INOUT.value:
Any any = nv.value();
any.read_value(is, any.type());
break;
}
}
}
catch ( org.omg.CORBA.Bounds ex ) {
// Cannot happen since we only iterate till _arguments.count()
}
}
public Request create_request(org.omg.CORBA.Object obj,
Context ctx,
String operation,
NVList arg_list,
NamedValue result,
ExceptionList exclist,
ContextList ctxlist)
{
return new RequestImpl(orb, obj, ctx, operation, arg_list, result,
exclist, ctxlist);
}
public NamedValue item(int index)
throws Bounds
{
try {
return (NamedValue) _namedValues.elementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
throw new Bounds();
}
}
public NamedValue item(int index)
throws Bounds
{
try {
return (NamedValue) _namedValues.elementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
throw new Bounds();
}
}
public Request create_request(org.omg.CORBA.Object obj,
Context ctx,
String operation,
NVList arg_list,
NamedValue result)
{
return new RequestImpl(orb, obj, ctx, operation, arg_list,
result, null, null);
}
public NamedValue add_item(String itemName, int flags)
{
NamedValue tmpVal = new NamedValueImpl(orb, itemName, new AnyImpl(orb),
flags);
_namedValues.addElement(tmpVal);
return tmpVal;
}
public void unmarshalReply(InputStream is)
{
// First unmarshal the return value if it is not void
if ( _result != null ) {
Any returnAny = _result.value();
TypeCode returnType = returnAny.type();
if ( returnType.kind().value() != TCKind._tk_void )
returnAny.read_value(is, returnType);
}
// Now unmarshal the out/inout args
try {
for ( int i=0; i<_arguments.count() ; i++) {
NamedValue nv = _arguments.item(i);
switch( nv.flags() ) {
case ARG_IN.value:
break;
case ARG_OUT.value:
case ARG_INOUT.value:
Any any = nv.value();
any.read_value(is, any.type());
break;
}
}
}
catch ( org.omg.CORBA.Bounds ex ) {
// Cannot happen since we only iterate till _arguments.count()
}
}
public NamedValue add_item(String itemName, int flags)
{
NamedValue tmpVal = new NamedValueImpl(orb, itemName, new AnyImpl(orb),
flags);
_namedValues.addElement(tmpVal);
return tmpVal;
}
public Request create_request(org.omg.CORBA.Object obj,
Context ctx,
String operation,
NVList arg_list,
NamedValue result)
{
return new RequestImpl(orb, obj, ctx, operation, arg_list,
result, null, null);
}
public Request create_request(org.omg.CORBA.Object obj,
Context ctx,
String operation,
NVList arg_list,
NamedValue result,
ExceptionList exclist,
ContextList ctxlist)
{
return new RequestImpl(orb, obj, ctx, operation, arg_list, result,
exclist, ctxlist);
}
/**
* Internal utility method to convert an NVList into a PI Parameter[]
*/
protected Parameter[] nvListToParameterArray( NVList parNVList ) {
// _REVISIT_ This utility method should probably be doing a deep
// copy so interceptor can't accidentally change the arguments.
int count = parNVList.count();
Parameter[] plist = new Parameter[count];
try {
for( int i = 0; i < count; i++ ) {
Parameter p = new Parameter();
plist[i] = p;
NamedValue nv = parNVList.item( i );
plist[i].argument = nv.value();
// ParameterMode spec can be found in 99-10-07.pdf
// Section:10.5.22
// nv.flags spec can be found in 99-10-07.pdf
// Section 7.1.1
// nv.flags has ARG_IN as 1, ARG_OUT as 2 and ARG_INOUT as 3
// To convert this into enum PARAM_IN, PARAM_OUT and
// PARAM_INOUT the value is subtracted by 1.
plist[i].mode = ParameterMode.from_int( nv.flags() - 1 );
}
} catch ( Exception e ) {
throw wrapper.exceptionInArguments( e ) ;
}
return plist;
}
public Request create_request(org.omg.CORBA.Object obj,
Context ctx,
String operation,
NVList arg_list,
NamedValue result,
ExceptionList exclist,
ContextList ctxlist)
{
return new RequestImpl(orb, obj, ctx, operation, arg_list, result,
exclist, ctxlist);
}
public NamedValue add_item(String itemName, int flags)
{
NamedValue tmpVal = new NamedValueImpl(orb, itemName, new AnyImpl(orb),
flags);
_namedValues.addElement(tmpVal);
return tmpVal;
}
public void arguments(NVList args)
{
if (_paramsCalled)
throw _wrapper.argumentsCalledMultiple() ;
if (_exceptionSet)
throw _wrapper.argumentsCalledAfterException() ;
if (args == null )
throw _wrapper.argumentsCalledNullArgs() ;
_paramsCalled = true;
NamedValue arg = null;
for (int i=0; i < args.count() ; i++) {
try {
arg = args.item(i);
} catch (Bounds e) {
throw _wrapper.boundsCannotOccur(e) ;
}
try {
if ((arg.flags() == org.omg.CORBA.ARG_IN.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
// unmarshal the value into the Any
arg.value().read_value(_ins, arg.value().type());
}
} catch ( Exception ex ) {
throw _wrapper.badArgumentsNvlist( ex ) ;
}
}
// hang on to the NVList for marshaling the result
_arguments = args;
_orb.getPIHandler().setServerPIInfo( _arguments );
_orb.getPIHandler().invokeServerPIIntermediatePoint();
}
/**
* Internal utility method to convert an NVList into a PI Parameter[]
*/
protected Parameter[] nvListToParameterArray( NVList parNVList ) {
// _REVISIT_ This utility method should probably be doing a deep
// copy so interceptor can't accidentally change the arguments.
int count = parNVList.count();
Parameter[] plist = new Parameter[count];
try {
for( int i = 0; i < count; i++ ) {
Parameter p = new Parameter();
plist[i] = p;
NamedValue nv = parNVList.item( i );
plist[i].argument = nv.value();
// ParameterMode spec can be found in 99-10-07.pdf
// Section:10.5.22
// nv.flags spec can be found in 99-10-07.pdf
// Section 7.1.1
// nv.flags has ARG_IN as 1, ARG_OUT as 2 and ARG_INOUT as 3
// To convert this into enum PARAM_IN, PARAM_OUT and
// PARAM_INOUT the value is subtracted by 1.
plist[i].mode = ParameterMode.from_int( nv.flags() - 1 );
}
} catch ( Exception e ) {
throw wrapper.exceptionInArguments( e ) ;
}
return plist;
}