Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-08-23 19:52:49 +0000
committerrescobar2010-08-23 19:52:49 +0000
commitf36d6d6d5a0fd6599e9bdb4d1b7c0ea1bf416d6c (patch)
tree55438bfbc205fa048582787970eb76b0e6000c1f /plugins/org.eclipse.osee.framework.core.message
parent9f26ca3c7b9276f27fc6116315b9393cab1aa631 (diff)
downloadorg.eclipse.osee-f36d6d6d5a0fd6599e9bdb4d1b7c0ea1bf416d6c.tar.gz
org.eclipse.osee-f36d6d6d5a0fd6599e9bdb4d1b7c0ea1bf416d6c.tar.xz
org.eclipse.osee-f36d6d6d5a0fd6599e9bdb4d1b7c0ea1bf416d6c.zip
Updated class dependencies to reflect direct cache dependency instead of depending on the cache service object which brings in unnecessary dependencies.
Updated DataTranslationService registration to use dependency tracker
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.message')
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/Activator.java98
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java30
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceRegHandler.java67
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/AttributeTypeCacheUpdateResponseTranslator.java13
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionCacheUpdateResponseTranslator.java13
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionRecordTranslator.java12
7 files changed, 101 insertions, 134 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.message/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.message/META-INF/MANIFEST.MF
index 7357b027f17..b7809717fdd 100644
--- a/plugins/org.eclipse.osee.framework.core.message/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.core.message/META-INF/MANIFEST.MF
@@ -17,6 +17,8 @@ Import-Package: org.eclipse.core.runtime,
org.eclipse.osee.framework.core.translation,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.logging,
org.osgi.framework,
org.osgi.util.tracker
Export-Package: org.eclipse.osee.framework.core.message
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/Activator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/Activator.java
index cc1f1e8902f..d2edeeaaa6e 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/Activator.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/Activator.java
@@ -10,109 +10,25 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.message.internal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.osee.framework.core.enums.OseeServiceTrackerId;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.BranchFactory;
-import org.eclipse.osee.framework.core.model.OseeModelFactoryService;
-import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
-import org.eclipse.osee.framework.core.model.type.ArtifactTypeFactory;
-import org.eclipse.osee.framework.core.model.type.AttributeTypeFactory;
-import org.eclipse.osee.framework.core.model.type.OseeEnumTypeFactory;
-import org.eclipse.osee.framework.core.model.type.RelationTypeFactory;
-import org.eclipse.osee.framework.core.services.IOseeCachingService;
-import org.eclipse.osee.framework.core.services.IOseeCachingServiceProvider;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
-import org.eclipse.osee.framework.core.translation.IDataTranslationService;
+import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
-public class Activator implements BundleActivator, IOseeCachingServiceProvider, IOseeModelFactoryServiceProvider {
+public class Activator implements BundleActivator {
public static final String PLUGIN_ID = "org.eclipse.osee.framework.core.model";
- private static Activator instance = null;
- private BundleContext bundleContext;
- private final List<ServiceRegistration> services;
- private final Map<OseeServiceTrackerId, ServiceTracker> mappedTrackers;
-
- public Activator() {
- services = new ArrayList<ServiceRegistration>();
- mappedTrackers = new HashMap<OseeServiceTrackerId, ServiceTracker>();
- }
+ private ServiceDependencyTracker dependencyTracker;
@Override
public void start(BundleContext context) throws Exception {
- instance = this;
- instance.bundleContext = context;
-
- IOseeModelFactoryService factories = createFactoryService();
- IDataTranslationService service = new DataTranslationServiceFactory().createService(this, this);
-
- createService(context, IOseeModelFactoryService.class, factories);
- createService(context, IDataTranslationService.class, service);
-
- createServiceTracker(context, IOseeCachingService.class, OseeServiceTrackerId.OSEE_CACHING_SERVICE);
- createServiceTracker(context, IOseeModelFactoryService.class, OseeServiceTrackerId.OSEE_MODEL_FACTORY);
- }
-
- private IOseeModelFactoryService createFactoryService() {
- return new OseeModelFactoryService(new BranchFactory(), new TransactionRecordFactory(),
- new ArtifactTypeFactory(), new AttributeTypeFactory(), new RelationTypeFactory(), new OseeEnumTypeFactory());
+ dependencyTracker = new ServiceDependencyTracker(context, new DataTranslationServiceRegHandler());
+ dependencyTracker.open();
}
@Override
public void stop(BundleContext context) throws Exception {
- for (ServiceRegistration service : services) {
- service.unregister();
- }
-
- for (ServiceTracker tracker : mappedTrackers.values()) {
- tracker.close();
- }
- services.clear();
- mappedTrackers.clear();
-
- instance.bundleContext = null;
- instance = null;
- }
-
- public static BundleContext getBundleContext() {
- return instance.bundleContext;
- }
-
- private void createService(BundleContext context, Class<?> serviceInterface, Object serviceImplementation) {
- services.add(context.registerService(serviceInterface.getName(), serviceImplementation, null));
- }
-
- private void createServiceTracker(BundleContext context, Class<?> clazz, OseeServiceTrackerId trackerId) {
- ServiceTracker tracker = new ServiceTracker(context, clazz.getName(), null);
- tracker.open();
- mappedTrackers.put(trackerId, tracker);
- }
-
- @Override
- public IOseeCachingService getOseeCachingService() {
- return getTracker(OseeServiceTrackerId.OSEE_CACHING_SERVICE, IOseeCachingService.class);
+ Lib.close(dependencyTracker);
}
- private <T> T getTracker(OseeServiceTrackerId trackerId, Class<T> clazz) {
- ServiceTracker tracker = mappedTrackers.get(trackerId);
- Object service = tracker.getService();
- return clazz.cast(service);
- }
-
- @Override
- public IOseeModelFactoryService getOseeFactoryService() throws OseeCoreException {
- return getTracker(OseeServiceTrackerId.OSEE_MODEL_FACTORY, IOseeModelFactoryService.class);
- }
-
- public static Activator getInstance() {
- return instance;
- }
}
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java
index 920e272b50d..c8157d3c083 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java
@@ -37,8 +37,9 @@ import org.eclipse.osee.framework.core.message.internal.translation.RelationType
import org.eclipse.osee.framework.core.message.internal.translation.TableDataTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.TransactionCacheUpdateResponseTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.TransactionRecordTranslator;
-import org.eclipse.osee.framework.core.services.IOseeCachingServiceProvider;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
+import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
+import org.eclipse.osee.framework.core.model.type.AttributeTypeFactory;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.core.translation.IDataTranslationService;
/**
@@ -48,28 +49,13 @@ import org.eclipse.osee.framework.core.translation.IDataTranslationService;
public class DataTranslationServiceFactory {
public DataTranslationServiceFactory() {
+ //
}
- public IDataTranslationService createService(IOseeCachingServiceProvider cachingService, IOseeModelFactoryServiceProvider factoryProvider) throws OseeCoreException {
+ public IDataTranslationService createService(IOseeCachingService cachingService, TransactionRecordFactory txRecordFactory, AttributeTypeFactory attributeTypeFactory) throws OseeCoreException {
IDataTranslationService service = new DataTranslationService();
- // service.addTranslator(new BasicArtifactTranslator(),
- // CoreTranslatorId.ARTIFACT_METADATA);
- // service.addTranslator(new BranchTranslator(service, factoryProvider),
- // CoreTranslatorId.BRANCH);
-
- // service.addTranslator(new ArtifactTypeTranslator(service,
- // factoryProvider), CoreTranslatorId.ARTIFACT_TYPE);
- // service.addTranslator(new AttributeTypeTranslator(service,
- // factoryProvider), CoreTranslatorId.ATTRIBUTE_TYPE);
- // service.addTranslator(new RelationTypeTranslator(service,
- // factoryProvider), CoreTranslatorId.RELATION_TYPE);
- // service.addTranslator(new OseeEnumEntryTranslator(factoryProvider),
- // CoreTranslatorId.OSEE_ENUM_ENTRY);
- // service.addTranslator(new OseeEnumTypeTranslator(service,
- // factoryProvider), CoreTranslatorId.OSEE_ENUM_TYPE);
-
- service.addTranslator(new TransactionRecordTranslator(factoryProvider), CoreTranslatorId.TRANSACTION_RECORD);
+ service.addTranslator(new TransactionRecordTranslator(txRecordFactory), CoreTranslatorId.TRANSACTION_RECORD);
service.addTranslator(new BranchCreationRequestTranslator(), CoreTranslatorId.BRANCH_CREATION_REQUEST);
service.addTranslator(new BranchCreationResponseTranslator(), CoreTranslatorId.BRANCH_CREATION_RESPONSE);
@@ -92,13 +78,13 @@ public class DataTranslationServiceFactory {
service.addTranslator(new BranchCacheUpdateResponseTranslator(), CoreTranslatorId.BRANCH_CACHE_UPDATE_RESPONSE);
service.addTranslator(new BranchCacheStoreRequestTranslator(), CoreTranslatorId.BRANCH_CACHE_STORE_REQUEST);
- service.addTranslator(new TransactionCacheUpdateResponseTranslator(factoryProvider),
+ service.addTranslator(new TransactionCacheUpdateResponseTranslator(txRecordFactory),
CoreTranslatorId.TX_CACHE_UPDATE_RESPONSE);
service.addTranslator(new ArtifactTypeCacheUpdateResponseTranslator(),
CoreTranslatorId.ARTIFACT_TYPE_CACHE_UPDATE_RESPONSE);
- service.addTranslator(new AttributeTypeCacheUpdateResponseTranslator(factoryProvider),
+ service.addTranslator(new AttributeTypeCacheUpdateResponseTranslator(attributeTypeFactory),
CoreTranslatorId.ATTRIBUTE_TYPE_CACHE_UPDATE_RESPONSE);
service.addTranslator(new RelationTypeCacheUpdateResponseTranslator(),
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceRegHandler.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceRegHandler.java
new file mode 100644
index 00000000000..b5a40ecca61
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceRegHandler.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.message.internal;
+
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
+import org.eclipse.osee.framework.core.model.type.AttributeTypeFactory;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
+import org.eclipse.osee.framework.core.translation.IDataTranslationService;
+import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DataTranslationServiceRegHandler extends AbstractTrackingHandler {
+
+ private static final Class<?>[] DEPENDENCIES = new Class<?>[] {//
+ IOseeCachingService.class, //
+ IOseeModelFactoryService.class //
+ };
+
+ private ServiceRegistration registration;
+
+ @Override
+ public Class<?>[] getDependencies() {
+ return DEPENDENCIES;
+ }
+
+ @Override
+ public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
+ IOseeCachingService cachingService = getService(IOseeCachingService.class, services);
+ IOseeModelFactoryService factoryService = getService(IOseeModelFactoryService.class, services);
+
+ TransactionRecordFactory txFactory = factoryService.getTransactionFactory();
+ AttributeTypeFactory attributeTypeFactory = factoryService.getAttributeTypeFactory();
+
+ DataTranslationServiceFactory factory = new DataTranslationServiceFactory();
+ try {
+ IDataTranslationService service = factory.createService(cachingService, txFactory, attributeTypeFactory);
+ registration = context.registerService(IDataTranslationService.class.getName(), service, null);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void onDeActivate() {
+ if (registration != null) {
+ registration.unregister();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/AttributeTypeCacheUpdateResponseTranslator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/AttributeTypeCacheUpdateResponseTranslator.java
index e71057fc5d4..f3b6cd55889 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/AttributeTypeCacheUpdateResponseTranslator.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/AttributeTypeCacheUpdateResponseTranslator.java
@@ -20,7 +20,6 @@ import org.eclipse.osee.framework.core.message.AttributeTypeCacheUpdateResponse;
import org.eclipse.osee.framework.core.message.TranslationUtil;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.model.type.AttributeTypeFactory;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
import org.eclipse.osee.framework.core.translation.ITranslator;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
@@ -35,14 +34,14 @@ public class AttributeTypeCacheUpdateResponseTranslator implements ITranslator<A
ATTR_TO_ENUM;
}
- private final IOseeModelFactoryServiceProvider provider;
+ private final AttributeTypeFactory attributeTypeFactory;
- public AttributeTypeCacheUpdateResponseTranslator(IOseeModelFactoryServiceProvider provider) {
- this.provider = provider;
+ public AttributeTypeCacheUpdateResponseTranslator(AttributeTypeFactory attributeTypeFactory) {
+ this.attributeTypeFactory = attributeTypeFactory;
}
- private AttributeTypeFactory getFactory() throws OseeCoreException {
- return provider.getOseeFactoryService().getAttributeTypeFactory();
+ private AttributeTypeFactory getFactory() {
+ return attributeTypeFactory;
}
@Override
@@ -60,7 +59,7 @@ public class AttributeTypeCacheUpdateResponseTranslator implements ITranslator<A
}
@Override
- public PropertyStore convert(AttributeTypeCacheUpdateResponse object) throws OseeCoreException {
+ public PropertyStore convert(AttributeTypeCacheUpdateResponse object) {
PropertyStore store = new PropertyStore();
List<AttributeType> rows = object.getAttrTypeRows();
for (int index = 0; index < rows.size(); index++) {
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionCacheUpdateResponseTranslator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionCacheUpdateResponseTranslator.java
index 68a614fa0fb..89883fe1db1 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionCacheUpdateResponseTranslator.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionCacheUpdateResponseTranslator.java
@@ -18,7 +18,6 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.message.TransactionCacheUpdateResponse;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
import org.eclipse.osee.framework.core.translation.ITranslator;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
@@ -34,14 +33,14 @@ public class TransactionCacheUpdateResponseTranslator implements ITranslator<Tra
TX_TO_BRANCH;
}
- private final IOseeModelFactoryServiceProvider provider;
+ private final TransactionRecordFactory txRecordFactory;
- public TransactionCacheUpdateResponseTranslator(IOseeModelFactoryServiceProvider provider) {
- this.provider = provider;
+ public TransactionCacheUpdateResponseTranslator(TransactionRecordFactory txRecordFactory) {
+ this.txRecordFactory = txRecordFactory;
}
- private TransactionRecordFactory getFactory() throws OseeCoreException {
- return provider.getOseeFactoryService().getTransactionFactory();
+ private TransactionRecordFactory getFactory() {
+ return txRecordFactory;
}
@Override
@@ -57,7 +56,7 @@ public class TransactionCacheUpdateResponseTranslator implements ITranslator<Tra
}
@Override
- public PropertyStore convert(TransactionCacheUpdateResponse object) throws OseeCoreException {
+ public PropertyStore convert(TransactionCacheUpdateResponse object) {
PropertyStore store = new PropertyStore();
List<TransactionRecord> rows = object.getTxRows();
for (int index = 0; index < rows.size(); index++) {
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionRecordTranslator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionRecordTranslator.java
index e54132f7f31..77b34050624 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionRecordTranslator.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TransactionRecordTranslator.java
@@ -16,7 +16,6 @@ import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
-import org.eclipse.osee.framework.core.services.IOseeModelFactoryServiceProvider;
import org.eclipse.osee.framework.core.translation.ITranslator;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
@@ -35,10 +34,10 @@ public final class TransactionRecordTranslator implements ITranslator<Transactio
TRANSACTION_COMMIT_ART_ID;
}
- private final IOseeModelFactoryServiceProvider factoryProvider;
+ private final TransactionRecordFactory txRecordFactory;
- public TransactionRecordTranslator(IOseeModelFactoryServiceProvider factoryProvider) {
- this.factoryProvider = factoryProvider;
+ public TransactionRecordTranslator(TransactionRecordFactory txRecordFactory) {
+ this.txRecordFactory = txRecordFactory;
}
@Override
@@ -50,12 +49,11 @@ public final class TransactionRecordTranslator implements ITranslator<Transactio
int authorArtId = store.getInt(Entry.TRANSACTION_AUTHOR_ART_ID.name());
int commitArtId = store.getInt(Entry.TRANSACTION_COMMIT_ART_ID.name());
int branchId = store.getInt(Entry.TRANSACTION_BRANCH.name());
- TransactionRecordFactory factory = factoryProvider.getOseeFactoryService().getTransactionFactory();
- return factory.create(transactionNumber, branchId, comment, time, authorArtId, commitArtId, txType);
+ return txRecordFactory.create(transactionNumber, branchId, comment, time, authorArtId, commitArtId, txType);
}
@Override
- public PropertyStore convert(TransactionRecord data) throws OseeCoreException {
+ public PropertyStore convert(TransactionRecord data) {
PropertyStore store = new PropertyStore();
store.put(Entry.TRANSACTION_ID.name(), data.getId());
store.put(Entry.TRANSACTION_TX_TYPE.name(), data.getTxType().name());

Back to the top