Commit 0b12f889 authored by terrymanu's avatar terrymanu
Browse files

add ListenerRegister

parent 37cff615
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package io.shardingsphere.core.jdbc.adapter;
import com.google.common.base.Preconditions;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.jdbc.unsupported.AbstractUnsupportedOperationDataSource;
import io.shardingsphere.core.listener.JDBCListenerRegister;
import io.shardingsphere.transaction.common.TransactionContextHolder;
import io.shardingsphere.transaction.common.config.JDBCTransactionConfiguration;
import lombok.Getter;
@@ -40,7 +41,7 @@ public abstract class AbstractDataSourceAdapter extends AbstractUnsupportedOpera
    
    static {
        JDBCTransactionConfiguration.getInstance().configTransactionContext(TransactionContextHolder.get().getTransactionType());
        JDBCTransactionConfiguration.getInstance().registerListener();
        JDBCListenerRegister.register();
    }
    
    @Getter
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * 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.
 * </p>
 */

package io.shardingsphere.core.listener;

import io.shardingsphere.transaction.common.listener.TransactionListener;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * Listener register for JDBC.
 *
 * @author zhangliang
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class JDBCListenerRegister {
    
    /**
     * Register all listeners.
     */
    public static void register() {
        new TransactionListener().register();
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import io.shardingsphere.jdbc.orchestration.internal.config.ConfigurationService
import io.shardingsphere.jdbc.orchestration.internal.eventbus.ProxyEventBusInstance;
import io.shardingsphere.proxy.config.RuleRegistry;
import io.shardingsphere.proxy.frontend.ShardingProxy;
import io.shardingsphere.proxy.listener.ProxyListenerRegister;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.yaml.snakeyaml.Yaml;
@@ -61,6 +62,7 @@ public final class Bootstrap {
     * @throws IOException IO exception
     */
    public static void main(final String[] args) throws InterruptedException, IOException {
        ProxyListenerRegister.register();
        OrchestrationProxyConfiguration localConfig = loadLocalConfiguration(new File(Bootstrap.class.getResource(getConfig(args)).getFile()));
        int port = getPort(args);
        if (null == localConfig.getOrchestration()) {
+0 −1
Original line number Diff line number Diff line
@@ -107,7 +107,6 @@ public final class RuleRegistry {
        connectionMode = ConnectionMode.valueOf(shardingProperties.<String>getValue(ShardingPropertiesConstant.CONNECTION_MODE));
        transactionType = TransactionType.valueOf(shardingProperties.<String>getValue(ShardingPropertiesConstant.PROXY_TRANSACTION_MODE));
        transactionManager = ProxyTransactionConfiguration.getInstance().configTransactionContext(transactionType);
        ProxyTransactionConfiguration.getInstance().registerListener();
        acceptorSize = shardingProperties.getValue(ShardingPropertiesConstant.ACCEPTOR_SIZE);
        executorSize = shardingProperties.getValue(ShardingPropertiesConstant.EXECUTOR_SIZE);
        // TODO :jiaqi force off use NIO for backend, this feature is not complete yet
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * 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.
 * </p>
 */

package io.shardingsphere.proxy.listener;

import io.shardingsphere.transaction.common.listener.TransactionListener;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * Listener register for Proxy.
 *
 * @author zhangliang
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ProxyListenerRegister {
    
    /**
     * Register all listeners.
     */
    public static void register() {
        new TransactionListener().register();
    }
}
Loading