use of org.osgi.service.jpa.EntityManagerFactoryBuilder in project aries by apache.
the class AbstractManagedJPAEMFLocator method removedService.
@Override
public void removedService(ServiceReference<EntityManagerFactoryBuilder> reference, EntityManagerFactoryBuilder service) {
boolean emfbLeft;
ServiceRegistration<JPAEntityManagerProvider> oldReg = null;
AbstractJPAEntityManagerProvider toClose = null;
synchronized (this) {
emfbLeft = activeEMFB.compareAndSet(service, null);
if (emfbLeft) {
toClose = providerObject.get();
oldReg = serviceReg.getAndSet(null);
}
}
if (oldReg != null) {
try {
oldReg.unregister();
} catch (IllegalStateException ise) {
LOG.debug("An exception occurred when unregistering a service for {}", pid);
}
}
if (toClose != null) {
try {
toClose.close();
} catch (Exception e) {
LOG.debug("An Exception occured when closing the Resource provider for {}", pid, e);
}
}
try {
context.ungetService(reference);
} catch (IllegalStateException ise) {
LOG.debug("An exception occurred when ungetting the service for {}", reference);
}
if (emfbLeft) {
ServiceReference<EntityManagerFactoryBuilder> newEMFBuilderRef = emfBuilderTracker.getServiceReference();
if (newEMFBuilderRef != null) {
EntityManagerFactoryBuilder newEMFBuilder = emfBuilderTracker.getService(newEMFBuilderRef);
if (newEMFBuilder != null) {
updateService(newEMFBuilderRef, newEMFBuilder);
}
}
}
}
use of org.osgi.service.jpa.EntityManagerFactoryBuilder in project aries by apache.
the class AbstractManagedJPAEMFLocator method addingService.
@Override
public EntityManagerFactoryBuilder addingService(ServiceReference<EntityManagerFactoryBuilder> reference) {
EntityManagerFactoryBuilder service = context.getService(reference);
updateService(reference, service);
return service;
}
Aggregations