Search in sources :

Example 1 with Coordinator

use of org.osgi.service.coordinator.Coordinator in project aries by apache.

the class Activator method removedService.

@Override
public synchronized void removedService(ServiceReference<Object> reference, Object service) {
    if (service instanceof Coordinator) {
        if (service.equals(coordinator)) {
            Coordinator coordinator = findAlternateServiceFor(Coordinator.class);
            if (coordinator == null)
                deactivate();
            this.coordinator = coordinator;
        }
    } else if (service instanceof RegionDigraph) {
        if (service.equals(regionDigraph)) {
            RegionDigraph regionDigraph = findAlternateServiceFor(RegionDigraph.class);
            if (regionDigraph == null)
                deactivate();
            this.regionDigraph = regionDigraph;
        }
    } else if (service instanceof Resolver) {
        if (service.equals(resolver)) {
            Resolver resolver = findAlternateServiceFor(Resolver.class);
            if (resolver == null)
                deactivate();
            this.resolver = resolver;
        }
    } else if (service instanceof IDirectoryFinder)
        finders.remove(service);
    else {
        if (service.equals(modelledResourceManager)) {
            try {
                Class clazz = getClass().getClassLoader().loadClass(MODELLED_RESOURCE_MANAGER);
                Object manager = findAlternateServiceFor(clazz);
                if (manager == null) {
                    modelledResourceManager = null;
                    serviceModeller = null;
                } else {
                    modelledResourceManager = service;
                    serviceModeller = new ApplicationServiceModeller(service);
                }
            } catch (ClassNotFoundException e) {
            // ignore
            } catch (NoClassDefFoundError e) {
            // ignore
            }
        }
    }
}
Also used : RegionDigraph(org.eclipse.equinox.region.RegionDigraph) Resolver(org.osgi.service.resolver.Resolver) IDirectoryFinder(org.apache.aries.util.filesystem.IDirectoryFinder) Coordinator(org.osgi.service.coordinator.Coordinator)

Example 2 with Coordinator

use of org.osgi.service.coordinator.Coordinator in project aries by apache.

the class TxNamespaceHandler method createAnnotationParserBean.

private MutableBeanMetadata createAnnotationParserBean(ParserContext pc, ComponentDefinitionRegistry cdr) {
    MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
    meta.setId(ANNOTATION_PARSER_BEAN_NAME);
    meta.setRuntimeClass(AnnotationProcessor.class);
    meta.setProcessor(true);
    meta.addArgument(passThrough(pc, cdr), ComponentDefinitionRegistry.class.getName(), 0);
    meta.addArgument(passThrough(pc, tm), TransactionManager.class.getName(), 1);
    meta.addArgument(passThrough(pc, coordinator), Coordinator.class.getName(), 1);
    return meta;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) ComponentDefinitionRegistry(org.apache.aries.blueprint.ComponentDefinitionRegistry) TransactionManager(javax.transaction.TransactionManager) Coordinator(org.osgi.service.coordinator.Coordinator)

Example 3 with Coordinator

use of org.osgi.service.coordinator.Coordinator in project aries by apache.

the class Aries1426Test method testNoEffectOnSharingPolicy.

@Test
public void testNoEffectOnSharingPolicy() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        Map<String, String> headers = applicationA.getDeploymentHeaders();
        // There should be no subsystem Require-Capability header because 
        // the Application-ImportService header included the only relevant
        // bundle clause.
        assertNull("Wrong Require-Capability", headers.get(Constants.REQUIRE_CAPABILITY));
        // There should be no subsystem Subsystem-ImportService header 
        // because the Application-ImportService header included the only 
        // relevant bundle clause.
        assertNull("Wrong Subsystem-ImportService", headers.get(SubsystemConstants.SUBSYSTEM_IMPORTSERVICE));
        org.apache.aries.subsystem.core.archive.Header<?> expected = new SubsystemContentHeader("bundle.a.jar;version=\"[0,0]\"");
        org.apache.aries.subsystem.core.archive.Header<?> actual = new SubsystemContentHeader(headers.get(SubsystemConstants.SUBSYSTEM_CONTENT));
        // The Subsystem-Content header should not include any synthesized
        // resources used to process Application-ImportService.
        assertEquals("Wrong Subsystem-Content", expected, actual);
        expected = new GenericHeader("Application-ImportService", "org.osgi.service.coordinator.Coordinator");
        actual = new GenericHeader("Application-ImportService", headers.get("Application-ImportService"));
        // The Application-ImportService header should be included in the
        // deployment manifest.
        assertEquals("Wrong Application-ImportService", expected, actual);
        BundleContext context = applicationA.getBundleContext();
        // The Coordinator service should not be visible to the application
        // region because Application-ImportService does not affect the
        // sharing policy and nothing outside of the subsystems 
        // implementation made it visible.
        assertNull("Coordinator service should not be visible", context.getServiceReference(Coordinator.class));
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : SubsystemContentHeader(org.apache.aries.subsystem.core.archive.SubsystemContentHeader) Subsystem(org.osgi.service.subsystem.Subsystem) GenericHeader(org.apache.aries.subsystem.core.archive.GenericHeader) Coordinator(org.osgi.service.coordinator.Coordinator) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 4 with Coordinator

