Example usage for com.google.common.collect Lists newArrayList

List of usage examples for com.google.common.collect Lists newArrayList

Introduction

In this page you can find the example usage for com.google.common.collect Lists newArrayList.

Prototype

@GwtCompatible(serializable = true)
public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements) 

Source Link

Document

Creates a mutable ArrayList instance containing the given elements; a very thin shortcut for creating an empty list and then calling Iterators#addAll .

Usage

From source file:com.google.api.services.samples.youtube.cmdline.youtube_cmdline_liststreams_sample.ListStreams.java

/**
 * Subscribes user's YouTube account to a user selected channel using OAuth2 for authentication.
 *//*from  ww  w  . j a v  a2s  .  co m*/
public static void main(String[] args) {

    // Scope required to read from YouTube.
    List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube.readonly");

    try {
        // Authorization.
        Credential credential = authorize(scopes);

        // YouTube object used to make all API requests.
        youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                .setApplicationName("youtube-cmdline-liststreams-sample").build();

        // List streams request is created.
        YouTube.LiveStreams.List livestreamRequest = youtube.liveStreams().list("id,snippet");

        // Modify results to have only user's streams.
        livestreamRequest.setMine(true);

        // List request is executed and list of streams are returned
        LiveStreamList returnedListResponse = livestreamRequest.execute();

        // Get the list of streams associated with the user.
        List<LiveStream> returnedList = returnedListResponse.getItems();

        // Print out returned results.
        System.out.println("\n================== Returned Streams ==================\n");
        for (LiveStream stream : returnedList) {
            System.out.println("  - Id: " + stream.getId());
            System.out.println("  - Title: " + stream.getSnippet().getTitle());
            System.out.println("  - Description: " + stream.getSnippet().getDescription());
            System.out.println("  - Published At: " + stream.getSnippet().getPublishedAt());
            System.out.println("\n-------------------------------------------------------------\n");
        }

    } catch (GoogleJsonResponseException e) {
        System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : "
                + e.getDetails().getMessage());
        e.printStackTrace();

    } catch (IOException e) {
        System.err.println("IOException: " + e.getMessage());
        e.printStackTrace();
    } catch (Throwable t) {
        System.err.println("Throwable: " + t.getMessage());
        t.printStackTrace();
    }
}

From source file:com.google.api.services.samples.youtube.cmdline.youtube_cmdline_listbroadcasts_sample.ListBroadcasts.java

/**
 * List user's broadcasts using OAuth2 for authentication.
 *
 * @param args command line args (not used).
 *//* w w  w  .  j  a va  2  s  . com*/
public static void main(String[] args) {

    // Scope required to read from YouTube.
    List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube.readonly");

    try {
        // Authorization.
        Credential credential = authorize(scopes);

        // YouTube object used to make all API requests.
        youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                .setApplicationName("youtube-cmdline-listbroadcasts-sample").build();

        // Create request to list broadcasts.
        YouTube.LiveBroadcasts.List liveBroadcastRequest = youtube.liveBroadcasts().list("id,snippet");

        // Modify results to have broadcasts in all states.
        liveBroadcastRequest.setBroadcastStatus("all");

        // List request is executed and list of broadcasts are returned
        LiveBroadcastList returnedListResponse = liveBroadcastRequest.execute();

        // Get the list of broadcasts associated with the user.
        List<LiveBroadcast> returnedList = returnedListResponse.getItems();

        // Print out returned results.
        System.out.println("\n================== Returned Broadcasts ==================\n");
        for (LiveBroadcast broadcast : returnedList) {
            System.out.println("  - Id: " + broadcast.getId());
            System.out.println("  - Title: " + broadcast.getSnippet().getTitle());
            System.out.println("  - Description: " + broadcast.getSnippet().getDescription());
            System.out.println("  - Published At: " + broadcast.getSnippet().getPublishedAt());
            System.out.println("  - Scheduled Start Time: " + broadcast.getSnippet().getScheduledStartTime());
            System.out.println("  - Scheduled End Time: " + broadcast.getSnippet().getScheduledEndTime());
            System.out.println("\n-------------------------------------------------------------\n");
        }

    } catch (GoogleJsonResponseException e) {
        System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : "
                + e.getDetails().getMessage());
        e.printStackTrace();

    } catch (IOException e) {
        System.err.println("IOException: " + e.getMessage());
        e.printStackTrace();
    } catch (Throwable t) {
        System.err.println("Throwable: " + t.getMessage());
        t.printStackTrace();
    }
}

