コード例 #1
0
  public List<?> distinct(String field) throws Exception {
    assert skip == 0;
    assert limit == 0;
    assert select == null;

    Type toto = store.type.getField(field).getGenericType();
    Class<?> to = store.type.getField(field).getType();
    if (to.isArray()) {
      toto = to.getComponentType();
    } else if (Collection.class.isAssignableFrom(to) && toto instanceof ParameterizedType) {
      toto = ((ParameterizedType) toto).getActualTypeArguments()[0];
    } else if (GenericArrayType.class.isAssignableFrom(to)) {
      toto = ((GenericArrayType) toto).getGenericComponentType();
    }

    List<?> list;

    // Do we have a sub selection? Then use the filter
    // otherwise use the call without where clause
    if (where == null) list = store.collection.distinct(field);
    else list = store.collection.distinct(field, where);

    List<Object> result = new ArrayList<Object>(list.size());
    for (Object o : list) {
      result.add(converter.convert(toto, o));
    }
    return result;
  }
コード例 #2
0
  /** We parse the -runremote and create sessions for each one of them */
  @Override
  public void prepare() throws Exception {
    if (prepared) return;

    prepared = true;

    updateFromProject();

    Map<String, Object> properties = new HashMap<String, Object>(getRunProperties());

    calculatedProperties(properties);

    Collection<String> embeddedActivators = getActivators();
    if (embeddedActivators != null && !embeddedActivators.isEmpty()) {
      properties.put("biz.aQute.remote.embedded", Strings.join(embeddedActivators));
    }

    for (Entry<String, Attrs> entry : runremote.entrySet()) {
      RunRemoteDTO dto = converter.convert(RunRemoteDTO.class, entry.getValue());
      dto.name = entry.getKey();

      Map<String, Object> sessionProperties = new HashMap<String, Object>(properties);
      sessionProperties.putAll(entry.getValue());
      sessionProperties.put("session.name", dto.name);

      if (dto.jmx != null) {
        tryJMXDeploy(dto.jmx, "biz.aQute.remote.agent");
      }

      RunSessionImpl session = new RunSessionImpl(this, dto, properties);
      sessions.add(session);
    }
  }