ENTAXY-248 release 1.8.1

This commit is contained in:
2022-02-28 15:20:38 +03:00
parent 4d274c4fcc
commit c826adf1db
1958 changed files with 195926 additions and 10280 deletions

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>initializer</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -16,6 +16,12 @@
<name>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: INITIALIZER :: CONNECTION INITIALIZER</name>
<description>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: INITIALIZER :: CONNECTION INITIALIZER</description>
<properties>
<!-- bundle.osgi.private.pkg>
ru.entaxy.esb.platform.runtime.core.initializer.connection
</bundle.osgi.private.pkg -->
</properties>
<build>
<plugins>
<plugin>
@ -66,7 +72,6 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer</groupId>
@ -74,5 +79,10 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
<artifactId>base-support</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.runtime.core.initializer.api.AbstractInitializer;
import ru.entaxy.esb.platform.runtime.core.initializer.api.InitializerException;
import ru.entaxy.esb.platform.runtime.core.management.connection.util.ConnectionManagerUtil;
import ru.entaxy.platform.base.support.FileUtils;
import java.io.File;
import java.io.IOException;
@ -55,6 +56,7 @@ public class ConnectionInitializer extends AbstractInitializer {
try {
initPlatformConnections(bundleContext);
} catch (Exception e) {
e.printStackTrace();
throw new InitializerException(this, "Can't create platform connections", "", e);
}
}
@ -65,10 +67,43 @@ public class ConnectionInitializer extends AbstractInitializer {
}
private void initPlatformConnections(BundleContext bundleContext) throws Exception {
chackAndPrepareFile(bundleContext);
String json = getJsonAsString(bundleContext);
ConnectionManagerUtil.getService().createAndInstallConnections(json);
FileUtils.FileHelper helper = new FileUtils.FileHelper(JSON_FILE_PATH);
if (!helper.isReadable()) {
// TODO throw exception
log.error("Platform connectons file {} is not readable", JSON_FILE_PATH);
return;
}
if (helper.isChanged()) {
log.info("File is new or changed, install/update connections");
// we need to create/update connections with new timestamp
String oldTimestamp = helper.getTimestamp();
String newTimestamp = helper.updateTimestamp();
// ConnectionManagerUtil.getService().createAndInstallConnections(json);
ConnectionManagerUtil.getService().installUpdateConnections(json, newTimestamp);
helper.updateMd5();
} else {
log.info("File is not changed, install/check connections");
// we need to create if absent connectoins with old timestamp
// ConnectionManagerUtil.getService().createAndInstallConnections(json);
ConnectionManagerUtil.getService().checkInstallConnections(json, helper.getTimestamp());
}
}
private void chackAndPrepareFile(BundleContext context) throws IOException {
File f = new File(JSON_FILE_PATH);
if (!f.exists()) {
FileUtils.string2file(getJsonAsString(context), JSON_FILE_PATH);
}
}
private String getJsonAsString(BundleContext context) throws IOException {
URL jsonUrl;
File f = new File(JSON_FILE_PATH);

View File

@ -18,15 +18,13 @@
"nodeType": "connection",
"uuid": "connection-uuid-2",
"name": "entaxy-broker",
"adapterName": "artemisAdapter",
"adapterName": "artemisAmqpAdapter",
"platform": true,
"pathParameter": "queue:entaxy.default",
"properties": {
"url": "(tcp://localhost:61616)",
"url": "amqp://localhost:5672",
"username": "entaxy",
"password": "entaxy",
"maxConnections": "20",
"maxSessionsPerConnection": "100"
"password": "entaxy"
},
"options": {}
},
@ -34,7 +32,8 @@
"nodeType": "connection",
"uuid": "connection-uuid-3",
"name": "entaxy-db-storage",
"adapterName": "postgresqlAdapter",
"adapterName.pg": "postgresqlAdapter",
"adapterName": "h2Adapter",
"platform": true,
"pathParameter": "entaxy.esb.storage",
"properties": {},
@ -44,7 +43,8 @@
"nodeType": "connection",
"uuid": "connection-uuid-4",
"name": "entaxy-db-cache",
"adapterName": "postgresqlAdapter",
"adapterName.pg": "postgresqlAdapter",
"adapterName": "h2Adapter",
"platform": true,
"pathParameter": "entaxy.esb.cache",
"properties": {},

View File

