/**
     * @param propertyName the property name (cannot be <code>null</code> or empty)
     * @param propertyValue the property value (can be <code>null</code> or empty)
     * @param multiValued <code>true</code> if property is multi-valued
     */
    public void addProperty(
        final String propertyName, final String propertyValue, final boolean multiValued) {
      CheckArg.isNotEmpty(propertyName, "propertyName");

      if (!StringUtil.isBlank(propertyValue)) {
        if (multiValued) {
          UnresolvedProperty unresolvedProperty = this.properties.get(propertyName);

          if (unresolvedProperty == null) {
            unresolvedProperty = new UnresolvedProperty(propertyName, propertyValue, true);
          } else {
            unresolvedProperty.addValue(propertyValue);
          }
          LOGGER.debug(
              "added multi-valued property '{0}' with value '{1}' to the unresolved reference '{2}'",
              propertyName, propertyValue, this.uuid);
        } else {
          this.properties.put(
              propertyName, new UnresolvedProperty(propertyName, propertyValue, false));
          LOGGER.debug(
              "added property '{0}' with value '{1}' to the unresolved reference '{2}'",
              propertyName, propertyValue, this.uuid);
        }
      }
    }
  @Override
  public ClassLoader getClassLoader(ClassLoader fallbackLoader, String... classpathEntries) {
    List<String> urls = new ArrayList<String>();
    if (classpathEntries != null) {
      for (String url : classpathEntries) {
        if (!StringUtil.isBlank(url)) {
          urls.add(url);
        }
      }
    }
    List<ClassLoader> delegatesList = new ArrayList<ClassLoader>();
    if (!urls.isEmpty()) {
      StringURLClassLoader urlClassLoader = new StringURLClassLoader(urls);
      // only if any custom urls were parsed add this loader
      if (urlClassLoader.getURLs().length > 0) {
        delegatesList.add(urlClassLoader);
      }
    }

    ClassLoader currentLoader = getClass().getClassLoader();
    if (fallbackLoader != null && !fallbackLoader.equals(currentLoader)) {
      // if the parent of fallback is the same as the current loader, just use that
      if (fallbackLoader.getParent().equals(currentLoader)) {
        currentLoader = fallbackLoader;
      } else {
        delegatesList.add(fallbackLoader);
      }
    }

    return delegatesList.isEmpty()
        ? currentLoader
        : new DelegatingClassLoader(currentLoader, delegatesList);
  }
 @Test
 public void shouldPrintToStringAllResults() {
   results = new QueryResults(columns, statistics, tuples, context.getProblems(), null);
   List<String> lines = StringUtil.splitLines(results.toString());
   assertThat(
       lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim
 }
 @Test
 public void shouldPrintToStringBuilderOnlyFirstLinesOfResults() {
   results = new QueryResults(columns, statistics, tuples, context.getProblems(), null);
   StringBuilder sb = new StringBuilder();
   results.toString(typeSystem, sb, 1);
   List<String> lines = StringUtil.splitLines(sb.toString());
   assertThat(lines.size(), is(1 + 4)); // = delim + header + delim + (...lines...) + delim
 }
Beispiel #5
0
 @Override
 public String toString() {
   int count = this.getCount();
   String samples = Inflector.getInstance().pluralize("sample", count);
   return StringUtil.createString(
       "{0} {1}: min={2}; avg={3}; max={4}",
       count, samples, this.minimum, this.mean, this.maximum);
 }
 @Test
 public void shouldPrintToStringBuilderAllResultsWhenMaxRowParameterIsLargerThanNumberOfTuples() {
   tuples.clear();
   results = new QueryResults(columns, statistics, tuples, context.getProblems(), null);
   StringBuilder sb = new StringBuilder();
   results.toString(typeSystem, sb, 3);
   List<String> lines = StringUtil.splitLines(sb.toString());
   assertThat(
       lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim
 }
Beispiel #7
0
 private void createLinksFromNodePaths(
     QueryResult result, String baseUrl, Row resultRow, RestQueryResult.RestRow restRow)
     throws RepositoryException {
   String defaultPath = resultRow.getPath();
   if (!StringUtil.isBlank(defaultPath)) {
     restRow.addValue(
         MODE_URI, RestHelper.urlFrom(baseUrl, RestHelper.ITEMS_METHOD_NAME, defaultPath));
   }
   for (String selectorName : result.getSelectorNames()) {
     try {
       String selectorPath = resultRow.getPath(selectorName);
       if (!StringUtil.isBlank(defaultPath) && !selectorPath.equals(defaultPath)) {
         restRow.addValue(
             MODE_URI + "-" + selectorName,
             RestHelper.urlFrom(baseUrl, RestHelper.ITEMS_METHOD_NAME, selectorPath));
       }
     } catch (RepositoryException e) {
       logger.debug(e, e.getMessage());
     }
   }
 }
Beispiel #8
0
  protected Property parse(String line, ValueFactories factories, PropertyFactory propFactory) {
    if (line.length() == 0) return null; // blank line
    char firstChar = line.charAt(0);
    if (firstChar == '#') return null; // comment line
    if (firstChar == ' ') return null; // ignore line
    Matcher matcher = PROPERTY_PATTERN.matcher(line);
    if (!matcher.matches()) {
      // It should be an empty multi-valued property, and the line consists only of the name ...
      Name name = factories.getNameFactory().create(decoder.decode(line));
      return propFactory.create(name);
    }

    String nameString = decoder.decode(matcher.group(1));
    String typeString = matcher.group(2);
    String valuesString = matcher.group(4);

    Name name = factories.getNameFactory().create(nameString);
    PropertyType type = PropertyType.valueFor(typeString);

    Pattern pattern = VALUE_PATTERN;
    ValueFactory<?> valueFactory = factories.getValueFactory(type);
    boolean binary = false;
    boolean decode = false;
    if (type == PropertyType.STRING) {
      // Parse the double-quoted value(s) ...
      pattern = STRING_VALUE_PATTERN;
      decode = true;
    } else if (type == PropertyType.BINARY) {
      binary = true;
    }
    Matcher valuesMatcher = pattern.matcher(valuesString);
    List<Object> values = new ArrayList<Object>();
    while (valuesMatcher.find()) {
      String valueString = valuesMatcher.group(1);
      if (binary) {
        // The value is a hexadecimal-encoded byte array ...
        byte[] binaryValue = StringUtil.fromHexString(valueString);
        Object value = valueFactory.create(binaryValue);
        values.add(value);
      } else {
        if (decode) valueString = quoter.decode(valueString);
        Object value = valueFactory.create(valueString);
        values.add(value);
      }
    }
    if (values.isEmpty()) return null;
    return propFactory.create(name, type, values);
  }
Beispiel #9
0
  @SuppressWarnings("rawtypes")
  @Override
  public void start() throws RepositoryException {
    if (!stopped) {
      return;
    }
    RW_LOCK.writeLock().lock();
    try {
      File journalFileLocation = new File(journalLocation);
      if (!journalFileLocation.exists()) {
        boolean folderHierarchyCreated = journalFileLocation.mkdirs();
        assert folderHierarchyCreated;
      }

      /**
       * TODO author=Horia Chiorean date=1/14/14 description=The following should be enabled when
       * append only files are available DBMaker dbMaker = DBMaker.newAppendFileDB(new
       * File(journalFileLocation, RECORDS_FIELD)) .compressionEnable() .checksumEnable()
       * .closeOnJvmShutdown() .snapshotEnable();
       */
      DBMaker dbMaker =
          DBMaker.newFileDB(new File(journalFileLocation, RECORDS_FIELD))
              .compressionEnable()
              .checksumEnable()
              .mmapFileEnableIfSupported()
              .snapshotEnable();
      if (asyncWritesEnabled) {
        dbMaker.asyncWriteEnable();
      }
      this.journalDB = dbMaker.make();
      this.records = this.journalDB.createTreeMap(RECORDS_FIELD).counterEnable().makeOrGet();
      Atomic.String journalAtomic = this.journalDB.getAtomicString(JOURNAL_ID_FIELD);
      // only write the value the first time
      if (StringUtil.isBlank(journalAtomic.get())) {
        journalAtomic.set("journal_" + UUID.randomUUID().toString());
      }
      this.journalId = journalAtomic.get();
      this.stopped = false;
    } catch (Exception e) {
      throw new RepositoryException(JcrI18n.cannotStartJournal.text(), e);
    } finally {
      RW_LOCK.writeLock().unlock();
    }
  }
Beispiel #10
0
 protected Map<Name, Property> load(File propertiesFile, ExecutionContext context)
     throws RepositorySourceException {
   if (!propertiesFile.exists() || !propertiesFile.canRead()) return NO_PROPERTIES_MAP;
   try {
     String content = IoUtil.read(propertiesFile);
     ValueFactories factories = context.getValueFactories();
     PropertyFactory propFactory = context.getPropertyFactory();
     Map<Name, Property> result = new HashMap<Name, Property>();
     for (String line : StringUtil.splitLines(content)) {
       // Parse each line ...
       Property property = parse(line, factories, propFactory);
       if (property != null) {
         result.put(property.getName(), property);
       }
     }
     return result;
   } catch (IOException e) {
     throw new RepositorySourceException(sourceName, e);
   }
 }
Beispiel #11
0
  private void parseSecurity(OperationContext context, ModelNode model, EditableDocument configDoc)
      throws OperationFailedException {
    EditableDocument security = configDoc.getOrCreateDocument(FieldName.SECURITY);

    // Anonymous ...
    EditableDocument anon = security.getOrCreateDocument(FieldName.ANONYMOUS);
    String anonUsername = attribute(context, model, ModelAttributes.ANONYMOUS_USERNAME).asString();
    boolean useAnonIfFailed =
        attribute(context, model, ModelAttributes.USE_ANONYMOUS_IF_AUTH_FAILED).asBoolean();
    anon.set(FieldName.ANONYMOUS_USERNAME, anonUsername);
    anon.set(FieldName.USE_ANONYMOUS_ON_FAILED_LOGINS, useAnonIfFailed);
    List<ModelNode> modelNodes =
        model.hasDefined(ModelKeys.ANONYMOUS_ROLES)
            ? model.get(ModelKeys.ANONYMOUS_ROLES).asList()
            : ModelAttributes.ANONYMOUS_ROLES.getDefaultValue().asList();
    for (ModelNode roleNode : modelNodes) {
      EditableArray anonymousRolesArray = anon.getOrCreateArray(FieldName.ANONYMOUS_ROLES);
      String roleName = roleNode.asString();
      if (!StringUtil.isBlank(roleName)) {
        anonymousRolesArray.addString(roleName);
      }
    }

    EditableArray providers = security.getOrCreateArray(FieldName.PROVIDERS);

    // JBoss authenticator ...
    String securityDomain = attribute(context, model, ModelAttributes.SECURITY_DOMAIN).asString();
    EditableDocument jboss = Schematic.newDocument();
    jboss.set(FieldName.CLASSNAME, JBossDomainAuthenticationProvider.class.getName());
    jboss.set(FieldName.SECURITY_DOMAIN, securityDomain);
    providers.add(jboss);

    // Servlet authenticator ...
    EditableDocument servlet = Schematic.newDocument();
    servlet.set(FieldName.CLASSNAME, "servlet");
    providers.add(servlet);
  }
Beispiel #12
0
 protected void write(Property property, Writer stream, ValueFactory<String> strings)
     throws IOException {
   String name = strings.create(property.getName());
   stream.append(encoder.encode(name));
   if (property.isEmpty()) return;
   stream.append(" (");
   PropertyType type = PropertyType.discoverType(property.getFirstValue());
   stream.append(type.getName().toLowerCase());
   stream.append(") ");
   if (property.isMultiple()) {
     stream.append('[');
   }
   boolean first = true;
   boolean quote = type == PropertyType.STRING;
   for (Object value : property) {
     if (first) first = false;
     else stream.append(", ");
     String str = null;
     if (value instanceof Binary) {
       str = StringUtil.getHexString(((Binary) value).getBytes());
     } else {
       str = strings.create(value);
     }
     if (quote) {
       stream.append('"');
       stream.append(quoter.encode(str));
       stream.append('"');
     } else {
       stream.append(str);
     }
   }
   if (property.isMultiple()) {
     stream.append(']');
   }
   stream.append('\n');
   stream.flush();
 }
Beispiel #13
0
  @Override
  public ClassLoader getClassLoader(ClassLoader fallbackLoader, String... classpathEntries) {
    List<ClassLoader> delegatingLoaders = new ArrayList<ClassLoader>();
    if (classpathEntries != null) {
      // each classpath entry is interpreted as a module identifier
      for (String moduleIdString : classpathEntries) {
        if (!StringUtil.isBlank(moduleIdString)) {
          try {
            ModuleIdentifier moduleIdentifier = ModuleIdentifier.fromString(moduleIdString);
            delegatingLoaders.add(moduleLoader().loadModule(moduleIdentifier).getClassLoader());
          } catch (IllegalArgumentException e) {
            LOG.warnv(
                "The string (classpath entry) is not a valid module identifier: {0}",
                moduleIdString);
          } catch (ModuleLoadException e) {
            LOG.warnv(
                "Cannot load module from (from classpath entry) with identifier: {0}",
                moduleIdString);
          }
        }
      }
    }
    ClassLoader currentLoader = getClass().getClassLoader();
    if (fallbackLoader != null && !fallbackLoader.equals(currentLoader)) {
      // if the parent of fallback is the same as the current loader, just use that
      if (fallbackLoader.getParent().equals(currentLoader)) {
        currentLoader = fallbackLoader;
      } else {
        delegatingLoaders.add(fallbackLoader);
      }
    }

    return delegatingLoaders.isEmpty()
        ? currentLoader
        : new DelegatingClassLoader(currentLoader, delegatingLoaders);
  }
Beispiel #14
0
 /**
  * @param metricName the metric name (cannot be <code>null</code> or empty)
  * @param window the metrics window (cannot be <code>null</code>)
  * @return the attribute definition name (never <code>null</code> or empty)
  */
 public static final String attributeName(final String metricName, final Window window) {
   assert !StringUtil.isBlank(metricName);
   assert (window != null);
   return (metricName + '-' + window.getLiteral());
 }
Beispiel #15
0
  @Override
  protected void performRuntime(
      final OperationContext context,
      final ModelNode operation,
      final ModelNode model,
      final ServiceVerificationHandler verificationHandler,
      final List<ServiceController<?>> newControllers)
      throws OperationFailedException {

    final ServiceTarget target = context.getServiceTarget();
    final AddressContext addressContext = AddressContext.forOperation(operation);
    final String repositoryName = addressContext.repositoryName();
    final String cacheName = attribute(context, model, ModelAttributes.CACHE_NAME, repositoryName);
    String infinispanConfig = attribute(context, model, ModelAttributes.CACHE_CONFIG, null);
    String configRelativeTo =
        attribute(context, model, ModelAttributes.CONFIG_RELATIVE_TO).asString();
    final boolean enableMonitoring =
        attribute(context, model, ModelAttributes.ENABLE_MONITORING).asBoolean();
    final String gcThreadPool =
        attribute(context, model, ModelAttributes.GARBAGE_COLLECTION_THREAD_POOL, null);
    final String gcInitialTime =
        attribute(context, model, ModelAttributes.GARBAGE_COLLECTION_INITIAL_TIME, null);
    final int gcIntervalInHours =
        attribute(context, model, ModelAttributes.GARBAGE_COLLECTION_INTERVAL).asInt();
    final String optThreadPool =
        attribute(context, model, ModelAttributes.DOCUMENT_OPTIMIZATION_THREAD_POOL, null);
    final String optInitialTime =
        attribute(context, model, ModelAttributes.DOCUMENT_OPTIMIZATION_INITIAL_TIME, null);
    final int optIntervalInHours =
        attribute(context, model, ModelAttributes.DOCUMENT_OPTIMIZATION_INTERVAL).asInt();
    final Integer optTarget =
        intAttribute(
            context, model, ModelAttributes.DOCUMENT_OPTIMIZATION_CHILD_COUNT_TARGET, null);
    final Integer eventBusSize = intAttribute(context, model, ModelAttributes.EVENT_BUS_SIZE, null);
    final Integer optTolerance =
        intAttribute(
            context, model, ModelAttributes.DOCUMENT_OPTIMIZATION_CHILD_COUNT_TOLERANCE, null);

    // Create a document for the repository configuration ...
    EditableDocument configDoc = Schematic.newDocument();
    configDoc.set(FieldName.NAME, repositoryName);

    // Determine the JNDI name ...
    configDoc.set(
        FieldName.JNDI_NAME,
        ""); // always set to empty string, since we'll register in JNDI here ...
    final String jndiName = ModeShapeJndiNames.JNDI_BASE_NAME + repositoryName;
    String jndiAlias = ModeShapeJndiNames.jndiNameFrom(model, repositoryName);
    if (jndiName.equals(jndiAlias)) {
      jndiAlias = null;
    }

    if (eventBusSize != null) {
      configDoc.setNumber(FieldName.EVENT_BUS_SIZE, eventBusSize);
    }

    // Parse the cache configuration
    if (StringUtil.isBlank(infinispanConfig)) {
      infinispanConfig = "modeshape/" + repositoryName + "-cache-config.xml";
    } else {
      // check if it's a system property
      String infinispanConfigSystemProperty = System.getProperty(infinispanConfig);
      if (!StringUtil.isBlank(infinispanConfigSystemProperty)) {
        infinispanConfig = infinispanConfigSystemProperty;
      }
    }
    // Set the storage information (that was set on the repository ModelNode) ...
    setRepositoryStorageConfiguration(infinispanConfig, cacheName, configDoc);

    // Always set whether monitoring is enabled ...
    enableMonitoring(enableMonitoring, configDoc);

    // Initial node-types if configured
    parseCustomNodeTypes(model, configDoc);

    // Workspace information is on the repository model node (unlike the XML) ...
    EditableDocument workspacesDoc = parseWorkspaces(context, model, configDoc);

    // security
    parseSecurity(context, model, configDoc);

    // Now create the repository service that manages the lifecycle of the JcrRepository instance
    // ...
    RepositoryConfiguration repositoryConfig =
        new RepositoryConfiguration(configDoc, repositoryName);
    String configRelativeToSystemProperty = System.getProperty(configRelativeTo);
    if (!StringUtil.isBlank(configRelativeToSystemProperty)) {
      configRelativeTo = configRelativeToSystemProperty;
    }
    if (!configRelativeTo.endsWith("/")) {
      configRelativeTo = configRelativeTo + "/";
    }
    RepositoryService repositoryService =
        new RepositoryService(repositoryConfig, infinispanConfig, configRelativeTo);
    ServiceName repositoryServiceName = ModeShapeServiceNames.repositoryServiceName(repositoryName);

    // Sequencing
    parseSequencing(model, configDoc);

    // Text Extraction
    parseTextExtraction(model, configDoc);

    // Reindexing
    parseReindexing(model, configDoc);

    // Journaling
    parseJournaling(repositoryService, context, model, configDoc);

    // Add the EngineService's dependencies ...
    ServiceBuilder<JcrRepository> repositoryServiceBuilder =
        target.addService(repositoryServiceName, repositoryService);

    // Add dependency to the ModeShape engine service ...
    repositoryServiceBuilder.addDependency(
        ModeShapeServiceNames.ENGINE, ModeShapeEngine.class, repositoryService.getEngineInjector());
    repositoryServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE);

    // Add garbage collection information ...
    if (gcThreadPool != null) {
      configDoc
          .getOrCreateDocument(FieldName.GARBAGE_COLLECTION)
          .setString(FieldName.THREAD_POOL, gcThreadPool);
    }
    if (gcInitialTime != null) {
      configDoc
          .getOrCreateDocument(FieldName.GARBAGE_COLLECTION)
          .setString(FieldName.INITIAL_TIME, gcInitialTime);
    }
    configDoc
        .getOrCreateDocument(FieldName.GARBAGE_COLLECTION)
        .setNumber(FieldName.INTERVAL_IN_HOURS, gcIntervalInHours);

    // Add document optimization information ...
    if (optTarget != null) {
      EditableDocument docOpt =
          configDoc
              .getOrCreateDocument(FieldName.STORAGE)
              .getOrCreateDocument(FieldName.DOCUMENT_OPTIMIZATION);
      if (optThreadPool != null) {
        docOpt.setString(FieldName.THREAD_POOL, optThreadPool);
      }
      if (optInitialTime != null) {
        docOpt.setString(FieldName.INITIAL_TIME, optInitialTime);
      }
      docOpt.setNumber(FieldName.INTERVAL_IN_HOURS, optIntervalInHours);
      docOpt.setNumber(FieldName.OPTIMIZATION_CHILD_COUNT_TARGET, optTarget.intValue());
      if (optTolerance != null) {
        docOpt.setNumber(FieldName.OPTIMIZATION_CHILD_COUNT_TOLERANCE, optTolerance.intValue());
      }
    }

    // Add the dependency to the Security Manager
    repositoryServiceBuilder.addDependency(
        SecurityManagementService.SERVICE_NAME,
        ISecurityManagement.class,
        repositoryService.getSecurityManagementServiceInjector());

    // Add dependency, if necessary, to the workspaces cache container
    String workspacesInfinispanConfig =
        attribute(context, model, ModelAttributes.WORKSPACES_CACHE_CONTAINER, null);
    if (workspacesInfinispanConfig != null
        && !workspacesInfinispanConfig.toLowerCase().equalsIgnoreCase(infinispanConfig)) {
      workspacesDoc.set(FieldName.WORKSPACE_CACHE_CONFIGURATION, workspacesInfinispanConfig);
    }

    repositoryServiceBuilder.addDependency(
        Services.JBOSS_SERVICE_MODULE_LOADER,
        ModuleLoader.class,
        repositoryService.getModuleLoaderInjector());

    // Set up the JNDI binder service ...
    final ReferenceFactoryService<JcrRepository> referenceFactoryService =
        new ReferenceFactoryService<JcrRepository>();
    ServiceName referenceFactoryServiceName =
        ModeShapeServiceNames.referenceFactoryServiceName(repositoryName);
    final ServiceBuilder<?> referenceBuilder =
        target.addService(referenceFactoryServiceName, referenceFactoryService);
    referenceBuilder.addDependency(
        repositoryServiceName, JcrRepository.class, referenceFactoryService.getInjector());
    referenceBuilder.setInitialMode(ServiceController.Mode.ACTIVE);

    ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
    BinderService binder = new BinderService(bindInfo.getBindName());
    ServiceBuilder<?> binderBuilder = target.addService(bindInfo.getBinderServiceName(), binder);
    if (jndiAlias != null) {
      ContextNames.BindInfo aliasInfo = ContextNames.bindInfoFor(jndiAlias);
      ServiceName alias = aliasInfo.getBinderServiceName();
      binderBuilder.addAliases(alias);
      LOG.debugv(
          "Binding repository {0} to JNDI name {1} and {2}",
          repositoryName, bindInfo.getAbsoluteJndiName(), aliasInfo.getAbsoluteJndiName());
    } else {
      LOG.debugv(
          "Binding repository {0} to JNDI name {1}",
          repositoryName, bindInfo.getAbsoluteJndiName());
    }
    binderBuilder.addDependency(
        referenceFactoryServiceName,
        ManagedReferenceFactory.class,
        binder.getManagedObjectInjector());
    binderBuilder.addDependency(
        bindInfo.getParentContextServiceName(),
        ServiceBasedNamingStore.class,
        binder.getNamingStoreInjector());
    binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE);

    // Add dependency to the data directory ...
    ServiceName dataDirServiceName = ModeShapeServiceNames.dataDirectoryServiceName(repositoryName);
    ServiceController<String> dataDirServiceController =
        RelativePathService.addService(
            dataDirServiceName,
            "modeshape/" + repositoryName,
            ModeShapeExtension.JBOSS_DATA_DIR_VARIABLE,
            target);
    newControllers.add(dataDirServiceController);
    repositoryServiceBuilder.addDependency(
        dataDirServiceName, String.class, repositoryService.getDataDirectoryPathInjector());

    // Add the default binary storage service which will provide the binary configuration
    BinaryStorageService defaultBinaryService = BinaryStorageService.createDefault();
    ServiceName defaultBinaryStorageServiceName =
        ModeShapeServiceNames.binaryStorageDefaultServiceName(repositoryName);
    ServiceBuilder<BinaryStorage> binaryStorageBuilder =
        target.addService(defaultBinaryStorageServiceName, defaultBinaryService);
    binaryStorageBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
    // Add dependency to the binaries storage service, which captures the properties for the
    // binaries storage
    repositoryServiceBuilder.addDependency(
        defaultBinaryStorageServiceName,
        BinaryStorage.class,
        repositoryService.getBinaryStorageInjector());

    // Add monitor service
    final MonitorService monitorService = new MonitorService();
    final ServiceBuilder<RepositoryMonitor> monitorBuilder =
        target.addService(ModeShapeServiceNames.monitorServiceName(repositoryName), monitorService);
    monitorBuilder.addDependency(
        ModeShapeServiceNames.repositoryServiceName(repositoryName),
        JcrRepository.class,
        monitorService.getJcrRepositoryInjector());
    monitorBuilder.setInitialMode(ServiceController.Mode.ACTIVE);

    // Now add the controller for the RepositoryService ...
    newControllers.add(repositoryServiceBuilder.install());
    newControllers.add(referenceBuilder.install());
    newControllers.add(binderBuilder.install());
    newControllers.add(binaryStorageBuilder.install());
    newControllers.add(monitorBuilder.install());
  }
Beispiel #16
0
 private JSONObject stringToJSONObject(String requestBody) throws JSONException {
   return StringUtil.isBlank(requestBody) ? new JSONObject() : new JSONObject(requestBody);
 }