Esempio n. 1
0
  private String resolveTypeDiscriminator(final Class<?> persistentType) {
    final List<String> discrimintators = new ArrayList<String>();
    TypeDiscriminator td = persistentType.getAnnotation(TypeDiscriminator.class);
    if (td != null) {
      if (td.value().length() == 0) {
        throw new ViewGenerationException(
            String.format(
                "@TypeDiscriminator declared on type level must specify custom discriminator condition",
                persistentType));
      }
      if (hasTypeDiscriminatorFieldOrMethod(persistentType)) {
        throw new ViewGenerationException(
            String.format(
                "@TypeDiscriminator declared on type level may not be combined with @TypeDiscriminator in fields or on methods",
                persistentType));
      }
      return td.value();
    }

    eachField(
        persistentType,
        new Predicate<Field>() {
          public boolean apply(Field input) {
            if (hasAnnotation(input, TypeDiscriminator.class)) {
              discrimintators.add("doc." + input.getName());
            }
            return false;
          }
        });

    eachMethod(
        persistentType,
        new Predicate<Method>() {
          public boolean apply(Method input) {
            if (hasAnnotation(input, TypeDiscriminator.class)) {
              discrimintators.add("doc." + firstCharToLowerCase(input.getName().substring(3)));
            }
            return true;
          }
        });
    return Joiner.join(discrimintators, " && ");
  }
Esempio n. 2
0
 public void join() {
   final long joinStartTime = joiner != null ? joiner.getStartTime() : Clock.currentTimeMillis();
   final long maxJoinMillis = getGroupProperties().MAX_JOIN_SECONDS.getInteger() * 1000;
   try {
     if (joiner == null) {
       logger.warning("No join method is enabled! Starting standalone.");
       setAsMaster();
     } else {
       joiner.join(joined);
     }
   } catch (Exception e) {
     if (Clock.currentTimeMillis() - joinStartTime < maxJoinMillis) {
       logger.warning("Trying to rejoin: " + e.getMessage());
       rejoin();
     } else {
       logger.severe("Could not join cluster, shutting down!", e);
       shutdown(false, true);
     }
   }
 }
Esempio n. 3
0
 public String toString(String delim) {
   return Joiner.join(this, delim);
 }