Skip to content

Commit

Permalink
console must scan&depend core to use @Autowired
Browse files Browse the repository at this point in the history
  • Loading branch information
Pil0tXia committed Mar 1, 2024
1 parent 2bd0807 commit e99e903
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 60 deletions.
30 changes: 17 additions & 13 deletions eventmesh-dashboard-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,27 @@
</properties>

<dependencies>
<!-- EventMesh Dashboard modules -->
<dependency>
<groupId>org.apache.eventmesh.dashboard.common</groupId>
<artifactId>eventmesh-dashboard-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.eventmesh.dashboard.service</groupId>
<artifactId>eventmesh-dashboard-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.eventmesh.dashboard.core</groupId>
<artifactId>eventmesh-dashboard-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

<!-- AOP -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>

<!-- Swagger -->
Expand All @@ -38,18 +54,6 @@
<version>1.7.0</version>
</dependency>

<!-- EventMesh Dashboard modules -->
<dependency>
<groupId>org.apache.eventmesh.dashboard.common</groupId>
<artifactId>eventmesh-dashboard-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.eventmesh.dashboard.service</groupId>
<artifactId>eventmesh-dashboard-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

<!-- Database -->
<dependency>
<groupId>com.alibaba</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
import lombok.extern.slf4j.Slf4j;

