-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Avgustin Marinov <[email protected]>
- Loading branch information
1 parent
af50e8c
commit 5eb9243
Showing
41 changed files
with
1,061 additions
and
226 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# hawkBit JPA EclipseLink Vendor integration | ||
|
||
Implementation of [EclipseLink](http://www.eclipse.org/eclipselink/) JPA vendor. |
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,47 @@ | ||
<!-- | ||
Copyright (c) 2015 Bosch Software Innovations GmbH and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.hawkbit</groupId> | ||
<version>${revision}</version> | ||
<artifactId>hawkbit-repository</artifactId> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>hawkbit-repository-jpa-api</artifactId> | ||
<name>hawkBit :: Repository :: JPA API</name> | ||
|
||
<properties> | ||
<apt.source.dir>${project.build.directory}/generated-sources/apt/</apt.source.dir> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.hawkbit</groupId> | ||
<artifactId>hawkbit-repository-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>org.eclipse.persistence.jpa</artifactId> | ||
<version>${eclipselink.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.
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
File renamed without changes.
51 changes: 51 additions & 0 deletions
51
...repository-jpa-api/src/main/java/org/eclipse/hawkbit/repository/jpa/model/BaseEntity.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,51 @@ | ||
/** | ||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.hawkbit.repository.model; | ||
|
||
import java.io.Serializable; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.eclipse.hawkbit.repository.Identifiable; | ||
|
||
/** | ||
* Core information of all entities. | ||
*/ | ||
public interface BaseEntity extends Serializable, Identifiable<Long> { | ||
|
||
static Long getIdOrNull(final BaseEntity entity) { | ||
return entity == null ? null : entity.getId(); | ||
} | ||
|
||
/** | ||
* @return user that created the {@link BaseEntity}. | ||
*/ | ||
String getCreatedBy(); | ||
|
||
/** | ||
* @return time in {@link TimeUnit#MILLISECONDS} when the {@link BaseEntity} was created. | ||
*/ | ||
long getCreatedAt(); | ||
|
||
/** | ||
* @return user that updated the {@link BaseEntity} last. | ||
*/ | ||
String getLastModifiedBy(); | ||
|
||
/** | ||
* @return time in {@link TimeUnit#MILLISECONDS} when the {@link BaseEntity} | ||
* was last time changed. | ||
*/ | ||
long getLastModifiedAt(); | ||
|
||
/** | ||
* @return version of the {@link BaseEntity}. | ||
*/ | ||
int getOptLockRevision(); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
hawkbit-repository/hawkbit-repository-jpa-eclipselink/README.md
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,3 @@ | ||
# hawkBit JPA EclipseLink Vendor integration | ||
|
||
Implementation of [EclipseLink](http://www.eclipse.org/eclipselink/) JPA vendor. |
74 changes: 74 additions & 0 deletions
74
hawkbit-repository/hawkbit-repository-jpa-eclipselink/pom.xml
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,74 @@ | ||
<!-- | ||
Copyright (c) 2015 Bosch Software Innovations GmbH and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.hawkbit</groupId> | ||
<version>${revision}</version> | ||
<artifactId>hawkbit-repository</artifactId> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>hawkbit-repository-jpa-eclipselink</artifactId> | ||
<name>hawkBit :: Repository :: JPA EclipseLink Vendor</name> | ||
|
||
<properties> | ||
<apt.source.dir>${project.build.directory}/generated-sources/apt/</apt.source.dir> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.hawkbit</groupId> | ||
<artifactId>hawkbit-repository-jpa-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<!-- Static class generation --> | ||
<dependency> | ||
<groupId>org.hibernate.orm</groupId> | ||
<artifactId>hibernate-jpamodelgen</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>org.eclipse.persistence.jpa</artifactId> | ||
<version>${eclipselink.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<!-- --> | ||
<!-- <build>--> | ||
<!-- <plugins>--> | ||
<!-- <plugin>--> | ||
<!-- <groupId>org.hibernate.orm.tooling</groupId>--> | ||
<!-- <artifactId>hibernate-enhance-maven-plugin</artifactId>--> | ||
<!-- <version>${hibernate.version}</version>--> | ||
<!-- <executions>--> | ||
<!-- <execution>--> | ||
<!-- <configuration>--> | ||
<!-- <!–--> | ||
<!-- enableLazyInitialization and enableDirtyTracking enabled by default.--> | ||
<!-- anyway, in future they couldn't be set to false anyway--> | ||
<!-- –>--> | ||
<!-- <enableAssociationManagement>false</enableAssociationManagement>--> | ||
<!-- <enableExtendedEnhancement>false</enableExtendedEnhancement>--> | ||
<!-- </configuration>--> | ||
<!-- <goals>--> | ||
<!-- <goal>enhance</goal>--> | ||
<!-- </goals>--> | ||
<!-- </execution>--> | ||
<!-- </executions>--> | ||
<!-- </plugin>--> | ||
<!-- </plugins>--> | ||
<!-- </build>--> | ||
</project> |
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
86 changes: 86 additions & 0 deletions
86
...ry-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaConfiguration.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,86 @@ | ||
/** | ||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.hawkbit.repository.jpa; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.eclipse.persistence.config.PersistenceUnitProperties; | ||
import org.springframework.beans.factory.ObjectProvider; | ||
import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; | ||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; | ||
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter; | ||
import org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect; | ||
import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
import org.springframework.transaction.jta.JtaTransactionManager; | ||
|
||
/** | ||
* General EclipseLink configuration for hawkBit's Repository. | ||
*/ | ||
@Configuration | ||
public class JpaConfiguration extends JpaBaseConfiguration { | ||
|
||
protected JpaConfiguration( | ||
final DataSource dataSource, final JpaProperties properties, | ||
final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) { | ||
super(dataSource, properties, jtaTransactionManagerProvider); | ||
} | ||
|
||
/** | ||
* {@link MultiTenantJpaTransactionManager} bean. | ||
* | ||
* @return a new {@link PlatformTransactionManager} | ||
* @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#transactionManager(ObjectProvider) | ||
*/ | ||
@Override | ||
@Bean | ||
public PlatformTransactionManager transactionManager(final ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) { | ||
return new MultiTenantJpaTransactionManager(); | ||
} | ||
|
||
@Override | ||
protected AbstractJpaVendorAdapter createJpaVendorAdapter() { | ||
return new EclipseLinkJpaVendorAdapter() { | ||
|
||
private final HawkbitEclipseLinkJpaDialect jpaDialect = new HawkbitEclipseLinkJpaDialect(); | ||
|
||
@Override | ||
public EclipseLinkJpaDialect getJpaDialect() { | ||
return jpaDialect; | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
protected Map<String, Object> getVendorProperties() { | ||
final Map<String, Object> properties = new HashMap<>(7); | ||
// Turn off dynamic weaving to disable LTW lookup in static weaving mode | ||
properties.put(PersistenceUnitProperties.WEAVING, "false"); | ||
// needed for reports | ||
properties.put(PersistenceUnitProperties.ALLOW_NATIVE_SQL_QUERIES, "true"); | ||
// flyway | ||
properties.put(PersistenceUnitProperties.DDL_GENERATION, "none"); | ||
// Embed into hawkBit logging | ||
properties.put(PersistenceUnitProperties.LOGGING_LOGGER, "JavaLogger"); | ||
// Ensure that we flush only at the end of the transaction | ||
properties.put(PersistenceUnitProperties.PERSISTENCE_CONTEXT_FLUSH_MODE, "COMMIT"); | ||
// Enable batch writing | ||
properties.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC"); | ||
// Batch size | ||
properties.put(PersistenceUnitProperties.BATCH_WRITING_SIZE, "500"); | ||
return properties; | ||
} | ||
} |
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
Oops, something went wrong.