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
}
}
}
}
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;
}
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);
}
}
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);
}
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();
}
Aggregations