Search in sources :

Example 1 with EntityManagerFactoryBuilder

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);
            }
        }
    }
}
Also used : AbstractJPAEntityManagerProvider(org.apache.aries.tx.control.jpa.common.impl.AbstractJPAEntityManagerProvider) AbstractJPAEntityManagerProvider(org.apache.aries.tx.control.jpa.common.impl.AbstractJPAEntityManagerProvider) JPAEntityManagerProvider(org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider) EntityManagerFactoryBuilder(org.osgi.service.jpa.EntityManagerFactoryBuilder) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) ConfigurationException(org.osgi.service.cm.ConfigurationException)

Example 2 with EntityManagerFactoryBuilder

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;
}
Also used : EntityManagerFactoryBuilder(org.osgi.service.jpa.EntityManagerFactoryBuilder)

Aggregations

EntityManagerFactoryBuilder (org.osgi.service.jpa.EntityManagerFactoryBuilder)2 AbstractJPAEntityManagerProvider (org.apache.aries.tx.control.jpa.common.impl.AbstractJPAEntityManagerProvider)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1 JPAEntityManagerProvider (org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider)1