@ -3,7 +3,7 @@
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>initializer</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer</groupId>
<artifactId>core-initializer</artifactId>
@ -23,7 +23,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Entaxy-Initializer-Class>ru.entaxy.esb.platform.runtime.core.initializer.core.CoreInitializer?id=core&amp;repeat=true&amp;depends-on=datasources</Entaxy-Initializer-Class>
<Entaxy-Initializer-Class>ru.entaxy.esb.platform.runtime.core.initializer.core.CoreInitializer?id=core&amp;repeat=true&amp;depends-on=repositories,datasources</Entaxy-Initializer-Class>
</instructions>
</configuration>
</plugin>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>initializer</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer</groupId>
<artifactId>datasources-initializer</artifactId>
@ -16,6 +16,9 @@
<bundle.osgi.import.pkg>
*
</bundle.osgi.import.pkg>
<!-- bundle.osgi.private.pkg>
ru.entaxy.esb.platform.runtime.core.initializer.datasources
</bundle.osgi.private.pkg -->
</properties>
<build>
@ -26,7 +29,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Entaxy-Initializer-Class>ru.entaxy.esb.platform.runtime.core.initializer.datasources.DataSourcesInitializer?id=datasources&amp;repeat=false&amp;retries=10&amp;interval=2000</Entaxy-Initializer-Class>
<Entaxy-Initializer-Class>ru.entaxy.esb.platform.runtime.core.initializer.datasources.DataSourcesInitializer?id=datasources&amp;repeat=false&amp;retries=10&amp;interval=2000&amp;depends-on=repositories</Entaxy-Initializer-Class>
</instructions>
</configuration>
</plugin>
@ -43,13 +46,23 @@
<configuration>
<artifacts>
<artifact>
<file>src/main/non-packaged-resources/etc/org.ops4j.datasource-entaxy.esb.cache.cfg</file>
<type>cfg</type>
<file>src/main/non-packaged-resources/etc/org.ops4j.datasource-entaxy.esb.cache.cfg.pg</file>
<type>cfg.pg</type>
<classifier>datasource-cache</classifier>
</artifact>
<artifact>
<file>src/main/non-packaged-resources/etc/org.ops4j.datasource-entaxy.esb.storage.cfg</file>
<type>cfg</type>
<file>src/main/non-packaged-resources/etc/org.ops4j.datasource-entaxy.esb.storage.cfg.pg</file>
<type>cfg.pg</type>
<classifier>datasource-storage</classifier>
</artifact>
<artifact>
<file>src/main/non-packaged-resources/etc/org.ops4j.datasource-entaxy.esb.cache.cfg.h2</file>
<type>cfg.h2</type>
<classifier>datasource-cache</classifier>
</artifact>
<artifact>
<file>src/main/non-packaged-resources/etc/org.ops4j.datasource-entaxy.esb.storage.cfg.h2</file>
<type>cfg.h2</type>
<classifier>datasource-storage</classifier>
</artifact>
</artifacts>
@ -57,6 +70,25 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>assebmly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/datasources.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~~~~~~licensing~~~~~~
entaxy-assembly
==========
Copyright (C) 2020 - 2021 EmDev LLC
==========
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
~~~~~~/licensing~~~~~~
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>datasources</id>
<baseDirectory>etc</baseDirectory>
<formats>
<format>zip</format>
<!-- format>tar.gz</format -->
</formats>
<fileSets>
<fileSet>
<directory>src/main/non-packaged-resources/etc</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>

View File

@ -0,0 +1,28 @@
###
# ~~~~~~licensing~~~~~~
# h2-adapter
# ==========
# Copyright (C) 2020 - 2021 EmDev LLC
# ==========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~~~~/licensing~~~~~~
###
dataSourceName=entaxy.esb.cache
osgi.jdbc.driver.name=H2 JDBC Driver
databaseName=${karaf.data}/h2/cache;JMX=TRUE
user=sa
password=
pool=dbcp2
xa=true
jdbc.pool.maxTotal=100

View File

@ -0,0 +1,28 @@
###
# ~~~~~~licensing~~~~~~
# h2-adapter
# ==========
# Copyright (C) 2020 - 2021 EmDev LLC
# ==========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~~~~/licensing~~~~~~
###
dataSourceName=entaxy.esb.storage
osgi.jdbc.driver.name=H2 JDBC Driver
databaseName=${karaf.data}/h2/storage;JMX=TRUE
user=sa
password=
pool=dbcp2
xa=true
jdbc.pool.maxTotal=100

