Ejemplo n.º 1
0
 @Override
 public CacheContainer getCacheContainer(String name) {
   CacheContainer container = null;
   if (BINARY_STORAGE_CONTAINER_NAME.equals(name)) {
     BinaryStorage storage = binaryStorageInjector.getValue();
     container = storage.getCacheContainer();
   }
   if (container == null) {
     container = cacheManagerInjector.getValue();
   }
   return container;
 }
Ejemplo n.º 2
0
 /**
  * Get the repository name.
  *
  * @return repositoryName
  */
 public String getRepositoryName() {
   return binaryStorage.getRepositoryName();
 }
Ejemplo n.º 3
0
  @Override
  public void start(StartContext arg0) throws StartException {
    JcrEngine jcr = getEngine();
    try {
      final String repositoryName = repositoryConfiguration.getName();

      // Get the index storage configuration ...
      IndexStorage indexStorageConfig = indexStorageConfigInjector.getValue();
      Document queryConfig = null;
      if (indexStorageConfig != null) {
        queryConfig = indexStorageConfig.getQueryConfiguration();
      } else {
        // We'll use the default index storage, but this will be overwritten by the *IndexStorageAdd
        // operation
        // (that we're dependent upon). The default for non-AS7 ModeShape repositories is to use
        // RAM index storage, but in AS7 we want to by default store the indexes on the filesystem
        // in the
        // AS7 data directory.
        // We'll do this by setting a path relative to the data directory, and then injecting
        // the "${jboss.server.data.dir}/modeshape" path into the repository service
        // (which will then update the configuration prior to deployment) ...
        EditableDocument query = Schematic.newDocument();
        EditableDocument indexing = query.getOrCreateDocument(FieldName.INDEXING);
        EditableDocument indexStorage = query.getOrCreateDocument(FieldName.INDEX_STORAGE);
        EditableDocument backend = indexing.getOrCreateDocument(FieldName.INDEXING_BACKEND);
        query.set(FieldName.REBUILD_UPON_STARTUP, "if_needed");
        backend.set(FieldName.TYPE, FieldValue.INDEXING_BACKEND_TYPE_LUCENE);
        indexStorage.set(FieldName.TYPE, FieldValue.INDEX_STORAGE_FILESYSTEM);
        String dataDirPath = dataDirectoryPathInjector.getValue();
        indexStorage.set(
            FieldName.INDEX_STORAGE_LOCATION, dataDirPath + "/" + repositoryName + "/indexes");
        queryConfig = query;
      }
      assert queryConfig != null;

      // Get the binary storage configuration ...
      Document binaryConfig = null;
      BinaryStorage binaryStorageConfig = binaryStorageInjector.getValue();
      if (binaryStorageConfig != null) {
        binaryConfig = binaryStorageConfig.getBinaryConfiguration();
      } else {
        // By default, store the binaries in the data directory ...
        EditableDocument binaries = Schematic.newDocument();
        binaries.set(FieldName.TYPE, FieldValue.BINARY_STORAGE_TYPE_FILE);
        String dataDirPath = dataDirectoryPathInjector.getValue();
        binaries.set(FieldName.DIRECTORY, dataDirPath + "/" + repositoryName + "/binaries");
        binaryConfig = binaries;
      }

      // Now update the configuration ...
      Editor editor = repositoryConfiguration.edit();
      editor.setDocument(FieldName.QUERY, queryConfig);
      editor
          .getOrCreateDocument(FieldName.STORAGE)
          .setDocument(FieldName.BINARY_STORAGE, binaryConfig);

      // Apply the changes to the configuration ...
      editor.apply(editor.getChanges());

      // Deploy the repository and use this as the environment ...
      jcr.deploy(repositoryConfiguration.with(this));
    } catch (ConfigurationException e) {
      throw new StartException(e);
    } catch (RepositoryException e) {
      throw new StartException(e);
    }
  }
Ejemplo n.º 4
0
  @Override
  public void start(StartContext arg0) throws StartException {
    ModeShapeEngine engine = getEngine();

    try {
      final String repositoryName = repositoryName();

      // Get the index storage configuration ...
      IndexStorage indexStorageConfig = indexStorageConfigInjector.getValue();
      Document queryConfig = null;
      if (indexStorageConfig != null) {
        queryConfig = indexStorageConfig.getQueryConfiguration();
      } else {
        // We'll use the default index storage, but this will be overwritten by the *IndexStorageAdd
        // operation
        // (that we're dependent upon). The default for non-AS7 ModeShape repositories is to use
        // RAM index storage, but in AS7 we want to by default store the indexes on the filesystem
        // in the
        // AS7 data directory.
        // We'll do this by setting a path relative to the data directory, and then injecting
        // the "${jboss.server.data.dir}/modeshape" path into the repository service
        // (which will then update the configuration prior to deployment) ...
        EditableDocument query = Schematic.newDocument();
        EditableDocument indexing = query.getOrCreateDocument(FieldName.INDEXING);
        EditableDocument indexStorage = query.getOrCreateDocument(FieldName.INDEX_STORAGE);
        EditableDocument backend = indexing.getOrCreateDocument(FieldName.INDEXING_BACKEND);
        query.set(FieldName.REBUILD_UPON_STARTUP, QueryRebuild.IF_MISSING.toString().toLowerCase());
        backend.set(FieldName.TYPE, FieldValue.INDEXING_BACKEND_TYPE_LUCENE);
        indexStorage.set(FieldName.TYPE, FieldValue.INDEX_STORAGE_FILESYSTEM);
        String dataDirPath = dataDirectoryPathInjector.getValue();
        indexStorage.set(
            FieldName.INDEX_STORAGE_LOCATION, dataDirPath + "/" + repositoryName + "/indexes");
        queryConfig = query;
      }
      assert queryConfig != null;

      // Get the binary storage configuration ...
      Document binaryConfig = null;
      BinaryStorage binaryStorageConfig = binaryStorageInjector.getValue();
      if (binaryStorageConfig != null) {
        binaryConfig = binaryStorageConfig.getBinaryConfiguration();
      } else {
        // By default, store the binaries in the data directory ...
        EditableDocument binaries = Schematic.newDocument();
        binaries.set(FieldName.TYPE, FieldValue.BINARY_STORAGE_TYPE_FILE);
        String dataDirPath = dataDirectoryPathInjector.getValue();
        binaries.set(FieldName.DIRECTORY, dataDirPath + "/" + repositoryName + "/binaries");
        binaryConfig = binaries;
      }

      // Create a new configuration document ...
      EditableDocument config = Schematic.newDocument(repositoryConfiguration.getDocument());
      config.setDocument(FieldName.QUERY, queryConfig);
      config
          .getOrCreateDocument(FieldName.STORAGE)
          .setDocument(FieldName.BINARY_STORAGE, binaryConfig);

      if (LOG.isDebugEnabled()) {
        LOG.debugv("ModeShape configuration for '{0}' repository: {1}", repositoryName, config);
        Problems problems = repositoryConfiguration.validate();
        if (problems.isEmpty()) {
          LOG.debugv(
              "Problems with configuration for '{0}' repository: {1}", repositoryName, problems);
        }
      }

      // Create a new (updated) configuration ...
      repositoryConfiguration = new RepositoryConfiguration(config, repositoryName);

      // Deploy the repository and use this as the environment ...
      engine.deploy(repositoryConfiguration.with(this));
    } catch (ConfigurationException e) {
      throw new StartException(e);
    } catch (RepositoryException e) {
      throw new StartException(e);
    }
  }