Package org.jboss.gravia.resource

Examples of org.jboss.gravia.resource.ContentCapability


        // #2 Try to get the runtime name from the content cpability
        if (runtimeName == null) {
            List<ContentCapability> ccaps = getRelevantContentCapabilities(resource);
            if (ccaps.size() == 1) {
                ContentCapability ccap = ccaps.get(0);
                runtimeName = (String) ccap.getAttribute(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE);
            }
        }

        // #3 Use fallback name deriven from the resource identity
        if (runtimeName == null) {
View Full Code Here


        List<Capability> ccaps = resource.getCapabilities(ContentNamespace.CONTENT_NAMESPACE);
        if (ccaps.isEmpty())
            throw new IllegalArgumentException("Cannot obtain content capability from: " + resource);

        ContentCapability ccap = (ContentCapability) ccaps.get(0);
        URL contentURL = ccap.getContentURL();
        if (contentURL == null)
            throw new IllegalArgumentException("Cannot obtain content URL from: " + ccap);

        synchronized (urls) {
            urls.add(contentURL);
View Full Code Here

                if (!ContentNamespace.CONTENT_NAMESPACE.equals(cap.getNamespace())) {
                    builder.addCapability(cap.getNamespace(), cap.getAttributes(), cap.getDirectives());
                }
            }
            for (Capability cap : ccaps) {
                ContentCapability ccap = cap.adapt(ContentCapability.class);
                Map<String, Object> contentAtts = new HashMap<String, Object>();
                String mimeType = (String) ccap.getAttribute(ContentNamespace.CAPABILITY_MIME_ATTRIBUTE);
                if (mimeType != null) {
                    contentAtts.put(ContentNamespace.CAPABILITY_MIME_ATTRIBUTE, mimeType);
                }
                InputStream input = getResourceContent(ccap);
                try {
View Full Code Here

        File tempfile = null;
        ResourceIdentity identity = resource.getIdentity();
        String runtimeName = getRuntimeName(resource);

        ContentCapability ccap = (ContentCapability) resource.getCapabilities(ContentNamespace.CONTENT_NAMESPACE).get(0);
        URL contentURL = ccap.getContentURL();
        if (contentURL == null || !contentURL.toExternalForm().startsWith("file:")) {
            ResourceContent content = getFirstRelevantResourceContent(resource);
            tempfile = new File(catalinaTemp, runtimeName);
            IOUtils.copyStream(content.getContent(), new FileOutputStream(tempfile));
            contentURL = tempfile.toURI().toURL();
View Full Code Here

    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();
View Full Code Here

        // #2 Try to get the runtime name from the content cpability
        if (runtimeName == null) {
            List<ContentCapability> ccaps = getRelevantContentCapabilities(resource);
            if (ccaps.size() == 1) {
                ContentCapability ccap = ccaps.get(0);
                runtimeName = (String) ccap.getAttribute(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE);
            }
        }

        // #3 Use fallback name deriven from the resource identity
        if (runtimeName == null) {
View Full Code Here

        List<Capability> ccaps = resource.getCapabilities(ContentNamespace.CONTENT_NAMESPACE);
        if (ccaps.isEmpty())
            throw new IllegalArgumentException("Cannot obtain content capability from: " + resource);

        ContentCapability ccap = (ContentCapability) ccaps.get(0);
        URL contentURL = ccap.getContentURL();
        if (contentURL == null)
            throw new IllegalArgumentException("Cannot obtain content URL from: " + ccap);

        synchronized (urls) {
            urls.add(contentURL);
View Full Code Here

        List<Capability> ccaps = getCapabilities(ContentNamespace.CONTENT_NAMESPACE);
        if (ccaps.isEmpty())
            return null;

        ContentCapability ccap = ccaps.get(0).adapt(ContentCapability.class);
        InputStream contentStream = ccap.getContentStream();
        if (contentStream == null) {
            URL contentURL = ccap.getContentURL();
            if (contentURL != null) {
                try {
                    contentStream = contentURL.openStream();
                } catch (IOException ex) {
                    throw new IllegalStateException("Cannot access content URL: " + contentURL, ex);
View Full Code Here

    private ResourceHandle installUnsharedResourceInternal(String runtimeName, Context context, Resource resource) 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) {
            ResourceContent content = resource.adapt(ResourceContent.class);
            IllegalStateAssertion.assertNotNull(content, "Cannot obtain content from: " + resource);
            tempfile = new File(catalinaTemp, identity.getSymbolicName() + "-" + identity.getVersion() + ".war");
            IOUtils.copyStream(content.getContent(), new FileOutputStream(tempfile));
View Full Code Here

        File tempfile = null;
        ResourceIdentity identity = resource.getIdentity();
        String runtimeName = getRuntimeName(resource);

        Path catalinaTemp = runtime.getCatalinaHome().resolve("temp");
        ContentCapability ccap = (ContentCapability) resource.getCapabilities(ContentNamespace.CONTENT_NAMESPACE).get(0);
        URL contentURL = ccap.getContentURL();
        if (contentURL == null || !contentURL.toExternalForm().startsWith("file:")) {
            ResourceContent content = getFirstRelevantResourceContent(resource);
            tempfile = catalinaTemp.resolve(runtimeName).toFile();
            IOUtils.copyStream(content.getContent(), new FileOutputStream(tempfile));
            contentURL = tempfile.toURI().toURL();
View Full Code Here

TOP

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

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.