Package org.apache.tuscany.sca.contribution.osgi

Examples of org.apache.tuscany.sca.contribution.osgi.BundleReference


        this.contribution = contribution;
        this.bundleProcessor = new OSGiBundleProcessor();
    }

    public void addModel(Object resolved) {
        BundleReference bundleRef = (BundleReference)resolved;
        map.put(bundleRef.getBundleUniqueName(), bundleRef);
    }
View Full Code Here


     * Handle artifact resolution when the specific class reference is imported from another contribution
     * @param unresolved
     * @return
     */
    private BundleReference resolveImportedModel(BundleReference unresolved) {
        BundleReference resolved = unresolved;

        if( this.contribution != null) {
            for (Import import_ : this.contribution.getImports()) {
               
                resolved = import_.getModelResolver().resolveModel(BundleReference.class, unresolved);
View Full Code Here

        Object bundle = null;
        String bundleName = ((BundleReference)unresolved).getBundleName();
        String bundleVersion = ((BundleReference)unresolved).getBundleVersion();
       
        bundle = osgiRuntime.findBundle(bundleName, bundleVersion);
        BundleReference bundleReference;
       
        if (bundle == null)
            bundleReference = bundleProcessor.installNestedBundle(contribution, bundleName, bundleVersion);
        else {
            bundleReference = new BundleReference(bundle,
                    ((BundleReference)unresolved).getBundleName(),
                    bundleVersion,
                    getBundleFileName(bundle)
                    );
        }
View Full Code Here

        this.contribution = contribution;
        this.bundleProcessor = new OSGiBundleProcessor();
    }

    public void addModel(Object resolved) {
        BundleReference bundleRef = (BundleReference)resolved;
        map.put(bundleRef.getBundleUniqueName(), bundleRef);
    }
View Full Code Here

     * Handle artifact resolution when the specific class reference is imported from another contribution
     * @param unresolved
     * @return
     */
    private BundleReference resolveImportedModel(BundleReference unresolved) {
        BundleReference resolved = unresolved;

        if( this.contribution != null) {
            for (Import import_ : this.contribution.getImports()) {
               
                resolved = import_.getModelResolver().resolveModel(BundleReference.class, unresolved);
View Full Code Here

        Object bundle = null;
        String bundleName = ((BundleReference)unresolved).getBundleName();
        String bundleVersion = ((BundleReference)unresolved).getBundleVersion();
       
        bundle = osgiRuntime.findBundle(bundleName, bundleVersion);
        BundleReference bundleReference;
       
        if (bundle == null)
            bundleReference = bundleProcessor.installNestedBundle(contribution, bundleName, bundleVersion);
        else {
            bundleReference = new BundleReference(bundle,
                    ((BundleReference)unresolved).getBundleName(),
                    bundleVersion,
                    getBundleFileName(bundle)
                    );
        }
View Full Code Here

    public BundleReference installNestedBundle(Contribution contribution,
                                               String bundleSymbolicName,
                                               String bundleVersion) {

        BundleReference bundleReference = null;

        initialize();
        if (osgiRuntime == null)
            return null;

        List<Artifact> artifacts = contribution.getArtifacts();
        for (Artifact a : artifacts) {
            if (a.getURI().endsWith(".jar")) {

                InputStream stream;
                JarInputStream jar = null;
                Object name;
                Object version;
                try {

                    URL artifactURL = new URL(a.getLocation());
                    stream = artifactURL.openStream();
                    jar = new JarInputStream(artifactURL.openStream());
                    Manifest manifest = jar.getManifest();
                    name = manifest.getMainAttributes().get(new Attributes.Name("Bundle-SymbolicName"));
                    version = manifest.getMainAttributes().get(new Attributes.Name("Bundle-Version"));

                    if (bundleSymbolicName.equals(name) && (bundleVersion == null || version == null || bundleVersion
                        .equals(version))) {

                        Object bundle = osgiRuntime.installBundle(a.getLocation(), stream);

                        bundleReference = new BundleReference(bundle, bundleSymbolicName, bundleVersion, a.getURI());

                        break;
                    }

                } catch (Exception e) {
View Full Code Here

          if (!impl.isUnresolved())
            return;
           
            impl.setUnresolved(false);
           
            BundleReference bundleReference = new BundleReference(impl.getBundleSymbolicName(), impl.getBundleVersion());
            BundleReference resolvedBundle = resolver.resolveModel(BundleReference.class, bundleReference);
            Bundle bundle = (Bundle)resolvedBundle.getBundle();
            if (bundle != null)
                impl.setOSGiBundle(bundle);
            else
                throw new ContributionResolveException("Could not locate OSGi bundle " +
                        impl.getBundleSymbolicName());
           
            String bundleName = resolvedBundle.getBundleRelativePath();
            String ctURI = bundleName.endsWith(".jar") || bundleName.endsWith(".JAR")?
                    bundleName.substring(0, bundleName.lastIndexOf(".")) : bundleName;
            ctURI = ctURI.replaceAll("\\.", "/");
            ctURI = ctURI + ".componentType";
View Full Code Here

    public BundleReference installNestedBundle(Contribution contribution,
                                               String bundleSymbolicName,
                                               String bundleVersion) {

        BundleReference bundleReference = null;

        List<Artifact> artifacts = contribution.getArtifacts();
        for (Artifact a : artifacts) {
            if (a.getURI().endsWith(".jar")) {
                try {
                    Bundle bundle = OSGiBundleActivator.installBundle(a.getLocation());
                    if (bundle != null) {
                        bundleReference = new BundleReference(bundle);
                        break;
                    }
                } catch (Exception e) {
                    // If OSGi cannot process the jar, treat the bundle as a plain jar file.
                }
View Full Code Here

        this.contribution = contribution;
        this.bundleProcessor = new OSGiBundleProcessor();
    }

    public void addModel(Object resolved, ProcessorContext context) {
        BundleReference bundleRef = (BundleReference)resolved;
        refs.put(bundleRef, bundleRef);
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.osgi.BundleReference

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.