use of org.osgi.service.coordinator.Coordinator in project aries by apache.

the class BaseNameSpaceHandlerSetup method setUp.

@Before
public void setUp() throws InvalidSyntaxException {
    control = EasyMock.createControl();
    b = control.createMock(Bundle.class);
    TransactionManager tm = control.createMock(TransactionManager.class);
    Coordinator coordinator = control.createMock(Coordinator.class);
    control.replay();
    namespaceHandler = new TxNamespaceHandler();
    namespaceHandler.setTm(tm);
    namespaceHandler.setCoordinator(coordinator);
    String[] namespaces = new String[] { "http://aries.apache.org/xmlns/transactions/v2.0.0" };
    nhri = new DummyNamespaceHandlerRegistry();
    nhri.addNamespaceHandlers(namespaces, namespaceHandler);
}
Also used : Bundle(org.osgi.framework.Bundle) TransactionManager(javax.transaction.TransactionManager) TxNamespaceHandler(org.apache.aries.transaction.parsing.TxNamespaceHandler) Coordinator(org.osgi.service.coordinator.Coordinator) Before(org.junit.Before)

Example 5 with Coordinator

use of org.osgi.service.coordinator.Coordinator in project aries by apache.

the class InterceptorTest method postCallWithTransaction.

private void postCallWithTransaction(Throwable th, boolean expectRollback, boolean failCoordination) throws Throwable {
    IMocksControl c = EasyMock.createControl();
    TransactionManager tm = c.createMock(TransactionManager.class);
    Coordinator coordinator = c.createMock(Coordinator.class);
    ComponentTxData txData = new ComponentTxData(AnnotatedPojo.class);
    TxInterceptorImpl sut = new TxInterceptorImpl(tm, coordinator, txData);
    Transaction tran = c.createMock(Transaction.class);
    if (expectRollback) {
        tran.setRollbackOnly();
        EasyMock.expectLastCall();
    }
    Coordination coordination = c.createMock(Coordination.class);
    coordination.end();
    if (failCoordination) {
        EasyMock.expectLastCall().andThrow(coordinationException(th));
    } else {
        EasyMock.expectLastCall();
    }
    c.replay();
    TransactionToken tt = new TransactionToken(tran, null, TransactionAttribute.REQUIRED);
    tt.setCoordination(coordination);
    sut.postCallWithException(null, this.getClass().getMethods()[0], th, tt);
    c.verify();
}
Also used : IMocksControl(org.easymock.IMocksControl) Transaction(javax.transaction.Transaction) Coordination(org.osgi.service.coordinator.Coordination) TransactionManager(javax.transaction.TransactionManager) Coordinator(org.osgi.service.coordinator.Coordinator)

Aggregations

Coordinator (org.osgi.service.coordinator.Coordinator)7 TransactionManager (javax.transaction.TransactionManager)3 BundleContext (org.osgi.framework.BundleContext)2 Coordination (org.osgi.service.coordinator.Coordination)2 ReporterLogService (aQute.bnd.deployer.repository.ReporterLogService)1 Jar (aQute.bnd.osgi.Jar)1 Version (aQute.bnd.version.Version)1 BndResolver (biz.aQute.resolve.BndResolver)1 ResolveProcess (biz.aQute.resolve.ResolveProcess)1 ResolverLogger (biz.aQute.resolve.ResolverLogger)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Transaction (javax.transaction.Transaction)1 ComponentDefinitionRegistry (org.apache.aries.blueprint.ComponentDefinitionRegistry)1 MutableBeanMetadata (org.apache.aries.blueprint.mutable.MutableBeanMetadata)1 GenericHeader (org.apache.aries.subsystem.core.archive.GenericHeader)1 SubsystemContentHeader (org.apache.aries.subsystem.core.archive.SubsystemContentHeader)1 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)1