Search in sources :

Example 46 with TypeCode

use of org.omg.CORBA.TypeCode in project wildfly by wildfly.

the class InterfaceRepository method addTypeCode.

/**
 * Add a new IDL TypeCode for a mapped class.
 *
 * @param cls      The Java class denoting the java type.
 * @param typeCode The IDL type code of the mapped java class.
 */
private void addTypeCode(Class cls, TypeCode typeCode) throws IRConstructionException {
    if (cls == null)
        throw IIOPLogger.ROOT_LOGGER.invalidNullClass();
    TypeCode tc = (TypeCode) typeCodeMap.get(cls);
    if (tc != null)
        throw IIOPLogger.ROOT_LOGGER.duplicateTypeCodeForClass(cls.getName());
    typeCodeMap.put(cls, typeCode);
}
Also used : TypeCode(org.omg.CORBA.TypeCode)

Example 47 with TypeCode

use of org.omg.CORBA.TypeCode in project wildfly by wildfly.

the class InterfaceRepository method getJavaIoSerializable.

/**
 * Get a reference to the special case mapping for java.io.Serializable.
 * This is according to "Java(TM) Language to IDL Mapping Specification",
 * section 1.3.10.1
 */
private AliasDefImpl getJavaIoSerializable() throws IRConstructionException {
    if (javaIoSerializable == null) {
        final String id = "IDL:java/io/Serializable:1.0";
        final String name = "Serializable";
        final String version = "1.0";
        // Get module to add typedef to.
        ModuleDefImpl m = ensurePackageExists("java.io");
        TypeCode typeCode = orb.create_alias_tc(id, name, orb.get_primitive_tc(TCKind.tk_any));
        // TypeCode typeCode = new TypeCodeImpl(TCKind._tk_alias, id, name,
        // new TypeCodeImpl(TCKind.tk_any));
        javaIoSerializable = new AliasDefImpl(id, name, version, m, typeCode, impl);
        m.add(name, javaIoSerializable);
    }
    return javaIoSerializable;
}
Also used : TypeCode(org.omg.CORBA.TypeCode)

Example 48 with TypeCode

use of org.omg.CORBA.TypeCode in project wildfly by wildfly.

the class InterfaceRepository method getTypeCode.

/**
 * Returns the TypeCode IDL TypeCodes for parameter, result, attribute
 * and value member types.
 * This may provoke a mapping of the class argument.
 * <p/>
 * Exception classes map to both values and exceptions. For these, this
 * method returns the typecode for the value, and you can use the
 * <code>getExceptionTypeCode</code> TODO method to get the typecode for the
 * mapping to exception.
 *
 * @param cls The Java class denoting the java type.
 */
private TypeCode getTypeCode(Class cls) throws IRConstructionException, RMIIIOPViolationException {
    if (cls == null)
        throw IIOPLogger.ROOT_LOGGER.invalidNullClass();
    TypeCode ret = (TypeCode) typeCodeMap.get(cls);
    if (ret == null) {
        if (cls == java.lang.String.class)
            ret = getJavaLangString().type();
        else if (cls == java.lang.Object.class)
            ret = getJavaLang_Object().type();
        else if (cls == java.lang.Class.class)
            ret = getJavaxRmiCORBAClassDesc().type();
        else if (cls == java.io.Serializable.class)
            ret = getJavaIoSerializable().type();
        else if (cls == java.io.Externalizable.class)
            ret = getJavaIoExternalizable().type();
        else {
            // Try adding a mapping of the the class to the IR
            addClass(cls);
            // Lookup again, it should be there now.
            ret = (TypeCode) typeCodeMap.get(cls);
            if (ret == null)
                throw IIOPLogger.ROOT_LOGGER.unknownTypeCodeForClass(cls.getName());
            else
                return ret;
        }
        typeCodeMap.put(cls, ret);
    }
    return ret;
}
Also used : TypeCode(org.omg.CORBA.TypeCode)

Example 49 with TypeCode

use of org.omg.CORBA.TypeCode in project wildfly by wildfly.

the class ExceptionDefImpl method members.

public StructMember[] members() {
    if (members == null) {
        TypeCode type = vDef.type();
        LocalIDLType localTypeDef = IDLTypeImpl.getIDLType(type, repository);
        IDLType type_def = IDLTypeHelper.narrow(localTypeDef.getReference());
        members = new StructMember[1];
        members[0] = new StructMember("value", type, type_def);
    }
    return members;
}
Also used : TypeCode(org.omg.CORBA.TypeCode) IDLType(org.omg.CORBA.IDLType) StructMember(org.omg.CORBA.StructMember)

Example 50 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaObjectReader method readFixed.

public void readFixed(CorbaFixedHandler fixedHandler) throws CorbaBindingException {
    long scale = fixedHandler.getScale();
    try {
        java.math.BigDecimal fixedValue = stream.read_fixed().movePointLeft((int) scale);
        fixedHandler.setValue(fixedValue);
    } catch (NO_IMPLEMENT ex) {
        // Some of them have a "read_fixed(TypeCode)" method, we'll try that
        try {
            Method m = stream.getClass().getMethod("read_fixed", new Class[] { TypeCode.class });
            BigDecimal fixedValue = (BigDecimal) m.invoke(stream, new Object[] { fixedHandler.getTypeCode() });
            fixedHandler.setValue(fixedValue);
        } catch (Throwable e1) {
            throw ex;
        }
    }
}
Also used : NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) BigDecimal(java.math.BigDecimal) TypeCode(org.omg.CORBA.TypeCode) Method(java.lang.reflect.Method) BigDecimal(java.math.BigDecimal)

Aggregations

TypeCode (org.omg.CORBA.TypeCode)70 QName (javax.xml.namespace.QName)49 Test (org.junit.Test)44 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)18 InputStream (org.omg.CORBA.portable.InputStream)15 OutputStream (org.omg.CORBA.portable.OutputStream)14 StructMember (org.omg.CORBA.StructMember)9 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)6 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)6 Any (org.omg.CORBA.Any)6 NVList (org.omg.CORBA.NVList)6 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)5 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4 Enum (org.apache.cxf.binding.corba.wsdl.Enum)4 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)4 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)4 Exchange (org.apache.cxf.message.Exchange)4 IOException (java.io.IOException)3