@Slf4j
@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"org.apache.eventmesh.dashboard.console", "org.apache.eventmesh.dashboard.core"})
@EnableTransactionManagement
public class EventMeshDashboardApplication {

public static void main(String[] args) {
try {
SpringApplication.run(EventMeshDashboardApplication.class, args);
log.info("{} Successfully booted.", EventMeshDashboardApplication.class.getSimpleName());
log.info("{} Boot Successful!", EventMeshDashboardApplication.class.getSimpleName());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.service.meta.ConnectionService;
import org.apache.eventmesh.dashboard.service.meta.ConnectionCore;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -31,7 +31,7 @@
public class ConnectionController {

@Autowired
ConnectionService connectionService;
ConnectionCore connectionCore;

/**
* Query Connection List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.eventmesh.dashboard.common.dto.Result;
import org.apache.eventmesh.dashboard.common.model.SubscriptionInfo;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionService;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionCore;

import java.util.List;

Expand All @@ -34,7 +34,7 @@
public class SubscriptionController {

@Autowired
SubscriptionService subscriptionService;
SubscriptionCore subscriptionCore;

// the subscription dataId naming pattern of EventMesh clients: ip-protocol
private static final String CLIENT_DATA_ID_PATTERN = "*.*.*.*-*";
Expand All @@ -48,7 +48,7 @@ public class SubscriptionController {
*/
@GetMapping("/subscription")
public Result<String> retrieveSubscription(@RequestParam("dataId") String dataId, @RequestParam("group") String group) {
return Result.success(subscriptionService.retrieveConfig(dataId, group));
return Result.success(subscriptionCore.retrieveConfig(dataId, group));
}

/**
Expand All @@ -66,7 +66,7 @@ public Result<List<SubscriptionInfo>> listSubscriptions(
@RequestParam(name = "size", defaultValue = "10") Integer size,
@RequestParam(name = "dataId", defaultValue = CLIENT_DATA_ID_PATTERN) String dataId,
@RequestParam(name = "group", defaultValue = "") String group) {
return Result.success(subscriptionService.retrieveConfigs(page, size, dataId, group));
return Result.success(subscriptionCore.retrieveConfigs(page, size, dataId, group));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.eventmesh.dashboard.common.model.TopicProperties;
import org.apache.eventmesh.dashboard.console.dto.CreateTopicRequest;
import org.apache.eventmesh.dashboard.console.dto.DeleteTopicRequest;
import org.apache.eventmesh.dashboard.service.store.TopicService;
import org.apache.eventmesh.dashboard.service.store.TopicCore;

import java.util.List;

Expand All @@ -41,7 +41,7 @@
public class TopicController {

@Autowired
TopicService topicService;
TopicCore topicCore;

/**
* TODO Is OPTIONS method and @CrossOrigin necessary?
Expand All @@ -60,23 +60,23 @@ public ResponseEntity<Object> preflight() {
@CrossOrigin
@GetMapping
public Result<List<TopicProperties>> getList() {
List<TopicProperties> topicList = topicService.getTopic();
List<TopicProperties> topicList = topicCore.getTopic();
return Result.success(topicList);
}

@CrossOrigin
@PostMapping
public Result<Object> create(@RequestBody CreateTopicRequest createTopicRequest) {
String topicName = createTopicRequest.getName();
topicService.createTopic(topicName);
topicCore.createTopic(topicName);
return Result.success();
}

@CrossOrigin
@DeleteMapping
public Result<Object> delete(@RequestBody DeleteTopicRequest deleteTopicRequest) {
String topicName = deleteTopicRequest.getName();
topicService.deleteTopic(topicName);
topicCore.deleteTopic(topicName);
return Result.success();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ spring:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/eventmesh_dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
username: ${DB_USERNAME:root}
password: ${DB_PASSWORD:password}

initial-size: 1
max-active: 50
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
package org.apache.eventmesh.dashboard.core.config;

import org.apache.eventmesh.dashboard.common.constant.ConfigConst;
import org.apache.eventmesh.dashboard.core.meta.EtcdConnectionService;
import org.apache.eventmesh.dashboard.core.meta.EtcdSubscriptionService;
import org.apache.eventmesh.dashboard.core.meta.NacosConnectionService;
import org.apache.eventmesh.dashboard.core.meta.NacosSubscriptionService;
import org.apache.eventmesh.dashboard.core.store.RocketmqTopicService;
import org.apache.eventmesh.dashboard.service.meta.ConnectionService;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionService;
import org.apache.eventmesh.dashboard.service.store.TopicService;
import org.apache.eventmesh.dashboard.core.meta.EtcdConnectionCore;
import org.apache.eventmesh.dashboard.core.meta.EtcdSubscriptionCore;
import org.apache.eventmesh.dashboard.core.meta.NacosConnectionCore;
import org.apache.eventmesh.dashboard.core.meta.NacosSubscriptionCore;
import org.apache.eventmesh.dashboard.core.store.RocketmqTopicCore;
import org.apache.eventmesh.dashboard.service.meta.ConnectionCore;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionCore;
import org.apache.eventmesh.dashboard.service.store.TopicCore;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -46,36 +46,36 @@ public BeanTypeConfig(AdminProperties adminProperties) {
}

@Bean
public ConnectionService connectionService() {
public ConnectionCore connectionCore() {
switch (adminProperties.getMeta().getType()) {
case ConfigConst.META_TYPE_NACOS:
return new NacosConnectionService(adminProperties);
return new NacosConnectionCore(adminProperties);
case ConfigConst.META_TYPE_ETCD:
return new EtcdConnectionService();
return new EtcdConnectionCore();
default:
throw new IllegalArgumentException("Unsupported EventMesh Meta type: " + adminProperties.getMeta().getType());
}
}

@Bean
public SubscriptionService subscriptionService() {
public SubscriptionCore subscriptionCore() {
switch (adminProperties.getMeta().getType()) {
case ConfigConst.META_TYPE_NACOS:
return new NacosSubscriptionService(adminProperties);
return new NacosSubscriptionCore(adminProperties);
case ConfigConst.META_TYPE_ETCD:
return new EtcdSubscriptionService();
return new EtcdSubscriptionCore();
default:
throw new IllegalArgumentException("Unsupported EventMesh Meta type: " + adminProperties.getMeta().getType());
}
}

@Bean
public TopicService topicService() {
public TopicCore topicCore() {
switch (adminProperties.getStore().getType()) {
case ConfigConst.STORE_TYPE_STANDALONE:
return null; // TODO StandaloneTopicService
case ConfigConst.STORE_TYPE_ROCKETMQ:
return new RocketmqTopicService(adminProperties);
return new RocketmqTopicCore(adminProperties);
case ConfigConst.STORE_TYPE_KAFKA:
return null; // TODO KafkaTopicService
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

package org.apache.eventmesh.dashboard.core.meta;

import org.apache.eventmesh.dashboard.service.meta.ConnectionService;
import org.apache.eventmesh.dashboard.service.meta.ConnectionCore;

import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class EtcdConnectionService implements ConnectionService {
public class EtcdConnectionCore implements ConnectionCore {

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.eventmesh.dashboard.common.dto.Result;
import org.apache.eventmesh.dashboard.common.model.SubscriptionInfo;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionService;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionCore;

import java.util.List;

Expand All @@ -29,7 +29,7 @@

@Slf4j
@Service
public class EtcdSubscriptionService implements SubscriptionService {
public class EtcdSubscriptionCore implements SubscriptionCore {

@Override
public String retrieveConfig(String dataId, String group) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
package org.apache.eventmesh.dashboard.core.meta;

import org.apache.eventmesh.dashboard.core.config.AdminProperties;
import org.apache.eventmesh.dashboard.service.meta.ConnectionService;
import org.apache.eventmesh.dashboard.service.meta.ConnectionCore;

import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class NacosConnectionService implements ConnectionService {
public class NacosConnectionCore implements ConnectionCore {

public NacosConnectionService(AdminProperties adminProperties) {
public NacosConnectionCore(AdminProperties adminProperties) {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.eventmesh.dashboard.common.exception.MetaException;
import org.apache.eventmesh.dashboard.common.model.SubscriptionInfo;
import org.apache.eventmesh.dashboard.core.config.AdminProperties;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionService;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionCore;

import java.util.ArrayList;
import java.util.Base64;
Expand Down Expand Up @@ -58,7 +58,7 @@

@Slf4j
@Service
public class NacosSubscriptionService implements SubscriptionService {
public class NacosSubscriptionCore implements SubscriptionCore {

AdminProperties adminProperties;

Expand All @@ -68,7 +68,7 @@ public class NacosSubscriptionService implements SubscriptionService {

private static String HTTP_PREFIX = ConfigConst.HTTP_PREFIX;

public NacosSubscriptionService(AdminProperties adminProperties) {
public NacosSubscriptionCore(AdminProperties adminProperties) {
this.adminProperties = adminProperties;

nacosProps.setProperty(PropertyKeyConst.SERVER_ADDR, adminProperties.getMeta().getNacos().getAddr());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.eventmesh.dashboard.common.model.TopicProperties;
import org.apache.eventmesh.dashboard.core.config.AdminProperties;
import org.apache.eventmesh.dashboard.service.store.TopicService;
import org.apache.eventmesh.dashboard.service.store.TopicCore;

import java.util.List;

Expand All @@ -33,11 +33,11 @@

@Slf4j
@Service
public class RocketmqTopicService implements TopicService {
public class RocketmqTopicCore implements TopicCore {

AdminProperties adminProperties;

public RocketmqTopicService(AdminProperties adminProperties) {
public RocketmqTopicCore(AdminProperties adminProperties) {
this.adminProperties = adminProperties;
}

Expand Down
1 change: 1 addition & 0 deletions eventmesh-dashboard-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</properties>

<dependencies>
<!-- EventMesh Dashboard modules -->
<dependency>
<groupId>org.apache.eventmesh.dashboard.common</groupId>
<artifactId>eventmesh-dashboard-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
* reported by the connector.
*/

public interface ConnectionService {
public interface ConnectionCore {

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* reported by the EventMesh runtime.
*/

public interface SubscriptionService {
public interface SubscriptionCore {

String retrieveConfig(String dataId, String group);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Manage topics of eventmesh-storage-plugin (EventMesh Store).
*/

public interface TopicService {
public interface TopicCore {

/**
* TODO rename to getTopics after being implemented
Expand Down

0 comments on commit e99e903

Please sign in to comment.