diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.database/src/org/eclipse')
-rw-r--r-- | plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java | 3 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/RemoteIdManager.java | 24 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/IdentityServiceImpl.java (renamed from plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/RemoteIdManagerImpl.java) | 36 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java | 7 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java | 14 |
5 files changed, 28 insertions, 56 deletions
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java index 1141dcd06ff..736cba49a31 100644 --- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java +++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java @@ -17,15 +17,12 @@ import org.eclipse.osee.framework.core.exception.OseeDataStoreException; import org.eclipse.osee.framework.database.core.IOseeSequence; import org.eclipse.osee.framework.database.core.IOseeStatement; import org.eclipse.osee.framework.database.core.OseeConnection; -import org.eclipse.osee.framework.database.core.RemoteIdManager; /** * @author Roberto E. Escobar */ public interface IOseeDatabaseService { - RemoteIdManager getRemoteIdManager(); - IOseeSequence getSequence() throws OseeDataStoreException; IOseeStatement getStatement() throws OseeDataStoreException; diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/RemoteIdManager.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/RemoteIdManager.java deleted file mode 100644 index f3027e0ebdf..00000000000 --- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/RemoteIdManager.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Created on Aug 17, 2011 - * - * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE - */ -package org.eclipse.osee.framework.database.core; - -import java.util.Collection; -import org.eclipse.osee.framework.core.data.Identity; -import org.eclipse.osee.framework.core.exception.OseeCoreException; - -public interface RemoteIdManager { - - Integer getLocalId(Long remoteId) throws OseeCoreException; - - Long getRemoteId(Integer localId) throws OseeCoreException; - - int getLocalId(Identity<Long> identity) throws OseeCoreException; - - void store(Collection<Long> remoteIds) throws OseeCoreException; - - void clear(); - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/RemoteIdManagerImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/IdentityServiceImpl.java index 98d7dbe10cc..0200ac772bb 100644 --- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/RemoteIdManagerImpl.java +++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/IdentityServiceImpl.java @@ -14,51 +14,51 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListSet; import org.eclipse.osee.framework.core.data.Identity; import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.services.IdentityService; import org.eclipse.osee.framework.core.util.Conditions; import org.eclipse.osee.framework.database.IOseeDatabaseService; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.RemoteIdManager; import org.eclipse.osee.framework.jdk.core.util.Collections; import org.eclipse.osee.framework.jdk.core.util.Lib; -public class RemoteIdManagerImpl implements RemoteIdManager { +public class IdentityServiceImpl implements IdentityService { private static final String SELECT_ALL = "select * from osee_type_id_map"; private static final String INSERT_SQL = "insert into osee_type_id_map (remote_id, local_id) values (?,?)"; - private final Map<Long, Integer> remoteIdToLocalId = new ConcurrentHashMap<Long, Integer>(); - private final Map<Integer, Long> localIdToRemoteId = new ConcurrentHashMap<Integer, Long>(); + private final Map<Long, Integer> universalIdToLocalId = new ConcurrentHashMap<Long, Integer>(); + private final Map<Integer, Long> localIdToUniversalId = new ConcurrentHashMap<Integer, Long>(); private final Set<Long> persistedIds = new ConcurrentSkipListSet<Long>(); private final IOseeDatabaseService service; private volatile boolean ensurePopulatedRanOnce; - public RemoteIdManagerImpl(IOseeDatabaseService service) { + public IdentityServiceImpl(IOseeDatabaseService service) { super(); this.service = service; } @Override - public Integer getLocalId(Long remoteId) throws OseeCoreException { + public Integer getLocalId(Long universalId) throws OseeCoreException { ensurePopulate(); - Conditions.checkNotNull(remoteId, "remoteId"); - Integer localId = remoteIdToLocalId.get(remoteId); + Conditions.checkNotNull(universalId, "universalId"); + Integer localId = universalIdToLocalId.get(universalId); if (localId == null) { reloadCache(); - localId = remoteIdToLocalId.get(remoteId); + localId = universalIdToLocalId.get(universalId); if (localId == null) { localId = service.getSequence().getNextLocalTypeId(); - cache(remoteId, localId); + cache(universalId, localId); } } return localId; } @Override - public Long getRemoteId(Integer localId) throws OseeCoreException { + public Long getUniversalId(Integer localId) throws OseeCoreException { ensurePopulate(); Conditions.checkNotNull(localId, "localId"); - Long remoteId = localIdToRemoteId.get(localId); + Long remoteId = localIdToUniversalId.get(localId); if (remoteId == null) { throw new OseeCoreException("Remote id for local id [%s] was not found", remoteId); } @@ -85,14 +85,14 @@ public class RemoteIdManagerImpl implements RemoteIdManager { @Override public void clear() { - remoteIdToLocalId.clear(); - localIdToRemoteId.clear(); + universalIdToLocalId.clear(); + localIdToUniversalId.clear(); persistedIds.clear(); } private void cache(Long remoteId, Integer localId) { - remoteIdToLocalId.put(remoteId, localId); - localIdToRemoteId.put(localId, remoteId); + universalIdToLocalId.put(remoteId, localId); + localIdToUniversalId.put(localId, remoteId); } private synchronized void ensurePopulate() throws OseeCoreException { @@ -103,10 +103,10 @@ public class RemoteIdManagerImpl implements RemoteIdManager { } @Override - public void store(Collection<Long> remoteIds) throws OseeCoreException { + public void store(Collection<Long> universalIds) throws OseeCoreException { ensurePopulate(); List<Object[]> data = new ArrayList<Object[]>(); - List<Long> toPersist = Collections.setComplement(remoteIds, persistedIds); + List<Long> toPersist = Collections.setComplement(universalIds, persistedIds); for (Long remoteId : toPersist) { Integer localId = getLocalId(remoteId); data.add(new Object[] {remoteId, localId}); diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java index e6e72ff7a1a..4cbda6ebf61 100644 --- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java +++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java @@ -27,7 +27,6 @@ import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider; import org.eclipse.osee.framework.database.core.IOseeSequence; import org.eclipse.osee.framework.database.core.IOseeStatement; import org.eclipse.osee.framework.database.core.OseeConnection; -import org.eclipse.osee.framework.database.core.RemoteIdManager; import org.eclipse.osee.framework.database.internal.Activator; import org.eclipse.osee.framework.logging.OseeLog; @@ -42,11 +41,9 @@ public class OseeDatabaseServiceImpl implements IOseeDatabaseService { private final IOseeSequence oseeSequence; private final ConnectionFactoryProvider dbConnectionFactory; private final IDatabaseInfoProvider dbInfoProvider; - private final RemoteIdManager remoteIdManager; public OseeDatabaseServiceImpl(IDatabaseInfoProvider dbInfoProvider, ConnectionFactoryProvider dbConnectionFactory) { this.oseeSequence = new OseeSequenceImpl(this); - this.remoteIdManager = new RemoteIdManagerImpl(this); this.dbInfoProvider = dbInfoProvider; this.dbConnectionFactory = dbConnectionFactory; } @@ -230,8 +227,4 @@ public class OseeDatabaseServiceImpl implements IOseeDatabaseService { return getDatabaseInfoProvider().isProduction(); } - @Override - public RemoteIdManager getRemoteIdManager() { - return remoteIdManager; - } } diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java index 4642f7d77d8..23a71c9f8d8 100644 --- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java +++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java @@ -11,10 +11,13 @@ package org.eclipse.osee.framework.database.internal.trackers; import java.util.Map; +import org.eclipse.osee.framework.core.services.IdentityService; import org.eclipse.osee.framework.core.util.AbstractTrackingHandler; +import org.eclipse.osee.framework.core.util.OsgiUtil; import org.eclipse.osee.framework.database.IOseeDatabaseService; import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider; import org.eclipse.osee.framework.database.internal.core.ConnectionFactoryProvider; +import org.eclipse.osee.framework.database.internal.core.IdentityServiceImpl; import org.eclipse.osee.framework.database.internal.core.OseeDatabaseServiceImpl; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -26,7 +29,8 @@ public final class OseeDatabaseServiceRegistrationHandler extends AbstractTracki private final static Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {IDatabaseInfoProvider.class}; - private ServiceRegistration serviceRegistration; + private ServiceRegistration<?> serviceRegistration; + private ServiceRegistration<?> serviceRegistration2; public OseeDatabaseServiceRegistrationHandler() { super(); @@ -44,12 +48,14 @@ public final class OseeDatabaseServiceRegistrationHandler extends AbstractTracki ConnectionFactoryProvider dbConnectionFactory = new ConnectionFactoryProvider(context); IOseeDatabaseService databaseService = new OseeDatabaseServiceImpl(dbInfoProvider, dbConnectionFactory); serviceRegistration = context.registerService(IOseeDatabaseService.class.getName(), databaseService, null); + + IdentityService identityService = new IdentityServiceImpl(databaseService); + serviceRegistration2 = context.registerService(IdentityService.class.getName(), identityService, null); } @Override public void onDeActivate() { - if (serviceRegistration != null) { - serviceRegistration.unregister(); - } + OsgiUtil.close(serviceRegistration); + OsgiUtil.close(serviceRegistration2); } }
\ No newline at end of file |