Exemplo n.º 1
0
  public Sha1Digester(final byte[] sourceBytes) {
    digest =
        MESSAGE_DIGEST_POOL.use(
            new ResourceContext<MessageDigest, byte[]>() {

              @Override
              public byte[] perform(MessageDigest resource) {
                return resource.digest(sourceBytes);
              }
            });
  }
Exemplo n.º 2
0
  @Override
  public T read(ConfigurationResource cr) {
    final Object parsedObject = marshallerPool.use(new UnmarshallerResourceContext(cr));
    final Object returnable =
        parsedObject instanceof JAXBElement
            ? ((JAXBElement) parsedObject).getValue()
            : parsedObject;

    if (!configurationClass().isInstance(returnable)) {
      throw new ClassCastException(
          "Parsed object from XML does not match the expected configuration class. "
              + "Expected: "
              + configurationClass().getCanonicalName()
              + "  -  "
              + "Actual: "
              + returnable.getClass().getCanonicalName());
    }

    return configurationClass().cast(returnable);
  }