-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1017 from puzzle/multitenancy_main-merge
Merge multitendancy in main
- Loading branch information
Showing
493 changed files
with
23,205 additions
and
7,635 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
22 changes: 22 additions & 0 deletions
22
backend/src/main/java/ch/puzzle/okr/FlywayMultitenantConfig.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ch.puzzle.okr; | ||
|
||
import ch.puzzle.okr.multitenancy.FlywayMultitenantMigrationInitializer; | ||
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy; | ||
import org.springframework.cache.interceptor.KeyGenerator; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class FlywayMultitenantConfig { | ||
|
||
@Bean | ||
public FlywayMigrationStrategy cleanMigrateStrategy(FlywayMultitenantMigrationInitializer flywayMigration) { | ||
return flyway -> flywayMigration.migrateFlyway(); | ||
} | ||
|
||
@Bean("customKeyGenerator") | ||
public KeyGenerator keyGenerator() { | ||
return new UserKeyGenerator(); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
package ch.puzzle.okr; | ||
|
||
import ch.puzzle.okr.service.clientconfig.ClientCustomizationProperties; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
@SpringBootApplication | ||
@EnableScheduling | ||
@EnableConfigurationProperties(ClientCustomizationProperties.class) | ||
public class OkrApplication { | ||
public static void main(String[] args) { | ||
SpringApplication.run(OkrApplication.class, args); | ||
|
||
new SpringApplicationBuilder(OkrApplication.class) // | ||
.initializers(new OkrApplicationContextInitializer()) // | ||
.run(args); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/src/main/java/ch/puzzle/okr/OkrApplicationContextInitializer.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ch.puzzle.okr; | ||
|
||
import ch.puzzle.okr.multitenancy.HibernateContext; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.ApplicationContextInitializer; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class OkrApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(OkrApplicationContextInitializer.class); | ||
|
||
@Override | ||
public void initialize(ConfigurableApplicationContext applicationContext) { | ||
logger.info("Loading hibernate configuration from application properties"); | ||
HibernateContext.extractAndSetHibernateConfig(applicationContext.getEnvironment()); | ||
} | ||
|
||
} |
Oops, something went wrong.