From source file:com.erix.streaming.OpenCVFeatureCount.java

public static void main(String[] args) {
    if (args.length < 1) {
        System.err.println("Usage: OpenCVFeatureCount <nats url>");
        System.exit(1);//  w w  w .  ja v a  2  s .  c o  m
    }
    String nats_url = args[0];

    final NatsClient nc = new NatsClient(nats_url);
    System.out.println("About to connect to nats server at : " + nats_url);

    // Update the cumulative count function
    final Function2<List<Integer>, Optional<Integer>, Optional<Integer>> updateFunction = new Function2<List<Integer>, Optional<Integer>, Optional<Integer>>() {
        @Override
        public Optional<Integer> call(List<Integer> values, Optional<Integer> state) {
            Integer newSum = state.or(0);
            for (Integer value : values) {
                newSum += value;
            }
            return Optional.of(newSum);
        }
    };

    //nc.Connect(nats_url);
    //nc.Subscribe("foo");
    //nc.Publish("foo", "Java Nats Client");
    //StreamingExamples.setStreamingLogLevels();

    // Create the context with a 1 second batch size
    SparkConf sparkConf = new SparkConf().setAppName("OpenCVStatefulFeatureCount");
    JavaStreamingContext ssc = new JavaStreamingContext(sparkConf, Durations.seconds(1));
    ssc.checkpoint("./ck");

    // Initial RDD input to updateStateByKey
    List<Tuple2<String, Integer>> tuples = Arrays.asList(new Tuple2<String, Integer>("0", 0),
            new Tuple2<String, Integer>("0", 0));
    JavaPairRDD<String, Integer> initialRDD = ssc.sc().parallelizePairs(tuples);

    JavaReceiverInputDStream<String> lines = ssc.receiverStream(nc);
    JavaDStream<String> words = lines.flatMap(new FlatMapFunction<String, String>() {
        @Override
        public Iterable<String> call(String x) {
            //System.out.println("Recevied x:"+x);
            String[] ins = SPACE.split(x.replace("\"", ""));
            //for (int i=0;i<ins.length ;i++ ) {
            //  ins[i]=ins[i].replace("\"","");
            //}
            return Lists.newArrayList(ins);
        }
    });
    JavaPairDStream<String, Integer> wordsDstream = words
            .mapToPair(new PairFunction<String, String, Integer>() {
                @Override
                public Tuple2<String, Integer> call(String s) {
                    return new Tuple2<String, Integer>(s, 1);
                }
            });

    // This will give a Dstream made of state (which is the cumulative count of the words)
    JavaPairDStream<String, Integer> stateDstream = wordsDstream.updateStateByKey(updateFunction,
            new HashPartitioner(ssc.sc().defaultParallelism()), initialRDD);

    stateDstream.print();
    stateDstream.foreachRDD(new Function2<JavaPairRDD<String, Integer>, Time, Void>() {
        @Override
        public Void call(JavaPairRDD<String, Integer> rdd, Time time) throws IOException {
            //String counts = "Counts at time " + time + " " + rdd.collect();
            //System.out.println(counts);
            nc.Publish("bar", rdd.collect().toString());
            return null;
        }
    });
    ssc.start();
    ssc.awaitTermination();
}

From source file:com.google.api.services.samples.youtube.cmdline.youtube_cmdline_addsubscription_sample.AddSubscription.java

/**
 * Subscribes user's YouTube account to a user selected channel using OAuth2 for authentication.
 *
 * @param args command line args (not used).
 *//*from ww w.  j a va2s . co  m*/
