Changed name of the instance field as suggested. See #1702
This commit is contained in:
parent
6a4d7f547c
commit
1572da09db
3 changed files with 16 additions and 12 deletions
|
|
@ -17,10 +17,10 @@ import static org.junit.Assert.*;
|
||||||
public class JavaExtension {
|
public class JavaExtension {
|
||||||
|
|
||||||
static class TestExtensionId extends AbstractExtensionId<TestExtension> implements ExtensionIdProvider {
|
static class TestExtensionId extends AbstractExtensionId<TestExtension> implements ExtensionIdProvider {
|
||||||
public final static TestExtensionId instance = new TestExtensionId();
|
public final static TestExtensionId TestExtensionProvider = new TestExtensionId();
|
||||||
|
|
||||||
public ExtensionId<TestExtension> lookup() {
|
public ExtensionId<TestExtension> lookup() {
|
||||||
return instance;
|
return TestExtensionId.TestExtensionProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestExtension createExtension(ActorSystemImpl i) {
|
public TestExtension createExtension(ActorSystemImpl i) {
|
||||||
|
|
@ -64,8 +64,8 @@ public class JavaExtension {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAccessible() {
|
public void mustBeAccessible() {
|
||||||
assertSame(system.extension(TestExtensionId.instance).system, system);
|
assertSame(system.extension(TestExtensionId.TestExtensionProvider).system, system);
|
||||||
assertSame(TestExtensionId.instance.apply(system).system, system);
|
assertSame(TestExtensionId.TestExtensionProvider.apply(system).system, system);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,14 @@ public class ExtensionDocTestBase {
|
||||||
//#extensionid
|
//#extensionid
|
||||||
public static class CountExtension extends AbstractExtensionId<CountExtensionImpl> implements ExtensionIdProvider {
|
public static class CountExtension extends AbstractExtensionId<CountExtensionImpl> implements ExtensionIdProvider {
|
||||||
//This will be the identifier of our CountExtension
|
//This will be the identifier of our CountExtension
|
||||||
public final static CountExtension instance = new CountExtension();
|
public final static CountExtension CountExtensionProvider = new CountExtension();
|
||||||
|
|
||||||
//The lookup method is required by ExtensionIdProvider,
|
//The lookup method is required by ExtensionIdProvider,
|
||||||
// so we return ourselves here, this allows us
|
// so we return ourselves here, this allows us
|
||||||
// to configure our extension to be loaded when
|
// to configure our extension to be loaded when
|
||||||
// the ActorSystem starts up
|
// the ActorSystem starts up
|
||||||
public CountExtension lookup() {
|
public CountExtension lookup() {
|
||||||
return CountExtension.instance; //The public static final
|
return CountExtension.CountExtensionProvider; //The public static final
|
||||||
}
|
}
|
||||||
|
|
||||||
//This method will be called by Akka
|
//This method will be called by Akka
|
||||||
|
|
@ -52,7 +52,8 @@ public class ExtensionDocTestBase {
|
||||||
//#extension-usage-actor
|
//#extension-usage-actor
|
||||||
public static class MyActor extends UntypedActor {
|
public static class MyActor extends UntypedActor {
|
||||||
public void onReceive(Object msg) {
|
public void onReceive(Object msg) {
|
||||||
CountExtension.instance.get(getContext().system()).increment();
|
// typically you would use static import of CountExtension.CountExtensionProvider field
|
||||||
|
CountExtension.CountExtensionProvider.get(getContext().system()).increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +64,8 @@ public class ExtensionDocTestBase {
|
||||||
final ActorSystem system = null;
|
final ActorSystem system = null;
|
||||||
try {
|
try {
|
||||||
//#extension-usage
|
//#extension-usage
|
||||||
CountExtension.instance.get(system).increment();
|
// typically you would use static import of CountExtension.CountExtensionProvider field
|
||||||
|
CountExtension.CountExtensionProvider.get(system).increment();
|
||||||
//#extension-usage
|
//#extension-usage
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//do nothing
|
//do nothing
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ public class SettingsExtensionDocTestBase {
|
||||||
|
|
||||||
//#extensionid
|
//#extensionid
|
||||||
public static class Settings extends AbstractExtensionId<SettingsImpl> implements ExtensionIdProvider {
|
public static class Settings extends AbstractExtensionId<SettingsImpl> implements ExtensionIdProvider {
|
||||||
public final static Settings instance = new Settings();
|
public final static Settings SettingsProvider = new Settings();
|
||||||
|
|
||||||
public Settings lookup() {
|
public Settings lookup() {
|
||||||
return Settings.instance;
|
return Settings.SettingsProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettingsImpl createExtension(ActorSystemImpl system) {
|
public SettingsImpl createExtension(ActorSystemImpl system) {
|
||||||
|
|
@ -53,7 +53,8 @@ public class SettingsExtensionDocTestBase {
|
||||||
|
|
||||||
//#extension-usage-actor
|
//#extension-usage-actor
|
||||||
public static class MyActor extends UntypedActor {
|
public static class MyActor extends UntypedActor {
|
||||||
final SettingsImpl settings = Settings.instance.get(getContext().system());
|
// typically you would use static import of CountExtension.CountExtensionProvider field
|
||||||
|
final SettingsImpl settings = Settings.SettingsProvider.get(getContext().system());
|
||||||
Connection connection = connect(settings.DB_URI, settings.CIRCUIT_BREAKER_TIMEOUT);
|
Connection connection = connect(settings.DB_URI, settings.CIRCUIT_BREAKER_TIMEOUT);
|
||||||
|
|
||||||
//#extension-usage-actor
|
//#extension-usage-actor
|
||||||
|
|
@ -75,7 +76,8 @@ public class SettingsExtensionDocTestBase {
|
||||||
final ActorSystem system = null;
|
final ActorSystem system = null;
|
||||||
try {
|
try {
|
||||||
//#extension-usage
|
//#extension-usage
|
||||||
String dbUri = Settings.instance.get(system).DB_URI;
|
// typically you would use static import of CountExtension.CountExtensionProvider field
|
||||||
|
String dbUri = Settings.SettingsProvider.get(system).DB_URI;
|
||||||
//#extension-usage
|
//#extension-usage
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//do nothing
|
//do nothing
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue