forked from spring-projects/spring-integration-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INTSAMPLES-148: Make JPA Sample as Boot App
JIRA: https://jira.spring.io/browse/INTSAMPLES-148 Upgrade several dependencies, especially OpenJPA-2.4.0 to support Java 8 Class Transformation Upgrade to DSL-1.1.2 and other polishing Upgrade to SI-4.3.0.M1
- Loading branch information
1 parent
b52ee9e
commit 6080639
Showing
22 changed files
with
233 additions
and
249 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
64 changes: 64 additions & 0 deletions
64
...c/main/java/org/springframework/integration/samples/jpa/EclipseLinkAutoConfiguration.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,64 @@ | ||
package org.springframework.integration.samples.jpa; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import javax.persistence.EntityManager; | ||
|
||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||
import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter; | ||
import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
import org.springframework.util.ClassUtils; | ||
|
||
/** | ||
* @author Artem Bilan | ||
* @since 4.2 | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass({LocalContainerEntityManagerFactoryBean.class, | ||
EnableTransactionManagement.class, EntityManager.class}) | ||
@Conditional(EclipseLinkAutoConfiguration.EclipseLinkEntityManagerCondition.class) | ||
@AutoConfigureAfter({DataSourceAutoConfiguration.class}) | ||
@Profile("eclipseLink") | ||
public class EclipseLinkAutoConfiguration extends JpaBaseConfiguration { | ||
|
||
@Override | ||
protected AbstractJpaVendorAdapter createJpaVendorAdapter() { | ||
return new EclipseLinkJpaVendorAdapter(); | ||
} | ||
|
||
@Override | ||
protected Map<String, Object> getVendorProperties() { | ||
return new HashMap<String, Object>(); | ||
} | ||
|
||
|
||
@Order(Ordered.HIGHEST_PRECEDENCE + 20) | ||
static class EclipseLinkEntityManagerCondition extends SpringBootCondition { | ||
|
||
@Override | ||
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
if (ClassUtils.isPresent("org.eclipse.persistence.jpa.JpaEntityManager", context.getClassLoader())) { | ||
return ConditionOutcome.match("found JpaEntityManager class"); | ||
} | ||
else { | ||
return ConditionOutcome.noMatch("did not find JpaEntityManager class"); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
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
64 changes: 64 additions & 0 deletions
64
...a/src/main/java/org/springframework/integration/samples/jpa/OpenJpaAutoConfiguration.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,64 @@ | ||
package org.springframework.integration.samples.jpa; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import javax.persistence.EntityManager; | ||
|
||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||
import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter; | ||
import org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
import org.springframework.util.ClassUtils; | ||
|
||
/** | ||
* @author Artem Bilan | ||
* @since 4.2 | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass({LocalContainerEntityManagerFactoryBean.class, | ||
EnableTransactionManagement.class, EntityManager.class}) | ||
@Conditional(OpenJpaAutoConfiguration.OpenJpaEntityManagerCondition.class) | ||
@AutoConfigureAfter({DataSourceAutoConfiguration.class}) | ||
@Profile("openJpa") | ||
public class OpenJpaAutoConfiguration extends JpaBaseConfiguration { | ||
|
||
@Override | ||
protected AbstractJpaVendorAdapter createJpaVendorAdapter() { | ||
return new OpenJpaVendorAdapter(); | ||
} | ||
|
||
@Override | ||
protected Map<String, Object> getVendorProperties() { | ||
return new HashMap<String, Object>(); | ||
} | ||
|
||
|
||
@Order(Ordered.HIGHEST_PRECEDENCE + 20) | ||
static class OpenJpaEntityManagerCondition extends SpringBootCondition { | ||
|
||
@Override | ||
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
if (ClassUtils.isPresent("org.apache.openjpa.persistence.OpenJPAEntityManager", context.getClassLoader())) { | ||
return ConditionOutcome.match("found OpenJPAEntityManager class"); | ||
} | ||
else { | ||
return ConditionOutcome.noMatch("did not find OpenJPAEntityManager class"); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.