Package org.jboss.gravia.resource

Examples of org.jboss.gravia.resource.Version


    }

    public static Version getVersion(Capability cap, String attname) {
        Object attval = cap.getAttributes().get(attname);
        if (attval != null && !(attval instanceof Version)) {
            attval = new Version(attval.toString());
            cap.getAttributes().put(attname, attval);
        }
        return attval != null ? (Version) attval : Version.emptyVersion;
    }
View Full Code Here


        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

        public Resource getResource(ResourceIdentity identity) {
            synchronized (cachedResources) {
                Resource resource = cachedResources.getResource(identity);
                if (resource == null) {
                    String symbolicName = identity.getSymbolicName();
                    Version version = identity.getVersion();
                    String modname = symbolicName + (version != Version.emptyVersion ? ":" + version : "");
                    ModuleIdentifier modid = ModuleIdentifier.fromString(modname);
                    ModuleLoader moduleLoader = Module.getBootModuleLoader();
                    try {
                        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
        Path catalinaLib = runtime.getCatalinaHome().resolve("lib");
        final File targetFile = catalinaLib.resolve(symbolicName + "-" + version + ".jar").toFile();
        if (targetFile.exists()) {
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

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

        String runtimeName = getRuntimeName(resource, true);
        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 = getFirstRelevantResourceContent(resource);
        IllegalStateAssertion.assertNotNull(content, "Cannot obtain content from: " + resource);

        // copy resource content
        moduleDir.mkdirs();
        File resFile = new File(moduleDir, runtimeName);
        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

    @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

    }

    public static Version getVersion(Capability cap, String attname) {
        Object attval = cap.getAttributes().get(attname);
        if (attval != null && !(attval instanceof Version)) {
            attval = new Version(attval.toString());
            cap.getAttributes().put(attname, attval);
        }
        return attval != null ? (Version)attval : Version.emptyVersion;
    }
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.