This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Body body = createBody(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component( modules = RandomInjectionModule.class ) | |
public interface Doctor { | |
Body injectBlood(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class RandomInjectionModule { | |
private static Blood blood; | |
public RandomInjectionModule() { | |
} | |
@Provides | |
static Blood provideBlood(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class A_Blood extends Blood{ | |
@Override | |
public String getKindOfBlood() { | |
return "A"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Blood { | |
public abstract String getKindOfBlood(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Body { | |
@Inject | |
Blood blood; | |
@Inject | |
public Body(){} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person{ | |
Body body; | |
@Inject | |
public Person(Body body){ | |
this.body = body; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ricston.injectionexample.domain; | |
import com.ricston.injectionexample.domain.com.ricston.injectionexample.domain.blood.Blood; | |
import javax.inject.Inject; | |
public class Body { | |
@Inject | |
public Body(){} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration(locations = { "classpath:META-INF/spring/testContext.xml" }) | |
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD) | |
public class MultiTenantConnectionProviderTest { | |
... | |
@Autowired | |
MultiTenantConnectionProviderImpl multitenancyConnectionProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* It specify what Tenant should be used: | |
* <p> | |
* <p> | |
* There are 2 modes of resolving the identifier using {@link #resolveCurrentTenantIdentifier()}: | |
* | |
* <li> Using a global tenant identifier for junit testing | |
* <li> Using the http session to get the tenant for deployed applications | |
* |
NewerOlder