Package org.apache.tuscany.sca.contribution.java

Examples of org.apache.tuscany.sca.contribution.java.JavaExport


     *    location is not provided
     *    import and export packages match
     */
    public boolean match(Export export) {
        if(export instanceof JavaExport) {
            JavaExport javaExport = (JavaExport)export;
            String exportedPackage = javaExport.getPackage();
            if (packageName.equals(exportedPackage)) {
                return true;
            } else {
                if (packageName.endsWith(".*")) {
                    String prefix = packageName.substring(0, packageName.length() - 1);
View Full Code Here


                    }
                }
               
                // Add Java export model objects for all the packages we found
                for (String pkg: packages) {
                    JavaExport export = new JavaExportImpl();
                    export.setPackage(pkg);
                    contribution.getExports().add(export);
                }
            }
        }
       
        // Initialize the contribution exports
        for (Export export: contribution.getExports()) {
            export.setModelResolver(contribution.getModelResolver());
        }
       
        // Initialize the contribution imports
        for (Import import_: contribution.getImports()) {
            boolean initialized = false;
           
            if(import_ instanceof JavaImport) {
                JavaImport javaImport = (JavaImport) import_;
               
                //Find a matching contribution
                if(javaImport.getLocation() != null) {
                    Contribution targetContribution = repository.getContribution(javaImport.getLocation());
                    if (targetContribution != null) {
                   
                        // Find a matching contribution export
                        for (Export export: targetContribution.getExports()) {
                            if (export instanceof JavaExport) {
                                JavaExport javaExport = (JavaExport)export;
                                if (javaImport.getPackage().equals(javaExport.getPackage())) {
                                    List<Contribution> exportingContributions = new ArrayList<Contribution>();
                                    exportingContributions.add(targetContribution);
                                    javaImport.setModelResolver(new JavaImportModelResolver(exportingContributions, javaExport.getModelResolver()));
                                    initialized = true;
                                    break;
                                }
                            }
                        }
View Full Code Here

   
    /**
     * Process <export package=""/>
     */
    public JavaExport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        JavaExport javaExport = this.factory.createJavaExport();
        QName element = null;
       
        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    element = reader.getName();
                   
                    // Read <export.java>
                    if (EXPORT_JAVA.equals(element)) {
                        String packageName = reader.getAttributeValue(null, PACKAGE);
                        if (packageName == null) {
                            throw new ContributionReadException("Attribute 'package' is missing");
                        }
                       
                        javaExport.setPackage(packageName);
                    }
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    if (EXPORT_JAVA.equals(reader.getName())) {
                        return javaExport;
View Full Code Here

        import_ = javaImportExportFactory.createJavaImport();
        import_.setPackage("calculator");
        import_.setModelResolver(new JavaImportModelResolver(exportContribList, null));
        contribB.getImports().add(import_);
       
        JavaExport export = javaImportExportFactory.createJavaExport();
        export.setPackage(this.getClass().getPackage().getName());
        contribA.getExports().add(export);
        export = javaImportExportFactory.createJavaExport();
        export.setPackage("calculator");
        contribC.getExports().add(export);       
       
        // Load class from parent, class is also present in imported contribution. Class should
        // be loaded from parent
        Class<?> testClassB = contribB.getClassLoader().loadClass(this.getClass().getName());       
View Full Code Here

        JavaImport import1_ = javaImportExportFactory.createJavaImport();
        import1_.setPackage("calculator");
        import1_.setModelResolver(new JavaImportModelResolver(exportContribList, null));
        contribB.getImports().add(import1_);
       
        JavaExport export = javaImportExportFactory.createJavaExport();
        export.setPackage(this.getClass().getPackage().getName());
        contribA.getExports().add(export);
        JavaExport export1 = javaImportExportFactory.createJavaExport();
        export1.setPackage("calculator");
        contribC.getExports().add(export1);

       
        // Load resource from parent
        URL resB = contribB.getClassLoader().getResource("deployables/sample-calculator.jar");
View Full Code Here

        XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(VALID_XML));

        ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
        factories.addFactory(new JavaImportExportFactoryImpl());
        JavaExportProcessor exportProcessor = new JavaExportProcessor(factories);
        JavaExport javaExport = exportProcessor.read(reader);
       
        assertEquals("org.apache.tuscany.sca.contribution.java", javaExport.getPackage());
    }
View Full Code Here

                    if (targetContribution != null) {

                        // Find a matching contribution export
                        for (Export export : targetContribution.getExports()) {
                            if (export instanceof JavaExport) {
                                JavaExport javaExport = (JavaExport)export;
                                if (packageName.equals(javaExport.getPackage())) {

                                    if (osgiRuntime.findBundle(targetContribution.getLocation()) == null)
                                        bundlesToInstall.add(targetContribution);

                                    initialized = true;
View Full Code Here

   
    /**
     * Process <export package=""/>
     */
    public JavaExport read(XMLStreamReader reader) throws ContributionReadException {
        JavaExport javaExport = this.factory.createJavaExport();
        QName element = null;
       
        try {
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        element = reader.getName();
                       
                        // Read <export.java>
                        if (EXPORT_JAVA.equals(element)) {
                            String packageName = reader.getAttributeValue(null, PACKAGE);
                            if (packageName == null) {
                              error("AttributePackageMissing", reader);
                                //throw new ContributionReadException("Attribute 'package' is missing");
                            } else                       
                                javaExport.setPackage(packageName);
                        }
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        if (EXPORT_JAVA.equals(reader.getName())) {
                            return javaExport;
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testLoad() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
        JavaExport javaExport = (JavaExport)staxProcessor.read(reader);
        Assert.assertEquals("org.apache.tuscany.sca.contribution.java", javaExport.getPackage());
    }
View Full Code Here

     *    location is not provided
     *    import and export packages match
     */
    public boolean match(Export export) {
        if(export instanceof JavaExport) {
            JavaExport javaExport = (JavaExport)export;
            String exportedPackage = javaExport.getPackage();
            if (packageName.equals(exportedPackage)) {
                return true;
            } else {
                if (packageName.endsWith(".*")) {
                    String prefix = packageName.substring(0, packageName.length() - 1);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.java.JavaExport

Copyright © 2018 www.massapicom. 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.