Commit 2275bf0a authored by terrymanu's avatar terrymanu
Browse files

for #601, Authority => AuthorityEnvironment, SQLSet => AuthoritySQLSet

parent bb77e806
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -30,10 +30,10 @@ import java.util.LinkedList;
 * @author panjuan
 */
@XmlRootElement(name = "authority")
public final class Authority {
public final class AuthorityEnvironment {
    
    @XmlElement(name = "sqlset")
    private Collection<SQLSet> sqlSets = new LinkedList<>();
    private Collection<AuthoritySQLSet> sqlSets = new LinkedList<>();
    
    /**
     * Get init sqls of this database type.
@@ -43,7 +43,7 @@ public final class Authority {
     */
    public Collection<String> getInitSQLs(final DatabaseType databaseType) {
        Collection<String> result = new LinkedList<>();
        for (SQLSet each : sqlSets) {
        for (AuthoritySQLSet each : sqlSets) {
            result.addAll(each.getCreateUserSQLs(databaseType));
        }
        return result;
@@ -57,7 +57,7 @@ public final class Authority {
     */
    public Collection<String> getCleanSQLs(final DatabaseType databaseType) {
        Collection<String> result = new LinkedList<>();
        for (SQLSet each : sqlSets) {
        for (AuthoritySQLSet each : sqlSets) {
            result.addAll(each.getDropUserSQLs(databaseType));
        }
        return result;
+4 −4
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import java.util.Map;
@Slf4j
public final class AuthorityEnvironmentManager {
    
    private final Authority authority;
    private final AuthorityEnvironment authorityEnvironment;
    
    private final Map<String, DataSource> instanceDataSourceMap;
    
@@ -46,7 +46,7 @@ public final class AuthorityEnvironmentManager {
    
    public AuthorityEnvironmentManager(final String path, final Map<String, DataSource> instanceDataSourceMap, final DatabaseType databaseType) throws IOException, JAXBException {
        try (FileReader reader = new FileReader(path)) {
            authority = (Authority) JAXBContext.newInstance(Authority.class).createUnmarshaller().unmarshal(reader);
            authorityEnvironment = (AuthorityEnvironment) JAXBContext.newInstance(AuthorityEnvironment.class).createUnmarshaller().unmarshal(reader);
        }
        this.instanceDataSourceMap = instanceDataSourceMap;
        this.databaseType = databaseType;
@@ -58,7 +58,7 @@ public final class AuthorityEnvironmentManager {
     * @throws SQLException SQL exception
     */
    public void initialize() throws SQLException {
        Collection<String> initSQLs = authority.getInitSQLs(databaseType);
        Collection<String> initSQLs = authorityEnvironment.getInitSQLs(databaseType);
        if (initSQLs.isEmpty()) {
            return;
        }
@@ -73,7 +73,7 @@ public final class AuthorityEnvironmentManager {
     * @throws SQLException SQL exception
     */
    public void clean() throws SQLException {
        Collection<String> cleanSQLs = authority.getCleanSQLs(databaseType);
        Collection<String> cleanSQLs = authorityEnvironment.getCleanSQLs(databaseType);
        if (cleanSQLs.isEmpty()) {
            return;
        }
+3 −3
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ import java.util.List;
 * @author panjuan
 */
@XmlAccessorType(XmlAccessType.FIELD)
public final class SQLSet {
public final class AuthoritySQLSet {
    
    @XmlAttribute(name = "db-types")
    private String databaseTypes = "H2,MySQL,Oracle,SQLServer,PostgreSQL";
@@ -52,7 +52,7 @@ public final class SQLSet {
    /**
     * Get all create user sqls.
     *
     * @param databaseType database type.
     * @param databaseType database type
     * @return create user sqls
     */
    public Collection<String> getCreateUserSQLs(final DatabaseType databaseType) {
@@ -62,7 +62,7 @@ public final class SQLSet {
    /**
     * Get all drop user sqls.
     *
     * @param databaseType database type.
     * @param databaseType database type
     * @return create user sqls
     */
    public Collection<String> getDropUserSQLs(final DatabaseType databaseType) {