コード例 #1
0
ファイル: Sha1Digester.java プロジェクト: gnomix/repose
  public Sha1Digester(final byte[] sourceBytes) {
    digest =
        MESSAGE_DIGEST_POOL.use(
            new ResourceContext<MessageDigest, byte[]>() {

              @Override
              public byte[] perform(MessageDigest resource) {
                return resource.digest(sourceBytes);
              }
            });
  }
コード例 #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);
  }