diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/Activator.java')
-rw-r--r-- | plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/Activator.java | 232 |
1 files changed, 116 insertions, 116 deletions
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 061e43e1244..7fe5b337113 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 @@ -1,116 +1,116 @@ -/*******************************************************************************
- * 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.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.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 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>();
- }
-
- 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());
- }
-
- 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);
- }
-
- 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;
- }
-}
+/******************************************************************************* + * 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.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.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 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>(); + } + + 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()); + } + + 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); + } + + 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; + } +} |