/** * Load an ApplicationBuilder from a JSON String. * @param json JSON String * @return Application Builder loaded from JSON * @throws AssemblyException if unable to declare the assembly */ public static ApplicationBuilder fromJson( String json ) { JsonObject root = Json.createReader( new StringReader( json ) ).readObject(); return fromJson( root ); }
/** * Load an ApplicationBuilder from a JSON String. * @param json JSON String * @return Application Builder loaded from JSON * @throws AssemblyException if unable to declare the assembly */ public static ApplicationBuilder fromJson( String json ) { JsonObject root = Json.createReader( new StringReader( json ) ).readObject(); return fromJson( root ); }
/** * Load an ApplicationBuilder from a JSON InputStream. * @param json JSON input * @return Application Builder loaded from JSON * @throws AssemblyException if unable to declare the assembly */ public static ApplicationBuilder fromJson( InputStream json ) throws AssemblyException { JsonObject root = Json.createReader( json ).readObject(); return fromJson( root ); }
/** * Load an ApplicationBuilder from a JSON InputStream. * @param json JSON input * @return Application Builder loaded from JSON * @throws AssemblyException if unable to declare the assembly */ public static ApplicationBuilder fromJson( InputStream json ) throws AssemblyException { JsonObject root = Json.createReader( json ).readObject(); return fromJson( root ); }
/** * {@literal main} method that read JSON from STDIN. * <p>Passivation exceptions are written to STDERR if any.</p> * @param args Unused * @throws AssemblyException if the assembly failed * @throws ActivationException if the activation failed */ public static void main( String[] args ) throws ActivationException, AssemblyException { fromJson( System.in ).withPassivationShutdownHook().newApplication(); } }
/** * {@literal main} method that read JSON from STDIN. * <p>Passivation exceptions are written to STDERR if any.</p> * @param args Unused * @throws AssemblyException if the assembly failed * @throws ActivationException if the activation failed */ public static void main( String[] args ) throws ActivationException, AssemblyException { fromJson( System.in ).withPassivationShutdownHook().newApplication(); } }
@Test public void givenJsonInputStreamWhenBuildingApplicationExpectSuccess() throws IOException, ActivationException, AssemblyException { InputStream input = new ByteArrayInputStream( APPLICATION.getBytes( "UTF-8" ) ); ApplicationBuilder builder = ApplicationBuilder.fromJson( input ); Application application = builder.newApplication(); Module module = application.findModule( "layer3", "test module" ); TestService service = module.findService( TestService.class ).get(); assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) ); }
@Test public void givenJsonWhenBuildingApplicationExpectSuccess() throws ActivationException, AssemblyException { ApplicationBuilder builder = ApplicationBuilder.fromJson( APPLICATION ); Application application = builder.newApplication(); Module module = application.findModule( "layer3", "test module" ); TestService service = module.findService( TestService.class ).get(); assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) ); }