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

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


            return modelClass.cast(resolved);
               
        } else if (unresolved instanceof BundleReference) {
            for (String bundlePath: bundles.keySet()) {
                Bundle bundle = bundles.get(bundlePath);
                BundleReference bundleRef = (BundleReference)unresolved;
                String bundleVersion = (String)bundle.getHeaders().get("Bundle-Version");
                if (bundle.getSymbolicName().equals(bundleRef.getBundleName())&&
                    (bundleVersion == null || bundleRef.getBundleVersion() == null ||
                    bundleVersion.equals(bundleRef.getBundleVersion()))) {
                   
                    resolved = new BundleReference(bundle,
                            bundle.getSymbolicName(),
                            bundleVersion,
                            bundlePath);
                    map.put(resolved, resolved);
                   
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

     * @param unresolved
     * @param context
     * @return
     */
    private BundleReference resolveImportedModel(BundleReference unresolved, ProcessorContext context) {
        BundleReference resolved = unresolved;

        if (this.contribution != null) {
            for (Import import_ : this.contribution.getImports()) {

                resolved = import_.getModelResolver().resolveModel(BundleReference.class, unresolved, context);
View Full Code Here

        Bundle bundle = null;
        String bundleName = ((BundleReference)unresolved).getSymbolicName();
        String bundleVersion = ((BundleReference)unresolved).getVersion();

        bundle = OSGiBundleActivator.findBundle(bundleName, bundleVersion);
        BundleReference bundleReference;

        if (bundle == null) {
            bundleReference = bundleProcessor.installNestedBundle(contribution, bundleName, bundleVersion);
        } else {
            bundleReference = new BundleReference(bundle);
        }

        if (bundleReference != null) {
            //if we load the class           
View Full Code Here

          if (impl == null || !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 {
              error("CouldNotLocateOSGiBundle", impl, impl.getBundleSymbolicName());
                //throw new ContributionResolveException("Could not locate OSGi bundle " +
                        //impl.getBundleSymbolicName());
              return;
            }
           
            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;

        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

            return modelClass.cast(resolved);
               
        } else if (unresolved instanceof BundleReference) {
            for (String bundlePath: bundles.keySet()) {
                Bundle bundle = bundles.get(bundlePath);
                BundleReference bundleRef = (BundleReference)unresolved;
                String bundleVersion = (String)bundle.getHeaders().get("Bundle-Version");
                if (bundle.getSymbolicName().equals(bundleRef.getBundleName())&&
                    (bundleVersion == null || bundleRef.getBundleVersion() == null ||
                    bundleVersion.equals(bundleRef.getBundleVersion()))) {
                   
                    resolved = new BundleReference(bundle,
                            bundle.getSymbolicName(),
                            bundleVersion,
                            bundlePath);
                    map.put(resolved, resolved);
                   
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) {
        BundleReference bundleRef = (BundleReference)resolved;
        refs.put(bundleRef, 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

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.