terrymanu commented on a change in pull request #15115:
URL: https://github.com/apache/shardingsphere/pull/15115#discussion_r794307018



##########
File path: 
shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/context/TransactionContextsBuilder.java
##########
@@ -61,4 +75,102 @@ private TransactionRule getTransactionRule() {
         Optional<TransactionRule> transactionRule = 
globalRules.stream().filter(each -> each instanceof TransactionRule).map(each 
-> (TransactionRule) each).findFirst();
         return transactionRule.orElseGet(() -> new TransactionRule(new 
DefaultTransactionRuleConfigurationBuilder().build()));
     }
+    
+    private void generateNarayanaConfig(final TransactionRule transactionRule) 
{
+        Map<Object, Object> result;
+        if (transactionRule.getDefaultType() == TransactionType.XA && 
transactionRule.getProviderType().equalsIgnoreCase("Narayana")) {
+            result = generateDefaultNarayanaConfig();
+            if (null != transactionRule.getProps()) {
+                swapJdbcStore(transactionRule, result);
+            }
+        } else {
+            return;
+        }
+        String value = narayanaConfigMapToXml((LinkedHashMap<Object, Object>) 
result);
+        String path = ClassLoader.getSystemResource("").getPath();
+        System.out.println(path);
+        try (BufferedWriter bufferedWriter = 
Files.newBufferedWriter(Paths.get(path, "jbossts-properties.xml"))) {
+            bufferedWriter.write(value);
+            bufferedWriter.flush();
+        } catch (final IOException ex) {
+            log.error("generate narayana config file failed.");
+        }
+    }

Review comment:
       This is for common transaction process, could you try to consider about 
abstract a SPI and move NarayanaConfig into the SPI implementation?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to