Malhar has not been updated to use the later version of core, so that's why
you don't find examples there. It is used in the ApexRunner in Beam though.
Here is a code snippet from a test I wrote recently that uses the new API:
EmbeddedAppLauncher<?> launcher = Launcher.getLauncher(LaunchMode.
EMBEDDED);
Attribute.AttributeMap launchAttributes = new Attribute.AttributeMap.
DefaultAttributeMap();
launchAttributes.put(EmbeddedAppLauncher.RUN_ASYNC, true);
Configuration conf = new Configuration(false);
conf.addResource(this.getClass().getResourceAsStream(
"/META-INF/properties.xml"));
conf.addResource(this.getClass().getResourceAsStream(
"/wordcounttest-properties.xml"));
File resultFile = new File("./target/wordcountresult_4.0");
if (resultFile.exists() && !resultFile.delete()) {
throw new AssertionError("Failed to delete " + resultFile);
}
AppHandle appHandle = launcher.launchApp(new Application(), conf,
launchAttributes);
long timeoutMillis = System.currentTimeMillis() + 10000;
while (!appHandle.isFinished() && System.currentTimeMillis() <
timeoutMillis) {
Thread.sleep(500);
if (resultFile.exists() && resultFile.length() > 0) {
break;
}
}
appHandle.shutdown(ShutdownMode.KILL);
Assert.assertTrue(resultFile.exists() && resultFile.length() > 0);
String result = FileUtils.readFileToString(resultFile);
Assert.assertTrue(result, result.contains("MyFirstApplication=5"));
On Wed, Mar 1, 2017 at 9:23 AM, Ganelin, Ilya <[email protected]>
wrote:
> Hi all, I’ve returned to writing Apex apps after a hiatus, it seems that
> the LocalMode is now deprecated, having been replaced by the Launcher
> interface. Is there an example or documentation anywhere of using this new
> API?
>
>
>
> Please let me know, thanks!
>
>
>
> - Ilya Ganelin
>
> [image: id:[email protected]]
>
> ------------------------------
>
> The information contained in this e-mail is confidential and/or
> proprietary to Capital One and/or its affiliates and may only be used
> solely in performance of work or services for Capital One. The information
> transmitted herewith is intended only for use by the individual or entity
> to which it is addressed. If the reader of this message is not the intended
> recipient, you are hereby notified that any review, retransmission,
> dissemination, distribution, copying or other use of, or taking of any
> action in reliance upon this information is strictly prohibited. If you
> have received this communication in error, please contact the sender and
> delete the material from your computer.
>