Package org.jboss.gravia.resource

Examples of org.jboss.gravia.resource.ResourceIdentity


    private String performCall(String path, Map<String, String> headers, long timeout, TimeUnit unit) throws Exception {
        return HttpRequest.get("http://localhost:8080" + path, headers, timeout, unit);
    }

    private ObjectName getObjectName(Module module) throws MalformedObjectNameException {
        ResourceIdentity identity = module.getIdentity();
        return new ObjectName("test:name=" + identity.getSymbolicName() + ",version=" + identity.getVersion());
    }
View Full Code Here


        // Try to find the providers in the delegate
        if (providers.isEmpty() && getDelegate() != null) {
            providers = new HashSet<Capability>();
            for (Capability cap : getDelegate().findProviders(req)) {
                Resource res = cap.getResource();
                ResourceIdentity resid = res.getIdentity();
                Resource storageResource = getRepositoryStorage().getResource(resid);
                if (storageResource == null) {
                    storageResource = getRepositoryStorage().addResource(res);
                    for (Capability aux : storageResource.getCapabilities(req.getNamespace())) {
                        if (cap.getAttributes().equals(aux.getAttributes())) {
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

        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 ResourceHandle installSharedResource(Resource resource, Map<Requirement, Resource> mapping) throws Exception {
        LOGGER.info("Installing shared resource: {}", resource);

        ResourceIdentity resid = resource.getIdentity();
        ResourceContent content = resource.adapt(ResourceContent.class);
        if (content == null)
            throw new IllegalStateException("Cannot obtain content from: " + resource);

        // copy resource content
        File targetFile = new File(catalinaLib, resid.getSymbolicName() + "-" + resid.getVersion() + ".jar");
        if (targetFile.exists())
            throw new IllegalStateException("Module already exists: " + targetFile);

        IOUtils.copyStream(content.getContent(), new FileOutputStream(targetFile));
View Full Code Here

    @Override
    public ResourceHandle installUnsharedResource(Resource resource, Map<Requirement, Resource> mapping) throws Exception {
        LOGGER.info("Installing unshared resource: {}", resource);

        File tempfile = null;
        ResourceIdentity identity = resource.getIdentity();
        ContentCapability ccap = (ContentCapability) resource.getCapabilities(ContentNamespace.CONTENT_NAMESPACE).get(0);
        URL contentURL = ccap.getContentURL();
        if (contentURL == null) {
            InputStream content = resource.adapt(ResourceContent.class).getContent();
            tempfile = new File(catalinaTemp, identity.getSymbolicName() + "-" + identity.getVersion() + ".war");
            IOUtils.copyStream(content, new FileOutputStream(tempfile));
            contentURL = tempfile.toURI().toURL();
        }

        // Get contextPath, username, password
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

    private Set<ResourceHandle> installResources(Context context) throws ProvisionException {
        IllegalArgumentAssertion.assertNotNull(context, "context");
        Set<ResourceHandle> handles = new HashSet<ResourceHandle>();
        for (Resource res : context.getResources()) {
            ResourceIdentity identity = res.getIdentity();
            if (!isAbstract(res) && getEnvironment().getResource(identity) == null) {
                handles.add(installer.installResource(context, res, null));
            }
        }
        return Collections.unmodifiableSet(handles);
View Full Code Here

    }

    private ResourceHandle installBundleResource(Resource resource, Dictionary<String, String> headers) throws ProvisionException {

        // Install the Bundle
        ResourceIdentity identity = resource.getIdentity();
        InputStream content = resource.adapt(ResourceContent.class).getContent();
        Bundle bundle;
        try {
            bundle = context.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

            }
        }

        // #3 Use fallback name deriven from the resource identity
        if (runtimeName == null) {
            ResourceIdentity resid = resource.getIdentity();
            String qualifiedName = resid.getSymbolicName() + "-" + resid.getVersion();
            if (ResourceUtils.isShared(resource)) {
                runtimeName = qualifiedName + ".jar";
            } else if (RuntimeType.TOMCAT == RuntimeType.getRuntimeType()) {
                runtimeName = qualifiedName + ".war";
            } else {
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.