src/main/java/com/ning/metrics/goodwill/access/GoodwillAccessor.java
public Future<GoodwillSchema> getSchema(final String schemaName)
    {
        try {
            return client.prepareGet(String.format("%s/%s", url, schemaName)).addHeader("Accept", "application/json").execute(new AsyncCompletionHandler<GoodwillSchema>()
            {
                @Override
                public GoodwillSchema onCompleted(final Response response) throws Exception
                {
                    if (response.getStatusCode() != 200) {
                        return null;
                    }

                    final InputStream in = response.getResponseBodyAsStream();
                    try {
                        return mapper.readValue(in, GoodwillSchema.class);
                    }
                    finally {
                        closeStream(in);
                    }
                }

                @Override
                public void onThrowable(final Throwable t)
                {
                    log.warn("Got exception looking up the schema", t);
                }
            });
        }
        catch (IOException e) {
            log.warn("Got exception looking up the schema", e);
            return null;
        }
    }
public Future<GoodwillSchema> getSchema(final String schemaName)
    {
        try {
            return client.prepareGet(String.format("%s/%s", url, schemaName)).addHeader("Accept", "application/json").execute(new AsyncCompletionHandler<GoodwillSchema>()
            {
                @Override
                public GoodwillSchema onCompleted(final Response response) throws Exception
                {
                    if (response.getStatusCode() != 200) {
                        return null;
                    }

                    final InputStream in = response.getResponseBodyAsStream();
                    try {
                        return mapper.readValue(in, GoodwillSchema.class);
                    }
                    finally {
                        closeStream(in);
                    }
                }

                @Override
                public void onThrowable(final Throwable t)
                {
                    log.warn("Got exception looking up the schema", t);
                }
            });
        }
        catch (IOException e) {
            log.warn("Got exception looking up the schema", e);
            return null;
        }
    }
public Future < GoodwillSchema > getSchema ( final String schemaName ) { try { return client . prepareGet ( String . format ( "%s/%s" , url , schemaName ) ) . addHeader ( "Accept" , "application/json" ) . execute ( new AsyncCompletionHandler < GoodwillSchema > ( ) { @ Override public GoodwillSchema onCompleted ( final Response response ) throws Exception { if ( response . getStatusCode ( ) != 200 ) { return null ; } final InputStream in = response . getResponseBodyAsStream ( ) ; try { return mapper . readValue ( in , GoodwillSchema . class ) ; } finally { closeStream ( in ) ; } } @ Override public void onThrowable ( final Throwable t ) { log . warn ( "Got exception looking up the schema" , t ) ; } } ) ; } catch ( IOException e ) { log . warn ( "Got exception looking up the schema" , e ) ; return null ; } }
Get the Goodwill schema associated to a schema name.
</p>
Typical invocation:
<pre>
try {
GoodwillSchema type = accessor.getSchema("test").get();
...
}
catch (Exception e) {
// Connection exception? Goodwill server down?
}
</pre>

@param schemaName schema name to lookup
@return a future on the Schema
Get the Goodwill schema associated to a schema name . < / p > Typical invocation : <pre > try { GoodwillSchema type = accessor . getSchema ( test ) . get () ; ... } catch ( Exception e ) { // Connection exception? Goodwill server down? } < / pre >