public static void main(String[] args) {

    // An OAuth 2 access scope that allows for full read/write access.
    List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube");

    try {
        // Authorization.
        Credential credential = authorize(scopes);

        // YouTube object used to make all API requests.
        youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                .setApplicationName("youtube-cmdline-addsubscription-sample").build();

        // We get the user selected channel to subscribe.
        String channelId = getChannelId();
        System.out.println("You chose " + channelId + " to subscribe.");

        // We create a resourceId with channel id.
        ResourceId resourceId = new ResourceId();
        resourceId.setChannelId(channelId);
        resourceId.setKind("youtube#channel");

        // We create a snippet with ResourceId.
        SubscriptionSnippet snippet = new SubscriptionSnippet();
        snippet.setResourceId(resourceId);

        // We create a subscription request with snippet.
        Subscription subscription = new Subscription();
        subscription.setSnippet(snippet);

        /*
         * The subscription insert command includes: 1. Information we want returned after file is
         * successfully uploaded. 2. Subscription metadata we want to insert.
         */
        YouTube.Subscriptions.Insert subscriptionInsert = youtube.subscriptions()
                .insert("snippet,contentDetails", subscription);

        // Execute subscription.
        Subscription returnedSubscription = subscriptionInsert.execute();

        // Print out returned results.
        System.out.println("\n================== Returned Subscription ==================\n");
        System.out.println("  - Id: " + returnedSubscription.getId());
        System.out.println("  - Title: " + returnedSubscription.getSnippet().getTitle());

    } catch (GoogleJsonResponseException e) {
        System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : "
                + e.getDetails().getMessage());
        e.printStackTrace();

    } catch (IOException e) {
        System.err.println("IOException: " + e.getMessage());
        e.printStackTrace();
    } catch (Throwable t) {
        System.err.println("Throwable: " + t.getMessage());
        t.printStackTrace();
    }
}

From source file:com.google.api.services.samples.youtube.cmdline.youtube_cmdline_addfeaturedvideo_sample.AddFeaturedVideo.java

/**
 * This is a very simple code sample that looks up a user's channel, then features the most recently
 * uploaded video in the bottom left hand corner of every single video in the channel.
 *
 * @param args command line args (not used).
 *///from   ww  w .  j  a va  2  s .c om
