Examples of JavaTypeMapper


Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

            //create the type mapper
            //First try to take the one that is already there
            TypeMapper mapper = cgconfig.getTypeMapper();
            if (mapper == null) {
                mapper = new JavaTypeMapper();
            }

            //change the  default class name of the mapper to
            //xmlbeans specific XMLObject
            mapper.setDefaultMappingName(XmlObject.class.getName());
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

                    !configuration.getOutputLanguage().trim().equals("") &&
                    configuration.getOutputLanguage().toLowerCase().equals("c")) {
                mapper = new CTypeMapper();

            else {
                mapper = new JavaTypeMapper();
            }

        }

        if (options.isWriteOutput()) {
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

        //create the type mapper
        //First try to take the one that is already there
        TypeMapper mapper = configuration.getTypeMapper();
        if (mapper == null) {
            mapper = new JavaTypeMapper();
        }

        if (options.isWriteOutput()) {
            //get the processed element map and transfer it to the type mapper
            Map processedMap = schemaCompiler.getProcessedElementMap();
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

            //create the type mapper
            //First try to take the one that is already there
            TypeMapper mapper = cgconfig.getTypeMapper();
            if (mapper == null) {
                mapper = new JavaTypeMapper();
            }

            //change the  default class name of the mapper to
            //xmlbeans specific XMLObject
            mapper.setDefaultMappingName(XmlObject.class.getName());
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

            }
           
            Vector xmlObjectsVector = new Vector();
           
            //create the type mapper
            JavaTypeMapper mapper = new JavaTypeMapper();

            String baseURI = cgconfig.getBaseURI();
           
            for (int i = 0; i < schemas.size(); i++) {
                XmlSchema schema = (XmlSchema) schemas.get(i);
                InputSource inputSource = new InputSource(new StringReader(getSchemaAsString(schema)));
                inputSource.setSystemId(baseURI);
                xmlObjectsVector.add(inputSource);
            }

            File outputDir = new File(cgconfig.getOutputLocation(), "src");
            outputDir.mkdir();
           
            Map nsMap = cgconfig.getUri2PackageNameMap();

            for (int i = 0; i < xmlObjectsVector.size(); i++) {
             
                SchemaCompiler sc = XJC.createSchemaCompiler();
                XmlSchema schema = (XmlSchema) schemas.get(i);

                String pkg = null;
                if(nsMap != null) {
                    pkg = (String) nsMap.get(schema.getTargetNamespace());
                }
                if (pkg == null) {
                    pkg = extractNamespace(schema);
                }
                sc.setDefaultPackageName(pkg);

                sc.parseSchema((InputSource) xmlObjectsVector.elementAt(i));

                // Bind the XML
                S2JJAXBModel jaxbModel = sc.bind();

                // Emit the code artifacts
                JCodeModel codeModel = jaxbModel.generateCode(null, null);
                FileCodeWriter writer = new FileCodeWriter(outputDir);
                codeModel.build(writer);

                Collection mappings = jaxbModel.getMappings();

                Iterator iter = mappings.iterator();

                while ( iter.hasNext() )
                {
                    Mapping mapping = (Mapping)iter.next();
                    QName qn = mapping.getElement();
                    String typeName = mapping.getType().getTypeClass().fullName();

                    mapper.addTypeMappingName( qn, typeName );
                }
            }

            // Return the type mapper
            return mapper;
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

            WSDLExtensibilityElement extensiblityElt;
            SchemaTypeSystem sts = null;
            Vector xmlObjectsVector = new Vector();
            //create the type mapper
            JavaTypeMapper mapper = new JavaTypeMapper();

            for (int i = 0; i < typesArray.size(); i++) {
                extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
                Schema schema;

                if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
                    schema = (Schema) extensiblityElt;
                    XmlOptions options = new XmlOptions();

                    options.setLoadAdditionalNamespaces(
                            configuration.getWom().getNamespaces()); //add the namespaces


                    Stack importedSchemaStack = schema.getImportedSchemaStack();
                    File schemaFolder = new File(configuration.getOutputLocation(), SCHEMA_FOLDER);
                    schemaFolder.mkdir();
                    //compile these schemas
                    while (!importedSchemaStack.isEmpty()) {
                        Element element = (Element)importedSchemaStack.pop();
                        String tagetNamespace = element.getAttribute("targetNamespace");
                        if (!processedSchemas.contains(tagetNamespace)){

                            // we are not using DOM toString method here, as it seems it depends on the
                            // JDK version that is being used.
                            String s = DOM2Writer.nodeToString(element);

                            //write the schema to a file
                            File tempFile = File.createTempFile("temp", ".xsd", schemaFolder);
                            FileWriter writer = new FileWriter(tempFile);
                            writer.write(s);
                            writer.flush();
                            writer.close();


                            xmlObjectsVector.add(
                                    XmlObject.Factory.parse(
                                            element
                                            , options));

                            processedSchemas.add(tagetNamespace);
                        }
                    }
                }
            }

            // add the third party schemas
            //todo pehaps checking the namespaces would be a good idea to
            //make the generated code work efficiently
            for (int i = 0; i < additionalSchemas.length; i++) {
                xmlObjectsVector.add(XmlObject.Factory.parse(
                        additionalSchemas[i]
                        , null));
            }

            //compile the type system
            XmlObject[] objeArray = convertToXMLObjectArray(xmlObjectsVector);
            BindingConfig config = new Axis2BindingConfig();

            //set the STS name to null. it makes the generated class include a unique (but random) STS name
            sts = XmlBeans.compileXmlBeans(null, null,
                    objeArray,
                    config, XmlBeans.getContextTypeLoader(),
                    new Axis2Filer(),
                    null);

            // prune the generated schema type system and add the list of base64 types
            FindBase64Types(sts);

            //get the schematypes and add the document types to the type mapper
            SchemaType[] schemaType = sts.documentTypes();
            SchemaType type;
            for (int j = 0; j < schemaType.length; j++) {
                type = schemaType[j];
                mapper.addTypeMapping(type.getDocumentElementName(),
                        type.getFullJavaName());
            }
            //set the type mapper to the config
            configuration.setTypeMapper(mapper);

            // write the mapper to a file for later retriival
            writeMappingsToFile(mapper.getAllTypeMappings());

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

            SchemaCompiler schemaCompiler = new SchemaCompiler(options);
            schemaCompiler
                    .compile(xmlSchemaTypeVector);

            //create the type mapper
            JavaTypeMapper mapper = new JavaTypeMapper();
            //get the processed element map and transfer it to the type mapper
            Map processedMap = schemaCompiler.getProcessedElementMap();
            Iterator processedkeys = processedMap.keySet().iterator();
            QName qNameKey;
            while (processedkeys.hasNext()) {
                qNameKey =(QName)processedkeys.next();
                mapper.addTypeMapping(qNameKey,processedMap.get(qNameKey));
            }

            //set the type mapper to the config
            configuration.setTypeMapper(mapper);
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

            Vector xmlObjectsVector = new Vector();
             //create the type mapper
        //First try to take the one that is already there
        TypeMapper mapper = configuration.getTypeMapper();
        if (mapper==null){
            mapper =new JavaTypeMapper();
        }

            for (int i = 0; i < typesList.size(); i++) {
                XmlSchema schema = (XmlSchema) typesList.get(i);
                xmlObjectsVector.add(new InputSource(new StringReader(getSchemaAsString(schema))));
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

            SchemaCompiler schemaCompiler = new SchemaCompiler(options);
            // run the schema compiler
            schemaCompiler.compile(xmlSchemaTypeVector);

            //create the type mapper
            JavaTypeMapper mapper = new JavaTypeMapper();

            if (options.isWriteOutput()){
                //get the processed element map and transfer it to the type mapper
                Map processedMap = schemaCompiler.getProcessedElementMap();
                Iterator processedkeys = processedMap.keySet().iterator();
                QName qNameKey;
                while (processedkeys.hasNext()) {
                    qNameKey = (QName) processedkeys.next();
                    mapper.addTypeMappingName(qNameKey, processedMap.get(qNameKey).toString());
                }

            }else{
                //get the processed model map and transfer it to the type mapper
                //since the options mentiond that its not writable, it should have
                //populated the model map
                Map processedModelMap = schemaCompiler.getProcessedModelMap();
                Iterator processedkeys = processedModelMap.keySet().iterator();
                QName qNameKey;
                while (processedkeys.hasNext()) {
                    qNameKey = (QName) processedkeys.next();
                    mapper.addTypeMappingObject(qNameKey, processedModelMap.get(qNameKey));
                }

                Map processedMap = schemaCompiler.getProcessedElementMap();
                processedkeys = processedMap.keySet().iterator();
                while (processedkeys.hasNext()) {
                    qNameKey = (QName) processedkeys.next();
                    mapper.addTypeMappingName(qNameKey, processedMap.get(qNameKey).toString());
                }

                //get the ADB template from the schema compilers property bag and set the
                //template
                configuration.putProperty(XSLTConstants.EXTERNAL_TEMPLATE_PROPERTY_KEY,
View Full Code Here

Examples of org.apache.axis2.wsdl.databinding.JavaTypeMapper

            WSDLExtensibilityElement extensiblityElt;
            SchemaTypeSystem sts;
            Vector xmlObjectsVector = new Vector();
            //create the type mapper
            JavaTypeMapper mapper = new JavaTypeMapper();

            for (int i = 0; i < typesArray.size(); i++) {
                extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
                Schema schema;

                if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
                    schema = (Schema) extensiblityElt;
                    XmlOptions options = new XmlOptions();

                    options.setLoadAdditionalNamespaces(
                            configuration.getWom().getNamespaces()); //add the namespaces


                    Stack importedSchemaStack = schema.getImportedSchemaStack();
                    File schemaFolder = null;
                    if(debug) {
                        schemaFolder = new File(configuration.getOutputLocation(), SCHEMA_FOLDER);
                        schemaFolder.mkdir();
                    }
                    //compile these schemas
                    while (!importedSchemaStack.isEmpty()) {
                        Element element = (Element) importedSchemaStack.pop();
                        String tagetNamespace = element.getAttribute("targetNamespace");
                        if (!processedSchemas.contains(tagetNamespace)) {

                            if(debug) {
                                // we are not using DOM toString method here, as it seems it depends on the
                                // JDK version that is being used.
                                String s = DOM2Writer.nodeToString(element);
   
                                //write the schema to a file
                                File tempFile = File.createTempFile("temp", ".xsd", schemaFolder);
                                FileWriter writer = new FileWriter(tempFile);
                                writer.write(s);
                                writer.flush();
                                writer.close();
                            }

                            xmlObjectsVector.add(
                                    XmlObject.Factory.parse(
                                            element
                                            , options));

                            processedSchemas.add(tagetNamespace);
                        }
                    }
                }
            }

            // add the third party schemas
            //todo perhaps checking the namespaces would be a good idea to
            //make the generated code work efficiently
            for (int i = 0; i < additionalSchemas.length; i++) {
                xmlObjectsVector.add(XmlObject.Factory.parse(
                        additionalSchemas[i]
                        , null));
            }

            //compile the type system
            XmlObject[] objeArray = convertToXMLObjectArray(xmlObjectsVector);
            BindingConfig config = new Axis2BindingConfig();

            //set the STS name to null. it makes the generated class include a unique (but random) STS name
            sts = XmlBeans.compileXmlBeans(null, null,
                    objeArray,
                    config, XmlBeans.getContextTypeLoader(),
                    new Axis2Filer(),
                    null);

            // prune the generated schema type system and add the list of base64 types
            FindBase64Types(sts);
            findPlainBase64Types(sts);

            //get the schematypes and add the document types to the type mapper
            SchemaType[] schemaType = sts.documentTypes();
            SchemaType type;
            for (int j = 0; j < schemaType.length; j++) {
                type = schemaType[j];
                mapper.addTypeMappingName(type.getDocumentElementName(),
                        type.getFullJavaName());
            }
            //set the type mapper to the config
            configuration.setTypeMapper(mapper);

            if(debug) {
                // write the mapper to a file for later retriival
                writeMappingsToFile(mapper.getAllMappedNames());
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.