Package org.jboss.gravia.resource

Examples of org.jboss.gravia.resource.ResourceIdentity


        LOGGER.info("Installing shared resource: {}", resource);
        return installBundleResource(resource);
    }

    private ResourceHandle installBundleResource(Resource resource) throws ProvisionException {
        ResourceIdentity identity = resource.getIdentity();
        InputStream content = resource.adapt(ResourceContent.class).getContent();
        final Bundle bundle;
        try {
            bundle = bundleContext.installBundle(identity.toString(), content);
        } catch (BundleException ex) {
            throw new ProvisionException(ex);
        }

        // Attempt to start the bundle. This relies on provision ordering.
View Full Code Here


    @Override
    public synchronized Set<ResourceHandle> installResources(List<Resource> resources, Map<Requirement, Resource> mapping) throws ProvisionException {
        Set<ResourceHandle> handles = new HashSet<ResourceHandle>();
        for (Resource res : resources) {
            ResourceIdentity identity = res.getIdentity();
            if (!isAbstract(res) && getEnvironment().getResource(identity) == null) {
                handles.add(installResourceInternal(res, mapping));
            }
        }
        return Collections.unmodifiableSet(handles);
View Full Code Here

        super(propertiesProvider);
        serviceManager = new RuntimeServicesManager(adapt(RuntimeEventsManager.class));
        storageHandler = new RuntimeStorageHandler(propertiesProvider, true);

        // Install system module
        ResourceIdentity sysid = getSystemIdentity();
        Resource resource = new DefaultResourceBuilder().addIdentityCapability(sysid).getResource();
        try {
            Dictionary<String, String> headers = new Hashtable<>();
            headers.put("Bundle-SymbolicName", sysid.getSymbolicName());
            headers.put("Bundle-Version", sysid.getVersion().toString());
            installModule(EmbeddedRuntime.class.getClassLoader(), resource, headers, context);
        } catch (ModuleException ex) {
            throw new IllegalStateException("Cannot install system module", ex);
        }
    }
View Full Code Here

    @Override
    public Set<Module> getModules(String symbolicName, VersionRange range) {
        Set<Module> result = getModules();
        Iterator<Module> iterator = result.iterator();
        while(iterator.hasNext()) {
            ResourceIdentity modid = iterator.next().getIdentity();
            if (symbolicName != null && !symbolicName.equals(modid.getSymbolicName())) {
                iterator.remove();
            }
            if (range != null && !range.includes(modid.getVersion())) {
                iterator.remove();
            }
        }
        return result;
    }
View Full Code Here

            resource = builder.getResource();
        }
        this.resource = resource;

        // Build the headers
        ResourceIdentity resourceIdentity = resource.getIdentity();
        Hashtable<String, String> coloned = new Hashtable<String, String>();
        if (headers != null) {
            Enumeration<String> keys = headers.keys();
            while(keys.hasMoreElements()) {
                String key = keys.nextElement();
                String value = headers.get(key);
                coloned.put(key, value);
            }
        }
        if (coloned.get(Constants.GRAVIA_IDENTITY_CAPABILITY) == null) {
            String identityHeader = getIdentityHeader(resourceIdentity);
            coloned.put(Constants.GRAVIA_IDENTITY_CAPABILITY, identityHeader);
        }
        this.headers = new UnmodifiableDictionary<String, String>(new CaseInsensitiveDictionary<String>(coloned));

        // Verify the resource & headers identity
        ResourceIdentity headersIdentity = new DictionaryResourceBuilder().load(coloned).getResource().getIdentity();
        if (!resourceIdentity.equals(headersIdentity))
            throw new IllegalArgumentException("Resource and header identity does not match: " + resourceIdentity);
    }
View Full Code Here

            if (!getDirectives().isEmpty()) {
                buffer.append(addcomma ? "," : "");
                buffer.append("dirs=" + directives);
                addcomma = true;
            }
            ResourceIdentity icap = resource.getIdentity();
            if (icap != null) {
                buffer.append(addcomma ? "," : "");
                buffer.append("[" + icap.getSymbolicName() + ":" + icap.getVersion() + "]");
                addcomma = true;
            } else {
                buffer.append(addcomma ? "," : "");
                buffer.append("[anonymous]");
                addcomma = true;
View Full Code Here

        return getClass().getSimpleName();
    }

    @Override
    public String toString() {
        ResourceIdentity id = identity;
        String idstr = (id != null ? id.getSymbolicName() + ":" + id.getVersion() : "anonymous");
        return getSimpleTypeName() + "[" + idstr + "]";
    }
View Full Code Here

            if (!getDirectives().isEmpty()) {
                buffer.append(addcomma ? "," : "");
                buffer.append("dirs=" + directives);
                addcomma = true;
            }
            ResourceIdentity icap = resource.getIdentity();
            if (icap != null) {
                buffer.append(addcomma ? "," : "");
                buffer.append("[" + icap.getSymbolicName() + ":" + icap.getVersion() + "]");
                addcomma = true;
            } else {
                buffer.append(addcomma ? "," : "");
                buffer.append("[anonymous]");
                addcomma = true;
View Full Code Here

    @SuppressWarnings("deprecation")
    private ResourceHandle installSharedResourceInternal(Context context, Resource resource) throws Exception {
        LOGGER.info("Installing shared resource: {}", resource);

        ResourceIdentity resid = resource.getIdentity();
        ModuleIdentifier modid = getModuleIdentifier(resid);
        String symbolicName = resid.getSymbolicName();
        Version version = resid.getVersion();

        final File modulesDir = injectedServerEnvironment.getValue().getModulesDir();
        final File moduleDir = new File(modulesDir, symbolicName.replace(".", File.separator) + File.separator + version);

        if (moduleDir.exists()) {
View Full Code Here

            Resource depres = mapping.get(req);
            if (depres != null) {
                ModuleIdentifier modid = null;
               
                // #1 Check the runtime for a deployed module
                ResourceIdentity resid = depres.getIdentity();
                Module module = runtime.getModule(resid);
                if (module != null) {
                    ModuleClassLoader modcl = (ModuleClassLoader) module.adapt(ClassLoader.class);
                    modid = modcl.getModule().getIdentifier();
                }
View Full Code Here

TOP

Related Classes of org.jboss.gravia.resource.ResourceIdentity

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.