public static void main(String[] args) {

    // An OAuth 2 access scope that allows for full read/write access.
    List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube");

    try {
        // Authorization.
        Credential credential = authorize(scopes);

        // YouTube object used to make all API requests.
        youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                .setApplicationName("youtube-cmdline-addfeaturedvideo-sample").build();

        // Fetch the user's channel. We also fetch the uploads playlist so we can use this later
        // to find the most recently uploaded video
        ChannelListResponse channelListResponse = youtube.channels().list("id,contentDetails").setMine(true)
                .setFields("items(contentDetails/relatedPlaylists/uploads,id)").execute();

        // This assumes the user has a channel already. If the user does not have a channel, this should
        // throw a GoogleJsonResponseException explaining the issue
        Channel myChannel = channelListResponse.getItems().get(0);
        String channelId = myChannel.getId();
        String uploadsPlaylistId = myChannel.getContentDetails().getRelatedPlaylists().getUploads();

        // Fetch the most recently uploaded video
        PlaylistItemListResponse playlistItemListResponse = youtube.playlistItems().list("snippet")
                .setPlaylistId(uploadsPlaylistId).setFields("items/snippet").execute();

        String featuredVideoId;
        if (playlistItemListResponse.getItems().isEmpty()) {
            // There are no videos on the channel. Therefore, we cannot feature a video. Exit.
            System.out.println(
                    "Channel contains no videos. Featuring a default video instead from the Google Developers channel.");
            featuredVideoId = "w4eiUiauo2w";
        } else {
            // The latest video should be the first video in the playlist response
            PlaylistItem featuredVideo = playlistItemListResponse.getItems().get(0);
            featuredVideoId = featuredVideo.getSnippet().getResourceId().getVideoId();

            System.out.println("Featuring video: " + featuredVideo.getSnippet().getTitle());
        }

        // Feature this video on the channel via the Invideo programming API
        // This describes the position of the video. Valid positions are bottomLeft, bottomRight, topLeft and
        // topRight
        InvideoPosition invideoPosition = new InvideoPosition();
        invideoPosition.setCornerPosition("bottomLeft");
        invideoPosition.setType("corner");

        // The allowed offsets are offsetFromEnd and offsetFromStart, with offsetMs being an offset in milliseconds
        InvideoTiming invideoTiming = new InvideoTiming();
        invideoTiming.setOffsetMs(BigInteger.valueOf(15000l));
        invideoTiming.setType("offsetFromEnd");

        // Represents the type of promotion. In this case, a video with a video ID
        PromotedItemId promotedItemId = new PromotedItemId();
        promotedItemId.setType("video");
        promotedItemId.setVideoId(featuredVideoId);

        // Construct the Invidideo promotion
        InvideoPromotion invideoPromotion = new InvideoPromotion();
        invideoPromotion.setPosition(invideoPosition);
        invideoPromotion.setTiming(invideoTiming);
        invideoPromotion.setItems(Lists.newArrayList(promotedItemId));

        // Now let's add the invideo promotion to the channel
        Channel channel = new Channel();
        channel.setId(channelId);
        channel.setInvideoPromotion(invideoPromotion);

        // Make the API call
        Channel updateChannelResponse = youtube.channels().update("invideoPromotion", channel).execute();

        // Print out returned results.
        System.out.println("\n================== Updated Channel Information ==================\n");
        System.out.println("\t- Channel ID: " + updateChannelResponse.getId());

        InvideoPromotion promotion = updateChannelResponse.getInvideoPromotion();
        System.out.println("\t- Invideo promotion video ID: " + promotion.getItems().get(0).getVideoId());
        System.out.println("\t- Promotion position: " + promotion.getPosition().getCornerPosition());
        System.out.println("\t- Promotion timing: " + promotion.getTiming().getOffsetMs() + " Offset: "
                + promotion.getTiming().getType());
    } catch (GoogleJsonResponseException e) {
        System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : "
                + e.getDetails().getMessage());
        e.printStackTrace();

    } catch (IOException e) {
        System.err.println("IOException: " + e.getMessage());
        e.printStackTrace();
    }
}

From source file:pl.edu.icm.cermine.bx.DocumentBibZonesCorrector.java

public static void main(String[] args) throws TransformationException, IOException, AnalysisException,
        ParseException, CloneNotSupportedException {
    Options options = new Options();
    options.addOption("input", true, "input path");
    options.addOption("output", true, "output path");
    CommandLineParser parser = new GnuParser();
    CommandLine line = parser.parse(options, args);
    String inDir = line.getOptionValue("input");
    String outDir = line.getOptionValue("output");

    File dir = new File(inDir);

    for (File f : FileUtils.listFiles(dir, new String[] { "xml" }, true)) {
        TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
        List<BxPage> pages = tvReader.read(new FileReader(f));
        BxDocument doc = new BxDocument().setPages(pages);
        doc.setFilename(f.getName());/* w  w w  .j av a  2s . c om*/

        for (BxZone z : doc.asZones()) {
            if (!BxZoneLabel.MET_BIB_INFO.equals(z.getLabel()) && !BxZoneLabel.REFERENCES.equals(z.getLabel())
                    && z.childrenCount() <= 2
                    && (z.toText().toLowerCase().contains("journal ")
                            || z.toText().toLowerCase().contains("vol.")
                            || z.toText().toLowerCase().contains("vol ")
                            || z.toText().toLowerCase().contains("pp.")
                            || z.toText().toLowerCase().contains("volume ")
                            || z.toText().toLowerCase().contains("pp ")
                            || z.toText().toLowerCase().contains("issn")
                            || z.toText().toLowerCase().contains("doi:")
                            || z.toText().toLowerCase().contains("doi ")
                            || z.toText().toLowerCase().contains("citation:"))) {
                System.out.println("DETECTED BIBINFO: ");
                System.out.println(z.getLabel() + " " + z.toText());
                System.out.println("");
                z.setLabel(BxZoneLabel.MET_BIB_INFO);
            } else if (!BxZoneLabel.OTH_UNKNOWN.equals(z.getLabel())
                    && !BxZoneLabel.MET_BIB_INFO.equals(z.getLabel()) && z.childrenCount() <= 2
                    && (z.toText().toLowerCase().contains("page "))) {
                System.out.println("DETECTED PAGE: ");
                System.out.println(z.getLabel() + " " + z.toText());
                System.out.println("");
                z.setLabel(BxZoneLabel.OTH_UNKNOWN);
            }
        }

        File f2 = new File(outDir + doc.getFilename());
        BxDocumentToTrueVizWriter wrt = new BxDocumentToTrueVizWriter();
        boolean created = f2.createNewFile();
        if (!created) {
            throw new IOException("Cannot create file: ");
        }
        FileWriter fw = new FileWriter(f2);
        wrt.write(fw, Lists.newArrayList(doc));
        fw.flush();
        fw.close();
    }
}

