Package edu.byu.hbll.box
Class Box
- java.lang.Object
-
- edu.byu.hbll.box.Box
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class Box extends Object implements Closeable
The principal API into the Box system. Start with a configuration file.Box box = newBox(config).build();
Or configure Box programmatically with the builder.
Box box = newBuilder()...build();
- Author:
- Charles Draper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Box.Builder
The configuration used to instantiate Box.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this Box instance and shutdowns down all internal scheduling and executors.BoxHealth
getHealth()
Returns a snapshot of the health of the Box system.Source
getPrincipalSource()
Returns the principal source.Source
getSource(String sourceName)
Returns the registered source denoted by the name.List<String>
getSourceNames()
Returns a list of names of the registered sources.Map<String,Source>
getSources()
Returns a list of the registered sources.static Box
newBox(com.fasterxml.jackson.databind.JsonNode config)
Creates a newBox
from the supplied configuration.static Box.Builder
newBuilder()
Creates a new builder.String
verifySource(String sourceName)
Verifies the existence of the source and returns it's name.
-
-
-
Method Detail
-
newBox
public static Box newBox(com.fasterxml.jackson.databind.JsonNode config)
Creates a newBox
from the supplied configuration.- Parameters:
config
- the config to use- Returns:
- the new Box builder
-
newBuilder
public static Box.Builder newBuilder()
Creates a new builder.- Returns:
- the new Box builder
-
getPrincipalSource
public Source getPrincipalSource()
Returns the principal source.- Returns:
- the principal source
-
getHealth
public BoxHealth getHealth()
Returns a snapshot of the health of the Box system.- Returns:
- the health of Box
-
getSource
public Source getSource(String sourceName)
Returns the registered source denoted by the name.IMPORTANT: Once a source is registered it should not be modified.
- Parameters:
sourceName
- the name of the source- Returns:
- the registered source
-
getSources
public Map<String,Source> getSources()
Returns a list of the registered sources.IMPORTANT: Once a source is registered it should not be modified.
- Returns:
- the list of registered sources
-
getSourceNames
public List<String> getSourceNames()
Returns a list of names of the registered sources.- Returns:
- list of source names
-
verifySource
public String verifySource(String sourceName)
Verifies the existence of the source and returns it's name. Throws exception if source is not recognized.- Parameters:
sourceName
- the source to verify- Returns:
- the sourceName
- Throws:
IllegalArgumentException
- if source is not recognized
-
close
public void close()
Closes this Box instance and shutdowns down all internal scheduling and executors.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-