Package org.jboss.gravia.resource

Examples of org.jboss.gravia.resource.Version


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

        ResourceIdentity identity = resource.getIdentity();
        String symbolicName = identity.getSymbolicName();
        Version version = identity.getVersion();
        File modulesDir = injectedServerEnvironment.getValue().getModulesDir();
        File moduleDir = new File(modulesDir, symbolicName.replace(".", File.separator) + File.separator + version);
        if (moduleDir.exists())
            throw new IllegalStateException("Module dir already exists: " + moduleDir);

        ResourceContent content = resource.adapt(ResourceContent.class);
        IllegalStateAssertion.assertNotNull(content, "Cannot obtain content from: " + resource);

        // copy resource content
        moduleDir.mkdirs();
        File resFile = new File(moduleDir, symbolicName + "-" + version + ".jar");
        IOUtils.copyStream(content.getContent(), new FileOutputStream(resFile));

        ModuleIdentifier modid = ModuleIdentifier.create(symbolicName, version.toString());

        // generate module.xml
        File xmlFile = new File(moduleDir, "module.xml");
        Map<Requirement, Resource> mapping = context.getResourceMapping();
        String moduleXML = generateModuleXML(resFile, resource, modid, mapping);
View Full Code Here


        for (Requirement req : resource.getRequirements(IdentityNamespace.IDENTITY_NAMESPACE)) {
            Resource depres = mapping != null ? mapping.get(req) : null;
            if (depres != null) {
                ResourceIdentity identity = depres.getIdentity();
                String modname = identity.getSymbolicName();
                Version version = identity.getVersion();
                String slot = version != Version.emptyVersion ? "slot='" + version + "'" : "";
                buffer.append("<module name='" + modname + "' " + slot + "/>");
                LOGGER.info("  {}", identity);
            } else {
                String modname = (String) req.getAttribute(IdentityNamespace.IDENTITY_NAMESPACE);
View Full Code Here

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

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

        ModuleIdentifier modid = ModuleIdentifier.create(symbolicName, version.toString());

        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

        for (Requirement req : resource.getRequirements(IdentityNamespace.IDENTITY_NAMESPACE)) {
            Resource depres = mapping != null ? mapping.get(req) : null;
            if (depres != null) {
                ResourceIdentity identity = depres.getIdentity();
                String modname = identity.getSymbolicName();
                Version version = identity.getVersion();
                String slot = version != Version.emptyVersion ? "slot='" + version + "'" : "";
                buffer.append("<module name='" + modname + "' " + slot + "/>");
                LOGGER.info("  {}", identity);
            } else {
                String modname = (String) req.getAttribute(IdentityNamespace.IDENTITY_NAMESPACE);
View Full Code Here

        }

        @Override
        public Resource getResource(ResourceIdentity identity) {
            String symbolicName = identity.getSymbolicName();
            Version version = identity.getVersion();
            String modname = symbolicName + (version != Version.emptyVersion ? ":" + version : "");
            ModuleIdentifier modid = ModuleIdentifier.fromString(modname);
            try {
                ModuleLoader moduleLoader = Module.getBootModuleLoader();
                moduleLoader.loadModule(modid);
View Full Code Here

            if (versionRange != null && moduleDir.isDirectory()) {
                for (File file : moduleDir.listFiles()) {
                    if (!file.isDirectory() || file.getName().equals("main")) {
                        continue;
                    }
                    Version version;
                    try {
                        version = new Version(file.getName());
                    } catch (Throwable th) {
                        continue;
                    }
                    if (!versionRange.includes(version)) {
                        continue;
View Full Code Here

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

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

        // copy resource content
        final File targetFile = new File(catalinaLib, symbolicName + "-" + version + ".jar");
        if (targetFile.exists()) {
            LOGGER.warn("Module already exists: " + targetFile);
View Full Code Here

                    if (w1 == null && w2 != null)
                        return +1;
                }

                // Prefer higher version
                Version v1 = AbstractCapability.getVersion(cap1, IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
                Version v2 = AbstractCapability.getVersion(cap2, IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
                return v2.compareTo(v1);
            }
        };    }
View Full Code Here

            throw new IllegalArgumentException("Resource and header identity does not match: " + resourceIdentity);
    }

    private String getIdentityHeader(ResourceIdentity identity) {
        String symbolicName = identity.getSymbolicName();
        Version version = identity.getVersion();
        return symbolicName + ";version=" + version;
    }
View Full Code Here

    @Override
    public ResourceIdentity getIdentity() {
        if (identity == null) {
            Capability icap = getIdentityCapability();
            String symbolicName = (String) icap.getAttribute(IdentityNamespace.IDENTITY_NAMESPACE);
            Version version = (Version) icap.getAttribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
            identity = ResourceIdentity.create(symbolicName, version);
        }
        return identity;
    }
View Full Code Here

TOP

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

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.