Class ApplicationConfigurationBinder
- java.lang.Object
-
- org.gcube.smartgears.configuration.application.ApplicationConfigurationBinder
-
public class ApplicationConfigurationBinder extends Object
BindsApplicationConfigurations to and from XML serialisations.- Author:
- Fabio Simeoni
-
-
Constructor Summary
Constructors Constructor Description ApplicationConfigurationBinder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ApplicationHandlersbindHandlers(ClassLoader classLoader)Returns the handlers of the application from their XML serialisation.ApplicationConfigurationload(InputStream stream)Returns the application configuration from its XML serialisation.voidscanForApplicationHandlers(ClassLoader currentClassLoader)Returns the extensions of the application from their XML serialisation.
-
-
-
Method Detail
-
load
public ApplicationConfiguration load(InputStream stream)
Returns the application configuration from its XML serialisation.- Parameters:
stream- the serialisation- Returns:
- the configuration
- Throws:
RuntimeException- if the serialisation is invalid
-
bindHandlers
public ApplicationHandlers bindHandlers(ClassLoader classLoader)
Returns the handlers of the application from their XML serialisation.- Parameters:
stream- the serialisation- Returns:
- the handlers
- Throws:
RuntimeException- if the serialisation is invalid
-
scanForApplicationHandlers
public void scanForApplicationHandlers(ClassLoader currentClassLoader)
Returns the extensions of the application from their XML serialisation.- Parameters:
stream- the serialisation- Throws:
RuntimeException- if the serialisation is invalid public ApplicationExtensions bindExtensions(InputStream stream) { //collects handler classes Set> classes = scanForExtensions(); try { JAXBContext ctx = JAXBContext.newInstance(classes.toArray(new Class>[0])); return (ApplicationExtensions) ctx.createUnmarshaller().unmarshal(stream); } catch (JAXBException e) { throw unchecked(e); } finally { closeSafely(stream); } } private Set > scanForExtensions() throws RuntimeException {
-
-