コード例 #1
0
ファイル: MeemStoreWedge.java プロジェクト: stormboy/Meemplex
  private void startStores(Properties properties) {
    String definitionStoreClassName = properties.getProperty(DEFINITION_STORE_CLASS);
    String contentStoreClassName = properties.getProperty(CONTENT_STORE_CLASS);

    // start definition store
    try {
      Class<?> definitionStoreClass = Class.forName(definitionStoreClassName);

      definitionStore = (MeemStoreDefinitionStore) definitionStoreClass.newInstance();
    } catch (Exception e) {
      logger.log(Level.INFO, "Exception while starting MeemStoreDefinitionStore", e);
    }

    if (definitionStore != null) definitionStore.configure(this, properties);

    //	start content store
    try {
      Class<?> contentStoreClass = Class.forName(contentStoreClassName);

      contentStore = (MeemStoreContentStore) contentStoreClass.newInstance();
    } catch (Exception e) {
      logger.log(Level.INFO, "Exception while starting MeemStoreContentStore", e);
    }

    if (contentStore != null) contentStore.configure(this, properties);
  }
コード例 #2
0
ファイル: MeemStoreWedge.java プロジェクト: stormboy/Meemplex
  public void storeMeemContent(MeemPath meemPath, MeemContent meemContent) {
    if (DEBUG) {
      logger.info("storing meem content: " + meemPath);
    }

    // only store meemstore paths
    if (meemPath.getSpace().equals(Space.MEEMSTORE)) {
      contentStore.store(meemPath, meemContent);

      String location = meemPath.getLocation();
      boolean stored = false;

      synchronized (meemPaths) {
        if (!meemPaths.containsKey(location)) {
          meemPaths.put(location, meemPath);
          stored = true;
        }

        if (stored) {
          meemStoreClient.meemStored(meemPath);
        }

        // TODO[peter] Should this be called if the meem was just stored?
        meemContentClient.meemContentChanged(meemPath, meemContent);
      }
    }
  }
コード例 #3
0
ファイル: MeemStoreWedge.java プロジェクト: stormboy/Meemplex
  public void destroyMeem(MeemPath meemPath) {

    String location = meemPath.getLocation();
    MeemPath removePath;

    synchronized (meemPaths) {
      removePath = (MeemPath) meemPaths.remove(location);

      if (removePath != null) {

        contentStore.remove(meemPath);
        definitionStore.remove(meemPath);

        meemStoreClient.meemDestroyed(meemPath);
        meemDefinitionClient.meemDefinitionChanged(meemPath, null);
        meemContentClient.meemContentChanged(meemPath, null);
      }
    }
  }
コード例 #4
0
ファイル: MeemStoreWedge.java プロジェクト: stormboy/Meemplex
  public void commence() {
    Properties properties = System.getProperties();

    // TODO put this in a commence() method, and close stores on conclude().
    startStores(properties);

    // grab the content and definition paths
    // it is possible to have a content stored without a definition and vice versa

    // -mg- not sure this is really necessary. should just hand off to store to try and
    // load and fail silently if path cannot be found
    HashSet<MeemPath> paths = new HashSet<MeemPath>();
    paths.addAll(contentStore.getAllPaths());
    paths.addAll(definitionStore.getAllPaths());

    for (MeemPath meemPath : paths) {
      meemPaths.put(meemPath.getLocation(), meemPath);
    }
  }