Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-05-03 02:41:01 +0000
committerRoberto E. Escobar2012-05-03 02:41:01 +0000
commit7f05bffc2108282a4a7bb7ef5ad11059e77dcb45 (patch)
treee7d8d3bda5d4ae2bc289d25e53d3654af35d84da /plugins/org.eclipse.osee.framework.access
parente1c0266afc5de401db1f02d1178de2f789afab9a (diff)
downloadorg.eclipse.osee-7f05bffc2108282a4a7bb7ef5ad11059e77dcb45.tar.gz
org.eclipse.osee-7f05bffc2108282a4a7bb7ef5ad11059e77dcb45.tar.xz
org.eclipse.osee-7f05bffc2108282a4a7bb7ef5ad11059e77dcb45.zip
feature[ats_VGR8B]: Change access control DS to lazy init
Diffstat (limited to 'plugins/org.eclipse.osee.framework.access')
-rw-r--r--plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF11
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml2
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/access.provider.admin.xml6
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml1
-rw-r--r--plugins/org.eclipse.osee.framework.access/build.properties2
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java92
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderAdmin.java79
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java95
8 files changed, 168 insertions, 120 deletions
diff --git a/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
index d82084b13b..b62523203a 100644
--- a/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
@@ -24,12 +24,19 @@ Import-Package: com.google.common.collect,
org.eclipse.osee.framework.jdk.core.util,
org.eclipse.osee.framework.lifecycle,
org.eclipse.osee.framework.logging,
+ org.eclipse.osee.framework.skynet.core,
+ org.eclipse.osee.framework.skynet.core.artifact,
+ org.eclipse.osee.framework.skynet.core.artifact.search,
+ org.eclipse.osee.framework.skynet.core.event,
+ org.eclipse.osee.framework.skynet.core.event.filter,
+ org.eclipse.osee.framework.skynet.core.event.listener,
+ org.eclipse.osee.framework.skynet.core.event.model,
+ org.eclipse.osee.framework.skynet.core.relation,
+ org.eclipse.osee.framework.skynet.core.utility,
org.osgi.framework,
org.osgi.util.tracker
Bundle-ActivationPolicy: lazy
Eclipse-ExtensibleAPI: true
Export-Package: org.eclipse.osee.framework.access,
org.eclipse.osee.framework.access.internal.data
-Require-Bundle: org.eclipse.osee.framework.skynet.core,
- org.eclipse.osee.framework.core.model
Service-Component: OSGI-INF/*.xml
diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml
index fc7b8e278f..2ec82dd4df 100644
--- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml
@@ -8,4 +8,6 @@
<reference bind="setCachingService" cardinality="1..1" interface="org.eclipse.osee.framework.core.services.IOseeCachingService" name="IOseeCachingService" policy="static"/>
<reference bind="setIdentityService" cardinality="1..1" interface="org.eclipse.osee.framework.core.services.IdentityService" name="IdentityService" policy="static"/>
<reference bind="setEventService" cardinality="1..1" interface="org.eclipse.osee.framework.skynet.core.event.OseeEventService" name="OseeEventService" policy="static"/>
+ <reference bind="setLifecycleService" cardinality="1..1" interface="org.eclipse.osee.framework.lifecycle.ILifecycleService" name="ILifecycleService" policy="static"/>
+ <reference bind="addAccessProvider" cardinality="1..n" interface="org.eclipse.osee.framework.access.IAccessProvider" name="IAccessProvider" policy="dynamic" unbind="removeAccessProvider"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.provider.admin.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.provider.admin.xml
deleted file mode 100644
index 06e89668c4..0000000000
--- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.provider.admin.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.framework.access.internal.AccessProviderAdmin">
- <implementation class="org.eclipse.osee.framework.access.internal.AccessProviderAdmin"/>
- <reference bind="setLifecycleService" cardinality="1..1" interface="org.eclipse.osee.framework.lifecycle.ILifecycleService" name="ILifecycleService" policy="static"/>
- <reference bind="addAccessProvider" cardinality="1..n" interface="org.eclipse.osee.framework.access.IAccessProvider" name="IAccessProvider" policy="dynamic" unbind="removeAccessProvider"/>
-</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml
index d66b84826f..91af415996 100644
--- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml
@@ -4,7 +4,6 @@
<service>
<provide interface="org.eclipse.osee.framework.access.IAccessProvider"/>
</service>
- <reference bind="setAccessControlService" cardinality="1..1" interface="org.eclipse.osee.framework.core.services.IAccessControlService" name="IAccessControlService" policy="static"/>
<reference bind="addCmAccessControl" cardinality="1..n" interface="org.eclipse.osee.framework.core.services.CmAccessControl"
name="CmAccessControl" policy="dynamic" unbind="removeCmAccessControl"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.access/build.properties b/plugins/org.eclipse.osee.framework.access/build.properties
index 6210e849b5..4a36e88a3c 100644
--- a/plugins/org.eclipse.osee.framework.access/build.properties
+++ b/plugins/org.eclipse.osee.framework.access/build.properties
@@ -3,3 +3,5 @@ bin.includes = META-INF/,\
.,\
OSGI-INF/
source.. = src/
+additional.bundles = org.eclipse.osee.framework.skynet.core,\
+ org.eclipse.osee.framework.core.model
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java
index 62723c241d..324b06e474 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java
@@ -11,7 +11,10 @@
package org.eclipse.osee.framework.access.internal;
import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
+import org.eclipse.osee.framework.access.IAccessProvider;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -22,16 +25,27 @@ import org.eclipse.osee.framework.core.services.IOseeCachingService;
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.lifecycle.ILifecycleService;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.event.OseeEventService;
import org.eclipse.osee.framework.skynet.core.event.listener.EventQosType;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
public final class AccessControlServiceProxy implements IAccessControlService {
+ private final List<ServiceReference<IAccessProvider>> registered =
+ new CopyOnWriteArrayList<ServiceReference<IAccessProvider>>();
+
+ private final List<ServiceReference<IAccessProvider>> pendingProviders =
+ new CopyOnWriteArrayList<ServiceReference<IAccessProvider>>();
+
private IOseeDatabaseService dbService;
private IOseeCachingService cachingService;
private IdentityService identityService;
private OseeEventService eventService;
+ private ILifecycleService lifecycleService;
private AccessControlService accessService;
private AccessEventListener accessEventListener;
@@ -53,7 +67,63 @@ public final class AccessControlServiceProxy implements IAccessControlService {
this.eventService = eventService;
}
+ public void setLifecycleService(ILifecycleService service) {
+ this.lifecycleService = service;
+ }
+
+ public void addAccessProvider(ServiceReference<IAccessProvider> reference) {
+ if (isReady()) {
+ register(reference);
+ registered.add(reference);
+ } else {
+ pendingProviders.add(reference);
+ }
+ }
+
+ public void removeAccessProvider(ServiceReference<IAccessProvider> reference) {
+ if (isReady()) {
+ deregister(reference);
+ registered.remove(reference);
+ } else {
+ pendingProviders.remove(reference);
+ }
+ }
+
+ private IAccessProvider getService(ServiceReference<IAccessProvider> reference) {
+ Bundle bundle = reference.getBundle();
+ BundleContext bundleContext = bundle.getBundleContext();
+ return bundleContext.getService(reference);
+ }
+
+ private void register(ServiceReference<IAccessProvider> reference) {
+ try {
+ IAccessProvider accessProvider = getService(reference);
+ lifecycleService.addHandler(AccessProviderVisitor.TYPE, accessProvider);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
+ }
+ }
+
+ private void deregister(ServiceReference<IAccessProvider> reference) {
+ try {
+ IAccessProvider accessProvider = getService(reference);
+ lifecycleService.removeHandler(AccessProviderVisitor.TYPE, accessProvider);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
+ }
+ }
+
+ private synchronized void ensureInitialized() {
+ if (accessService != null && !pendingProviders.isEmpty()) {
+ for (ServiceReference<IAccessProvider> reference : pendingProviders) {
+ register(reference);
+ }
+ pendingProviders.clear();
+ }
+ }
+
public AccessControlService getProxiedObject() {
+ ensureInitialized();
return accessService;
}
@@ -65,21 +135,16 @@ public final class AccessControlServiceProxy implements IAccessControlService {
}
}
+ private boolean isReady() {
+ return accessService != null && lifecycleService != null;
+ }
+
public void start() {
accessService = new AccessControlService(dbService, cachingService, identityService, eventService);
accessEventListener = new AccessEventListener(accessService, new AccessControlCacheHandler());
eventService.addListener(EventQosType.PRIORITY, accessEventListener);
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- accessService.start();
- }
- };
-
- thread = new Thread(runnable);
- thread.start();
+ accessService.start();
}
public void stop() {
@@ -88,6 +153,11 @@ public final class AccessControlServiceProxy implements IAccessControlService {
thread = null;
}
+ for (ServiceReference<IAccessProvider> provider : registered) {
+ deregister(provider);
+ }
+ registered.clear();
+
if (accessEventListener != null) {
eventService.removeListener(EventQosType.PRIORITY, accessEventListener);
accessEventListener = null;
@@ -100,7 +170,7 @@ public final class AccessControlServiceProxy implements IAccessControlService {
}
private void checkInitialized() throws OseeCoreException {
- Conditions.checkNotNull(accessService, "accessService", "Access Service not properly initialized");
+ Conditions.checkNotNull(getProxiedObject(), "accessService", "Access Service not properly initialized");
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderAdmin.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderAdmin.java
deleted file mode 100644
index 948c9c6c1e..0000000000
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderAdmin.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.access.internal;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.access.IAccessProvider;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.lifecycle.ILifecycleService;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-public class AccessProviderAdmin {
-
- private final List<IAccessProvider> pendingProviders = new CopyOnWriteArrayList<IAccessProvider>();
-
- private ILifecycleService lifecycleService;
-
- public void setLifecycleService(ILifecycleService service) {
- this.lifecycleService = service;
- }
-
- public void addAccessProvider(IAccessProvider accessProvider) {
- if (isReady()) {
- register(accessProvider);
- } else {
- pendingProviders.add(accessProvider);
- }
- }
-
- public void removeAccessProvider(IAccessProvider accessProvider) {
- if (isReady()) {
- deregister(accessProvider);
- } else {
- pendingProviders.remove(accessProvider);
- }
- }
-
- public void start() {
- for (IAccessProvider provider : pendingProviders) {
- register(provider);
- }
- }
-
- public void stop() {
- for (IAccessProvider provider : pendingProviders) {
- deregister(provider);
- }
- }
-
- private boolean isReady() {
- return lifecycleService != null;
- }
-
- private void register(IAccessProvider accessProvider) {
- try {
- lifecycleService.addHandler(AccessProviderVisitor.TYPE, accessProvider);
- } catch (OseeCoreException ex) {
- OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
- }
- }
-
- private void deregister(IAccessProvider accessProvider) {
- try {
- lifecycleService.removeHandler(AccessProviderVisitor.TYPE, accessProvider);
- } catch (OseeCoreException ex) {
- OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java
index 5f6061fce3..2fadcd2271 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java
@@ -11,9 +11,12 @@
package org.eclipse.osee.framework.access.internal.cm;
import java.util.Collection;
-import java.util.Map;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.logging.Level;
import org.eclipse.osee.framework.access.IAccessProvider;
+import org.eclipse.osee.framework.access.internal.AccessControlHelper;
import org.eclipse.osee.framework.access.internal.AccessControlServiceProxy;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.IBasicArtifact;
@@ -22,29 +25,49 @@ import org.eclipse.osee.framework.core.services.CmAccessControl;
import org.eclipse.osee.framework.core.services.CmAccessControlProvider;
import org.eclipse.osee.framework.core.services.IAccessControlService;
import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* @author Roberto E. Escobar
*/
public final class CmAccessProviderProxy implements IAccessProvider {
+ private final List<ServiceReference<CmAccessControl>> pending =
+ new CopyOnWriteArrayList<ServiceReference<CmAccessControl>>();
+
private final Collection<CmAccessControl> cmServices = new CopyOnWriteArraySet<CmAccessControl>();
+
private IAccessProvider accessProvider;
- private IAccessControlService accessControlService;
+ private CmAccessControlProvider cmProvider;
+ private BundleContext bundleContext;
+ private Thread thread;
- private final CmAccessControlProvider cmProvider;
+ public void addCmAccessControl(ServiceReference<CmAccessControl> reference) {
+ if (isReady()) {
+ register(bundleContext, reference);
+ } else {
+ pending.add(reference);
+ }
+ }
- public CmAccessProviderProxy() {
- super();
- cmProvider = new CmAccessControlProviderImpl(cmServices);
+ public void removeCmAccessControl(ServiceReference<CmAccessControl> reference) {
+ if (isReady()) {
+ unregister(bundleContext, reference);
+ } else {
+ pending.remove(reference);
+ }
}
- public void setAccessControlService(IAccessControlService accessControlService) {
- this.accessControlService = accessControlService;
+ private boolean isReady() {
+ return bundleContext != null && cmProvider != null;
}
- public void addCmAccessControl(CmAccessControl cmAccessControl, Map<String, Object> properties) {
- if (isDefault(properties)) {
+ private void register(BundleContext bundleContext, ServiceReference<CmAccessControl> reference) {
+ CmAccessControl cmAccessControl = bundleContext.getService(reference);
+ if (isDefault(reference)) {
cmProvider.setDefaultAccessControl(cmAccessControl);
} else {
cmServices.add(cmAccessControl);
@@ -52,8 +75,9 @@ public final class CmAccessProviderProxy implements IAccessProvider {
reloadCache();
}
- public void removeCmAccessControl(CmAccessControl cmAccessControl, Map<String, Object> properties) {
- if (isDefault(properties)) {
+ private void unregister(BundleContext bundleContext, ServiceReference<CmAccessControl> reference) {
+ CmAccessControl cmAccessControl = bundleContext.getService(reference);
+ if (isDefault(reference)) {
cmProvider.setDefaultAccessControl(null);
} else {
cmServices.remove(cmAccessControl);
@@ -61,30 +85,59 @@ public final class CmAccessProviderProxy implements IAccessProvider {
reloadCache();
}
- private boolean isDefault(Map<String, Object> properties) {
- if (properties.containsKey("default")) {
- return (Boolean) properties.get("default");
+ private boolean isDefault(ServiceReference<CmAccessControl> reference) {
+ boolean toReturn = false;
+ String value = String.valueOf(reference.getProperty("default"));
+ if (Strings.isValid(value)) {
+ toReturn = Boolean.parseBoolean(value);
}
- return false;
+ return toReturn;
}
- public void start() {
+ public void start(BundleContext context) {
+ this.bundleContext = context;
+
+ cmProvider = new CmAccessControlProviderImpl(cmServices);
accessProvider = new CmAccessProvider(cmProvider);
+
+ for (ServiceReference<CmAccessControl> reference : pending) {
+ register(bundleContext, reference);
+ }
+ pending.clear();
}
public void stop() {
+ if (thread != null) {
+ thread.interrupt();
+ thread = null;
+ }
accessProvider = null;
cmProvider.setDefaultAccessControl(null);
cmServices.clear();
+ bundleContext = null;
+ }
+
+ private AccessControlServiceProxy getAccessService() {
+ AccessControlServiceProxy toReturn = null;
+ ServiceReference<IAccessControlService> reference =
+ bundleContext.getServiceReference(IAccessControlService.class);
+ IAccessControlService service = bundleContext.getService(reference);
+ if (service instanceof AccessControlServiceProxy) {
+ toReturn = (AccessControlServiceProxy) service;
+ } else {
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, "Error initializing ObjectAccessProvider");
+ }
+ return toReturn;
}
- public void reloadCache() {
- if (accessControlService instanceof AccessControlServiceProxy) {
- ((AccessControlServiceProxy) accessControlService).reloadCache();
+ private void reloadCache() {
+ AccessControlServiceProxy service = getAccessService();
+ if (service != null) {
+ service.reloadCache();
}
}
- public IAccessProvider getAccessProvider() {
+ private IAccessProvider getAccessProvider() {
return accessProvider;
}

Back to the top