Package org.apache.clerezza.rdf.core.access

Examples of org.apache.clerezza.rdf.core.access.LockableMGraph


       
        TypeHandlerSpace typeHandlerSpace = new TypeHandlerSpace();
        typeHandlerSpace.tcManager = new TcManager(){
          @Override
          public LockableMGraph getMGraph(UriRef name) {
            return new LockableMGraph() {

              @Override
              public ReadWriteLock getLock() {
                return mGraph.getLock();
              }
View Full Code Here


   * @param permissionDescriptions
   */
  public void setRequiredReadPermissionStrings(UriRef tripleCollectionUri,
      Collection<String> permissionDescriptions) {
    readPermissionCache.remove(tripleCollectionUri);
    final LockableMGraph permissionMGraph = getOrCreatePermisionGraph();
    Lock l = permissionMGraph.getLock().writeLock();
    l.lock();
    try {
      removeExistingRequiredReadPermissions(tripleCollectionUri, permissionMGraph);
      final NonLiteral permissionList = createList(permissionDescriptions.iterator(), permissionMGraph);
      permissionMGraph.add(new TripleImpl(tripleCollectionUri,
          readPermissionListProperty, permissionList));
    } finally {
      l.unlock();
    }
  }
View Full Code Here

   * @param permissionDescriptions
   */
  public void setRequiredReadWritePermissionStrings(UriRef tripleCollectionUri,
      Collection<String> permissionDescriptions) {
    readWritePermissionCache.remove(tripleCollectionUri);
    final LockableMGraph permissionMGraph = getOrCreatePermisionGraph();
    Lock l = permissionMGraph.getLock().writeLock();
    l.lock();
    try {
      removeExistingRequiredReadPermissions(tripleCollectionUri, permissionMGraph);
      final NonLiteral permissionList = createList(permissionDescriptions.iterator(), permissionMGraph);
      permissionMGraph.add(new TripleImpl(tripleCollectionUri,
          readWritePermissionListProperty, permissionList));
    } finally {
      l.unlock();
    }
  }
View Full Code Here

  private Collection<String> getRequiredReadPermissionStrings(final UriRef tripleCollectionUri) {
    return getRequiredPermissionStrings(tripleCollectionUri, readPermissionListProperty);
  }
  private Collection<String> getRequiredPermissionStrings(final UriRef tripleCollectionUri, UriRef property) {
    try {
      final LockableMGraph permissionMGraph = tcManager.getMGraph(permissionGraphName);
      Lock l = permissionMGraph.getLock().readLock();
      l.lock();
      try {
        Triple t = permissionMGraph.filter(tripleCollectionUri, property, null).next();
        NonLiteral list = (NonLiteral) t.getObject();
        LinkedList<String> result = new LinkedList<String>();
        readList(list, permissionMGraph, result);
        return result;
      } catch (NoSuchElementException e) {
View Full Code Here

  LanguageDescription(GraphNode resource) {
    this.resource = resource;
    Literal iso1Literal = null;
    TripleCollection configGraph = resource.getGraph();
    if (configGraph instanceof LockableMGraph) {
      LockableMGraph lockableConfigGraph = (LockableMGraph)configGraph;
      Lock readLock = lockableConfigGraph.getLock().readLock();
      readLock.lock();
      try {
        iso1Literal = (Literal) resource.getObjects(LINGVOJ.iso1).next();
      } finally {
        readLock.unlock();
View Full Code Here

   */
  public String getLabel(Language lang) {
    Lock readLock = null;
    TripleCollection configGraph = resource.getGraph();
    if (configGraph instanceof LockableMGraph) {
      LockableMGraph lockableConfigGraph = (LockableMGraph)configGraph;
      readLock = lockableConfigGraph.getLock().readLock();
      readLock.lock();
    }
    try {
      Iterator<Resource> labels = resource.getObjects(RDFS.label);
      while (labels.hasNext()) {
View Full Code Here

  private GraphNode addLanguages(GraphNode node, NonLiteral platformInstance, List<LanguageDescription> languages,
      boolean copyToNode) {
    TripleCollection graph = node.getGraph();
    BNode listNode = new BNode();   
    RdfList list = new RdfList(listNode, graph);
    LockableMGraph configGraph = getConfigGraph();
    Lock readLock = configGraph.getLock().readLock();
    for (LanguageDescription languageDescription : languages) {
      NonLiteral languageUri = (NonLiteral) languageDescription.getResource().getNode();
      list.add(languageUri);
      if (copyToNode) {
        readLock.lock();
View Full Code Here

   * @param languageUri The language uri which specifies the language to be
   *    added to the platform.
   */
  public void addLanguage(UriRef languageUri) {
    if (!languageListCache.contains(languageUri)) {
      LockableMGraph systemGraph = getSystemGraph();
      Lock writeLock = systemGraph.getLock().writeLock();
      writeLock.lock();
      try {
        if (languageList.add(languageUri)) {
          addToLanguageConfigGraph(languageUri);
        }
View Full Code Here

   * The added language will not be a platform language.
   *
   * @param languageUri
   */
  public void addToLanguageConfigGraph(NonLiteral languageUri) {
    LockableMGraph configGraph = getConfigGraph();
    Lock writeLock = configGraph.getLock().writeLock();
    writeLock.lock();
    try {
      if (!configGraph.filter(languageUri, LINGVOJ.iso1, null).hasNext()) {
        configGraph.addAll(getLanguageContext(languageUri));
      }
    } finally {
      writeLock.unlock();
    }
  }
View Full Code Here

   * The activate method is called when SCR activates the component configuration.
   *
   * @param componentContext
   */
  protected void activate(ComponentContext componentContext) {
    LockableMGraph systemGraph = getSystemGraph();
    NonLiteral listNode = getListNode(systemGraph);

    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      // the constructor of RdfList might write to the graph! => requires a write lock
      final RdfList rdfList = new RdfList(listNode, systemGraph);
      languageList = Collections.synchronizedList(rdfList);
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.access.LockableMGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.