View File

@ -3,7 +3,7 @@
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>initializer</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer</groupId>
<artifactId>init-manager</artifactId>
@ -13,6 +13,7 @@
<properties>
<bundle.osgi.export.pkg>ru.entaxy.esb.platform.runtime.core.initializer.api</bundle.osgi.export.pkg>
<!-- bundle.osgi.private.pkg>ru.entaxy.esb.platform.runtime.core.initializer</bundle.osgi.private.pkg -->
</properties>
<build>

View File

@ -34,6 +34,7 @@ import org.apache.felix.utils.properties.TypedProperties;
import org.apache.karaf.config.core.ConfigRepository;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.wiring.BundleWiring;
@ -82,7 +83,10 @@ public class InitManager {
String className;
boolean repeat;
Bundle bundle;
// Bundle bundle;
long bundleId;
BundleContext bundleContext;
Map<String, InitializerMeta> dependsOn = new HashMap<>();
Map<String, InitializerMeta> dependedBy = new HashMap<>();
@ -153,10 +157,11 @@ public class InitManager {
public void load(InitializerMeta other) {
this.className = other.className;
this.bundle = other.bundle;
this.bundleId = other.bundleId;
this.repeat = other.repeat;
this.retries = other.retries;
this.interval = other.interval;
this.bundleContext = other.bundleContext;
for (InitializerMeta meta: other.dependsOn.values())
this.addDependency(meta);
}
@ -180,6 +185,10 @@ public class InitManager {
meta.dependencyReady(this);
}
public Bundle getBundle() {
return bundleContext.getBundle(bundleId);
}
public boolean execute() {
/**
* instantiate initializer and call "init"
@ -187,6 +196,7 @@ public class InitManager {
*
* @see <code>Initializer</code>
*/
Bundle bundle = getBundle();
BundleWiring wiring = bundle.adapt(BundleWiring.class);
ClassLoader cl = wiring.getClassLoader();
Class<?> clazz;
@ -212,7 +222,7 @@ public class InitManager {
}
public void setCallback() {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
BundleWiring wiring = getBundle().adapt(BundleWiring.class);
ClassLoader cl = wiring.getClassLoader();
Class<?> clazz;
try {
@ -246,6 +256,66 @@ public class InitManager {
};
protected static class Executor implements Runnable {
InitializerMeta meta;
public Executor(InitializerMeta meta) {
this.meta = meta;
}
@Override
public void run() {
/**
* check the initialization status
*/
if (meta.isExecutedBefore()) {
log.info("Initializer with id {} in bundle [{}] {} is already inited", meta.id,
meta.bundleId, meta.getBundle().getSymbolicName());
if (meta.repeat)
log.info("Initializer with id {} is set to be repeated", meta.id);
else {
meta.toBeExecuted = false;
meta.notifyDependent();
return;
}
}
if (!meta.canExecute()) {
String dependsOn = meta.dependsOn.values().stream().map((m)->m.id).collect(Collectors.joining(","));
log.info("Initializer with id {} is waiting for dependencies: {}", meta.id, dependsOn);
/*
* synchronized (this.waiting) { this.waiting.add(meta.id); }
*/
return;
}
int retriesCount = meta.retries;
boolean result = false;
while (!result && (retriesCount > 0)) {
log.info("Executing initializer with id {}: try {} of {}", meta.id, meta.retries-retriesCount+1, meta.retries);
retriesCount--;
result = meta.execute();
if ((retriesCount > 0) && !result)
try {
log.info("Executing initializer with id {}: sleeping for {}", meta.id, meta.interval);
Thread.sleep(meta.interval);
} catch (InterruptedException e) {
log.error("Failed sleep for thread {} on initializer {}", Thread.currentThread().getId(), meta.id);
e.printStackTrace();
}
}
// last try
if (!result)
meta.setCallback();
}
}
protected InitializerMeta getMetaById(String id) {
synchronized (initializers) {
@ -272,7 +342,8 @@ public class InitManager {
protected InitializerMeta createMeta(String initializerMeta, Bundle bundle) {
InitializerMeta meta = new InitializerMeta();
meta.load(initializerMeta);
meta.bundle = bundle;
meta.bundleId = bundle.getBundleId();
meta.bundleContext = bundleContext;
synchronized (this.initializers) {
if (this.initializers.containsKey(meta.id)) {
@ -297,50 +368,10 @@ public class InitManager {
InitializerMeta meta = createMeta(initializerClass, bundle);
/**
* check the initialization status
*/
if (meta.isExecutedBefore()) {
log.info("Initializer with id {} in bundle [{}] {} is already inited", meta.id,
meta.bundle.getBundleId(), meta.bundle.getSymbolicName());
if (meta.repeat)
log.info("Initializer with id {} is set to be repeated", meta.id);
else {
meta.toBeExecuted = false;
meta.notifyDependent();
return;
}
}
Thread thread = new Thread(new Executor(meta));
thread.setContextClassLoader(Thread.currentThread().getContextClassLoader());
thread.start();
if (!meta.canExecute()) {
String dependsOn = meta.dependsOn.values().stream().map((m)->m.id).collect(Collectors.joining(","));
log.info("Initializer with id {} is waiting for dependencies: {}", meta.id, dependsOn);
/*
* synchronized (this.waiting) { this.waiting.add(meta.id); }
*/
return;
}
int retriesCount = meta.retries;
boolean result = false;
while (!result && (retriesCount > 0)) {
log.info("Executing initializer with id {}: try {} of {}", meta.id, meta.retries-retriesCount+1, meta.retries);
retriesCount--;
result = meta.execute();
if ((retriesCount > 0) && !result)
try {
log.info("Executing initializer with id {}: sleeping for {}", meta.id, meta.interval);
Thread.sleep(meta.interval);
} catch (InterruptedException e) {
log.error("Failed sleep for thread {} on initializer {}", Thread.currentThread().getId(), meta.id);
e.printStackTrace();
}
}
// last try
if (!result)
meta.setCallback();
}
/* protected void execute(InitializerMeta meta) {

View File

@ -3,7 +3,7 @@
<parent>
<groupId>ru.entaxy.esb.platform.runtime</groupId>
<artifactId>core</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>initializer</artifactId>

View File

@ -6,7 +6,7 @@
<parent>
<artifactId>storage-initializer</artifactId>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer</groupId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer.storage.initializer</groupId>

View File

@ -26,7 +26,7 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="blob_type" value="bytea" dbms="postgresql"/>
<property name="blob_type" value="blob" dbms="mssql"/>
<property name="blob_type" value="blob"/>
<changeSet id="001001" author="v.s.borodina" context="main">
<createTable tableName="receive_acknowledge">

View File

@ -6,7 +6,7 @@
<parent>
<artifactId>storage-initializer</artifactId>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer</groupId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer.storage.initializer</groupId>

View File

@ -24,31 +24,35 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="text" value="varchar(1024)" dbms="h2"/>
<property name="text" value="text"/>
<changeSet id="001001" author="mmoiseev" context="main">
<createTable tableName="storage">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true"/>
</column>
<column name="uuid" type="text">
<column name="uuid" type="${text}">
<constraints nullable="false"/>
</column>
<column name="name" type="text">
<column name="name" type="${text}">
<constraints nullable="false"/>
</column>
<column name="description" type="text"/>
<column name="description" type="${text}"/>
<column name="create_date" type="timestamp">
<constraints nullable="false"/>
</column>
<column name="edit_date" type="timestamp"/>
<column name="created_by" type="text">
<column name="created_by" type="${text}">
<constraints nullable="false"/>
</column>
<column name="edited_by" type="text"/>
<column name="login" type="text"/>
<column name="password" type="text"/>
<column name="edited_by" type="${text}"/>
<column name="login" type="${text}"/>
<column name="password" type="${text}"/>
<column name="is_active" type="boolean"/>
<column name="bundle_id" type="text"/>
<column name="embedded_route" type="text"/>
<column name="bundle_id" type="${text}"/>
<column name="embedded_route" type="${text}"/>
<column name="version" type="double precision"/>
</createTable>
</changeSet>

View File

@ -24,33 +24,37 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="text" value="varchar(1024)" dbms="h2"/>
<property name="text" value="text"/>
<changeSet id="002001" author="v.s.borodina" context="main">
<createTable tableName="service_registry">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true"/>
</column>
<column name="uuid" type="text">
<column name="uuid" type="${text}">
<constraints nullable="false"/>
</column>
<column name="name" type="text">
<column name="name" type="${text}">
<constraints nullable="false"/>
</column>
<column name="description" type="text"/>
<column name="description" type="${text}"/>
<column name="create_date" type="date">
<constraints nullable="false"/>
</column>
<column name="edit_date" type="date"/>
<column name="created_by" type="text">
<column name="created_by" type="${text}">
<constraints nullable="false"/>
</column>
<column name="edited_by" type="text"/>
<column name="edited_by" type="${text}"/>
<column name="version" type="double precision"/>
<column name="type" type="text"/>
<column name="connectorId" type="text"/>
<column name="descriptionFileUrl" type="text"/>
<column name="endpointName" type="text"/>
<column name="address" type="text"/>
<column name="responseType" type="text"/>
<column name="type" type="${text}"/>
<column name="connectorId" type="${text}"/>
<column name="descriptionFileUrl" type="${text}"/>
<column name="endpointName" type="${text}"/>
<column name="address" type="${text}"/>
<column name="responseType" type="${text}"/>
</createTable>
</changeSet>
<changeSet id="002002" author="v.s.borodina" context="main">
@ -58,7 +62,7 @@
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true"/>
</column>
<column name="serviceName" type="text">
<column name="serviceName" type="${text}">
<constraints nullable="false"/>
</column>
<column name="id_service_registry" type="bigint"/>

View File

@ -24,6 +24,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="text" value="varchar(1024)" dbms="h2"/>
<property name="text" value="text"/>
<changeSet id="003001" author="v.s.borodina" context="main">
<createTable tableName="bundle">
<column name="id" type="bigint" autoIncrement="true">
@ -33,7 +37,7 @@
<column name="type" type="varchar(1024)"/>
<column name="status" type="varchar(1024)"/>
<column name="version" type="double precision"/>
<column name="url" type="text"/>
<column name="url" type="${text}"/>
</createTable>
</changeSet>
</databaseChangeLog>

View File

@ -25,6 +25,9 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="text" value="varchar(1024)" dbms="h2"/>
<property name="text" value="text"/>
<changeSet id="004001" author="mmoiseev" context="main">
<createTable tableName="system">
<column name="id" type="bigint" autoIncrement="true">
@ -36,20 +39,20 @@
<column name="name" type="varchar(100)">
<constraints nullable="false" unique="true"/>
</column>
<column name="description" type="text"/>
<column name="description" type="${text}"/>
<column name="create_date" type="timestamp">
<constraints nullable="false"/>
</column>
<column name="edit_date" type="timestamp"/>
<column name="created_by" type="text">
<column name="created_by" type="${text}">
<constraints nullable="false"/>
</column>
<column name="edited_by" type="text"/>
<column name="edited_by" type="${text}"/>
<column name="version" type="double precision">
<constraints nullable="false"/>
</column>
<column name="type" type="text"/>
<column name="origin" type="text"/>
<column name="type" type="${text}"/>
<column name="origin" type="${text}"/>
<column name="bundle_id" type="bigint"/>
<column name="default_route" type="bool"/>
</createTable>

View File

@ -25,6 +25,9 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="text" value="varchar(1024)" dbms="h2"/>
<property name="text" value="text"/>
<changeSet id="005001" author="skryuchkov" context="main">
<createTable tableName="basic_auth_account">
<column name="id" type="bigint" autoIncrement="true">
@ -33,23 +36,23 @@
<column name="login" type="varchar(100)">
<constraints unique="true" nullable="false"/>
</column>
<column name="password_hash" type="text">
<column name="password_hash" type="${text}">
<constraints nullable="false"/>
</column>
<column name="authorization_header_hash" type="text">
<column name="authorization_header_hash" type="${text}">
<constraints nullable="false"/>
</column>
<column name="description" type="text"/>
<column name="description" type="${text}"/>
<column name="create_date" type="timestamp">
<constraints nullable="false"/>
</column>
<column name="edit_date" type="timestamp"/>
<column name="created_by" type="text">
<column name="created_by" type="${text}">
<constraints nullable="false"/>
</column>
<column name="edited_by" type="text"/>
<column name="encryption_algorithm" type="text"/>
<column name="system_uuid" type="text"/>
<column name="edited_by" type="${text}"/>
<column name="encryption_algorithm" type="${text}"/>
<column name="system_uuid" type="${text}"/>
</createTable>
</changeSet>

View File

@ -24,6 +24,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="text" value="varchar(1024)" dbms="h2"/>
<property name="text" value="text"/>
<changeSet id="006001" author="mmoiseev" context="main">
<createTable tableName="event_topic">
<column name="id" type="bigint" autoIncrement="true">
@ -36,10 +40,10 @@
<constraints nullable="false"/>
</column>
<column name="edit_date" type="timestamp"/>
<column name="created_by" type="text">
<column name="created_by" type="${text}">
<constraints nullable="false"/>
</column>
<column name="edited_by" type="text"/>
<column name="edited_by" type="${text}"/>
</createTable>
</changeSet>
<changeSet id="006002" author="mmoiseev" context="main">

View File

@ -24,6 +24,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="text" value="varchar(1024)" dbms="h2"/>
<property name="text" value="text"/>
<changeSet id="008001" author="v.s.borodina" context="main">
<createTable tableName="connector">
<column name="id" type="bigint" autoIncrement="true">
@ -36,9 +39,9 @@
</column>
<column name="template_name" type="varchar(1024)"/>
<column name="create_date" type="timestamp"/>
<column name="created_by" type="text"/>
<column name="created_by" type="${text}"/>
<column name="edit_date" type="timestamp"/>
<column name="edited_by" type="text"/>
<column name="edited_by" type="${text}"/>
<column name="system_id" type="bigint"/>
<column name="system_group_id" type="bigint"/>
<column name="bundle_id" type="bigint"/>

View File

@ -27,6 +27,7 @@
<property name="curdatetime" value="GETDATE()" dbms="mssql"/>
<property name="curdatetime" value="now()" dbms="postgresql"/>
<property name="curdatetime" value="CURRENT_TIMESTAMP()" dbms="h2"/>
<changeSet id="011001" author="mmoiseev" context="main">
<insert tableName="basic_auth_account">

View File

@ -26,7 +26,10 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<property name="blob_type" value="bytea" dbms="postgresql"/>
<property name="blob_type" value="blob" dbms="mssql"/>
<property name="blob_type" value="blob"/>
<property name="text" value="varchar(1024)" dbms="h2"/>
<property name="text" value="text"/>
<changeSet id="015001" author="v.s.borodina" context="main">
<createTable tableName="resource">
@ -34,9 +37,9 @@
<constraints primaryKey="true"/>
</column>
<column name="edited_date" type="timestamp"/>
<column name="edited_by" type="text"/>
<column name="edited_by" type="${text}"/>
<column name="created_date" type="timestamp"/>
<column name="created_by" type="text"/>
<column name="created_by" type="${text}"/>
<column name="resource_value" type="${blob_type}">
<constraints nullable="false"/>
@ -52,17 +55,17 @@
<column name="name" type="varchar(1024)"/>
<column name="namespace" type="varchar(1024)"/>
<column name="namespace_out" type="varchar(1024)"/>
<column name="description" type="text"/>
<column name="description" type="${text}"/>
<column name="version" type="varchar(30)"/>
<column name="convertor" type="boolean"/>
<column name="created_date" type="timestamp">
<constraints nullable="false"/>
</column>
<column name="created_by" type="text">
<column name="created_by" type="${text}">
<constraints nullable="false"/>
</column>
<column name="edited_date" type="timestamp"/>
<column name="edited_by" type="text"/>
<column name="edited_by" type="${text}"/>
<column name="resource_id" type="bigint">
<constraints foreignKeyName="fk_param_resource_info_on_id" references="resource(id)"/>
</column>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>storage-initializer</artifactId>
<groupId>ru.entaxy.esb.platform.runtime.core.initializer</groupId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,14 +26,6 @@
</properties>
<dependencies>
<!-- dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>

View File

@ -26,16 +26,23 @@ import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.osgi.OSGiResourceAccessor;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.SQLException;
import javax.sql.DataSource;
public class LiquibaseUpdater {
private static final Logger log = LoggerFactory.getLogger(LiquibaseUpdater.class);
private static final String CHANGELOG_PATH = "db/changelog.xml";
public LiquibaseUpdater(DataSource dataSource, BundleContext bundleContext) {
java.sql.Connection connection = null;
try {
java.sql.Connection connection = dataSource.getConnection();
connection = dataSource.getConnection();
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
String config = bundleContext.getBundle().getEntry(CHANGELOG_PATH).getPath();
@ -46,6 +53,13 @@ public class LiquibaseUpdater {
liquibase.update(new Contexts());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
} finally {
if (connection != null)
try {
connection.close();
} catch (SQLException e) {
log.error("LiquibaseUpdater", e);
}
}
}
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>initializer</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>