Search in sources :

Example 1 with BlueprintRepository

use of org.apache.aries.blueprint.container.BlueprintRepository in project aries by apache.

the class WiringTest method testCircularBreaking.

public void testCircularBreaking() throws Exception {
    BlueprintRepository repository;
    repository = createBlueprintContainer().getRepository();
    assertNotNull(repository.create("c1"));
    repository = createBlueprintContainer().getRepository();
    assertNotNull(repository.create("c2"));
    repository = createBlueprintContainer().getRepository();
    assertNotNull(repository.create("c3"));
}
Also used : BlueprintRepository(org.apache.aries.blueprint.container.BlueprintRepository)

Example 2 with BlueprintRepository

use of org.apache.aries.blueprint.container.BlueprintRepository in project aries by apache.

the class WiringTest method testCircularPrototype.

public void testCircularPrototype() throws Exception {
    BlueprintRepository repository = createBlueprintContainer().getRepository();
    try {
        repository.create("circularPrototypeDriver");
        fail("Did not throw exception");
    } catch (CircularDependencyException e) {
    // that's what we expect
    }
    try {
        repository.create("circularPrototype");
        fail("Did not throw exception");
    } catch (CircularDependencyException e) {
    // that's what we expect
    }
}
Also used : BlueprintRepository(org.apache.aries.blueprint.container.BlueprintRepository) CircularDependencyException(org.apache.aries.blueprint.di.CircularDependencyException)

Example 3 with BlueprintRepository

use of org.apache.aries.blueprint.container.BlueprintRepository in project aries by apache.

the class WiringTest method testRecursive.

public void testRecursive() throws Exception {
    BlueprintRepository repository = createBlueprintContainer().getRepository();
    try {
        repository.create("recursiveConstructor");
        fail("Did not throw exception");
    } catch (ComponentDefinitionException e) {
        if (e.getCause() instanceof CircularDependencyException) {
        // that's what we expect
        } else {
            fail("Did not throw expected exception");
            throw e;
        }
    }
    PojoRecursive pojo;
    pojo = (PojoRecursive) repository.create("recursiveSetter");
    assertNotNull(pojo);
    pojo = (PojoRecursive) repository.create("recursiveInitMethod");
    assertNotNull(pojo);
}
Also used : ComponentDefinitionException(org.osgi.service.blueprint.container.ComponentDefinitionException) BlueprintRepository(org.apache.aries.blueprint.container.BlueprintRepository) CircularDependencyException(org.apache.aries.blueprint.di.CircularDependencyException)

Example 4 with BlueprintRepository

use of org.apache.aries.blueprint.container.BlueprintRepository in project aries by apache.

the class WiringTest method testCircular.

public void testCircular() throws Exception {
    BlueprintRepository repository = createBlueprintContainer().getRepository();
    // this should pass (we allow circular dependencies for components without init method)
    Object obj1 = repository.create("a");
    // test service and listener circular dependencies
    Object obj2 = repository.create("service");
    assertNotNull(obj2);
    assertTrue(obj2 instanceof ServiceRegistration);
    Object obj3 = repository.create("listener");
    assertNotNull(obj3);
    assertTrue(obj3 instanceof PojoListener);
    assertEquals(obj2, ((PojoListener) obj3).getService());
}
Also used : BlueprintRepository(org.apache.aries.blueprint.container.BlueprintRepository) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Aggregations

BlueprintRepository (org.apache.aries.blueprint.container.BlueprintRepository)4 CircularDependencyException (org.apache.aries.blueprint.di.CircularDependencyException)2 ServiceRegistration (org.osgi.framework.ServiceRegistration)1 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)1