Package org.exist.storage

Examples of org.exist.storage.BrokerPool


    else
      {return new PolicyFinderResult(matchedPolicy);}
  }
  public PolicyFinderResult findPolicy(URI idReference, int type)
  {
    final BrokerPool pool = pdp.getBrokerPool();
    DBBroker broker = null;
    try
    {
      broker = pool.get(pool.getSecurityManager().getSystemSubject());
      final AbstractPolicy policy = pdp.getUtil().findPolicy(broker, idReference, type);
      return (policy == null) ? new PolicyFinderResult() : new PolicyFinderResult(policy);
    }
    catch(final Exception e)
    {
      return XACMLUtil.errorResult("Error resolving id '" + idReference.toString() + "': " + e.getMessage(), e);
    }
    finally
    {
      pool.release(broker);
    }
  }
View Full Code Here


  /* (non-Javadoc)
   * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence)
   */
  public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
   
    BrokerPool db = null;
    DBBroker broker = null;
    try {
      db = BrokerPool.getInstance();
     
      broker = db.get(context.getSubject());
     
      Collection col = broker.getCollection(XmldbURI.ROOT_COLLECTION_URI);
     
      checkSub(broker, col);
     
    } catch (Exception e) {
        //e.printStackTrace();
      throw new XPathException(this, e);
    } finally {
      if (db != null)
        db.release(broker);
    }
   
    return Sequence.EMPTY_SEQUENCE;
  }
View Full Code Here

  }
  protected void initializePolicyCollection()
  {
    DBBroker broker = null;
    try {
                    final BrokerPool pool = pdp.getBrokerPool();
                    broker = pool.get(pool.getSecurityManager().getSystemSubject());
                    initializePolicyCollection(broker);
    } catch(final PermissionDeniedException pde) {
                    LOG.error(pde.getMessage(), pde);
                } catch(final EXistException ee) {
      LOG.error("Could not get broker pool to initialize policy collection", ee);
View Full Code Here

   * @param forceCorruption  Should the database be forcefully corrupted
   */
  private void constructedNodeQuery(boolean forceCorruption)
  {
    BrokerPool.FORCE_CORRUPTION = forceCorruption;
      BrokerPool pool = null;       
      DBBroker broker = null;
     
      try
      {
        pool = startDB();
        assertNotNull(pool);
          broker = pool.get(pool.getSecurityManager().getSystemSubject());
         
          TransactionManager transact = pool.getTransactionManager();
            assertNotNull(transact);
           
            //only store the documents the first time
            if(forceCorruption)
            {
              //store a first test document
              storeTestDocument(broker, transact, "testcr1.xml");

              //store a second test document
              storeTestDocument(broker, transact, "testcr2.xml");
            }
           
            //create some child collections in TEMP collection
          createTempChildCollection(broker, transact, "testchild1");
          createTempChildCollection(broker, transact, "testchild2");
           
            //execute an xquery
          XQuery service = broker.getXQueryService();
          assertNotNull(service);
         
          CompiledXQuery compiled = service.compile(service.newContext(AccessContext.TEST), new StringSource(xquery));
          assertNotNull(compiled);
         
          Sequence result = service.execute(compiled, null);
          assertNotNull(result);
        
          assertEquals(expectedResults.length, result.getItemCount());
         
          for(int i = 0; i < result.getItemCount(); i++)
      {
        assertEquals(expectedResults[i], (String)result.itemAt(i).getStringValue());
      }
         
          //read the first test document
          testDocumentIsValid(broker, transact, "testcr1.xml");
         
          //read the second test document
          testDocumentIsValid(broker, transact, "testcr1.xml");
         
          //test the child collections exist
          testTempChildCollectionExists(broker, transact, "testchild1");
          testTempChildCollectionExists(broker, transact, "testchild2");
         
          transact.getJournal().flushToLog(true);
      }
      catch(Exception e)
      {           
          fail(e.getMessage());
          e.printStackTrace();
      }
      finally
      {
        if (pool != null) pool.release(broker);
      }
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence)
   */
  public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
   
    BrokerPool db = null;
    DBBroker broker = null;
    try {
      db = BrokerPool.getInstance();
     
      broker = db.get(null);
     
      Subject currentSubject = broker.getSubject();
      try {
          broker.setSubject( db.getSecurityManager().getSystemSubject() );
         
          Collection col = broker.getCollection(XmldbURI.ROOT_COLLECTION_URI);
         
          final MetaData md = MetaData.get();
         
          checkSub(broker, md, col);
      } finally {
          broker.setSubject(currentSubject);
      }
     
    } catch (Exception e) {
      throw new XPathException(this, e);
    } finally {
      if (db != null)
        db.release(broker);
    }
   
    return Sequence.EMPTY_SEQUENCE;
  }
View Full Code Here

        //TODO : find a way to retrieve the actual instance's name !
        atts.addAttribute("", "default", "default", "CDATA", "exist");
        this.contentHandler.startElement(NAMESPACE, "database-instances",
            PREFIX + ":database-instances", atts);
        atts.clear();
        BrokerPool instance;
        for(final Iterator<BrokerPool> i = BrokerPool.getInstances(); i.hasNext(); ) {
            instance = i.next();
            atts.addAttribute("", "name", "name", "CDATA", instance.getId());
            this.contentHandler.startElement(NAMESPACE, "database-instance",
                PREFIX + ":database-instance", atts);
            atts.clear();
            addValue("configuration", instance.getConfiguration().getConfigFilePath());
            addValue("data-directory", (String)instance.getConfiguration().getProperty(BrokerPool.PROPERTY_DATA_DIR));
            addValue("cache-size", String.valueOf(instance.getConfiguration().getInteger("db-connection.cache-size")));
            addValue("page-size", String.valueOf(instance.getConfiguration().getInteger("db-connection.page-size")));
            addValue("collection-cache-mem", String.valueOf(instance.getConfiguration().getInteger("db-connection.collection-cache-mem")));
            this.contentHandler.startElement(NAMESPACE, "pool", PREFIX + ":pool", atts);
            addValue("max", String.valueOf(instance.getMax()));
            addValue("active", String.valueOf(instance.countActiveBrokers()));
            addValue("available", String.valueOf(instance.available()));
            this.contentHandler.endElement(NAMESPACE, "pool", PREFIX + ":pool");
            genBufferStatus(instance);
            this.contentHandler.endElement(NAMESPACE, "database-instance",
                PREFIX + ":database-instance");
        }
View Full Code Here

TOP

Related Classes of org.exist.storage.BrokerPool

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.