clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: CLEREZZA-888: preventing TcAccessController from being instantiated
Date Tue, 04 Mar 2014 15:48:12 GMT
Repository: clerezza
Updated Branches:
  refs/heads/master 26a76e3e9 -> 9da2007d6


CLEREZZA-888: preventing TcAccessController from being instantiated

Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/9da2007d
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/9da2007d
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/9da2007d

Branch: refs/heads/master
Commit: 9da2007d6bca9dc507e407cefc23f7ee2df8c660
Parents: 26a76e3
Author: retobg <reto@apache.org>
Authored: Tue Mar 4 16:47:55 2014 +0100
Committer: retobg <reto@apache.org>
Committed: Tue Mar 4 16:47:55 2014 +0100

----------------------------------------------------------------------
 .../apache/clerezza/rdf/core/access/TcManager.java    |  9 ++++++++-
 .../rdf/core/access/security/TcAccessController.java  | 14 +++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/9da2007d/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
index e8d76d3..c59b048 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
@@ -103,7 +103,14 @@ public class TcManager extends TcProviderMultiplexer {
 
     public final static String GENERAL_PURPOSE_TC = "general.purpose.tc";
     private static volatile TcManager instance;
-    private TcAccessController tcAccessController = new TcAccessController(this);
+    private TcAccessController tcAccessController = new TcAccessController() {
+
+        @Override
+        protected TcManager getTcManager() {
+            return TcManager.this;
+        }
+            
+    };
     private Map<UriRef, ServiceRegistration> serviceRegistrations = Collections
             .synchronizedMap(new HashMap<UriRef, ServiceRegistration>());
     

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9da2007d/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
index 5bbb207..74a88b2 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
@@ -52,9 +52,11 @@ import org.apache.clerezza.utils.security.PermissionParser;
  * access a TripleCollection. These permissions are stored persistently in an
  * MGraph named urn:x-localinstance:/graph-access.graph
  *
+ * Clients should get an instance from TcManager.getTcAccessController()
+ * 
  * @author reto
  */
-public class TcAccessController {
+public abstract class TcAccessController {
 
     private final TcManager tcManager;
     private final UriRef permissionGraphName = new UriRef("urn:x-localinstance:/graph-access.graph");
@@ -80,8 +82,8 @@ public class TcAccessController {
      *
      * @param tcManager the tcManager used to locate urn:x-localinstance:/graph-access.graph
      */
-    public TcAccessController(TcManager tcManager) {
-        this.tcManager = tcManager;
+    public TcAccessController() {
+        this.tcManager = getTcManager();
     }
 
     public void checkReadPermission(UriRef tripleCollectionUri) {
@@ -343,4 +345,10 @@ public class TcAccessController {
             return tcManager.createMGraph(permissionGraphName);
         }
     }
+
+    /**
+     * Note that this will only be invoked once
+     * @return 
+     */
+    protected abstract TcManager getTcManager();
 }


Mime
View raw message