コード例 #1
0
  private synchronized <T extends SchemaSourceRepresentation> void removeSource(
      final PotentialSchemaSource<?> source, final SchemaSourceRegistration<?> reg) {
    final Multimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>>
        m = sources.get(source.getSourceIdentifier());
    if (m != null) {
      m.remove(source.getRepresentation(), reg);

      for (SchemaListenerRegistration l : listeners) {
        l.getInstance().schemaSourceUnregistered(source);
      }

      if (m.isEmpty()) {
        sources.remove(source.getSourceIdentifier());
      }
    }
  }
コード例 #2
0
  private synchronized <T extends SchemaSourceRepresentation> void addSource(
      final PotentialSchemaSource<T> source, final AbstractSchemaSourceRegistration<T> reg) {
    ListMultimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>>
        m = sources.get(source.getSourceIdentifier());
    if (m == null) {
      m = ArrayListMultimap.create();
      sources.put(source.getSourceIdentifier(), m);
    }

    m.put(source.getRepresentation(), reg);

    final Collection<PotentialSchemaSource<?>> reps =
        Collections.<PotentialSchemaSource<?>>singleton(source);
    for (SchemaListenerRegistration l : listeners) {
      l.getInstance().schemaSourceRegistered(reps);
    }
  }
コード例 #3
0
  @Override
  public <T extends SchemaSourceRepresentation> SchemaSourceRegistration<T> registerSchemaSource(
      final SchemaSourceProvider<? super T> provider, final PotentialSchemaSource<T> source) {
    final PotentialSchemaSource<T> src = source.cachedReference();

    final AbstractSchemaSourceRegistration<T> ret =
        new AbstractSchemaSourceRegistration<T>(provider, src) {
          @Override
          protected void removeRegistration() {
            removeSource(src, this);
          }
        };

    addSource(src, ret);
    return ret;
  }