From source file:tv.icntv.grade.film.recommend.CorrelateJob.java

public static void main(String[] args) throws Exception {
    final Configuration configuration = HBaseConfiguration.create();
    configuration.addResource("grade.xml");
    String tables = configuration.get("hbase.cdn.tables");
    if (Strings.isNullOrEmpty(tables)) {
        return;/*from   w ww .  j a  v a 2  s  .c  om*/
    }
    List<String> list = Lists.newArrayList(Splitter.on(",").split(tables));
    List<String> results = Lists.transform(list, new Function<String, String>() {
        @Override
        public String apply(@Nullable java.lang.String input) {
            return String.format(configuration.get("hdfs.directory.base.db"), new Date(), input);
        }
    });
    String middleDirectory = String.format(configuration.get("icntv.correlate.input"), new Date());
    StringBuilder sb = new StringBuilder();
    sb.append("minSupport=").append(configuration.get("correlate.minSupport", "3")).append("--")
            .append("maxHeapSize=100").append("--").append("splitterPattern='[\t ]'").append("--")
            .append("input=").append(middleDirectory).append("--").append("output=")
            .append(String.format(configuration.get("icntv.correlate.fp.growth.output"), new Date()));
    ToolRunner.run(configuration, new CorrelateJob(),
            new String[] { Joiner.on(",").join(results), middleDirectory, sb.toString(),
                    String.format(configuration.get("icntv.correlate.output"), new Date()) });
}

From source file:com.google.api.services.samples.youtube.cmdline.youtube_cmdline_updatevideo_sample.UpdateVideo.java

/**
 * Uploads user selected video in the project folder to the user's YouTube account using OAuth2
 * for authentication.//from   w  w  w.  j ava 2  s  . c  om
 *
 * @param args command line args (not used).
 */
public static void main(String[] args) {

    // An OAuth 2 access scope that allows for full read/write access.
    List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube");

    try {
        // Authorization.
        Credential credential = authorize(scopes);

        // YouTube object used to make all API requests.
        youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                .setApplicationName("youtube-cmdline-updatevideo-sample").build();

        // Get the user selected video Id.
        String videoId = getVideoIdFromUser();
        System.out.println("You chose " + videoId + " to update.");

        // Get the user selected tag for video.
        String tag = getTagFromUser();
        System.out.println("You chose " + tag + " as a tag.");

        // Create the video list request
        YouTube.Videos.List listVideosRequest = youtube.videos().list(videoId, "snippet");

        // Request is executed and video list response is returned
        VideoListResponse listResponse = listVideosRequest.execute();

        List<Video> videoList = listResponse.getItems();
        if (videoList.isEmpty()) {
            System.out.println("Can't find a video with video id: " + videoId);
            return;
        }

        // Since a unique video id is given, it will only return 1 video.
        Video video = videoList.get(0);
        VideoSnippet snippet = video.getSnippet();

        List<String> tags = snippet.getTags();

        // getTags() returns null if the video didn't have any tags, so we will check for this and
        // create a new list if needed
        if (tags == null) {
            tags = new ArrayList<String>(1);
            snippet.setTags(tags);
        }
        tags.add(tag);

        // Create the video update request
        YouTube.Videos.Update updateVideosRequest = youtube.videos().update("snippet", video);

        // Request is executed and updated video is returned
        Video videoResponse = updateVideosRequest.execute();

        // Print out returned results.
        System.out.println("\n================== Returned Video ==================\n");
        System.out.println("  - Title: " + videoResponse.getSnippet().getTitle());
        System.out.println("  - Tags: " + videoResponse.getSnippet().getTags());

    } catch (GoogleJsonResponseException e) {
        System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : "
                + e.getDetails().getMessage());
        e.printStackTrace();
    } catch (IOException e) {
        System.err.println("IOException: " + e.getMessage());
        e.printStackTrace();
    } catch (Throwable t) {
        System.err.println("Throwable: " + t.getMessage());
        t.printStackTrace();
    }
}

