Search in sources :

Example 1 with PreProcessorInputStream

use of org.apache.axis2.corba.idl.PreProcessorInputStream in project axis-axis2-java-core by apache.

the class CorbaUtil method getIDL.

public static IDL getIDL(AxisService service, ORB orb, String dirName) throws CorbaException {
    Parameter idlFile = service.getParameter(IDL_FILE);
    if (idlFile == null) {
        throw new CorbaInvocationException("Please specify the IDL file");
    }
    String idlFileName = ((String) idlFile.getValue()).trim();
    String cacheKey = dirName + File.separator + idlFileName;
    IDL idl = (IDL) IDL_CACHE.get(cacheKey);
    if (idl == null) {
        try {
            /*File file = new File(dirName);
                InputStream stream;
                if (file.isDirectory()) {
                    stream = new FileInputStream(cacheKey);
                } else {
                    ZipInputStream zin = new ZipInputStream(new FileInputStream(file));

                    ZipEntry entry;
                    boolean found = false;
                    while ((entry = zin.getNextEntry()) != null) {
                        if (entry.getName().equalsIgnoreCase(idlFileName)) {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                        new CorbaInvocationException("cannot find " + idlFileName + " in " + file.getPath());

                    stream = zin;
                }*/
            InputStream stream = new PreProcessorInputStream(dirName, idlFileName);
            // TODO: Set pre-processor system and user input paths
            IDLProcessor idlProcessor = new IDLProcessor(stream);
            idl = idlProcessor.process();
            stream.close();
            IDL_CACHE.put(cacheKey, idl);
        } catch (IOException e) {
            throw new CorbaInvocationException("cannot process idl file", e);
        }
    }
    Map types = idl.getCompositeDataTypes();
    if (types != null) {
        Iterator iter = types.values().iterator();
        while (iter.hasNext()) {
            DataType type = (DataType) iter.next();
            if (type instanceof ValueType) {
                StreamableValueFactory.register(orb, (ValueType) type);
            }
        }
    }
    return idl;
}
Also used : PreProcessorInputStream(org.apache.axis2.corba.idl.PreProcessorInputStream) IDLProcessor(org.apache.axis2.corba.idl.IDLProcessor) Parameter(org.apache.axis2.description.Parameter) PreProcessorInputStream(org.apache.axis2.corba.idl.PreProcessorInputStream) CorbaInvocationException(org.apache.axis2.corba.exceptions.CorbaInvocationException)

Aggregations

CorbaInvocationException (org.apache.axis2.corba.exceptions.CorbaInvocationException)1 IDLProcessor (org.apache.axis2.corba.idl.IDLProcessor)1 PreProcessorInputStream (org.apache.axis2.corba.idl.PreProcessorInputStream)1 Parameter (org.apache.axis2.description.Parameter)1