@Test public void demonstrateHowToCreateAndUseAnAkkaExtensionInJava() { final ActorSystem system = null; try { // #extension-usage // typically you would use static import of the Settings.SettingsProvider field String dbUri = Settings.SettingsProvider.get(system).DB_URI; // #extension-usage } catch (Exception e) { // do nothing } }
public // #extension-usage-actor static class MyActor extends UntypedActor { // typically you would use static import of the Settings.SettingsProvider field final SettingsImpl settings = Settings.SettingsProvider.get(getContext().system()); Connection connection = connect(settings.DB_URI, settings.CIRCUIT_BREAKER_TIMEOUT); // #extension-usage-actor public Connection connect(String dbUri, Duration circuitBreakerTimeout) { return new Connection(); } public void onReceive(Object msg) {} // #extension-usage-actor }