From source file:pl.edu.icm.cermine.PdfBxStructureExtractor.java

public static void main(String[] args) throws ParseException, IOException {
    CommandLineOptionsParser parser = new CommandLineOptionsParser();
    if (!parser.parse(args)) {
        System.err.println("Usage: PdfBxStructureExtractor -path <path> [optional parameters]\n\n"
                + "Tool for extracting structured content from PDF files.\n\n" + "Arguments:\n"
                + "  -path <path>              path to a PDF file or directory containing PDF files\n"
                + "  -modelmeta <path>         (optional) the path to the metadata classifier model file\n"
                + "  -modelinit <path>         (optional) the path to the initial classifier model file\n"
                + "  -strext <extension>       (optional) the extension of the structure (TrueViz) file;\n"
                + "                            default: \"cxml\"; used only if passed path is a directory\n"
                + "  -threads <num>            number of threads for parallel processing\n");
        System.exit(1);/*from  w ww  .  ja va  2 s  .  co  m*/
    }

    String path = parser.getPath();
    String strExtension = parser.getBxExtension();
    PdfNLMContentExtractor.THREADS_NUMBER = parser.getThreadsNumber();

    File file = new File(path);
    Collection<File> files = FileUtils.listFiles(file, new String[] { "pdf" }, true);

    int i = 0;
    for (File pdf : files) {
        File strF = new File(pdf.getPath().replaceAll("pdf$", strExtension));
        if (strF.exists()) {
            i++;
            continue;
        }

        long start = System.currentTimeMillis();
        float elapsed = 0;

        System.out.println(pdf.getPath());

        try {
            PdfBxStructureExtractor extractor = new PdfBxStructureExtractor();
            parser.updateMetadataModel(extractor.getConf());
            parser.updateInitialModel(extractor.getConf());

            InputStream in = new FileInputStream(pdf);
            BxDocument doc = ExtractionUtils.extractStructure(extractor.getConf(), in);
            doc = extractor.getConf().getMetadataClassifier().classifyZones(doc);

            long end = System.currentTimeMillis();
            elapsed = (end - start) / 1000F;

            BxDocumentToTrueVizWriter writer = new BxDocumentToTrueVizWriter();
            writer.write(new FileWriter(strF), Lists.newArrayList(doc));
        } catch (AnalysisException ex) {
            ex.printStackTrace();
        } catch (TransformationException ex) {
            ex.printStackTrace();
        }

        i++;
        int percentage = i * 100 / files.size();
        if (elapsed == 0) {
            elapsed = (System.currentTimeMillis() - start) / 1000F;
        }
        System.out.println("Extraction time: " + Math.round(elapsed) + "s");
        System.out.println(percentage + "% done (" + i + " out of " + files.size() + ")");
        System.out.println("");
    }
}

From source file:org.apache.brooklyn.demo.WebClusterDatabaseExample.java

public static void main(String[] argv) {
    List<String> args = Lists.newArrayList(argv);
    String port = CommandLineUtil.getCommandLineOption(args, "--port", "8081+");
    String location = CommandLineUtil.getCommandLineOption(args, "--location", "localhost");

    BrooklynLauncher launcher = BrooklynLauncher.newInstance()
            .application(EntitySpec.create(StartableApplication.class, WebClusterDatabaseExample.class)
                    .displayName("Brooklyn WebApp Cluster with Database example"))
            .webconsolePort(port).location(location).start();

    Entities.dumpInfo(launcher.getApplications());
}