Package org.jboss.gravia.resource

Examples of org.jboss.gravia.resource.ResourceIdentity


    @SuppressWarnings("deprecation")
    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);
View Full Code Here


    private void addModuleDependencies(Resource resource, Map<Requirement, Resource> mapping, StringBuffer buffer) {
        buffer.append(" <dependencies>");
        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

            RepositoryMBean repository = MBeanProxy.get(context.getMBeanServer(), RepositoryMBean.OBJECT_NAME, RepositoryMBean.class);
            try {
                RepositoryReader reader = new DefaultRepositoryXMLReader(input);
                Resource auxres = reader.nextResource();
                while (auxres != null) {
                    ResourceIdentity identity = auxres.getIdentity();
                    if (repository.getResource(identity.getCanonicalForm()) == null) {
                        repository.addResource(auxres.adapt(CompositeData.class));
                        result.add(identity);
                    }
                    auxres = reader.nextResource();
                }
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

        MBeanServer server = ServiceLocator.getRequiredService(context, MBeanServer.class);
        server.unregisterMBean(getObjectName(context.getModule()));
    }

    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

    }

    private ResourceHandle installBundleResource(Resource resource) throws ProvisionException {

        // Install the Bundle
        ResourceIdentity resid = resource.getIdentity();
        ResourceContent content = getFirstRelevantResourceContent(resource);
        IllegalStateAssertion.assertNotNull(content.getContent(), "Cannot obtain content from: " + resource);

        Bundle bundle;
        try {
View Full Code Here

        MBeanServer server = ServiceLocator.getRequiredService(context, MBeanServer.class);
        server.unregisterMBean(getObjectName(context.getModule()));
    }

    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

        Runtime runtime = RuntimeLocator.getRequiredRuntime();

        // Tomcat does not support jar deployments
        Assume.assumeFalse(RuntimeType.TOMCAT == RuntimeType.getRuntimeType());

        ResourceIdentity identityA = ResourceIdentity.fromString("camel.core.unshared");
        MavenCoordinates mavenid = MavenCoordinates.parse("org.apache.camel:camel-core:jar:2.11.0");
        ResourceBuilder builderA = provisioner.getMavenResourceBuilder(identityA, mavenid);
        ResourceHandle handleA = provisioner.installResource(builderA.getResource());
        try {
            Assert.assertSame(handleA.getModule(), runtime.getModule(identityA));
View Full Code Here

    public void testSharedMavenResource() throws Exception {

        Provisioner provisioner = ServiceLocator.getRequiredService(Provisioner.class);
        Runtime runtime = RuntimeLocator.getRequiredRuntime();

        ResourceIdentity identityA = ResourceIdentity.fromString("camel.core.shared");
        MavenCoordinates mavenid = MavenCoordinates.parse("org.apache.camel:camel-core:jar:2.11.0");
        ResourceBuilder builderA = provisioner.getMavenResourceBuilder(identityA, mavenid);
        builderA.addIdentityRequirement("javax.api");
        builderA.addIdentityRequirement("org.slf4j");
        ResourceHandle handleA = provisioner.installSharedResource(builderA.getResource());
        try {
            Assert.assertSame(handleA.getModule(), runtime.getModule(identityA));
            Assert.assertEquals("ACTIVE " + identityA, State.ACTIVE, handleA.getModule().getState());

            ResourceIdentity identityC = ResourceIdentity.fromString(RESOURCE_C);
            ResourceBuilder builderC = provisioner.getContentResourceBuilder(identityC, deployer.getDeployment(RESOURCE_C));
            Map<String, Object> attsC = builderC.getMutableResource().getIdentityCapability().getAttributes();
            attsC.put(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE, RESOURCE_C + ".war");
            ResourceHandle handleC = provisioner.installResource(builderC.getResource());
            try {
View Full Code Here

    public void testAbstractFeature() throws Exception {

        Provisioner provisioner = ServiceLocator.getRequiredService(Provisioner.class);

        // Provision the camel.core feature
        ResourceIdentity identity = ResourceIdentity.fromString("camel.core.feature:0.0.0");
        Requirement req = new IdentityRequirementBuilder(identity).getRequirement();
        Set<ResourceHandle> result = provisioner.provisionResources(Collections.singleton(req));

        List<ResourceHandle> handles = new ArrayList<>(result);
        try {
            // Verify the wiring
            Environment environment = provisioner.getEnvironment();
            Map<Resource, Wiring> wirings = environment.getWirings();
            ResourceIdentity residA = ResourceIdentity.create("org.apache.camel.core", "2.11.0");
            Resource resA = environment.getResource(residA);
            Assert.assertNotNull("Resource in environment", resA);
            Wiring wiringA = wirings.get(resA);
            Assert.assertNotNull("Wiring in environment", wiringA);
            Assert.assertEquals("Two required wires", 2, wiringA.getRequiredResourceWires(null).size());

            // Build a resource that has a class loading dependency
            DefaultResourceBuilder builderD = new DefaultResourceBuilder();
            ResourceIdentity residD = ResourceIdentity.create(RESOURCE_D, Version.emptyVersion);
            Map<String, Object> attsD = builderD.addIdentityCapability(residD).getAttributes();
            attsD.put(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE, RESOURCE_D + ".war");
            builderD.addContentCapability(deployer.getDeployment(RESOURCE_D));
            Resource resD = builderD.getResource();
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.