diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afe8311..afb6c11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,13 +36,13 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - - uses: dorny/paths-filter@v2 - id: filter - with: - filters: '.github/filters.yml' - list-files: json +# - uses: dorny/paths-filter@v2 +# id: filter +# with: +# filters: '.github/filters.yml' +# list-files: json - name: Restore ShenYu Maven Repos - if: steps.filter.outputs.changed == 'true' +# if: steps.filter.outputs.changed == 'true' id: restore-maven-cache uses: actions/cache/restore@v3 with: @@ -51,18 +51,19 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - uses: actions/setup-java@v1 - if: steps.filter.outputs.changed == 'true' +# if: steps.filter.outputs.changed == 'true' with: java-version: ${{ matrix.java }} - name: Build with Maven - if: steps.filter.outputs.changed == 'true' +# if: steps.filter.outputs.changed == 'true' run: ./mvnw -B clean test -Prelease - uses: codecov/codecov-action@v1 with: token: 2760af6a-3405-4882-9e61-04c5176fecfa - if: steps.filter.outputs.changed == 'true' +# if: steps.filter.outputs.changed == 'true' - name: Save ShenYu Maven Repos - if: steps.filter.outputs.changed == 'true' && steps.restore-maven-cache.outputs.cache-hit != 'true' +# if: steps.filter.outputs.changed == 'true' && steps.restore-maven-cache.outputs.cache-hit != 'true' + if: steps.restore-maven-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v3 with: path: ~/.m2/repository diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f4ae8e7..dfdafb0 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -29,7 +29,7 @@ jobs: analyze: name: Analyze runs-on: ubuntu-latest - if: (github.repository == 'apache/shenyu') + if: (github.repository == 'apache/shenyu-client-java') strategy: fail-fast: false diff --git a/pom.xml b/pom.xml index 1d66e25..dfe3c62 100644 --- a/pom.xml +++ b/pom.xml @@ -27,23 +27,9 @@ org.apache.shenyu shenyu-client-java pom - 2.7.1-SNAPSHOT + 2.7.0.1-jdk8-SNAPSHOT - shenyu-java-common - shenyu-client-java-core - shenyu-client-java-http - shenyu-client-java-dubbo - shenyu-client-java-sofa - shenyu-client-java-tars - shenyu-client-java-grpc - shenyu-client-java-motan - shenyu-client-java-websocket - shenyu-client-java-api-docs-annotations - shenyu-client-java-autoconfig - shenyu-register-java-common - shenyu-register-java-client - shenyu-spring-boot-starter-java-client - shenyu-java-examples + shenyu-client @@ -79,13 +65,20 @@ 2.9.0 4.9.3 1.2 - 3.25.5 + 3.21.12 3.2.14 2.7.18 5.7.6 2.1.1 1.7.2 1.2.1 + 5.7.6 + 2.3.1 + 32.0.0-jre + 4.9.3 + 1.78 + 3.5.15 + 4.0.3 @@ -98,6 +91,74 @@ pom import + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + org.ow2.asm + asm-tree + ${asm.version} + + + com.alipay.sofa + sofa-rpc-all + ${sofa.rpc.version} + + + net.jcip + jcip-annotations + + + io.grpc + grpc-core + + + grpc-api + io.grpc + + + grpc-protobuf + io.grpc + + + grpc-stub + io.grpc + + + grpc-netty-shaded + io.grpc + + + + + com.tencent.tars + tars-spring-boot-starter + ${tars.version} + + + org.slf4j + slf4j-api + 1.7.36 + + + org.slf4j + jcl-over-slf4j + 1.7.36 + + + + com.google.guava + guava + ${guava.version} + + + + org.bouncycastle + bcprov-jdk18on + ${bcprov-jdk18on.version} + @@ -122,6 +183,50 @@ spring-test test + + org.junit.jupiter + junit-jupiter + test + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-library + test + + + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.mockito + mockito-inline + ${mockito.version} + test + + + org.awaitility + awaitility + ${awaitility.version} + test + + + javax.xml.bind + jaxb-api + ${jaxb.api.version} + diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/InstanceRegisterListener.java b/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/InstanceRegisterListener.java deleted file mode 100644 index 82701ad..0000000 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/InstanceRegisterListener.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.core.register; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.common.dto.DiscoveryUpstreamData; -import org.apache.shenyu.common.exception.ShenyuException; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.discovery.api.ShenyuDiscoveryService; -import org.apache.shenyu.discovery.api.config.DiscoveryConfig; -import org.apache.shenyu.register.common.config.ShenyuDiscoveryConfig; -import org.apache.shenyu.spi.ExtensionLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.core.Ordered; - -import java.util.Objects; -import java.util.Optional; -import java.util.Properties; - -/** - * InstanceRegisterListener. - *

- * instance register into discovery. - *

- */ -public class InstanceRegisterListener implements ApplicationListener, Ordered { - - private static final Logger LOGGER = LoggerFactory.getLogger(InstanceRegisterListener.class); - - private final DiscoveryUpstreamData currentInstanceUpstream; - - private final DiscoveryConfig discoveryConfig; - - private ShenyuDiscoveryService discoveryService; - - private final String path; - - public InstanceRegisterListener(final DiscoveryUpstreamData discoveryUpstream, final ShenyuDiscoveryConfig shenyuDiscoveryConfig) { - this.currentInstanceUpstream = discoveryUpstream; - this.currentInstanceUpstream.setProps("{\"warmupTime\":\"10\"}"); - this.discoveryConfig = new DiscoveryConfig(); - this.discoveryConfig.setServerList(shenyuDiscoveryConfig.getServerList()); - this.discoveryConfig.setType(shenyuDiscoveryConfig.getType()); - this.discoveryConfig.setProps(Optional.ofNullable(shenyuDiscoveryConfig.getProps()).orElse(new Properties())); - this.discoveryConfig.setName(shenyuDiscoveryConfig.getName()); - this.path = shenyuDiscoveryConfig.getRegisterPath(); - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - LOGGER.info("unregister upstream server by jvm runtime hook"); - if (Objects.nonNull(discoveryService)) { - discoveryService.shutdown(); - } - })); - } - - @Override - public void onApplicationEvent(final ContextRefreshedEvent event) { - try { - if (StringUtils.isBlank(discoveryConfig.getType()) || StringUtils.equalsIgnoreCase(discoveryConfig.getType(), "local")) { - return; - } - this.discoveryService = ExtensionLoader.getExtensionLoader(ShenyuDiscoveryService.class).getJoin(discoveryConfig.getType()); - discoveryService.init(discoveryConfig); - discoveryService.register(path, GsonUtils.getInstance().toJson(currentInstanceUpstream)); - LOGGER.info("shenyu register into ShenyuDiscoveryService {} success", discoveryConfig.getType()); - } catch (Exception e) { - LOGGER.error("shenyu register into ShenyuDiscoveryService {} type find error", discoveryConfig.getType(), e); - throw new ShenyuException(String.format("shenyu register into ShenyuDiscoveryService %s type find error", discoveryConfig.getType())); - } - } - - @Override - public int getOrder() { - return HIGHEST_PRECEDENCE; - } -} diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/common/dto/DiscoveryUpstreamData.java b/shenyu-client-java-core/src/main/java/org/apache/shenyu/common/dto/DiscoveryUpstreamData.java deleted file mode 100644 index 524766e..0000000 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/common/dto/DiscoveryUpstreamData.java +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import com.fasterxml.jackson.annotation.JsonFormat; - -import java.sql.Timestamp; -import java.util.Objects; - -public class DiscoveryUpstreamData { - - /** - * primary key. - */ - private String id; - - /** - * created time. - */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Timestamp dateCreated; - - /** - * updated time. - */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Timestamp dateUpdated; - - - /** - * discoveryHandlerId. - */ - private String discoveryHandlerId; - - /** - * protocol. - */ - private String protocol; - - /** - * url. - */ - private String url; - - /** - * status. - */ - private int status; - - /** - * weight. - */ - private int weight; - - /** - * props. - */ - private String props; - - /** - * namespaceId. - */ - private String namespaceId; - - - /** - * getDiscoveryHandlerId. - * - * @return discoveryHandlerId - */ - public String getDiscoveryHandlerId() { - return discoveryHandlerId; - } - - /** - * setDiscoveryHandlerId. - * - * @param discoveryHandlerId discoveryHandlerId - */ - public void setDiscoveryHandlerId(final String discoveryHandlerId) { - this.discoveryHandlerId = discoveryHandlerId; - } - - /** - * getProtocol. - * - * @return protocol - */ - public String getProtocol() { - return protocol; - } - - /** - * setProtocol. - * - * @param protocol protocol - */ - public void setProtocol(final String protocol) { - this.protocol = protocol; - } - - /** - * getUrl. - * - * @return url - */ - public String getUrl() { - return url; - } - - /** - * setUrl. - * - * @param url url - */ - public void setUrl(final String url) { - this.url = url; - } - - /** - * getStatus. - * - * @return status - */ - public int getStatus() { - return status; - } - - /** - * setStatus. - * - * @param status status - */ - public void setStatus(final int status) { - this.status = status; - } - - /** - * getWeight. - * - * @return weight - */ - public int getWeight() { - return weight; - } - - /** - * setWeight. - * - * @param weight weight - */ - public void setWeight(final int weight) { - this.weight = weight; - } - - /** - * getProps. - * - * @return props - */ - public String getProps() { - return props; - } - - /** - * setProps. - * - * @param props props - */ - public void setProps(final String props) { - this.props = props; - } - - /** - * Gets the value of id. - * - * @return the value of id - */ - public String getId() { - return id; - } - - /** - * Sets the id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Gets the value of dateCreated. - * - * @return the value of dateCreated - */ - public Timestamp getDateCreated() { - return dateCreated; - } - - /** - * Sets the dateCreated. - * - * @param dateCreated dateCreated - */ - public void setDateCreated(final Timestamp dateCreated) { - this.dateCreated = dateCreated; - } - - /** - * Gets the value of dateUpdated. - * - * @return the value of dateUpdated - */ - public Timestamp getDateUpdated() { - return dateUpdated; - } - - /** - * setDateUpdated. - * - * @param dateUpdated dateUpdated - */ - public void setDateUpdated(final Timestamp dateUpdated) { - this.dateUpdated = dateUpdated; - } - - /** - * get namespaceId. - * - * @return namespaceId - */ - public String getNamespaceId() { - return namespaceId; - } - - /** - * set namespaceId. - * - * @param namespaceId namespaceId - */ - public void setNamespaceId(final String namespaceId) { - this.namespaceId = namespaceId; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - DiscoveryUpstreamData that = (DiscoveryUpstreamData) o; - return status == that.status && weight == that.weight && Objects.equals(id, that.id) - && Objects.equals(dateCreated, that.dateCreated) && Objects.equals(dateUpdated, that.dateUpdated) - && Objects.equals(discoveryHandlerId, that.discoveryHandlerId) && Objects.equals(protocol, that.protocol) - && Objects.equals(url, that.url) && Objects.equals(props, that.props) - && Objects.equals(namespaceId, that.namespaceId); - } - - @Override - public int hashCode() { - return Objects.hash(id, dateCreated, dateUpdated, discoveryHandlerId, protocol, url, status, weight, props, namespaceId); - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - - private String id; - - private Timestamp dateCreated; - - private Timestamp dateUpdated; - - private String discoveryHandlerId; - - private String protocol; - - private String url; - - private int status; - - private int weight; - - private String props; - - private String namespaceId; - - private Builder() { - } - - /** - * build new Object. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * build id. - * - * @param id id - * @return this - */ - public Builder id(final String id) { - this.id = id; - return this; - } - - /** - * build dateCreated. - * - * @param dateCreated dateCreated - * @return this - */ - public Builder dateCreated(final Timestamp dateCreated) { - this.dateCreated = dateCreated; - return this; - } - - /** - * build dateUpdated. - * - * @param dateUpdated dateUpdated - * @return this - */ - public Builder dateUpdated(final Timestamp dateUpdated) { - this.dateUpdated = dateUpdated; - return this; - } - - /** - * build discoveryHandlerId. - * - * @param discoveryHandlerId discoveryHandlerId - * @return this - */ - public Builder discoveryHandlerId(final String discoveryHandlerId) { - this.discoveryHandlerId = discoveryHandlerId; - return this; - } - - /** - * build protocol. - * - * @param protocol protocol - * @return this - */ - public Builder protocol(final String protocol) { - this.protocol = protocol; - return this; - } - - /** - * build url. - * - * @param url url - * @return this - */ - public Builder url(final String url) { - this.url = url; - return this; - } - - /** - * build status. - * - * @param status status - * @return this - */ - public Builder status(final int status) { - this.status = status; - return this; - } - - /** - * build weight. - * - * @param weight weight - * @return this - */ - public Builder weight(final int weight) { - this.weight = weight; - return this; - } - - /** - * build props. - * - * @param props props - * @return this - */ - public Builder props(final String props) { - this.props = props; - return this; - } - - /** - * build namespaceId. - * - * @param namespaceId namespaceId - * @return this - */ - public Builder namespaceId(final String namespaceId) { - this.namespaceId = namespaceId; - return this; - } - - /** - * build new Object. - * - * @return DiscoveryUpstreamData - */ - public DiscoveryUpstreamData build() { - DiscoveryUpstreamData discoveryUpstreamData = new DiscoveryUpstreamData(); - discoveryUpstreamData.setId(id); - discoveryUpstreamData.setDateCreated(dateCreated); - discoveryUpstreamData.setDateUpdated(dateUpdated); - discoveryUpstreamData.setDiscoveryHandlerId(discoveryHandlerId); - discoveryUpstreamData.setProtocol(protocol); - discoveryUpstreamData.setUrl(url); - discoveryUpstreamData.setStatus(status); - discoveryUpstreamData.setWeight(weight); - discoveryUpstreamData.setProps(props); - discoveryUpstreamData.setNamespaceId(namespaceId); - return discoveryUpstreamData; - } - } -} diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/pom.xml b/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/pom.xml deleted file mode 100644 index 5541070..0000000 --- a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-client-java-dubbo - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-client-java-apache-dubbo - - - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - - junit - junit - 4.13.2 - test - - - org.apache.shenyu - shenyu-client-java-dubbo-common - ${project.version} - - - org.apache.dubbo - dubbo - ${apache.dubbo.version} - provided - - - org.springframework - spring-beans - provided - - - org.springframework - spring-context - provided - - - org.springframework - spring-core - provided - - - javax.validation - validation-api - 2.0.1.Final - provided - - - org.hibernate - hibernate-validator - 6.2.0.Final - test - - - javax.el - javax.el-api - 3.0.0 - test - - - org.glassfish.web - javax.el - 2.2.6 - provided - - - - diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMapping.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMapping.java deleted file mode 100644 index 5026b6a..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMapping.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.web.bind.annotation.RequestMethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This is a convenience annotation that is equivalent to - * declaring {@code @DeleteMapping} and {@code @ShenyuRequestMapping}. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@ShenyuRequestMapping(method = {RequestMethod.DELETE}) -public @interface ShenyuDeleteMapping { - - /** - * Alias for {@link ShenyuRequestMapping#value}. - * - * @return the string - */ - @AliasFor(attribute = "path") - String[] value() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#path}. - * - * @return the string - */ - @AliasFor(attribute = "value") - String[] path() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#ruleName}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String ruleName() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#desc}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String desc() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#enabled}. - * - * @return the boolean - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - boolean enabled() default true; - - /** - * Alias for {@link ShenyuRequestMapping#params}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] params() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#headers}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] headers() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#consumes}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] consumes() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#produces}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] produces() default {}; -} - - diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMapping.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMapping.java deleted file mode 100644 index 290071a..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMapping.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.web.bind.annotation.RequestMethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This is a convenience annotation that is equivalent to - * declaring {@code @GetMapping} and {@code @ShenyuSpringCloudClient}. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@ShenyuRequestMapping(method = {RequestMethod.GET}) -public @interface ShenyuGetMapping { - - /** - * Alias for {@link ShenyuRequestMapping#value}. - * - * @return the string - */ - @AliasFor(attribute = "path") - String[] value() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#path}. - * - * @return the string - */ - @AliasFor(attribute = "value") - String[] path() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#ruleName}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String ruleName() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#desc}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String desc() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#enabled}. - * - * @return the boolean - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - boolean enabled() default true; - - /** - * Alias for {@link ShenyuRequestMapping#params}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] params() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#headers}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] headers() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#consumes}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] consumes() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#produces}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] produces() default {}; -} - - diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMapping.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMapping.java deleted file mode 100644 index f3079ea..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMapping.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.web.bind.annotation.RequestMethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This is a convenience annotation that is equivalent to - * declaring {@code @PatchMapping} and {@code @ShenyuSpringCloudClient}.. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@ShenyuRequestMapping(method = {RequestMethod.PATCH}) -public @interface ShenyuPatchMapping { - - /** - * Alias for {@link ShenyuRequestMapping#value}. - * - * @return the string - */ - @AliasFor(attribute = "path") - String[] value() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#path}. - * - * @return the string - */ - @AliasFor(attribute = "value") - String[] path() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#ruleName}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String ruleName() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#desc}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String desc() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#enabled}. - * - * @return the boolean - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - boolean enabled() default true; - - /** - * Alias for {@link ShenyuRequestMapping#params}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] params() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#headers}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] headers() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#consumes}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] consumes() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#produces}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] produces() default {}; -} - - diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMapping.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMapping.java deleted file mode 100644 index b55f378..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMapping.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.web.bind.annotation.RequestMethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This is a convenience annotation that is equivalent to - * declaring {@code @PostMapping} and {@code @ShenyuSpringCloudClient}. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@ShenyuRequestMapping(method = {RequestMethod.POST}) -public @interface ShenyuPostMapping { - - /** - * Alias for {@link ShenyuRequestMapping#value}. - * - * @return the string - */ - @AliasFor(attribute = "path") - String[] value() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#path}. - * - * @return the string - */ - @AliasFor(attribute = "value") - String[] path() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#ruleName}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String ruleName() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#desc}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String desc() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#enabled}. - * - * @return the boolean - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - boolean enabled() default true; - - /** - * Alias for {@link ShenyuRequestMapping#params}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] params() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#headers}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] headers() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#consumes}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] consumes() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#produces}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] produces() default {}; -} - - diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMapping.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMapping.java deleted file mode 100644 index 37d5345..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMapping.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.web.bind.annotation.RequestMethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This is a convenience annotation that is equivalent to - * declaring {@code @PutMapping} and {@code @ShenyuRequestMapping}. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@ShenyuRequestMapping(method = {RequestMethod.PUT}) -public @interface ShenyuPutMapping { - - /** - * Alias for {@link ShenyuRequestMapping#value}. - * - * @return the string - */ - @AliasFor(attribute = "path") - String[] value() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#path}. - * - * @return the string - */ - @AliasFor(attribute = "value") - String[] path() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#ruleName}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String ruleName() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#desc}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String desc() default ""; - - /** - * Alias for {@link ShenyuRequestMapping#enabled}. - * - * @return the boolean - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - boolean enabled() default true; - - /** - * Alias for {@link ShenyuRequestMapping#params}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] params() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#headers}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] headers() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#consumes}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] consumes() default {}; - - /** - * Alias for {@link ShenyuRequestMapping#produces}. - * - * @return the string[] - */ - @AliasFor(annotation = ShenyuRequestMapping.class) - String[] produces() default {}; -} - - diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuRequestMapping.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuRequestMapping.java deleted file mode 100644 index d08b034..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuRequestMapping.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This is a convenience annotation that is equivalent to - * declaring {@code @RequestMapping} and {@code @ShenyuSpringCloudClient}. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@RequestMapping -@ShenyuSpringCloudClient -public @interface ShenyuRequestMapping { - - /** - * Alias for {@link RequestMapping#value}, {@link ShenyuSpringCloudClient#value}. - * - * @return the string - */ - @AliasFor(attribute = "path") - String[] value() default ""; - - /** - * Alias for {@link RequestMapping#path}, {@link ShenyuSpringCloudClient#path}. - * - * @return the string - */ - @AliasFor(attribute = "value") - String[] path() default ""; - - /** - * Alias for {@link ShenyuSpringCloudClient#ruleName}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuSpringCloudClient.class) - String ruleName() default ""; - - /** - * Alias for {@link ShenyuSpringCloudClient#desc}. - * - * @return the string - */ - @AliasFor(annotation = ShenyuSpringCloudClient.class) - String desc() default ""; - - /** - * Alias for {@link ShenyuSpringCloudClient#enabled}. - * - * @return the boolean - */ - @AliasFor(annotation = ShenyuSpringCloudClient.class) - boolean enabled() default true; - - /** - * Alias for {@link RequestMapping#params}. - * - * @return the string[] - */ - @AliasFor(annotation = RequestMapping.class) - String[] params() default {}; - - /** - * Alias for {@link RequestMapping#headers}. - * - * @return the string[] - */ - @AliasFor(annotation = RequestMapping.class) - String[] headers() default {}; - - /** - * Alias for {@link RequestMapping#consumes}. - * - * @return the string[] - */ - @AliasFor(annotation = RequestMapping.class) - String[] consumes() default {}; - - /** - * Alias for {@link RequestMapping#produces}. - * - * @return the string[] - */ - @AliasFor(annotation = RequestMapping.class) - String[] produces() default {}; - - /** - * Alias for {@link RequestMapping#method}. - * - * @return the RequestMethod[] - */ - @AliasFor(annotation = RequestMapping.class) - RequestMethod[] method() default {}; -} - - diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuSpringCloudClient.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuSpringCloudClient.java deleted file mode 100644 index ff4b799..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/annotation/ShenyuSpringCloudClient.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.springframework.core.annotation.AliasFor; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * The interface shenyu spring cloud client. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD}) -public @interface ShenyuSpringCloudClient { - - /** - * Path string. - * - * @return the string - */ - @AliasFor(attribute = "path") - String[] value() default ""; - - /** - * Path string. - * - * @return the string - */ - @AliasFor(attribute = "value") - String[] path() default ""; - - /** - * Rule name string. - * - * @return the string - */ - String ruleName() default ""; - - /** - * Desc string. - * - * @return String string - */ - String desc() default ""; - - /** - * Enabled boolean. - * - * @return the boolean - */ - boolean enabled() default true; - - /** - * Register meta data boolean. - * - * @return the boolean - */ - boolean registerMetaData() default true; -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListener.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListener.java deleted file mode 100644 index 4778964..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListener.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.init; - -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.client.core.client.AbstractContextRefreshedEventListener; -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; -import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; -import org.apache.shenyu.client.core.exception.ShenyuClientIllegalArgumentException; -import org.apache.shenyu.client.core.utils.PortUtils; -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.exception.ShenyuException; -import org.apache.shenyu.common.utils.PathUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; -import org.javatuples.Sextet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.core.env.Environment; -import org.springframework.lang.NonNull; -import org.springframework.lang.Nullable; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.util.UriComponentsBuilder; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Properties; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * The type Spring cloud client event listener. - */ -public class SpringCloudClientEventListener extends AbstractContextRefreshedEventListener { - - private static final Logger LOG = LoggerFactory.getLogger(SpringCloudClientEventListener.class); - - private final ShenyuClientRegisterEventPublisher publisher = ShenyuClientRegisterEventPublisher.getInstance(); - - private final Boolean isFull; - - private final Environment env; - - private final String servletContextPath; - - private final boolean addPrefixed; - - private final List> mappingAnnotation = new ArrayList<>(3); - - /** - * Instantiates a new Spring cloud client bean post processor. - * - * @param clientConfig the shenyu client config - * @param shenyuClientRegisterRepository the shenyuClientRegisterRepository - * @param env the env - */ - public SpringCloudClientEventListener(final ShenyuClientConfig clientConfig, - final ShenyuClientRegisterRepository shenyuClientRegisterRepository, - final Environment env) { - super(clientConfig, shenyuClientRegisterRepository); - Properties props = clientConfig.getClient().get(getClientName()).getProps(); - this.env = env; - if (StringUtils.isBlank(getAppName())) { - String errorMsg = "spring cloud param must config the appName"; - LOG.error(errorMsg); - throw new ShenyuClientIllegalArgumentException(errorMsg); - } - this.addPrefixed = Boolean.parseBoolean(props.getProperty(ShenyuClientConstants.ADD_PREFIXED, Boolean.FALSE.toString())); - this.isFull = Boolean.parseBoolean(props.getProperty(ShenyuClientConstants.IS_FULL, Boolean.FALSE.toString())); - this.servletContextPath = env.getProperty("server.servlet.context-path", ""); - mappingAnnotation.add(ShenyuSpringCloudClient.class); - mappingAnnotation.add(RequestMapping.class); - } - - @Override - protected Sextet buildApiDocSextet(final Method method, final Annotation annotation, final Map beans) { - RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); - String produce = requestMapping.produces().length == 0 ? ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE : String.join(",", requestMapping.produces()); - String consume = requestMapping.consumes().length == 0 ? ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE : String.join(",", requestMapping.consumes()); - String[] values = requestMapping.value(); - RequestMethod[] requestMethods = requestMapping.method(); - if (requestMethods.length == 0) { - requestMethods = RequestMethod.values(); - } - List collect = Stream.of(requestMethods).map(item -> ApiHttpMethodEnum.of(item.name())).collect(Collectors.toList()); - ApiHttpMethodEnum[] apiHttpMethodEnums = collect.toArray(new ApiHttpMethodEnum[]{}); - String version = "v0.01"; - return Sextet.with(values, consume, produce, apiHttpMethodEnums, RpcTypeEnum.SPRING_CLOUD, version); - } - - @Override - protected Map getBeans(final ApplicationContext context) { - // Filter out is not controller out - if (Boolean.TRUE.equals(isFull)) { - LOG.info("init spring cloud client success with isFull mode"); - List namespaceIds = super.getNamespace(); - namespaceIds.forEach(namespaceId -> { - getPublisher().publishEvent(MetaDataRegisterDTO.builder() - .contextPath(getContextPath()) - .appName(getAppName()) - .path(UriComponentsBuilder.fromUriString(PathUtils.decoratorPathWithSlash(getContextPath()) + EVERY_PATH).build().encode().toUriString()) - .rpcType(RpcTypeEnum.SPRING_CLOUD.getName()) - .enabled(true) - .ruleName(getContextPath()) - .namespaceId(namespaceId) - .build()); - publisher.publishEvent(buildURIRegisterDTO(context, Collections.emptyMap(), namespaceId)); - }); - return Collections.emptyMap(); - } - return context.getBeansWithAnnotation(Controller.class); - } - - @Override - protected URIRegisterDTO buildURIRegisterDTO(final ApplicationContext context, final Map beans, final String namespaceId) { - try { - return URIRegisterDTO.builder() - .contextPath(getContextPath()) - .appName(getAppName()) - .host(super.getHost()) - .port(Integer.valueOf(getPort())) - .rpcType(RpcTypeEnum.SPRING_CLOUD.getName()) - .eventType(EventType.REGISTER) - .namespaceId(namespaceId) - .build(); - } catch (ShenyuException e) { - throw new ShenyuException(e.getMessage() + "please config ${shenyu.client.http.props.port} in xml/yml !"); - } - } - - @Override - protected String getClientName() { - return RpcTypeEnum.SPRING_CLOUD.getName(); - } - - @Override - protected void handleMethod(final Object bean, final Class clazz, - @Nullable final ShenyuSpringCloudClient beanShenyuClient, final Method method, - final String superPath) { - final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); - ShenyuSpringCloudClient methodShenyuClient = AnnotatedElementUtils.findMergedAnnotation(method, ShenyuSpringCloudClient.class); - methodShenyuClient = Objects.isNull(methodShenyuClient) ? beanShenyuClient : methodShenyuClient; - // the result of ReflectionUtils#getUniqueDeclaredMethods contains methods such as hashCode, wait, toSting - // add Objects.nonNull(requestMapping) to make sure not register wrong method - if (Objects.nonNull(methodShenyuClient) && Objects.nonNull(requestMapping)) { - List namespaceIds = super.getNamespace(); - for (String namespaceId : namespaceIds) { - final MetaDataRegisterDTO metaData = buildMetaDataDTO(bean, methodShenyuClient, - buildApiPath(method, superPath, methodShenyuClient), clazz, method, namespaceId); - getPublisher().publishEvent(metaData); - getMetaDataMap().put(method, metaData); - } - } - } - - @Override - protected String buildApiPath(final Method method, final String superPath, - @NonNull final ShenyuSpringCloudClient methodShenyuClient) { - final String contextPath = getContextPath(); - if (StringUtils.isNotBlank(methodShenyuClient.path()[0])) { - return pathJoin(contextPath, superPath, methodShenyuClient.path()[0]); - } - final String path = getPathByMethod(method); - if (StringUtils.isNotBlank(path)) { - return pathJoin(contextPath, superPath, path); - } - return pathJoin(contextPath, superPath); - } - - private String getPathByMethod(@NonNull final Method method) { - for (Class mapping : mappingAnnotation) { - final Annotation mergedAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, mapping); - final String pathByAnnotation = getPathByAnnotation(mergedAnnotation); - if (StringUtils.isNotBlank(pathByAnnotation)) { - return pathByAnnotation; - } - } - return null; - } - - private String getPathByAnnotation(@Nullable final Annotation annotation) { - if (Objects.isNull(annotation)) { - return null; - } - final Object value = AnnotationUtils.getValue(annotation, "value"); - if (value instanceof String && StringUtils.isNotBlank((String) value)) { - return (String) value; - } - if (value instanceof String[] && ArrayUtils.isNotEmpty((String[]) value) - && StringUtils.isNotBlank(((String[]) value)[0])) { - return ((String[]) value)[0]; - } - return null; - } - - @Override - protected String buildApiSuperPath(final Class clazz, @Nullable final ShenyuSpringCloudClient beanShenyuClient) { - if (Objects.nonNull(beanShenyuClient) && StringUtils.isNotBlank(beanShenyuClient.path()[0])) { - return beanShenyuClient.path()[0]; - } - RequestMapping requestMapping = AnnotationUtils.findAnnotation(clazz, RequestMapping.class); - // Only the first path is supported temporarily - if (Objects.nonNull(requestMapping) && ArrayUtils.isNotEmpty(requestMapping.path()) - && StringUtils.isNotBlank(requestMapping.path()[0])) { - return requestMapping.path()[0]; - } - return ""; - } - - @Override - protected Class getAnnotationType() { - return ShenyuSpringCloudClient.class; - } - - @Override - protected MetaDataRegisterDTO buildMetaDataDTO(final Object bean, - final @NonNull ShenyuSpringCloudClient shenyuClient, - final String path, final Class clazz, final Method method, final String namespaceId) { - return MetaDataRegisterDTO.builder() - .contextPath(StringUtils.defaultIfBlank(getContextPath(), this.servletContextPath)) - .addPrefixed(addPrefixed) - .appName(getAppName()) - .serviceName(clazz.getName()) - .methodName(Optional.ofNullable(method).map(Method::getName).orElse(null)) - .path(path) - .pathDesc(shenyuClient.desc()) - .parameterTypes(Optional.ofNullable(method) - .map(m -> Arrays.stream(m.getParameterTypes()) - .map(Class::getName) - .collect(Collectors.joining(",")) - ).orElse(null)) - .rpcType(RpcTypeEnum.SPRING_CLOUD.getName()) - .enabled(shenyuClient.enabled()) - .ruleName(StringUtils.defaultIfBlank(shenyuClient.ruleName(), path)) - .namespaceId(namespaceId) - .build(); - } - - @Override - public String getAppName() { - return env.getProperty("spring.application.name"); - } - - @Override - public String getPort() { - final int port = Integer.parseInt(Optional.ofNullable(super.getPort()).orElse("-1")); - final int mergedPort = port <= 0 ? PortUtils.findPort(getContext().getAutowireCapableBeanFactory()) : port; - return String.valueOf(mergedPort); - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/proceeor/extractor/RequestMappingProcessor.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/proceeor/extractor/RequestMappingProcessor.java deleted file mode 100644 index ee5e77a..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/proceeor/extractor/RequestMappingProcessor.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.proceeor.extractor; - -import org.apache.commons.lang3.ArrayUtils; -import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.client.core.register.matcher.ApiAnnotationProcessor; -import org.apache.shenyu.client.core.register.matcher.ExtractorProcessor; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.ListUtil; -import org.springframework.lang.NonNull; -import org.springframework.web.bind.annotation.RequestMapping; - -import java.util.List; -import java.util.Objects; - -/** - * RequestMappingProcessor. - */ -public class RequestMappingProcessor implements ApiAnnotationProcessor, ExtractorProcessor { - - @Override - public List supportedClient() { - return ListUtil.of(RpcTypeEnum.SPRING_CLOUD.getName()); - } - - @Override - public void process(final ApiBean api, final RequestMapping annotation) { - - String beanPath = Objects.isNull(annotation) ? "" : getPath(annotation); - // rewrite api path - api.setBeanPath(beanPath); - - if (Objects.nonNull(annotation)) { - api.addProperties("consumes", String.join(",", annotation.consumes())); - api.addProperties("produces", String.join(",", annotation.produces())); - } - - // Get additional values from the annotation. - // TO_DO : Provides support annotation extensions - } - - @Override - public void process(final ApiBean.ApiDefinition definition, final RequestMapping annotation) { - // rewrite api path - definition.setMethodPath(getPath(annotation)); - - definition.addProperties("consumes", String.join(",", annotation.consumes())); - definition.addProperties("produces", String.join(",", annotation.produces())); - - definition.addProperties("desc", definition.getApiMethodName()); - definition.addProperties("rule", ""); - definition.addProperties("value", getPath(annotation)); - // Get additional values from the annotation. - // TO_DO : Provides support annotation extensions - } - - @Override - public Class matchAnnotation() { - return RequestMapping.class; - } - - private String getPath(@NonNull final RequestMapping requestMapping) { - if (ArrayUtils.isEmpty(requestMapping.path())) { - return ""; - } - return requestMapping.path()[0]; - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/proceeor/register/ShenyuSpringCloudClientProcessorImpl.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/proceeor/register/ShenyuSpringCloudClientProcessorImpl.java deleted file mode 100644 index 60fb4db..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/proceeor/register/ShenyuSpringCloudClientProcessorImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.proceeor.register; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.client.core.register.matcher.BaseAnnotationApiProcessor; -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; - -import java.util.Objects; - -/** - * RequestMappingProcessorImpl.
- * About support for {@link ShenyuSpringCloudClient} annotations - * - * @see ShenyuSpringCloudClient - */ -public class ShenyuSpringCloudClientProcessorImpl extends BaseAnnotationApiProcessor { - - @Override - public void process(final ApiBean apiBean, final ShenyuSpringCloudClient annotation) { - apiBean.setBeanPath(annotation.path()[0]); - apiBean.addProperties("desc", annotation.desc()); - if (StringUtils.isNotBlank(apiBean.getPropertiesValue("rule"))) { - apiBean.addProperties("rule", annotation.ruleName()); - } - apiBean.addProperties("value", annotation.value()[0]); - apiBean.addProperties("enabled", Objects.toString(annotation.enabled())); - apiBean.addProperties("registerMetaData", Objects.toString(annotation.registerMetaData())); - if (!annotation.registerMetaData()) { - apiBean.setStatus(ApiBean.Status.CAN_NO_BE_REGISTERED); - } else { - apiBean.setStatus(ApiBean.Status.REGISTRABLE_API); - } - // This annotation is on the support class, and all APIs will be registered - for (ApiBean.ApiDefinition definition : apiBean.getApiDefinitions()) { - definition.setStatus(apiBean.getStatus()); - } - } - - @Override - public void process(final ApiBean.ApiDefinition definition, final ShenyuSpringCloudClient annotation) { - definition.setMethodPath(annotation.path()[0]); - definition.addProperties("desc", annotation.desc()); - definition.addProperties("rule", annotation.ruleName()); - definition.addProperties("value", annotation.value()[0]); - definition.addProperties("enabled", Objects.toString(annotation.enabled())); - definition.addProperties("registerMetaData", Objects.toString(annotation.registerMetaData())); - if (!annotation.registerMetaData()) { - definition.setStatus(ApiBean.Status.CAN_NO_BE_REGISTERED); - } else { - definition.setStatus(ApiBean.Status.REGISTRABLE); - } - } - - @Override - public Class matchAnnotation() { - return ShenyuSpringCloudClient.class; - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiBeansExtractor.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiBeansExtractor.java deleted file mode 100644 index 44cd285..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiBeansExtractor.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.register; - -import org.apache.shenyu.client.core.register.extractor.BaseAnnotationApiBeansExtractor; -import org.apache.shenyu.client.core.register.extractor.RpcApiBeansExtractor; -import org.apache.shenyu.client.springcloud.proceeor.extractor.RequestMappingProcessor; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * Support for Spring Cloud.
- * Should inherit from SpringMvcApiBeansExtractor. - */ -public class SpringCloudApiBeansExtractor extends BaseAnnotationApiBeansExtractor implements RpcApiBeansExtractor { - - public SpringCloudApiBeansExtractor() { - - } - - @Override - public String clientName() { - return RpcTypeEnum.SPRING_CLOUD.getName(); - } - - /** - * default. - * - * @return default - */ - public static SpringCloudApiBeansExtractor buildDefaultSpringCloudApiBeansExtractor() { - final SpringCloudApiBeansExtractor extractor = new SpringCloudApiBeansExtractor(); - - // Annotations supported by class - extractor.addSupportedApiAnnotations(Controller.class); - extractor.addSupportedApiAnnotations(RequestMapping.class); - - // Annotations supported by the method - extractor.addSupportedApiDefinitionAnnotations(RequestMapping.class); - - extractor.addExtractorProcessor(new RequestMappingProcessor()); - return extractor; - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiMetaRegister.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiMetaRegister.java deleted file mode 100644 index 8849ca3..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/main/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiMetaRegister.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.register; - -import com.google.common.collect.Lists; -import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; -import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.matcher.AnnotatedApiDefinitionMatcher; -import org.apache.shenyu.client.core.register.matcher.Matcher; -import org.apache.shenyu.client.core.register.registrar.AbstractApiMetaRegistrar; -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.PathUtils; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.springframework.core.annotation.AnnotationUtils; - -import java.util.List; -import java.util.Objects; - -public class SpringCloudApiMetaRegister extends AbstractApiMetaRegistrar { - - private final Matcher apiDefinitionMatcher = - new AnnotatedApiDefinitionMatcher(ShenyuSpringCloudClient.class) - .or(api -> AnnotationUtils.isAnnotationDeclaredLocally(ShenyuSpringCloudClient.class, api.getBeanClass())); - - private final Boolean addPrefixed; - - private final String appName; - - private final String host; - - private final Integer port; - - private final ClientRegisterConfig clientRegisterConfig; - - public SpringCloudApiMetaRegister(final ShenyuClientRegisterEventPublisher publisher, - final ClientRegisterConfig clientRegisterConfig) { - super(publisher); - - this.addPrefixed = clientRegisterConfig.getAddPrefixed(); - this.appName = clientRegisterConfig.getAppName(); - this.host = clientRegisterConfig.getHost(); - this.port = clientRegisterConfig.getPort(); - this.clientRegisterConfig = clientRegisterConfig; - } - - @Override - protected Boolean preMatch(final ApiBean apiBean) { - - ShenyuSpringCloudClient annotation = apiBean.getAnnotation(ShenyuSpringCloudClient.class); - - return Objects.nonNull(annotation) && annotation.path()[0].endsWith("/**"); - } - - @Override - protected MetaDataRegisterDTO preParse(final ApiBean apiBean) { - - ShenyuSpringCloudClient annotation = apiBean.getAnnotation(ShenyuSpringCloudClient.class); - String apiPath = PathUtils.pathJoin(clientRegisterConfig.getContextPath(), annotation.path()[0]); - - return MetaDataRegisterDTO.builder() - .contextPath(clientRegisterConfig.getContextPath()) - .addPrefixed(addPrefixed) - .appName(appName) - .serviceName(apiBean.getBeanClass().getName()) - .host(host) - .port(port) - .methodName(null) - .path(apiPath) - .pathDesc(annotation.desc()) - .parameterTypes(null) - .rpcType(RpcTypeEnum.SPRING_CLOUD.getName()) - .enabled(annotation.enabled()) - .ruleName(StringUtils.defaultIfBlank(annotation.ruleName(), apiPath)) - .build(); - } - - @Override - protected Boolean match(final ApiBean apiBean) { - ShenyuSpringCloudClient annotation = apiBean.getAnnotation(ShenyuSpringCloudClient.class); - if (Objects.nonNull(annotation)) { - return !annotation.path()[0].endsWith("/**"); - } - return true; - } - - @Override - protected Boolean match(final ApiBean.ApiDefinition apiDefinition) { - return apiDefinitionMatcher.match(apiDefinition); - } - - @Override - protected List parse(final ApiBean.ApiDefinition apiDefinition) { - - ShenyuSpringCloudClient methodAnnotation = apiDefinition.getAnnotation(ShenyuSpringCloudClient.class); - - String methodPath = Objects.isNull(methodAnnotation) ? StringUtils.EMPTY : methodAnnotation.path()[0]; - - if (StringUtils.isEmpty(methodPath)) { - methodPath = apiDefinition.getMethodPath(); - } - - ShenyuSpringCloudClient classAnnotation = apiDefinition.getApiBean() - .getAnnotation(ShenyuSpringCloudClient.class); - - String beanPath = Objects.isNull(classAnnotation) || StringUtils.isBlank(classAnnotation.path()[0]) - ? apiDefinition.getBeanPath() : classAnnotation.path()[0]; - - String apiPath = PathUtils.pathJoin(clientRegisterConfig.getContextPath(), beanPath, methodPath); - - String pathDesc = Objects.isNull(methodAnnotation) ? classAnnotation.desc() : methodAnnotation.desc(); - - boolean enabled = (Objects.isNull(classAnnotation) || classAnnotation.enabled()) - && (Objects.isNull(methodAnnotation) || methodAnnotation.enabled()); - - String ruleName = Objects.isNull(methodAnnotation) || StringUtils.isEmpty(methodAnnotation.ruleName()) - ? apiPath : methodAnnotation.ruleName(); - - return Lists.newArrayList(MetaDataRegisterDTO.builder() - .contextPath(clientRegisterConfig.getContextPath()) - .addPrefixed(addPrefixed) - .appName(appName) - .host(host) - .port(port) - .serviceName(apiDefinition.getBeanClass().getName()) - .methodName(apiDefinition.getApiMethodName()) - .path(apiPath) - .pathDesc(pathDesc) - .parameterTypes(apiDefinition.getParameterTypes()) - .rpcType(RpcTypeEnum.SPRING_CLOUD.getName()) - .enabled(enabled) - .ruleName(ruleName) - .build()); - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMappingTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMappingTest.java deleted file mode 100644 index e1e69d4..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMappingTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.PathVariable; - -import java.lang.reflect.Method; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -/** - * Test for {@link ShenyuDeleteMapping}. - */ -@ExtendWith(MockitoExtension.class) -@TestMethodOrder(MethodOrderer.Alphanumeric.class) -public class ShenyuDeleteMappingTest { - - private final SpringCloudClientTestBean springCloudClientTestBean = new SpringCloudClientTestBean(); - - @Test - public void testWithShenyuRequestMappingAnnotation() { - Class clazz = springCloudClientTestBean.getClass(); - final Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz); - for (Method method : methods) { - if (!Objects.equals(method.getName(), "delete")) { - continue; - } - final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); - assertNotNull(requestMapping); - assertEquals(requestMapping.method()[0], RequestMethod.DELETE); - assertEquals(requestMapping.value()[0], "/{id}"); - assertEquals(requestMapping.path()[0], "/{id}"); - ShenyuSpringCloudClient shenyuSpringCloudClient = AnnotatedElementUtils.findMergedAnnotation(method, ShenyuSpringCloudClient.class); - assertNotNull(shenyuSpringCloudClient); - assertEquals(shenyuSpringCloudClient.value()[0], "/{id}"); - assertEquals(shenyuSpringCloudClient.path()[0], "/{id}"); - assertEquals(shenyuSpringCloudClient.ruleName(), "divide"); - assertFalse(shenyuSpringCloudClient.enabled()); - assertEquals(shenyuSpringCloudClient.desc(), "it`s test."); - } - } - - static class SpringCloudClientTestBean { - - @ShenyuDeleteMapping(value = "/{id}", ruleName = "divide", enabled = false, desc = "it`s test.") - public String delete(@PathVariable final String id) { - return id; - } - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMappingTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMappingTest.java deleted file mode 100644 index 8b8ae71..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMappingTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.PathVariable; - -import java.lang.reflect.Method; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -/** - * Test for {@link ShenyuGetMapping}. - */ -@ExtendWith(MockitoExtension.class) -@TestMethodOrder(MethodOrderer.Alphanumeric.class) -public class ShenyuGetMappingTest { - - private final SpringCloudClientTestBean springCloudClientTestBean = new SpringCloudClientTestBean(); - - @Test - public void testWithShenyuRequestMappingAnnotation() { - Class clazz = springCloudClientTestBean.getClass(); - final Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz); - for (Method method : methods) { - if (!Objects.equals(method.getName(), "get")) { - continue; - } - final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); - assertNotNull(requestMapping); - assertEquals(requestMapping.method()[0], RequestMethod.GET); - assertEquals(requestMapping.value()[0], "/{id}"); - assertEquals(requestMapping.path()[0], "/{id}"); - ShenyuSpringCloudClient shenyuSpringCloudClient = AnnotatedElementUtils.findMergedAnnotation(method, ShenyuSpringCloudClient.class); - assertNotNull(shenyuSpringCloudClient); - assertEquals(shenyuSpringCloudClient.value()[0], "/{id}"); - assertEquals(shenyuSpringCloudClient.path()[0], "/{id}"); - assertEquals(shenyuSpringCloudClient.ruleName(), "divide"); - assertFalse(shenyuSpringCloudClient.enabled()); - assertEquals(shenyuSpringCloudClient.desc(), "it`s test."); - } - } - - static class SpringCloudClientTestBean { - - @ShenyuGetMapping(value = "/{id}", ruleName = "divide", enabled = false, desc = "it`s test.") - public String get(@PathVariable final String id) { - return id; - } - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMappingTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMappingTest.java deleted file mode 100644 index 22d38db..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMappingTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestBody; - -import java.lang.reflect.Method; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -/** - * Test for {@link ShenyuPatchMapping}. - */ -@ExtendWith(MockitoExtension.class) -@TestMethodOrder(MethodOrderer.Alphanumeric.class) -public class ShenyuPatchMappingTest { - - private final SpringCloudClientTestBean springCloudClientTestBean = new SpringCloudClientTestBean(); - - @Test - public void testWithShenyuRequestMappingAnnotation() { - Class clazz = springCloudClientTestBean.getClass(); - final Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz); - for (Method method : methods) { - if (!Objects.equals(method.getName(), "patch")) { - continue; - } - final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); - assertNotNull(requestMapping); - assertEquals(requestMapping.method()[0], RequestMethod.PATCH); - assertEquals(requestMapping.value()[0], "/patch"); - assertEquals(requestMapping.path()[0], "/patch"); - ShenyuSpringCloudClient shenyuSpringCloudClient = AnnotatedElementUtils.findMergedAnnotation(method, ShenyuSpringCloudClient.class); - assertNotNull(shenyuSpringCloudClient); - assertEquals(shenyuSpringCloudClient.value()[0], "/patch"); - assertEquals(shenyuSpringCloudClient.path()[0], "/patch"); - assertEquals(shenyuSpringCloudClient.ruleName(), "divide"); - assertFalse(shenyuSpringCloudClient.enabled()); - assertEquals(shenyuSpringCloudClient.desc(), "it`s test."); - } - } - - static class SpringCloudClientTestBean { - - @ShenyuPatchMapping(value = "/patch", ruleName = "divide", enabled = false, desc = "it`s test.") - public String patch(@RequestBody final String operator) { - return operator; - } - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMappingTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMappingTest.java deleted file mode 100644 index 116d81b..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMappingTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestBody; - -import java.lang.reflect.Method; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -/** - * Test for {@link ShenyuPostMapping}. - */ -@ExtendWith(MockitoExtension.class) -@TestMethodOrder(MethodOrderer.Alphanumeric.class) -public class ShenyuPostMappingTest { - - private final SpringCloudClientTestBean springCloudClientTestBean = new SpringCloudClientTestBean(); - - @Test - public void testWithShenyuRequestMappingAnnotation() { - Class clazz = springCloudClientTestBean.getClass(); - final Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz); - for (Method method : methods) { - if (!Objects.equals(method.getName(), "save")) { - continue; - } - final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); - assertNotNull(requestMapping); - assertEquals(requestMapping.method()[0], RequestMethod.POST); - assertEquals(requestMapping.value()[0], "/save"); - assertEquals(requestMapping.path()[0], "/save"); - ShenyuSpringCloudClient shenyuSpringCloudClient = AnnotatedElementUtils.findMergedAnnotation(method, ShenyuSpringCloudClient.class); - assertNotNull(shenyuSpringCloudClient); - assertEquals(shenyuSpringCloudClient.value()[0], "/save"); - assertEquals(shenyuSpringCloudClient.path()[0], "/save"); - assertEquals(shenyuSpringCloudClient.ruleName(), "divide"); - assertFalse(shenyuSpringCloudClient.enabled()); - assertEquals(shenyuSpringCloudClient.desc(), "it`s test."); - } - } - - static class SpringCloudClientTestBean { - - @ShenyuPostMapping(value = "/save", ruleName = "divide", enabled = false, desc = "it`s test.") - public String save(@RequestBody final String body) { - return body; - } - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMappingTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMappingTest.java deleted file mode 100644 index 369c143..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMappingTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestBody; - -import java.lang.reflect.Method; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -/** - * Test for {@link ShenyuPutMapping}. - */ -@ExtendWith(MockitoExtension.class) -@TestMethodOrder(MethodOrderer.Alphanumeric.class) -public class ShenyuPutMappingTest { - - private final SpringCloudClientTestBean springCloudClientTestBean = new SpringCloudClientTestBean(); - - @Test - public void testWithShenyuRequestMappingAnnotation() { - Class clazz = springCloudClientTestBean.getClass(); - final Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(clazz); - for (Method method : methods) { - if (!Objects.equals(method.getName(), "put")) { - continue; - } - final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); - assertNotNull(requestMapping); - assertEquals(requestMapping.method()[0], RequestMethod.PUT); - assertEquals(requestMapping.value()[0], "/put"); - assertEquals(requestMapping.path()[0], "/put"); - ShenyuSpringCloudClient shenyuSpringCloudClient = AnnotatedElementUtils.findMergedAnnotation(method, ShenyuSpringCloudClient.class); - assertNotNull(shenyuSpringCloudClient); - assertEquals(shenyuSpringCloudClient.value()[0], "/put"); - assertEquals(shenyuSpringCloudClient.path()[0], "/put"); - assertEquals(shenyuSpringCloudClient.ruleName(), "divide"); - assertFalse(shenyuSpringCloudClient.enabled()); - assertEquals(shenyuSpringCloudClient.desc(), "it`s test."); - } - } - - static class SpringCloudClientTestBean { - - @ShenyuPutMapping(value = "/put", ruleName = "divide", enabled = false, desc = "it`s test.") - public String put(@RequestBody final String body) { - return body; - } - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuRequestMappingTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuRequestMappingTest.java deleted file mode 100644 index 71e0dbf..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuRequestMappingTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.annotation; - -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -/** - * Test for {@link ShenyuRequestMapping}. - */ -@ExtendWith(MockitoExtension.class) -@TestMethodOrder(MethodOrderer.Alphanumeric.class) -public class ShenyuRequestMappingTest { - - private final SpringCloudClientTestBean springCloudClientTestBean = new SpringCloudClientTestBean(); - - @Test - public void testWithShenyuRequestMappingAnnotation() { - Class clazz = springCloudClientTestBean.getClass(); - final ShenyuSpringCloudClient shenyuSpringCloudClient = AnnotatedElementUtils.findMergedAnnotation(clazz, ShenyuSpringCloudClient.class); - assertNotNull(shenyuSpringCloudClient); - assertEquals(shenyuSpringCloudClient.value()[0], "/order"); - assertEquals(shenyuSpringCloudClient.path()[0], "/order"); - assertEquals(shenyuSpringCloudClient.ruleName(), "divide"); - assertFalse(shenyuSpringCloudClient.enabled()); - assertEquals(shenyuSpringCloudClient.desc(), "it`s test."); - final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(clazz, RequestMapping.class); - assertNotNull(requestMapping); - assertEquals(requestMapping.value()[0], "/order"); - assertEquals(requestMapping.path()[0], "/order"); - } - - @RestController - @ShenyuRequestMapping(value = "/order", ruleName = "divide", enabled = false, desc = "it`s test.") - static class SpringCloudClientTestBean { - - public String hello() { - return "hello"; - } - } -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListenerTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListenerTest.java deleted file mode 100644 index 0afa0f4..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListenerTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.init; - -import org.apache.shenyu.client.core.exception.ShenyuClientIllegalArgumentException; -import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepositoryFactory; -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig.ClientPropertiesConfig; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; -import org.junit.Assert; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.MockedStatic; -import org.mockito.junit.jupiter.MockitoExtension; -import org.mockito.stubbing.Answer; -import org.springframework.context.ApplicationContext; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.core.env.Environment; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Properties; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Test for {@link SpringCloudClientEventListener}. - */ -@ExtendWith(MockitoExtension.class) -@TestMethodOrder(MethodOrderer.Alphanumeric.class) -public final class SpringCloudClientEventListenerTest { - - @Mock - private static Environment env; - - private final MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - - private final SpringCloudClientTestBean springCloudClientTestBean = new SpringCloudClientTestBean(); - - @Mock - private ApplicationContext applicationContext; - - private ContextRefreshedEvent contextRefreshedEvent; - - @BeforeEach - public void beforeEach() { - when(env.getProperty("spring.application.name")).thenReturn("spring-cloud-test"); - } - - private void init() { - Map results = new LinkedHashMap<>(); - results.put("springCloudClientTestBean", springCloudClientTestBean); - when(applicationContext.getBeansWithAnnotation(any())).thenReturn(results); - contextRefreshedEvent = new ContextRefreshedEvent(applicationContext); - } - - @Test - public void testShenyuBeanProcess() { - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.of("token")); - // config with full - SpringCloudClientEventListener springCloudClientEventListener = buildSpringCloudClientEventListener(true); - springCloudClientEventListener.onApplicationEvent(new ContextRefreshedEvent(applicationContext)); - verify(applicationContext, never()).getBeansWithAnnotation(any()); - registerUtilsMockedStatic.close(); - } - - @Test - public void testNormalBeanProcess() { - init(); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.of("token")); - SpringCloudClientEventListener springCloudClientEventListener = buildSpringCloudClientEventListener(false); - springCloudClientEventListener.onApplicationEvent(contextRefreshedEvent); - verify(applicationContext, times(2)).getBeansWithAnnotation(any()); - registerUtilsMockedStatic.close(); - } - - @Test - public void testWithShenyuClientAnnotation() { - init(); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.of("token")); - registerUtilsMockedStatic.when(() -> RegisterUtils.doRegister(any(), any(), any())) - .thenAnswer((Answer) invocation -> null); - SpringCloudClientEventListener springCloudClientEventListener = buildSpringCloudClientEventListener(false); - springCloudClientEventListener.onApplicationEvent(contextRefreshedEvent); - verify(applicationContext, times(2)).getBeansWithAnnotation(any()); - registerUtilsMockedStatic.close(); - } - - private SpringCloudClientEventListener buildSpringCloudClientEventListener(final boolean full) { - Properties properties = new Properties(); - properties.setProperty("contextPath", "/test"); - properties.setProperty("isFull", String.valueOf(full)); - properties.setProperty("ip", "127.0.0.1"); - properties.setProperty("port", "8081"); - properties.setProperty("username", "admin"); - properties.setProperty("password", "123456"); - ClientPropertiesConfig config = new ClientPropertiesConfig(); - config.setProps(properties); - ShenyuRegisterCenterConfig mockRegisterCenter = new ShenyuRegisterCenterConfig(); - mockRegisterCenter.setServerLists("http://127.0.0.1:8080"); - mockRegisterCenter.setRegisterType("http"); - mockRegisterCenter.setProps(properties); - ShenyuClientConfig clientConfig = new ShenyuClientConfig(); - Map client = new LinkedHashMap<>(); - client.put(RpcTypeEnum.SPRING_CLOUD.getName(), config); - clientConfig.setClient(client); - // hit error - when(env.getProperty("spring.application.name")).thenReturn(""); - Assert.assertThrows(ShenyuClientIllegalArgumentException.class, - () -> new SpringCloudClientEventListener(clientConfig, ShenyuClientRegisterRepositoryFactory.newInstance(mockRegisterCenter), env)); - when(env.getProperty("spring.application.name")).thenReturn("spring-cloud-test"); - return new SpringCloudClientEventListener(clientConfig, ShenyuClientRegisterRepositoryFactory.newInstance(mockRegisterCenter), env); - } - - @RestController - @RequestMapping("/order") - static class SpringCloudClientTestBean { - @PostMapping("/save") - @ShenyuSpringCloudClient(path = "/order/save") - public String save(@RequestBody final String body) { - return body; - } - - @PostMapping("/update") - @ShenyuSpringCloudClient(path = "") - public String update(@RequestBody final String body) { - return body; - } - } - -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiBeansExtractorTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiBeansExtractorTest.java deleted file mode 100644 index c38476b..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiBeansExtractorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.register; - -import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.client.core.register.extractor.ApiBeansExtractor; -import org.junit.jupiter.api.Test; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.stereotype.Controller; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.RequestMapping; - -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -public class SpringCloudApiBeansExtractorTest { - - private final ApiBeansExtractor extractor = SpringCloudApiBeansExtractor.buildDefaultSpringCloudApiBeansExtractor(); - - @Test - public void testExtractBeans() throws NoSuchMethodException { - - GenericApplicationContext applicationContext = new GenericApplicationContext(); - applicationContext.refresh(); - applicationContext.registerBean(ExtractorTestBean.class); - applicationContext.registerBean(ExtractorTestWithoutControllerBean.class); - - List apiBeans = extractor.extract(applicationContext); - - assertThat(apiBeans.size(), is(1)); - ApiBean apiBean = apiBeans.get(0); - assertThat(apiBean.getBeanClass(), is(ExtractorTestBean.class)); - assertThat(apiBean.getBeanPath(), is("/testBean")); - assertThat(apiBean.getApiDefinitions().size(), is(1)); - - ApiBean.ApiDefinition apiDefinition = apiBean.getApiDefinitions().get(0); - assertThat(apiDefinition.getApiMethod(), is(ExtractorTestBean.class.getMethod("test"))); - assertThat(apiDefinition.getMethodPath(), is("/testMethod")); - } - - @Controller - @RequestMapping("/testBean") - private static class ExtractorTestBean { - @RequestMapping("/testMethod") - public String test() { - return ""; - } - - public String testWithoutRequestMapping() { - return ""; - } - - } - - @Service - private static class ExtractorTestWithoutControllerBean { - } - -} diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiMetaRegisterTest.java b/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiMetaRegisterTest.java deleted file mode 100644 index ee6c852..0000000 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/src/test/java/org/apache/shenyu/client/springcloud/register/SpringCloudApiMetaRegisterTest.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.client.springcloud.register; - -import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; -import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.type.DataTypeParent; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.HashMap; -import java.util.Map; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.nullValue; - -public class SpringCloudApiMetaRegisterTest { - - private TestShenyuClientRegisterEventPublisher testShenyuClientRegisterEventPublisher; - - private SpringCloudApiMetaRegister springCloudApiMetaRegister; - - private final SpringCloudApiBeansExtractor beansExtractor = SpringCloudApiBeansExtractor.buildDefaultSpringCloudApiBeansExtractor(); - - @BeforeEach - public void init() { - - testShenyuClientRegisterEventPublisher = new TestShenyuClientRegisterEventPublisher(); - - springCloudApiMetaRegister = new SpringCloudApiMetaRegister( - testShenyuClientRegisterEventPublisher, new TestClientRegisterConfig()); - } - - @Test - void testAnnotatedClass() throws Exception { - - ApiBean apiBean = createSimpleApiBean(TestApiBeanAnnotatedClass.class); - - springCloudApiMetaRegister.register(apiBean); - - assertThat(testShenyuClientRegisterEventPublisher.metaData.getPath(), - equalTo("/testContext/testClass/testMethod")); - } - - @Test - void testAnnotatedMethod() throws Exception { - - ApiBean apiBean = createSimpleApiBean(TestApiBeanAnnotatedMethod.class); - - springCloudApiMetaRegister.register(apiBean); - - assertThat(testShenyuClientRegisterEventPublisher.metaData.getPath(), - equalTo("/testContext/testClass/testMethod")); - } - - @Test - void testAnnotatedMethodAndClass() throws Exception { - - ApiBean apiBean = createSimpleApiBean(TestApiBeanAnnotatedMethodAndClass.class); - - springCloudApiMetaRegister.register(apiBean); - - assertThat(testShenyuClientRegisterEventPublisher.metaData.getPath(), - equalTo("/testContext/testClass/testMethod")); - } - - @Test - void testApiBeanNoAnnotated() throws Exception { - - ApiBean apiBean = createSimpleApiBean(TestApiBeanNoAnnotated.class); - - springCloudApiMetaRegister.register(apiBean); - - assertThat(testShenyuClientRegisterEventPublisher.metaData, nullValue()); - } - - @Test - void testPreApiBean() throws Exception { - - ApiBean apiBean = createSimpleApiBean(TestPreApiBean.class); - - springCloudApiMetaRegister.register(apiBean); - - assertThat(testShenyuClientRegisterEventPublisher.metaData.getPath(), - equalTo("/testContext/testClass/**")); - - } - - @Test - void testApiBeanDifferentPath() throws Exception { - - ApiBean apiBean = createSimpleApiBean(TestApiBeanDifferentPath.class); - - springCloudApiMetaRegister.register(apiBean); - - assertThat(testShenyuClientRegisterEventPublisher.metaData.getPath(), - equalTo("/testContext/testClassPath/testMethodPath")); - - } - - private ApiBean createSimpleApiBean(final Class beanClass) throws Exception { - final Map objectHashMap = new HashMap<>(); - objectHashMap.put(beanClass.getName(), beanClass.getDeclaredConstructor().newInstance()); - return beansExtractor.extract(null, objectHashMap).get(0); - } - - @ShenyuSpringCloudClient - @RestController - @RequestMapping("/testClass") - static class TestApiBeanAnnotatedClass { - @RequestMapping("/testMethod") - public String testMethod() { - return ""; - } - } - - @RestController - @RequestMapping("/testClass") - static class TestApiBeanAnnotatedMethod { - - @RequestMapping("/testMethod") - @ShenyuSpringCloudClient("/testMethod") - public String testMethod() { - return ""; - } - } - - @ShenyuSpringCloudClient - @RestController - @RequestMapping("/testClass") - static class TestApiBeanAnnotatedMethodAndClass { - - @RequestMapping("/testMethod") - @ShenyuSpringCloudClient("/testMethod") - public String testMethod() { - return ""; - } - } - - @RestController - @ShenyuSpringCloudClient("/testClass/**") - @RequestMapping("/testClass") - static class TestPreApiBean { - - @RequestMapping("/testMethod") - @ShenyuSpringCloudClient - public String testMethod() { - return ""; - } - } - - @RestController - @RequestMapping("/testClass") - static class TestApiBeanNoAnnotated { - - @RequestMapping("/testMethod") - public String testMethod() { - return ""; - } - } - - @RestController - @ShenyuSpringCloudClient("/testClassPath") - @RequestMapping("/testClass") - static class TestApiBeanDifferentPath { - - @RequestMapping("/testMethod") - @ShenyuSpringCloudClient("/testMethodPath") - public String testMethod() { - return ""; - } - } - - static class TestShenyuClientRegisterEventPublisher extends ShenyuClientRegisterEventPublisher { - - private MetaDataRegisterDTO metaData; - - @Override - public void start(final ShenyuClientRegisterRepository shenyuClientRegisterRepository) { - } - - @Override - public void publishEvent(final DataTypeParent data) { - this.metaData = (MetaDataRegisterDTO) data; - } - } - - static class TestClientRegisterConfig implements ClientRegisterConfig { - @Override - public Integer getPort() { - return -1; - } - - @Override - public String getHost() { - return "127.0.0.1"; - } - - @Override - public String getAppName() { - return "test"; - } - - @Override - public String getContextPath() { - return "testContext"; - } - - @Override - public String getIpAndPort() { - return "127.0.0.1:80"; - } - - @Override - public Boolean getAddPrefixed() { - return false; - } - - @Override - public RpcTypeEnum getRpcTypeEnum() { - return RpcTypeEnum.HTTP; - } - } - -} diff --git a/shenyu-client-java-motan/pom.xml b/shenyu-client-java-motan/pom.xml deleted file mode 100644 index b604c14..0000000 --- a/shenyu-client-java-motan/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT - - 4.0.0 - - shenyu-client-java-motan - - - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - - junit - junit - 4.13.2 - test - - - org.apache.shenyu - shenyu-client-java-core - ${project.version} - - - org.springframework - spring-beans - provided - - - org.springframework - spring-context - provided - - - org.springframework - spring-core - provided - - - com.weibo - motan-springsupport - ${motan.version} - provided - - - - diff --git a/shenyu-client-java-sofa/pom.xml b/shenyu-client-java-sofa/pom.xml deleted file mode 100644 index ffc3cb1..0000000 --- a/shenyu-client-java-sofa/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-client-java-sofa - - - 3.22.0 - 4.3.0 - - - - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - - junit - junit - 4.13.2 - test - - - org.apache.shenyu - shenyu-client-java-core - ${project.version} - - - grpc-netty - io.grpc - - - - - com.alipay.sofa - runtime-sofa-boot-starter - ${runtime-sofa-boot-starter.version} - provided - - - sofa-common-tools - com.alipay.sofa.common - - - - - - com.alipay.sofa - sofa-rpc-all - ${sofa.rpc.version} - provided - - - com.alipay.sofa.common - sofa-common-tools - ${sofa-common-tools.version} - - - org.springframework - spring-beans - provided - - - org.springframework - spring-context - provided - - - org.springframework - spring-core - provided - - - diff --git a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/pom.xml b/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/pom.xml deleted file mode 100644 index 8bdcb84..0000000 --- a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-client-java-websocket - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-client-java-spring-websocket - - - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - - junit - junit - 4.13.2 - test - - - org.apache.shenyu - shenyu-client-java-core - ${project.version} - - - org.springframework - spring-beans - provided - - - org.springframework - spring-context - provided - - - org.springframework - spring-core - provided - - - org.springframework - spring-web - provided - - - jakarta.websocket - jakarta.websocket-api - provided - - - jakarta.servlet - jakarta.servlet-api - provided - - - org.springframework - spring-websocket - test - - - org.apache.tomcat.embed - tomcat-embed-websocket - - - diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/pom.xml b/shenyu-client/pom.xml similarity index 54% rename from shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/pom.xml rename to shenyu-client/pom.xml index 9cc6a63..6628e50 100644 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/pom.xml +++ b/shenyu-client/pom.xml @@ -15,38 +15,50 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> + - shenyu-spring-boot-starter-java-client org.apache.shenyu - 2.7.1-SNAPSHOT + shenyu-client-java + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 + shenyu-client + pom - shenyu-spring-boot-starter-java-client-spring-websocket + + shenyu-client-core + shenyu-client-http + shenyu-client-dubbo + shenyu-client-sofa + shenyu-client-tars + shenyu-client-grpc + shenyu-client-motan + shenyu-client-websocket + shenyu-client-api-docs-annotations + shenyu-client-autoconfig + - org.mockito - mockito-inline - 3.3.3 - test + com.squareup.okhttp3 + okhttp + ${okhttp.version} - org.apache.shenyu - shenyu-client-java-spring-websocket - ${project.version} + com.google.code.gson + gson + ${gson.version} - org.apache.shenyu - shenyu-spring-boot-starter-java-client-common - ${project.version} + org.javatuples + javatuples + ${javatuples.version} - org.apache.shenyu - shenyu-client-java-autoconfig - ${project.version} + org.springframework + spring-test + test - diff --git a/shenyu-client-java-api-docs-annotations/pom.xml b/shenyu-client/shenyu-client-api-docs-annotations/pom.xml similarity index 87% rename from shenyu-client-java-api-docs-annotations/pom.xml rename to shenyu-client/shenyu-client-api-docs-annotations/pom.xml index 0a2c2d8..e0812d6 100644 --- a/shenyu-client-java-api-docs-annotations/pom.xml +++ b/shenyu-client/shenyu-client-api-docs-annotations/pom.xml @@ -18,11 +18,11 @@ org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-api-docs-annotations + shenyu-client-api-docs-annotations diff --git a/shenyu-client-java-api-docs-annotations/src/main/java/org/apache/shenyu/client/apidocs/annotations/ApiDoc.java b/shenyu-client/shenyu-client-api-docs-annotations/src/main/java/org/apache/shenyu/client/apidocs/annotations/ApiDoc.java similarity index 100% rename from shenyu-client-java-api-docs-annotations/src/main/java/org/apache/shenyu/client/apidocs/annotations/ApiDoc.java rename to shenyu-client/shenyu-client-api-docs-annotations/src/main/java/org/apache/shenyu/client/apidocs/annotations/ApiDoc.java diff --git a/shenyu-client-java-api-docs-annotations/src/main/java/org/apache/shenyu/client/apidocs/annotations/ApiModule.java b/shenyu-client/shenyu-client-api-docs-annotations/src/main/java/org/apache/shenyu/client/apidocs/annotations/ApiModule.java similarity index 100% rename from shenyu-client-java-api-docs-annotations/src/main/java/org/apache/shenyu/client/apidocs/annotations/ApiModule.java rename to shenyu-client/shenyu-client-api-docs-annotations/src/main/java/org/apache/shenyu/client/apidocs/annotations/ApiModule.java diff --git a/shenyu-client-java-autoconfig/pom.xml b/shenyu-client/shenyu-client-autoconfig/pom.xml similarity index 87% rename from shenyu-client-java-autoconfig/pom.xml rename to shenyu-client/shenyu-client-autoconfig/pom.xml index 89fc139..d864515 100644 --- a/shenyu-client-java-autoconfig/pom.xml +++ b/shenyu-client/shenyu-client-autoconfig/pom.xml @@ -18,18 +18,18 @@ - shenyu-client-java + shenyu-client org.apache.shenyu - 2.7.1-SNAPSHOT + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-autoconfig + shenyu-client-autoconfig org.apache.shenyu - shenyu-client-java-core + shenyu-client-core ${project.version} diff --git a/shenyu-client-java-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/ClientRegisterConfiguration.java b/shenyu-client/shenyu-client-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/ClientRegisterConfiguration.java similarity index 98% rename from shenyu-client-java-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/ClientRegisterConfiguration.java rename to shenyu-client/shenyu-client-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/ClientRegisterConfiguration.java index daa1ddc..5e6b6d4 100644 --- a/shenyu-client-java-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/ClientRegisterConfiguration.java +++ b/shenyu-client/shenyu-client-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/ClientRegisterConfiguration.java @@ -20,6 +20,7 @@ import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; import org.apache.shenyu.client.core.register.ClientApiRefreshedEventListener; import org.apache.shenyu.client.core.register.ClientRegisterConfig; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; import org.apache.shenyu.client.core.register.extractor.MultiClientApiBeansExtractorImpl; import org.apache.shenyu.client.core.register.extractor.RpcApiBeansExtractor; import org.apache.shenyu.client.core.register.matcher.ApiDocProcessorImpl; @@ -27,7 +28,6 @@ import org.apache.shenyu.client.core.register.registrar.ApiDocRegistrarImpl; import org.apache.shenyu.client.core.register.registrar.ApiRegistrar; import org.apache.shenyu.client.core.register.registrar.MateDataApiRegistrarImpl; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/shenyu-client-java-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/EnableClientRegister.java b/shenyu-client/shenyu-client-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/EnableClientRegister.java similarity index 100% rename from shenyu-client-java-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/EnableClientRegister.java rename to shenyu-client/shenyu-client-autoconfig/src/main/java/org/apache/shenyu/client/auto/config/EnableClientRegister.java diff --git a/shenyu-client-java-core/pom.xml b/shenyu-client/shenyu-client-core/pom.xml similarity index 66% rename from shenyu-client-java-core/pom.xml rename to shenyu-client/shenyu-client-core/pom.xml index 4cfbcdf..467d2f2 100644 --- a/shenyu-client-java-core/pom.xml +++ b/shenyu-client/shenyu-client-core/pom.xml @@ -19,54 +19,55 @@ org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-core + shenyu-client-core - org.hamcrest - hamcrest - 2.2 - test + org.apache.shenyu + shenyu-disruptor + 2.6.1 + + + + + + - org.mockito - mockito-junit-jupiter - 4.11.0 - test + com.github.ben-manes.caffeine + caffeine + - org.mockito - mockito-inline - 3.3.3 - test + com.fasterxml.jackson.core + jackson-annotations - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test + org.bouncycastle + bcprov-jdk18on - + - junit - junit - 4.13.2 - test + org.slf4j + slf4j-api - - org.apache.shenyu - shenyu-disruptor - 2.6.1 + org.slf4j + jcl-over-slf4j - org.apache.shenyu - shenyu-register-java-client-http - ${project.version} + com.google.guava + guava + + + com.google.re2j + re2j + + org.springframework @@ -85,14 +86,9 @@ org.apache.shenyu - shenyu-client-java-api-docs-annotations + shenyu-client-api-docs-annotations ${project.version} - - org.apache.shenyu - shenyu-discovery-api - 2.6.1 - org.springframework spring-web @@ -108,5 +104,15 @@ spring-boot-starter-tomcat test + + + org.apache.commons + commons-lang3 + + + org.apache.commons + commons-collections4 + + diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java similarity index 93% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java index 5868ee6..0d9ac05 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java @@ -24,24 +24,25 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.shenyu.client.apidocs.annotations.ApiDoc; import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig.ClientPropertiesConfig; +import org.apache.shenyu.client.core.constant.Constants; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.ApiSourceEnum; +import org.apache.shenyu.client.core.enums.ApiStateEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.exception.ShenyuClientIllegalArgumentException; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig.ClientPropertiesConfig; +import org.apache.shenyu.client.core.utils.GsonUtils; +import org.apache.shenyu.client.core.utils.IpUtils; import org.apache.shenyu.client.core.utils.OpenApiUtils; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.ApiSourceEnum; -import org.apache.shenyu.common.enums.ApiStateEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.common.utils.IpUtils; -import org.apache.shenyu.common.utils.UriUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; +import org.apache.shenyu.client.core.utils.UriUtils; import org.javatuples.Sextet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -124,10 +125,10 @@ public AbstractContextRefreshedEventListener(final ShenyuClientConfig clientConf Properties props = config.getProps(); String namespace = clientConfig.getNamespace(); if (StringUtils.isBlank(namespace)) { - LOG.warn("current shenyu.namespace is null, use default namespace: {}", ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID); - namespace = ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID; + LOG.warn("current shenyu.namespace is null, use default namespace: {}", Constants.SYS_DEFAULT_NAMESPACE_ID); + namespace = Constants.SYS_DEFAULT_NAMESPACE_ID; } - this.namespace = Lists.newArrayList(StringUtils.split(namespace, ShenyuClientConstants.SEPARATOR_CHARS)); + this.namespace = Lists.newArrayList(StringUtils.split(namespace, Constants.SEPARATOR_CHARS)); this.appName = props.getProperty(ShenyuClientConstants.APP_NAME); this.contextPath = Optional.ofNullable(props.getProperty(ShenyuClientConstants.CONTEXT_PATH)).map(UriUtils::repairData).orElse(""); if (StringUtils.isBlank(appName) && StringUtils.isBlank(contextPath)) { @@ -262,7 +263,9 @@ private String buildDocumentJson(final List tags, final String path, fin .put("tags", tags) .put("operationId", path) .put("parameters", OpenApiUtils.generateDocumentParameters(path, method)) - .put("responses", OpenApiUtils.generateDocumentResponse(path)).build(); + .put("responses", OpenApiUtils.generateDocumentResponse(path)) + .put("responseType", Collections.singletonList(OpenApiUtils.parseReturnType(method))) + .build(); return GsonUtils.getInstance().toJson(documentMap); } diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/Constants.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/constant/Constants.java similarity index 83% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/Constants.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/constant/Constants.java index c84929a..8489011 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/Constants.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/constant/Constants.java @@ -15,13 +15,29 @@ * limitations under the License. */ -package org.apache.shenyu.common.constant; +package org.apache.shenyu.client.core.constant; /** * Constants. */ public interface Constants { + + /** + * The constant URI_SUFFIX. + */ + String URI_SUFFIX = "/**"; + + /** + * The constant URI_SLASH_SUFFIX. + */ + String URI_SLASH_SUFFIX = "/"; + + /** + * The constant string separator. + */ + String SEPARATOR_CHARS = ";"; + /** * The constant SUCCESS. */ @@ -247,6 +263,12 @@ public interface Constants { */ String URI = "uri"; + + /** + * The constant HEARTBEAT. + */ + String HEARTBEAT = "heartbeat"; + /** * The constant header key of sign plugin version-2. */ @@ -255,7 +277,7 @@ public interface Constants { /** * The constant LINE_SEPARATOR. */ - String LINE_SEPARATOR = System.getProperty("line.separator"); + String LINE_SEPARATOR = System.lineSeparator(); /** * The constant URL_SEPARATOR. @@ -541,6 +563,11 @@ public interface Constants { * dubbo remote address. */ String DUBBO_REMOTE_ADDRESS = "dubboRemoteAddress"; + + /** + * dubbo load balance from meta data. + */ + String DUBBO_LOAD_BALANCE = "dubboLoadBalance"; /** * dubbo group. @@ -800,6 +827,16 @@ public interface Constants { */ String PLUGIN_END_TIME = "pluginEndTime:"; + /** + * the chain start time of chain lifecycle. + */ + String CHAIN_START_TIME = "chainStartTime:"; + + /** + * the chain end time of chain lifecycle. + */ + String CHAIN_END_TIME = "chainEndTime:"; + /** * ratelimiter plugin metrics. */ @@ -819,7 +856,141 @@ public interface Constants { * Hystrix plugin metrics. */ String METRICS_HYSTRIX = "metricsHystrix"; + + /** + * The constant shenyu namespace id. + */ + String SHENYU_NAMESPACE_ID = "namespaceId"; + + /** + * The constant SYS_DEFAULT_NAMESPACE_ID. + */ + String SYS_DEFAULT_NAMESPACE_ID = "649330b6-c2d7-4edc-be8e-8a54df9eb385"; + + /** + * The constant DEFAULT_NAMESPACE_PRIMARY_KEY. + */ + String DEFAULT_NAMESPACE_PRIMARY_KEY = "1"; + + /** + * The constant EVENT_NAME_DICT. + */ + String EVENT_NAME_DICT = "dict"; + + /** + * The constant EVENT_NAME_PLUGIN_HANDLE. + */ + String EVENT_NAME_PLUGIN_HANDLE = "plugin-handle"; + + /** + * The constant EVENT_NAME_META_DATA. + */ + String EVENT_NAME_META_DATA = "meta-data"; + + /** + * The constant EVENT_NAME_NAMESPACE. + */ + String EVENT_NAME_NAMESPACE = "namespace"; + + /** + * The constant EVENT_NAME_PLUGIN. + */ + String EVENT_NAME_PLUGIN = "plugin"; + + /** + * The constant EVENT_NAME_NAMESPACE_PLUGIN. + */ + String EVENT_NAME_NAMESPACE_PLUGIN = "namespace-plugin"; + + /** + * The constant EVENT_NAME_RESOURCE. + */ + String EVENT_NAME_RESOURCE = "resource"; + + /** + * The constant EVENT_NAME_ROLE. + */ + String EVENT_NAME_ROLE = "role"; + + /** + * The constant EVENT_NAME_RULE. + */ + String EVENT_NAME_RULE = "rule"; + + /** + * The constant EVENT_NAME_SELECTOR. + */ + String EVENT_NAME_SELECTOR = "selector"; + + /** + * The constant EVENT_NAME_USER. + */ + String EVENT_NAME_USER = "user"; + + /** + * The constant EVENT_NAME_DATA. + */ + String EVENT_NAME_DATA = "data"; + + /** + * The constant EVENT_NAME_REGISTER. + */ + String HTTP_PATH = "shenyu.httpPath"; + /** + * The constant preserve host. + */ + String PRESERVE_HOST = "preserveHost"; + + /** + * The constant model. + */ + String MODEL = "model"; + + /** + * The constant stream. + */ + String STREAM = "stream"; + + /** + * The constant prompt. + */ + String PROMPT = "prompt"; + + /** + * The constant messages. + */ + String MESSAGES = "messages"; + + /** + * The constant usedTokens. + */ + String USED_TOKENS = "used-tokens"; + + /** + * The constant X-Client-ID. + */ + String CLIENT_ID = "X-Client-ID"; + + /** + * The constant Content-Encoding. + */ + String CONTENT_ENCODING = "Content-Encoding"; + /** + * Http request retry policy. + */ + String HTTP_RETRY_BACK_OFF_SPEC = "default"; + + /** + * The constant Content. + */ + String CONTENT = "content"; + + /** + * The constant ROLE. + */ + String ROLE = "role"; + /** * String q. */ diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/constant/ShenyuClientConstants.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/constant/ShenyuClientConstants.java similarity index 89% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/constant/ShenyuClientConstants.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/constant/ShenyuClientConstants.java index 7a11b0e..bfac42f 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/constant/ShenyuClientConstants.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/constant/ShenyuClientConstants.java @@ -21,16 +21,6 @@ * ShenyuClientConstants. */ public final class ShenyuClientConstants { - - /** - * The constant string separator. - */ - public static final String SEPARATOR_CHARS = ";"; - - /** - * The constant SYS_DEFAULT_NAMESPACE_ID. - */ - public static final String SYS_DEFAULT_NAMESPACE_ID = "649330b6-c2d7-4edc-be8e-8a54df9eb385"; /** * the constant of APP_NAME. diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/ShenyuClientRegisterEventPublisher.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/ShenyuClientRegisterEventPublisher.java similarity index 95% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/ShenyuClientRegisterEventPublisher.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/ShenyuClientRegisterEventPublisher.java index 416fbba..b5eaea0 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/ShenyuClientRegisterEventPublisher.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/ShenyuClientRegisterEventPublisher.java @@ -21,10 +21,10 @@ import org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientApiDocExecutorSubscriber; import org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientMetadataExecutorSubscriber; import org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientURIExecutorSubscriber; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.type.DataTypeParent; import org.apache.shenyu.disruptor.DisruptorProviderManage; import org.apache.shenyu.disruptor.provider.DisruptorProvider; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.type.DataTypeParent; /** * The type shenyu client register event publisher. diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/executor/RegisterClientConsumerExecutor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/executor/RegisterClientConsumerExecutor.java similarity index 89% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/executor/RegisterClientConsumerExecutor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/executor/RegisterClientConsumerExecutor.java index 0b8efbd..8a1f6a1 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/executor/RegisterClientConsumerExecutor.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/executor/RegisterClientConsumerExecutor.java @@ -18,11 +18,11 @@ package org.apache.shenyu.client.core.disruptor.executor; import com.google.common.collect.Lists; +import org.apache.shenyu.client.core.register.subsriber.AbstractQueueConsumerFactory; +import org.apache.shenyu.client.core.register.subsriber.ExecutorTypeSubscriber; +import org.apache.shenyu.client.core.type.DataType; +import org.apache.shenyu.client.core.type.DataTypeParent; import org.apache.shenyu.disruptor.consumer.QueueConsumerExecutor; -import org.apache.shenyu.register.common.subsriber.AbstractQueueConsumerFactory; -import org.apache.shenyu.register.common.subsriber.ExecutorTypeSubscriber; -import org.apache.shenyu.register.common.type.DataType; -import org.apache.shenyu.register.common.type.DataTypeParent; import java.util.EnumMap; import java.util.Map; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriber.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriber.java similarity index 86% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriber.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriber.java index 4a5a7a5..21fcbe5 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriber.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriber.java @@ -17,10 +17,11 @@ package org.apache.shenyu.client.core.disruptor.subcriber; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.subsriber.ExecutorTypeSubscriber; -import org.apache.shenyu.register.common.type.DataType; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.subsriber.ExecutorTypeSubscriber; +import org.apache.shenyu.client.core.type.DataType; + import java.util.Collection; /** diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriber.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriber.java similarity index 86% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriber.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriber.java index 5fd4331..82e356a 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriber.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriber.java @@ -17,10 +17,11 @@ package org.apache.shenyu.client.core.disruptor.subcriber; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.subsriber.ExecutorTypeSubscriber; -import org.apache.shenyu.register.common.type.DataType; + +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.subsriber.ExecutorTypeSubscriber; +import org.apache.shenyu.client.core.type.DataType; import java.util.Collection; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriber.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriber.java similarity index 86% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriber.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriber.java index 514828f..b8e96a9 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriber.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriber.java @@ -19,14 +19,14 @@ import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.subsriber.ExecutorTypeSubscriber; import org.apache.shenyu.client.core.shutdown.ShenyuClientShutdownHook; import org.apache.shenyu.client.core.shutdown.ShutdownHookManager; -import org.apache.shenyu.common.concurrent.ShenyuThreadFactory; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; -import org.apache.shenyu.register.common.subsriber.ExecutorTypeSubscriber; -import org.apache.shenyu.register.common.type.DataType; +import org.apache.shenyu.client.core.type.DataType; +import org.apache.shenyu.client.core.utils.ShenyuThreadFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -63,7 +63,13 @@ public ShenyuClientURIExecutorSubscriber(final ShenyuClientRegisterRepository sh ThreadFactory requestFactory = ShenyuThreadFactory.create("heartbeat-reporter", true); executor = new ScheduledThreadPoolExecutor(1, requestFactory); - executor.scheduleAtFixedRate(() -> URIS.forEach(this::sendHeartbeat), 30, 30, TimeUnit.SECONDS); + executor.scheduleAtFixedRate(() -> { + try { + URIS.forEach(this::sendHeartbeat); + } catch (Exception e) { + LOG.error("send heartbeat error", e); + } + }, 30, 30, TimeUnit.SECONDS); } @Override @@ -116,6 +122,6 @@ public void executor(final Collection dataList) { } private void sendHeartbeat(final URIRegisterDTO uriRegisterDTO) { -// shenyuClientRegisterRepository.sendHeartbeat(uriRegisterDTO); + shenyuClientRegisterRepository.sendHeartbeat(uriRegisterDTO); } } diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/ApiDocRegisterDTO.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/ApiDocRegisterDTO.java similarity index 98% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/ApiDocRegisterDTO.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/ApiDocRegisterDTO.java index a7e8a04..26d8240 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/ApiDocRegisterDTO.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/ApiDocRegisterDTO.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.dto; +package org.apache.shenyu.client.core.dto; -import org.apache.shenyu.register.common.enums.EventType; -import org.apache.shenyu.register.common.type.DataType; -import org.apache.shenyu.register.common.type.DataTypeParent; + +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.type.DataType; +import org.apache.shenyu.client.core.type.DataTypeParent; import java.util.List; import java.util.Objects; @@ -60,7 +61,7 @@ public class ApiDocRegisterDTO implements DataTypeParent { private String version; /** - * http,dubbo,sofa,tars,websocket,springCloud,motan,grpc. + * http,dubbo,sofa,tars,websocket,motan,grpc. */ private String rpcType; diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/DiscoveryConfigRegisterDTO.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/DiscoveryConfigRegisterDTO.java similarity index 98% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/DiscoveryConfigRegisterDTO.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/DiscoveryConfigRegisterDTO.java index 0ab8ba0..ca5c0dc 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/DiscoveryConfigRegisterDTO.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/DiscoveryConfigRegisterDTO.java @@ -15,10 +15,11 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.dto; +package org.apache.shenyu.client.core.dto; -import org.apache.shenyu.register.common.type.DataType; -import org.apache.shenyu.register.common.type.DataTypeParent; + +import org.apache.shenyu.client.core.type.DataType; +import org.apache.shenyu.client.core.type.DataTypeParent; import java.util.Properties; diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/MetaDataRegisterDTO.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/MetaDataRegisterDTO.java similarity index 99% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/MetaDataRegisterDTO.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/MetaDataRegisterDTO.java index 8dab26d..2a6f84d 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/MetaDataRegisterDTO.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/MetaDataRegisterDTO.java @@ -15,10 +15,11 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.dto; +package org.apache.shenyu.client.core.dto; -import org.apache.shenyu.register.common.type.DataType; -import org.apache.shenyu.register.common.type.DataTypeParent; + +import org.apache.shenyu.client.core.type.DataType; +import org.apache.shenyu.client.core.type.DataTypeParent; import java.util.Collections; import java.util.List; diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/URIRegisterDTO.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/URIRegisterDTO.java similarity index 97% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/URIRegisterDTO.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/URIRegisterDTO.java index bcf6102..5c6f05c 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/dto/URIRegisterDTO.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/dto/URIRegisterDTO.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.dto; +package org.apache.shenyu.client.core.dto; -import org.apache.shenyu.register.common.enums.EventType; -import org.apache.shenyu.register.common.type.DataType; -import org.apache.shenyu.register.common.type.DataTypeParent; + +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.type.DataType; +import org.apache.shenyu.client.core.type.DataTypeParent; import java.util.Objects; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiHttpMethodEnum.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiHttpMethodEnum.java similarity index 88% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiHttpMethodEnum.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiHttpMethodEnum.java index 1182b97..6257193 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiHttpMethodEnum.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiHttpMethodEnum.java @@ -15,9 +15,8 @@ * limitations under the License. */ -package org.apache.shenyu.common.enums; +package org.apache.shenyu.client.core.enums; -import org.apache.shenyu.common.exception.ShenyuException; import java.util.Arrays; @@ -114,7 +113,7 @@ public static Integer getValueByName(final String name) { return Arrays.stream(ApiHttpMethodEnum.values()) .filter(e -> e.name.equals(name)).findFirst() .map(item -> item.value) - .orElseThrow(() -> new ShenyuException(String.format(" this http method can not support %s", name))); + .orElseThrow(() -> new RuntimeException(String.format(" this http method can not support %s", name))); } /** @@ -126,7 +125,7 @@ public static Integer getValueByName(final String name) { public static ApiHttpMethodEnum of(final String name) { return Arrays.stream(ApiHttpMethodEnum.values()) .filter(e -> e.name.equals(name)).findFirst() - .orElseThrow(() -> new ShenyuException(String.format(" this http method can not support %s", name))); + .orElseThrow(() -> new RuntimeException(String.format(" this http method can not support %s", name))); } } diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiSourceEnum.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiSourceEnum.java similarity index 97% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiSourceEnum.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiSourceEnum.java index c35fa9c..c7a5650 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiSourceEnum.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiSourceEnum.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.enums; +package org.apache.shenyu.client.core.enums; /** * the api source. diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiStateEnum.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiStateEnum.java similarity index 96% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiStateEnum.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiStateEnum.java index a28033d..7f55acd 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ApiStateEnum.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/ApiStateEnum.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.enums; +package org.apache.shenyu.client.core.enums; /** * the api state. diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/enums/EventType.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/EventType.java similarity index 90% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/enums/EventType.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/EventType.java index 0626509..670e80c 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/enums/EventType.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/EventType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.enums; +package org.apache.shenyu.client.core.enums; /** * The enum Event type. @@ -45,5 +45,10 @@ public enum EventType { /** * offline event type. */ - OFFLINE + OFFLINE, + + /** + * heartbeat event type. + */ + HEARTBEAT } diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/PluginEnum.java similarity index 94% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/PluginEnum.java index 398e3a6..9458af3 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/PluginEnum.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.enums; +package org.apache.shenyu.client.core.enums; import java.util.Arrays; import java.util.List; @@ -142,6 +142,11 @@ public enum PluginEnum { */ LOGGING_CONSOLE(160, 0, "loggingConsole"), + /** + * AI Prompt plugin enum. + */ + AI_PROMPT(170, 0, "aiPrompt"), + /** * Logging RocketMQ plugin enum. */ @@ -266,6 +271,21 @@ public enum PluginEnum { * Key-auth plugin enum. */ KEY_AUTH(430, 0, "keyAuth"), + + /** + * Ai-proxy plugin enum. + */ + AI_PROXY(199, 0, "aiProxy"), + + /** + * Ai-token-limiter plugin enum. + */ + AI_TOKEN_LIMITER(171, 0, "aiTokenLimiter"), + + /** + * Mcp-server plugin enum. + */ + MCP_SERVER(180, 0, "mcpServer"), /** * Basic-auth plugin enum. diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/enums/RegisterTypeEnum.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/RegisterTypeEnum.java similarity index 91% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/enums/RegisterTypeEnum.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/RegisterTypeEnum.java index 4c6ae6b..6a76aed 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/enums/RegisterTypeEnum.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/RegisterTypeEnum.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.enums; +package org.apache.shenyu.client.core.enums; /** * RegisterTypeEnum. @@ -47,11 +47,6 @@ public enum RegisterTypeEnum { */ MOTAN("motan"), - /** - * springCloud rpc type enum. - */ - SPRING_CLOUD("springCloud"), - /** * grpc. */ diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RpcTypeEnum.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/RpcTypeEnum.java similarity index 93% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RpcTypeEnum.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/RpcTypeEnum.java index 2a51388..3a44ac0 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RpcTypeEnum.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/enums/RpcTypeEnum.java @@ -15,9 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.enums; - -import org.apache.shenyu.common.exception.ShenyuException; +package org.apache.shenyu.client.core.enums; import java.util.Arrays; import java.util.List; @@ -66,7 +64,12 @@ public enum RpcTypeEnum { /** * grpc. */ - GRPC("grpc", true); + GRPC("grpc", true), + + /** + * ai. + */ + AI("ai", true); private final String name; @@ -146,6 +149,6 @@ public static List acquireSupportSwaggers() { public static RpcTypeEnum acquireByName(final String name) { return Arrays.stream(RpcTypeEnum.values()) .filter(e -> e.support && e.name.equals(name)).findFirst() - .orElseThrow(() -> new ShenyuException(String.format(" this rpc type can not support %s", name))); + .orElseThrow(() -> new RuntimeException(String.format(" this rpc type can not support %s", name))); } } diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/CommonErrorCode.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/exception/CommonErrorCode.java similarity index 96% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/CommonErrorCode.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/exception/CommonErrorCode.java index 8416386..7deaf73 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/CommonErrorCode.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/exception/CommonErrorCode.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.exception; +package org.apache.shenyu.client.core.exception; /** * CommonErrorCode. diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/exception/ShenyuClientIllegalArgumentException.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/exception/ShenyuClientIllegalArgumentException.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/exception/ShenyuClientIllegalArgumentException.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/exception/ShenyuClientIllegalArgumentException.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ApiBean.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ApiBean.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ApiBean.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ApiBean.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientApiRefreshedEventListener.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientApiRefreshedEventListener.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientApiRefreshedEventListener.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientApiRefreshedEventListener.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientDiscoveryConfigRefreshedEventListener.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientDiscoveryConfigRefreshedEventListener.java similarity index 83% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientDiscoveryConfigRefreshedEventListener.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientDiscoveryConfigRefreshedEventListener.java index 9b69b30..4386d83 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientDiscoveryConfigRefreshedEventListener.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientDiscoveryConfigRefreshedEventListener.java @@ -19,13 +19,11 @@ import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; -import org.apache.shenyu.register.common.dto.DiscoveryConfigRegisterDTO; -import org.apache.shenyu.common.enums.PluginEnum; -import org.apache.shenyu.common.exception.ShenyuException; -import org.apache.shenyu.register.client.http.HttpClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuDiscoveryConfig; +import org.apache.shenyu.client.core.constant.Constants; +import org.apache.shenyu.client.core.dto.DiscoveryConfigRegisterDTO; +import org.apache.shenyu.client.core.enums.PluginEnum; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.register.config.ShenyuDiscoveryConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationListener; @@ -62,10 +60,10 @@ public ClientDiscoveryConfigRefreshedEventListener(final ShenyuDiscoveryConfig s this.plugin = plugin; String namespace = shenyuClientConfig.getNamespace(); if (StringUtils.isBlank(namespace)) { - LOG.warn("current shenyu.namespace is null, use default namespace: {}", ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID); - namespace = ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID; + LOG.warn("current shenyu.namespace is null, use default namespace: {}", Constants.SYS_DEFAULT_NAMESPACE_ID); + namespace = Constants.SYS_DEFAULT_NAMESPACE_ID; } - this.namespace = Lists.newArrayList(StringUtils.split(namespace, ShenyuClientConstants.SEPARATOR_CHARS)); + this.namespace = Lists.newArrayList(StringUtils.split(namespace, Constants.SEPARATOR_CHARS)); } @Override @@ -81,11 +79,11 @@ public void onApplicationEvent(final ContextRefreshedEvent event) { protected DiscoveryConfigRegisterDTO buildDiscoveryConfigRegisterDTO(final ShenyuDiscoveryConfig shenyuDiscoveryConfig, final String namespaceId) { if (StringUtils.isEmpty(shenyuDiscoveryConfig.getServerList())) { LOG.error("If using service discovery. The configuration shenyu.discovery.name in xml/yml cannot be null"); - throw new ShenyuException("The configuration shenyu.discovery.serverList in xml/yml cannot be null"); + throw new RuntimeException("The configuration shenyu.discovery.serverList in xml/yml cannot be null"); } if (StringUtils.isEmpty(shenyuDiscoveryConfig.getType())) { LOG.error("If using service discovery. The configuration shenyu.discovery.name in xml/yml cannot be null"); - throw new ShenyuException("The configuration shenyu.discovery.type in xml/yml cannot be null"); + throw new RuntimeException("The configuration shenyu.discovery.type in xml/yml cannot be null"); } return DiscoveryConfigRegisterDTO.builder() .name(discoveryName()) diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfig.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfig.java similarity index 96% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfig.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfig.java index f1b5e62..414b49a 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfig.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfig.java @@ -17,7 +17,8 @@ package org.apache.shenyu.client.core.register; -import org.apache.shenyu.common.enums.RpcTypeEnum; + +import org.apache.shenyu.client.core.enums.RpcTypeEnum; public interface ClientRegisterConfig { diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfigImpl.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfigImpl.java similarity index 94% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfigImpl.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfigImpl.java index 6483e96..c50cfbe 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfigImpl.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ClientRegisterConfigImpl.java @@ -18,11 +18,11 @@ package org.apache.shenyu.client.core.register; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.IpUtils; import org.apache.shenyu.client.core.utils.PortUtils; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.IpUtils; -import org.apache.shenyu.common.utils.UriUtils; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.UriUtils; import org.springframework.context.ApplicationContext; import org.springframework.core.env.Environment; diff --git a/shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/FailbackRegistryRepository.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/FailbackRegistryRepository.java similarity index 93% rename from shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/FailbackRegistryRepository.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/FailbackRegistryRepository.java index 3231dbe..28ee568 100644 --- a/shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/FailbackRegistryRepository.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/FailbackRegistryRepository.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.shenyu.register.client.api; +package org.apache.shenyu.client.core.register; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.timer.Timer; -import org.apache.shenyu.common.timer.WheelTimerFactory; -import org.apache.shenyu.register.client.api.retry.FailureRegistryTask; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.constant.Constants; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.register.retry.FailureRegistryTask; +import org.apache.shenyu.client.core.timer.Timer; +import org.apache.shenyu.client.core.timer.WheelTimerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/HttpClientRegisterRepository.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/HttpClientRegisterRepository.java similarity index 80% rename from shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/HttpClientRegisterRepository.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/HttpClientRegisterRepository.java index 4658ad2..e6898ed 100644 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/HttpClientRegisterRepository.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/HttpClientRegisterRepository.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.client.http; +package org.apache.shenyu.client.core.register; import com.github.benmanes.caffeine.cache.CacheLoader; import com.github.benmanes.caffeine.cache.Caffeine; @@ -23,19 +23,17 @@ import com.google.common.base.Splitter; import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.utils.AesUtils; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.register.client.api.FailbackRegistryRepository; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.apache.shenyu.register.client.http.utils.RuntimeUtils; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.dto.DiscoveryConfigRegisterDTO; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; -import org.apache.shenyu.spi.Join; +import org.apache.shenyu.client.core.constant.Constants; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.dto.DiscoveryConfigRegisterDTO; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; +import org.apache.shenyu.client.core.utils.AesUtils; +import org.apache.shenyu.client.core.utils.GsonUtils; +import org.apache.shenyu.client.core.utils.RegisterUtils; +import org.apache.shenyu.client.core.utils.RuntimeUtils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.Logger; @@ -49,7 +47,6 @@ /** * The type Http client register repository. */ -@Join public class HttpClientRegisterRepository extends FailbackRegistryRepository { private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientRegisterRepository.class); @@ -130,6 +127,15 @@ public void offline(final URIRegisterDTO offlineDTO) { doUnregister(offlineDTO); } + @Override + public void sendHeartbeat(final URIRegisterDTO heartbeatDTO) { + if (RuntimeUtils.listenByOther(heartbeatDTO.getPort())) { + return; + } + heartbeatDTO.setEventType(EventType.HEARTBEAT); + doHeartbeat(heartbeatDTO, Constants.URI_PATH); + } + /** * doPersistApiDoc. * @@ -187,6 +193,26 @@ private void doRegister(final T t, final String path, final String type) { } } } + + private void doHeartbeat(final T t, final String path) { + int i = 0; + for (String server : serverList) { + i++; + String concat = server.concat(path); + try { + String accessToken = this.accessToken.get(server); + if (StringUtils.isBlank(accessToken)) { + throw new NullPointerException("accessToken is null"); + } + RegisterUtils.doHeartBeat(GsonUtils.getInstance().toJson(t), concat, Constants.HEARTBEAT, accessToken); + } catch (Exception e) { + LOGGER.error("HeartBeat admin url :{} is fail, will retry.", server, e); + if (i == serverList.size()) { + throw new RuntimeException(e); + } + } + } + } private void doUnregister(final T t) { for (String server : serverList) { diff --git a/shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/ShenyuClientRegisterRepository.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepository.java similarity index 80% rename from shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/ShenyuClientRegisterRepository.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepository.java index 5b482f9..449a423 100644 --- a/shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/ShenyuClientRegisterRepository.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepository.java @@ -15,18 +15,17 @@ * limitations under the License. */ -package org.apache.shenyu.register.client.api; +package org.apache.shenyu.client.core.register; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.spi.SPI; + +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; /** * Shenyu client register repository. */ -@SPI public interface ShenyuClientRegisterRepository { /** @@ -60,6 +59,14 @@ default void persistURI(URIRegisterDTO registerDTO) { default void offline(URIRegisterDTO offlineDTO) { } + /** + * Send heartbeat. + * + * @param heartbeatDTO the heartbeat dto + */ + default void sendHeartbeat(URIRegisterDTO heartbeatDTO) { + } + /** * persistApiDoc. * @param apiDocRegisterDTO apiDocRegisterDTO diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactory.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactory.java similarity index 86% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactory.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactory.java index 7c2b0d9..7a3a758 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactory.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactory.java @@ -20,10 +20,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; import org.apache.shenyu.client.core.shutdown.ShenyuClientShutdownHook; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; -import org.apache.shenyu.spi.ExtensionLoader; /** * The type shenyu client register repository factory. @@ -49,7 +47,7 @@ public static Map getRepositoryMap() { */ public static ShenyuClientRegisterRepository newInstance(final ShenyuRegisterCenterConfig shenyuRegisterCenterConfig) { if (!REPOSITORY_MAP.containsKey(shenyuRegisterCenterConfig.getRegisterType())) { - ShenyuClientRegisterRepository result = ExtensionLoader.getExtensionLoader(ShenyuClientRegisterRepository.class).getJoin(shenyuRegisterCenterConfig.getRegisterType()); + ShenyuClientRegisterRepository result = new HttpClientRegisterRepository(); result.init(shenyuRegisterCenterConfig); ShenyuClientShutdownHook.set(result, shenyuRegisterCenterConfig.getProps()); REPOSITORY_MAP.put(shenyuRegisterCenterConfig.getRegisterType(), result); diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/EntityResult.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuInstanceRegisterRepository.java similarity index 54% rename from shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/EntityResult.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuInstanceRegisterRepository.java index 81664be..b4dd5a0 100644 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/EntityResult.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/ShenyuInstanceRegisterRepository.java @@ -15,61 +15,48 @@ * limitations under the License. */ -package org.apache.shenyu.examples.springcloud.dto; +package org.apache.shenyu.client.core.register; -/** - * EntityResult. - */ -public class EntityResult { - /** - * code. - */ - private int code; +import org.apache.shenyu.client.core.register.config.RegisterConfig; +import org.apache.shenyu.client.core.register.entity.InstanceEntity; - /** - * message. - */ - private String message; - - public EntityResult(final int code, final String message) { - this.code = code; - this.message = message; - } +import java.util.Collections; +import java.util.List; + +/** + * Shenyu instance register repository. + */ +public interface ShenyuInstanceRegisterRepository { /** - * getCode. + * Init. * - * @return int + * @param config the config */ - public int getCode() { - return code; + default void init(RegisterConfig config) { } - + /** - * setCode. + * Persist instance. * - * @param code code + * @param instance instance */ - public void setCode(final int code) { - this.code = code; - } + void persistInstance(InstanceEntity instance); /** - * getMessage. + * selectInstances. * - * @return message + * @param selectKey selectKey + * @return {@link List} */ - public String getMessage() { - return message; + default List selectInstances(final String selectKey) { + return Collections.emptyList(); } /** - * setMessage. - * - * @param message message + * Close. */ - public void setMessage(final String message) { - this.message = message; + default void close() { } } diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/PropertiesConfig.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/PropertiesConfig.java similarity index 95% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/PropertiesConfig.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/PropertiesConfig.java index 58ee850..50c4bf9 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/PropertiesConfig.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/PropertiesConfig.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.config; +package org.apache.shenyu.client.core.register.config; import java.util.Properties; diff --git a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/RegisterConfig.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/RegisterConfig.java new file mode 100644 index 0000000..b24bdff --- /dev/null +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/RegisterConfig.java @@ -0,0 +1,253 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.shenyu.client.core.register.config; + +import java.util.Map; +import java.util.Objects; +import java.util.Properties; + +/** + * The type Register config. + */ +public class RegisterConfig { + + private boolean enabled; + + private String registerType; + + private String serverLists; + + private Properties props = new Properties(); + + /** + * RegisterConfig. + */ + public RegisterConfig() { + + } + + /** + * registerType. + * + * @param registerType the register type + * @param serverLists the server lists + * @param props the props + */ + public RegisterConfig(final String registerType, final String serverLists, final Properties props) { + this.registerType = registerType; + this.serverLists = serverLists; + this.props = props; + } + + /** + * getRegisterType. + * + * @return String register type + */ + public String getRegisterType() { + return registerType; + } + + /** + * setRegisterType. + * + * @param registerType registerType + */ + public void setRegisterType(final String registerType) { + this.registerType = registerType; + } + + /** + * getServerLists. + * + * @return String server lists + */ + public String getServerLists() { + return serverLists; + } + + /** + * setServerLists. + * + * @param serverLists serverLists + */ + public void setServerLists(final String serverLists) { + this.serverLists = serverLists; + } + + /** + * getProps. + * + * @return String props + */ + public Properties getProps() { + return props; + } + + /** + * setProps. + * + * @param props props + */ + public void setProps(final Properties props) { + this.props = props; + } + + /** + * Gets enabled. + * + * @return the enabled + */ + public boolean getEnabled() { + return enabled; + } + + /** + * Sets enabled. + * + * @param enabled the enabled + */ + public void setEnabled(final boolean enabled) { + this.enabled = enabled; + } + + @Override + public boolean equals(final Object obj) { + if (Objects.isNull(obj)) { + return false; + } + RegisterConfig registerConfig = (RegisterConfig) obj; + if (!this.getRegisterType().equals(registerConfig.getRegisterType())) { + return false; + } + if (!this.getServerLists().equals(registerConfig.getServerLists())) { + return false; + } + if (Objects.isNull(this.getProps()) && Objects.isNull(registerConfig.getProps())) { + return true; + } + if (Objects.isNull(this.getProps()) || Objects.isNull(registerConfig.getProps())) { + return false; + } + if (this.getProps().entrySet().size() != registerConfig.getProps().entrySet().size()) { + return false; + } + for (Map.Entry entry : this.getProps().entrySet()) { + Object newValue = entry.getValue(); + Object oldValue = registerConfig.getProps().get(entry.getKey()); + if (!newValue.equals(oldValue)) { + return false; + } + } + return true; + } + + @Override + public int hashCode() { + int result = Objects.nonNull(getRegisterType()) ? getRegisterType().hashCode() : 0; + result = 31 * result + (Objects.nonNull(getServerLists()) ? getServerLists().hashCode() : 0); + + if (Objects.nonNull(getProps())) { + for (Map.Entry entry : getProps().entrySet()) { + result = 31 * result + (Objects.nonNull(entry.getKey()) ? entry.getKey().hashCode() : 0); + result = 31 * result + (Objects.nonNull(entry.getValue()) ? entry.getValue().hashCode() : 0); + } + } + + return result; + } + + /** + * The type Builder. + */ + public static final class Builder { + + private boolean enabled; + + private String registerType; + + private String serverLists; + + private Properties props; + + private Builder() { + } + + public static Builder builder() { + return new Builder(); + } + + /** + * enabled. + * + * @param enabled enabled + * @return Builder builder + */ + public Builder enabled(final boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * registerType. + * + * @param registerType registerType + * @return Builder builder + */ + public Builder registerType(final String registerType) { + this.registerType = registerType; + return this; + } + + /** + * serverLists. + * + * @param serverLists serverLists + * @return Builder builder + */ + public Builder serverLists(final String serverLists) { + this.serverLists = serverLists; + return this; + } + + /** + * props. + * + * @param props props + * @return Builder builder + */ + public Builder props(final Properties props) { + this.props = props; + return this; + } + + /** + * build. + * + * @return Builder instance register dto + */ + public RegisterConfig build() { + RegisterConfig registerConfig = new RegisterConfig(); + registerConfig.setEnabled(enabled); + registerConfig.setRegisterType(registerType); + registerConfig.setServerLists(serverLists); + registerConfig.setProps(props); + return registerConfig; + } + } +} diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/register/common/config/ShenyuClientConfig.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuClientConfig.java similarity index 90% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/register/common/config/ShenyuClientConfig.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuClientConfig.java index 47e5b2b..7b06adf 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/register/common/config/ShenyuClientConfig.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuClientConfig.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.config; +package org.apache.shenyu.client.core.register.config; + -import org.apache.shenyu.common.exception.ShenyuException; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -32,7 +32,7 @@ public final class ShenyuClientConfig { public ClientPropertiesConfig get(final Object key) { ClientPropertiesConfig config = super.get(key); if (Objects.isNull(key) || Objects.isNull(config)) { - throw new ShenyuException("key is null or invalid, you should checkout property of " + key); + throw new RuntimeException("key is null or invalid, you should checkout property of " + key); } return config; } diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuDiscoveryConfig.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuDiscoveryConfig.java similarity index 97% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuDiscoveryConfig.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuDiscoveryConfig.java index 215488e..b9d901f 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuDiscoveryConfig.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuDiscoveryConfig.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.config; +package org.apache.shenyu.client.core.register.config; /** * The type Discovery config. diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuRegisterCenterConfig.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuRegisterCenterConfig.java similarity index 97% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuRegisterCenterConfig.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuRegisterCenterConfig.java index daf7aeb..a97ff06 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuRegisterCenterConfig.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/config/ShenyuRegisterCenterConfig.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.config; +package org.apache.shenyu.client.core.register.config; import java.util.Properties; diff --git a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/entity/InstanceEntity.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/entity/InstanceEntity.java new file mode 100644 index 0000000..df25dc7 --- /dev/null +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/entity/InstanceEntity.java @@ -0,0 +1,286 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.shenyu.client.core.register.entity; + +import java.net.URI; +import java.util.Objects; + +/** + * The type Instance register dto. + */ +public class InstanceEntity { + + private String appName; + + private String host; + + private Integer port; + + private URI uri; + + private int status; + + private int weight; + + /** + * Instantiates a new Instance register dto. + * + * @param appName the app name + * @param host the host + * @param port the port + */ + public InstanceEntity(final String appName, final String host, final Integer port) { + this.appName = appName; + this.host = host; + this.port = port; + } + + /** + * Instantiates a new Instance register dto. + */ + public InstanceEntity() { + } + + private InstanceEntity(final Builder builder) { + appName = builder.appName; + host = builder.host; + port = builder.port; + uri = builder.uri; + } + + + /** + * return builder. + * + * @return Builder builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * getAppName. + * + * @return String app name + */ + public String getAppName() { + return appName; + } + + /** + * setAppName. + * + * @param appName appName + */ + public void setAppName(final String appName) { + this.appName = appName; + } + + /** + * getHost. + * + * @return String host + */ + public String getHost() { + return host; + } + + /** + * setHost. + * + * @param host host + */ + public void setHost(final String host) { + this.host = host; + } + + /** + * getPort. + * + * @return String port + */ + public Integer getPort() { + return port; + } + + /** + * setPort. + * + * @param port port + */ + public void setPort(final Integer port) { + this.port = port; + } + + /** + * getUri. + * + * @return URI uri + */ + public URI getUri() { + return uri; + } + + /** + * setUri. + * + * @param uri uri + */ + public void setUri(final URI uri) { + this.uri = uri; + } + + /** + * status. + * + * @return Status + */ + public int getStatus() { + return status; + } + + /** + * set status. + * + * @param status status + */ + public void setStatus(final int status) { + this.status = status; + } + + /** + * weight. + * + * @return Weight + */ + public int getWeight() { + return weight; + } + + /** + * set weight. + * + * @param weight weight + */ + public void setWeight(final int weight) { + this.weight = weight; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return Boolean.TRUE; + } + + if (Objects.isNull(o) || getClass() != o.getClass()) { + return Boolean.FALSE; + } + + InstanceEntity that = (InstanceEntity) o; + return Objects.equals(getAppName(), that.getAppName()) + && Objects.equals(getHost(), that.getHost()) + && Objects.equals(getPort(), that.getPort()); + } + + @Override + public int hashCode() { + return Objects.hash(getAppName(), getHost(), getPort()); + } + + @Override + public String toString() { + return "URIRegisterDTO{" + + "appName='" + + appName + + ", host='" + + host + + ", port=" + + port + + '}'; + } + + /** + * The type Builder. + */ + public static final class Builder { + + private String appName; + + private String host; + + private Integer port; + + private URI uri; + + private Builder() { + } + + /** + * appName. + * + * @param appName appName + * @return Builder builder + */ + public Builder appName(final String appName) { + this.appName = appName; + return this; + } + + /** + * host. + * + * @param host host + * @return Builder builder + */ + public Builder host(final String host) { + this.host = host; + return this; + } + + /** + * port. + * + * @param port port + * @return Builder builder + */ + public Builder port(final Integer port) { + this.port = port; + return this; + } + + /** + * uri. + * + * @param uri uri + * @return Builder builder + */ + public Builder uri(final URI uri) { + this.uri = uri; + return this; + } + + /** + * build. + * + * @return Builder instance register dto + */ + public InstanceEntity build() { + return new InstanceEntity(this); + } + } +} diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/ApiBeansExtractor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/ApiBeansExtractor.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/ApiBeansExtractor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/ApiBeansExtractor.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/BaseAnnotationApiBeansExtractor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/BaseAnnotationApiBeansExtractor.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/BaseAnnotationApiBeansExtractor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/BaseAnnotationApiBeansExtractor.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/BaseApiBeansExtractor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/BaseApiBeansExtractor.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/BaseApiBeansExtractor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/BaseApiBeansExtractor.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/MultiClientApiBeansExtractorImpl.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/MultiClientApiBeansExtractorImpl.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/MultiClientApiBeansExtractorImpl.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/MultiClientApiBeansExtractorImpl.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/RpcApiBeansExtractor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/RpcApiBeansExtractor.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/extractor/RpcApiBeansExtractor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/extractor/RpcApiBeansExtractor.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/AnnotatedApiBeanMatcher.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/AnnotatedApiBeanMatcher.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/AnnotatedApiBeanMatcher.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/AnnotatedApiBeanMatcher.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/AnnotatedApiDefinitionMatcher.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/AnnotatedApiDefinitionMatcher.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/AnnotatedApiDefinitionMatcher.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/AnnotatedApiDefinitionMatcher.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiAnnotationProcessor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiAnnotationProcessor.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiAnnotationProcessor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiAnnotationProcessor.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiBeanMatcher.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiBeanMatcher.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiBeanMatcher.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiBeanMatcher.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiBeanProcessor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiBeanProcessor.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiBeanProcessor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiBeanProcessor.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDefinitionMatcher.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDefinitionMatcher.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDefinitionMatcher.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDefinitionMatcher.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDocProcessorImpl.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDocProcessorImpl.java similarity index 94% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDocProcessorImpl.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDocProcessorImpl.java index 6ec000e..c58ec64 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDocProcessorImpl.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiDocProcessorImpl.java @@ -18,9 +18,9 @@ package org.apache.shenyu.client.core.register.matcher; import org.apache.shenyu.client.apidocs.annotations.ApiDoc; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.common.utils.ListUtil; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.utils.ListUtil; import java.util.List; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiRegisterProcessor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiRegisterProcessor.java similarity index 93% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiRegisterProcessor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiRegisterProcessor.java index 56e093b..13639c4 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiRegisterProcessor.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ApiRegisterProcessor.java @@ -18,8 +18,8 @@ package org.apache.shenyu.client.core.register.matcher; import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.common.utils.ListUtil; -import org.apache.shenyu.register.common.type.DataTypeParent; +import org.apache.shenyu.client.core.type.DataTypeParent; +import org.apache.shenyu.client.core.utils.ListUtil; import java.util.List; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/BaseAnnotationApiProcessor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/BaseAnnotationApiProcessor.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/BaseAnnotationApiProcessor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/BaseAnnotationApiProcessor.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ExtractorProcessor.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ExtractorProcessor.java similarity index 96% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ExtractorProcessor.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ExtractorProcessor.java index 6753d4f..6ca1255 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ExtractorProcessor.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/ExtractorProcessor.java @@ -17,7 +17,9 @@ package org.apache.shenyu.client.core.register.matcher; -import org.apache.shenyu.common.enums.RpcTypeEnum; + + +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import java.util.Arrays; import java.util.List; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/Matcher.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/Matcher.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/matcher/Matcher.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/matcher/Matcher.java diff --git a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/path/InstancePathConstants.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/path/InstancePathConstants.java new file mode 100644 index 0000000..6443238 --- /dev/null +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/path/InstancePathConstants.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.shenyu.client.core.register.path; + +/** + * zookeeper register center. + */ +public class InstancePathConstants { + + /** + * root path of zookeeper register center. + */ + public static final String ROOT_PATH = "/shenyu/register"; + + /** + * constants of separator. + */ + private static final String SEPARATOR = "/"; + + /** + * Dot separator. + */ + private static final String DOT_SEPARATOR = "."; + + /** + * Build instance parent path string. + * build child path of "/shenyu/register/instance/ + * + * @return the string + */ + public static String buildInstanceParentPath() { + return String.join(SEPARATOR, ROOT_PATH, "instance"); + } + + /** + * Build instance parent path string. + * build child path of "/shenyu/register/instance/serviceName + * + * @param serviceName serviceName + * @return the string + */ + public static String buildInstanceParentPath(final String serviceName) { + return String.join(SEPARATOR, ROOT_PATH, "instance", serviceName); + } + + /** + * Build real node string. + * + * @param nodePath the node path + * @param nodeName the node name + * @return the string + */ + public static String buildRealNode(final String nodePath, final String nodeName) { + return String.join(SEPARATOR, nodePath, nodeName); + } +} diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java similarity index 92% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java index 767054a..771e861 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java @@ -24,24 +24,25 @@ import org.apache.shenyu.client.apidocs.annotations.ApiModule; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.ApiSourceEnum; +import org.apache.shenyu.client.core.enums.ApiStateEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; import org.apache.shenyu.client.core.register.matcher.AnnotatedApiBeanMatcher; import org.apache.shenyu.client.core.register.matcher.AnnotatedApiDefinitionMatcher; import org.apache.shenyu.client.core.register.matcher.Matcher; +import org.apache.shenyu.client.core.utils.GsonUtils; import org.apache.shenyu.client.core.utils.OpenApiUtils; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.ApiSourceEnum; -import org.apache.shenyu.common.enums.ApiStateEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.common.utils.PathUtils; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; +import org.apache.shenyu.client.core.utils.PathUtils; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -131,7 +132,9 @@ private String buildDocumentJson(final List tags, final String path, fin .put("tags", tags) .put("operationId", path) .put("parameters", OpenApiUtils.generateDocumentParameters(path, method)) - .put("responses", OpenApiUtils.generateDocumentResponse(path)).build(); + .put("responses", OpenApiUtils.generateDocumentResponse(path)) + .put("responseType", Collections.singletonList(OpenApiUtils.parseReturnType(method))) + .build(); return GsonUtils.getInstance().toJson(documentMap); } diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiMetaRegistrar.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiMetaRegistrar.java similarity index 94% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiMetaRegistrar.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiMetaRegistrar.java index 107b4f3..e045d0d 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiMetaRegistrar.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiMetaRegistrar.java @@ -18,7 +18,7 @@ package org.apache.shenyu.client.core.register.registrar; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; public abstract class AbstractApiMetaRegistrar extends AbstractApiRegistrar { diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiRegistrar.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiRegistrar.java similarity index 98% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiRegistrar.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiRegistrar.java index e987049..b7d4dc5 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiRegistrar.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiRegistrar.java @@ -19,7 +19,8 @@ import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.register.common.type.DataTypeParent; +import org.apache.shenyu.client.core.type.DataTypeParent; + import java.util.List; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java similarity index 92% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java index 1e0cc2d..3fbe98e 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java @@ -21,18 +21,18 @@ import org.apache.commons.lang3.StringUtils; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.ApiSourceEnum; +import org.apache.shenyu.client.core.enums.ApiStateEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; import org.apache.shenyu.client.core.utils.ApiBeanUtil; +import org.apache.shenyu.client.core.utils.GsonUtils; import org.apache.shenyu.client.core.utils.OpenApiUtils; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.ApiSourceEnum; -import org.apache.shenyu.common.enums.ApiStateEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.common.utils.PathUtils; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; +import org.apache.shenyu.client.core.utils.PathUtils; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -136,7 +136,9 @@ private String getDocument(final ApiBean.ApiDefinition api) { .put("tags", buildTags(api)) .put("operationId", path) .put("parameters", OpenApiUtils.generateDocumentParameters(path, api.getApiMethod())) - .put("responses", OpenApiUtils.generateDocumentResponse(path)).build(); + .put("responses", OpenApiUtils.generateDocumentResponse(path)) + .put("responseType", Collections.singletonList(OpenApiUtils.parseReturnType(api.getApiMethod()))) + .build(); return GsonUtils.getInstance().toJson(documentMap); } diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiRegistrar.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiRegistrar.java similarity index 95% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiRegistrar.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiRegistrar.java index 0973b3f..2ace900 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiRegistrar.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiRegistrar.java @@ -18,7 +18,7 @@ package org.apache.shenyu.client.core.register.registrar; import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.register.common.type.DataTypeParent; +import org.apache.shenyu.client.core.type.DataTypeParent; import java.util.List; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/BaseApiRegistrarImpl.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/BaseApiRegistrarImpl.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/BaseApiRegistrarImpl.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/BaseApiRegistrarImpl.java diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrar.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrar.java similarity index 97% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrar.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrar.java index 32d27f1..127dc49 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrar.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrar.java @@ -19,9 +19,9 @@ import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/MateDataApiRegistrarImpl.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/MateDataApiRegistrarImpl.java similarity index 98% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/MateDataApiRegistrarImpl.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/MateDataApiRegistrarImpl.java index e887d1a..42cba55 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/MateDataApiRegistrarImpl.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/MateDataApiRegistrarImpl.java @@ -19,10 +19,10 @@ import org.apache.commons.lang3.StringUtils; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.common.utils.PathUtils; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.utils.PathUtils; import org.jetbrains.annotations.NotNull; /** diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrar.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrar.java similarity index 96% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrar.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrar.java index dff8cff..ac5237f 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrar.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrar.java @@ -20,9 +20,10 @@ import com.google.common.collect.Lists; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; + import java.util.List; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/UriApiRegistrarImplImpl.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/UriApiRegistrarImplImpl.java similarity index 96% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/UriApiRegistrarImplImpl.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/UriApiRegistrarImplImpl.java index c987428..20cd8df 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/register/registrar/UriApiRegistrarImplImpl.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/UriApiRegistrarImplImpl.java @@ -18,11 +18,11 @@ package org.apache.shenyu.client.core.register.registrar; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.EventType; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; import org.apache.shenyu.client.core.utils.ApiBeanUtil; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; /** * UriApiRegistrarImplImpl. diff --git a/shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/retry/FailureRegistryTask.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/retry/FailureRegistryTask.java similarity index 88% rename from shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/retry/FailureRegistryTask.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/retry/FailureRegistryTask.java index 6d0215e..333a350 100644 --- a/shenyu-register-java-client/shenyu-register-java-client-api/src/main/java/org/apache/shenyu/register/client/api/retry/FailureRegistryTask.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/retry/FailureRegistryTask.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.shenyu.register.client.api.retry; +package org.apache.shenyu.client.core.register.retry; -import org.apache.shenyu.common.timer.AbstractRetryTask; -import org.apache.shenyu.common.timer.TimerTask; -import org.apache.shenyu.register.client.api.FailbackRegistryRepository; + +import org.apache.shenyu.client.core.register.FailbackRegistryRepository; +import org.apache.shenyu.client.core.timer.AbstractRetryTask; +import org.apache.shenyu.client.core.timer.TimerTask; import java.util.concurrent.TimeUnit; diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/AbstractQueueConsumerFactory.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/AbstractQueueConsumerFactory.java similarity index 93% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/AbstractQueueConsumerFactory.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/AbstractQueueConsumerFactory.java index 50470bc..a758db7 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/AbstractQueueConsumerFactory.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/AbstractQueueConsumerFactory.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.subsriber; +package org.apache.shenyu.client.core.register.subsriber; +import org.apache.shenyu.client.core.type.DataTypeParent; import org.apache.shenyu.disruptor.consumer.QueueConsumerFactory; -import org.apache.shenyu.register.common.type.DataTypeParent; import java.util.HashSet; import java.util.Set; diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/ExecutorSubscriber.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/ExecutorSubscriber.java similarity index 94% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/ExecutorSubscriber.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/ExecutorSubscriber.java index 40be7d2..cd99aea 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/ExecutorSubscriber.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/ExecutorSubscriber.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.subsriber; +package org.apache.shenyu.client.core.register.subsriber; import java.util.Collection; diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/ExecutorTypeSubscriber.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/ExecutorTypeSubscriber.java similarity index 86% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/ExecutorTypeSubscriber.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/ExecutorTypeSubscriber.java index faac0ea..86e2892 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/subsriber/ExecutorTypeSubscriber.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/subsriber/ExecutorTypeSubscriber.java @@ -15,10 +15,11 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.subsriber; +package org.apache.shenyu.client.core.register.subsriber; -import org.apache.shenyu.register.common.type.DataType; -import org.apache.shenyu.register.common.type.DataTypeParent; + +import org.apache.shenyu.client.core.type.DataType; +import org.apache.shenyu.client.core.type.DataTypeParent; /** * The interface Executor type subscriber. diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShenyuClientShutdownHook.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShenyuClientShutdownHook.java similarity index 97% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShenyuClientShutdownHook.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShenyuClientShutdownHook.java index 0472018..06a1043 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShenyuClientShutdownHook.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShenyuClientShutdownHook.java @@ -25,8 +25,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShutdownHookManager.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShutdownHookManager.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShutdownHookManager.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShutdownHookManager.java diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/AbstractRetryTask.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/AbstractRetryTask.java similarity index 98% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/AbstractRetryTask.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/AbstractRetryTask.java index 97842c9..8628d7c 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/AbstractRetryTask.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/AbstractRetryTask.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/AbstractRoundTask.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/AbstractRoundTask.java similarity index 97% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/AbstractRoundTask.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/AbstractRoundTask.java index 31dfe2b..3190f64 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/AbstractRoundTask.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/AbstractRoundTask.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/HierarchicalWheelTimer.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/HierarchicalWheelTimer.java similarity index 97% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/HierarchicalWheelTimer.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/HierarchicalWheelTimer.java index fb3502a..9f1540e 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/HierarchicalWheelTimer.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/HierarchicalWheelTimer.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; -import java.util.Objects; -import org.apache.shenyu.common.concurrent.ShenyuThreadFactory; +import org.apache.shenyu.client.core.utils.ShenyuThreadFactory; + +import java.util.Objects; import java.util.concurrent.DelayQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; @@ -82,7 +83,7 @@ public HierarchicalWheelTimer(final String executorName, final Long startMs) { ThreadFactory threadFactory = ShenyuThreadFactory.create(executorName, false); taskExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(), threadFactory); + new LinkedBlockingQueue<>(), threadFactory); workerThread = threadFactory.newThread(new Worker(this)); timingWheel = new TimingWheel(tickMs, wheelSize, startMs, taskCounter, delayQueue); } diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TaskEntity.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TaskEntity.java similarity index 96% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TaskEntity.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TaskEntity.java index 0a675e5..d32db51 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TaskEntity.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TaskEntity.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; /** * TimerEntity . diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/Timer.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/Timer.java similarity index 96% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/Timer.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/Timer.java index 47a58a9..4791b1d 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/Timer.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/Timer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; /** * Timer . diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimerTask.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimerTask.java similarity index 98% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimerTask.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimerTask.java index d8e1868..9f6de84 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimerTask.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimerTask.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; import java.util.Objects; import java.util.concurrent.TimeUnit; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimerTaskList.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimerTaskList.java similarity index 99% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimerTaskList.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimerTaskList.java index 7c7b3d3..4a0b831 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimerTaskList.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimerTaskList.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; import java.util.Iterator; import java.util.Objects; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimingWheel.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimingWheel.java similarity index 98% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimingWheel.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimingWheel.java index 30ce34b..47ec47d 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/TimingWheel.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/TimingWheel.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; import java.util.Objects; import java.util.concurrent.DelayQueue; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/WheelTimerFactory.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/WheelTimerFactory.java similarity index 98% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/WheelTimerFactory.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/WheelTimerFactory.java index 59feb6b..c9ceebc 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/timer/WheelTimerFactory.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/timer/WheelTimerFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.timer; +package org.apache.shenyu.client.core.timer; import java.util.Objects; diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/type/DataType.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/type/DataType.java similarity index 91% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/type/DataType.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/type/DataType.java index 37ddf62..f9eae28 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/type/DataType.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/type/DataType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.type; +package org.apache.shenyu.client.core.type; /** * The enum Data type enum. @@ -37,6 +37,11 @@ public enum DataType { */ API_DOC, + /** + * Heartbeat type enum. + */ + HEARTBEAT, + /** * Discovery config type enum. */ diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/type/DataTypeParent.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/type/DataTypeParent.java similarity index 95% rename from shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/type/DataTypeParent.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/type/DataTypeParent.java index 1d26750..6dc1173 100644 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/type/DataTypeParent.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/type/DataTypeParent.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.common.type; +package org.apache.shenyu.client.core.type; /** * The interface Data type parent. diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/AesUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/AesUtils.java similarity index 95% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/AesUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/AesUtils.java index 33de5d9..5104401 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/AesUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/AesUtils.java @@ -15,19 +15,19 @@ * limitations under the License. */ -package org.apache.shenyu.common.utils; +package org.apache.shenyu.client.core.utils; + +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.nio.charset.StandardCharsets; -import java.security.Security; -import java.util.Base64; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -import org.apache.shenyu.common.exception.ShenyuException; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.nio.charset.StandardCharsets; +import java.security.Security; +import java.util.Base64; /** * AesUtils. @@ -58,7 +58,7 @@ public static String cbcEncrypt(final String secretKeyStr, final String ivStr, f encryptStr = Base64.getEncoder().encodeToString(encryptedBytes); } catch (Exception e) { LOG.error("aes encrypt fail. cause:{}", e.getMessage()); - throw new ShenyuException(e); + throw new RuntimeException(e); } return encryptStr; } @@ -85,7 +85,7 @@ public static String cbcDecrypt(final String secretKeyStr, final String ivStr, f decryptStr = new String(decryptedBytes); } catch (Exception e) { LOG.error("aes decrypt fail. cause:{}", e.getMessage()); - throw new ShenyuException(e); + throw new RuntimeException(e); } return decryptStr; } diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/ApiBeanUtil.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ApiBeanUtil.java similarity index 97% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/ApiBeanUtil.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ApiBeanUtil.java index ad4ca14..5198ab3 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/ApiBeanUtil.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ApiBeanUtil.java @@ -18,8 +18,8 @@ package org.apache.shenyu.client.core.utils; import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.common.enums.RpcTypeEnum; import java.util.Objects; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/GsonUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/GsonUtils.java similarity index 98% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/GsonUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/GsonUtils.java index 2471dfe..4f0a67f 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/GsonUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/GsonUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.utils; +package org.apache.shenyu.client.core.utils; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -37,8 +37,7 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.exception.ShenyuException; +import org.apache.shenyu.client.core.constant.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -357,7 +356,7 @@ public Map deserialize(final JsonElement json, final Type type, final Json } Map resultMap = null; - assert Objects.nonNull(mapClass); + Objects.requireNonNull(mapClass); if (Objects.requireNonNull(mapClass).isInterface()) { resultMap = new LinkedHashMap<>(); } else { @@ -437,7 +436,7 @@ public String read(final JsonReader reader) { } return reader.nextString(); } catch (IOException e) { - throw new ShenyuException(e); + throw new RuntimeException(e); } } } @@ -501,7 +500,7 @@ public Duration read(final JsonReader reader) { } return Duration.parse(reader.nextString()); } catch (IOException e) { - throw new ShenyuException(e); + throw new RuntimeException(e); } } } diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/IpUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/IpUtils.java similarity index 99% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/IpUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/IpUtils.java index ca3ea37..d03a0c2 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/IpUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/IpUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.utils; +package org.apache.shenyu.client.core.utils; import org.apache.commons.lang3.StringUtils; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ListUtil.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ListUtil.java similarity index 97% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ListUtil.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ListUtil.java index ba23cfd..8f9f323 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ListUtil.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ListUtil.java @@ -15,9 +15,10 @@ * limitations under the License. */ -package org.apache.shenyu.common.utils; +package org.apache.shenyu.client.core.utils; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; import java.util.Collection; import java.util.Collections; @@ -185,8 +186,7 @@ public static Set mergeSet(final Set set1, final Set set2) { * @return list1 */ public static List merge(final List list1, final List list2) { - list1.addAll(list2); - return list1; + return ListUtils.union(list1, list2); } /** diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OkHttpTools.java similarity index 97% rename from shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OkHttpTools.java index e9e24f6..200cfc3 100644 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OkHttpTools.java @@ -15,15 +15,16 @@ * limitations under the License. */ -package org.apache.shenyu.register.client.http.utils; +package org.apache.shenyu.client.core.utils; +import okhttp3.Headers; +import okhttp3.HttpUrl; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import org.apache.shenyu.common.constant.Constants; +import org.apache.shenyu.client.core.constant.Constants; + import java.io.IOException; import java.util.Map; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java similarity index 51% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java index 81e8612..5affbce 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java @@ -25,10 +25,25 @@ import org.springframework.web.bind.annotation.RequestPart; import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.GenericArrayType; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.lang.reflect.WildcardType; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * openApiUtils. @@ -150,6 +165,210 @@ public static Map generateDocumentResponse(final String path) { .build(); } + /** + * Perhaps a better way is to generate API documentation through OpenAPI annotations. + * + * @param method the method + * @return return type + */ + public static ResponseType parseReturnType(final Method method) { + Type returnType = method.getGenericReturnType(); + return parseType("ROOT", returnType, 0, new HashMap<>(16)); + } + + private static ResponseType parseType(final String name, final Type type, final int depth, final Map, Type> typeVariableMap) { + ResponseType responseType = new ResponseType(); + if (StringUtils.isBlank(name)) { + responseType.setName(type.getTypeName()); + } else { + responseType.setName(name); + } + if (depth > 5) { + responseType.setType("object"); + return responseType; + } + if (type instanceof Class) { + return parseClass(responseType, (Class) type, depth, typeVariableMap); + } else if (type instanceof ParameterizedType) { + return parseParameterizedType(responseType, (ParameterizedType) type, depth, typeVariableMap); + } else if (type instanceof GenericArrayType) { + return parseGenericArrayType(responseType, (GenericArrayType) type, depth, typeVariableMap); + } else if (type instanceof TypeVariable) { + Type actualType = typeVariableMap.get(type); + if (Objects.nonNull(actualType)) { + return parseType(name, actualType, depth, typeVariableMap); + } else if (((TypeVariable) type).getBounds().length > 0) { + Type upperBound = ((TypeVariable) type).getBounds()[0]; + return parseType(name, upperBound, depth, typeVariableMap); + } else { + responseType.setType("object"); + return responseType; + } + } else if (type instanceof WildcardType) { + responseType.setType("object"); + return responseType; + } else { + responseType.setType("object"); + return responseType; + } + } + + private static ResponseType parseClass(final ResponseType responseType, final Class clazz, final int depth, final Map, Type> typeVariableMap) { + if (clazz.isArray()) { + responseType.setType("array"); + responseType.setRefs(Collections.singletonList(parseType("ITEMS", clazz.getComponentType(), depth + 1, typeVariableMap))); + return responseType; + } else if (clazz.isEnum()) { + responseType.setType("string"); + return responseType; + } else if (isBooleanType(clazz)) { + responseType.setType("boolean"); + return responseType; + } else if (isIntegerType(clazz)) { + responseType.setType("integer"); + return responseType; + } else if (isNumberType(clazz)) { + responseType.setType("number"); + return responseType; + } else if (isStringType(clazz)) { + responseType.setType("string"); + return responseType; + } else if (isDateType(clazz)) { + responseType.setType("date"); + return responseType; + } else { + List refs = new ArrayList<>(); + for (Field field : clazz.getDeclaredFields()) { + if (Modifier.isStatic(field.getModifiers())) { + continue; + } + refs.add(parseType(field.getName(), field.getGenericType(), depth + 1, typeVariableMap)); + } + responseType.setType("object"); + responseType.setRefs(refs); + return responseType; + } + } + + private static ResponseType parseParameterizedType(final ResponseType responseType, final ParameterizedType type, final int depth, final Map, Type> typeVariableMap) { + Class rawType = (Class) type.getRawType(); + Type[] actualTypeArguments = type.getActualTypeArguments(); + TypeVariable[] typeVariables = rawType.getTypeParameters(); + Map, Type> newTypeVariableMap = new HashMap<>(typeVariableMap); + for (int i = 0; i < typeVariables.length; i++) { + newTypeVariableMap.put(typeVariables[i], actualTypeArguments[i]); + } + if (Collection.class.isAssignableFrom(rawType)) { + Type actualType = actualTypeArguments[0]; + ResponseType elementParam = parseType("ITEMS", actualType, depth + 1, newTypeVariableMap); + responseType.setRefs(Collections.singletonList(elementParam)); + responseType.setType("array"); + return responseType; + } else if (Map.class.isAssignableFrom(rawType)) { + Type keyType = actualTypeArguments[0]; + Type valueType = actualTypeArguments[1]; + ResponseType keyParam = parseType("key", keyType, depth + 1, newTypeVariableMap); + ResponseType valueParam = parseType("value", valueType, depth + 1, newTypeVariableMap); + List children = new ArrayList<>(); + children.add(keyParam); + children.add(valueParam); + responseType.setRefs(children); + responseType.setType("map"); + return responseType; + } else { + List refs = new ArrayList<>(); + for (Field field : rawType.getDeclaredFields()) { + if (Modifier.isStatic(field.getModifiers())) { + continue; + } + ResponseType fieldParam = parseType(field.getName(), field.getGenericType(), depth + 1, newTypeVariableMap); + refs.add(fieldParam); + } + responseType.setType("object"); + responseType.setRefs(refs); + return responseType; + } + } + + private static ResponseType parseGenericArrayType(final ResponseType responseType, final GenericArrayType type, final int depth, final Map, Type> typeVariableMap) { + responseType.setRefs(Collections.singletonList(parseType("ITEMS", type.getGenericComponentType(), depth + 1, typeVariableMap))); + responseType.setType("array"); + return responseType; + } + + private static boolean isDateType(final Class clazz) { + return clazz == Date.class || clazz == LocalDate.class + || clazz == LocalDateTime.class || clazz == LocalTime.class; + } + + private static boolean isStringType(final Class clazz) { + return CharSequence.class.isAssignableFrom(clazz) || clazz == char.class + || clazz == Character.class; + } + + private static boolean isBooleanType(final Class clazz) { + return clazz == boolean.class || clazz == Boolean.class; + } + + private static boolean isIntegerType(final Class clazz) { + return clazz == byte.class || clazz == Byte.class + || clazz == short.class || clazz == Short.class + || clazz == int.class || clazz == Integer.class + || clazz == long.class || clazz == Long.class; + } + + private static boolean isNumberType(final Class clazz) { + return clazz == float.class || clazz == Float.class + || clazz == double.class || clazz == Double.class; + } + + public static class ResponseType { + + private String name; + + private String description; + + private String type; + + /** + * child fields. + */ + private List refs; + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(final String type) { + this.type = type; + } + + public List getRefs() { + return refs; + } + + public void setRefs(final List refs) { + this.refs = refs; + } + } + + public static class Parameter { private String name; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/PathUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/PathUtils.java similarity index 78% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/PathUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/PathUtils.java index 0782fc4..2e45409 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/PathUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/PathUtils.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.shenyu.common.utils; +package org.apache.shenyu.client.core.utils; import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.common.constant.AdminConstants; -import org.apache.shenyu.common.constant.Constants; +import org.apache.shenyu.client.core.constant.Constants; import org.checkerframework.checker.nullness.qual.NonNull; /** @@ -34,7 +33,7 @@ public final class PathUtils { * @return the string */ public static String decoratorPath(final String contextPath) { - return StringUtils.contains(contextPath, AdminConstants.URI_SUFFIX) ? contextPath : contextPath + AdminConstants.URI_SUFFIX; + return StringUtils.contains(contextPath, Constants.URI_SUFFIX) ? contextPath : contextPath + Constants.URI_SUFFIX; } /** @@ -44,7 +43,7 @@ public static String decoratorPath(final String contextPath) { * @return the string */ public static String decoratorContextPath(final String contextPath) { - return StringUtils.contains(contextPath, AdminConstants.URI_SUFFIX) ? StringUtils.substringBefore(contextPath, AdminConstants.URI_SUFFIX) : contextPath; + return StringUtils.contains(contextPath, Constants.URI_SUFFIX) ? StringUtils.substringBefore(contextPath, Constants.URI_SUFFIX) : contextPath; } /** @@ -54,7 +53,7 @@ public static String decoratorContextPath(final String contextPath) { * @return the string */ public static String decoratorPathWithSlash(final String contextPath) { - return StringUtils.endsWith(contextPath, AdminConstants.URI_SLASH_SUFFIX) ? contextPath : contextPath + AdminConstants.URI_SLASH_SUFFIX; + return StringUtils.endsWith(contextPath, Constants.URI_SLASH_SUFFIX) ? contextPath : contextPath + Constants.URI_SLASH_SUFFIX; } /** diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/PortUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/PortUtils.java similarity index 96% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/PortUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/PortUtils.java index c8e1363..f151162 100644 --- a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/PortUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/PortUtils.java @@ -18,7 +18,6 @@ package org.apache.shenyu.client.core.utils; import org.apache.commons.collections4.CollectionUtils; -import org.apache.shenyu.common.exception.ShenyuException; import org.springframework.beans.factory.BeanFactory; import javax.management.MBeanServer; @@ -44,7 +43,7 @@ public class PortUtils { * * @param beanFactory beanFactory * @return port number - * @throws ShenyuException when can not find port + * @throws RuntimeException when failed to get port */ @SuppressWarnings("all") public static int findPort(final BeanFactory beanFactory) { @@ -62,7 +61,7 @@ public static int findPort(final BeanFactory beanFactory) { //works for springmvc with external tomcat return PortUtils.getPort(); } catch (Exception e) { - throw new ShenyuException("can not find port automatically ! "); + throw new RuntimeException("can not find port automatically ! "); } } diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ReflectUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ReflectUtils.java similarity index 97% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ReflectUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ReflectUtils.java index 5ce414f..4d1d976 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ReflectUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ReflectUtils.java @@ -15,12 +15,11 @@ * limitations under the License. */ -package org.apache.shenyu.common.utils; +package org.apache.shenyu.client.core.utils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.reflect.MethodUtils; -import org.apache.shenyu.common.exception.ShenyuException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -158,7 +157,7 @@ public static void setFieldValue(final Object obj, final String fieldName, final field.set(obj, value); } catch (IllegalAccessException e) { LOG.error("Failed to assign to the element.", e); - throw new ShenyuException(e.getMessage()); + throw new RuntimeException(e.getMessage()); } } diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/RegisterUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/RegisterUtils.java similarity index 78% rename from shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/RegisterUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/RegisterUtils.java index 11889d0..544c511 100644 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/RegisterUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/RegisterUtils.java @@ -15,13 +15,12 @@ * limitations under the License. */ -package org.apache.shenyu.register.client.http.utils; +package org.apache.shenyu.client.core.utils; import okhttp3.Headers; import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.exception.CommonErrorCode; -import org.apache.shenyu.common.utils.GsonUtils; +import org.apache.shenyu.client.core.constant.Constants; +import org.apache.shenyu.client.core.exception.CommonErrorCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +30,6 @@ import java.util.Objects; import java.util.Optional; -import static org.apache.shenyu.common.constant.Constants.SUCCESS; /** * RegisterUtils. @@ -59,7 +57,7 @@ public static void doRegister(final String json, final String url, final String } Headers headers = new Headers.Builder().add(Constants.X_ACCESS_TOKEN, accessToken).build(); String result = OkHttpTools.getInstance().post(url, json, headers); - if (Objects.equals(SUCCESS, result)) { + if (Objects.equals(Constants.SUCCESS, result)) { LOGGER.info("{} client register success: {} ", type, json); } else { LOGGER.error("{} client register error: {} ", type, json); @@ -76,12 +74,35 @@ public static void doRegister(final String json, final String url, final String */ public static void doRegister(final String json, final String url, final String type) throws IOException { String result = OkHttpTools.getInstance().post(url, json); - if (Objects.equals(SUCCESS, result)) { + if (Objects.equals(Constants.SUCCESS, result)) { LOGGER.info("{} client register success: {} ", type, json); } else { LOGGER.error("{} client register error: {} ", type, json); } } + + /** + * Do heartbeat. + * + * @param json the json + * @param url the url + * @param type the type + * @param accessToken the token + * @throws IOException the io exception + */ + public static void doHeartBeat(final String json, final String url, final String type, final String accessToken) throws IOException { + if (StringUtils.isBlank(accessToken)) { + LOGGER.error("{} client heartbeat error accessToken is null, please check the config : {} ", type, json); + return; + } + Headers headers = new Headers.Builder().add(Constants.X_ACCESS_TOKEN, accessToken).build(); + String result = OkHttpTools.getInstance().post(url, json, headers); + if (Objects.equals(Constants.SUCCESS, result)) { + LOGGER.info("{} success: {} ", type, json); + } else { + LOGGER.error("{} error: {} ", type, json); + } + } /** * Do unregister. @@ -98,7 +119,7 @@ public static void doUnregister(final String json, final String url, final Strin } Headers headers = new Headers.Builder().add(Constants.X_ACCESS_TOKEN, accessToken).build(); String result = OkHttpTools.getInstance().post(url, json, headers); - if (Objects.equals(SUCCESS, result)) { + if (Objects.equals(Constants.SUCCESS, result)) { LOGGER.info("{} client unregister success: {} ", Constants.URI, json); } else { LOGGER.error("{} client unregister error: {} ", Constants.URI, json); diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/RuntimeUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/RuntimeUtils.java similarity index 98% rename from shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/RuntimeUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/RuntimeUtils.java index 5812307..cc0e015 100644 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/RuntimeUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/RuntimeUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.client.http.utils; +package org.apache.shenyu.client.core.utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactory.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ShenyuThreadFactory.java similarity index 98% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactory.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ShenyuThreadFactory.java index c573461..2ddade5 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactory.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/ShenyuThreadFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.concurrent; +package org.apache.shenyu.client.core.utils; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicLong; diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/SystemUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/SystemUtils.java similarity index 97% rename from shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/SystemUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/SystemUtils.java index 1b20697..fa890ca 100644 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/SystemUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/SystemUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.register.client.http.utils; +package org.apache.shenyu.client.core.utils; import java.lang.management.ManagementFactory; import java.util.Optional; diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UriUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/UriUtils.java similarity index 97% rename from shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UriUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/UriUtils.java index 6adf4df..c7cca0a 100644 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UriUtils.java +++ b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/UriUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shenyu.common.utils; +package org.apache.shenyu.client.core.utils; import org.apache.commons.lang3.StringUtils; @@ -112,7 +112,7 @@ public static String appendScheme(final String url, final String scheme) { */ public static int getActualPort(final String scheme, final Integer port) { Integer actualPort = port; - if (Objects.isNull(port) || port.intValue() < 0) { + if (Objects.isNull(port) || port < 0) { if (!"http".equals(scheme) && !"ws".equals(scheme)) { if ("https".equals(scheme) || "wss".equals(scheme)) { actualPort = 443; diff --git a/shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/UrlPathUtils.java b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/UrlPathUtils.java similarity index 100% rename from shenyu-client-java-core/src/main/java/org/apache/shenyu/client/core/utils/UrlPathUtils.java rename to shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/UrlPathUtils.java diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriberTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriberTest.java similarity index 92% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriberTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriberTest.java index 7c51d33..cc9d5fc 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriberTest.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientApiDocExecutorSubscriberTest.java @@ -17,10 +17,10 @@ package org.apache.shenyu.client.core.disruptor.subcriber; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; -import org.apache.shenyu.register.common.type.DataType; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.type.DataType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriberTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriberTest.java similarity index 94% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriberTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriberTest.java index 42e6f29..d33bc86 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriberTest.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientMetadataExecutorSubscriberTest.java @@ -17,9 +17,9 @@ package org.apache.shenyu.client.core.disruptor.subcriber; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.type.DataType; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.type.DataType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientRegisterEventPublisherTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientRegisterEventPublisherTest.java similarity index 94% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientRegisterEventPublisherTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientRegisterEventPublisherTest.java index a3ccf5e..d7b2e30 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientRegisterEventPublisherTest.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientRegisterEventPublisherTest.java @@ -18,8 +18,8 @@ package org.apache.shenyu.client.core.disruptor.subcriber; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.type.DataTypeParent; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.type.DataTypeParent; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mock; diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriberTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriberTest.java similarity index 92% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriberTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriberTest.java index b7e6f83..e95856a 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriberTest.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/disruptor/subcriber/ShenyuClientURIExecutorSubscriberTest.java @@ -17,11 +17,11 @@ package org.apache.shenyu.client.core.disruptor.subcriber; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; import org.apache.shenyu.client.core.shutdown.ShenyuClientShutdownHook; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; -import org.apache.shenyu.register.common.type.DataType; +import org.apache.shenyu.client.core.type.DataType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/exception/ShenyuClientIllegalArgumentExceptionTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/exception/ShenyuClientIllegalArgumentExceptionTest.java similarity index 100% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/exception/ShenyuClientIllegalArgumentExceptionTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/exception/ShenyuClientIllegalArgumentExceptionTest.java diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactoryTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactoryTest.java similarity index 92% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactoryTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactoryTest.java index c07b878..4f30f45 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactoryTest.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/ShenyuClientRegisterRepositoryFactoryTest.java @@ -17,8 +17,7 @@ package org.apache.shenyu.client.core.register; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrarTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrarTest.java similarity index 94% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrarTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrarTest.java index 19391fb..751d0dd 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrarTest.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrarTest.java @@ -22,13 +22,13 @@ import org.apache.shenyu.client.apidocs.annotations.ApiModule; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.type.DataTypeParent; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.type.DataTypeParent; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrarTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrarTest.java similarity index 96% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrarTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrarTest.java index 0e99ad1..c2ba293 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrarTest.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/HttpApiDocRegistrarTest.java @@ -20,9 +20,9 @@ import com.google.common.collect.Lists; import org.apache.shenyu.client.apidocs.annotations.ApiDoc; import org.apache.shenyu.client.apidocs.annotations.ApiModule; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java similarity index 95% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java index 835c57a..2e425fb 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java @@ -20,9 +20,9 @@ import org.apache.shenyu.client.apidocs.annotations.ApiDoc; import org.apache.shenyu.client.apidocs.annotations.ApiModule; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/TestClientRegisterConfig.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/TestClientRegisterConfig.java similarity index 96% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/TestClientRegisterConfig.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/TestClientRegisterConfig.java index 93e16b0..7d6cb5c 100644 --- a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/register/registrar/TestClientRegisterConfig.java +++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/TestClientRegisterConfig.java @@ -17,8 +17,8 @@ package org.apache.shenyu.client.core.register.registrar; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.common.enums.RpcTypeEnum; public class TestClientRegisterConfig implements ClientRegisterConfig { @Override diff --git a/shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/utils/PortUtilsTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/utils/PortUtilsTest.java similarity index 100% rename from shenyu-client-java-core/src/test/java/org/apache/shenyu/client/core/utils/PortUtilsTest.java rename to shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/utils/PortUtilsTest.java diff --git a/shenyu-client-java-http/pom.xml b/shenyu-client/shenyu-client-dubbo/pom.xml similarity index 82% rename from shenyu-client-java-http/pom.xml rename to shenyu-client/shenyu-client-dubbo/pom.xml index 960ec88..464892e 100644 --- a/shenyu-client-java-http/pom.xml +++ b/shenyu-client/shenyu-client-dubbo/pom.xml @@ -19,15 +19,15 @@ org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-http + shenyu-client-dubbo pom - shenyu-client-java-springmvc - shenyu-client-java-springcloud + shenyu-client-dubbo-common + shenyu-client-apache-dubbo diff --git a/shenyu-client-java-http/shenyu-client-java-springcloud/pom.xml b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/pom.xml similarity index 65% rename from shenyu-client-java-http/shenyu-client-java-springcloud/pom.xml rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/pom.xml index c8c87e9..a421223 100644 --- a/shenyu-client-java-http/shenyu-client-java-springcloud/pom.xml +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/pom.xml @@ -19,49 +19,24 @@ org.apache.shenyu - shenyu-client-java-http - 2.7.1-SNAPSHOT + shenyu-client-dubbo + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-springcloud - + shenyu-client-apache-dubbo + - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - - junit - junit - 4.13.2 - test - org.apache.shenyu - shenyu-client-java-core + shenyu-client-dubbo-common ${project.version} + + org.apache.dubbo + dubbo + ${apache.dubbo.version} + provided + org.springframework spring-beans @@ -78,9 +53,21 @@ provided - org.springframework - spring-web + javax.validation + validation-api provided + + org.hibernate + hibernate-validator + 5.2.5.Final + test + + + javax.el + el-api + 2.2 + test + diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboApiBeansExtractor.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboApiBeansExtractor.java similarity index 97% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboApiBeansExtractor.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboApiBeansExtractor.java index 06246ee..8baee81 100644 --- a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboApiBeansExtractor.java +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboApiBeansExtractor.java @@ -21,9 +21,9 @@ import org.apache.dubbo.config.annotation.Service; import org.apache.shenyu.client.apache.dubbo.processor.extractor.DubboServiceProcessor; import org.apache.shenyu.client.apache.dubbo.processor.extractor.ServiceProcessor; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.extractor.BaseAnnotationApiBeansExtractor; import org.apache.shenyu.client.core.register.extractor.RpcApiBeansExtractor; -import org.apache.shenyu.common.enums.RpcTypeEnum; public class ApacheDubboApiBeansExtractor extends BaseAnnotationApiBeansExtractor implements RpcApiBeansExtractor { diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java similarity index 87% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java index 8c2378a..266b657 100644 --- a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/ApacheDubboServiceBeanListener.java @@ -19,21 +19,22 @@ import org.apache.commons.lang3.StringUtils; import org.apache.dubbo.common.constants.CommonConstants; +import org.apache.dubbo.config.MethodConfig; import org.apache.dubbo.config.spring.ServiceBean; import org.apache.shenyu.client.core.client.AbstractContextRefreshedEventListener; +import org.apache.shenyu.client.core.constant.Constants; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.GsonUtils; import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; import org.apache.shenyu.client.dubbo.common.dto.DubboRpcExt; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.exception.ShenyuException; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; +import org.apache.shenyu.client.dubbo.common.dto.DubboRpcMethodExt; import org.javatuples.Sextet; import org.springframework.aop.support.AopUtils; import org.springframework.context.ApplicationContext; @@ -44,8 +45,8 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; @@ -188,7 +189,7 @@ protected MetaDataRegisterDTO buildMetaDataDTO(final ServiceBean bean, String serviceName = bean.getInterface(); String configRuleName = shenyuClient.ruleName(); String ruleName = ("".equals(configRuleName)) ? path : configRuleName; - String methodName = Optional.ofNullable(method).map(Method::getName).orElseThrow(() -> new ShenyuException("unexpected error")); + String methodName = Optional.ofNullable(method).map(Method::getName).orElseThrow(() -> new RuntimeException("unexpected error")); Class[] parameterTypesClazz = method.getParameterTypes(); String parameterTypes = Arrays.stream(parameterTypesClazz).map(Class::getName).collect(Collectors.joining(",")); return MetaDataRegisterDTO.builder() @@ -231,17 +232,21 @@ private String buildRpcExt(final ServiceBean serviceBean, final String method .sent(Optional.ofNullable(serviceBean.getSent()).orElse(Boolean.FALSE)) .cluster(StringUtils.isNotEmpty(serviceBean.getCluster()) ? serviceBean.getCluster() : Constants.DEFAULT_CLUSTER) .url("") + .serialization(serviceBean.getSerialization()) .build(); - // set method config: loadbalance,retries,timeout,sent - Optional.ofNullable(serviceBean.getMethods()).orElse(Collections.emptyList()).stream() - .filter(m -> methodName.equals(m.getName())) - .findFirst() - .ifPresent(methodConfig -> { - Optional.ofNullable(methodConfig.getLoadbalance()).filter(StringUtils::isNotEmpty).ifPresent(build::setLoadbalance); - Optional.ofNullable(methodConfig.getRetries()).ifPresent(build::setRetries); - Optional.ofNullable(methodConfig.getTimeout()).ifPresent(build::setTimeout); - Optional.ofNullable(methodConfig.getSent()).ifPresent(build::setSent); - }); + // method config: loadbalance,retries,timeout,sent + if (Objects.nonNull(serviceBean.getMethods())) { + build.setMethods(new ArrayList<>()); + for (MethodConfig methodConfig : serviceBean.getMethods()) { + DubboRpcMethodExt methodExt = new DubboRpcMethodExt(); + methodExt.setName(methodConfig.getName()); + methodExt.setLoadbalance(methodConfig.getLoadbalance()); + methodExt.setRetries(methodConfig.getRetries()); + methodExt.setTimeout(methodConfig.getTimeout()); + methodExt.setSent(methodConfig.getSent()); + build.getMethods().add(methodExt); + } + } return GsonUtils.getInstance().toJson(build); } } diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuDubboService.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuDubboService.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuDubboService.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuDubboService.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuService.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuService.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuService.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuService.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/DubboServiceProcessor.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/DubboServiceProcessor.java similarity index 94% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/DubboServiceProcessor.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/DubboServiceProcessor.java index 71e4602..81061cd 100644 --- a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/DubboServiceProcessor.java +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/DubboServiceProcessor.java @@ -21,14 +21,14 @@ import org.apache.dubbo.common.constants.CommonConstants; import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.spring.ServiceBean; +import org.apache.shenyu.client.core.constant.Constants; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.matcher.ApiAnnotationProcessor; import org.apache.shenyu.client.core.register.matcher.ExtractorProcessor; +import org.apache.shenyu.client.core.utils.GsonUtils; +import org.apache.shenyu.client.core.utils.ListUtil; import org.apache.shenyu.client.dubbo.common.dto.DubboRpcExt; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.common.utils.ListUtil; import java.util.List; import java.util.Optional; diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/ServiceProcessor.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/ServiceProcessor.java similarity index 94% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/ServiceProcessor.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/ServiceProcessor.java index 4473573..6559d13 100644 --- a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/ServiceProcessor.java +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/extractor/ServiceProcessor.java @@ -17,11 +17,11 @@ package org.apache.shenyu.client.apache.dubbo.processor.extractor; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.matcher.ApiAnnotationProcessor; import org.apache.shenyu.client.core.register.matcher.ExtractorProcessor; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.ListUtil; +import org.apache.shenyu.client.core.utils.ListUtil; import org.springframework.stereotype.Service; import java.util.List; diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/register/ShenyuDubboProcessor.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/register/ShenyuDubboProcessor.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/register/ShenyuDubboProcessor.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/processor/register/ShenyuDubboProcessor.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidation.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidation.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidation.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidation.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.validation.Validation b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.validation.Validation similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.validation.Validation rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.validation.Validation diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuDubboServiceDefaultValueTest.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuDubboServiceDefaultValueTest.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuDubboServiceDefaultValueTest.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/annotation/ShenyuDubboServiceDefaultValueTest.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidationTest.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidationTest.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidationTest.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidationTest.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java similarity index 97% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java index 0b016a8..1162fad 100644 --- a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java @@ -43,7 +43,7 @@ public final class ApacheDubboClientValidatorTest { private ApacheDubboClientValidator apacheDubboClientValidatorUnderTest; /** - * test method {@link ApacheDubboClientValidator#validate(java.lang.String, java.lang.Class[], java.lang.Object[])}. + * test method {@link ApacheDubboClientValidator#validate(String, Class[], Object[])}. */ @Test public void validate() throws Exception { diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockConstraint.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockConstraint.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockConstraint.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockConstraint.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockConstraintValidator.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockConstraintValidator.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockConstraintValidator.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockConstraintValidator.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockEnumType.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockEnumType.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockEnumType.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockEnumType.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockValidationParameter.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockValidationParameter.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockValidationParameter.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockValidationParameter.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockValidatorTarget.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockValidatorTarget.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockValidatorTarget.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/mock/MockValidatorTarget.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/service/TestService.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/service/TestService.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/service/TestService.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/service/TestService.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-dubbo-common/pom.xml b/shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/pom.xml similarity index 87% rename from shenyu-client-java-dubbo/shenyu-client-java-dubbo-common/pom.xml rename to shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/pom.xml index b8e3ad3..63df892 100644 --- a/shenyu-client-java-dubbo/shenyu-client-java-dubbo-common/pom.xml +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/pom.xml @@ -19,16 +19,16 @@ org.apache.shenyu - shenyu-client-java-dubbo - 2.7.1-SNAPSHOT + shenyu-client-dubbo + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-dubbo-common + shenyu-client-dubbo-common org.apache.shenyu - shenyu-client-java-core + shenyu-client-core ${project.version} diff --git a/shenyu-client-java-dubbo/shenyu-client-java-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/annotation/ShenyuDubboClient.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/annotation/ShenyuDubboClient.java similarity index 100% rename from shenyu-client-java-dubbo/shenyu-client-java-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/annotation/ShenyuDubboClient.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/annotation/ShenyuDubboClient.java diff --git a/shenyu-client-java-dubbo/shenyu-client-java-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcExt.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcExt.java similarity index 83% rename from shenyu-client-java-dubbo/shenyu-client-java-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcExt.java rename to shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcExt.java index 76774fb..a583a78 100644 --- a/shenyu-client-java-dubbo/shenyu-client-java-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcExt.java +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcExt.java @@ -18,6 +18,7 @@ package org.apache.shenyu.client.dubbo.common.dto; import java.io.Serializable; +import java.util.List; /** * The type Dubbo rpc ext. @@ -44,6 +45,10 @@ public class DubboRpcExt implements Serializable { private String protocol; + private String serialization; + + private List methods; + /** * constructor without parameter. */ @@ -71,7 +76,8 @@ public DubboRpcExt(final String group, final String url, final Boolean sent, final String cluster, - final String protocol) { + final String protocol, + final String serialization) { this.group = group; this.version = version; this.loadbalance = loadbalance; @@ -81,6 +87,7 @@ public DubboRpcExt(final String group, this.sent = sent; this.cluster = cluster; this.protocol = protocol; + this.serialization = serialization; } /** @@ -245,6 +252,42 @@ public void setProtocol(final String protocol) { this.protocol = protocol; } + /** + * get serialization. + * + * @return serialization + */ + public String getSerialization() { + return serialization; + } + + /** + * set serialization. + * + * @param serialization serialization + */ + public void setSerialization(final String serialization) { + this.serialization = serialization; + } + + /** + * get methods. + * + * @return methods + */ + public List getMethods() { + return methods; + } + + /** + * set methods. + * + * @param methods methods + */ + public void setMethods(final List methods) { + this.methods = methods; + } + @Override public String toString() { return "DubboRpcExt{" @@ -257,6 +300,8 @@ public String toString() { + ", sent=" + sent + ", cluster='" + cluster + '\'' + ", protocol='" + protocol + '\'' + + ", serialization='" + serialization + '\'' + + ", methods=" + methods + '\'' + '}'; } @@ -292,6 +337,10 @@ public static final class Builder { private String protocol; + private String serialization; + + private List methods; + /** * constructor without parameter. */ @@ -397,6 +446,28 @@ public Builder protocol(final String protocol) { return this; } + /** + * set serialization. + * + * @param serialization serialization + * @return Builder + */ + public Builder serialization(final String serialization) { + this.serialization = serialization; + return this; + } + + /** + * set methods. + * + * @param methods methods + * @return Builder + */ + public Builder methods(final List methods) { + this.methods = methods; + return this; + } + /** * build DubboRpcExt. * @@ -413,6 +484,8 @@ public DubboRpcExt build() { dubboRpcExt.setSent(sent); dubboRpcExt.setCluster(cluster); dubboRpcExt.setProtocol(protocol); + dubboRpcExt.setSerialization(serialization); + dubboRpcExt.setMethods(methods); return dubboRpcExt; } } diff --git a/shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcMethodExt.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcMethodExt.java new file mode 100644 index 0000000..2a628e2 --- /dev/null +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-dubbo-common/src/main/java/org/apache/shenyu/client/dubbo/common/dto/DubboRpcMethodExt.java @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.shenyu.client.dubbo.common.dto; + +import java.io.Serializable; + +public class DubboRpcMethodExt implements Serializable { + + private static final long serialVersionUID = 1685981839659220568L; + + private String name; + + private String loadbalance; + + private Integer retries; + + private Integer timeout; + + private Boolean sent; + + /** + * get name. + * + * @return name + */ + public String getName() { + return name; + } + + /** + * set name. + * + * @param name name + */ + public void setName(final String name) { + this.name = name; + } + + /** + * get loadbalance. + * + * @return loadbalance + */ + public String getLoadbalance() { + return loadbalance; + } + + /** + * set loadbalance. + * + * @param loadbalance loadbalance + */ + public void setLoadbalance(final String loadbalance) { + this.loadbalance = loadbalance; + } + + /** + * get retries. + * + * @return retries + */ + public Integer getRetries() { + return retries; + } + + /** + * set retries. + * + * @param retries retries + */ + public void setRetries(final Integer retries) { + this.retries = retries; + } + + /** + * get timeout. + * + * @return timeout + */ + public Integer getTimeout() { + return timeout; + } + + /** + * set timeout. + * + * @param timeout timeout + */ + public void setTimeout(final Integer timeout) { + this.timeout = timeout; + } + + /** + * get sent. + * + * @return sent + */ + public Boolean getSent() { + return sent; + } + + /** + * set sent. + * + * @param sent sent + */ + public void setSent(final Boolean sent) { + this.sent = sent; + } + + @Override + public String toString() { + return "DubboRpcMethodExt{" + + "name='" + name + '\'' + + ", loadbalance='" + loadbalance + '\'' + + ", retries=" + retries + + ", timeout=" + timeout + + ", sent=" + sent + + '}'; + } +} diff --git a/shenyu-client-java-grpc/pom.xml b/shenyu-client/shenyu-client-grpc/pom.xml similarity index 63% rename from shenyu-client-java-grpc/pom.xml rename to shenyu-client/shenyu-client-grpc/pom.xml index afadb1c..705457a 100644 --- a/shenyu-client-java-grpc/pom.xml +++ b/shenyu-client/shenyu-client-grpc/pom.xml @@ -19,47 +19,16 @@ org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-grpc + shenyu-client-grpc - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - - junit - junit - 4.13.2 - test - org.apache.shenyu - shenyu-client-java-core + shenyu-client-core ${project.version} @@ -67,6 +36,12 @@ org.apache.shenyu shenyu-protocol-grpc 2.6.1 + + + shenyu-common + org.apache.shenyu + + diff --git a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/GrpcClientEventListener.java b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/GrpcClientEventListener.java similarity index 95% rename from shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/GrpcClientEventListener.java rename to shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/GrpcClientEventListener.java index 11a8b16..13241d6 100644 --- a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/GrpcClientEventListener.java +++ b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/GrpcClientEventListener.java @@ -24,18 +24,18 @@ import org.apache.commons.lang3.StringUtils; import org.apache.shenyu.client.core.client.AbstractContextRefreshedEventListener; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.exception.ShenyuClientIllegalArgumentException; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.GsonUtils; import org.apache.shenyu.client.grpc.common.annotation.ShenyuGrpcClient; import org.apache.shenyu.client.grpc.common.dto.GrpcExt; import org.apache.shenyu.client.grpc.json.JsonServerServiceInterceptor; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; import org.javatuples.Sextet; import org.springframework.context.ApplicationContext; import org.springframework.core.annotation.AnnotatedElementUtils; diff --git a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/common/annotation/ShenyuGrpcClient.java b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/common/annotation/ShenyuGrpcClient.java similarity index 100% rename from shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/common/annotation/ShenyuGrpcClient.java rename to shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/common/annotation/ShenyuGrpcClient.java diff --git a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/common/dto/GrpcExt.java b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/common/dto/GrpcExt.java similarity index 100% rename from shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/common/dto/GrpcExt.java rename to shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/common/dto/GrpcExt.java diff --git a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCall.java b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCall.java similarity index 100% rename from shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCall.java rename to shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCall.java diff --git a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerCallListener.java b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerCallListener.java similarity index 93% rename from shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerCallListener.java rename to shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerCallListener.java index 741719d..0d4ec7a 100644 --- a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerCallListener.java +++ b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerCallListener.java @@ -24,8 +24,7 @@ import io.grpc.ServerCall; import io.grpc.ServerCall.Listener; import io.grpc.Status; -import org.apache.shenyu.common.exception.ShenyuException; -import org.apache.shenyu.common.utils.ReflectUtils; +import org.apache.shenyu.client.core.utils.ReflectUtils; import org.apache.shenyu.protocol.grpc.message.JsonMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,7 +66,7 @@ public void onMessage(final R message) { String reqData = JsonMessage.getDataFromDynamicMessage((DynamicMessage) message); JsonFormat.parser().ignoringUnknownFields().merge(reqData, builder); if (Objects.isNull(builder)) { - throw new ShenyuException("build json response message is error, newBuilder method is null"); + throw new RuntimeException("build json response message is error, newBuilder method is null"); } delegate.onMessage((R) builder.build()); diff --git a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptor.java b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptor.java similarity index 94% rename from shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptor.java rename to shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptor.java index b4bc743..20b1349 100644 --- a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptor.java +++ b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptor.java @@ -28,8 +28,7 @@ import io.grpc.ServiceDescriptor; import io.grpc.protobuf.ProtoUtils; -import org.apache.shenyu.common.exception.ShenyuException; -import org.apache.shenyu.common.utils.ReflectUtils; +import org.apache.shenyu.client.core.utils.ReflectUtils; import org.apache.shenyu.protocol.grpc.constant.GrpcConstants; import org.apache.shenyu.protocol.grpc.message.JsonMessage; @@ -84,9 +83,9 @@ public static ServerServiceDefinition useMarshalledMessages(final ServerServ if (Objects.isNull(defaultInstanceField)) { // Compatible with lower versions. eg: grpc 1.6.0 if (requestMarshaller instanceof MethodDescriptor.PrototypeMarshaller) { - MethodDescriptor.PrototypeMarshaller prototypeMarshaller = (PrototypeMarshaller) requestMarshaller; + PrototypeMarshaller prototypeMarshaller = (PrototypeMarshaller) requestMarshaller; if (Objects.isNull(prototypeMarshaller.getMessagePrototype())) { - throw new ShenyuException(String.format("can not get defaultInstance Field of %s", requestMarshaller.getClass())); + throw new RuntimeException(String.format("can not get defaultInstance Field of %s", requestMarshaller.getClass())); } grpcRequestParamClass = prototypeMarshaller.getMessagePrototype().getClass(); } @@ -115,7 +114,7 @@ public static ServerServiceDefinition useMarshalledMessages(final ServerServ for (MethodDescriptor md : wrappedDescriptors) { Field fullMethodNameField = ReflectUtils.getField(md.getClass(), "fullMethodName"); if (Objects.isNull(fullMethodNameField)) { - throw new ShenyuException(String.format("can not get fullMethodName Field of %s", md.getClass())); + throw new RuntimeException(String.format("can not get fullMethodName Field of %s", md.getClass())); } fullMethodNameField.setAccessible(true); String fullMethodName = (String) fullMethodNameField.get(md); diff --git a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/server/GrpcServerBuilder.java b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/server/GrpcServerBuilder.java similarity index 100% rename from shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/server/GrpcServerBuilder.java rename to shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/server/GrpcServerBuilder.java diff --git a/shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/server/GrpcServerRunner.java b/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/server/GrpcServerRunner.java similarity index 100% rename from shenyu-client-java-grpc/src/main/java/org/apache/shenyu/client/grpc/server/GrpcServerRunner.java rename to shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/server/GrpcServerRunner.java diff --git a/shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/TestRequest.java b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestRequest.java similarity index 100% rename from shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/TestRequest.java rename to shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestRequest.java diff --git a/shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/TestResponse.java b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestResponse.java similarity index 100% rename from shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/TestResponse.java rename to shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestResponse.java diff --git a/shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCallTest.java b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCallTest.java similarity index 100% rename from shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCallTest.java rename to shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCallTest.java diff --git a/shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerCallListenerTest.java b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerCallListenerTest.java similarity index 100% rename from shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerCallListenerTest.java rename to shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerCallListenerTest.java diff --git a/shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptorTest.java b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptorTest.java similarity index 100% rename from shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptorTest.java rename to shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptorTest.java diff --git a/shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/server/GrpcServerRunnerTest.java b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/server/GrpcServerRunnerTest.java similarity index 100% rename from shenyu-client-java-grpc/src/test/java/org/apache/shenyu/client/grpc/server/GrpcServerRunnerTest.java rename to shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/server/GrpcServerRunnerTest.java diff --git a/shenyu-client-java-websocket/pom.xml b/shenyu-client/shenyu-client-http/pom.xml similarity index 85% rename from shenyu-client-java-websocket/pom.xml rename to shenyu-client/shenyu-client-http/pom.xml index 634811f..c46c3d4 100644 --- a/shenyu-client-java-websocket/pom.xml +++ b/shenyu-client/shenyu-client-http/pom.xml @@ -19,14 +19,14 @@ org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-websocket + shenyu-client-http pom - shenyu-client-java-spring-websocket + shenyu-client-springmvc diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/pom.xml b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/pom.xml similarity index 66% rename from shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/pom.xml rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/pom.xml index bc83d14..8441d2f 100644 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/pom.xml +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/pom.xml @@ -19,34 +19,38 @@ org.apache.shenyu - shenyu-spring-boot-starter-java-client - 2.7.1-SNAPSHOT + shenyu-client-http + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-spring-boot-starter-java-client-apache-dubbo + shenyu-client-springmvc - - org.mockito - mockito-inline - 3.3.3 - test - org.apache.shenyu - shenyu-client-java-apache-dubbo + shenyu-client-core ${project.version} - org.apache.shenyu - shenyu-spring-boot-starter-java-client-common - ${project.version} + org.springframework + spring-beans + provided + + + org.springframework + spring-context + provided + + + org.springframework + spring-core + provided - org.apache.dubbo - dubbo - ${apache.dubbo.version} + org.springframework + spring-web provided + diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMapping.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMapping.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMapping.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMapping.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMapping.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMapping.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMapping.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMapping.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMapping.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMapping.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMapping.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMapping.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMapping.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMapping.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMapping.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMapping.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMapping.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMapping.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMapping.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMapping.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuRequestMapping.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuRequestMapping.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuRequestMapping.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuRequestMapping.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuSpringMvcClient.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuSpringMvcClient.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuSpringMvcClient.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/annotation/ShenyuSpringMvcClient.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java similarity index 94% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java index d2f89f8..fe06dc0 100644 --- a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java @@ -22,18 +22,17 @@ import org.apache.shenyu.client.core.client.AbstractContextRefreshedEventListener; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.ApiDocRegisterDTO; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.PathUtils; import org.apache.shenyu.client.core.utils.PortUtils; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.exception.ShenyuException; -import org.apache.shenyu.common.utils.PathUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.dto.ApiDocRegisterDTO; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; import org.javatuples.Sextet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -157,8 +156,8 @@ protected URIRegisterDTO buildURIRegisterDTO(final ApplicationContext context, .eventType(EventType.REGISTER) .namespaceId(namespaceId) .build(); - } catch (ShenyuException e) { - throw new ShenyuException(e.getMessage() + "please config ${shenyu.client.http.props.port} in xml/yml !"); + } catch (Exception e) { + throw new RuntimeException(e.getMessage() + "please config ${shenyu.client.http.props.port} in xml/yml !"); } } diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/extractor/RequestMappingProcessor.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/extractor/RequestMappingProcessor.java similarity index 96% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/extractor/RequestMappingProcessor.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/extractor/RequestMappingProcessor.java index 35f66c8..e851626 100644 --- a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/extractor/RequestMappingProcessor.java +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/extractor/RequestMappingProcessor.java @@ -18,11 +18,11 @@ package org.apache.shenyu.client.springmvc.proceeor.extractor; import org.apache.commons.lang3.ArrayUtils; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.matcher.ApiAnnotationProcessor; import org.apache.shenyu.client.core.register.matcher.ExtractorProcessor; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.ListUtil; +import org.apache.shenyu.client.core.utils.ListUtil; import org.springframework.lang.NonNull; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/register/ShenyuSpringMvcClientProcessorImpl.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/register/ShenyuSpringMvcClientProcessorImpl.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/register/ShenyuSpringMvcClientProcessorImpl.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/proceeor/register/ShenyuSpringMvcClientProcessorImpl.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractor.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractor.java similarity index 97% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractor.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractor.java index c0ae930..25fce3b 100644 --- a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractor.java +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractor.java @@ -17,10 +17,10 @@ package org.apache.shenyu.client.springmvc.register; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.extractor.BaseAnnotationApiBeansExtractor; import org.apache.shenyu.client.core.register.extractor.RpcApiBeansExtractor; import org.apache.shenyu.client.springmvc.proceeor.extractor.RequestMappingProcessor; -import org.apache.shenyu.common.enums.RpcTypeEnum; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegister.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegister.java similarity index 97% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegister.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegister.java index 2fbf858..9738326 100644 --- a/shenyu-client-java-http/shenyu-client-java-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegister.java +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegister.java @@ -20,15 +20,15 @@ import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; import org.apache.shenyu.client.core.register.matcher.AnnotatedApiDefinitionMatcher; import org.apache.shenyu.client.core.register.matcher.Matcher; import org.apache.shenyu.client.core.register.registrar.AbstractApiMetaRegistrar; +import org.apache.shenyu.client.core.utils.PathUtils; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.PathUtils; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; import org.springframework.core.annotation.AnnotationUtils; import java.util.List; diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMappingTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMappingTest.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMappingTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMappingTest.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMappingTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMappingTest.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMappingTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMappingTest.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMappingTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMappingTest.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMappingTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMappingTest.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMappingTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMappingTest.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMappingTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMappingTest.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMappingTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMappingTest.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMappingTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMappingTest.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuRequestMappingTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuRequestMappingTest.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuRequestMappingTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuRequestMappingTest.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java similarity index 93% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java index a9e4ba8..fa6aa47 100644 --- a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java @@ -19,15 +19,14 @@ import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.exception.ShenyuClientIllegalArgumentException; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepositoryFactory; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig.ClientPropertiesConfig; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; +import org.apache.shenyu.client.core.utils.RegisterUtils; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.common.exception.ShenyuException; import org.apache.shenyu.client.core.utils.PortUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig.ClientPropertiesConfig; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -142,7 +141,7 @@ private SpringMvcClientEventListener buildSpringMvcClientEventListener(final boo properties.setProperty("username", "admin"); properties.setProperty("password", "123456"); properties.setProperty(ShenyuClientConstants.DISCOVERY_LOCAL_MODE_KEY, Boolean.TRUE.toString()); - ShenyuClientConfig.ClientPropertiesConfig config = new ShenyuClientConfig.ClientPropertiesConfig(); + ClientPropertiesConfig config = new ClientPropertiesConfig(); config.setProps(properties); ShenyuRegisterCenterConfig mockRegisterCenter = new ShenyuRegisterCenterConfig(); mockRegisterCenter.setServerLists("http://127.0.0.1:9095"); @@ -174,7 +173,7 @@ public void testOnApplicationEvent() { public void testOnApplicationEventError() { init(); SpringMvcClientEventListener springMvcClientEventListener = buildSpringMvcClientEventListener(false, false); - Assert.assertThrows(ShenyuException.class, () -> springMvcClientEventListener.onApplicationEvent(contextRefreshedEvent)); + Assert.assertThrows(RuntimeException.class, () -> springMvcClientEventListener.onApplicationEvent(contextRefreshedEvent)); registerUtilsMockedStatic.close(); } diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractorTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractorTest.java similarity index 100% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractorTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiBeansExtractorTest.java diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegisterTest.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegisterTest.java similarity index 96% rename from shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegisterTest.java rename to shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegisterTest.java index ec8a7d5..6221c36 100644 --- a/shenyu-client-java-http/shenyu-client-java-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegisterTest.java +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/register/SpringMvcApiMetaRegisterTest.java @@ -18,13 +18,13 @@ package org.apache.shenyu.client.springmvc.register; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ApiBean; import org.apache.shenyu.client.core.register.ClientRegisterConfig; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.type.DataTypeParent; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.type.DataTypeParent; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/pom.xml b/shenyu-client/shenyu-client-motan/pom.xml similarity index 71% rename from shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/pom.xml rename to shenyu-client/shenyu-client-motan/pom.xml index b2ab2f7..28ae6e6 100644 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/pom.xml +++ b/shenyu-client/shenyu-client-motan/pom.xml @@ -19,29 +19,33 @@ org.apache.shenyu - shenyu-spring-boot-starter-java-client - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-spring-boot-starter-java-client-motan + shenyu-client-motan - - org.mockito - mockito-inline - 3.3.3 - test - org.apache.shenyu - shenyu-client-java-motan + shenyu-client-core ${project.version} - org.apache.shenyu - shenyu-spring-boot-starter-java-client-common - ${project.version} + org.springframework + spring-beans + provided + + + org.springframework + spring-context + provided + + + org.springframework + spring-core + provided com.weibo diff --git a/shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/MotanServiceEventListener.java b/shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/MotanServiceEventListener.java similarity index 95% rename from shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/MotanServiceEventListener.java rename to shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/MotanServiceEventListener.java index f8fdcf3..274b05d 100644 --- a/shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/MotanServiceEventListener.java +++ b/shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/MotanServiceEventListener.java @@ -33,17 +33,17 @@ import org.apache.shenyu.client.core.client.AbstractContextRefreshedEventListener; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.exception.ShenyuClientIllegalArgumentException; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.GsonUtils; import org.apache.shenyu.client.motan.common.annotation.ShenyuMotanClient; import org.apache.shenyu.client.motan.common.dto.MotanRpcExt; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; import org.javatuples.Sextet; import org.springframework.context.ApplicationContext; import org.springframework.core.StandardReflectionParameterNameDiscoverer; diff --git a/shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/common/annotation/ShenyuMotanClient.java b/shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/common/annotation/ShenyuMotanClient.java similarity index 100% rename from shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/common/annotation/ShenyuMotanClient.java rename to shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/common/annotation/ShenyuMotanClient.java diff --git a/shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/common/annotation/ShenyuMotanService.java b/shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/common/annotation/ShenyuMotanService.java similarity index 100% rename from shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/common/annotation/ShenyuMotanService.java rename to shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/common/annotation/ShenyuMotanService.java diff --git a/shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/common/dto/MotanRpcExt.java b/shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/common/dto/MotanRpcExt.java similarity index 100% rename from shenyu-client-java-motan/src/main/java/org/apache/shenyu/client/motan/common/dto/MotanRpcExt.java rename to shenyu-client/shenyu-client-motan/src/main/java/org/apache/shenyu/client/motan/common/dto/MotanRpcExt.java diff --git a/shenyu-client-java-motan/src/test/java/org/apache/shenyu/client/motan/MotanServiceEventListenerTest.java b/shenyu-client/shenyu-client-motan/src/test/java/org/apache/shenyu/client/motan/MotanServiceEventListenerTest.java similarity index 91% rename from shenyu-client-java-motan/src/test/java/org/apache/shenyu/client/motan/MotanServiceEventListenerTest.java rename to shenyu-client/shenyu-client-motan/src/test/java/org/apache/shenyu/client/motan/MotanServiceEventListenerTest.java index 6d71f10..8afb6ec 100644 --- a/shenyu-client-java-motan/src/test/java/org/apache/shenyu/client/motan/MotanServiceEventListenerTest.java +++ b/shenyu-client/shenyu-client-motan/src/test/java/org/apache/shenyu/client/motan/MotanServiceEventListenerTest.java @@ -27,16 +27,16 @@ import java.util.Map; import java.util.Properties; -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; +import org.apache.shenyu.client.core.constant.Constants; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepositoryFactory; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig.ClientPropertiesConfig; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; import org.apache.shenyu.client.motan.common.annotation.ShenyuMotanClient; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig.ClientPropertiesConfig; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; import org.jetbrains.annotations.NotNull; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; @@ -124,10 +124,10 @@ public void testBuildURIRegisterDTO() { .eventType(EventType.REGISTER) .host(HOST) .port(Integer.parseInt(PORT)) - .namespaceId(ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID) + .namespaceId(Constants.SYS_DEFAULT_NAMESPACE_ID) .build(); Map beans = new HashMap<>(); - URIRegisterDTO realURIRegisterDTO = motanServiceEventListener.buildURIRegisterDTO(applicationContext, beans, ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID); + URIRegisterDTO realURIRegisterDTO = motanServiceEventListener.buildURIRegisterDTO(applicationContext, beans, Constants.SYS_DEFAULT_NAMESPACE_ID); assertEquals(expectedURIRegisterDTO, realURIRegisterDTO); } @@ -188,7 +188,7 @@ public void testBuildMetaDataDTOForMotan() throws NoSuchMethodException { SUPER_PATH_NOT_CONTAINS_STAR, MockMotanServiceClass.class, method, - ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID); + Constants.SYS_DEFAULT_NAMESPACE_ID); MetaDataRegisterDTO expectedMetaDataRegisterDTO = MetaDataRegisterDTO.builder() .appName(APP_NAME) @@ -204,7 +204,7 @@ public void testBuildMetaDataDTOForMotan() throws NoSuchMethodException { .rpcType(RpcTypeEnum.MOTAN.getName()) .rpcExt(expectedRpcExt) .enabled(ENABLED) - .namespaceId(ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID) + .namespaceId(Constants.SYS_DEFAULT_NAMESPACE_ID) .build(); assertEquals(expectedMetaDataRegisterDTO, realMetaDataRegisterDTO); @@ -248,7 +248,7 @@ private MotanServiceEventListener buildMotanServiceEventListener() { shenyuRegisterCenterConfig.setRegisterType("http"); shenyuRegisterCenterConfig.setProps(properties); ShenyuClientConfig clientConfig = new ShenyuClientConfig(); - Map client = new LinkedHashMap<>(); + Map client = new LinkedHashMap<>(); client.put(RpcTypeEnum.MOTAN.getName(), config); clientConfig.setClient(client); return new MotanServiceEventListener(clientConfig, ShenyuClientRegisterRepositoryFactory.newInstance(shenyuRegisterCenterConfig)); diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/pom.xml b/shenyu-client/shenyu-client-sofa/pom.xml similarity index 59% rename from shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/pom.xml rename to shenyu-client/shenyu-client-sofa/pom.xml index 38f8687..5ee5205 100644 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/pom.xml +++ b/shenyu-client/shenyu-client-sofa/pom.xml @@ -19,38 +19,53 @@ org.apache.shenyu - shenyu-spring-boot-starter-java-client - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-spring-boot-starter-java-client-sofa + shenyu-client-sofa - 3.22.0 + 3.1.4 - - org.mockito - mockito-inline - 3.3.3 - test - - - org.apache.shenyu - shenyu-client-java-sofa - ${project.version} - org.apache.shenyu - shenyu-spring-boot-starter-java-client-common + shenyu-client-core ${project.version} + + + grpc-netty + io.grpc + + com.alipay.sofa runtime-sofa-boot-starter ${runtime-sofa-boot-starter.version} - test + provided + + + com.alipay.sofa + sofa-rpc-all + provided + + + org.springframework + spring-beans + provided + + + org.springframework + spring-context + provided + + + org.springframework + spring-core + provided diff --git a/shenyu-client-java-sofa/src/main/java/org/apache/shenyu/client/sofa/SofaServiceEventListener.java b/shenyu-client/shenyu-client-sofa/src/main/java/org/apache/shenyu/client/sofa/SofaServiceEventListener.java similarity index 95% rename from shenyu-client-java-sofa/src/main/java/org/apache/shenyu/client/sofa/SofaServiceEventListener.java rename to shenyu-client/shenyu-client-sofa/src/main/java/org/apache/shenyu/client/sofa/SofaServiceEventListener.java index 167c580..9c8eaa8 100644 --- a/shenyu-client-java-sofa/src/main/java/org/apache/shenyu/client/sofa/SofaServiceEventListener.java +++ b/shenyu-client/shenyu-client-sofa/src/main/java/org/apache/shenyu/client/sofa/SofaServiceEventListener.java @@ -22,16 +22,16 @@ import org.apache.commons.lang3.StringUtils; import org.apache.shenyu.client.core.client.AbstractContextRefreshedEventListener; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.GsonUtils; import org.apache.shenyu.client.sofa.common.annotation.ShenyuSofaClient; import org.apache.shenyu.client.sofa.common.dto.SofaRpcExt; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; import org.javatuples.Sextet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/shenyu-client-java-sofa/src/main/java/org/apache/shenyu/client/sofa/common/annotation/ShenyuSofaClient.java b/shenyu-client/shenyu-client-sofa/src/main/java/org/apache/shenyu/client/sofa/common/annotation/ShenyuSofaClient.java similarity index 100% rename from shenyu-client-java-sofa/src/main/java/org/apache/shenyu/client/sofa/common/annotation/ShenyuSofaClient.java rename to shenyu-client/shenyu-client-sofa/src/main/java/org/apache/shenyu/client/sofa/common/annotation/ShenyuSofaClient.java diff --git a/shenyu-client-java-sofa/src/main/java/org/apache/shenyu/client/sofa/common/dto/SofaRpcExt.java b/shenyu-client/shenyu-client-sofa/src/main/java/org/apache/shenyu/client/sofa/common/dto/SofaRpcExt.java similarity index 100% rename from shenyu-client-java-sofa/src/main/java/org/apache/shenyu/client/sofa/common/dto/SofaRpcExt.java rename to shenyu-client/shenyu-client-sofa/src/main/java/org/apache/shenyu/client/sofa/common/dto/SofaRpcExt.java diff --git a/shenyu-client-java-sofa/src/test/java/org/apache/shenyu/client/sofa/SofaServiceEventListenerTest.java b/shenyu-client/shenyu-client-sofa/src/test/java/org/apache/shenyu/client/sofa/SofaServiceEventListenerTest.java similarity index 91% rename from shenyu-client-java-sofa/src/test/java/org/apache/shenyu/client/sofa/SofaServiceEventListenerTest.java rename to shenyu-client/shenyu-client-sofa/src/test/java/org/apache/shenyu/client/sofa/SofaServiceEventListenerTest.java index 2226921..5b46f09 100644 --- a/shenyu-client-java-sofa/src/test/java/org/apache/shenyu/client/sofa/SofaServiceEventListenerTest.java +++ b/shenyu-client/shenyu-client-sofa/src/test/java/org/apache/shenyu/client/sofa/SofaServiceEventListenerTest.java @@ -18,16 +18,16 @@ package org.apache.shenyu.client.sofa; import com.alipay.sofa.runtime.spring.factory.ServiceFactoryBean; -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; +import org.apache.shenyu.client.core.constant.Constants; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepositoryFactory; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig.ClientPropertiesConfig; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; import org.apache.shenyu.client.sofa.common.annotation.ShenyuSofaClient; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig.ClientPropertiesConfig; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -121,10 +121,10 @@ public void testBuildURIRegisterDTO() { .eventType(EventType.REGISTER) .host(HOST) .port(Integer.parseInt(PORT)) - .namespaceId(ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID) + .namespaceId(Constants.SYS_DEFAULT_NAMESPACE_ID) .build(); Map beans = new HashMap<>(); - URIRegisterDTO realURIRegisterDTO = sofaServiceEventListener.buildURIRegisterDTO(applicationContext, beans, ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID); + URIRegisterDTO realURIRegisterDTO = sofaServiceEventListener.buildURIRegisterDTO(applicationContext, beans, Constants.SYS_DEFAULT_NAMESPACE_ID); assertEquals(expectedURIRegisterDTO, realURIRegisterDTO); } @@ -210,7 +210,7 @@ public void testBuildMetaDataDTO() throws NoSuchMethodException { shenyuSofaClient, SUPER_PATH_NOT_CONTAINS_STAR, SofaServiceEventListener.class, - method, ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID); + method, Constants.SYS_DEFAULT_NAMESPACE_ID); MetaDataRegisterDTO expectedMetaDataRegisterDTO = MetaDataRegisterDTO .builder() .appName(APP_NAME) @@ -226,7 +226,7 @@ public void testBuildMetaDataDTO() throws NoSuchMethodException { .rpcType(RpcTypeEnum.SOFA.getName()) .rpcExt(expectedRpcExt) .enabled(ENABLED) - .namespaceId(ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID) + .namespaceId(Constants.SYS_DEFAULT_NAMESPACE_ID) .build(); assertEquals(expectedMetaDataRegisterDTO, realMetaDataRegisterDTO); diff --git a/shenyu-client-java-tars/pom.xml b/shenyu-client/shenyu-client-tars/pom.xml similarity index 66% rename from shenyu-client-java-tars/pom.xml rename to shenyu-client/shenyu-client-tars/pom.xml index 9605ac4..1849483 100644 --- a/shenyu-client-java-tars/pom.xml +++ b/shenyu-client/shenyu-client-tars/pom.xml @@ -19,54 +19,22 @@ org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-tars + shenyu-client-tars - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - - junit - junit - 4.13.2 - test - org.apache.shenyu - shenyu-client-java-core + shenyu-client-core ${project.version} com.tencent.tars tars-spring-boot-starter - ${tars.version} org.slf4j diff --git a/shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/TarsServiceBeanEventListener.java b/shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/TarsServiceBeanEventListener.java similarity index 95% rename from shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/TarsServiceBeanEventListener.java rename to shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/TarsServiceBeanEventListener.java index 59891e1..816a511 100644 --- a/shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/TarsServiceBeanEventListener.java +++ b/shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/TarsServiceBeanEventListener.java @@ -22,18 +22,18 @@ import org.apache.shenyu.client.core.client.AbstractContextRefreshedEventListener; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.exception.ShenyuClientIllegalArgumentException; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.GsonUtils; import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsClient; import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsService; import org.apache.shenyu.client.tars.common.dto.TarsRpcExt; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; import org.javatuples.Sextet; import org.springframework.aop.support.AopUtils; import org.springframework.context.ApplicationContext; diff --git a/shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/common/annotation/ShenyuTarsClient.java b/shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/common/annotation/ShenyuTarsClient.java similarity index 100% rename from shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/common/annotation/ShenyuTarsClient.java rename to shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/common/annotation/ShenyuTarsClient.java diff --git a/shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/common/annotation/ShenyuTarsService.java b/shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/common/annotation/ShenyuTarsService.java similarity index 100% rename from shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/common/annotation/ShenyuTarsService.java rename to shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/common/annotation/ShenyuTarsService.java diff --git a/shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/common/dto/TarsRpcExt.java b/shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/common/dto/TarsRpcExt.java similarity index 100% rename from shenyu-client-java-tars/src/main/java/org/apache/shenyu/client/tars/common/dto/TarsRpcExt.java rename to shenyu-client/shenyu-client-tars/src/main/java/org/apache/shenyu/client/tars/common/dto/TarsRpcExt.java diff --git a/shenyu-client-java-tars/src/test/java/org/apache/shenyu/client/tars/TarsRpcExtTest.java b/shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsRpcExtTest.java similarity index 100% rename from shenyu-client-java-tars/src/test/java/org/apache/shenyu/client/tars/TarsRpcExtTest.java rename to shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsRpcExtTest.java diff --git a/shenyu-client-java-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java b/shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java similarity index 93% rename from shenyu-client-java-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java rename to shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java index 26bacfa..a81395e 100644 --- a/shenyu-client-java-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java +++ b/shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java @@ -17,16 +17,16 @@ package org.apache.shenyu.client.tars; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; import org.apache.shenyu.client.core.exception.ShenyuClientIllegalArgumentException; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepositoryFactory; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig.ClientPropertiesConfig; +import org.apache.shenyu.client.core.register.config.ShenyuRegisterCenterConfig; +import org.apache.shenyu.client.core.utils.RegisterUtils; import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsClient; import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsService; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig.ClientPropertiesConfig; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; import org.junit.Assert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.MethodOrderer; diff --git a/shenyu-client-java-dubbo/pom.xml b/shenyu-client/shenyu-client-websocket/pom.xml similarity index 82% rename from shenyu-client-java-dubbo/pom.xml rename to shenyu-client/shenyu-client-websocket/pom.xml index 5e5f176..802f70b 100644 --- a/shenyu-client-java-dubbo/pom.xml +++ b/shenyu-client/shenyu-client-websocket/pom.xml @@ -19,15 +19,14 @@ org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT + shenyu-client + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-dubbo + shenyu-client-websocket pom - shenyu-client-java-dubbo-common - shenyu-client-java-apache-dubbo + shenyu-client-spring-websocket diff --git a/shenyu-client-java-http/shenyu-client-java-springmvc/pom.xml b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/pom.xml similarity index 67% rename from shenyu-client-java-http/shenyu-client-java-springmvc/pom.xml rename to shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/pom.xml index c195633..e5cfc24 100644 --- a/shenyu-client-java-http/shenyu-client-java-springmvc/pom.xml +++ b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/pom.xml @@ -19,47 +19,16 @@ org.apache.shenyu - shenyu-client-java-http - 2.7.1-SNAPSHOT + shenyu-client-websocket + 2.7.0.1-jdk8-SNAPSHOT 4.0.0 - shenyu-client-java-springmvc + shenyu-client-spring-websocket - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - - junit - junit - 4.13.2 - test - org.apache.shenyu - shenyu-client-java-core + shenyu-client-core ${project.version} @@ -82,6 +51,24 @@ spring-web provided - + + javax.websocket + javax.websocket-api + provided + + + javax.servlet + javax.servlet-api + provided + + + org.springframework + spring-websocket + test + + + org.apache.tomcat.embed + tomcat-embed-websocket + diff --git a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/annotation/ShenyuServerEndpoint.java b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/annotation/ShenyuServerEndpoint.java similarity index 100% rename from shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/annotation/ShenyuServerEndpoint.java rename to shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/annotation/ShenyuServerEndpoint.java diff --git a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/annotation/ShenyuSpringWebSocketClient.java b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/annotation/ShenyuSpringWebSocketClient.java similarity index 100% rename from shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/annotation/ShenyuSpringWebSocketClient.java rename to shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/annotation/ShenyuSpringWebSocketClient.java diff --git a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java similarity index 93% rename from shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java rename to shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java index 173a343..324e440 100644 --- a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java +++ b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java @@ -19,7 +19,6 @@ import java.util.Objects; import org.apache.shenyu.client.spring.websocket.annotation.ShenyuServerEndpoint; -import org.apache.shenyu.common.exception.ShenyuException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.annotation.AnnotatedElementUtils; @@ -60,7 +59,7 @@ protected ServerContainer getServerContainer() { @Override protected void initServletContext(final ServletContext servletContext) { if (Objects.isNull(this.serverContainer)) { - this.serverContainer = (ServerContainer) servletContext.getAttribute("javax.websocket.server.ServerContainer"); + this.serverContainer = (ServerContainer) servletContext.getAttribute("jakarta.websocket.server.ServerContainer"); } } @@ -76,7 +75,7 @@ protected boolean isContextRequired() { public void registerEndpoint(final Class pojo) { ShenyuServerEndpoint annotation = AnnotatedElementUtils.findMergedAnnotation(pojo, ShenyuServerEndpoint.class); if (Objects.isNull(annotation)) { - throw new ShenyuException("Class missing annotation ShenyuServerEndpoint! class name: " + pojo.getName()); + throw new RuntimeException("Class missing annotation ShenyuServerEndpoint! class name: " + pojo.getName()); } String path = annotation.value(); @@ -87,7 +86,7 @@ public void registerEndpoint(final Class pojo) { configurator = annotation.configurator().getConstructor().newInstance(); } catch (ReflectiveOperationException ex) { LOG.error("ShenyuServerEndpoint configurator init fail! Class name: {}, configurator name: {}", pojo.getName(), annotation.configurator().getName()); - throw new ShenyuException(ex); + throw new RuntimeException(ex); } } ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(pojo, path) diff --git a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListener.java b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListener.java similarity index 95% rename from shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListener.java rename to shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListener.java index 338ad8d..ca0e7a3 100644 --- a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListener.java +++ b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListener.java @@ -22,18 +22,17 @@ import org.apache.shenyu.client.core.client.AbstractContextRefreshedEventListener; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.ApiHttpMethodEnum; +import org.apache.shenyu.client.core.enums.EventType; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.utils.PathUtils; import org.apache.shenyu.client.core.utils.PortUtils; import org.apache.shenyu.client.spring.websocket.annotation.ShenyuServerEndpoint; import org.apache.shenyu.client.spring.websocket.annotation.ShenyuSpringWebSocketClient; -import org.apache.shenyu.common.enums.ApiHttpMethodEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.exception.ShenyuException; -import org.apache.shenyu.common.utils.PathUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; -import org.apache.shenyu.register.common.enums.EventType; import org.javatuples.Sextet; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -130,8 +129,8 @@ protected URIRegisterDTO buildURIRegisterDTO(final ApplicationContext context, .eventType(EventType.REGISTER) .namespaceId(namespaceId) .build(); - } catch (ShenyuException e) { - throw new ShenyuException(e.getMessage() + "please config ${shenyu.client.http.props.port} in xml/yml !"); + } catch (Exception e) { + throw new RuntimeException(e.getMessage() + "please config ${shenyu.client.http.props.port} in xml/yml !"); } } diff --git a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporterTest.java b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporterTest.java similarity index 96% rename from shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporterTest.java rename to shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporterTest.java index cedfcc7..33c5525 100644 --- a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporterTest.java +++ b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporterTest.java @@ -18,7 +18,6 @@ package org.apache.shenyu.client.spring.websocket.init; import org.apache.shenyu.client.spring.websocket.annotation.ShenyuServerEndpoint; -import org.apache.shenyu.common.exception.ShenyuException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -111,7 +110,7 @@ public void registerEndpointTest() throws DeploymentException { */ @Test public void registerEndpointMissingAnnotationTest() { - assertThrows(ShenyuException.class, () -> exporter.registerEndpoint(pojo.getClass())); + assertThrows(RuntimeException.class, () -> exporter.registerEndpoint(pojo.getClass())); verifyNoInteractions(serverContainer); } diff --git a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListenerTest.java b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListenerTest.java similarity index 90% rename from shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListenerTest.java rename to shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListenerTest.java index 9da0232..d49e450 100644 --- a/shenyu-client-java-websocket/shenyu-client-java-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListenerTest.java +++ b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/test/java/org/apache/shenyu/client/spring/websocket/init/SpringWebSocketClientEventListenerTest.java @@ -17,16 +17,17 @@ package org.apache.shenyu.client.spring.websocket.init; +import org.apache.shenyu.client.core.constant.Constants; import org.apache.shenyu.client.core.constant.ShenyuClientConstants; import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; +import org.apache.shenyu.client.core.dto.MetaDataRegisterDTO; +import org.apache.shenyu.client.core.dto.URIRegisterDTO; +import org.apache.shenyu.client.core.enums.RpcTypeEnum; +import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepository; +import org.apache.shenyu.client.core.register.config.PropertiesConfig; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig; +import org.apache.shenyu.client.core.register.config.ShenyuClientConfig.ClientPropertiesConfig; import org.apache.shenyu.client.spring.websocket.annotation.ShenyuSpringWebSocketClient; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.PropertiesConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig.ClientPropertiesConfig; -import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO; -import org.apache.shenyu.register.common.dto.URIRegisterDTO; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -116,7 +117,7 @@ public void testGetBeans() { @Test public void testBuildURIRegisterDTO() { - URIRegisterDTO uriRegisterDTO = eventListener.buildURIRegisterDTO(applicationContext, Collections.emptyMap(), ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID); + URIRegisterDTO uriRegisterDTO = eventListener.buildURIRegisterDTO(applicationContext, Collections.emptyMap(), Constants.SYS_DEFAULT_NAMESPACE_ID); assertNotNull(uriRegisterDTO); assertEquals("/contextPath", uriRegisterDTO.getContextPath()); assertEquals("appName", uriRegisterDTO.getAppName()); @@ -166,7 +167,7 @@ public void testBuildApiPath() throws NoSuchMethodException { @Test public void testBuildMetaDataDTO() throws NoSuchMethodException { Method method = mockClass.getClass().getMethod("mockMethod"); - MetaDataRegisterDTO metaDataRegisterDTO = eventListener.buildMetaDataDTO(mockClass, annotation, SUPER_PATH, MockClass.class, method, ShenyuClientConstants.SYS_DEFAULT_NAMESPACE_ID); + MetaDataRegisterDTO metaDataRegisterDTO = eventListener.buildMetaDataDTO(mockClass, annotation, SUPER_PATH, MockClass.class, method, Constants.SYS_DEFAULT_NAMESPACE_ID); assertNotNull(metaDataRegisterDTO); } diff --git a/shenyu-java-common/pom.xml b/shenyu-java-common/pom.xml deleted file mode 100644 index 2541b20..0000000 --- a/shenyu-java-common/pom.xml +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-common - - - - com.google.code.gson - gson - - - - org.apache.commons - commons-lang3 - - - - com.fasterxml.jackson.core - jackson-databind - - - - com.fasterxml.jackson.datatype - jackson-datatype-jdk8 - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - - - com.fasterxml.jackson.module - jackson-module-parameter-names - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - - com.github.ben-manes.caffeine - caffeine - - - commons-codec - commons-codec - - - - org.ow2.asm - asm-tree - ${asm.version} - - - - io.projectreactor.netty - reactor-netty-core - - - - io.projectreactor.netty - reactor-netty-http - - - - org.bouncycastle - bcprov-jdk18on - ${bcprov-jdk18on.version} - - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - - - com.google.code.findbugs - jsr305 - 3.0.2 - - - com.google.guava - guava - 32.0.0-jre - - - com.google.re2j - re2j - - - - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.5.15 - test - - - org.junit.jupiter - junit-jupiter-api - 5.8.2 - test - - - org.junit.jupiter - junit-jupiter-params - 5.8.2 - test - - - - junit - junit - 4.13.2 - test - - - - diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/MemorySafeLRUMap.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/MemorySafeLRUMap.java deleted file mode 100644 index ff344ec..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/MemorySafeLRUMap.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.cache; - -import org.apache.commons.collections4.map.LRUMap; -import org.apache.shenyu.common.concurrent.MemoryLimitCalculator; - -import javax.annotation.concurrent.NotThreadSafe; -import java.util.Map; - -/** - * The only difference between this class and {@link org.apache.commons.collections4.map.LRUMap} - * is that it handles memory issues via {@link org.apache.shenyu.common.concurrent.MemoryLimitCalculator}. - * - *

Note: this class is not thread safe! see https://github.com/apache/shenyu/issues/3929 - */ -@NotThreadSafe -public class MemorySafeLRUMap extends LRUMap { - - private final int maxFreeMemory; - - public MemorySafeLRUMap(final int maxFreeMemory, - final int initialSize) { - super(MAXIMUM_CAPACITY, initialSize); - this.maxFreeMemory = maxFreeMemory; - } - - public MemorySafeLRUMap(final int maxFreeMemory, - final int initialSize, - final float loadFactor) { - super(MAXIMUM_CAPACITY, initialSize, loadFactor); - this.maxFreeMemory = maxFreeMemory; - } - - public MemorySafeLRUMap(final int maxFreeMemory, - final int initialSize, - final float loadFactor, - final boolean scanUntilRemovable) { - super(MAXIMUM_CAPACITY, initialSize, loadFactor, scanUntilRemovable); - this.maxFreeMemory = maxFreeMemory; - } - - public MemorySafeLRUMap(final int maxFreeMemory, - final Map map) { - super(map); - this.maxFreeMemory = maxFreeMemory; - } - - public MemorySafeLRUMap(final int maxFreeMemory, - final Map map, - final boolean scanUntilRemovable) { - super(map, scanUntilRemovable); - this.maxFreeMemory = maxFreeMemory; - } - - @Override - public boolean isFull() { - // when free memory less than certain value, consider it's full - return size() > 0 && MemoryLimitCalculator.maxAvailable() < maxFreeMemory; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMap.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMap.java deleted file mode 100644 index 1500ae2..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMap.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.cache; - -import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; -import org.apache.shenyu.common.concurrent.MemoryLimitCalculator; -import org.apache.shenyu.common.concurrent.ShenyuThreadFactory; -import org.apache.shenyu.common.constant.Constants; -import org.checkerframework.checker.nullness.qual.NonNull; - -import javax.annotation.concurrent.ThreadSafe; -import java.io.Serializable; -import java.lang.ref.WeakReference; -import java.util.AbstractMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * The differences between this class and {@link MemorySafeLRUMap} - * is that this class is thread safe, and it use WindowTinyLFU algorithm - * provided by caffeine which is better than LRU algorithm. - */ -@ThreadSafe -public class MemorySafeWindowTinyLFUMap extends AbstractMap implements Serializable { - - private static final long serialVersionUID = -3288161459386389022L; - - private static final AtomicBoolean GLOBAL = new AtomicBoolean(false); - - private static final Set>> ALL = new CopyOnWriteArraySet<>(); - - private final int maxFreeMemory; - - private final Cache cache; - - public MemorySafeWindowTinyLFUMap(final int maxFreeMemory, - final int initialSize) { - this(maxFreeMemory, initialSize, Long.MAX_VALUE, Constants.LRU_MAP_MAXSIZE); - } - - public MemorySafeWindowTinyLFUMap(final int maxFreeMemory, - final int initialSize, - final long expireAfterWrite, - final long maximumSize) { - this.maxFreeMemory = maxFreeMemory; - //see https://github.com/ben-manes/caffeine/issues/776 - this.cache = Caffeine.newBuilder() - .expireAfterWrite(expireAfterWrite, TimeUnit.MILLISECONDS) - .maximumSize(maximumSize) - .initialCapacity(initialSize) - .build(); - } - - @Override - public V get(final Object key) { - return cache.getIfPresent(key); - } - - @Override - public V put(final K key, final V value) { - checkAndScheduleRefresh(this); - final V previous = cache.getIfPresent(key); - cache.put(key, value); - return previous; - } - - @Override - public V remove(final Object key) { - final V previous = cache.getIfPresent(key); - cache.invalidate(key); - cache.cleanUp(); - return previous; - } - - @Override - public Set> entrySet() { - return cache.asMap().entrySet(); - } - - /** - * clean invalidated cache now. - */ - public void cleanUp() { - while (isFull()) { - invalidate(); - } - } - - /** - * invalidate coldest cache now. - */ - public void invalidate() { - cache.policy().eviction().ifPresent(eviction -> { - final Map<@NonNull K, @NonNull V> coldest = eviction.coldest(1); - if (coldest.size() == 0) { - return; - } - Optional.ofNullable(coldest.entrySet().iterator().next()) - .ifPresent(entry -> cache.invalidate(entry.getKey())); - }); - } - - /** - * whether to full. - * - * @return true if it's full - */ - public boolean isFull() { - // when free memory less than certain value, consider it's full - return cache.estimatedSize() > 0 && MemoryLimitCalculator.maxAvailable() < maxFreeMemory; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof MemorySafeWindowTinyLFUMap)) { - return false; - } - if (!super.equals(o)) { - return false; - } - MemorySafeWindowTinyLFUMap that = (MemorySafeWindowTinyLFUMap) o; - return maxFreeMemory == that.maxFreeMemory && Objects.equals(cache, that.cache); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), maxFreeMemory, cache); - } - - private static void checkAndScheduleRefresh(final MemorySafeWindowTinyLFUMap map) { - ALL.add(new WeakReference<>(map)); - if (!GLOBAL.get()) { - refresh(); - if (GLOBAL.compareAndSet(false, true)) { - ScheduledExecutorService scheduledExecutorService = - new ScheduledThreadPoolExecutor(1, ShenyuThreadFactory.create("Shenyu-Memory-Safe-Lru-Map", false)); - // check every 50 ms to improve performance - scheduledExecutorService.scheduleWithFixedDelay(MemorySafeWindowTinyLFUMap::refresh, 50, 50, TimeUnit.MILLISECONDS); - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - GLOBAL.set(false); - scheduledExecutorService.shutdown(); - })); - } - } - } - - private static void refresh() { - // try to clear weak reference - for (WeakReference> weakReference : ALL) { - MemorySafeWindowTinyLFUMap cacheMap = weakReference.get(); - if (Objects.isNull(cacheMap)) { - ALL.remove(weakReference); - } - } - // if jvm memory is full, try to release memory from caffine - boolean anyFull = ALL.stream().map(WeakReference::get).filter(Objects::nonNull) - .anyMatch(MemorySafeWindowTinyLFUMap::isFull); - while (anyFull) { - ALL.stream().map(WeakReference::get).filter(Objects::nonNull).forEach(MemorySafeWindowTinyLFUMap::invalidate); - anyFull = ALL.stream().map(WeakReference::get).filter(Objects::nonNull) - .anyMatch(MemorySafeWindowTinyLFUMap::isFull); - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/WindowTinyLFUMap.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/WindowTinyLFUMap.java deleted file mode 100644 index 826b645..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/cache/WindowTinyLFUMap.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.cache; - -import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; - -import javax.annotation.concurrent.ThreadSafe; -import java.io.Serializable; -import java.util.AbstractMap; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -/** - * this cache is provided by caffeine, the cache has two implements including weak-key cache and strong-key cache.
- *

the weak-key cache applies to scenarios where objects can be collected. when memory lock causes full gc, the weakKey will collect by gc.

- *

the strong-key cache applies to immutable cache object data, and the user determines the cache size.

- *

about the weak-key cache and strong-key cache, please refer to: - * caffeine cache ISSUES #776

- */ -@ThreadSafe -public class WindowTinyLFUMap extends AbstractMap implements Serializable { - - private static final long serialVersionUID = 2176631265536166614L; - - private final Cache cache; - - /** - * build caffeine cache. - * - * @param maximumSize maximumSize - */ - public WindowTinyLFUMap(final long maximumSize) { - this.cache = Caffeine.newBuilder() - .maximumSize(maximumSize) - .build(); - } - - /** - * initial caffeine cache include WeakReference cache and StrongReference cache. - * - *

when the weakKey is true that means using weakKeys cache, gc will collect the weak key, please refer to: - * com.github.benmanes.caffeine.cache.References.WeakKeyReference

- * - *

when the weakKey is false, use strong reference, jvm maybe throw oom-error.

- * - *
{@code Map strongMap = new WindowTinyLFUMap<>(100, 100, Boolean.FALSE);
-     * strongMap.put(new String("abc"), 1);
-     * strongMap.put(new String("abc"), 1);
-     * assert strongMap.get("abc") != null;
-     *
-     * Map strongMap = new WindowTinyLFUMap<>(100, 100, Boolean.TRUE);
-     * strongMap.put(new String("abc"), 1);
-     * strongMap.put(new String("abc"), 1);
-     * assert strongMap.get("abc") == null;
-     * }
- * - * @param initialCapacity initial capacity - * @param maximumSize maximum size - * @param weakKey weak key - */ - public WindowTinyLFUMap(final int initialCapacity, final long maximumSize, final Boolean weakKey) { - if (Boolean.TRUE.equals(weakKey)) { - this.cache = Caffeine.newBuilder() - .weakKeys() - .initialCapacity(initialCapacity) - .maximumSize(maximumSize) - .build(); - } else { - this.cache = Caffeine.newBuilder() - .initialCapacity(initialCapacity) - .maximumSize(maximumSize) - .build(); - } - } - - public WindowTinyLFUMap(final int initialSize, final long expireAfterWrite, final long maximumSize, final Boolean weakKey) { - if (Boolean.TRUE.equals(weakKey)) { - this.cache = Caffeine.newBuilder() - .weakKeys() - .initialCapacity(initialSize) - .expireAfterWrite(expireAfterWrite, TimeUnit.MILLISECONDS) - .maximumSize(maximumSize) - .build(); - } else { - this.cache = Caffeine.newBuilder() - .initialCapacity(initialSize) - .expireAfterWrite(expireAfterWrite, TimeUnit.MILLISECONDS) - .maximumSize(maximumSize) - .build(); - } - - } - - @Override - public V put(final K key, final V value) { - V v = cache.getIfPresent(key); - cache.put(key, value); - return v; - } - - @Override - public V get(final Object key) { - return cache.getIfPresent(key); - } - - @Override - public V remove(final Object key) { - V value = cache.getIfPresent(key); - cache.invalidate(key); - cache.cleanUp(); - return value; - } - - @Override - public void clear() { - this.cache.invalidateAll(); - this.cache.cleanUp(); - } - - @Override - public int size() { - return this.cache.asMap().entrySet().size(); - } - - @Override - public Set> entrySet() { - return cache.asMap().entrySet(); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/AbortPolicy.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/AbortPolicy.java deleted file mode 100644 index 758cd0f..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/AbortPolicy.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.Queue; - -/** - * A handler for rejected element that throws a - * {@code RejectException}. - */ -public class AbortPolicy implements Rejector { - - @Override - public void reject(final E e, final Queue queue) { - throw new RejectException("no more memory can be used !"); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/DiscardOldestPolicy.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/DiscardOldestPolicy.java deleted file mode 100644 index 44a8fc0..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/DiscardOldestPolicy.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.Queue; - -/** - * A handler for rejected element that discards the oldest element. - */ -public class DiscardOldestPolicy implements Rejector { - - @Override - public void reject(final E e, final Queue queue) { - queue.poll(); - queue.offer(e); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/DiscardPolicy.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/DiscardPolicy.java deleted file mode 100644 index d7e14c9..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/DiscardPolicy.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.Queue; - -/** - * A handler for rejected element that silently discards the - * rejected element. - */ -public class DiscardPolicy implements Rejector { - - @Override - public void reject(final E e, final Queue queue) { - - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/EagerExecutorService.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/EagerExecutorService.java deleted file mode 100644 index 94c4706..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/EagerExecutorService.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.concurrent.ExecutorService; - -/** - * EagerExecutorService. - */ -public interface EagerExecutorService extends ExecutorService { - - /** - * Returns the current number of threads in the pool. - * - * @return the number of threads - */ - int getPoolSize(); - - /** - * Returns the approximate number of threads that are actively - * executing tasks. - * - * @return the number of threads - */ - int getActiveCount(); - - /** - * Returns the maximum allowed number of threads. - * - * @return the maximum allowed number of threads - */ - int getMaximumPoolSize(); -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitCalculator.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitCalculator.java deleted file mode 100644 index 8688c27..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitCalculator.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * {@link java.lang.Runtime#freeMemory()} technology is used to calculate the - * memory limit by using the percentage of the current maximum available memory, - * which can be used with {@link org.apache.shenyu.common.concurrent.MemoryLimiter}. - * - * @see org.apache.shenyu.common.concurrent.MemoryLimiter - */ -public class MemoryLimitCalculator { - - private static volatile long maxAvailable; - - private static final AtomicBoolean REFRESH_STARTED = new AtomicBoolean(false); - - private static void checkAndScheduleRefresh() { - if (!REFRESH_STARTED.get()) { - // see https://github.com/apache/dubbo/pull/10178 - refresh(); - if (REFRESH_STARTED.compareAndSet(false, true)) { - ScheduledExecutorService scheduledExecutorService = - new ScheduledThreadPoolExecutor(1, ShenyuThreadFactory.create("Shenyu-Memory-Calculator-", false)); - // check every 50 ms to improve performance - scheduledExecutorService.scheduleWithFixedDelay(MemoryLimitCalculator::refresh, 50, 50, TimeUnit.MILLISECONDS); - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - REFRESH_STARTED.set(false); - scheduledExecutorService.shutdown(); - } - )); - } - } - } - - private static void refresh() { - maxAvailable = Runtime.getRuntime().freeMemory(); - } - - /** - * Get the maximum available memory of the current JVM. - * - * @return maximum available memory - */ - public static long maxAvailable() { - checkAndScheduleRefresh(); - return maxAvailable; - } - - /** - * Take the current JVM's maximum available memory - * as a percentage of the result as the limit. - * - * @param percentage percentage - * @return available memory - */ - public static long calculate(final float percentage) { - if (percentage <= 0 || percentage > 1) { - throw new IllegalArgumentException(); - } - checkAndScheduleRefresh(); - return (long) (maxAvailable() * percentage); - } - - /** - * By default, it takes 80% of the maximum available memory of the current JVM. - * - * @return available memory - */ - public static long defaultLimit() { - checkAndScheduleRefresh(); - return (long) (maxAvailable() * 0.8); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitedLinkedBlockingQueue.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitedLinkedBlockingQueue.java deleted file mode 100644 index ea6ec11..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitedLinkedBlockingQueue.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.lang.instrument.Instrumentation; -import java.util.Collection; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -/** - * Can completely solve the OOM problem caused by {@link java.util.concurrent.LinkedBlockingQueue}. - * - * @see org.apache.shenyu.common.concurrent.MemoryLimiter - * @see org.apache.shenyu.common.concurrent.MemoryLimitCalculator - */ -public class MemoryLimitedLinkedBlockingQueue extends LinkedBlockingQueue { - - private static final long serialVersionUID = -6106022470621447542L; - - private final MemoryLimiter memoryLimiter; - - public MemoryLimitedLinkedBlockingQueue(final Instrumentation inst) { - this(Integer.MAX_VALUE, inst); - } - - public MemoryLimitedLinkedBlockingQueue(final long memoryLimit, - final Instrumentation inst) { - super(Integer.MAX_VALUE); - this.memoryLimiter = new MemoryLimiter(memoryLimit, inst); - } - - public MemoryLimitedLinkedBlockingQueue(final Collection c, - final long memoryLimit, - final Instrumentation inst) { - super(c); - this.memoryLimiter = new MemoryLimiter(memoryLimit, inst); - } - - /** - * set the memory limit. - * - * @param memoryLimit the memory limit - */ - public void setMemoryLimit(final long memoryLimit) { - memoryLimiter.setMemoryLimit(memoryLimit); - } - - /** - * get the memory limit. - * - * @return the memory limit - */ - public long getMemoryLimit() { - return memoryLimiter.getMemoryLimit(); - } - - /** - * get the current memory. - * - * @return the current memory - */ - public long getCurrentMemory() { - return memoryLimiter.getCurrentMemory(); - } - - /** - * get the current remain memory. - * - * @return the current remain memory - */ - public long getCurrentRemainMemory() { - return memoryLimiter.getCurrentRemainMemory(); - } - - @Override - public void put(final E e) throws InterruptedException { - memoryLimiter.acquireInterruptibly(e); - super.put(e); - } - - @Override - public boolean offer(final E e, final long timeout, final TimeUnit unit) throws InterruptedException { - return memoryLimiter.acquire(e, timeout, unit) && super.offer(e, timeout, unit); - } - - @Override - public boolean offer(final E e) { - return memoryLimiter.acquire(e) && super.offer(e); - } - - @Override - public E take() throws InterruptedException { - final E e = super.take(); - memoryLimiter.releaseInterruptibly(e); - return e; - } - - @Override - public E poll(final long timeout, final TimeUnit unit) throws InterruptedException { - final E e = super.poll(timeout, unit); - memoryLimiter.releaseInterruptibly(e, timeout, unit); - return e; - } - - @Override - public E poll() { - final E e = super.poll(); - memoryLimiter.release(e); - return e; - } - - @Override - public boolean remove(final Object o) { - final boolean success = super.remove(o); - if (success) { - memoryLimiter.release(o); - } - return success; - } - - @Override - public void clear() { - super.clear(); - memoryLimiter.reset(); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitedTaskQueue.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitedTaskQueue.java deleted file mode 100644 index 5df59eb..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimitedTaskQueue.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.lang.instrument.Instrumentation; - -/** - * MemoryLimitedTaskQueue in the {@link org.apache.shenyu.common.concurrent.ShenyuThreadPoolExecutor}. - * It offer a task if the executor's submittedTaskCount less than currentPoolThreadSize - * or the currentPoolThreadSize more than executor's maximumPoolSize. - * That can make the executor create new worker - * when the task num is bigger than corePoolSize but less than maximumPoolSize. - */ -public class MemoryLimitedTaskQueue extends MemoryLimitedLinkedBlockingQueue implements TaskQueue { - - private static final long serialVersionUID = -2635853580887179627L; - - private EagerExecutorService executor; - - public MemoryLimitedTaskQueue(final Instrumentation inst) { - super(inst); - } - - public MemoryLimitedTaskQueue(final long memoryLimit, final Instrumentation inst) { - super(memoryLimit, inst); - } - - @Override - public EagerExecutorService getExecutor() { - return executor; - } - - @Override - public void setExecutor(final EagerExecutorService executor) { - this.executor = executor; - } - - @Override - public boolean doOffer(final Runnable runnable) { - return super.offer(runnable); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimiter.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimiter.java deleted file mode 100644 index d771ef2..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemoryLimiter.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.lang.instrument.Instrumentation; -import java.util.Objects; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.LongAdder; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.ReentrantLock; - -/** - * memory limiter. - * - * @see org.apache.shenyu.common.concurrent.MemoryLimitCalculator - */ -public class MemoryLimiter { - - private final Instrumentation inst; - - private long memoryLimit; - - private final LongAdder memory = new LongAdder(); - - private final ReentrantLock acquireLock = new ReentrantLock(); - - private final Condition notLimited = acquireLock.newCondition(); - - private final ReentrantLock releaseLock = new ReentrantLock(); - - private final Condition notEmpty = releaseLock.newCondition(); - - public MemoryLimiter(final Instrumentation inst) { - this(Integer.MAX_VALUE, inst); - } - - public MemoryLimiter(final long memoryLimit, final Instrumentation inst) { - if (memoryLimit <= 0) { - throw new IllegalArgumentException(); - } - this.memoryLimit = memoryLimit; - this.inst = inst; - } - - /** - * set the memory limit. - * - * @param memoryLimit the memory limit - */ - public void setMemoryLimit(final long memoryLimit) { - if (memoryLimit <= 0) { - throw new IllegalArgumentException(); - } - this.memoryLimit = memoryLimit; - } - - /** - * get the memory limit. - * - * @return the memory limit - */ - public long getMemoryLimit() { - return memoryLimit; - } - - /** - * get the current memory. - * - * @return the current memory - */ - public long getCurrentMemory() { - return memory.sum(); - } - - /** - * get the current remain memory. - * - * @return the current remain memory - */ - public long getCurrentRemainMemory() { - return getMemoryLimit() - getCurrentMemory(); - } - - private void signalNotEmpty() { - releaseLock.lock(); - try { - notEmpty.signal(); - } finally { - releaseLock.unlock(); - } - } - - private void signalNotLimited() { - acquireLock.lock(); - try { - notLimited.signal(); - } finally { - acquireLock.unlock(); - } - } - - /** - * Locks to prevent both acquires and releases. - */ - private void fullyLock() { - acquireLock.lock(); - releaseLock.lock(); - } - - /** - * Unlocks to allow both acquires and releases. - */ - private void fullyUnlock() { - releaseLock.unlock(); - acquireLock.unlock(); - } - - /** - * acquire memory by {@link Object}. - * this method does not respond to interrupts. - * - * @param o memory size to be applied by calculating - * @return true if acquire success - */ - public boolean acquire(final Object o) { - if (Objects.isNull(o)) { - throw new NullPointerException(); - } - if (memory.sum() >= memoryLimit) { - return false; - } - acquireLock.lock(); - try { - final long sum = memory.sum(); - final long objectSize = inst.getObjectSize(o); - if (sum + objectSize >= memoryLimit) { - return false; - } - memory.add(objectSize); - if (memory.sum() < memoryLimit) { - notLimited.signal(); - } - } finally { - acquireLock.unlock(); - } - if (memory.sum() > 0) { - signalNotEmpty(); - } - return true; - } - - /** - * acquire memory by {@link Object}. - * this method response to interrupts. - * - * @param o memory size to be applied by calculating - * @param timeout max time to wait - * @param unit time unit - * @return true if acquire success - * @throws InterruptedException the InterruptedException - */ - public boolean acquire(final Object o, final long timeout, - final TimeUnit unit) throws InterruptedException { - if (Objects.isNull(o)) { - throw new NullPointerException(); - } - long nanos = unit.toNanos(timeout); - acquireLock.lockInterruptibly(); - try { - final long objectSize = inst.getObjectSize(o); - while (memory.sum() + objectSize >= memoryLimit) { - if (nanos <= 0) { - return false; - } - nanos = notLimited.awaitNanos(nanos); - } - memory.add(objectSize); - if (memory.sum() < memoryLimit) { - notLimited.signal(); - } - } finally { - acquireLock.unlock(); - } - if (memory.sum() > 0) { - signalNotEmpty(); - } - return true; - } - - /** - * acquire memory by {@link Object}. - * this method response to interrupts. - * - * @param o memory size to be applied by calculating - * @throws InterruptedException the InterruptedException - */ - public void acquireInterruptibly(final Object o) throws InterruptedException { - if (Objects.isNull(o)) { - throw new NullPointerException(); - } - acquireLock.lockInterruptibly(); - try { - final long objectSize = inst.getObjectSize(o); - while (memory.sum() + objectSize >= memoryLimit) { - notLimited.await(); - } - memory.add(objectSize); - if (memory.sum() < memoryLimit) { - notLimited.signal(); - } - } finally { - acquireLock.unlock(); - } - if (memory.sum() > 0) { - signalNotEmpty(); - } - } - - /** - * release memory by {@link Object}. - * this method does not respond to interrupts. - * - * @param o memory size to be applied by calculating - */ - public void release(final Object o) { - if (Objects.isNull(o)) { - return; - } - if (memory.sum() == 0) { - return; - } - releaseLock.lock(); - try { - final long objectSize = inst.getObjectSize(o); - if (memory.sum() > 0) { - memory.add(-objectSize); - if (memory.sum() > 0) { - notEmpty.signal(); - } - } - } finally { - releaseLock.unlock(); - } - if (memory.sum() < memoryLimit) { - signalNotLimited(); - } - } - - /** - * release memory by {@link Object}. - * this method response to interrupts. - * - * @param o memory size to be applied by calculating - * @throws InterruptedException the InterruptedException - */ - public void releaseInterruptibly(final Object o) throws InterruptedException { - if (Objects.isNull(o)) { - return; - } - releaseLock.lockInterruptibly(); - try { - final long objectSize = inst.getObjectSize(o); - while (memory.sum() == 0) { - notEmpty.await(); - } - memory.add(-objectSize); - if (memory.sum() > 0) { - notEmpty.signal(); - } - } finally { - releaseLock.unlock(); - } - if (memory.sum() < memoryLimit) { - signalNotLimited(); - } - } - - /** - * release memory by {@link Object}. - * this method response to interrupts. - * - * @param o memory size to be applied by calculating - * @param timeout max time to wait - * @param unit time unit - * @throws InterruptedException the InterruptedException - */ - public void releaseInterruptibly(final Object o, final long timeout, - final TimeUnit unit) throws InterruptedException { - if (Objects.isNull(o)) { - return; - } - long nanos = unit.toNanos(timeout); - releaseLock.lockInterruptibly(); - try { - final long objectSize = inst.getObjectSize(o); - while (memory.sum() == 0) { - if (nanos <= 0) { - return; - } - nanos = notEmpty.awaitNanos(nanos); - } - memory.add(-objectSize); - if (memory.sum() > 0) { - notEmpty.signal(); - } - } finally { - releaseLock.unlock(); - } - if (memory.sum() < memoryLimit) { - signalNotLimited(); - } - } - - /** - * reset this MemoryLimiter. - */ - public void reset() { - fullyLock(); - try { - if (memory.sumThenReset() < memoryLimit) { - notLimited.signal(); - } - } finally { - fullyUnlock(); - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemorySafeLinkedBlockingQueue.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemorySafeLinkedBlockingQueue.java deleted file mode 100644 index 6eff9a4..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemorySafeLinkedBlockingQueue.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.Collection; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -/** - * Can completely solve the OOM problem caused by {@link java.util.concurrent.LinkedBlockingQueue}, - * does not depend on {@link java.lang.instrument.Instrumentation} and is easier to use than - * {@link org.apache.shenyu.common.concurrent.MemoryLimitedLinkedBlockingQueue}. - */ -public class MemorySafeLinkedBlockingQueue extends LinkedBlockingQueue { - - private static final long serialVersionUID = 8032578371749960142L; - - private int maxFreeMemory; - - private Rejector rejector; - - public MemorySafeLinkedBlockingQueue(final int maxFreeMemory) { - super(Integer.MAX_VALUE); - this.maxFreeMemory = maxFreeMemory; - //default as DiscardPolicy to ensure compatibility with the old version - this.rejector = new DiscardPolicy<>(); - } - - public MemorySafeLinkedBlockingQueue(final Collection c, - final int maxFreeMemory) { - super(c); - this.maxFreeMemory = maxFreeMemory; - //default as DiscardPolicy to ensure compatibility with the old version - this.rejector = new DiscardPolicy<>(); - } - - /** - * set the max free memory. - * - * @param maxFreeMemory the max free memory - */ - public void setMaxFreeMemory(final int maxFreeMemory) { - this.maxFreeMemory = maxFreeMemory; - } - - /** - * get the max free memory. - * - * @return the max free memory limit - */ - public int getMaxFreeMemory() { - return maxFreeMemory; - } - - /** - * set the rejector. - * - * @param rejector the rejector - */ - public void setRejector(final Rejector rejector) { - this.rejector = rejector; - } - - /** - * determine if there is any remaining free memory. - * - * @return true if has free memory - */ - public boolean hasRemainedMemory() { - return MemoryLimitCalculator.maxAvailable() > maxFreeMemory; - } - - @Override - public void put(final E e) throws InterruptedException { - if (hasRemainedMemory()) { - super.put(e); - } - rejector.reject(e, this); - } - - @Override - public boolean offer(final E e, final long timeout, final TimeUnit unit) throws InterruptedException { - if (!hasRemainedMemory()) { - rejector.reject(e, this); - return false; - } - return super.offer(e, timeout, unit); - } - - @Override - public boolean offer(final E e) { - if (!hasRemainedMemory()) { - rejector.reject(e, this); - return false; - } - return super.offer(e); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemorySafeTaskQueue.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemorySafeTaskQueue.java deleted file mode 100644 index dca0ccf..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/MemorySafeTaskQueue.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.Collection; - -/** - * MemorySafeTaskQueue in the {@link org.apache.shenyu.common.concurrent.ShenyuThreadPoolExecutor}. - * It offer a task if the executor's submittedTaskCount less than currentPoolThreadSize - * or the currentPoolThreadSize more than executor's maximumPoolSize. - * That can make the executor create new worker - * when the task num is bigger than corePoolSize but less than maximumPoolSize. - */ -public class MemorySafeTaskQueue extends MemorySafeLinkedBlockingQueue implements TaskQueue { - - private static final long serialVersionUID = -1998413481091670338L; - - private EagerExecutorService executor; - - public MemorySafeTaskQueue(final int maxFreeMemory) { - super(maxFreeMemory); - } - - public MemorySafeTaskQueue(final Collection c, final int maxFreeMemory) { - super(c, maxFreeMemory); - } - - @Override - public EagerExecutorService getExecutor() { - return this.executor; - } - - @Override - public void setExecutor(final EagerExecutorService executor) { - this.executor = executor; - } - - @Override - public boolean doOffer(final Runnable runnable) { - return super.offer(runnable); - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/RejectException.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/RejectException.java deleted file mode 100644 index 8378faf..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/RejectException.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -/** - * Exception thrown by an {@link MemorySafeLinkedBlockingQueue} - * when a element cannot be accepted. - */ -public class RejectException extends RuntimeException { - - private static final long serialVersionUID = -3240015871717170195L; - - /** - * Constructs a {@code RejectException} with no detail message. - * The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause(Throwable) initCause}. - */ - public RejectException() { - } - - /** - * Constructs a {@code RejectException} with the - * specified detail message. The cause is not initialized, and may - * subsequently be initialized by a call to {@link - * #initCause(Throwable) initCause}. - * - * @param message the detail message - */ - public RejectException(final String message) { - super(message); - } - - /** - * Constructs a {@code RejectException} with the - * specified detail message and cause. - * - * @param message the detail message - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method) - */ - public RejectException(final String message, final Throwable cause) { - super(message, cause); - } - - /** - * Constructs a {@code RejectException} with the - * specified cause. The detail message is set to {@code (cause == - * null ? null : cause.toString())} (which typically contains - * the class and detail message of {@code cause}). - * - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method) - */ - public RejectException(final Throwable cause) { - super(cause); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/Rejector.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/Rejector.java deleted file mode 100644 index 3865498..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/Rejector.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.Queue; - -/** - * RejectHandler, it works when you need to custom reject action in - * {@link org.apache.shenyu.common.concurrent.MemorySafeLinkedBlockingQueue}. - * - * @see AbortPolicy - * @see DiscardPolicy - * @see DiscardOldestPolicy - */ -public interface Rejector { - - /** - * Method that may be invoked by a {@link MemorySafeLinkedBlockingQueue} when - * {@link MemorySafeLinkedBlockingQueue#hasRemainedMemory} return true. - * This may occur when no more memory are available because their bounds would be exceeded. - * - *

In the absence of other alternatives, the method may throw an unchecked - * {@link RejectException}, which will be propagated to the caller. - * - * @param e the element requested to be added - * @param queue the queue attempting to add this element - * @throws RejectException if there is no more memory - */ - void reject(E e, Queue queue); -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/ShenyuThreadPoolExecutor.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/ShenyuThreadPoolExecutor.java deleted file mode 100644 index fdaa1fa..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/ShenyuThreadPoolExecutor.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.Objects; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.RejectedExecutionHandler; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -/** - * ShenyuThreadPoolExecutor. - */ -public class ShenyuThreadPoolExecutor extends ThreadPoolExecutor implements EagerExecutorService { - - public ShenyuThreadPoolExecutor(final int corePoolSize, - final int maximumPoolSize, - final long keepAliveTime, - final TimeUnit unit, - final TaskQueue workQueue, - final ThreadFactory threadFactory, - final RejectedExecutionHandler handler) { - super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler); - workQueue.setExecutor(this); - } - - @Override - public void execute(final Runnable command) { - if (Objects.isNull(command)) { - throw new NullPointerException(); - } - - try { - super.execute(command); - } catch (RejectedExecutionException e) { - // retry to offer the task into queue. - final TaskQueue queue = (TaskQueue) super.getQueue(); - try { - if (!queue.retryOffer(command, 0, TimeUnit.MILLISECONDS)) { - throw new RejectedExecutionException("Queue capacity is full.", e); - } - } catch (InterruptedException t) { - throw new RejectedExecutionException(t); - } - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/TaskQueue.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/TaskQueue.java deleted file mode 100644 index d1f16bf..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/concurrent/TaskQueue.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import java.util.Objects; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.TimeUnit; - -/** - * TaskQueue. - */ -public interface TaskQueue extends BlockingQueue { - - /** - * get executor. - * - * @return the executor - */ - EagerExecutorService getExecutor(); - - /** - * set the executor. - * - * @param executor executor - */ - void setExecutor(EagerExecutorService executor); - - @Override - default boolean offer(final E e) { - if (Objects.isNull(getExecutor())) { - throw new RejectedExecutionException("The task queue does not have executor!"); - } - - int currentPoolThreadSize = getExecutor().getPoolSize(); - // have free worker. put task into queue to let the worker deal with task. - if (getExecutor().getActiveCount() < currentPoolThreadSize) { - return doOffer(e); - } - - // return false to let executor create new worker. - if (currentPoolThreadSize < getExecutor().getMaximumPoolSize()) { - return false; - } - - // currentPoolThreadSize >= max - return doOffer(e); - } - - /** - * offer element to the queue. - * - * @param e the element to add - * @return {@code true} if the element was added to this queue, else {@code false} - */ - boolean doOffer(E e); - - /** - * retry offer task. - * - * @param o task - * @param timeout timeout - * @param unit timeout unit - * @return offer success or not - * @throws java.util.concurrent.RejectedExecutionException if executor is terminated. - * @throws java.lang.InterruptedException if the current thread is interrupted. - */ - default boolean retryOffer(final E o, final long timeout, final TimeUnit unit) throws InterruptedException { - if (getExecutor().isShutdown()) { - throw new RejectedExecutionException("Executor is shutdown!"); - } - return offer(o, timeout, unit); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/NettyChannelProperties.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/NettyChannelProperties.java deleted file mode 100644 index e3dfd7c..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/NettyChannelProperties.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.config; - -import io.netty.buffer.ByteBufAllocator; -import io.netty.buffer.PooledByteBufAllocator; -import io.netty.buffer.UnpooledByteBufAllocator; -import io.netty.channel.DefaultMessageSizeEstimator; -import io.netty.channel.MessageSizeEstimator; - -import java.util.Objects; - -/** - * Netty channel properties. - */ -public class NettyChannelProperties { - - private static final String UN_POOLED = "unpooled"; - - private static final String POOLED = "pooled"; - - private Integer connectTimeoutMillis = 10000; - - private Integer writeBufferHighWaterMark = 65536; - - private Integer writeBufferLowWaterMark = 32768; - - private Integer writeSpinCount = 16; - - private Boolean autoRead = false; - - /** - * options: unpooled or pooled. - */ - private String allocType = POOLED; - - private Boolean soReuseAddr = false; - - /** - * message estimator. - */ - private Integer messageSizeEstimator = 8; - - /** - * single event executor. - */ - private Boolean singleEventExecutorPerGroup = true; - - /** - * get connectTimeoutMillis. - * - * @return connectTimeoutMillis - */ - public Integer getConnectTimeoutMillis() { - return connectTimeoutMillis; - } - - /** - * set connectTimeoutMillis. - * - * @param connectTimeoutMillis the connection timeout millis - */ - public void setConnectTimeoutMillis(final Integer connectTimeoutMillis) { - this.connectTimeoutMillis = connectTimeoutMillis; - } - - /** - * get writeBufferHighWaterMark. - * - * @return writeBufferHighWaterMark - */ - public Integer getWriteBufferHighWaterMark() { - return writeBufferHighWaterMark; - } - - /** - * set writeBufferHighWaterMark. - * - * @param writeBufferHighWaterMark write buffer high water mark - */ - public void setWriteBufferHighWaterMark(final Integer writeBufferHighWaterMark) { - this.writeBufferHighWaterMark = writeBufferHighWaterMark; - } - - /** - * get writeBufferLowWaterMark. - * - * @return writeBufferLowWaterMark - */ - public Integer getWriteBufferLowWaterMark() { - return writeBufferLowWaterMark; - } - - /** - * set writeBufferLowWaterMark. - * - * @param writeBufferLowWaterMark write buffer low water mark - */ - public void setWriteBufferLowWaterMark(final Integer writeBufferLowWaterMark) { - this.writeBufferLowWaterMark = writeBufferLowWaterMark; - } - - /** - * get writeSpinCount. - * - * @return writeSpinCount - */ - public Integer getWriteSpinCount() { - return writeSpinCount; - } - - /** - * set writeSpinCount. - * - * @param writeSpinCount WRITE_SPIN_COUNT - */ - public void setWriteSpinCount(final Integer writeSpinCount) { - this.writeSpinCount = writeSpinCount; - } - - /** - * get autoRead. - * - * @return autoRead - */ - public Boolean isAutoRead() { - return autoRead; - } - - /** - * set autoRead. - * - * @param autoRead AUTO_READ - */ - public void setAutoRead(final Boolean autoRead) { - this.autoRead = autoRead; - } - - /** - * get allocator. - * - * @return ByteBufAllocator - */ - public ByteBufAllocator getAllocator() { - return UN_POOLED.equals(getAllocType()) ? UnpooledByteBufAllocator.DEFAULT : PooledByteBufAllocator.DEFAULT; - } - - /** - * get allocator type. - * - * @return allocator type - */ - public String getAllocType() { - return allocType; - } - - /** - * set allocator type. - * - * @param allocType allocator type - */ - public void setAllocType(final String allocType) { - this.allocType = allocType; - } - - /** - * get SoReuseaddr. - * - * @return soReuseAddr - */ - public Boolean isSoReuseAddr() { - return soReuseAddr; - } - - /** - * set setSoReuseAddr. - * - * @param soReuseAddr SO_REUSEADDR - */ - public void setSoReuseAddr(final Boolean soReuseAddr) { - this.soReuseAddr = soReuseAddr; - } - - /** - * message size estimator. - * - * @return MessageSizeEstimator - */ - public MessageSizeEstimator getMessageSizeEstimatorBuild() { - return Objects.isNull(messageSizeEstimator) || messageSizeEstimator == 8 ? DefaultMessageSizeEstimator.DEFAULT - : new DefaultMessageSizeEstimator(this.getMessageSizeEstimator()); - } - - /** - * get message size estimator. - * - * @return message size estimator - */ - public Integer getMessageSizeEstimator() { - return messageSizeEstimator; - } - - /** - * set message size estimator. - * - * @param messageSizeEstimator messageSizeEstimator - */ - public void setMessageSizeEstimator(final Integer messageSizeEstimator) { - this.messageSizeEstimator = messageSizeEstimator; - } - - /** - * single event executor. - * - * @return single event executor state - */ - public Boolean getSingleEventExecutorPerGroup() { - return singleEventExecutorPerGroup; - } - - /** - * set single event executor. - * - * @param singleEventExecutorPerGroup single executor - */ - public void setSingleEventExecutorPerGroup(final Boolean singleEventExecutorPerGroup) { - this.singleEventExecutorPerGroup = singleEventExecutorPerGroup; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/NettyHttpProperties.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/NettyHttpProperties.java deleted file mode 100644 index 82c8949..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/NettyHttpProperties.java +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.config; - -import org.apache.shenyu.common.config.ssl.SslCrtAndKeyFile; - -import java.util.List; - -/** - * The netty tcp properties. - */ -public class NettyHttpProperties { - - private Boolean webServerFactoryEnabled = true; - - private Integer selectCount = 1; - - private Integer workerCount = Runtime.getRuntime().availableProcessors() << 1; - - private Boolean accessLog = false; - - private ServerSocketChannelProperties serverSocketChannel = new ServerSocketChannelProperties(); - - private SocketChannelProperties socketChannel = new SocketChannelProperties(); - - private SniProperties sni = new SniProperties(); - - /** - * get webServerFactoryEnabled. - * - * @return webServerFactoryEnabled - */ - public Boolean isWebServerFactoryEnabled() { - return webServerFactoryEnabled; - } - - /** - * set webServerFactoryEnabled. - * set to false, user can custom the netty tcp server config. - * - * @param webServerFactoryEnabled web server factory enabled - */ - public void setWebServerFactoryEnabled(final Boolean webServerFactoryEnabled) { - this.webServerFactoryEnabled = webServerFactoryEnabled; - } - - /** - * get select count. - * - * @return selectCount - */ - public Integer getSelectCount() { - return selectCount; - } - - /** - * set selectCount. - * - * @param selectCount select count - */ - public void setSelectCount(final Integer selectCount) { - this.selectCount = selectCount; - } - - /** - * get workerCount. - * - * @return workerCount - */ - public Integer getWorkerCount() { - return workerCount; - } - - /** - * set workerCount. - * - * @param workerCount worker count - */ - public void setWorkerCount(final Integer workerCount) { - this.workerCount = workerCount; - } - - /** - * get serverSocketChannel. - * - * @return serverSocketChannel - */ - public ServerSocketChannelProperties getServerSocketChannel() { - return serverSocketChannel; - } - - /** - * set serverSocketChannel. - * - * @param serverSocketChannel server socket channel config - */ - public void setServerSocketChannel(final ServerSocketChannelProperties serverSocketChannel) { - this.serverSocketChannel = serverSocketChannel; - } - - /** - * set socketChannel. - * - * @param socketChannel socket channel config - */ - public void setSocketChannel(final SocketChannelProperties socketChannel) { - this.socketChannel = socketChannel; - } - - /** - * get socketChannel. - * - * @return socketChannel - */ - public SocketChannelProperties getSocketChannel() { - return socketChannel; - } - - /** - * get sni properties. - * - * @return sni properties - */ - public SniProperties getSni() { - return sni; - } - - /** - * set sni properties. - * - * @param sni sni properties - */ - public void setSni(final SniProperties sni) { - this.sni = sni; - } - - /** - * get access log state. - * - * @return access log state - */ - public Boolean getAccessLog() { - return accessLog; - } - - /** - * set access log state. - * - * @param accessLog access log state - */ - public void setAccessLog(final Boolean accessLog) { - this.accessLog = accessLog; - } - - public static class ServerSocketChannelProperties extends NettyChannelProperties { - - private Integer soBacklog = 128; - - /** - * get soBacklog. - * - * @return soBacklog - */ - public Integer getSoBacklog() { - return soBacklog; - } - - /** - * set soBacklog. - * - * @param soBacklog SO_BACKLOG - */ - public void setSoBacklog(final Integer soBacklog) { - this.soBacklog = soBacklog; - } - } - - public static class SocketChannelProperties extends NettyChannelProperties { - - private Boolean soKeepAlive = false; - - private Integer soLinger = -1; - - private Boolean tcpNoDelay = true; - - private Integer ipTos = 0; - - private Boolean allowHalfClosure = false; - - /** - * get soKeepAlive. - * - * @return soKeepAlive - */ - public Boolean isSoKeepAlive() { - return soKeepAlive; - } - - /** - * set soKeepAlive. - * - * @param soKeepAlive SO_KEEPALIVE - */ - public void setSoKeepAlive(final Boolean soKeepAlive) { - this.soKeepAlive = soKeepAlive; - } - - /** - * get soLinger. - * - * @return soLinger - */ - public Integer getSoLinger() { - return soLinger; - } - - /** - * set soLinger. - * - * @param soLinger SO_LINGER - */ - public void setSoLinger(final Integer soLinger) { - this.soLinger = soLinger; - } - - /** - * get tcpNoDelay. - * - * @return tcpNoDelay - */ - public Boolean isTcpNoDelay() { - return tcpNoDelay; - } - - /** - * set tcpNoDelay. - * - * @param tcpNoDelay TCP_NODELAY - */ - public void setTcpNoDelay(final Boolean tcpNoDelay) { - this.tcpNoDelay = tcpNoDelay; - } - - /** - * get ipTos. - * @return ipTos - */ - public Integer getIpTos() { - return ipTos; - } - - /** - * set ipTos. - * - * @param ipTos IP_TOS - */ - public void setIpTos(final Integer ipTos) { - this.ipTos = ipTos; - } - - /** - * get isAllowHalfClosure. - * - * @return isAllowHalfClosure - */ - public Boolean isAllowHalfClosure() { - return allowHalfClosure; - } - - /** - * set allowHalfClosure. - * - * @param allowHalfClosure ALLOW_HALF_CLOSURE - */ - public void setAllowHalfClosure(final Boolean allowHalfClosure) { - this.allowHalfClosure = allowHalfClosure; - } - } - - public static class SniProperties { - - private Boolean enabled = false; - - private String mod; - - private String defaultK8sSecretName; - - private String defaultK8sSecretNamespace; - - private List certificates; - - /** - * Get default kubernetes secret namespace. - * - * @return default kubernetes secret namespace - */ - public String getDefaultK8sSecretNamespace() { - return defaultK8sSecretNamespace; - } - - /** - * Set default kubernetes secret namespace. - * - * @param defaultK8sSecretNamespace default kubernetes secret namespace - */ - public void setDefaultK8sSecretNamespace(final String defaultK8sSecretNamespace) { - this.defaultK8sSecretNamespace = defaultK8sSecretNamespace; - } - - /** - * get enabled. - * @return enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set enabled. - * @param enabled enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - /** - * get mod. - * @return mod - */ - public String getMod() { - return mod; - } - - /** - * set mod. - * @param mod mod - */ - public void setMod(final String mod) { - this.mod = mod; - } - - /** - * get defaultK8sSecretName. - * @return defaultK8sSecretName - */ - public String getDefaultK8sSecretName() { - return defaultK8sSecretName; - } - - /** - * set defaultK8sSecretName. - * @param defaultK8sSecretName defaultK8sSecretName - */ - public void setDefaultK8sSecretName(final String defaultK8sSecretName) { - this.defaultK8sSecretName = defaultK8sSecretName; - } - - /** - * get certificates. - * @return certificates - */ - public List getCertificates() { - return certificates; - } - - /** - * set certificates. - * @param certificates certificates - */ - public void setCertificates(final List certificates) { - this.certificates = certificates; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ShenyuConfig.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ShenyuConfig.java deleted file mode 100644 index 8b181bf..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ShenyuConfig.java +++ /dev/null @@ -1,2018 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.config; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.common.concurrent.MemoryLimitCalculator; -import org.apache.shenyu.common.enums.TrieMatchModeEnum; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * The type shenyu config. - */ -public class ShenyuConfig { - - private SwitchConfig switchConfig = new SwitchConfig(); - - private FileConfig file = new FileConfig(); - - private ExcludePath exclude = new ExcludePath(); - - private Health health = new Health(); - - private FallbackPath fallback = new FallbackPath(); - - private ExtPlugin extPlugin = new ExtPlugin(); - - private Scheduler scheduler = new Scheduler(); - - private UpstreamCheck upstreamCheck = new UpstreamCheck(); - - private CrossFilterConfig cross = new CrossFilterConfig(); - - private RibbonConfig ribbon = new RibbonConfig(); - - private Local local = new Local(); - - private WebsocketConfig websocket = new WebsocketConfig(); - - private SharedPool sharedPool = new SharedPool(); - - private MetricsConfig metrics = new MetricsConfig(); - - private SelectorMatchCache selectorMatchCache = new SelectorMatchCache(); - - private RuleMatchCache ruleMatchCache = new RuleMatchCache(); - - private SpringCloudCacheConfig springCloudCache = new SpringCloudCacheConfig(); - - private AlertConfig alert = new AlertConfig(); - - /** - * Gets health. - * - * @return the health - */ - public Health getHealth() { - return health; - } - - /** - * Sets health. - * - * @param health the health - */ - public void setHealth(final Health health) { - this.health = health; - } - - /** - * Gets metrics. - * - * @return the metrics - */ - public MetricsConfig getMetrics() { - return metrics; - } - - /** - * Sets metrics. - * - * @param metrics the metrics - */ - public void setMetrics(final MetricsConfig metrics) { - this.metrics = metrics; - } - - /** - * Gets the shared thread pool config. - * - * @return the shared thread pool config - */ - public SharedPool getSharedPool() { - return sharedPool; - } - - /** - * Sets the shared thread pool config. - * - * @param sharedPool the shared thread pool config - */ - public void setSharedPool(final SharedPool sharedPool) { - this.sharedPool = sharedPool; - } - - /** - * Gets the local config. - * - * @return the local config - */ - public Local getLocal() { - return local; - } - - /** - * Sets the local config. - * - * @param local the local config - */ - public void setLocal(final Local local) { - this.local = local; - } - - /** - * Gets ribbon. - * - * @return the ribbon - */ - public RibbonConfig getRibbon() { - return ribbon; - } - - /** - * Sets ribbon. - * - * @param ribbon the ribbon - */ - public void setRibbon(final RibbonConfig ribbon) { - this.ribbon = ribbon; - } - - /** - * Gets switch config. - * - * @return the switch config - */ - public SwitchConfig getSwitchConfig() { - return switchConfig; - } - - /** - * Sets switch config. - * - * @param switchConfig the switch config - */ - public void setSwitchConfig(final SwitchConfig switchConfig) { - this.switchConfig = switchConfig; - } - - /** - * Gets scheduler. - * - * @return the scheduler - */ - public Scheduler getScheduler() { - return scheduler; - } - - /** - * Sets scheduler. - * - * @param scheduler the scheduler - */ - public void setScheduler(final Scheduler scheduler) { - this.scheduler = scheduler; - } - - /** - * Gets ext plugin. - * - * @return the ext plugin - */ - public ExtPlugin getExtPlugin() { - return extPlugin; - } - - /** - * Sets ext plugin. - * - * @param extPlugin the ext plugin - */ - public void setExtPlugin(final ExtPlugin extPlugin) { - this.extPlugin = extPlugin; - } - - /** - * Gets file. - * - * @return the file - */ - public FileConfig getFile() { - return file; - } - - /** - * Sets file. - * - * @param file the file - */ - public void setFile(final FileConfig file) { - this.file = file; - } - - /** - * Gets exclude. - * - * @return the exclude - */ - public ExcludePath getExclude() { - return exclude; - } - - /** - * Sets exclude. - * - * @param exclude the exclude - */ - public void setExclude(final ExcludePath exclude) { - this.exclude = exclude; - } - - /** - * Gets fallback. - * - * @return the fallback - */ - public FallbackPath getFallback() { - return fallback; - } - - /** - * Sets fallback. - * - * @param fallback the fallback - */ - public void setFallback(final FallbackPath fallback) { - this.fallback = fallback; - } - - /** - * Gets upstream check. - * - * @return the upstream check - */ - public UpstreamCheck getUpstreamCheck() { - return upstreamCheck; - } - - /** - * Sets upstream check. - * - * @param upstreamCheck the upstream check - */ - public void setUpstreamCheck(final UpstreamCheck upstreamCheck) { - this.upstreamCheck = upstreamCheck; - } - - /** - * Gets cross. - * - * @return the cross - */ - public CrossFilterConfig getCross() { - return cross; - } - - /** - * Gets the websocket config. - * - * @return the websocket config - */ - public WebsocketConfig getWebsocket() { - return websocket; - } - - /** - * Sets the websocket config. - * - * @param websocket the websocket config - */ - public void setWebsocket(final WebsocketConfig websocket) { - this.websocket = websocket; - } - - /** - * Sets cross. - * - * @param cross the cross - */ - public void setCross(final CrossFilterConfig cross) { - this.cross = cross; - } - - /** - * get selector match cache. - * - * @return selector match cache - */ - public SelectorMatchCache getSelectorMatchCache() { - return selectorMatchCache; - } - - /** - * set selector match cache. - * - * @param selectorMatchCache selector match cache - */ - public void setSelectorMatchCache(final SelectorMatchCache selectorMatchCache) { - this.selectorMatchCache = selectorMatchCache; - } - - /** - * get rule match cache. - * - * @return rule match cache - */ - public RuleMatchCache getRuleMatchCache() { - return ruleMatchCache; - } - - /** - * set rule match cache. - * - * @param ruleMatchCache rule match cache - */ - public void setRuleMatchCache(final RuleMatchCache ruleMatchCache) { - this.ruleMatchCache = ruleMatchCache; - } - - /** - * get spring cloud cache config. - * - * @return {@linkplain SpringCloudCacheConfig} - */ - public SpringCloudCacheConfig getSpringCloudCache() { - return springCloudCache; - } - - /** - * set spring cloud cache config. - * - * @param springCloudCache cache config - */ - public void setSpringCloudCache(final SpringCloudCacheConfig springCloudCache) { - this.springCloudCache = springCloudCache; - } - - /** - * Get shenyu alert report config. - * @return alert config - */ - public AlertConfig getAlert() { - return alert; - } - - /** - * Set shenyu alert report config. - * @param alert alert config - */ - public void setAlert(final AlertConfig alert) { - this.alert = alert; - } - - /** - * The type Scheduler. - */ - public static class Scheduler { - - private boolean enabled; - - private String type = "fixed"; - - private Integer threads = Math.max((Runtime.getRuntime().availableProcessors() << 1) + 1, 16); - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Gets type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Sets type. - * - * @param type the type - */ - public void setType(final String type) { - this.type = type; - } - - /** - * Gets threads. - * - * @return the threads - */ - public Integer getThreads() { - return threads; - } - - /** - * Sets threads. - * - * @param threads the threads - */ - public void setThreads(final Integer threads) { - this.threads = threads; - } - - } - - /** - * The type Ext plugin. - */ - public static class ExtPlugin { - - private String path; - - private boolean enabled; - - private Integer threads = 1; - - private Integer scheduleTime = 300; - - private Integer scheduleDelay = 30; - - /** - * Gets path. - * - * @return the path - */ - public String getPath() { - return path; - } - - /** - * Sets path. - * - * @param path the path - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Gets threads. - * - * @return the threads - */ - public Integer getThreads() { - return threads; - } - - /** - * Sets threads. - * - * @param threads the threads - */ - public void setThreads(final Integer threads) { - this.threads = threads; - } - - /** - * Gets schedule time. - * - * @return the schedule time - */ - public Integer getScheduleTime() { - return scheduleTime; - } - - /** - * Sets schedule time. - * - * @param scheduleTime the schedule time - */ - public void setScheduleTime(final Integer scheduleTime) { - this.scheduleTime = scheduleTime; - } - - /** - * Gets schedule delay. - * - * @return the schedule delay - */ - public Integer getScheduleDelay() { - return scheduleDelay; - } - - /** - * Sets schedule delay. - * - * @param scheduleDelay the schedule delay - */ - public void setScheduleDelay(final Integer scheduleDelay) { - this.scheduleDelay = scheduleDelay; - } - } - - public static class SelectorMatchCache { - - /** - * the match cache, L1 cache. - */ - private MatchCacheConfig cache = new MatchCacheConfig(); - - /** - * the trie cache, L2 cache. - */ - private ShenyuTrieConfig trie = new ShenyuTrieConfig(); - -/** - * get selector cache config. - * - * @return {@linkplain MatchCacheConfig} - */ - public MatchCacheConfig getCache() { - return cache; - } - - /** - * set selector cache config. - * - * @param cache SelectorCacheConfig - */ - public void setCache(final MatchCacheConfig cache) { - this.cache = cache; - } - - /** - * get rule cache Config. - * - * @return rule cache config - */ - public ShenyuTrieConfig getTrie() { - return trie; - } - - /** - * set rule cache config. - * - * @param trie rule cache - */ - public void setTrie(final ShenyuTrieConfig trie) { - this.trie = trie; - } - } - - public static class RuleMatchCache { - - /** - * the match cache, L1 cache. - */ - private MatchCacheConfig cache = new MatchCacheConfig(); - - /** - * the trie cache, L2 cache. - */ - private ShenyuTrieConfig trie = new ShenyuTrieConfig(); - - /** - * get selector cache config. - * - * @return {@linkplain MatchCacheConfig} - */ - public MatchCacheConfig getCache() { - return cache; - } - - /** - * set selector cache config. - * - * @param cache SelectorCacheConfig - */ - public void setCache(final MatchCacheConfig cache) { - this.cache = cache; - } - - /** - * get rule cache Config. - * - * @return rule cache config - */ - public ShenyuTrieConfig getTrie() { - return trie; - } - - /** - * set rule cache config. - * - * @param trie rule cache - */ - public void setTrie(final ShenyuTrieConfig trie) { - this.trie = trie; - } - } - - /** - * rule cache config. - */ - public static class MatchCacheConfig { - - private Boolean enabled = Boolean.TRUE; - - private int initialCapacity = 10000; - - private long maximumSize = 10000L; - - /** - * get rule cache enabled. - * - * @return rule cache enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set rule cache enabled. - * - * @param enabled rule cache enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - /** - * get initial capacity. - * - * @return initial capacity - */ - public int getInitialCapacity() { - return initialCapacity; - } - - /** - * set initial capacity. - * - * @param initialCapacity initialCapacity - */ - public void setInitialCapacity(final int initialCapacity) { - this.initialCapacity = initialCapacity; - } - - /** - * get maximum size. - * - * @return rule cache maximumSize - */ - public long getMaximumSize() { - return maximumSize; - } - - /** - * set rule cache maximumSize. - * - * @param maximumSize rule cache maximumSize - */ - public void setMaximumSize(final long maximumSize) { - this.maximumSize = maximumSize; - } - } - - /** - * The type Exclude path. - */ - public static class ExcludePath { - - private boolean enabled; - - private List paths = new ArrayList<>(); - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Sets paths. - * - * @param paths the paths - */ - public void setPaths(final List paths) { - this.paths = paths; - } - - /** - * get paths. - * - * @return paths paths - */ - public List getPaths() { - return paths; - } - } - - /** - * The type fallback path. - */ - public static class FallbackPath { - - private boolean enabled; - - private List paths = new ArrayList<>(); - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Sets paths. - * - * @param paths the paths - */ - public void setPaths(final List paths) { - this.paths = paths; - } - - /** - * get paths. - * - * @return paths paths - */ - public List getPaths() { - return paths; - } - } - - /** - * The type Health. - */ - public static class Health { - - private boolean enabled; - - private List paths = new ArrayList<>(); - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Sets paths. - * - * @param paths the paths - */ - public void setPaths(final List paths) { - this.paths = paths; - } - - /** - * get paths. - * - * @return paths paths - */ - public List getPaths() { - return paths; - } - } - - /** - * The type File config. - */ - public static class FileConfig { - - private boolean enabled; - - private Integer maxSize = 10; - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Gets file max size. - * - * @return the file max size - */ - public Integer getMaxSize() { - return maxSize; - } - - /** - * Sets file max size. - * - * @param maxSize the file max size - */ - public void setMaxSize(final Integer maxSize) { - this.maxSize = maxSize; - } - } - - /** - * The type Switch config. - */ - public static class SwitchConfig { - - private boolean local = true; - - private boolean collapseSlashes = true; - - /** - * Gets local. - * - * @return the local - */ - public boolean getLocal() { - return local; - } - - /** - * Sets local. - * - * @param local the local - */ - public void setLocal(final boolean local) { - this.local = local; - } - - /** - * get collapseSlashes. - * - * @return collapseSlashes - */ - public boolean getCollapseSlashes() { - return collapseSlashes; - } - - /** - * set collapseSlashes. - * - * @param collapseSlashes collapseSlashes - */ - public void setCollapseSlashes(final boolean collapseSlashes) { - this.collapseSlashes = collapseSlashes; - } - } - - /** - * The type Upstream check. - */ - public static class UpstreamCheck { - - private boolean enabled; - - private Integer poolSize = 10; - - private Integer timeout = 3000; - - private Integer healthyThreshold = 1; - - private Integer unhealthyThreshold = 1; - - private Integer interval = 5000; - - private boolean printEnabled; - - private Integer printInterval = 60000; - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * get checkThreadPoolSize. - * - * @return checkThreadPoolSize - */ - public Integer getPoolSize() { - return poolSize; - } - - /** - * set checkThreadPoolSize. - * - * @param poolSize checkThreadPoolSize - */ - public void setPoolSize(final Integer poolSize) { - this.poolSize = poolSize; - } - - /** - * Gets timeout. - * - * @return the timeout - */ - public Integer getTimeout() { - return timeout; - } - - /** - * Sets timeout. - * - * @param timeout the timeout - */ - public void setTimeout(final Integer timeout) { - this.timeout = timeout; - } - - /** - * Gets healthy threshold. - * - * @return the healthy threshold - */ - public Integer getHealthyThreshold() { - return healthyThreshold; - } - - /** - * Sets healthy threshold. - * - * @param healthyThreshold the healthy threshold - */ - public void setHealthyThreshold(final Integer healthyThreshold) { - this.healthyThreshold = healthyThreshold; - } - - /** - * Gets unhealthy threshold. - * - * @return the unhealthy threshold - */ - public Integer getUnhealthyThreshold() { - return unhealthyThreshold; - } - - /** - * Sets unhealthy threshold. - * - * @param unhealthyThreshold the unhealthy threshold - */ - public void setUnhealthyThreshold(final Integer unhealthyThreshold) { - this.unhealthyThreshold = unhealthyThreshold; - } - - /** - * Gets interval. - * - * @return the interval - */ - public Integer getInterval() { - return interval; - } - - /** - * Sets interval. - * - * @param interval the interval - */ - public void setInterval(final Integer interval) { - this.interval = interval; - } - - /** - * Gets print enabled. - * - * @return the print enabled - */ - public boolean getPrintEnabled() { - return printEnabled; - } - - /** - * Sets print enabled. - * - * @param printEnabled the print enabled - */ - public void setPrintEnabled(final boolean printEnabled) { - this.printEnabled = printEnabled; - } - - /** - * Gets print interval. - * - * @return the print interval - */ - public Integer getPrintInterval() { - return printInterval; - } - - /** - * Sets print interval. - * - * @param printInterval the print interval - */ - public void setPrintInterval(final Integer printInterval) { - this.printInterval = printInterval; - } - } - - /** - * The Cross Filter Config. - */ - public static class CrossFilterConfig { - - private static final Set DEFAULT_ALLOWED_HEADERS; - - static { - DEFAULT_ALLOWED_HEADERS = new HashSet() { - { - add("x-requested-with"); - add("authorization"); - add("Content-Type"); - add("Authorization"); - add("credential"); - add("X-XSRF-TOKEN"); - add("token"); - add("username"); - add("client"); - } - }; - } - - private boolean enabled; - - /** - * Comma-separated of “header”. - */ - private String allowedHeaders = ""; - - /** - * Comma-separated of “method”. - */ - private String allowedMethods = "*"; - - private AllowedOriginConfig allowedOrigin = new AllowedOriginConfig(); - - private boolean allowedAnyOrigin; - - private String allowedExpose = ""; - - private String maxAge = "18000"; - - private boolean allowCredentials; - - /** - * wrapper the headers. - * - * @param headers headers - * @return wrapped headers - */ - private String wrapperHeaders(final String headers) { - final Set headerSet = DEFAULT_ALLOWED_HEADERS; - if (StringUtils.isNotEmpty(headers)) { - headerSet.addAll(Stream.of(headers.split(",")).collect(Collectors.toSet())); - } - return String.join(",", headerSet); - } - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Gets the value of allowedHeaders. - * - * @return the value of allowedHeaders - */ - public String getAllowedHeaders() { - return allowedHeaders = wrapperHeaders(allowedHeaders); - } - - /** - * Sets the allowedHeaders. - * - * @param allowedHeaders allowedHeaders - */ - public void setAllowedHeaders(final String allowedHeaders) { - this.allowedHeaders = wrapperHeaders(allowedHeaders); - } - - /** - * Gets the value of allowedMethods. - * - * @return the value of allowedMethods - */ - public String getAllowedMethods() { - return allowedMethods; - } - - /** - * Sets the allowedMethods. - * - * @param allowedMethods allowedMethods - */ - public void setAllowedMethods(final String allowedMethods) { - this.allowedMethods = allowedMethods; - } - - /** - * Gets the value of allowedOrigin. - * - * @return the value of allowedOrigin - */ - public AllowedOriginConfig getAllowedOrigin() { - return allowedOrigin; - } - - /** - * Sets the allowedOrigin. - * - * @param allowedOrigin allowedOrigin - */ - public void setAllowedOrigin(final AllowedOriginConfig allowedOrigin) { - this.allowedOrigin = allowedOrigin; - } - - /** - * Gets the value of allowedAnyOrigin. - * - * @return the value of allowedAnyOrigin - */ - public boolean isAllowedAnyOrigin() { - return allowedAnyOrigin; - } - - /** - * Sets the allowedExpose. - * - * @param allowedAnyOrigin allowedExpose - */ - public void setAllowedAnyOrigin(final boolean allowedAnyOrigin) { - this.allowedAnyOrigin = allowedAnyOrigin; - } - - /** - * Gets the value of allowedExpose. - * - * @return the value of allowedExpose - */ - public String getAllowedExpose() { - return allowedExpose; - } - - /** - * Sets the allowedExpose. - * - * @param allowedExpose allowedExpose - */ - public void setAllowedExpose(final String allowedExpose) { - this.allowedExpose = allowedExpose; - } - - /** - * Gets the value of maxAge. - * - * @return the value of maxAge - */ - public String getMaxAge() { - return maxAge; - } - - /** - * Sets the maxAge. - * - * @param maxAge maxAge - */ - public void setMaxAge(final String maxAge) { - this.maxAge = maxAge; - } - - /** - * Gets the value of allowCredentials. - * - * @return the value of allowCredentials - */ - public boolean isAllowCredentials() { - return allowCredentials; - } - - /** - * Sets the allowCredentials. - * - * @param allowCredentials allowCredentials - */ - public void setAllowCredentials(final boolean allowCredentials) { - this.allowCredentials = allowCredentials; - } - - /** - * the cors allowedOrigin config. - */ - public static class AllowedOriginConfig { - - private String spacer = "."; - - private String domain; - - private Set prefixes = new HashSet<>(); - - private Set origins; - - private String originRegex; - - /** - * Gets the spacer. - * - * @return the value of spacer - */ - public String getSpacer() { - return spacer; - } - - /** - * Sets the spacer. - * - * @param spacer spacer - */ - public void setSpacer(final String spacer) { - this.spacer = spacer; - } - - /** - * Gets the domain. - * - * @return the value of domain - */ - public String getDomain() { - return domain; - } - - /** - * Sets the enabled. - * - * @param domain domain - */ - public void setDomain(final String domain) { - this.domain = domain; - } - - /** - * Gets the prefixes. - * - * @return the value of prefixes - */ - public Set getPrefixes() { - return prefixes; - } - - /** - * Sets the enabled. - * - * @param prefixes prefixes - */ - public void setPrefixes(final Set prefixes) { - this.prefixes = prefixes; - } - - /** - * Gets the prefixes. - * - * @return the value of prefixes - */ - public Set getOrigins() { - return origins; - } - - /** - * Sets the origins. - * - * @param origins origins - */ - public void setOrigins(final Set origins) { - this.origins = origins; - } - - /** - * Gets the originRegex. - * - * @return the value of originRegex - */ - public String getOriginRegex() { - return originRegex; - } - - /** - * Sets the originRegex. - * - * @param originRegex originRegex - */ - public void setOriginRegex(final String originRegex) { - this.originRegex = originRegex; - } - } - } - - /** - * The Ribbon Config. - */ - public static class RibbonConfig { - - /** - * see {@code com.netflix.client.config.CommonClientConfigKey#ServerListRefreshInterval}. - */ - private Integer serverListRefreshInterval = 10000; - - /** - * Instantiates a new RibbonConfig. - */ - public RibbonConfig() { - } - - /** - * Instantiates a new RibbonConfig. - * - * @param serverListRefreshInterval serverListRefreshInterval - */ - public RibbonConfig(final Integer serverListRefreshInterval) { - this.serverListRefreshInterval = serverListRefreshInterval; - } - - /** - * Gets serverListRefreshInterval. - * - * @return the serverListRefreshInterval - */ - public Integer getServerListRefreshInterval() { - return serverListRefreshInterval; - } - - /** - * setServerListRefreshInterval. - * - * @param serverListRefreshInterval serverListRefreshInterval - */ - public void setServerListRefreshInterval(final Integer serverListRefreshInterval) { - this.serverListRefreshInterval = serverListRefreshInterval; - } - } - - /** - * The local config. - */ - public static class Local { - - private boolean enabled; - - private String sha512Key; - - /** - * Instantiates a new Local. - */ - public Local() { - } - - /** - * Instantiates a new Local. - * - * @param sha512Key the sha 512 key - */ - public Local(final String sha512Key) { - this.sha512Key = sha512Key; - } - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Get Sha512Key. - * - * @return the key - */ - public String getSha512Key() { - return sha512Key; - } - - /** - * Set Sha512Key. - * - * @param sha512Key sha512Key - */ - public void setSha512Key(final String sha512Key) { - this.sha512Key = sha512Key; - } - } - - /** - * the websocket config. - */ - public static class WebsocketConfig { - - /** - * max frame pay load size mb. - */ - private Integer maxFramePayloadSize = 10; - - /** - * whether enable ping. - */ - private Boolean enableProxyPing = false; - - /** - * Get max frame payload size. - * - * @return the max frame payload szie - */ - public Integer getMaxFramePayloadSize() { - return maxFramePayloadSize; - } - - /** - * Set max frame payload size. - * - * @param maxFramePayloadSize the max frame paylod size - */ - public void setMaxFramePayloadSize(final Integer maxFramePayloadSize) { - this.maxFramePayloadSize = maxFramePayloadSize; - } - - /** - * Get whether enable ping. - * @return whether ping is enabled - */ - public Boolean getEnableProxyPing() { - return enableProxyPing; - } - - /** - * enable ping or disable ping. - * @param enableProxyPing enable ping or disable ping - */ - public void setEnableProxyPing(final boolean enableProxyPing) { - this.enableProxyPing = enableProxyPing; - } - } - - /** - * The type Shared Thread Pool. - */ - public static class SharedPool { - - /** - * Whether to enable shared thread pool, defaults to false. - * Note: it is planned to be enabled by default when all RPC/HTTP - * plugins support this shared thread pool. - */ - private Boolean enable = Boolean.FALSE; - - /** - * The the thread name prefix, defaults to shenyu-shared. - */ - private String prefix = "shenyu-shared"; - - /** - * the number of threads to keep in the thread pool. - */ - private Integer corePoolSize = 200; - - /** - * the maximum number of threads to allow in the thread pool. - */ - private Integer maximumPoolSize = Integer.MAX_VALUE; - - /** - * when the number of threads is greater than the core, - * this is the maximum time that excess idle threads - * will wait for new tasks before terminating. - * Note: the unit of time is {@link java.util.concurrent.TimeUnit#MILLISECONDS} - */ - private Long keepAliveTime = 60000L; - - /** - * Maximum memory allowed to be used by a blocking queue, yes, unlike other - * implementations of {@link java.util.concurrent.BlockingQueue} - * (which all control memory based on the length of the blocking queue), - * {@link org.apache.shenyu.common.concurrent.MemoryLimitedLinkedBlockingQueue} - * controls memory directly by calculating the memory size used by the blocking queue. - */ - private Long maxWorkQueueMemory = MemoryLimitCalculator.defaultLimit(); - - /** - * The memory used by the blocking queue is always in the safe range, and there - * is always an attempt to make the JVM's free memory higher than this value. - * - * @see org.apache.shenyu.common.concurrent.MemorySafeLinkedBlockingQueue#getMaxFreeMemory() - */ - private Integer maxFreeMemory; - - /** - * Whether to enable shared thread pool. - * - * @return whether to enable - */ - public Boolean getEnable() { - return enable; - } - - /** - * Set enable. - * - * @param enable the enable - */ - public void setEnable(final Boolean enable) { - this.enable = enable; - } - - /** - * Get shared thread pool name prefix. - * - * @return the shared thread pool name prefix - */ - public String getPrefix() { - return prefix; - } - - /** - * Set prefix. - * - * @param prefix the prefix - */ - public void setPrefix(final String prefix) { - this.prefix = prefix; - } - - /** - * Get shared thread pool core size. - * - * @return the shared thread pool core size - */ - public Integer getCorePoolSize() { - return corePoolSize; - } - - /** - * Set core pool size. - * - * @param corePoolSize the core pool size - */ - public void setCorePoolSize(final Integer corePoolSize) { - this.corePoolSize = corePoolSize; - } - - /** - * Get shared thread pool maximum size. - * - * @return the shared thread pool name prefix - */ - public Integer getMaximumPoolSize() { - return maximumPoolSize; - } - - /** - * Set max pool size. - * - * @param maximumPoolSize the max pool size - */ - public void setMaximumPoolSize(final Integer maximumPoolSize) { - this.maximumPoolSize = maximumPoolSize; - } - - /** - * Get shared thread pool keep alive time. - * - * @return the shared thread pool keep alive time - */ - public Long getKeepAliveTime() { - return keepAliveTime; - } - - /** - * Set keep alive time. - * - * @param keepAliveTime the keep alive time - */ - public void setKeepAliveTime(final Long keepAliveTime) { - this.keepAliveTime = keepAliveTime; - } - - /** - * Get shared thread pool max work queue memory. - * - * @return the shared thread pool max work queue memory - */ - public Long getMaxWorkQueueMemory() { - return maxWorkQueueMemory; - } - - /** - * Set max work queue memory. - * - * @param maxWorkQueueMemory the max work queue memory - */ - public void setMaxWorkQueueMemory(final Long maxWorkQueueMemory) { - this.maxWorkQueueMemory = maxWorkQueueMemory; - } - - /** - * Get shared thread pool max work queue free memory. - * - * @return the shared thread pool max work queue free memory - */ - public Integer getMaxFreeMemory() { - return maxFreeMemory; - } - - /** - * Set max work queue free memory. - * - * @param maxFreeMemory the max work queue free memory - */ - public void setMaxFreeMemory(final Integer maxFreeMemory) { - this.maxFreeMemory = maxFreeMemory; - } - } - - /** - * The type Metrics config. - */ - public static class MetricsConfig { - - private boolean enabled; - - private String name; - - private String host; - - private Integer port; - - private String jmxConfig; - - private Properties props; - - /** - * Instantiates a new Metrics config. - */ - public MetricsConfig() { - } - - /** - * Gets enabled. - * - * @return the enabled - */ - public boolean getEnabled() { - return enabled; - } - - /** - * Sets enabled. - * - * @param enabled the enabled - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Gets metrics name. - * - * @return the metrics name - */ - public String getName() { - return name; - } - - /** - * Sets metrics name. - * @param name the metrics name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * Gets host. - * @return the host - */ - public String getHost() { - return host; - } - - /** - * Sets host. - * @param host the host - */ - public void setHost(final String host) { - this.host = host; - } - - /** - * Gets port. - * @return the port - */ - public Integer getPort() { - return port; - } - - /** - * Sets port. - * - * @param port the port - */ - public void setPort(final Integer port) { - this.port = port; - } - - /** - * Gets jmx config. - * @return the jmx config - */ - public String getJmxConfig() { - return jmxConfig; - } - - /** - * Sets jmx config. - * @param jmxConfig the jmx config - */ - public void setJmxConfig(final String jmxConfig) { - this.jmxConfig = jmxConfig; - } - - /** - * Gets props. - * @return the props - */ - public Properties getProps() { - return props; - } - - /** - * Sets props. - * @param props the props - */ - public void setProps(final Properties props) { - this.props = props; - } - } - - /** - * shenyu trie config. - */ - public static class ShenyuTrieConfig { - - private Boolean enabled = Boolean.FALSE; - - private Long cacheSize = 512L; - - /** - * match mode. - * @see TrieMatchModeEnum - */ - private String matchMode = TrieMatchModeEnum.ANT_PATH_MATCH.getMatchMode(); - - /** - * get match enabled. - * @return Boolean - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set match enabled. - * @param enabled enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - /** - * get cache size. - * @return cache size - */ - public Long getCacheSize() { - return cacheSize; - } - - /** - * set cache size. - * @param cacheSize cache size - */ - public void setCacheSize(final Long cacheSize) { - this.cacheSize = cacheSize; - } - - /** - * get match mode. - * @return match mode - */ - public String getMatchMode() { - return matchMode; - } - - /** - * set match mode. - * @param matchMode match mode - */ - public void setMatchMode(final String matchMode) { - this.matchMode = matchMode; - } - } - - public static class SpringCloudCacheConfig { - private Boolean enabled = Boolean.FALSE; - - /** - * get shenyu spring cloud cache status. - * @return the enabled status - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set shenyu spring cloud cache status. - * @param enabled the status - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - } - - public static class AlertConfig { - private Boolean enabled = Boolean.FALSE; - - private String admins = "localhost:9095"; - - /** - * get shenyu spring cloud cache status. - * @return the enabled status - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set shenyu spring cloud cache status. - * @param enabled the status - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - /** - * Get shenyu admin alert report urls. - * eg: localhost:9095,localhost:9093 - * @return admin alert report server list - */ - public String getAdmins() { - return admins; - } - - /** - * Set shenyu admin alert report url. - * @param admins admin url - */ - public void setAdmins(final String admins) { - this.admins = admins; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/ShenyuSniAsyncMapping.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/ShenyuSniAsyncMapping.java deleted file mode 100644 index e1e5c3d..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/ShenyuSniAsyncMapping.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.config.ssl; - -import io.netty.util.AsyncMapping; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.Promise; -import org.apache.shenyu.common.exception.ShenyuException; -import reactor.netty.http.Http11SslContextSpec; -import reactor.netty.tcp.SslProvider; -import reactor.netty.tcp.TcpSslContextSpec; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Pattern; - -/** - * Sni async map, can be used to dynamically configure ssl certificates. - */ -public class ShenyuSniAsyncMapping implements AsyncMapping { - - private final ConcurrentHashMap sslProviderMap; - - public ShenyuSniAsyncMapping() { - this.sslProviderMap = new ConcurrentHashMap<>(); - } - - public ShenyuSniAsyncMapping(final List sslCrtAndKeys) { - if (Objects.isNull(sslCrtAndKeys) || sslCrtAndKeys.isEmpty()) { - throw new ShenyuException("The sslCrtAndKeys can not be null"); - } - this.sslProviderMap = new ConcurrentHashMap<>(); - sslCrtAndKeys.forEach(sslCrtAndKey -> { - Http11SslContextSpec sslContextSpec = Http11SslContextSpec.forServer(new File(sslCrtAndKey.getKeyCertChainFile()), - new File(sslCrtAndKey.getKeyFile())); - SslProvider sslProvider = SslProvider.builder().sslContext(sslContextSpec).build(); - this.sslProviderMap.put(sslCrtAndKey.getDomain(), sslProvider); - }); - } - - /** - * Add SslProvider by domain. - * - * @param domain domain - * @param sslProvider SslProvider - */ - public void addSslProvider(final String domain, final SslProvider sslProvider) { - sslProviderMap.put(domain, sslProvider); - } - - /** - * Add ssl config. - * - * @param sslCrtAndKey sslCrtAndKey - * @throws IOException IOException - */ - public void addSslCertificate(final SslCrtAndKey sslCrtAndKey) throws IOException { - if (sslCrtAndKey instanceof SslCrtAndKeyFile) { - SslCrtAndKeyFile sslCrtAndKeyFile = (SslCrtAndKeyFile) sslCrtAndKey; - TcpSslContextSpec sslContextSpec = TcpSslContextSpec.forServer(new File(sslCrtAndKeyFile.getKeyCertChainFile()), - new File(sslCrtAndKeyFile.getKeyFile())); - SslProvider sslProvider = SslProvider.builder().sslContext(sslContextSpec).build(); - this.sslProviderMap.put(sslCrtAndKeyFile.getDomain(), sslProvider); - } else if (sslCrtAndKey instanceof SslCrtAndKeyStream) { - SslCrtAndKeyStream sslCrtAndKeyStream = (SslCrtAndKeyStream) sslCrtAndKey; - sslCrtAndKeyStream.getKeyCertChainInputStream().reset(); - sslCrtAndKeyStream.getKeyInputStream().reset(); - TcpSslContextSpec sslContextSpec = TcpSslContextSpec.forServer(sslCrtAndKeyStream.getKeyCertChainInputStream(), - sslCrtAndKeyStream.getKeyInputStream()); - SslProvider sslProvider = SslProvider.builder().sslContext(sslContextSpec).build(); - this.sslProviderMap.put(sslCrtAndKeyStream.getDomain(), sslProvider); - } - } - - /** - * Remove ssl config by domain. - * - * @param domain domain - */ - public void removeSslCertificate(final String domain) { - this.sslProviderMap.remove(domain); - } - - /** - * Get SslProvider by domain. - * - * @param domain domain - * @param promise the promise of SslProvider - * @return SslProvider Future - */ - @Override - public Future map(final String domain, final Promise promise) { - try { - for (String key : sslProviderMap.keySet()) { - if (matchDomain(domain, key)) { - return promise.setSuccess(sslProviderMap.get(key)); - } - } - return promise.setFailure(new ShenyuException( - String.format("Can not find ssl certificate of domain %s", domain))); - } catch (Throwable cause) { - return promise.setFailure(cause); - } - } - - private boolean matchDomain(final String domain, final String pattern) { - return Pattern.matches(pattern.replace(".", "\\.").replace("*", ".*"), domain); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKey.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKey.java deleted file mode 100644 index 87531ba..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKey.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.config.ssl; - -/** - * ssl certificate and key. - */ -public interface SslCrtAndKey { -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKeyFile.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKeyFile.java deleted file mode 100644 index 8a39a28..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKeyFile.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.config.ssl; - -/** - * ssl certificate and key. - */ -public class SslCrtAndKeyFile implements SslCrtAndKey { - - private String domain; - - private String keyCertChainFile; - - private String keyFile; - - public SslCrtAndKeyFile() { - } - - public SslCrtAndKeyFile(final String domain, final String keyCertChainFile, final String keyFile) { - this.domain = domain; - this.keyCertChainFile = keyCertChainFile; - this.keyFile = keyFile; - } - - /** - * set domain. - * - * @param domain domain - */ - public void setDomain(final String domain) { - this.domain = domain; - } - - /** - * set keyCertChainFile. - * - * @param keyCertChainFile keyCertChainFile - */ - public void setKeyCertChainFile(final String keyCertChainFile) { - this.keyCertChainFile = keyCertChainFile; - } - - /** - * set keyFile. - * - * @param keyFile keyFile - */ - public void setKeyFile(final String keyFile) { - this.keyFile = keyFile; - } - - /** - * get domain. - * - * @return domain - */ - public String getDomain() { - return domain; - } - - /** - * get keyCertChainFile. - * - * @return keyCertChainFile - */ - public String getKeyCertChainFile() { - return keyCertChainFile; - } - - /** - * get keyFile. - * - * @return keyFile - */ - public String getKeyFile() { - return keyFile; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKeyStream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKeyStream.java deleted file mode 100644 index 67728bc..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/config/ssl/SslCrtAndKeyStream.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.config.ssl; - -import java.io.InputStream; - -/** - * ssl certificate and key. - */ -public class SslCrtAndKeyStream implements SslCrtAndKey { - - private String domain; - - private InputStream keyCertChainInputStream; - - private InputStream keyInputStream; - - public SslCrtAndKeyStream() { - } - - public SslCrtAndKeyStream(final String domain, final InputStream keyCertChainInputStream, final InputStream keyInputStream) { - this.domain = domain; - this.keyCertChainInputStream = keyCertChainInputStream; - this.keyInputStream = keyInputStream; - } - - /** - * get domain. - * - * @return domain - */ - public String getDomain() { - return domain; - } - - /** - * get keyCertChainInputStream. - * - * @return keyCertChainInputStream - */ - public InputStream getKeyCertChainInputStream() { - return keyCertChainInputStream; - } - - /** - * get keyInputStream. - * - * @return keyInputStream - */ - public InputStream getKeyInputStream() { - return keyInputStream; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/AdminConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/AdminConstants.java deleted file mode 100644 index d3316a2..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/AdminConstants.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * The type Admin constants. - */ -public final class AdminConstants { - - /** - * The constant SUCCESS, equals to ShenyuResultMessage.SUCCESS. - */ - public static final String SUCCESS = "SUCCESS"; - - /** - * The constant PLUGIN_NAME_IS_EXIST. - */ - public static final String PLUGIN_NAME_IS_EXIST = "The plugin name already exists and can't be added repeatedly!"; - - /** - * The constant RESOURCE_NAME_IS_EXIST. - */ - public static final String RESOURCE_NAME_IS_EXIST = "The resource name already exists and can't be added repeatedly!"; - - /** - * The constant ID_NOT_EXIST. - */ - public static final String ID_NOT_EXIST = "ID NOT EXIST!"; - - /** - * The constant PLUGIN_NAME_NOT_EXIST. - */ - public static final String PLUGIN_NAME_NOT_EXIST = "The plugin name not exist!"; - - /** - * The constant SYS_PLUGIN_NOT_DELETE. - */ - public static final String SYS_PLUGIN_NOT_DELETE = "System plugins can't be deleted!"; - - /** - * The constant SYS_PLUGIN_ID_NOT_EXIST. - */ - public static final String SYS_PLUGIN_ID_NOT_EXIST = "The plugin(s) does not exist!"; - - /** - * The constant SYS_API_ID_NOT_EXIST. - */ - public static final String SYS_API_ID_NOT_EXIST = "The api(s) does not exist!"; - - /** - * The constant DATA_PATH_IS_EXIST. - */ - public static final String DATA_PATH_IS_EXIST = "The path already exists and can't be added repeatedly!"; - - /** - * The constant PARAMS_ERROR. - */ - public static final String PARAMS_ERROR = "Error parameter!"; - - /** - * The constant Super Role ID. - */ - public static final String ROLE_SUPER_ID = "1346358560427216896"; - - /** - * The constant Plugin Menu ID. - */ - public static final String RESOURCE_PLUGIN_ID = "1346775491550474240"; - - /** - * The constant Plugin Url prefix. - */ - public static final String RESOURCE_PLUGIN_URL_PREFIX = "/plug/"; - - /** - * The constant Plugin Resource Icon. - */ - public static final String RESOURCE_PLUGIN_DEFAULT_ICON = "block"; - - /** - * The constant Selector Name. - */ - public static final String DATA_PERMISSION_SELECTOR = "selector"; - - /** - * The constant Rule Name. - */ - public static final String DATA_PERMISSION_RULE = "rule"; - - /** - * The constant Admin Name. - */ - public static final String ADMIN_NAME = "admin"; - - /** - * The constant selector data type. - */ - public static final Integer SELECTOR_DATA_TYPE = 0; - - /** - * the constant rule data type. - */ - public static final Integer RULE_DATA_TYPE = 1; - - /** - * the constant selector add. - */ - public static final String PLUGIN_SELECTOR_ADD = "SHENYU.BUTTON.PLUGIN.SELECTOR.ADD"; - - /** - * the constant selector type add. - */ - public static final String PLUGIN_TYPE_SELECTOR_ADD = "Selector:add"; - - /** - * the constant selector query. - */ - public static final String PLUGIN_SELECTOR_QUERY = "SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY"; - - /** - * the constant selector type query. - */ - public static final String PLUGIN_TYPE_SELECTOR_QUERY = "Selector:query"; - - /** - * the constant selector edit. - */ - public static final String PLUGIN_SELECTOR_EDIT = "SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT"; - - /** - * the constant selector type edit. - */ - public static final String PLUGIN_TYPE_SELECTOR_EDIT = "Selector:edit"; - - /** - * the constant selector delete. - */ - public static final String PLUGIN_SELECTOR_DELETE = "SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE"; - - /** - * the constant selector type delete. - */ - public static final String PLUGIN_TYPE_SELECTOR_DELETE = "Selector:delete"; - - /** - * the constant rule add. - */ - public static final String PLUGIN_RULE_ADD = "SHENYU.BUTTON.PLUGIN.RULE.ADD"; - - /** - * the constant rule type add. - */ - public static final String PLUGIN_TYPE_RULE_ADD = "Rule:add"; - - /** - * the constant rule query. - */ - public static final String PLUGIN_RULE_QUERY = "SHENYU.BUTTON.PLUGIN.RULE.QUERY"; - - /** - * the constant rule type query. - */ - public static final String PLUGIN_TYPE_RULE_QUERY = "Rule:query"; - - /** - * the constant rule edit. - */ - public static final String PLUGIN_RULE_EDIT = "SHENYU.BUTTON.PLUGIN.RULE.EDIT"; - - /** - * the constant rule type edit. - */ - public static final String PLUGIN_TYPE_RULE_EDIT = "Rule:edit"; - - /** - * the constant rule delete. - */ - public static final String PLUGIN_RULE_DELETE = "SHENYU.BUTTON.PLUGIN.RULE.DELETE"; - - /** - * the constant rule type delete. - */ - public static final String PLUGIN_TYPE_RULE_DELETE = "Rule:delete"; - - /** - * the constant plugin synchronize. - */ - public static final String PLUGIN_SYNCHRONIZE = "SHENYU.BUTTON.PLUGIN.SYNCHRONIZE"; - - /** - * the constant plugin type modify. - */ - public static final String PLUGIN_TYPE_SYNCHRONIZE = ":modify"; - - /** - * the constant table init dict type. - */ - public static final String DICT_TABLE_FLAG_TYPE = "table"; - - /** - * the constant table init dict code. - */ - public static final String DICT_TABLE_FLAG_DICTCODE = "INIT_FLAG"; - - /** - * the constant table init dict name. - */ - public static final String DICT_TABLE_FLAG_DICTNAME = "status"; - - /** - * the constant table init dict desc. - */ - public static final String DICT_TABLE_FLAG_DESC = "table(resource,permission) init status"; - - /** - * the constant table init dict sort. - */ - public static final Integer DICT_TABLE_FLAG_SORT = 0; - - /** - * The constant URI_SUFFIX. - */ - public static final String URI_SUFFIX = "/**"; - - /** - * The constant URI_SLASH_SUFFIX. - */ - public static final String URI_SLASH_SUFFIX = "/"; - - /** - * The constant URI_VARIABLE_SUFFIX. - */ - public static final String URI_VARIABLE_SUFFIX = "{"; - - /** - * the constant api document global flag dict code. - */ - public static final String DICT_API_DOC_FLAG_DICTCODE = "API_DOC_GLOBAL_FLAG"; - - /** - * the constant api document global flag dict name. - */ - public static final String DICT_API_DOC_FLAG_DICTNAME = "status"; - - /** - * the constant api document environment dict name. - */ - public static final String DICT_TYPE_API_DOC_ENV = "apidocEnv"; - - public static final String TAG_ROOT_PARENT_ID = "0"; - - public static final String THE_PLUGIN_JAR_FILE_IS_NOT_CORRECT_OR_EXCEEDS_16_MB = "The plugin JAR file is not correct or exceeds 16MB!"; - - public static final String PLUGIN_INTERFACE_PATH = "org.apache.shenyu.plugin.api.ShenyuPlugin"; - - public static final String PLUGIN_ABSTRACR_PATH = "org.apache.shenyu.plugin.base.AbstractShenyuPlugin"; - - public static final String PROXY_SELECTOR_NAME_IS_EXIST = "The proxy selector name already exists and can't be added repeatedly!"; - - public static final String PROXY_SELECTOR_ID_IS_NOT_EXIST = "The proxy selector(s) does not exist"; - - public static final long THE_ONE_DAY_MILLIS_TIME = 24 * 60 * 60 * 1000L; - - public static final long FIVE_SECONDS_MILLIS_TIME = 5 * 1000L; - - public static final long TEN_SECONDS_MILLIS_TIME = 10 * 1000L; -} - diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ApolloPathConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ApolloPathConstants.java deleted file mode 100644 index e2a7c7d..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ApolloPathConstants.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -/** - * apollo path. - */ -public class ApolloPathConstants { - - /** - * apollo config default group. - */ - public static final String GROUP = "DEFAULT_GROUP"; - - /** - * plugin data id. - */ - public static final String PLUGIN_DATA_ID = "plugin"; - - /** - * selector data id. - */ - public static final String SELECTOR_DATA_ID = "selector"; - - /** - * rule data id. - */ - public static final String RULE_DATA_ID = "rule"; - - /** - * auth data id. - */ - public static final String AUTH_DATA_ID = "auth"; - - /** - * meta data id. - */ - public static final String META_DATA_ID = "meta"; - - /** - * proxy selector data id. - */ - public static final String PROXY_SELECTOR_DATA_ID = "proxy.selector"; - - /** - * proxy selector data id. - */ - public static final String DISCOVERY_DATA_ID = "discovery"; - - /** - * register metadata id. - */ - public static final String REGISTER_METADATA_ID = "shenyu.register.metadata"; - - /** - * register uri id. - */ - public static final String REGISTER_URI_ID = "shenyu.register.uri"; - - /** - * default value of get config. - */ - public static final String EMPTY_CONFIG_DEFAULT_VALUE = "{}"; - - /** - * default time out of get config. - */ - public static final long DEFAULT_TIME_OUT = 6000; - - /** - * get path key set. - * - * @return path key set - */ - public static Set pathKeySet() { - return new HashSet<>(Arrays.asList(PLUGIN_DATA_ID, SELECTOR_DATA_ID, RULE_DATA_ID, AUTH_DATA_ID, - META_DATA_ID, PROXY_SELECTOR_DATA_ID, DISCOVERY_DATA_ID)); - } -} - diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ConsulConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ConsulConstants.java deleted file mode 100644 index 2f4c60e..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ConsulConstants.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * Consul constants. - */ -public final class ConsulConstants { - - public static final String SYNC_PRE_FIX = "shenyu/sync"; - - /** - * plugin data path. - */ - public static final String PLUGIN_DATA = SYNC_PRE_FIX + "/plugin"; - - /** - * selector data path. - */ - public static final String SELECTOR_DATA = SYNC_PRE_FIX + "/selector"; - - /** - * rule data path. - */ - public static final String RULE_DATA = SYNC_PRE_FIX + "/rule"; - - /** - * auth data path. - */ - public static final String AUTH_DATA = SYNC_PRE_FIX + "/auth"; - - /** - * meta data path. - */ - public static final String META_DATA = SYNC_PRE_FIX + "/meta"; - - /** - * proxy selector data id. - */ - public static final String PROXY_SELECTOR_DATA_ID = SYNC_PRE_FIX + "/proxySelector"; - - /** - * The constant DISCOVERY_UPSTREAM. - */ - public static final String DISCOVERY_UPSTREAM = SYNC_PRE_FIX + "/discoveryUpstream"; - - /** - * default value of get config. - */ - public static final String EMPTY_CONFIG_DEFAULT_VALUE = "{}"; - - /** - * default value of config version index. - */ - public static final Long INIT_CONFIG_VERSION_INDEX = -1L; -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DefaultNodeConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DefaultNodeConstants.java deleted file mode 100644 index 884d909..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DefaultNodeConstants.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * DefaultNodeConstants. - */ -public final class DefaultNodeConstants implements Constants { - - /** - * JOIN_POINT. - */ - public static final String JOIN_POINT = "."; - - /** - * POINT_LIST. - */ - public static final String POINT_LIST = ".list"; - - /** - * LIST_STR. - */ - public static final String LIST_STR = "list"; - - /** - * EMPTY_ARRAY_STR. - */ - public static final String EMPTY_ARRAY_STR = "[]"; - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DefaultPathConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DefaultPathConstants.java deleted file mode 100644 index ff14dc0..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DefaultPathConstants.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * DefaultPathConstants. - */ -public final class DefaultPathConstants implements Constants { - - /** - * The constant SELECTOR_JOIN_RULE. - */ - public static final String SELECTOR_JOIN_RULE = "-"; - - private static final String PRE_FIX = "/shenyu"; - - /** - * The constant PLUGIN_PARENT. - */ - public static final String PLUGIN_PARENT = PRE_FIX + "/plugin"; - - /** - * The constant SELECTOR_PARENT. - */ - public static final String SELECTOR_PARENT = PRE_FIX + "/selector"; - - public static final String RULE_PARENT = PRE_FIX + "/rule"; - - /** - * The constant APP_AUTH_PARENT. - */ - public static final String APP_AUTH_PARENT = PRE_FIX + "/auth"; - - /** - * The constant META_DATA. - */ - public static final String META_DATA = PRE_FIX + "/metaData"; - - /** - * The constant PROXY_SELECTOR. - */ - public static final String PROXY_SELECTOR = PRE_FIX + "/proxySelectorData"; - - /** - * The constant DISCOVERY_UPSTREAM. - */ - public static final String DISCOVERY_UPSTREAM = PRE_FIX + "/discoveryUpstream"; - - /** - * acquire app_auth_path. - * - * @param appKey appKey - * @return app_auth_path string - */ - public static String buildAppAuthPath(final String appKey) { - return String.join(PATH_SEPARATOR, APP_AUTH_PARENT, appKey); - } - - /** - * Build meta data path string. - * - * @param path the path - * @return the string - */ - public static String buildMetaDataPath(final String path) { - String join = String.join(PATH_SEPARATOR, META_DATA, path); - return join.replaceAll("//", PATH_SEPARATOR); - } - - /** - * buildPluginParentPath. - * - * @return zk path for plugin - */ - public static String buildPluginParentPath() { - return String.join(PATH_SEPARATOR, PLUGIN_PARENT); - } - - /** - * buildPluginRealPath. - * - * @param pluginName pluginName - * @return zk path for plugin - */ - public static String buildPluginPath(final String pluginName) { - return String.join(PATH_SEPARATOR, PLUGIN_PARENT, pluginName); - } - - /** - * buildSelectorParentPath. - * - * @param pluginName pluginName - * @return zk path for selector - */ - public static String buildSelectorParentPath(final String pluginName) { - return String.join(PATH_SEPARATOR, SELECTOR_PARENT, pluginName); - } - - /** - * buildSelectorRealPath. - * - * @param pluginName pluginName - * @param selectorId selectorId - * @return zk full path for selector - */ - public static String buildSelectorRealPath(final String pluginName, final String selectorId) { - return String.join(PATH_SEPARATOR, SELECTOR_PARENT, pluginName, selectorId); - } - - /** - * buildRuleParentPath. - * - * @param pluginName pluginName - * @return zk rule parent path. - */ - public static String buildRuleParentPath(final String pluginName) { - return String.join(PATH_SEPARATOR, RULE_PARENT, pluginName); - } - - /** - * buildRulePath. - * - * @param pluginName pluginName - * @param selectorId selectorId - * @param ruleId ruleId - * @return /shenyu/rule/pluginName/selectorId-ruleId - */ - public static String buildRulePath(final String pluginName, final String selectorId, final String ruleId) { - return String.join(PATH_SEPARATOR, buildRuleParentPath(pluginName), String.join(SELECTOR_JOIN_RULE, selectorId, ruleId)); - } - - /** - * buildProxySelector. - * - * @param pluginName pluginName - * @param proxySelectorName selectorId - * @return /shenyu/proxySelectorData/pluginName/proxySelectorName - */ - public static String buildProxySelectorPath(final String pluginName, final String proxySelectorName) { - return String.join(PATH_SEPARATOR, PROXY_SELECTOR, pluginName, proxySelectorName); - } - - /** - * buildDiscoveryUpstreamPath. - * - * @param pluginName pluginName - * @param proxySelectorName selectorId - * @return /shenyu/discoveryUpstream/pluginName/proxySelectorName - */ - public static String buildDiscoveryUpstreamPath(final String pluginName, final String proxySelectorName) { - return String.join(PATH_SEPARATOR, DISCOVERY_UPSTREAM, pluginName, proxySelectorName); - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DubboParamConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DubboParamConstants.java deleted file mode 100644 index 4047a40..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/DubboParamConstants.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * DubboParamConstants. - */ -public final class DubboParamConstants { - - /** - * The constant PARAM_CLASS. - */ - public static final String PARAM_CLASS = "paramClass"; - - /** - * The constant CLASS_PARAMS. - */ - public static final String CLASS_PARAMS = "classParams"; - - /** - * The constant PARAMS. - */ - public static final String PARAMS = "params"; - - /** - * The constant INTERFACE_NAME. - */ - public static final String INTERFACE_NAME = "interfaceName"; - - /** - * The constant METHOD. - */ - public static final String METHOD = "method"; - - /** - * The constant TIMEOUT. - */ - public static final String TIMEOUT = "timeout"; - - /** - * The constant VERSION. - */ - public static final String VERSION = "version"; - - /** - * The constant GROUP. - */ - public static final String GROUP = "group"; - - /** - * The constant RETRIES. - */ - public static final String RETRIES = "retries"; - - /** - * The constant LOADBALANCE. - */ - public static final String LOADBALANCE = "loadbalance"; - - /** - * The constant url. - */ - public static final String URL = "url"; -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ExportImportConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ExportImportConstants.java deleted file mode 100644 index 9df9c31..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ExportImportConstants.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * Export/Import path constants. - */ -public final class ExportImportConstants { - /** - * export config file name. - */ - public static final String EXPORT_CONFIG_FILE_NAME = "shenyu_config_export_"; - - /** - * export config file name ext. - */ - public static final String EXPORT_CONFIG_FILE_NAME_EXT = ".zip"; - - /** - * export config file name date format. - */ - public static final String EXPORT_CONFIG_FILE_NAME_DATE_FORMAT = "yyyyMMddHHmmss"; - - /** - * plugin json config name. - */ - public static final String PLUGIN_JSON = "plugin.json"; - - /** - * selector json config name. - */ - public static final String SELECTOR_JSON = "selector.json"; - - /** - * rule json config name. - */ - public static final String RULE_JSON = "rule.json"; - - /** - * meta json config name. - */ - public static final String META_JSON = "meta.json"; - - /** - * auth json config name. - */ - public static final String AUTH_JSON = "auth.json"; - - /** - * dict json config name. - */ - public static final String DICT_JSON = "dict.json"; - - /** - * proxy_selector json config name. - */ - public static final String PROXY_SELECTOR_JSON = "proxy_selector.json"; - - /** - * discovery json config name. - */ - public static final String DISCOVERY_JSON = "discovery.json"; - - /** - * discovery_upstream json config name. - */ - public static final String DISCOVERY_UPSTREAM_JSON = "discovery_upstream.json"; - - /** - * plugin import success count. - */ - public static final String PLUGIN_IMPORT_SUCCESS_COUNT = "pluginImportSuccessCount"; - - /** - * plugin import fail message. - */ - public static final String PLUGIN_IMPORT_FAIL_MESSAGE = "pluginImportFailMessage"; - - /** - * selector import success count. - */ - public static final String SELECTOR_IMPORT_SUCCESS_COUNT = "selectorImportSuccessCount"; - - /** - * selector import fail message. - */ - public static final String SELECTOR_IMPORT_FAIL_MESSAGE = "selectorImportFailMessage"; - - /** - * rule import success count. - */ - public static final String RULE_IMPORT_SUCCESS_COUNT = "ruleImportSuccessCount"; - - /** - * rule import fail message. - */ - public static final String RULE_IMPORT_FAIL_MESSAGE = "ruleImportFailMessage"; - - /** - * dict import success count. - */ - public static final String DICT_IMPORT_SUCCESS_COUNT = "dictImportSuccessCount"; - - /** - * dict import fail message. - */ - public static final String DICT_IMPORT_FAIL_MESSAGE = "dictImportFailMessage"; - - /** - * proxy_selector import success count. - */ - public static final String PROXY_SELECTOR_IMPORT_SUCCESS_COUNT = "proxySelectorImportSuccessCount"; - - /** - * proxy_selector import fail message. - */ - public static final String PROXY_SELECTOR_IMPORT_FAIL_MESSAGE = "proxySelectorImportFailMessage"; - - /** - * discovery import success count. - */ - public static final String DISCOVERY_IMPORT_SUCCESS_COUNT = "discoveryImportSuccessCount"; - - /** - * discovery import fail message. - */ - public static final String DISCOVERY_IMPORT_FAIL_MESSAGE = "discoveryImportFailMessage"; - - /** - * discoveryUpstream import success count. - */ - public static final String DISCOVERY_UPSTREAM_IMPORT_SUCCESS_COUNT = "discoveryUpstreamImportSuccessCount"; - - /** - * discoveryUpstream import fail message. - */ - public static final String DISCOVERY_UPSTREAM_IMPORT_FAIL_MESSAGE = "discoveryUpstreamImportFailMessage"; - - /** - * auth import success count. - */ - public static final String AUTH_IMPORT_SUCCESS_COUNT = "authImportSuccessCount"; - - /** - * auth import fail message. - */ - public static final String AUTH_IMPORT_FAIL_MESSAGE = "authImportFailMessage"; - - /** - * meta import success count. - */ - public static final String META_IMPORT_SUCCESS_COUNT = "metaImportSuccessCount"; - - /** - * meta import fail message. - */ - public static final String META_IMPORT_FAIL_MESSAGE = "metaImportFailMessage"; - - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/HttpConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/HttpConstants.java deleted file mode 100644 index 7d29fd8..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/HttpConstants.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -import java.util.concurrent.TimeUnit; - -/** - * constants for http, including http long polling. - * - * @since 2.0.0 - */ -public final class HttpConstants { - - /** - * Client long polling timeout is 90s. - */ - public static final long CLIENT_POLLING_READ_TIMEOUT = TimeUnit.SECONDS.toMillis(90); - - /** - * The maximum timeout of server block is 60s. - */ - public static final long SERVER_MAX_HOLD_TIMEOUT = TimeUnit.SECONDS.toMillis(60); - - /** - * Default connection timeout is 10s. - */ - public static final long CLIENT_POLLING_CONNECT_TIMEOUT = TimeUnit.SECONDS.toMillis(10); - - /** - * Default write timeout is 90s. - */ - public static final long CLIENT_POLLING_WRITE_TIMEOUT = TimeUnit.SECONDS.toMillis(90); -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/NacosPathConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/NacosPathConstants.java deleted file mode 100644 index c9cccd9..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/NacosPathConstants.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * Nacos path constants. - */ -public final class NacosPathConstants { - - /** - * Nacos config default group. - */ - public static final String GROUP = "DEFAULT_GROUP"; - - /** - * plugin data id. - */ - public static final String PLUGIN_DATA_ID = "plugin"; - - /** - * selector data id. - */ - public static final String SELECTOR_DATA_ID = "selector"; - - /** - * rule data id. - */ - public static final String RULE_DATA_ID = "rule"; - - /** - * auth data id. - */ - public static final String AUTH_DATA_ID = "auth"; - - /** - * meta data id. - */ - public static final String META_DATA_ID = "meta"; - - /** - * proxy selector data id. - */ - public static final String PROXY_SELECTOR_DATA_ID = "proxy.selector"; - - /** - * proxy selector data id. - */ - public static final String DISCOVERY_DATA_ID = "discovery"; - - /** - * default value of get config. - */ - public static final String EMPTY_CONFIG_DEFAULT_VALUE = "{}"; - - /** - * default time out of get config. - */ - public static final long DEFAULT_TIME_OUT = 6000; -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/PolarisPathConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/PolarisPathConstants.java deleted file mode 100644 index 43e195f..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/PolarisPathConstants.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * Polaris path constants. - */ -public final class PolarisPathConstants { - - /** - * Polaris config default namespace. - */ - public static final String NAMESPACE = "default"; - - /** - * Polaris file group. - */ - public static final String FILE_GROUP = "shenyu"; - - /** - * auth data id. - */ - public static final String AUTH_DATA_ID_FILE_NAME = "auth"; - - /** - * plugin data id. - */ - public static final String PLUGIN_DATA_FILE_NAME = "plugin"; - - /** - * selector data id. - */ - public static final String SELECTOR_DATA_FILE_NAME = "selector"; - - /** - * rule data id. - */ - public static final String RULE_DATA_FILE_NAME = "rule"; - - /** - * meta data id. - */ - public static final String META_DATA_FILE_NAME = "meta"; - - /** - * proxy selector data id. - */ - public static final String PROXY_SELECTOR_FILE_NAME = "proxy.selector"; - - /** - * default value of get config. - */ - public static final String EMPTY_CONFIG_DEFAULT_VALUE = "{}"; -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RedisKeyConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RedisKeyConstants.java deleted file mode 100644 index 3f098e0..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RedisKeyConstants.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * RedisKeyConstants. - */ -public final class RedisKeyConstants implements Constants { - - /** - * The constant PLUGIN. - */ - public static final String PLUGIN = "plugin"; - - /** - * The constant SELECTOR. - */ - public static final String SELECTOR = "selector"; - - /** - * The constant RULE. - */ - public static final String RULE = "rule"; - - private static final String PLUGIN_INFO = ":info"; - - private static final String PLUGIN_SELECTOR = ":selector"; - - /** - * this is a function. - * - * @param pluginName pluginName - * @return java.lang.String string - */ - public static String pluginInfoKey(final String pluginName) { - return String.join("", pluginName, PLUGIN_INFO); - - } - - /** - * this is a function. - * - * @param pluginName pluginName - * @return java.lang.String string - */ - public static String pluginSelectorKey(final String pluginName) { - return String.join("", pluginName, PLUGIN_SELECTOR); - - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ResourceTypeConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ResourceTypeConstants.java deleted file mode 100644 index e140313..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/ResourceTypeConstants.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * The Constants for Resource Type. - */ -public final class ResourceTypeConstants { - - /** - * Permission. - */ - public static final Integer MENU_TYPE_2 = 2; -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RuleHandleConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RuleHandleConstants.java deleted file mode 100644 index df8e4f4..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RuleHandleConstants.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -import org.apache.shenyu.common.enums.LoadBalanceEnum; - -/** - * The Constants for RuleHandles. - */ -public final class RuleHandleConstants { - - /** - * Default load balance for RuleHandle. - */ - public static final LoadBalanceEnum DEFAULT_LOAD_BALANCE = LoadBalanceEnum.RANDOM; - - /** - * Default timeout for RuleHandle. - */ - public static final long DEFAULT_TIMEOUT = 3000; - - /** - * Default retries for RuleHandle. - */ - public static final int DEFAULT_RETRIES = 0; - - /** - * Default retry for RuleHandle. - */ - public static final int DEFAULT_RETRY = 0; -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RunningModeConstants.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RunningModeConstants.java deleted file mode 100644 index 6f1f4cc..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/constant/RunningModeConstants.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -/** - * running mode constants. - */ -public class RunningModeConstants { - - /** - * The constant eventType. - */ - public static final String EVENT_TYPE = "eventType"; - - /** - * The constant runningMode. - */ - public static final String RUNNING_MODE = "runningMode"; - - /** - * The constant masterUrl. - */ - public static final String MASTER_URL = "masterUrl"; - - /** - * The constant isMaster. - */ - public static final String IS_MASTER = "isMaster"; - - /** - * The constant CLUSTER. - */ - public static final String CLUSTER = "CLUSTER"; -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AlarmContent.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AlarmContent.java deleted file mode 100644 index fa0ed0d..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AlarmContent.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.Date; -import java.util.Map; - -/** - * AlertContent. - */ -public final class AlarmContent { - - /** - * primary key id. - */ - private Long id; - - /** - * alert title. - */ - private String title; - - /** - * Alarm level. - * 0: high-emergency-critical alarm-red. - * 1: medium-critical-critical alarm-orange. - * 2: low-warning-warning alarm-yellow - */ - private byte level; - - /** - * alert labels. - */ - private Map labels; - - /** - * The actual content of the alarm notification. - */ - private String content; - - /** - * create time. - */ - private Date dateCreated; - - /** - * update time. - */ - private Date dateUpdated; - - private AlarmContent() { - } - - private AlarmContent(final Builder builder) { - setTitle(builder.title); - setLevel(builder.level); - setLabels(builder.labels); - setContent(builder.content); - setDateCreated(builder.dateCreated); - setDateUpdated(builder.dateUpdated); - } - - /** - * get id. - * - * @return id - */ - public Long getId() { - return id; - } - - /** - * set id. - * - * @param id id - */ - public void setId(final Long id) { - this.id = id; - } - - /** - * get title. - * @return title - */ - public String getTitle() { - return title; - } - - /** - * set title. - * @param title title - */ - public void setTitle(final String title) { - this.title = title; - } - - /** - * get level. - * @return level - */ - public byte getLevel() { - return level; - } - - /** - * set level. - * @param level level - */ - public void setLevel(final byte level) { - this.level = level; - } - - /** - * get labels. - * @return labels - */ - public Map getLabels() { - return labels; - } - - /** - * set labels. - * @param labels labels - */ - public void setLabels(final Map labels) { - this.labels = labels; - } - - /** - * get content. - * - * @return content - */ - public String getContent() { - return content; - } - - /** - * set content. - * - * @param content content - */ - public void setContent(final String content) { - this.content = content; - } - - /** - * get dateCreated. - * - * @return dateCreated - */ - public Date getDateCreated() { - return dateCreated; - } - - /** - * set dateCreated. - * - * @param dateCreated dateCreated - */ - public void setDateCreated(final Date dateCreated) { - this.dateCreated = dateCreated; - } - - /** - * get dateUpdated. - * - * @return dateUpdated - */ - public Date getDateUpdated() { - return dateUpdated; - } - - /** - * set dateUpdated. - * - * @param dateUpdated dateUpdated - */ - public void setDateUpdated(final Date dateUpdated) { - this.dateUpdated = dateUpdated; - } - - - /** - * builder. - */ - public static final class Builder { - /** - * alert title. - */ - private String title; - - /** - * Alarm level. - * 0: high-emergency-critical alarm-red. - * 1: medium-critical-critical alarm-orange. - * 2: low-warning-warning alarm-yellow - */ - private byte level; - - /** - * alert labels. - */ - private Map labels; - - /** - * The actual content of the alarm notification. - */ - private String content; - - /** - * create time. - */ - private Date dateCreated; - - /** - * update time. - */ - private Date dateUpdated; - - /** - * builder constructor. - */ - public Builder() { - } - - /** - * builder constructor. - * @param val title - * @return builder - */ - public Builder title(final String val) { - title = val; - return this; - } - - /** - * builder constructor. - * @param val level - * @return level - */ - public Builder level(final byte val) { - level = val; - return this; - } - - /** - * builder constructor. - * @param val labels - * @return builder - */ - public Builder labels(final Map val) { - labels = val; - return this; - } - - /** - * builder constructor. - * @param val content - * @return builder - */ - public Builder content(final String val) { - content = val; - return this; - } - - /** - * builder constructor. - * @param val date created - * @return builder - */ - public Builder dateCreated(final Date val) { - dateCreated = val; - return this; - } - - /** - * builder constructor. - * @param val date updated - * @return builder - */ - public Builder dateUpdated(final Date val) { - dateUpdated = val; - return this; - } - - /** - * build content. - * @return alarm content - */ - public AlarmContent build() { - return new AlarmContent(this); - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AppAuthData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AppAuthData.java deleted file mode 100644 index 3c2329d..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AppAuthData.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.List; -import java.util.Objects; - -/** - * AppAuthDTO. - * - * @since 2.0.0 - */ -public class AppAuthData { - - private String appKey; - - private String appSecret; - - private Boolean enabled; - - private Boolean open; - - private List paramDataList; - - private List pathDataList; - - /** - * no args constructor. - */ - public AppAuthData() { - } - - /** - * builder constructor. - * - * @param builder builder - */ - private AppAuthData(final Builder builder) { - this.appKey = builder.appKey; - this.appSecret = builder.appSecret; - this.enabled = builder.enabled; - this.open = builder.open; - this.paramDataList = builder.paramDataList; - this.pathDataList = builder.pathDataList; - } - - /** - * class builder. - * - * @return builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get appKey. - * - * @return appKey - */ - public String getAppKey() { - return appKey; - } - - /** - * set appKey. - * - * @param appKey appKey - */ - public void setAppKey(final String appKey) { - this.appKey = appKey; - } - - /** - * get appSecret. - * - * @return appSecret - */ - public String getAppSecret() { - return appSecret; - } - - /** - * set appSecret. - * - * @param appSecret appSecret - */ - public void setAppSecret(final String appSecret) { - this.appSecret = appSecret; - } - - /** - * get enabled. - * - * @return enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set enabled. - * - * @param enabled enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - /** - * get open. - * - * @return open - */ - public Boolean getOpen() { - return open; - } - - /** - * set open. - * - * @param open open - */ - public void setOpen(final Boolean open) { - this.open = open; - } - - /** - * get paramDataList. - * - * @return paramDataList - */ - public List getParamDataList() { - return paramDataList; - } - - /** - * set paramDataList. - * - * @param paramDataList paramDataList - */ - public void setParamDataList(final List paramDataList) { - this.paramDataList = paramDataList; - } - - /** - * get pathDataList. - * - * @return pathDataList - */ - public List getPathDataList() { - return pathDataList; - } - - /** - * set pathDataList. - * - * @param pathDataList pathDataList - */ - public void setPathDataList(final List pathDataList) { - this.pathDataList = pathDataList; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - AppAuthData that = (AppAuthData) o; - return Objects.equals(appKey, that.appKey) && Objects.equals(appSecret, that.appSecret) && Objects.equals(enabled, that.enabled) - && Objects.equals(open, that.open) && Objects.equals(paramDataList, that.paramDataList) && Objects.equals(pathDataList, that.pathDataList); - } - - @Override - public int hashCode() { - return Objects.hash(appKey, appSecret, enabled, open, paramDataList, pathDataList); - } - - @Override - public String toString() { - return "AppAuthData{" - + "appKey='" - + appKey - + '\'' - + ", appSecret='" - + appSecret - + '\'' - + ", enabled=" - + enabled - + ", open=" - + open - + ", paramDataList=" - + paramDataList - + ", pathDataList=" - + pathDataList - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * appKey. - */ - private String appKey; - - /** - * appSecret. - */ - private String appSecret; - - /** - * enabled. - */ - private Boolean enabled; - - /** - * open. - */ - private Boolean open; - - /** - * paramDataList. - */ - private List paramDataList; - - /** - * pathDataList. - */ - private List pathDataList; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return AppAuthData - */ - public AppAuthData build() { - return new AppAuthData(this); - } - - /** - * build appKey. - * - * @param appKey appKey - * @return this - */ - public Builder appKey(final String appKey) { - this.appKey = appKey; - return this; - } - - /** - * build appSecret. - * - * @param appSecret appSecret - * @return this - */ - public Builder appSecret(final String appSecret) { - this.appSecret = appSecret; - return this; - } - - /** - * build enabled. - * - * @param enabled enabled - * @return this - */ - public Builder enabled(final Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * build open. - * - * @param open open - * @return this - */ - public Builder open(final Boolean open) { - this.open = open; - return this; - } - - /** - * build paramDataList. - * - * @param paramDataList paramDataList - * @return this - */ - public Builder paramDataList(final List paramDataList) { - this.paramDataList = paramDataList; - return this; - } - - /** - * build pathDataList. - * - * @param pathDataList pathDataList - * @return this - */ - public Builder pathDataList(final List pathDataList) { - this.pathDataList = pathDataList; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AuthParamData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AuthParamData.java deleted file mode 100644 index bf1da01..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AuthParamData.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.Objects; - -/** - * The type Auth param data. - */ -public class AuthParamData { - - private String appName; - - private String appParam; - - /** - * no args constructor. - */ - public AuthParamData() { - } - - /** - * all args constructor. - * - * @param appName appName - * @param appParam appParam - */ - public AuthParamData(final String appName, final String appParam) { - this.appName = appName; - this.appParam = appParam; - } - - /** - * get appName. - * - * @return appName - */ - public String getAppName() { - return appName; - } - - /** - * set appName. - * - * @param appName appName - */ - public void setAppName(final String appName) { - this.appName = appName; - } - - /** - * get appParam. - * - * @return appParam - */ - public String getAppParam() { - return appParam; - } - - /** - * set appParam. - * - * @param appParam appParam - */ - public void setAppParam(final String appParam) { - this.appParam = appParam; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - AuthParamData that = (AuthParamData) o; - return Objects.equals(appName, that.appName) && Objects.equals(appParam, that.appParam); - } - - @Override - public int hashCode() { - return Objects.hash(appName, appParam); - } - - @Override - public String toString() { - return "AuthParamData{" - + "appName='" - + appName - + '\'' - + ", appParam='" - + appParam - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AuthPathData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AuthPathData.java deleted file mode 100644 index f202db2..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/AuthPathData.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.Objects; - -/** - * The type Auth path data. - */ -public class AuthPathData { - - private String appName; - - private String path; - - private Boolean enabled; - - /** - * no args constructor. - */ - public AuthPathData() { - } - - /** - * all args constructor. - * - * @param appName appName - * @param path path - * @param enabled enabled - */ - public AuthPathData(final String appName, final String path, final Boolean enabled) { - this.appName = appName; - this.path = path; - this.enabled = enabled; - } - - /** - * builder constructor. - * - * @param builder builder - */ - private AuthPathData(final Builder builder) { - this.appName = builder.appName; - this.path = builder.path; - this.enabled = builder.enabled; - } - - /** - * class builder. - * - * @return builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get appName. - * - * @return appName - */ - public String getAppName() { - return appName; - } - - /** - * set appName. - * - * @param appName appName - */ - public void setAppName(final String appName) { - this.appName = appName; - } - - /** - * get path. - * - * @return path - */ - public String getPath() { - return path; - } - - /** - * set path. - * - * @param path path - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * get enabled. - * - * @return enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set enabled. - * - * @param enabled enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - AuthPathData that = (AuthPathData) o; - return Objects.equals(appName, that.appName) && Objects.equals(path, that.path) && Objects.equals(enabled, that.enabled); - } - - @Override - public int hashCode() { - return Objects.hash(appName, path, enabled); - } - - @Override - public String toString() { - return "AuthPathData{" - + "appName='" - + appName - + '\'' - + ", path='" - + path - + '\'' - + ", enabled=" - + enabled - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * appName. - */ - private String appName; - - /** - * path. - */ - private String path; - - /** - * enabled. - */ - private Boolean enabled; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return AuthPathData - */ - public AuthPathData build() { - return new AuthPathData(this); - } - - /** - * build appName. - * - * @param appName appName - * @return this - */ - public Builder appName(final String appName) { - this.appName = appName; - return this; - } - - /** - * build path. - * - * @param path path - * @return this - */ - public Builder path(final String path) { - this.path = path; - return this; - } - - /** - * build enabled. - * - * @param enabled enabled - * @return this - */ - public Builder enabled(final Boolean enabled) { - this.enabled = enabled; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ConditionData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ConditionData.java deleted file mode 100644 index 7c47f02..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ConditionData.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.Objects; - -/** - * ConditionDTO. - * - * @since 2.0.0 - */ -public class ConditionData { - - /** - * {@linkplain org.apache.shenyu.common.enums.ParamTypeEnum}. - */ - private String paramType; - - /** - * {@linkplain org.apache.shenyu.common.enums.OperatorEnum}. - */ - private String operator; - - /** - * param name. - */ - private String paramName; - - /** - * param value. - */ - private String paramValue; - - /** - * get paramType. - * - * @return paramType - */ - public String getParamType() { - return paramType; - } - - /** - * set paramType. - * - * @param paramType paramType - */ - public void setParamType(final String paramType) { - this.paramType = paramType; - } - - /** - * get operator. - * - * @return operator - */ - public String getOperator() { - return operator; - } - - /** - * set operator. - * - * @param operator operator - */ - public void setOperator(final String operator) { - this.operator = operator; - } - - /** - * get paramName. - * - * @return paramName - */ - public String getParamName() { - return paramName; - } - - /** - * set paramName. - * - * @param paramName paramName - */ - public void setParamName(final String paramName) { - this.paramName = paramName; - } - - /** - * get paramValue. - * - * @return paramValue - */ - public String getParamValue() { - return paramValue; - } - - /** - * set paramValue. - * - * @param paramValue paramValue - */ - public void setParamValue(final String paramValue) { - this.paramValue = paramValue; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ConditionData that = (ConditionData) o; - return Objects.equals(paramType, that.paramType) && Objects.equals(operator, that.operator) - && Objects.equals(paramName, that.paramName) && Objects.equals(paramValue, that.paramValue); - } - - @Override - public int hashCode() { - return Objects.hash(paramType, operator, paramName, paramValue); - } - - @Override - public String toString() { - return "ConditionData{" - + "paramType='" - + paramType - + '\'' - + ", operator='" - + operator - + '\'' - + ", paramName='" - + paramName - + '\'' - + ", paramValue='" - + paramValue - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ConfigData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ConfigData.java deleted file mode 100644 index 3253385..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ConfigData.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.apache.shenyu.common.utils.GsonUtils; - -import java.util.List; -import java.util.Objects; - -/** - * Data set, including {@link AppAuthData}、{@link ConditionData}、{@link PluginData}、{@link RuleData}、{@link SelectorData}. - * - * @since 2.0.0 - */ -public class ConfigData { - - private String md5; - - private long lastModifyTime; - - private List data; - - /** - * no args constructor. - */ - public ConfigData() { - } - - /** - * all args constructor. - * - * @param md5 md5 - * @param lastModifyTime lastModifyTime - * @param data data - */ - public ConfigData(final String md5, final long lastModifyTime, final List data) { - this.md5 = md5; - this.lastModifyTime = lastModifyTime; - this.data = data; - } - - /** - * get md5. - * - * @return md5 - */ - public String getMd5() { - return md5; - } - - /** - * set md5. - * - * @param md5 md5 - * @return this - */ - public ConfigData setMd5(final String md5) { - this.md5 = md5; - return this; - } - - /** - * get lastModifyTime. - * - * @return lastModifyTime - */ - public long getLastModifyTime() { - return lastModifyTime; - } - - /** - * set lastModifyTime. - * - * @param lastModifyTime lastModifyTime - * @return this - */ - public ConfigData setLastModifyTime(final long lastModifyTime) { - this.lastModifyTime = lastModifyTime; - return this; - } - - /** - * get data. - * - * @return data - */ - public List getData() { - return data; - } - - /** - * set data. - * - * @param data data - * @return this - */ - public ConfigData setData(final List data) { - this.data = data; - return this; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ConfigData that = (ConfigData) o; - return lastModifyTime == that.lastModifyTime && Objects.equals(md5, that.md5) && Objects.equals(data, that.data); - } - - @Override - public int hashCode() { - return Objects.hash(md5, lastModifyTime, data); - } - - @Override - public String toString() { - return GsonUtils.getInstance().toJson(this); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/DiscoverySyncData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/DiscoverySyncData.java deleted file mode 100644 index 0f5526b..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/DiscoverySyncData.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.List; - -public class DiscoverySyncData { - - /** - * selectorId. - */ - private String selectorId; - - /** - * pluginName. - */ - private String pluginName; - - /** - * selectorName. - */ - private String selectorName; - - /** - * upstreamDataList. - */ - private List upstreamDataList; - - /** - * getSelectorId. - * - * @return selectorId - */ - public String getSelectorId() { - return selectorId; - } - - /** - * setSelectorId. - * - * @param selectorId selectorId - */ - public void setSelectorId(final String selectorId) { - this.selectorId = selectorId; - } - - /** - * getPluginName. - * - * @return pluginName - */ - public String getPluginName() { - return pluginName; - } - - /** - * setPluginName. - * - * @param pluginName pluginName - */ - public void setPluginName(final String pluginName) { - this.pluginName = pluginName; - } - - /** - * getSelectorName. - * - * @return selectorName - */ - public String getSelectorName() { - return selectorName; - } - - /** - * setSelectorName. - * - * @param selectorName selectorName - */ - public void setSelectorName(final String selectorName) { - this.selectorName = selectorName; - } - - - /** - * getUpstreamDataList. - * - * @return upstreamDataList - */ - public List getUpstreamDataList() { - return upstreamDataList; - } - - /** - * setUpstreamDataList. - * - * @param upstreamDataList upstreamDataList - */ - public void setUpstreamDataList(final List upstreamDataList) { - this.upstreamDataList = upstreamDataList; - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/DiscoveryUpstreamData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/DiscoveryUpstreamData.java deleted file mode 100644 index 42bd7fe..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/DiscoveryUpstreamData.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import com.fasterxml.jackson.annotation.JsonFormat; - -import java.sql.Timestamp; -import java.util.Objects; - -public class DiscoveryUpstreamData { - - /** - * primary key. - */ - private String id; - - /** - * created time. - */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Timestamp dateCreated; - - /** - * updated time. - */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Timestamp dateUpdated; - - - /** - * discoveryHandlerId. - */ - private String discoveryHandlerId; - - /** - * protocol. - */ - private String protocol; - - /** - * url. - */ - private String url; - - /** - * status. - */ - private int status; - - /** - * weight. - */ - private int weight; - - /** - * props. - */ - private String props; - - - /** - * getDiscoveryHandlerId. - * - * @return discoveryHandlerId - */ - public String getDiscoveryHandlerId() { - return discoveryHandlerId; - } - - /** - * setDiscoveryHandlerId. - * - * @param discoveryHandlerId discoveryHandlerId - */ - public void setDiscoveryHandlerId(final String discoveryHandlerId) { - this.discoveryHandlerId = discoveryHandlerId; - } - - /** - * getProtocol. - * - * @return protocol - */ - public String getProtocol() { - return protocol; - } - - /** - * setProtocol. - * - * @param protocol protocol - */ - public void setProtocol(final String protocol) { - this.protocol = protocol; - } - - /** - * getUrl. - * - * @return url - */ - public String getUrl() { - return url; - } - - /** - * setUrl. - * - * @param url url - */ - public void setUrl(final String url) { - this.url = url; - } - - /** - * getStatus. - * - * @return status - */ - public int getStatus() { - return status; - } - - /** - * setStatus. - * - * @param status status - */ - public void setStatus(final int status) { - this.status = status; - } - - /** - * getWeight. - * - * @return weight - */ - public int getWeight() { - return weight; - } - - /** - * setWeight. - * - * @param weight weight - */ - public void setWeight(final int weight) { - this.weight = weight; - } - - /** - * getProps. - * - * @return props - */ - public String getProps() { - return props; - } - - /** - * setProps. - * - * @param props props - */ - public void setProps(final String props) { - this.props = props; - } - - /** - * Gets the value of id. - * - * @return the value of id - */ - public String getId() { - return id; - } - - /** - * Sets the id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Gets the value of dateCreated. - * - * @return the value of dateCreated - */ - public Timestamp getDateCreated() { - return dateCreated; - } - - /** - * Sets the dateCreated. - * - * @param dateCreated dateCreated - */ - public void setDateCreated(final Timestamp dateCreated) { - this.dateCreated = dateCreated; - } - - /** - * Gets the value of dateUpdated. - * - * @return the value of dateUpdated - */ - public Timestamp getDateUpdated() { - return dateUpdated; - } - - /** - * setDateUpdated. - * - * @param dateUpdated dateUpdated - */ - public void setDateUpdated(final Timestamp dateUpdated) { - this.dateUpdated = dateUpdated; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - DiscoveryUpstreamData that = (DiscoveryUpstreamData) o; - return status == that.status && weight == that.weight && Objects.equals(id, that.id) - && Objects.equals(dateCreated, that.dateCreated) && Objects.equals(dateUpdated, that.dateUpdated) - && Objects.equals(discoveryHandlerId, that.discoveryHandlerId) && Objects.equals(protocol, that.protocol) - && Objects.equals(url, that.url) && Objects.equals(props, that.props); - } - - @Override - public int hashCode() { - return Objects.hash(id, dateCreated, dateUpdated, discoveryHandlerId, protocol, url, status, weight, props); - } - - /** - * class builder. - * - * @return Builder - */ - public static DiscoveryUpstreamData.Builder builder() { - return new DiscoveryUpstreamData.Builder(); - } - - public static final class Builder { - - private String id; - - private Timestamp dateCreated; - - private Timestamp dateUpdated; - - private String discoveryHandlerId; - - private String protocol; - - private String url; - - private int status; - - private int weight; - - private String props; - - private Builder() { - } - - /** - * build new Object. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * build id. - * - * @param id id - * @return this - */ - public Builder id(final String id) { - this.id = id; - return this; - } - - /** - * build dateCreated. - * - * @param dateCreated dateCreated - * @return this - */ - public Builder dateCreated(final Timestamp dateCreated) { - this.dateCreated = dateCreated; - return this; - } - - /** - * build dateUpdated. - * - * @param dateUpdated dateUpdated - * @return this - */ - public Builder dateUpdated(final Timestamp dateUpdated) { - this.dateUpdated = dateUpdated; - return this; - } - - /** - * build discoveryHandlerId. - * - * @param discoveryHandlerId discoveryHandlerId - * @return this - */ - public Builder discoveryHandlerId(final String discoveryHandlerId) { - this.discoveryHandlerId = discoveryHandlerId; - return this; - } - - /** - * build protocol. - * - * @param protocol protocol - * @return this - */ - public Builder protocol(final String protocol) { - this.protocol = protocol; - return this; - } - - /** - * build url. - * - * @param url url - * @return this - */ - public Builder url(final String url) { - this.url = url; - return this; - } - - /** - * build status. - * - * @param status status - * @return this - */ - public Builder status(final int status) { - this.status = status; - return this; - } - - /** - * build weight. - * - * @param weight weight - * @return this - */ - public Builder weight(final int weight) { - this.weight = weight; - return this; - } - - /** - * build props. - * - * @param props props - * @return this - */ - public Builder props(final String props) { - this.props = props; - return this; - } - - /** - * build new Object. - * - * @return DiscoveryUpstreamData - */ - public DiscoveryUpstreamData build() { - DiscoveryUpstreamData discoveryUpstreamData = new DiscoveryUpstreamData(); - discoveryUpstreamData.setId(id); - discoveryUpstreamData.setDateCreated(dateCreated); - discoveryUpstreamData.setDateUpdated(dateUpdated); - discoveryUpstreamData.setDiscoveryHandlerId(discoveryHandlerId); - discoveryUpstreamData.setProtocol(protocol); - discoveryUpstreamData.setUrl(url); - discoveryUpstreamData.setStatus(status); - discoveryUpstreamData.setWeight(weight); - discoveryUpstreamData.setProps(props); - return discoveryUpstreamData; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/MetaData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/MetaData.java deleted file mode 100644 index 2eff33f..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/MetaData.java +++ /dev/null @@ -1,532 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.apache.commons.lang3.StringUtils; - -import java.util.Objects; - -public class MetaData { - - private String id; - - private String appName; - - private String contextPath; - - private String path; - - private String rpcType; - - private String serviceName; - - private String methodName; - - private String parameterTypes; - - private String rpcExt; - - private Boolean enabled; - - /** - * no args constructor. - */ - public MetaData() { - } - - /** - * all args constructor. - * - * @param id id - * @param appName appName - * @param contextPath contextPath - * @param path path - * @param rpcType rpcType - * @param serviceName serviceName - * @param methodName methodName - * @param parameterTypes parameterTypes - * @param rpcExt rpcExt - * @param enabled enabled - */ - public MetaData(final String id, final String appName, final String contextPath, final String path, final String rpcType, final String serviceName, - final String methodName, final String parameterTypes, final String rpcExt, final Boolean enabled) { - this.id = id; - this.appName = appName; - this.contextPath = contextPath; - this.path = path; - this.rpcType = rpcType; - this.serviceName = serviceName; - this.methodName = methodName; - this.parameterTypes = parameterTypes; - this.rpcExt = rpcExt; - this.enabled = enabled; - } - - /** - * builder constructor. - * - * @param builder builder - */ - private MetaData(final Builder builder) { - this.id = builder.id; - this.appName = builder.appName; - this.contextPath = builder.contextPath; - this.path = builder.path; - this.rpcType = builder.rpcType; - this.serviceName = builder.serviceName; - this.methodName = builder.methodName; - this.parameterTypes = builder.parameterTypes; - this.rpcExt = builder.rpcExt; - this.enabled = builder.enabled; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * get appName. - * - * @return appName - */ - public String getAppName() { - return appName; - } - - /** - * set appName. - * - * @param appName appName - */ - public void setAppName(final String appName) { - this.appName = appName; - } - - /** - * get contextPath. - * - * @return contextPath - */ - public String getContextPath() { - return contextPath; - } - - /** - * set contextPath. - * - * @param contextPath contextPath - */ - public void setContextPath(final String contextPath) { - this.contextPath = contextPath; - } - - /** - * get path. - * - * @return path - */ - public String getPath() { - return path; - } - - /** - * set path. - * - * @param path path - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * get rpcType. - * - * @return rpcType - */ - public String getRpcType() { - return rpcType; - } - - /** - * set rpcType. - * - * @param rpcType rpcType - */ - public void setRpcType(final String rpcType) { - this.rpcType = rpcType; - } - - /** - * get serviceName. - * - * @return serviceName - */ - public String getServiceName() { - return serviceName; - } - - /** - * set serviceName. - * - * @param serviceName serviceName - */ - public void setServiceName(final String serviceName) { - this.serviceName = serviceName; - } - - /** - * get methodName. - * - * @return methodName - */ - public String getMethodName() { - return methodName; - } - - /** - * set methodName. - * - * @param methodName methodName - */ - public void setMethodName(final String methodName) { - this.methodName = methodName; - } - - /** - * get parameterTypes. - * - * @return parameterTypes - */ - public String getParameterTypes() { - return parameterTypes; - } - - /** - * set parameterTypes. - * - * @param parameterTypes parameterTypes - */ - public void setParameterTypes(final String parameterTypes) { - this.parameterTypes = parameterTypes; - } - - /** - * get rpcExt. - * - * @return rpcExt - */ - public String getRpcExt() { - return rpcExt; - } - - /** - * set rpcExt. - * - * @param rpcExt rpcExt - */ - public void setRpcExt(final String rpcExt) { - this.rpcExt = rpcExt; - } - - /** - * get enabled. - * - * @return enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set enabled. - * - * @param enabled enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - MetaData metaData = (MetaData) o; - return Objects.equals(id, metaData.id) && Objects.equals(appName, metaData.appName) && Objects.equals(contextPath, metaData.contextPath) - && Objects.equals(path, metaData.path) && Objects.equals(rpcType, metaData.rpcType) && Objects.equals(serviceName, metaData.serviceName) - && Objects.equals(methodName, metaData.methodName) && Objects.equals(parameterTypes, metaData.parameterTypes) - && Objects.equals(rpcExt, metaData.rpcExt) && Objects.equals(enabled, metaData.enabled); - } - - @Override - public int hashCode() { - return Objects.hash(id, appName, contextPath, path, rpcType, serviceName, methodName, parameterTypes, rpcExt, enabled); - } - - @Override - public String toString() { - return "MetaData{" - + "id='" - + id - + '\'' - + ", appName='" - + appName - + '\'' - + ", contextPath='" - + contextPath - + '\'' - + ", path='" - + path - + '\'' - + ", rpcType='" - + rpcType - + '\'' - + ", serviceName='" - + serviceName - + '\'' - + ", methodName='" - + methodName - + '\'' - + ", parameterTypes='" - + parameterTypes - + '\'' - + ", rpcExt='" - + rpcExt - + '\'' - + ", enabled=" - + enabled - + '}'; - } - - /** - * update ContextPath. - */ - public void updateContextPath() { - if (StringUtils.isNoneBlank(this.path)) { - this.contextPath = StringUtils.indexOf(path, "/", 1) > -1 - ? this.path.substring(0, StringUtils.indexOf(path, "/", 1)) : path; - } - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * id. - */ - private String id; - - /** - * appName. - */ - private String appName; - - /** - * contextPath. - */ - private String contextPath; - - /** - * path. - */ - private String path; - - /** - * rpcType. - */ - private String rpcType; - - /** - * serviceName. - */ - private String serviceName; - - /** - * methodName. - */ - private String methodName; - - /** - * parameterTypes. - */ - private String parameterTypes; - - /** - * rpcExt. - */ - private String rpcExt; - - /** - * enabled. - */ - private Boolean enabled; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return MetaData - */ - public MetaData build() { - return new MetaData(this); - } - - /** - * build id. - * - * @param id id - * @return this - */ - public Builder id(final String id) { - this.id = id; - return this; - } - - /** - * build appName. - * - * @param appName appName - * @return this - */ - public Builder appName(final String appName) { - this.appName = appName; - return this; - } - - /** - * build contextPath. - * - * @param contextPath contextPath - * @return this - */ - public Builder contextPath(final String contextPath) { - this.contextPath = contextPath; - return this; - } - - /** - * build path. - * - * @param path path - * @return this - */ - public Builder path(final String path) { - this.path = path; - return this; - } - - /** - * build rpcType. - * - * @param rpcType rpcType - * @return this - */ - public Builder rpcType(final String rpcType) { - this.rpcType = rpcType; - return this; - } - - /** - * build serviceName. - * - * @param serviceName serviceName - * @return this - */ - public Builder serviceName(final String serviceName) { - this.serviceName = serviceName; - return this; - } - - /** - * build methodName. - * - * @param methodName methodName - * @return this - */ - public Builder methodName(final String methodName) { - this.methodName = methodName; - return this; - } - - /** - * build parameterTypes. - * - * @param parameterTypes parameterTypes - * @return this - */ - public Builder parameterTypes(final String parameterTypes) { - this.parameterTypes = parameterTypes; - return this; - } - - /** - * build rpcExt. - * - * @param rpcExt rpcExt - * @return this - */ - public Builder rpcExt(final String rpcExt) { - this.rpcExt = rpcExt; - return this; - } - - /** - * build enabled. - * - * @param enabled enabled - * @return this - */ - public Builder enabled(final Boolean enabled) { - this.enabled = enabled; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/PluginData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/PluginData.java deleted file mode 100644 index 50ad72b..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/PluginData.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.Objects; - -/** - * PluginData. - * - * @since 2.0.0 - */ -public class PluginData { - - private String id; - - private String name; - - private String config; - - private String role; - - private Boolean enabled; - - private Integer sort; - - private String pluginJar; - - /** - * no args constructor. - */ - public PluginData() { - } - - /** - * all args constructor without sort. - * - * @param id id - * @param name name - * @param config config - * @param role role - * @param enabled enabled - */ - public PluginData(final String id, final String name, final String config, final String role, final Boolean enabled, final String pluginJar) { - this.id = id; - this.name = name; - this.config = config; - this.role = role; - this.enabled = enabled; - this.pluginJar = pluginJar; - } - - /** - * all args constructor. - * - * @param id id - * @param name name - * @param config config - * @param role role - * @param enabled enabled - * @param sort sort - */ - public PluginData(final String id, final String name, final String config, final String role, final Boolean enabled, - final Integer sort, final String pluginJar) { - this.id = id; - this.name = name; - this.config = config; - this.role = role; - this.enabled = enabled; - this.sort = sort; - this.pluginJar = pluginJar; - } - - /** - * builder constructor. - * - * @param builder builder - */ - private PluginData(final Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.config = builder.config; - this.role = builder.role; - this.enabled = builder.enabled; - this.sort = builder.sort; - this.pluginJar = builder.pluginJar; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * get config. - * - * @return config - */ - public String getConfig() { - return config; - } - - /** - * set config. - * - * @param config config - */ - public void setConfig(final String config) { - this.config = config; - } - - /** - * get role. - * - * @return role - */ - public String getRole() { - return role; - } - - /** - * set role. - * - * @param role role - */ - public void setRole(final String role) { - this.role = role; - } - - /** - * get enabled. - * - * @return enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * get pluginJar. - * @return pluginJar - */ - public String getPluginJar() { - return pluginJar; - } - - /** - * set pluginJar. - * @param pluginJar pluginJar - */ - public void setPluginJar(final String pluginJar) { - this.pluginJar = pluginJar; - } - - /** - * get sort. - * - * @return enabled - */ - public Integer getSort() { - return sort; - } - - - /** - * set sort. - * - * @param sort sort value - */ - public void setSort(final Integer sort) { - this.sort = sort; - } - - /** - * set enabled. - * - * @param enabled enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - PluginData that = (PluginData) o; - return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(config, that.config) - && Objects.equals(role, that.role) && Objects.equals(enabled, that.enabled); - } - - @Override - public int hashCode() { - return Objects.hash(id, name, config, role, enabled); - } - - @Override - public String toString() { - return "PluginData{" - + "id='" + id + '\'' - + ", name='" + name + '\'' - + ", config='" + config + '\'' - + ", role='" + role + '\'' - + ", enabled=" + enabled - + ", sort=" + sort - + ", pluginJar=" + pluginJar - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * id. - */ - private String id; - - /** - * name. - */ - private String name; - - /** - * config. - */ - private String config; - - /** - * role. - */ - private String role; - - /** - * enabled. - */ - private Boolean enabled; - - /** - * sort. - */ - private Integer sort; - - /** - * sort. - */ - private String pluginJar; - - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return PluginData - */ - public PluginData build() { - return new PluginData(this); - } - - /** - * build id. - * - * @param id id - * @return this - */ - public Builder id(final String id) { - this.id = id; - return this; - } - - /** - * build name. - * - * @param name name - * @return this - */ - public Builder name(final String name) { - this.name = name; - return this; - } - - /** - * build config. - * - * @param config config - * @return this - */ - public Builder config(final String config) { - this.config = config; - return this; - } - - /** - * build role. - * - * @param role role - * @return this - */ - public Builder role(final String role) { - this.role = role; - return this; - } - - /** - * build enabled. - * - * @param enabled enabled - * @return this - */ - public Builder enabled(final Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * build sort. - * - * @param sort sort - * @return this - */ - public Builder sort(final Integer sort) { - this.sort = sort; - return this; - } - - - /** - * build pluginJar. - * - * @param pluginJar pluginJar - * @return this - */ - public Builder pluginJar(final String pluginJar) { - this.pluginJar = pluginJar; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ProxySelectorData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ProxySelectorData.java deleted file mode 100644 index 0f28eed..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/ProxySelectorData.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.Properties; - -/** - * ProxySelectorData. - */ -public class ProxySelectorData { - - private String id; - - private String name; - - private String pluginName; - - private String type; - - private Integer forwardPort; - - private Properties props = new Properties(); - - /** - * getId. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * setId. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * getName. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * setName. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * getPluginName. - * - * @return pluginName - */ - public String getPluginName() { - return pluginName; - } - - /** - * setPluginName. - * - * @param pluginName pluginName - */ - public void setPluginName(final String pluginName) { - this.pluginName = pluginName; - } - - /** - * getType. - * - * @return type - */ - public String getType() { - return type; - } - - /** - * setType. - * - * @param type type - */ - public void setType(final String type) { - this.type = type; - } - - /** - * getForwardPort. - * - * @return forwardPort - */ - public Integer getForwardPort() { - return forwardPort; - } - - /** - * setForwardPort. - * - * @param forwardPort forwardPort - */ - public void setForwardPort(final Integer forwardPort) { - this.forwardPort = forwardPort; - } - - /** - * getProps. - * - * @return props - */ - public Properties getProps() { - return props; - } - - /** - * setProps. - * - * @param props props - */ - public void setProps(final Properties props) { - this.props = props; - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/RuleData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/RuleData.java deleted file mode 100644 index 4e8ffae..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/RuleData.java +++ /dev/null @@ -1,572 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.List; -import java.util.Objects; - -/** - * RuleData. - * - * @since 2.0.0 - */ -public class RuleData { - - private String id; - - private String name; - - private String pluginName; - - private String selectorId; - - /** - * match way(0 and 1 or). - */ - private Integer matchMode; - - private Integer sort; - - private Boolean enabled; - - private Boolean loged; - - /** - * handle message(different plugin have different handle to mark ,json style). - */ - private String handle; - - private List conditionDataList; - - private List beforeConditionDataList; - - /** - * match restful. - */ - private Boolean matchRestful; - - /** - * no args constructor. - */ - public RuleData() { - } - - /** - * builder constructor. - * - * @param builder builder - */ - private RuleData(final Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.pluginName = builder.pluginName; - this.selectorId = builder.selectorId; - this.matchMode = builder.matchMode; - this.sort = builder.sort; - this.enabled = builder.enabled; - this.loged = builder.loged; - this.handle = builder.handle; - this.conditionDataList = builder.conditionDataList; - this.beforeConditionDataList = builder.beforeConditionDataList; - this.matchRestful = builder.matchRestful; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * set id. - * - * @param id id - * @return this - */ - public RuleData setId(final String id) { - this.id = id; - return this; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * set name. - * - * @param name name - * @return this - */ - public RuleData setName(final String name) { - this.name = name; - return this; - } - - /** - * get pluginName. - * - * @return pluginName - */ - public String getPluginName() { - return pluginName; - } - - /** - * set pluginName. - * - * @param pluginName pluginName - * @return this - */ - public RuleData setPluginName(final String pluginName) { - this.pluginName = pluginName; - return this; - } - - /** - * get selectorId. - * - * @return selectorId - */ - public String getSelectorId() { - return selectorId; - } - - /** - * set selectorId. - * - * @param selectorId selectorId - * @return this - */ - public RuleData setSelectorId(final String selectorId) { - this.selectorId = selectorId; - return this; - } - - /** - * get matchMode. - * - * @return matchMode - */ - public Integer getMatchMode() { - return matchMode; - } - - /** - * set matchMode. - * - * @param matchMode matchMode - * @return this - */ - public RuleData setMatchMode(final Integer matchMode) { - this.matchMode = matchMode; - return this; - } - - /** - * get sort. - * - * @return sort - */ - public Integer getSort() { - return sort; - } - - /** - * set sort. - * - * @param sort sort - * @return this - */ - public RuleData setSort(final Integer sort) { - this.sort = sort; - return this; - } - - /** - * get enabled. - * - * @return enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set enabled. - * - * @param enabled enabled - * @return this - */ - public RuleData setEnabled(final Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * get loged. - * - * @return loged - */ - public Boolean getLoged() { - return loged; - } - - /** - * set loged. - * - * @param loged loged - * @return this - */ - public RuleData setLoged(final Boolean loged) { - this.loged = loged; - return this; - } - - /** - * get handle. - * - * @return handle - */ - public String getHandle() { - return handle; - } - - /** - * set handle. - * - * @param handle handle - * @return this - */ - public RuleData setHandle(final String handle) { - this.handle = handle; - return this; - } - - /** - * get conditionDataList. - * - * @return conditionDataList - */ - public List getConditionDataList() { - return conditionDataList; - } - - /** - * set conditionDataList. - * - * @param conditionDataList conditionDataList - * @return this - */ - public RuleData setConditionDataList(final List conditionDataList) { - this.conditionDataList = conditionDataList; - return this; - } - - /** - * get beforeConditionDataList. - * - * @return beforeConditionDataList - */ - public List getBeforeConditionDataList() { - return beforeConditionDataList; - } - - /** - * set beforeConditionDataList. - * - * @param beforeConditionDataList beforeConditionDataList - */ - public void setBeforeConditionDataList(final List beforeConditionDataList) { - this.beforeConditionDataList = beforeConditionDataList; - } - - /** - * get match restful. - * - * @return matchRestful - */ - public Boolean getMatchRestful() { - return matchRestful; - } - - /** - * set match restful. - * - * @param matchRestful matchRestful - */ - public void setMatchRestful(final Boolean matchRestful) { - this.matchRestful = matchRestful; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - final RuleData ruleData = (RuleData) o; - return Objects.equals(id, ruleData.id) - && Objects.equals(name, ruleData.name) - && Objects.equals(pluginName, ruleData.pluginName) - && Objects.equals(selectorId, ruleData.selectorId) - && Objects.equals(matchMode, ruleData.matchMode) - && Objects.equals(sort, ruleData.sort) - && Objects.equals(enabled, ruleData.enabled) - && Objects.equals(loged, ruleData.loged) - && Objects.equals(handle, ruleData.handle) - && Objects.equals(conditionDataList, ruleData.conditionDataList) - && Objects.equals(beforeConditionDataList, ruleData.beforeConditionDataList) - && Objects.equals(matchRestful, ruleData.matchRestful); - } - - @Override - public int hashCode() { - return Objects.hash(id, name, pluginName, selectorId, matchMode, sort, enabled, loged, handle, conditionDataList, - beforeConditionDataList, matchRestful); - } - - @Override - public String toString() { - return "RuleData{" - + "id='" - + id - + '\'' - + ", name='" - + name - + '\'' - + ", pluginName='" - + pluginName - + '\'' - + ", selectorId='" - + selectorId - + '\'' - + ", matchMode=" - + matchMode - + ", sort=" - + sort - + ", enabled=" - + enabled - + ", loged=" - + loged - + ", handle='" - + handle - + '\'' - + ", conditionDataList=" - + conditionDataList - + ", matchRestful=" - + matchRestful - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - private String id; - - private String name; - - private String pluginName; - - private String selectorId; - - private Integer matchMode; - - private Integer sort; - - private Boolean enabled; - - private Boolean loged; - - private String handle; - - private List conditionDataList; - - private List beforeConditionDataList; - - private Boolean matchRestful; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return RuleData - */ - public RuleData build() { - return new RuleData(this); - } - - /** - * build id. - * - * @param id id - * @return this - */ - public Builder id(final String id) { - this.id = id; - return this; - } - - /** - * build name. - * - * @param name name - * @return this - */ - public Builder name(final String name) { - this.name = name; - return this; - } - - /** - * build pluginName. - * - * @param pluginName pluginName - * @return this - */ - public Builder pluginName(final String pluginName) { - this.pluginName = pluginName; - return this; - } - - /** - * build selectorId. - * - * @param selectorId selectorId - * @return this - */ - public Builder selectorId(final String selectorId) { - this.selectorId = selectorId; - return this; - } - - /** - * build matchMode. - * - * @param matchMode matchMode - * @return this - */ - public Builder matchMode(final Integer matchMode) { - this.matchMode = matchMode; - return this; - } - - /** - * build sort. - * - * @param sort sort - * @return this - */ - public Builder sort(final Integer sort) { - this.sort = sort; - return this; - } - - /** - * build enabled. - * - * @param enabled enabled - * @return this - */ - public Builder enabled(final Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * build loged. - * - * @param loged loged - * @return this - */ - public Builder loged(final Boolean loged) { - this.loged = loged; - return this; - } - - /** - * build handle. - * - * @param handle handle - * @return this - */ - public Builder handle(final String handle) { - this.handle = handle; - return this; - } - - /** - * build conditionDataList. - * - * @param conditionDataList conditionDataList - * @return this - */ - public Builder conditionDataList(final List conditionDataList) { - this.conditionDataList = conditionDataList; - return this; - } - - /** - * build conditionDataList. - * - * @param beforeConditionDataList beforeConditionDataList - * @return this - */ - public Builder beforeConditionDataList(final List beforeConditionDataList) { - this.beforeConditionDataList = beforeConditionDataList; - return this; - } - - /** - * build match restful. - * - * @param matchRestful matchRestful - * @return this - */ - public Builder matchRestful(final Boolean matchRestful) { - this.matchRestful = matchRestful; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/SelectorData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/SelectorData.java deleted file mode 100644 index 9597c11..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/SelectorData.java +++ /dev/null @@ -1,623 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import java.util.List; -import java.util.Objects; - -/** - * SelectorData. - * - * @since 2.0.0 - */ -public class SelectorData { - - private String id; - - private String pluginId; - - /** - * plugin name. - */ - private String pluginName; - - private String name; - - /** - * matchMode(0 and 1 or). - */ - private Integer matchMode; - - /** - * type(false full,true custom). - */ - private Integer type; - - private Integer sort; - - private Boolean enabled; - - private Boolean logged; - - private Boolean continued = Boolean.TRUE; - - private String handle; - - private List conditionList; - - private List beforeConditionList; - - /** - * match restful api. - */ - private Boolean matchRestful; - - /** - * no args constructor. - */ - public SelectorData() { - } - - /** - * builder constructor. - * - * @param builder builder - */ - private SelectorData(final Builder builder) { - this.id = builder.id; - this.pluginId = builder.pluginId; - this.pluginName = builder.pluginName; - this.name = builder.name; - this.matchMode = builder.matchMode; - this.type = builder.type; - this.sort = builder.sort; - this.enabled = builder.enabled; - this.logged = builder.logged; - this.continued = builder.continued; - this.handle = builder.handle; - this.conditionList = builder.conditionList; - this.matchRestful = builder.matchRestful; - this.beforeConditionList = builder.beforeConditionList; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * get pluginId. - * - * @return pluginId - */ - public String getPluginId() { - return pluginId; - } - - /** - * set pluginId. - * - * @param pluginId pluginId - */ - public void setPluginId(final String pluginId) { - this.pluginId = pluginId; - } - - /** - * get pluginName. - * - * @return pluginName - */ - public String getPluginName() { - return pluginName; - } - - /** - * set pluginName. - * - * @param pluginName pluginName - */ - public void setPluginName(final String pluginName) { - this.pluginName = pluginName; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * get matchMode. - * - * @return matchMode - */ - public Integer getMatchMode() { - return matchMode; - } - - /** - * set matchMode. - * - * @param matchMode matchMode - */ - public void setMatchMode(final Integer matchMode) { - this.matchMode = matchMode; - } - - /** - * get type. - * - * @return type - */ - public Integer getType() { - return type; - } - - /** - * set type. - * - * @param type type - */ - public void setType(final Integer type) { - this.type = type; - } - - /** - * get sort. - * - * @return sort - */ - public Integer getSort() { - return sort; - } - - /** - * set sort. - * - * @param sort sort - */ - public void setSort(final Integer sort) { - this.sort = sort; - } - - /** - * get enabled. - * - * @return enabled - */ - public Boolean getEnabled() { - return enabled; - } - - /** - * set enabled. - * - * @param enabled enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - /** - * get logged. - * - * @return logged - */ - public Boolean getLogged() { - return logged; - } - - /** - * set logged. - * - * @param logged logged - */ - public void setLogged(final Boolean logged) { - this.logged = logged; - } - - /** - * get continued. - * - * @return continued - */ - public Boolean getContinued() { - if (Objects.isNull(continued)) { - return true; - } - return continued; - } - - /** - * set continued. - * - * @param continued continued - */ - public void setContinued(final Boolean continued) { - this.continued = continued; - } - - /** - * get handle. - * - * @return handle - */ - public String getHandle() { - return handle; - } - - /** - * set handle. - * - * @param handle handle - */ - public void setHandle(final String handle) { - this.handle = handle; - } - - /** - * get conditionList. - * - * @return conditionList - */ - public List getConditionList() { - return conditionList; - } - - /** - * set conditionList. - * - * @param conditionList conditionList - */ - public void setConditionList(final List conditionList) { - this.conditionList = conditionList; - } - - /** - * get match restful. - * - * @return match restful - */ - public Boolean getMatchRestful() { - return matchRestful; - } - - /** - * set match restful. - * - * @param matchRestful matchRestful - */ - public void setMatchRestful(final Boolean matchRestful) { - this.matchRestful = matchRestful; - } - - /** - * get before condition list. - * - * @return before condition list - */ - public List getBeforeConditionList() { - return beforeConditionList; - } - - /** - * set before condition list. - * - * @param beforeConditionList before condition list - */ - public void setBeforeConditionList(final List beforeConditionList) { - this.beforeConditionList = beforeConditionList; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - SelectorData that = (SelectorData) o; - return Objects.equals(id, that.id) && Objects.equals(pluginId, that.pluginId) && Objects.equals(pluginName, that.pluginName) - && Objects.equals(name, that.name) && Objects.equals(matchMode, that.matchMode) && Objects.equals(type, that.type) - && Objects.equals(sort, that.sort) && Objects.equals(enabled, that.enabled) && Objects.equals(logged, that.logged) - && Objects.equals(continued, that.continued) && Objects.equals(handle, that.handle) - && Objects.equals(conditionList, that.conditionList) && Objects.equals(matchRestful, that.matchRestful) - && Objects.equals(beforeConditionList, that.beforeConditionList); - } - - @Override - public int hashCode() { - return Objects.hash(id, pluginId, pluginName, name, matchMode, type, sort, enabled, logged, continued, handle, conditionList, matchRestful, beforeConditionList); - } - - @Override - public String toString() { - return "SelectorData{" - + "id='" - + id - + '\'' - + ", pluginId='" - + pluginId - + '\'' - + ", pluginName='" - + pluginName - + '\'' - + ", name='" - + name - + '\'' - + ", matchMode=" - + matchMode - + ", type=" - + type - + ", sort=" - + sort - + ", enabled=" - + enabled - + ", logged=" - + logged - + ", continued=" - + continued - + ", handle='" - + handle - + '\'' - + ", conditionList=" - + conditionList - + ", matchRestful=" - + matchRestful - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - private String id; - - private String pluginId; - - private String pluginName; - - private String name; - - private Integer matchMode; - - private Integer type; - - private Integer sort; - - private Boolean enabled; - - private Boolean logged; - - private Boolean continued; - - private String handle; - - private List conditionList; - - private Boolean matchRestful; - - private List beforeConditionList; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return SelectorData - */ - public SelectorData build() { - return new SelectorData(this); - } - - /** - * build id. - * - * @param id id - * @return this - */ - public Builder id(final String id) { - this.id = id; - return this; - } - - /** - * build pluginId. - * - * @param pluginId pluginId - * @return this - */ - public Builder pluginId(final String pluginId) { - this.pluginId = pluginId; - return this; - } - - /** - * build pluginName. - * - * @param pluginName pluginName - * @return this - */ - public Builder pluginName(final String pluginName) { - this.pluginName = pluginName; - return this; - } - - /** - * build name. - * - * @param name name - * @return this - */ - public Builder name(final String name) { - this.name = name; - return this; - } - - /** - * build matchMode. - * - * @param matchMode matchMode - * @return this - */ - public Builder matchMode(final Integer matchMode) { - this.matchMode = matchMode; - return this; - } - - /** - * build type. - * - * @param type type - * @return this - */ - public Builder type(final Integer type) { - this.type = type; - return this; - } - - /** - * build sort. - * - * @param sort sort - * @return this - */ - public Builder sort(final Integer sort) { - this.sort = sort; - return this; - } - - /** - * build enabled. - * - * @param enabled enabled - * @return this - */ - public Builder enabled(final Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * build logged. - * - * @param logged logged - * @return this - */ - public Builder logged(final Boolean logged) { - this.logged = logged; - return this; - } - - /** - * build continued. - * - * @param continued continued - * @return this - */ - public Builder continued(final Boolean continued) { - this.continued = continued; - return this; - } - - /** - * build handle. - * - * @param handle handle - * @return this - */ - public Builder handle(final String handle) { - this.handle = handle; - return this; - } - - /** - * build conditionList. - * - * @param conditionList conditionList - * @return this - */ - public Builder conditionList(final List conditionList) { - this.conditionList = conditionList; - return this; - } - - /** - * build match restful. - * - * @param matchRestful matchRestful - * @return this - */ - public Builder matchRestful(final Boolean matchRestful) { - this.matchRestful = matchRestful; - return this; - } - - /** - * build beforeConditionList. - * - * @param beforeConditionList beforeConditionList - * @return this - */ - public Builder beforeConditionList(final List beforeConditionList) { - this.beforeConditionList = beforeConditionList; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/WebsocketData.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/WebsocketData.java deleted file mode 100644 index beb690c..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/WebsocketData.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.apache.shenyu.common.enums.ConfigGroupEnum; -import org.apache.shenyu.common.enums.DataEventTypeEnum; - -import java.util.List; -import java.util.Objects; - -/** - * Data set, including {@link AppAuthData}、{@link ConditionData}、{@link PluginData}、{@link RuleData}、{@link SelectorData}. - * - * @param the type parameter - * @since 2.0.0 - */ -public class WebsocketData { - - /** - * group type. - * {@linkplain ConfigGroupEnum} - */ - private String groupType; - - /** - * event type. - * {@linkplain DataEventTypeEnum} - */ - private String eventType; - - /** - * data list. - * {@link AppAuthData}、{@link ConditionData}、{@link PluginData}、{@link RuleData}、{@link SelectorData}. - */ - private List data; - - /** - * no args constructor. - */ - public WebsocketData() { - } - - /** - * all args constructor. - * - * @param groupType groupType - * @param eventType eventType - * @param data data - */ - public WebsocketData(final String groupType, final String eventType, final List data) { - this.groupType = groupType; - this.eventType = eventType; - this.data = data; - } - - /** - * get groupType. - * - * @return groupType - */ - public String getGroupType() { - return groupType; - } - - /** - * set groupType. - * - * @param groupType groupType - * @return this - */ - public WebsocketData setGroupType(final String groupType) { - this.groupType = groupType; - return this; - } - - /** - * get eventType. - * - * @return eventType - */ - public String getEventType() { - return eventType; - } - - /** - * set eventType. - * - * @param eventType eventType - * @return this - */ - public WebsocketData setEventType(final String eventType) { - this.eventType = eventType; - return this; - } - - /** - * get data. - * - * @return data - */ - public List getData() { - return data; - } - - /** - * set data. - * - * @param data data - * @return this - */ - public WebsocketData setData(final List data) { - this.data = data; - return this; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - WebsocketData that = (WebsocketData) o; - return Objects.equals(groupType, that.groupType) && Objects.equals(eventType, that.eventType) && Objects.equals(data, that.data); - } - - @Override - public int hashCode() { - return Objects.hash(groupType, eventType, data); - } - - @Override - public String toString() { - return "WebsocketData{" - + "groupType='" - + groupType - + '\'' - + ", eventType='" - + eventType - + '\'' - + ", data=" - + data - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/DubboRegisterConfig.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/DubboRegisterConfig.java deleted file mode 100644 index 06eb25d..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/DubboRegisterConfig.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import java.io.Serializable; -import java.util.Objects; - -/** - * The type dubbo register config. - */ -public class DubboRegisterConfig implements Serializable { - - private static final long serialVersionUID = -4156204056244019979L; - - private String register; - - private String group; - - private String protocol; - - private String threadpool; - - private Integer corethreads; - - private Integer threads; - - private Integer queues; - - /** - * get register. - * - * @return register - */ - public String getRegister() { - return register; - } - - /** - * set register. - * - * @param register register - */ - public void setRegister(final String register) { - this.register = register; - } - - /** - * get group. - * - * @return group - */ - public String getGroup() { - return group; - } - - /** - * set group. - * - * @param group group - */ - public void setGroup(final String group) { - this.group = group; - } - - /** - * get protocol. - * - * @return protocol - */ - public String getProtocol() { - return protocol; - } - - /** - * set protocol. - * - * @param protocol protocol - */ - public void setProtocol(final String protocol) { - this.protocol = protocol; - } - - /** - * get threadpool. - * - * @return threadpool - */ - public String getThreadpool() { - return threadpool; - } - - /** - * set threadpool. - * - * @param threadpool threadpool - */ - public void setThreadpool(final String threadpool) { - this.threadpool = threadpool; - } - - /** - * get corethreads. - * - * @return corethreads - */ - public Integer getCorethreads() { - return corethreads; - } - - /** - * set corethreads. - * - * @param corethreads corethreads - */ - public void setCorethreads(final Integer corethreads) { - this.corethreads = corethreads; - } - - /** - * get threads. - * - * @return threads - */ - public Integer getThreads() { - return threads; - } - - /** - * set threads. - * - * @param threads threads - */ - public void setThreads(final Integer threads) { - this.threads = threads; - } - - /** - * get queues. - * - * @return queues - */ - public Integer getQueues() { - return queues; - } - - /** - * set queues. - * - * @param queues queues - */ - public void setQueues(final Integer queues) { - this.queues = queues; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - DubboRegisterConfig that = (DubboRegisterConfig) o; - return Objects.equals(register, that.register) && Objects.equals(group, that.group) && Objects.equals(protocol, that.protocol) - && Objects.equals(threadpool, that.threadpool) && Objects.equals(corethreads, that.corethreads) && Objects.equals(threads, that.threads) - && Objects.equals(queues, that.queues); - } - - @Override - public int hashCode() { - return Objects.hash(register, group, protocol, threadpool, corethreads, threads, queues); - } - - @Override - public String toString() { - return "DubboRegisterConfig{" - + "register='" - + register - + '\'' - + ", group='" - + group - + '\'' - + ", protocol='" - + protocol - + '\'' - + ", threadpool='" - + threadpool - + '\'' - + ", corethreads='" - + corethreads - + '\'' - + ", threads='" - + threads - + '\'' - + ", queues='" - + queues - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/GrpcRegisterConfig.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/GrpcRegisterConfig.java deleted file mode 100644 index 7ca6a41..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/GrpcRegisterConfig.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import java.io.Serializable; -import java.util.Objects; - -/** - * The type grpc register config. - */ -public class GrpcRegisterConfig implements Serializable { - - private static final long serialVersionUID = -4496044027526152878L; - - private String threadpool; - - /** - * get threadpool. - * - * @return threadpool - */ - public String getThreadpool() { - return threadpool; - } - - /** - * set threadpool. - * - * @param threadpool threadpool - */ - public void setThreadpool(final String threadpool) { - this.threadpool = threadpool; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - GrpcRegisterConfig that = (GrpcRegisterConfig) o; - return Objects.equals(threadpool, that.threadpool); - } - - @Override - public int hashCode() { - return Objects.hash(threadpool); - } - - @Override - public String toString() { - return "GrpcRegisterConfig{" - + "threadpool='" - + threadpool - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/MotanRegisterConfig.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/MotanRegisterConfig.java deleted file mode 100644 index ead3bf7..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/MotanRegisterConfig.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import java.io.Serializable; -import java.util.Objects; - -/** - * The type motan register config. - */ -public class MotanRegisterConfig implements Serializable { - - private static final long serialVersionUID = 2488053756247710408L; - - private String registerProtocol; - - private String registerAddress; - - private String threadpool; - - private Integer corethreads; - - private Integer threads; - - private Integer queues; - - /** - * get threadpool. - * - * @return threadpool - */ - public String getThreadpool() { - return threadpool; - } - - /** - * set threadpool. - * - * @param threadpool threadpool - */ - public void setThreadpool(final String threadpool) { - this.threadpool = threadpool; - } - - - /** - * get corethreads. - * - * @return corethreads - */ - public Integer getCorethreads() { - return corethreads; - } - - /** - * set corethreads. - * - * @param corethreads corethreads - */ - public void setCorethreads(final Integer corethreads) { - this.corethreads = corethreads; - } - - /** - * get threads. - * - * @return threads threads - */ - public Integer getThreads() { - return threads; - } - - /** - * set threads. - * - * @param threads threads - */ - public void setThreads(final Integer threads) { - this.threads = threads; - } - - /** - * get queues. - * - * @return queues - */ - public Integer getQueues() { - return queues; - } - - /** - * set queues. - * - * @param queues queues - */ - public void setQueues(final Integer queues) { - this.queues = queues; - } - - /** - * get RegisterProtocol. - * - * @return registerProtocol - */ - public String getRegisterProtocol() { - return registerProtocol; - } - - /** - * set registerProtocol. - * - * @param registerProtocol registerProtocol - */ - public void setRegisterProtocol(final String registerProtocol) { - this.registerProtocol = registerProtocol; - } - - /** - * get RegisterAddress. - * - * @return registerAddress - */ - public String getRegisterAddress() { - return registerAddress; - } - - /** - * set RegisterAddress. - * - * @param registerAddress registerAddress - */ - public void setRegisterAddress(final String registerAddress) { - this.registerAddress = registerAddress; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - MotanRegisterConfig that = (MotanRegisterConfig) o; - return Objects.equals(registerProtocol, that.registerProtocol) && Objects.equals(registerAddress, that.registerAddress) && Objects.equals(threadpool, that.threadpool) - && Objects.equals(corethreads, that.corethreads) && Objects.equals(threads, that.threads) - && Objects.equals(queues, that.queues); - } - - @Override - public int hashCode() { - return Objects.hash(registerProtocol, registerAddress, threadpool, corethreads, threads, queues); - } - - @Override - public String toString() { - return "MotanRegisterConfig{" - + "registerProtocol='" - + registerProtocol - + '\'' - + ", registerAddress='" - + registerAddress - + '\'' - + ", threadpool='" - + threadpool - + '\'' - + ", corethreads='" - + corethreads - + '\'' - + ", threads='" - + threads - + '\'' - + ", queues='" - + queues - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/SofaRegisterConfig.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/SofaRegisterConfig.java deleted file mode 100644 index 38916ea..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/SofaRegisterConfig.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import java.io.Serializable; -import java.util.Objects; - -/** - * The type sofa register config. - */ -public class SofaRegisterConfig implements Serializable { - - private static final long serialVersionUID = -3770114790533455035L; - - private String register; - - private String group; - - private String protocol; - - private String threadpool; - - private Integer corethreads; - - private Integer threads; - - private Integer queues; - - /** - * get register. - * - * @return register - */ - public String getRegister() { - return register; - } - - /** - * set register. - * - * @param register register - */ - public void setRegister(final String register) { - this.register = register; - } - - /** - * get group. - * - * @return group - */ - public String getGroup() { - return group; - } - - /** - * set group. - * - * @param group group - */ - public void setGroup(final String group) { - this.group = group; - } - - /** - * get protocol. - * - * @return protocol - */ - public String getProtocol() { - return protocol; - } - - /** - * set protocol. - * - * @param protocol protocol - */ - public void setProtocol(final String protocol) { - this.protocol = protocol; - } - - /** - * get threadpool. - * - * @return threadpool - */ - public String getThreadpool() { - return threadpool; - } - - /** - * set threadpool. - * - * @param threadpool threadpool - */ - public void setThreadpool(final String threadpool) { - this.threadpool = threadpool; - } - - /** - * get corethreads. - * - * @return corethreads - */ - public Integer getCorethreads() { - return corethreads; - } - - /** - * set corethreads. - * - * @param corethreads corethreads - */ - public void setCorethreads(final Integer corethreads) { - this.corethreads = corethreads; - } - - /** - * get threads. - * - * @return threads - */ - public Integer getThreads() { - return threads; - } - - /** - * set threads. - * - * @param threads threads - */ - public void setThreads(final Integer threads) { - this.threads = threads; - } - - /** - * get queues. - * - * @return queues - */ - public Integer getQueues() { - return queues; - } - - /** - * set queues. - * - * @param queues queues - */ - public void setQueues(final Integer queues) { - this.queues = queues; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - SofaRegisterConfig that = (SofaRegisterConfig) o; - return Objects.equals(register, that.register) && Objects.equals(group, that.group) - && Objects.equals(protocol, that.protocol) && Objects.equals(threadpool, that.threadpool) - && Objects.equals(corethreads, that.corethreads) && Objects.equals(threads, that.threads) - && Objects.equals(queues, that.queues); - } - - @Override - public int hashCode() { - return Objects.hash(register, group, protocol, threadpool, corethreads, threads, queues); - } - - @Override - public String toString() { - return "SofaRegisterConfig{" - + "register='" - + register - + '\'' - + ", group='" - + group - + '\'' - + ", protocol='" - + protocol - + '\'' - + ", threadpool='" - + threadpool - + '\'' - + ", corethreads='" - + corethreads - + '\'' - + ", threads='" - + threads - + '\'' - + ", queues='" - + queues - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/TarsRegisterConfig.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/TarsRegisterConfig.java deleted file mode 100644 index 4b29654..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/TarsRegisterConfig.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import java.io.Serializable; -import java.util.Objects; - -/** - * The type tars register config. - */ -public class TarsRegisterConfig implements Serializable { - - private static final long serialVersionUID = -1124348422759120146L; - - private String threadpool; - - private Integer corethreads; - - private Integer threads; - - private Integer queues; - - /** - * get threadpool. - * - * @return threadpool - */ - public String getThreadpool() { - return threadpool; - } - - /** - * set threadpool. - * - * @param threadpool threadpool - */ - public void setThreadpool(final String threadpool) { - this.threadpool = threadpool; - } - - /** - * get corethreads. - * - * @return corethreads - */ - public Integer getCorethreads() { - return corethreads; - } - - /** - * set corethreads. - * - * @param corethreads corethreads - */ - public void setCorethreads(final Integer corethreads) { - this.corethreads = corethreads; - } - - /** - * get threads. - * - * @return threads - */ - public Integer getThreads() { - return threads; - } - - /** - * set threads. - * - * @param threads threads - */ - public void setThreads(final Integer threads) { - this.threads = threads; - } - - /** - * get queues. - * - * @return queues - */ - public Integer getQueues() { - return queues; - } - - /** - * set queues. - * - * @param queues queues - */ - public void setQueues(final Integer queues) { - this.queues = queues; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - TarsRegisterConfig that = (TarsRegisterConfig) o; - return Objects.equals(threadpool, that.threadpool) && Objects.equals(corethreads, that.corethreads) - && Objects.equals(threads, that.threads) && Objects.equals(queues, that.queues); - } - - @Override - public int hashCode() { - return Objects.hash(threadpool, corethreads, threads, queues); - } - - @Override - public String toString() { - return "TarsRegisterConfig{" - + "threadpool='" - + threadpool - + '\'' - + ", corethreads='" - + corethreads - + '\'' - + ", threads='" - + threads - + '\'' - + ", queues='" - + queues - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/GeneralContextHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/GeneralContextHandle.java deleted file mode 100644 index a95e331..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/GeneralContextHandle.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import java.util.Objects; - -/** - * this is RequestHandle plugin handle. - */ -public class GeneralContextHandle { - /** - * general context type. - */ - private String generalContextType; - - /** - * generalContextKey. - *

- * need to be added new context value. - * key: new general context key, value: general context value. - *

- */ - private String generalContextKey; - - /** - * generalContextValue. - * when generalContextType is addGeneralContext, the generalContextValue is the value of generalContextKey. - * when generalContextType is transmitHeaderToGeneralContext, the generalContextValue is the new key of generalContext. - * In this case, if generalContextValue is blank, default value is same as generalContextKey. - */ - private String generalContextValue; - - /** - * no args constructor. - */ - public GeneralContextHandle() { - } - - /** - * all args constructor. - * - * @param generalContextType generalContextType - * @param generalContextKey generalContextKey - * @param generalContextValue generalContextValue - */ - public GeneralContextHandle(final String generalContextType, final String generalContextKey, final String generalContextValue) { - this.generalContextType = generalContextType; - this.generalContextKey = generalContextKey; - this.generalContextValue = generalContextValue; - } - - /** - * get generalContextType. - * - * @return generalContextType - */ - public String getGeneralContextType() { - return generalContextType; - } - - /** - * set generalContextType. - * - * @param generalContextType generalContextType - */ - public void setGeneralContextType(final String generalContextType) { - this.generalContextType = generalContextType; - } - - /** - * get generalContextKey. - * - * @return generalContextKey - */ - public String getGeneralContextKey() { - return generalContextKey; - } - - /** - * set generalContextKey. - * - * @param generalContextKey generalContextKey - */ - public void setGeneralContextKey(final String generalContextKey) { - this.generalContextKey = generalContextKey; - } - - /** - * get generalContextValue. - * - * @return generalContextValue - */ - public String getGeneralContextValue() { - return generalContextValue; - } - - /** - * set generalContextValue. - * - * @param generalContextValue generalContextValue - */ - public void setGeneralContextValue(final String generalContextValue) { - this.generalContextValue = generalContextValue; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - GeneralContextHandle that = (GeneralContextHandle) o; - return Objects.equals(generalContextType, that.generalContextType) - && Objects.equals(generalContextKey, that.generalContextKey) - && Objects.equals(generalContextValue, that.generalContextValue); - } - - @Override - public int hashCode() { - return Objects.hash(generalContextType, generalContextKey, generalContextValue); - } - - @Override - public String toString() { - return "GeneralContextHandleContent{" - + "generalContextType='" + generalContextType + '\'' - + ", generalContextKey='" + generalContextKey + '\'' - + ", generalContextValue='" + generalContextValue + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/HystrixHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/HystrixHandle.java deleted file mode 100644 index 30cd4dd..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/HystrixHandle.java +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.enums.HystrixIsolationModeEnum; - -import java.util.Objects; - -/** - * this is hystrix handle. - */ -public class HystrixHandle { - - /** - * hystrix group key is required. - */ - private String groupKey; - - /** - * hystrix command key is required. - */ - private String commandKey; - - /** - * hystrix withExecutionIsolationSemaphoreMaxConcurrentRequests. - */ - private int maxConcurrentRequests = Constants.MAX_CONCURRENT_REQUESTS; - - /** - * hystrix withCircuitBreakerErrorThresholdPercentage. - */ - private int errorThresholdPercentage = Constants.ERROR_THRESHOLD_PERCENTAGE; - - /** - * hystrix withCircuitBreakerRequestVolumeThreshold. - */ - private int requestVolumeThreshold = Constants.REQUEST_VOLUME_THRESHOLD; - - /** - * hystrix withCircuitBreakerSleepWindowInMilliseconds. - */ - private int sleepWindowInMilliseconds = Constants.SLEEP_WINDOW_INMILLISECONDS; - - /** - * timeout is required. - */ - private long timeout = Constants.TIME_OUT; - - /** - * call back uri. - * when some error occurs in hystrix invoke it will forward to this - */ - private String callBackUri = "/fallback/hystrix"; - - /** - * Isolation strategy to use when executing a hystrix command. - */ - private int executionIsolationStrategy = HystrixIsolationModeEnum.SEMAPHORE.getCode(); - - /** - * hystrix thread pool config. - */ - private HystrixThreadPoolConfig hystrixThreadPoolConfig; - - /** - * New instance hystrix handle. - * - * @return the hystrix handle - */ - public static HystrixHandle newDefaultInstance() { - return new HystrixHandle(); - } - - /** - * get groupKey. - * - * @return groupKey group key - */ - public String getGroupKey() { - return groupKey; - } - - /** - * set groupKey. - * - * @param groupKey groupKey - */ - public void setGroupKey(final String groupKey) { - this.groupKey = groupKey; - } - - /** - * get commandKey. - * - * @return commandKey command key - */ - public String getCommandKey() { - return commandKey; - } - - /** - * set commandKey. - * - * @param commandKey commandKey - */ - public void setCommandKey(final String commandKey) { - this.commandKey = commandKey; - } - - /** - * get maxConcurrentRequests. - * - * @return maxConcurrentRequests max concurrent requests - */ - public int getMaxConcurrentRequests() { - return maxConcurrentRequests; - } - - /** - * set maxConcurrentRequests. - * - * @param maxConcurrentRequests maxConcurrentRequests - */ - public void setMaxConcurrentRequests(final int maxConcurrentRequests) { - this.maxConcurrentRequests = maxConcurrentRequests; - } - - /** - * get errorThresholdPercentage. - * - * @return errorThresholdPercentage error threshold percentage - */ - public int getErrorThresholdPercentage() { - return errorThresholdPercentage; - } - - /** - * set errorThresholdPercentage. - * - * @param errorThresholdPercentage errorThresholdPercentage - */ - public void setErrorThresholdPercentage(final int errorThresholdPercentage) { - this.errorThresholdPercentage = errorThresholdPercentage; - } - - /** - * get requestVolumeThreshold. - * - * @return requestVolumeThreshold request volume threshold - */ - public int getRequestVolumeThreshold() { - return requestVolumeThreshold; - } - - /** - * set requestVolumeThreshold. - * - * @param requestVolumeThreshold requestVolumeThreshold - */ - public void setRequestVolumeThreshold(final int requestVolumeThreshold) { - this.requestVolumeThreshold = requestVolumeThreshold; - } - - /** - * get sleepWindowInMilliseconds. - * - * @return sleepWindowInMilliseconds sleep window in milliseconds - */ - public int getSleepWindowInMilliseconds() { - return sleepWindowInMilliseconds; - } - - /** - * set sleepWindowInMilliseconds. - * - * @param sleepWindowInMilliseconds sleepWindowInMilliseconds - */ - public void setSleepWindowInMilliseconds(final int sleepWindowInMilliseconds) { - this.sleepWindowInMilliseconds = sleepWindowInMilliseconds; - } - - /** - * get timeout. - * - * @return timeout timeout - */ - public long getTimeout() { - return timeout; - } - - /** - * set timeout. - * - * @param timeout timeout - */ - public void setTimeout(final long timeout) { - this.timeout = timeout; - } - - /** - * get callBackUri. - * - * @return callBackUri call back uri - */ - public String getCallBackUri() { - return callBackUri; - } - - /** - * set callBackUri. - * - * @param callBackUri callBackUri - */ - public void setCallBackUri(final String callBackUri) { - this.callBackUri = callBackUri; - } - - /** - * get executionIsolationStrategy. - * - * @return executionIsolationStrategy execution isolation strategy - */ - public int getExecutionIsolationStrategy() { - return executionIsolationStrategy; - } - - /** - * set executionIsolationStrategy. - * - * @param executionIsolationStrategy executionIsolationStrategy - */ - public void setExecutionIsolationStrategy(final int executionIsolationStrategy) { - this.executionIsolationStrategy = executionIsolationStrategy; - } - - /** - * get hystrixThreadPoolConfig. - * - * @return hystrixThreadPoolConfig hystrix thread pool config - */ - public HystrixThreadPoolConfig getHystrixThreadPoolConfig() { - return hystrixThreadPoolConfig; - } - - /** - * set hystrixThreadPoolConfig. - * - * @param hystrixThreadPoolConfig hystrixThreadPoolConfig - */ - public void setHystrixThreadPoolConfig(final HystrixThreadPoolConfig hystrixThreadPoolConfig) { - this.hystrixThreadPoolConfig = hystrixThreadPoolConfig; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - HystrixHandle that = (HystrixHandle) o; - return maxConcurrentRequests == that.maxConcurrentRequests && errorThresholdPercentage == that.errorThresholdPercentage - && requestVolumeThreshold == that.requestVolumeThreshold && sleepWindowInMilliseconds == that.sleepWindowInMilliseconds - && timeout == that.timeout && executionIsolationStrategy == that.executionIsolationStrategy && Objects.equals(groupKey, that.groupKey) - && Objects.equals(commandKey, that.commandKey) && Objects.equals(callBackUri, that.callBackUri) - && Objects.equals(hystrixThreadPoolConfig, that.hystrixThreadPoolConfig); - } - - @Override - public int hashCode() { - return Objects.hash(groupKey, commandKey, maxConcurrentRequests, errorThresholdPercentage, requestVolumeThreshold, - sleepWindowInMilliseconds, timeout, callBackUri, executionIsolationStrategy, hystrixThreadPoolConfig); - } - - @Override - public String toString() { - return "HystrixHandle{" - + "groupKey='" - + groupKey - + '\'' - + ", commandKey='" - + commandKey - + '\'' - + ", maxConcurrentRequests=" - + maxConcurrentRequests - + ", errorThresholdPercentage=" - + errorThresholdPercentage - + ", requestVolumeThreshold=" - + requestVolumeThreshold - + ", sleepWindowInMilliseconds=" - + sleepWindowInMilliseconds - + ", timeout=" - + timeout - + ", callBackUri='" - + callBackUri - + '\'' - + ", executionIsolationStrategy=" - + executionIsolationStrategy - + ", hystrixThreadPoolConfig=" - + hystrixThreadPoolConfig - + '}'; - } - - /** - * hystrix thread pool config. - */ - public static class HystrixThreadPoolConfig { - - private int coreSize = Constants.HYSTRIX_THREAD_POOL_CORE_SIZE; - - private int maximumSize = Constants.HYSTRIX_THREAD_POOL_MAX_SIZE; - - private int keepAliveTimeMinutes = Constants.HYSTRIX_THREAD_KEEP_ALIVE_TIME_MINUTE; - - private int maxQueueSize = Constants.HYSTRIX_THREAD_POOL_QUEUE_SIZE; - - /** - * get coreSize. - * - * @return coreSize core size - */ - public int getCoreSize() { - return coreSize; - } - - /** - * set coreSize. - * - * @param coreSize coreSize - */ - public void setCoreSize(final int coreSize) { - this.coreSize = coreSize; - } - - /** - * get maximumSize. - * - * @return maximumSize maximum size - */ - public int getMaximumSize() { - return maximumSize; - } - - /** - * set maximumSize. - * - * @param maximumSize maximumSize - */ - public void setMaximumSize(final int maximumSize) { - this.maximumSize = maximumSize; - } - - /** - * get keepAliveTimeMinutes. - * - * @return keepAliveTimeMinutes keep alive time minutes - */ - public int getKeepAliveTimeMinutes() { - return keepAliveTimeMinutes; - } - - /** - * set keepAliveTimeMinutes. - * - * @param keepAliveTimeMinutes keepAliveTimeMinutes - */ - public void setKeepAliveTimeMinutes(final int keepAliveTimeMinutes) { - this.keepAliveTimeMinutes = keepAliveTimeMinutes; - } - - /** - * get maxQueueSize. - * - * @return maxQueueSize max queue size - */ - public int getMaxQueueSize() { - return maxQueueSize; - } - - /** - * set maxQueueSize. - * - * @param maxQueueSize maxQueueSize - */ - public void setMaxQueueSize(final int maxQueueSize) { - this.maxQueueSize = maxQueueSize; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - HystrixThreadPoolConfig that = (HystrixThreadPoolConfig) o; - return coreSize == that.coreSize && maximumSize == that.maximumSize && keepAliveTimeMinutes == that.keepAliveTimeMinutes && maxQueueSize == that.maxQueueSize; - } - - @Override - public int hashCode() { - return Objects.hash(coreSize, maximumSize, keepAliveTimeMinutes, maxQueueSize); - } - - @Override - public String toString() { - return "HystrixThreadPoolConfig{" + "coreSize=" + coreSize + ", maximumSize=" + maximumSize + ", keepAliveTimeMinutes=" + keepAliveTimeMinutes + ", maxQueueSize=" + maxQueueSize + '}'; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/MockHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/MockHandle.java deleted file mode 100644 index 0391eb7..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/MockHandle.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import java.util.Objects; - -/** - * this is RequestHandle plugin handle. - */ -public class MockHandle { - - private Integer httpStatusCode; - - private String responseContent; - - /** - * get http status code. - * @return http status code. - */ - public Integer getHttpStatusCode() { - return httpStatusCode; - } - - /** - * set http status code. - * - * @param httpStatusCode http status code. - */ - public void setHttpStatusCode(final Integer httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - /** - * get response content. - * - * @return content. - */ - public String getResponseContent() { - return responseContent; - } - - /** - * set response content. - * - * @param responseContent content. - */ - public void setResponseContent(final String responseContent) { - this.responseContent = responseContent; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - MockHandle that = (MockHandle) o; - return Objects.equals(httpStatusCode, that.httpStatusCode) && Objects.equals(responseContent, that.responseContent); - } - - @Override - public int hashCode() { - return Objects.hash(httpStatusCode, responseContent); - } - - @Override - public String toString() { - return "MockHandle{" - + "httpStatusCode=" - + httpStatusCode - + ", responseContent='" - + responseContent - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RateLimiterHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RateLimiterHandle.java deleted file mode 100644 index 1a40c11..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RateLimiterHandle.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import java.util.Objects; - -/** - * this is rateLimiter plugin handle. - */ -public class RateLimiterHandle { - - /** - * algorithm name. - */ - private String algorithmName; - - /** - * replenish rate. - */ - private double replenishRate; - - /** - * burst capacity. - */ - private double burstCapacity; - - /** - * request count. - */ - private double requestCount = 1.0; - - /** - * loged. - */ - private boolean loged; - - /** - * key resolver name. - */ - private String keyResolverName; - - /** - * New default instance rate limiter handle. - * - * @return the rate limiter handle - */ - public static RateLimiterHandle newDefaultInstance() { - RateLimiterHandle rateLimiterHandle = new RateLimiterHandle(); - rateLimiterHandle.setAlgorithmName("tokenBucket"); - rateLimiterHandle.setReplenishRate(1.0); - rateLimiterHandle.setBurstCapacity(100.0); - rateLimiterHandle.setRequestCount(1.0); - rateLimiterHandle.setLoged(false); - return rateLimiterHandle; - } - - /** - * get algorithmName. - * - * @return algorithmName algorithm name - */ - public String getAlgorithmName() { - return algorithmName; - } - - /** - * set algorithmName. - * - * @param algorithmName algorithmName - */ - public void setAlgorithmName(final String algorithmName) { - this.algorithmName = algorithmName; - } - - /** - * get replenishRate. - * - * @return replenishRate replenish rate - */ - public double getReplenishRate() { - return replenishRate; - } - - /** - * set replenishRate. - * - * @param replenishRate replenishRate - */ - public void setReplenishRate(final double replenishRate) { - this.replenishRate = replenishRate; - } - - /** - * get burstCapacity. - * - * @return burstCapacity burst capacity - */ - public double getBurstCapacity() { - return burstCapacity; - } - - /** - * set burstCapacity. - * - * @param burstCapacity burstCapacity - */ - public void setBurstCapacity(final double burstCapacity) { - this.burstCapacity = burstCapacity; - } - - /** - * get requestCount. - * - * @return requestCount request count - */ - public double getRequestCount() { - return requestCount; - } - - /** - * set requestCount. - * - * @param requestCount requestCount - */ - public void setRequestCount(final double requestCount) { - this.requestCount = requestCount; - } - - /** - * get loged. - * - * @return loged boolean - */ - public boolean isLoged() { - return loged; - } - - /** - * set loged. - * - * @param loged loged - */ - public void setLoged(final boolean loged) { - this.loged = loged; - } - - /** - * get keyResolverName. - * - * @return keyResolverName key resolver name - */ - public String getKeyResolverName() { - return keyResolverName; - } - - /** - * set keyResolverName. - * - * @param keyResolverName keyResolverName - */ - public void setKeyResolverName(final String keyResolverName) { - this.keyResolverName = keyResolverName; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - RateLimiterHandle that = (RateLimiterHandle) o; - return Double.compare(that.replenishRate, replenishRate) == 0 && Double.compare(that.burstCapacity, burstCapacity) == 0 - && Double.compare(that.requestCount, requestCount) == 0 && loged == that.loged - && Objects.equals(algorithmName, that.algorithmName) && Objects.equals(keyResolverName, that.keyResolverName); - } - - @Override - public int hashCode() { - return Objects.hash(algorithmName, replenishRate, burstCapacity, requestCount, loged, keyResolverName); - } - - @Override - public String toString() { - return "RateLimiterHandle{" - + "algorithmName='" - + algorithmName - + '\'' - + ", replenishRate=" - + replenishRate - + ", burstCapacity=" - + burstCapacity - + ", requestCount=" - + requestCount - + ", loged=" - + loged - + ", keyResolverName='" - + keyResolverName - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RedirectHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RedirectHandle.java deleted file mode 100644 index 19f8bde..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RedirectHandle.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import java.util.Objects; - -/** - * This is redirect plugin handle. - */ -public class RedirectHandle { - - /** - * http status code. - */ - private Integer httpStatusCode = 302; - - /** - * redirect url. - */ - private String redirectURI; - - /** - * Gets http status code. - * - * @return the http status code - */ - public Integer getHttpStatusCode() { - return httpStatusCode; - } - - /** - * Sets http status code. - * - * @param httpStatusCode the http status code - */ - public void setHttpStatusCode(final Integer httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - /** - * get redirectURI. - * - * @return redirectURI redirect uri - */ - public String getRedirectURI() { - return redirectURI; - } - - /** - * set redirectURI. - * - * @param redirectURI redirectURI - */ - public void setRedirectURI(final String redirectURI) { - this.redirectURI = redirectURI; - } - - @Override - public String toString() { - return "RedirectHandle{" + "httpStatusCode=" + httpStatusCode + ", redirectURI='" + redirectURI + '\'' + '}'; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - final RedirectHandle that = (RedirectHandle) o; - return Objects.equals(httpStatusCode, that.httpStatusCode) && Objects.equals(redirectURI, that.redirectURI); - } - - @Override - public int hashCode() { - return Objects.hash(httpStatusCode, redirectURI); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RequestHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RequestHandle.java deleted file mode 100644 index 7a68424..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RequestHandle.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; - -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -/** - * this is RequestHandle plugin handle. - */ -public class RequestHandle { - - private ShenyuRequestHeader header; - - private ShenyuRequestParameter parameter; - - private ShenyuCookie cookie; - - /** - * get header. - * - * @return header - */ - public ShenyuRequestHeader getHeader() { - return header; - } - - /** - * set header. - * - * @param header header - */ - public void setHeader(final ShenyuRequestHeader header) { - this.header = header; - } - - /** - * get parameter. - * - * @return parameter - */ - public ShenyuRequestParameter getParameter() { - return parameter; - } - - /** - * set parameter. - * - * @param parameter parameter - */ - public void setParameter(final ShenyuRequestParameter parameter) { - this.parameter = parameter; - } - - /** - * get cookie. - * - * @return cookie - */ - public ShenyuCookie getCookie() { - return cookie; - } - - /** - * set cookie. - * - * @param cookie cookie - */ - public void setCookie(final ShenyuCookie cookie) { - this.cookie = cookie; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - RequestHandle that = (RequestHandle) o; - return Objects.equals(header, that.header) && Objects.equals(parameter, that.parameter) && Objects.equals(cookie, that.cookie); - } - - @Override - public int hashCode() { - return Objects.hash(header, parameter, cookie); - } - - @Override - public String toString() { - return "RequestHandle{" - + "header=" - + header - + ", parameter=" - + parameter - + ", cookie=" - + cookie - + '}'; - } - - /** - * is empty config. - * - * @return empty is true - */ - public boolean isEmptyConfig() { - return !isNotEmptyConfig(); - } - - /** - * is not empty config. - * - * @return not empty is true - */ - private boolean isNotEmptyConfig() { - return header.isNotEmptyConfig() || parameter.isNotEmptyConfig() || cookie.isNotEmptyConfig(); - } - - public class ShenyuRequestHeader { - /** - * need to be appended new header value. - */ - private Map addHeaders; - - /** - * new headerKey replaces old headerKey. - * key: oldHeaderKey, value: newHeaderKey. - */ - private Map replaceHeaderKeys; - - /** - * need to be covered header value. - * key: oldHeaderKey, value: newHeaderValue. - */ - private Map setHeaders; - - /** - * need to be removed headerKey. - */ - private Set removeHeaderKeys; - - /** - * no args constructor. - */ - public ShenyuRequestHeader() { - } - - /** - * all args constructor. - * - * @param addHeaders addHeaders - * @param replaceHeaderKeys replaceHeaderKeys - * @param setHeaders setHeaders - * @param removeHeaderKeys removeHeaderKeys - */ - public ShenyuRequestHeader(final Map addHeaders, final Map replaceHeaderKeys, - final Map setHeaders, final Set removeHeaderKeys) { - this.addHeaders = addHeaders; - this.replaceHeaderKeys = replaceHeaderKeys; - this.setHeaders = setHeaders; - this.removeHeaderKeys = removeHeaderKeys; - } - - /** - * get addHeaders. - * - * @return addHeaders - */ - public Map getAddHeaders() { - return addHeaders; - } - - /** - * set addHeaders. - * - * @param addHeaders addHeaders - */ - public void setAddHeaders(final Map addHeaders) { - this.addHeaders = addHeaders; - } - - /** - * get replaceHeaderKeys. - * - * @return replaceHeaderKeys - */ - public Map getReplaceHeaderKeys() { - return replaceHeaderKeys; - } - - /** - * set replaceHeaderKeys. - * - * @param replaceHeaderKeys replaceHeaderKeys - */ - public void setReplaceHeaderKeys(final Map replaceHeaderKeys) { - this.replaceHeaderKeys = replaceHeaderKeys; - } - - /** - * get setHeaders. - * - * @return setHeaders - */ - public Map getSetHeaders() { - return setHeaders; - } - - /** - * set setHeaders. - * - * @param setHeaders setHeaders - */ - public void setSetHeaders(final Map setHeaders) { - this.setHeaders = setHeaders; - } - - /** - * get removeHeaderKeys. - * - * @return removeHeaderKeys - */ - public Set getRemoveHeaderKeys() { - return removeHeaderKeys; - } - - /** - * set removeHeaderKeys. - * - * @param removeHeaderKeys removeHeaderKeys - */ - public void setRemoveHeaderKeys(final Set removeHeaderKeys) { - this.removeHeaderKeys = removeHeaderKeys; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ShenyuRequestHeader that = (ShenyuRequestHeader) o; - return Objects.equals(addHeaders, that.addHeaders) && Objects.equals(replaceHeaderKeys, that.replaceHeaderKeys) - && Objects.equals(setHeaders, that.setHeaders) && Objects.equals(removeHeaderKeys, that.removeHeaderKeys); - } - - @Override - public int hashCode() { - return Objects.hash(addHeaders, replaceHeaderKeys, setHeaders, removeHeaderKeys); - } - - @Override - public String toString() { - return "ShenyuRequestHeader{" - + "addHeaders=" - + addHeaders - + ", replaceHeaderKeys=" - + replaceHeaderKeys - + ", setHeaders=" - + setHeaders - + ", removeHeaderKeys=" - + removeHeaderKeys - + '}'; - } - - /** - * is not empty config. - * - * @return not empty is true - */ - public boolean isNotEmptyConfig() { - return MapUtils.isNotEmpty(addHeaders) || MapUtils.isNotEmpty(replaceHeaderKeys) - || MapUtils.isNotEmpty(setHeaders) || CollectionUtils.isNotEmpty(removeHeaderKeys); - } - } - - public class ShenyuRequestParameter { - - private Map addParameters; - - private Map replaceParameterKeys; - - private Map setParameters; - - private Set removeParameterKeys; - - /** - * no args constructor. - */ - public ShenyuRequestParameter() { - } - - /** - * all args constructor. - * - * @param addParameters addParameters - * @param replaceParameterKeys replaceParameterKeys - * @param setParameters setParameters - * @param removeParameterKeys removeParameterKeys - */ - public ShenyuRequestParameter(final Map addParameters, final Map replaceParameterKeys, - final Map setParameters, final Set removeParameterKeys) { - this.addParameters = addParameters; - this.replaceParameterKeys = replaceParameterKeys; - this.setParameters = setParameters; - this.removeParameterKeys = removeParameterKeys; - } - - /** - * get addParameters. - * - * @return addParameters - */ - public Map getAddParameters() { - return addParameters; - } - - /** - * set addParameters. - * - * @param addParameters addParameters - */ - public void setAddParameters(final Map addParameters) { - this.addParameters = addParameters; - } - - /** - * get replaceParameterKeys. - * - * @return replaceParameterKeys - */ - public Map getReplaceParameterKeys() { - return replaceParameterKeys; - } - - /** - * set replaceParameterKeys. - * - * @param replaceParameterKeys replaceParameterKeys - */ - public void setReplaceParameterKeys(final Map replaceParameterKeys) { - this.replaceParameterKeys = replaceParameterKeys; - } - - /** - * get setParameters. - * - * @return setParameters - */ - public Map getSetParameters() { - return setParameters; - } - - /** - * set setParameters. - * - * @param setParameters setParameters - */ - public void setSetParameters(final Map setParameters) { - this.setParameters = setParameters; - } - - /** - * get removeParameterKeys. - * - * @return removeParameterKeys - */ - public Set getRemoveParameterKeys() { - return removeParameterKeys; - } - - /** - * set removeParameterKeys. - * - * @param removeParameterKeys removeParameterKeys - */ - public void setRemoveParameterKeys(final Set removeParameterKeys) { - this.removeParameterKeys = removeParameterKeys; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ShenyuRequestParameter that = (ShenyuRequestParameter) o; - return Objects.equals(addParameters, that.addParameters) && Objects.equals(replaceParameterKeys, that.replaceParameterKeys) - && Objects.equals(setParameters, that.setParameters) && Objects.equals(removeParameterKeys, that.removeParameterKeys); - } - - @Override - public String toString() { - return "ShenyuRequestParameter{" - + "addParameters=" - + addParameters - + ", replaceParameterKeys=" - + replaceParameterKeys - + ", setParameters=" - + setParameters - + ", removeParameterKeys=" - + removeParameterKeys - + '}'; - } - - @Override - public int hashCode() { - return Objects.hash(addParameters, replaceParameterKeys, setParameters, removeParameterKeys); - } - - /** - * is not empty config. - * - * @return not empty is true - */ - public boolean isNotEmptyConfig() { - return MapUtils.isNotEmpty(addParameters) || MapUtils.isNotEmpty(replaceParameterKeys) - || MapUtils.isNotEmpty(setParameters) || CollectionUtils.isNotEmpty(removeParameterKeys); - } - } - - public class ShenyuCookie { - private Map addCookies; - - private Map replaceCookieKeys; - - private Map setCookies; - - private Set removeCookieKeys; - - /** - * no args constructor. - */ - public ShenyuCookie() { - } - - /** - * all args constructor. - * - * @param addCookies addCookies - * @param replaceCookieKeys replaceCookieKeys - * @param setCookies setCookies - * @param removeCookieKeys removeCookieKeys - */ - public ShenyuCookie(final Map addCookies, final Map replaceCookieKeys, - final Map setCookies, final Set removeCookieKeys) { - this.addCookies = addCookies; - this.replaceCookieKeys = replaceCookieKeys; - this.setCookies = setCookies; - this.removeCookieKeys = removeCookieKeys; - } - - /** - * get addCookies. - * - * @return addCookies - */ - public Map getAddCookies() { - return addCookies; - } - - /** - * set addCookies. - * - * @param addCookies addCookies - */ - public void setAddCookies(final Map addCookies) { - this.addCookies = addCookies; - } - - /** - * get replaceCookieKeys. - * - * @return replaceCookieKeys - */ - public Map getReplaceCookieKeys() { - return replaceCookieKeys; - } - - /** - * set replaceCookieKeys. - * - * @param replaceCookieKeys replaceCookieKeys - */ - public void setReplaceCookieKeys(final Map replaceCookieKeys) { - this.replaceCookieKeys = replaceCookieKeys; - } - - /** - * get setCookies. - * - * @return setCookies - */ - public Map getSetCookies() { - return setCookies; - } - - /** - * set setCookies. - * - * @param setCookies setCookies - */ - public void setSetCookies(final Map setCookies) { - this.setCookies = setCookies; - } - - /** - * get removeCookieKeys. - * - * @return removeCookieKeys - */ - public Set getRemoveCookieKeys() { - return removeCookieKeys; - } - - /** - * set removeCookieKeys. - * - * @param removeCookieKeys removeCookieKeys - */ - public void setRemoveCookieKeys(final Set removeCookieKeys) { - this.removeCookieKeys = removeCookieKeys; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ShenyuCookie that = (ShenyuCookie) o; - return Objects.equals(addCookies, that.addCookies) && Objects.equals(replaceCookieKeys, that.replaceCookieKeys) - && Objects.equals(setCookies, that.setCookies) && Objects.equals(removeCookieKeys, that.removeCookieKeys); - } - - @Override - public int hashCode() { - return Objects.hash(addCookies, replaceCookieKeys, setCookies, removeCookieKeys); - } - - @Override - public String toString() { - return "ShenyuCookie{" - + "addCookies=" - + addCookies - + ", replaceCookieKeys=" - + replaceCookieKeys - + ", setCookies=" - + setCookies - + ", removeCookieKeys=" - + removeCookieKeys - + '}'; - } - - /** - * is not empty config. - * - * @return not empty is true - */ - public boolean isNotEmptyConfig() { - return MapUtils.isNotEmpty(addCookies) || MapUtils.isNotEmpty(replaceCookieKeys) - || MapUtils.isNotEmpty(setCookies) || CollectionUtils.isNotEmpty(removeCookieKeys); - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandle.java deleted file mode 100644 index 7486966..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandle.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import org.apache.shenyu.common.constant.Constants; - -import java.util.Objects; - -/** - * this is Resilience4J plugin handle. - */ -public class Resilience4JHandle { - - /** - * ratelimiter timeoutDurationRate. - */ - private int timeoutDurationRate = Constants.TIMEOUT_DURATION_RATE; - - /** - * ratelimiter limitRefreshPeriod. - */ - private int limitRefreshPeriod = Constants.LIMIT_REFRESH_PERIOD; - - /** - * ratelimiter limitForPeriod. - */ - private int limitForPeriod = Constants.LIMIT_FOR_PERIOD; - - /** - * circuitBreaker circuitEnable. - */ - private int circuitEnable = Constants.CIRCUIT_DISABLE; - - /** - * circuitBreaker timeoutDuration. - */ - private long timeoutDuration = Constants.TIMEOUT_DURATION; - - /** - * circuitBreaker fallbackUri. - */ - private String fallbackUri = "/fallback/resilience4j"; - - /** - * circuitBreaker slidingWindowSize. - */ - private int slidingWindowSize = Constants.SLIDING_WINDOW_SIZE; - - /** - * circuitBreaker slidingWindowType. - */ - private int slidingWindowType = Constants.SLIDING_WINDOW_TYPE; - - /** - * circuitBreaker minimumNumberOfCalls. - */ - private int minimumNumberOfCalls = Constants.MINIMUM_NUMBER_OF_CALLS; - - /** - * circuitBreaker waitIntervalFunctionInOpenState. - */ - private int waitIntervalFunctionInOpenState = Constants.WAIT_INTERVAL_FUNCTION_IN_OPEN_STATE; - - /** - * circuitBreaker permittedNumberOfCallsInHalfOpenState. - */ - private int permittedNumberOfCallsInHalfOpenState = Constants.PERMITTED_NUMBER_OF_CALLS_IN_HALF_OPEN_STATE; - - /** - * circuitBreaker failureRateThreshold. - */ - private float failureRateThreshold = Constants.FAILURE_RATE_THRESHOLD; - - /** - * circuitBreaker automaticTransitionFromOpenToHalfOpenEnabled. - */ - private Boolean automaticTransitionFromOpenToHalfOpenEnabled = Constants.AUTOMATIC_TRANSITION_FROM_OPEN_TO_HALF_OPEN_ENABLED; - - /** - * New default instance resilience 4 j handle. - * - * @return the resilience 4 j handle - */ - public static Resilience4JHandle newDefaultInstance() { - return new Resilience4JHandle(); - } - - /** - * get timeoutDurationRate. - * - * @return timeoutDurationRate timeout duration rate - */ - public int getTimeoutDurationRate() { - return timeoutDurationRate; - } - - /** - * set timeoutDurationRate. - * - * @param timeoutDurationRate timeoutDurationRate - */ - public void setTimeoutDurationRate(final int timeoutDurationRate) { - this.timeoutDurationRate = timeoutDurationRate; - } - - /** - * get limitRefreshPeriod. - * - * @return limitRefreshPeriod limit refresh period - */ - public int getLimitRefreshPeriod() { - return limitRefreshPeriod; - } - - /** - * set limitRefreshPeriod. - * - * @param limitRefreshPeriod limitRefreshPeriod - */ - public void setLimitRefreshPeriod(final int limitRefreshPeriod) { - this.limitRefreshPeriod = limitRefreshPeriod; - } - - /** - * get limitForPeriod. - * - * @return limitForPeriod limit for period - */ - public int getLimitForPeriod() { - return limitForPeriod; - } - - /** - * set limitForPeriod. - * - * @param limitForPeriod limitForPeriod - */ - public void setLimitForPeriod(final int limitForPeriod) { - this.limitForPeriod = limitForPeriod; - } - - /** - * get circuitEnable. - * - * @return circuitEnable circuit enable - */ - public int getCircuitEnable() { - return circuitEnable; - } - - /** - * set circuitEnable. - * - * @param circuitEnable circuitEnable - */ - public void setCircuitEnable(final int circuitEnable) { - this.circuitEnable = circuitEnable; - } - - /** - * get timeoutDuration. - * - * @return timeoutDuration timeout duration - */ - public long getTimeoutDuration() { - return timeoutDuration; - } - - /** - * set timeoutDuration. - * - * @param timeoutDuration timeoutDuration - */ - public void setTimeoutDuration(final long timeoutDuration) { - this.timeoutDuration = timeoutDuration; - } - - /** - * get fallbackUri. - * - * @return fallbackUri fallback uri - */ - public String getFallbackUri() { - return fallbackUri; - } - - /** - * set fallbackUri. - * - * @param fallbackUri fallbackUri - */ - public void setFallbackUri(final String fallbackUri) { - this.fallbackUri = fallbackUri; - } - - /** - * get slidingWindowSize. - * - * @return slidingWindowSize sliding window size - */ - public int getSlidingWindowSize() { - return slidingWindowSize; - } - - /** - * set slidingWindowSize. - * - * @param slidingWindowSize slidingWindowSize - */ - public void setSlidingWindowSize(final int slidingWindowSize) { - this.slidingWindowSize = slidingWindowSize; - } - - /** - * get slidingWindowType. - * - * @return slidingWindowType sliding window type - */ - public int getSlidingWindowType() { - return slidingWindowType; - } - - /** - * set slidingWindowType. - * - * @param slidingWindowType slidingWindowType - */ - public void setSlidingWindowType(final int slidingWindowType) { - this.slidingWindowType = slidingWindowType; - } - - /** - * get minimumNumberOfCalls. - * - * @return minimumNumberOfCalls minimum number of calls - */ - public int getMinimumNumberOfCalls() { - return minimumNumberOfCalls; - } - - /** - * set minimumNumberOfCalls. - * - * @param minimumNumberOfCalls minimumNumberOfCalls - */ - public void setMinimumNumberOfCalls(final int minimumNumberOfCalls) { - this.minimumNumberOfCalls = minimumNumberOfCalls; - } - - /** - * get waitIntervalFunctionInOpenState. - * - * @return waitIntervalFunctionInOpenState wait interval function in open state - */ - public int getWaitIntervalFunctionInOpenState() { - return waitIntervalFunctionInOpenState; - } - - /** - * set waitIntervalFunctionInOpenState. - * - * @param waitIntervalFunctionInOpenState waitIntervalFunctionInOpenState - */ - public void setWaitIntervalFunctionInOpenState(final int waitIntervalFunctionInOpenState) { - this.waitIntervalFunctionInOpenState = waitIntervalFunctionInOpenState; - } - - /** - * get permittedNumberOfCallsInHalfOpenState. - * - * @return permittedNumberOfCallsInHalfOpenState permitted number of calls in half open state - */ - public int getPermittedNumberOfCallsInHalfOpenState() { - return permittedNumberOfCallsInHalfOpenState; - } - - /** - * set permittedNumberOfCallsInHalfOpenState. - * - * @param permittedNumberOfCallsInHalfOpenState permittedNumberOfCallsInHalfOpenState - */ - public void setPermittedNumberOfCallsInHalfOpenState(final int permittedNumberOfCallsInHalfOpenState) { - this.permittedNumberOfCallsInHalfOpenState = permittedNumberOfCallsInHalfOpenState; - } - - /** - * get failureRateThreshold. - * - * @return failureRateThreshold failure rate threshold - */ - public float getFailureRateThreshold() { - return failureRateThreshold; - } - - /** - * set failureRateThreshold. - * - * @param failureRateThreshold failureRateThreshold - */ - public void setFailureRateThreshold(final float failureRateThreshold) { - this.failureRateThreshold = failureRateThreshold; - } - - /** - * get automaticTransitionFromOpenToHalfOpenEnabled. - * - * @return automaticTransitionFromOpenToHalfOpenEnabled automatic transition from open to half open enabled - */ - public Boolean getAutomaticTransitionFromOpenToHalfOpenEnabled() { - return automaticTransitionFromOpenToHalfOpenEnabled; - } - - /** - * set automaticTransitionFromOpenToHalfOpenEnabled. - * - * @param automaticTransitionFromOpenToHalfOpenEnabled automaticTransitionFromOpenToHalfOpenEnabled - */ - public void setAutomaticTransitionFromOpenToHalfOpenEnabled(final Boolean automaticTransitionFromOpenToHalfOpenEnabled) { - this.automaticTransitionFromOpenToHalfOpenEnabled = automaticTransitionFromOpenToHalfOpenEnabled; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - Resilience4JHandle that = (Resilience4JHandle) o; - return timeoutDurationRate == that.timeoutDurationRate && limitRefreshPeriod == that.limitRefreshPeriod && limitForPeriod == that.limitForPeriod - && circuitEnable == that.circuitEnable && timeoutDuration == that.timeoutDuration && slidingWindowSize == that.slidingWindowSize - && slidingWindowType == that.slidingWindowType && minimumNumberOfCalls == that.minimumNumberOfCalls - && waitIntervalFunctionInOpenState == that.waitIntervalFunctionInOpenState && permittedNumberOfCallsInHalfOpenState == that.permittedNumberOfCallsInHalfOpenState - && Float.compare(that.failureRateThreshold, failureRateThreshold) == 0 && Objects.equals(fallbackUri, that.fallbackUri) - && Objects.equals(automaticTransitionFromOpenToHalfOpenEnabled, that.automaticTransitionFromOpenToHalfOpenEnabled); - } - - @Override - public int hashCode() { - return Objects.hash(timeoutDurationRate, limitRefreshPeriod, limitForPeriod, circuitEnable, timeoutDuration, fallbackUri, - slidingWindowSize, slidingWindowType, minimumNumberOfCalls, waitIntervalFunctionInOpenState, - permittedNumberOfCallsInHalfOpenState, failureRateThreshold, automaticTransitionFromOpenToHalfOpenEnabled); - } - - @Override - public String toString() { - return "Resilience4JHandle{" - + "timeoutDurationRate=" - + timeoutDurationRate - + ", limitRefreshPeriod=" - + limitRefreshPeriod - + ", limitForPeriod=" - + limitForPeriod - + ", circuitEnable=" - + circuitEnable - + ", timeoutDuration=" - + timeoutDuration - + ", fallbackUri='" - + fallbackUri - + '\'' - + ", slidingWindowSize=" - + slidingWindowSize - + ", slidingWindowType=" - + slidingWindowType - + ", minimumNumberOfCalls=" - + minimumNumberOfCalls - + ", waitIntervalFunctionInOpenState=" - + waitIntervalFunctionInOpenState - + ", permittedNumberOfCallsInHalfOpenState=" - + permittedNumberOfCallsInHalfOpenState - + ", failureRateThreshold=" - + failureRateThreshold - + ", automaticTransitionFromOpenToHalfOpenEnabled=" - + automaticTransitionFromOpenToHalfOpenEnabled - + '}'; - } - - /** - * check filed default value. - * - * @param resilience4JHandle {@linkplain Resilience4JHandle} - */ - public void checkData(final Resilience4JHandle resilience4JHandle) { - resilience4JHandle.setTimeoutDurationRate(resilience4JHandle.getTimeoutDurationRate() < 0 ? Constants.TIMEOUT_DURATION_RATE : resilience4JHandle.getTimeoutDurationRate()); - resilience4JHandle.setLimitRefreshPeriod(resilience4JHandle.getLimitRefreshPeriod() < 0 ? Constants.LIMIT_REFRESH_PERIOD : resilience4JHandle.getLimitRefreshPeriod()); - resilience4JHandle.setLimitForPeriod(resilience4JHandle.getLimitForPeriod() < 0 ? Constants.LIMIT_FOR_PERIOD : resilience4JHandle.getLimitForPeriod()); - resilience4JHandle.setCircuitEnable(resilience4JHandle.getCircuitEnable() != Constants.CIRCUIT_ENABLE ? Constants.CIRCUIT_DISABLE : Constants.CIRCUIT_ENABLE); - resilience4JHandle.setTimeoutDuration(resilience4JHandle.getTimeoutDuration() < 0 ? Constants.TIMEOUT_DURATION : resilience4JHandle.getTimeoutDuration()); - resilience4JHandle.setFallbackUri(!"0".equals(resilience4JHandle.getFallbackUri()) ? resilience4JHandle.getFallbackUri() : ""); - resilience4JHandle.setSlidingWindowSize(resilience4JHandle.getSlidingWindowSize() < 0 ? Constants.SLIDING_WINDOW_SIZE : resilience4JHandle.getSlidingWindowSize()); - resilience4JHandle.setSlidingWindowType(resilience4JHandle.getSlidingWindowType() < 0 ? Constants.SLIDING_WINDOW_TYPE : resilience4JHandle.getSlidingWindowType()); - resilience4JHandle.setMinimumNumberOfCalls(resilience4JHandle.getMinimumNumberOfCalls() < 0 ? Constants.MINIMUM_NUMBER_OF_CALLS : resilience4JHandle.getMinimumNumberOfCalls()); - resilience4JHandle.setWaitIntervalFunctionInOpenState(resilience4JHandle.getWaitIntervalFunctionInOpenState() < 0 - ? Constants.WAIT_INTERVAL_FUNCTION_IN_OPEN_STATE : resilience4JHandle.getWaitIntervalFunctionInOpenState()); - resilience4JHandle.setPermittedNumberOfCallsInHalfOpenState(resilience4JHandle.getPermittedNumberOfCallsInHalfOpenState() < 0 - ? Constants.PERMITTED_NUMBER_OF_CALLS_IN_HALF_OPEN_STATE : resilience4JHandle.getPermittedNumberOfCallsInHalfOpenState()); - resilience4JHandle.setFailureRateThreshold( - resilience4JHandle.getFailureRateThreshold() < 0 || resilience4JHandle.getFailureRateThreshold() > 100 - ? Constants.FAILURE_RATE_THRESHOLD : resilience4JHandle.getFailureRateThreshold()); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RewriteHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RewriteHandle.java deleted file mode 100644 index c60b7f5..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RewriteHandle.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import java.util.Objects; - -/** - * this is rewrite plugin handle. - */ -public class RewriteHandle { - - /** - * java regular expression. - */ - private String regex; - - /** - * replace string. - */ - private String replace; - - /** - * percentage of rewritten traffic. - */ - private Integer percentage; - - /** - * rewrite the original metadata. - */ - private Boolean rewriteMetaData; - - /** - * get regex. - * - * @return regex - */ - public String getRegex() { - return regex; - } - - /** - * set regex. - * - * @param regex regex - */ - public void setRegex(final String regex) { - this.regex = regex; - } - - /** - * get replace. - * - * @return replace - */ - public String getReplace() { - return replace; - } - - /** - * set replace. - * - * @param replace replace - */ - public void setReplace(final String replace) { - this.replace = replace; - } - - /** - * get percentage. - * - * @return percentage - */ - public Integer getPercentage() { - return percentage; - } - - /** - * set percentage. - * - * @param percentage percentage - */ - public void setPercentage(final Integer percentage) { - this.percentage = percentage; - } - - /** - * get rewrite meta data status. - * - * @return rewrite meta data status - */ - public Boolean getRewriteMetaData() { - return rewriteMetaData; - } - - /** - * set rewrite meta data. - * - * @param rewriteMetaData status - */ - public void setRewriteMetaData(final Boolean rewriteMetaData) { - this.rewriteMetaData = rewriteMetaData; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - RewriteHandle that = (RewriteHandle) o; - return Objects.equals(regex, that.regex) && Objects.equals(replace, that.replace) - && Objects.equals(rewriteMetaData, that.rewriteMetaData); - } - - @Override - public int hashCode() { - return Objects.hash(regex, replace, rewriteMetaData); - } - - @Override - public String toString() { - return "RewriteHandle{" - + "regex='" - + regex - + '\'' - + ", replace='" - + replace - + '\'' - + ", percentage='" - + percentage - + '\'' - + ", rewriteMetaData='" - + rewriteMetaData - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java deleted file mode 100644 index 4d612be..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RuleHandle.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import org.apache.shenyu.common.utils.GsonUtils; - -/** - * The RuleHandle interface. - */ -public interface RuleHandle { - - /** - * Format this object to json string. - * @return json string. - */ - default String toJson() { - return GsonUtils.getGson().toJson(this); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/SentinelHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/SentinelHandle.java deleted file mode 100644 index 2835605..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/SentinelHandle.java +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import org.apache.shenyu.common.constant.Constants; - -import java.util.Objects; - -/** - * This is SentinelHandle. - */ -public class SentinelHandle { - - /** - * Flow rule enable. - */ - private Integer flowRuleEnable = Constants.SENTINEL_ENABLE_FLOW_RULE; - - /** - * Flow rule grade. - */ - private Integer flowRuleGrade = Constants.SENTINEL_QPS_FLOW_GRADE; - - /** - * Max queueing time in rate limiter behavior (ms). - */ - private int flowRuleMaxQueueingTimeMs = 500; - - - /** - * The flow control warm-up time (s). - */ - private int flowRuleWarmUpPeriodSec = 10; - - /** - * Flow rule count. - */ - private Integer flowRuleCount; - - /** - * Flow rule control behavior. - */ - private Integer flowRuleControlBehavior = Constants.SENTINEL_FLOW_REJECT; - - /** - * Degrade rule control behavior. - */ - private Integer degradeRuleEnable = Constants.SENTINEL_ENABLE_DEGRADE_RULE; - - /** - * Degrade rule grade. - */ - private Integer degradeRuleGrade = Constants.SENTINEL_RESPONSE_RULE_GRADE; - - /** - * Degrade rule count. - */ - private Double degradeRuleCount; - - /** - * Degrade rule time window. - */ - private Integer degradeRuleTimeWindow; - - /** - * Degrade rule min request amount. - */ - private Integer degradeRuleMinRequestAmount = Constants.SENTINEL_MIN_REQUEST_AMOUNT; - - /** - * Degrade rule slow ratio threshold. - */ - private Double degradeRuleSlowRatioThreshold = Constants.SENTINEL_SLOW_RATIO_THRESHOLD; - - /** - * Degrade rule stat intervalMs. - */ - private int degradeRuleStatIntervals = Constants.SENTINEL_STAT_INTERVALS; - - /** - * Sentinel fallback uri. - */ - private String fallbackUri = "/fallback/sentinel"; - - /** - * New default instance sentinel handle. - * - * @return the sentinel handle - */ - public static SentinelHandle newDefaultInstance() { - return new SentinelHandle(); - } - - /** - * get flowRuleEnable. - * - * @return flowRuleEnable flow rule enable - */ - public Integer getFlowRuleEnable() { - return flowRuleEnable; - } - - /** - * set flowRuleEnable. - * - * @param flowRuleEnable flowRuleEnable - */ - public void setFlowRuleEnable(final Integer flowRuleEnable) { - this.flowRuleEnable = flowRuleEnable; - } - - /** - * get flowRuleGrade. - * - * @return flowRuleGrade flow rule grade - */ - public Integer getFlowRuleGrade() { - return flowRuleGrade; - } - - /** - * set flowRuleGrade. - * - * @param flowRuleGrade flowRuleGrade - */ - public void setFlowRuleGrade(final Integer flowRuleGrade) { - this.flowRuleGrade = flowRuleGrade; - } - - /** - * get flowRuleCount. - * - * @return flowRuleCount flow rule count - */ - public Integer getFlowRuleCount() { - return flowRuleCount; - } - - /** - * set flowRuleCount. - * - * @param flowRuleCount flowRuleCount - */ - public void setFlowRuleCount(final Integer flowRuleCount) { - this.flowRuleCount = flowRuleCount; - } - - /** - * get flowRuleControlBehavior. - * - * @return flowRuleControlBehavior flow rule control behavior - */ - public Integer getFlowRuleControlBehavior() { - return flowRuleControlBehavior; - } - - /** - * set flowRuleControlBehavior. - * - * @param flowRuleControlBehavior flowRuleControlBehavior - */ - public void setFlowRuleControlBehavior(final Integer flowRuleControlBehavior) { - this.flowRuleControlBehavior = flowRuleControlBehavior; - } - - /** - * get degradeRuleEnable. - * - * @return degradeRuleEnable degrade rule enable - */ - public Integer getDegradeRuleEnable() { - return degradeRuleEnable; - } - - /** - * set degradeRuleEnable. - * - * @param degradeRuleEnable degradeRuleEnable - */ - public void setDegradeRuleEnable(final Integer degradeRuleEnable) { - this.degradeRuleEnable = degradeRuleEnable; - } - - /** - * get degradeRuleGrade. - * - * @return degradeRuleGrade degrade rule grade - */ - public Integer getDegradeRuleGrade() { - return degradeRuleGrade; - } - - /** - * set degradeRuleGrade. - * - * @param degradeRuleGrade degradeRuleGrade - */ - public void setDegradeRuleGrade(final Integer degradeRuleGrade) { - this.degradeRuleGrade = degradeRuleGrade; - } - - /** - * get degradeRuleCount. - * - * @return degradeRuleCount degrade rule count - */ - public Double getDegradeRuleCount() { - return degradeRuleCount; - } - - /** - * set degradeRuleCount. - * - * @param degradeRuleCount degradeRuleCount - */ - public void setDegradeRuleCount(final Double degradeRuleCount) { - this.degradeRuleCount = degradeRuleCount; - } - - /** - * get degradeRuleTimeWindow. - * - * @return degradeRuleTimeWindow degrade rule time window - */ - public Integer getDegradeRuleTimeWindow() { - return degradeRuleTimeWindow; - } - - /** - * set degradeRuleTimeWindow. - * - * @param degradeRuleTimeWindow degradeRuleTimeWindow - */ - public void setDegradeRuleTimeWindow(final Integer degradeRuleTimeWindow) { - this.degradeRuleTimeWindow = degradeRuleTimeWindow; - } - - /** - * get degradeRuleMinRequestAmount. - * - * @return degradeRuleMinRequestAmount degrade rule min request amount - */ - public Integer getDegradeRuleMinRequestAmount() { - return degradeRuleMinRequestAmount; - } - - /** - * set degradeRuleMinRequestAmount. - * - * @param degradeRuleMinRequestAmount degradeRuleMinRequestAmount - */ - public void setDegradeRuleMinRequestAmount(final Integer degradeRuleMinRequestAmount) { - this.degradeRuleMinRequestAmount = degradeRuleMinRequestAmount; - } - - /** - * get degradeRuleSlowRatioThreshold. - * - * @return degradeRuleSlowRatioThreshold degrade rule slow ratio threshold - */ - public Double getDegradeRuleSlowRatioThreshold() { - return degradeRuleSlowRatioThreshold; - } - - /** - * set degradeRuleSlowRatioThreshold. - * - * @param degradeRuleSlowRatioThreshold degradeRuleSlowRatioThreshold - */ - public void setDegradeRuleSlowRatioThreshold(final Double degradeRuleSlowRatioThreshold) { - this.degradeRuleSlowRatioThreshold = degradeRuleSlowRatioThreshold; - } - - /** - * get degradeRuleStatIntervals. - * - * @return degradeRuleStatIntervals degrade rule stat intervals - */ - public int getDegradeRuleStatIntervals() { - return degradeRuleStatIntervals; - } - - /** - * set degradeRuleStatIntervals. - * - * @param degradeRuleStatIntervals degradeRuleStatIntervals - */ - public void setDegradeRuleStatIntervals(final int degradeRuleStatIntervals) { - this.degradeRuleStatIntervals = degradeRuleStatIntervals; - } - - /** - * get fallbackUri. - * - * @return fallbackUri fallback uri - */ - public String getFallbackUri() { - return fallbackUri; - } - - /** - * set fallbackUri. - * - * @param fallbackUri fallbackUri - */ - public void setFallbackUri(final String fallbackUri) { - this.fallbackUri = fallbackUri; - } - - /** - * flowRuleMaxQueueingTimeMs. - * - * @return FlowRuleMaxQueueingTimeMs flow rule max queueing time ms - */ - public int getFlowRuleMaxQueueingTimeMs() { - return flowRuleMaxQueueingTimeMs; - } - - /** - * set flowRuleMaxQueueingTimeMs. - * - * @param flowRuleMaxQueueingTimeMs flowRuleMaxQueueingTimeMs - */ - public void setFlowRuleMaxQueueingTimeMs(final int flowRuleMaxQueueingTimeMs) { - this.flowRuleMaxQueueingTimeMs = flowRuleMaxQueueingTimeMs; - } - - /** - * flowRuleWarmUpPeriodSec. - * - * @return FlowRuleWarmUpPeriodSec flow rule warm up period sec - */ - public int getFlowRuleWarmUpPeriodSec() { - return flowRuleWarmUpPeriodSec; - } - - /** - * set flowRuleWarmUpPeriodSec. - * - * @param flowRuleWarmUpPeriodSec flowRuleWarmUpPeriodSec - */ - public void setFlowRuleWarmUpPeriodSec(final int flowRuleWarmUpPeriodSec) { - this.flowRuleWarmUpPeriodSec = flowRuleWarmUpPeriodSec; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - SentinelHandle that = (SentinelHandle) o; - return degradeRuleStatIntervals == that.degradeRuleStatIntervals && Objects.equals(flowRuleEnable, that.flowRuleEnable) - && Objects.equals(flowRuleGrade, that.flowRuleGrade) && Objects.equals(flowRuleCount, that.flowRuleCount) - && Objects.equals(flowRuleControlBehavior, that.flowRuleControlBehavior) && Objects.equals(degradeRuleEnable, that.degradeRuleEnable) - && Objects.equals(degradeRuleGrade, that.degradeRuleGrade) && Objects.equals(degradeRuleCount, that.degradeRuleCount) - && Objects.equals(degradeRuleTimeWindow, that.degradeRuleTimeWindow) && Objects.equals(degradeRuleMinRequestAmount, that.degradeRuleMinRequestAmount) - && Objects.equals(degradeRuleSlowRatioThreshold, that.degradeRuleSlowRatioThreshold) && Objects.equals(fallbackUri, that.fallbackUri) - && Objects.equals(flowRuleMaxQueueingTimeMs, that.flowRuleMaxQueueingTimeMs) && Objects.equals(flowRuleWarmUpPeriodSec, that.flowRuleWarmUpPeriodSec); - } - - @Override - public int hashCode() { - return Objects.hash(flowRuleEnable, flowRuleGrade, flowRuleCount, flowRuleControlBehavior, degradeRuleEnable, degradeRuleGrade, - degradeRuleCount, degradeRuleTimeWindow, degradeRuleMinRequestAmount, degradeRuleSlowRatioThreshold, degradeRuleStatIntervals, - fallbackUri, flowRuleMaxQueueingTimeMs, flowRuleWarmUpPeriodSec); - } - - @Override - public String toString() { - return "SentinelHandle{" - + "flowRuleEnable=" - + flowRuleEnable - + ", flowRuleGrade=" - + flowRuleGrade - + ", flowRuleCount=" - + flowRuleCount - + ", flowRuleControlBehavior=" - + flowRuleControlBehavior - + ", degradeRuleEnable=" - + degradeRuleEnable - + ", degradeRuleGrade=" - + degradeRuleGrade - + ", degradeRuleCount=" - + degradeRuleCount - + ", degradeRuleTimeWindow=" - + degradeRuleTimeWindow - + ", degradeRuleMinRequestAmount=" - + degradeRuleMinRequestAmount - + ", degradeRuleSlowRatioThreshold=" - + degradeRuleSlowRatioThreshold - + ", degradeRuleStatIntervals=" - + degradeRuleStatIntervals - + ", fallbackUri='" - + fallbackUri - + ", flowRuleMaxQueueingTimeMs='" - + flowRuleMaxQueueingTimeMs - + ", flowRuleWarmUpPeriodSec='" - + flowRuleWarmUpPeriodSec - + '\'' - + '}'; - } - - /** - * check filed default value. - */ - public void checkData() { - this.setFlowRuleEnable((this.getFlowRuleEnable() == Constants.FLOW_RULE_ENABLE_ON || this.getFlowRuleEnable() == Constants.FLOW_RULE_ENABLE_OFF) - ? this.getFlowRuleEnable() : Constants.SENTINEL_ENABLE_FLOW_RULE); - this.setDegradeRuleEnable((this.getDegradeRuleEnable() == Constants.DEGRADE_RULE_ENABLE_ON || this.getDegradeRuleEnable() == Constants.DEGRADE_RULE_ENABLE_OFF) - ? this.getDegradeRuleEnable() : Constants.SENTINEL_ENABLE_DEGRADE_RULE); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/WafHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/WafHandle.java deleted file mode 100644 index 873dad6..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/WafHandle.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import org.apache.shenyu.common.enums.WafEnum; - -import java.util.Objects; - -/** - * this is waf plugin handle. - */ -public class WafHandle { - - /** - * permission. - */ - private String permission; - - /** - * statusCode. - */ - private String statusCode; - - /** - * New default instance waf handle. - * - * @return the waf handle - */ - public static WafHandle newDefaultInstance() { - WafHandle wafHandle = new WafHandle(); - wafHandle.setPermission(WafEnum.REJECT.getName()); - wafHandle.setStatusCode("403"); - return wafHandle; - } - - /** - * get permission. - * - * @return permission permission - */ - public String getPermission() { - return permission; - } - - /** - * set permission. - * - * @param permission permission - */ - public void setPermission(final String permission) { - this.permission = permission; - } - - /** - * get statusCode. - * - * @return statusCode status code - */ - public String getStatusCode() { - return statusCode; - } - - /** - * set statusCode. - * - * @param statusCode statusCode - */ - public void setStatusCode(final String statusCode) { - this.statusCode = statusCode; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - WafHandle wafHandle = (WafHandle) o; - return Objects.equals(permission, wafHandle.permission) && Objects.equals(statusCode, wafHandle.statusCode); - } - - @Override - public int hashCode() { - return Objects.hash(permission, statusCode); - } - - @Override - public String toString() { - return "WafHandle{" - + "permission='" - + permission - + '\'' - + ", statusCode='" - + statusCode - + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CacheRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CacheRuleHandle.java deleted file mode 100644 index 4d8a09e..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/CacheRuleHandle.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; - -/** - * The type Divide rule handle. - */ -public class CacheRuleHandle implements RuleHandle { - - /** - * the cache timeout seconds. - */ - private Long timeoutSeconds = 60L; - - /** - * Get the timeout seconds. - * - * @return the timeout seconds - */ - public Long getTimeoutSeconds() { - return timeoutSeconds; - } - - /** - * Set timeout seconds. - * - * @param timeoutSeconds the timeout seconds - */ - public void setTimeoutSeconds(final Long timeoutSeconds) { - this.timeoutSeconds = timeoutSeconds; - } - - /** - * New instance cache rule handle. - * - * @return the cache rule handle - */ - public static CacheRuleHandle newInstance() { - return new CacheRuleHandle(); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingRuleHandle.java deleted file mode 100644 index 4d138bb..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingRuleHandle.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; - -import java.util.Objects; - -/** - * Context mapping thread handle. - */ -public class ContextMappingRuleHandle implements RuleHandle { - - private boolean addPrefixed; - - private String contextPath; - - private String addPrefix; - - private String rewriteContextPath; - - /** - * percentage of rewritten traffic in context. - */ - private Integer percentage; - - /** - * New instance context mapping rule handle. - * - * @return the context mapping rule handle - */ - public static ContextMappingRuleHandle newInstance() { - return new ContextMappingRuleHandle(); - } - - /** - * get prefix forward status. - * - * @return prefix -forward status - */ - public boolean getAddPrefixed() { - return addPrefixed; - } - - /** - * set prefix forward. - * - * @param addPrefixed status - */ - public void setAddPrefixed(final boolean addPrefixed) { - this.addPrefixed = addPrefixed; - } - - /** - * get contextPath. - * - * @return contextPath context path - */ - public String getContextPath() { - return contextPath; - } - - /** - * set contextPath. - * - * @param contextPath contextPath - */ - public void setContextPath(final String contextPath) { - this.contextPath = contextPath; - } - - /** - * get addPrefix. - * - * @return addPrefix add prefix - */ - public String getAddPrefix() { - return addPrefix; - } - - /** - * set addPrefix. - * - * @param addPrefix addPrefix - */ - public void setAddPrefix(final String addPrefix) { - this.addPrefix = addPrefix; - } - - /** - * get rewrite context path. - * - * @return rewrite context path - */ - public String getRewriteContextPath() { - return rewriteContextPath; - } - - /** - * set rewrite context path. - * - * @param rewriteContextPath rewrite context path - */ - public void setRewriteContextPath(final String rewriteContextPath) { - this.rewriteContextPath = rewriteContextPath; - } - - /** - * get percentage. - * - * @return percentage - */ - public Integer getPercentage() { - return percentage; - } - - /** - * set percentage. - * - * @param percentage percentage - */ - public void setPercentage(final Integer percentage) { - this.percentage = percentage; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ContextMappingRuleHandle that = (ContextMappingRuleHandle) o; - return Objects.equals(contextPath, that.contextPath) && Objects.equals(addPrefix, that.addPrefix) - && Objects.equals(addPrefixed, that.addPrefixed) && Objects.equals(rewriteContextPath, that.rewriteContextPath); - } - - @Override - public String toString() { - return "ContextMappingRuleHandle{" - + "contextPath='" - + contextPath - + '\'' - + ", addPrefix='" - + addPrefix - + '\'' - + "addPrefixed='" - + addPrefixed - + '\'' - + ", rewriteContextPath='" - + rewriteContextPath - + '\'' - + ", percentage='" - + percentage - + '\'' - + '}'; - } - - @Override - public int hashCode() { - return Objects.hash(contextPath, addPrefix, addPrefixed, rewriteContextPath); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandle.java deleted file mode 100644 index 20b1864..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandle.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; -import org.apache.shenyu.common.enums.LoadBalanceEnum; -import org.apache.shenyu.common.enums.RetryEnum; - -import java.util.Objects; - -/** - * The type Divide rule handle. - */ -public class DivideRuleHandle implements RuleHandle { - - /** - * loadBalance. - * {@linkplain LoadBalanceEnum} - */ - private String loadBalance = LoadBalanceEnum.RANDOM.getName(); - - /** - * retryStrategy. - * {@linkplain RetryEnum} - */ - private String retryStrategy = RetryEnum.CURRENT.getName(); - - /** - * http retry. - */ - private int retry = 3; - - /** - * timeout is required. - */ - private long timeout = Constants.TIME_OUT; - - /** - * headerMaxSize. - */ - private long headerMaxSize; - - /** - * requestMaxSize. - */ - private long requestMaxSize; - - /** - * New instance divide rule handle. - * - * @return the divide rule handle - */ - public static DivideRuleHandle newInstance() { - return new DivideRuleHandle(); - } - - /** - * get loadBalance. - * - * @return loadBalance load balance - */ - public String getLoadBalance() { - return loadBalance; - } - - /** - * set loadBalance. - * - * @param loadBalance loadBalance - */ - public void setLoadBalance(final String loadBalance) { - this.loadBalance = loadBalance; - } - - /** - * get retryStrategy. - * - * @return retryStrategy retry strategy - */ - public String getRetryStrategy() { - return retryStrategy; - } - - /** - * set retryStrategy. - * - * @param retryStrategy retryStrategy - */ - public void setRetryStrategy(final String retryStrategy) { - this.retryStrategy = retryStrategy; - } - - /** - * get retry. - * - * @return retry retry - */ - public int getRetry() { - return retry; - } - - /** - * set retry. - * - * @param retry retry - */ - public void setRetry(final int retry) { - this.retry = retry; - } - - /** - * get timeout. - * - * @return timeout timeout - */ - public long getTimeout() { - return timeout; - } - - /** - * set timeout. - * - * @param timeout timeout - */ - public void setTimeout(final long timeout) { - this.timeout = timeout; - } - - /** - * get headerMaxSize. - * - * @return headerMaxSize header max size - */ - public long getHeaderMaxSize() { - return headerMaxSize; - } - - /** - * set headerMaxSize. - * - * @param headerMaxSize headerMaxSize - */ - public void setHeaderMaxSize(final long headerMaxSize) { - this.headerMaxSize = headerMaxSize; - } - - /** - * get requestMaxSize. - * - * @return requestMaxSize request max size - */ - public long getRequestMaxSize() { - return requestMaxSize; - } - - /** - * set requestMaxSize. - * - * @param requestMaxSize requestMaxSize - */ - public void setRequestMaxSize(final long requestMaxSize) { - this.requestMaxSize = requestMaxSize; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - DivideRuleHandle that = (DivideRuleHandle) o; - return retry == that.retry && timeout == that.timeout && headerMaxSize == that.headerMaxSize - && requestMaxSize == that.requestMaxSize && Objects.equals(loadBalance, that.loadBalance) - && Objects.equals(retryStrategy, that.retryStrategy); - } - - @Override - public int hashCode() { - return Objects.hash(loadBalance, retryStrategy, retry, timeout, headerMaxSize, requestMaxSize); - } - - @Override - public String toString() { - return "DivideRuleHandle{" - + "loadBalance='" - + loadBalance - + '\'' - + "retryStrategy='" - + retryStrategy - + '\'' - + ", retry=" - + retry - + ", timeout=" - + timeout - + ", headerMaxSize=" - + headerMaxSize - + ", requestMaxSize=" - + requestMaxSize - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandle.java deleted file mode 100644 index ec31321..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandle.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; -import org.apache.shenyu.common.enums.LoadBalanceEnum; - -import java.util.Objects; - -/** - * The type Dubbo rule handle. - */ -public class DubboRuleHandle implements RuleHandle { - - /** - * version. - */ - private String version; - - /** - * group. - */ - private String group; - - /** - * retries. - */ - private Integer retries = 0; - - /** - * the loadbalance. - * {@linkplain LoadBalanceEnum} - */ - private String loadBalance = LoadBalanceEnum.RANDOM.getName(); - - /** - * timeout is required. - */ - private long timeout = Constants.TIME_OUT; - - /** - * New instance dubbo rule handle. - * - * @return the dubbo rule handle - */ - public static DubboRuleHandle newInstance() { - return new DubboRuleHandle(); - } - - /** - * get version. - * - * @return version version - */ - public String getVersion() { - return version; - } - - /** - * set version. - * - * @param version version - */ - public void setVersion(final String version) { - this.version = version; - } - - /** - * get group. - * - * @return group group - */ - public String getGroup() { - return group; - } - - /** - * set group. - * - * @param group group - */ - public void setGroup(final String group) { - this.group = group; - } - - /** - * get retries. - * - * @return retries retries - */ - public Integer getRetries() { - return retries; - } - - /** - * set retries. - * - * @param retries retries - */ - public void setRetries(final Integer retries) { - this.retries = retries; - } - - /** - * Gets the value of loadbalance. - * - * @return the value of loadbalance - */ - public String getLoadBalance() { - return loadBalance; - } - - /** - * Sets the loadbalance. - * - * @param loadBalance loadbalance - */ - public void setLoadBalance(final String loadBalance) { - this.loadBalance = loadBalance; - } - - /** - * get timeout. - * - * @return timeout timeout - */ - public long getTimeout() { - return timeout; - } - - /** - * set timeout. - * - * @param timeout timeout - */ - public void setTimeout(final long timeout) { - this.timeout = timeout; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DubboRuleHandle)) { - return false; - } - DubboRuleHandle that = (DubboRuleHandle) o; - return timeout == that.timeout - && Objects.equals(version, that.version) - && Objects.equals(group, that.group) - && Objects.equals(retries, that.retries) - && Objects.equals(loadBalance, that.loadBalance); - } - - @Override - public int hashCode() { - return Objects.hash(version, group, retries, loadBalance, timeout); - } - - @Override - public String toString() { - return "DubboRuleHandle{" - + "version='" + version + '\'' - + ", group='" + group + '\'' - + ", retries=" + retries - + ", loadbalance='" + loadBalance + '\'' - + ", timeout=" + timeout - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/GrpcRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/GrpcRuleHandle.java deleted file mode 100644 index 2fa8a8f..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/GrpcRuleHandle.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; -import org.apache.shenyu.common.enums.LoadBalanceEnum; - -import java.util.Objects; - -/** - * The type Grpc rule handle. - */ -public class GrpcRuleHandle implements RuleHandle { - - /** - * the loadBalance. - * {@linkplain LoadBalanceEnum} - */ - private String loadBalance = LoadBalanceEnum.RANDOM.getName(); - - /** - * New instance Grpc rule handle. - * - * @return the Grpc rule handle - */ - public static GrpcRuleHandle newInstance() { - return new GrpcRuleHandle(); - } - - /** - * Gets the value of loadBalance. - * - * @return the value of loadBalance - */ - public String getLoadBalance() { - return loadBalance; - } - - /** - * Sets the loadBalance. - * - * @param loadBalance loadBalance - */ - public void setLoadBalance(final String loadBalance) { - this.loadBalance = loadBalance; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof GrpcRuleHandle)) { - return false; - } - GrpcRuleHandle that = (GrpcRuleHandle) o; - return Objects.equals(loadBalance, that.loadBalance); - } - - @Override - public int hashCode() { - return Objects.hash(loadBalance); - } - - @Override - public String toString() { - return "GrpcRuleHandle{" - + "loadBalance='" + loadBalance + '\'' - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/KeyAuthRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/KeyAuthRuleHandle.java deleted file mode 100644 index b360a80..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/KeyAuthRuleHandle.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; - -import java.util.Objects; - -/** - * Key-Auth rule handle. - */ -public class KeyAuthRuleHandle implements RuleHandle { - - /** - * The key attribute name. It is required. - */ - private String keyName; - - /** - * The key value. It is required. - */ - private String key; - - /** - * Get key attribute name. - * - * @return keyName - */ - public String getKeyName() { - return keyName; - } - - /** - * Set key attribute name. - * - * @param keyName keyName - */ - public void setKeyName(final String keyName) { - this.keyName = keyName; - } - - /** - * Get the key. - * - * @return key - */ - public String getKey() { - return key; - } - - /** - * Set the key. - * - * @param key key - */ - public void setKey(final String key) { - this.key = key; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - KeyAuthRuleHandle that = (KeyAuthRuleHandle) o; - return Objects.equals(keyName, that.keyName) - && Objects.equals(key, that.key); - } - - @Override - public int hashCode() { - return Objects.hash(keyName, key); - } - - @Override - public String toString() { - return "KeyAuthRuleHandle{" - + "keyName='" + keyName - + "', key='" + key - + "'}"; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandle.java deleted file mode 100644 index b76aebc..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandle.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; - -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -/** - * The type ModifyResponse rule handle. - */ -public class ModifyResponseRuleHandle implements RuleHandle { - - /** - * add header map. - */ - private Map addHeaders; - - /** - * set header map. - */ - private Map setHeaders; - - /** - * replace header map - * key: oldHeaderKey, value: newHeaderKey. - */ - private Map replaceHeaderKeys; - - /** - * remove header List. - */ - private Set removeHeaderKeys; - - /** - * http response status code. - */ - private int statusCode; - - /** - * add body List. - */ - private List addBodyKeys; - - /** - * replace body List. - */ - private List replaceBodyKeys; - - /** - * remove body List. - */ - private Set removeBodyKeys; - - /** - * get addHeaders. - * - * @return addHeaders - */ - public Map getAddHeaders() { - return addHeaders; - } - - /** - * set addHeaders. - * - * @param addHeaders addHeaders - */ - public void setAddHeaders(final Map addHeaders) { - this.addHeaders = addHeaders; - } - - /** - * get setHeaders. - * - * @return setHeaders - */ - public Map getSetHeaders() { - return setHeaders; - } - - /** - * set setHeaders. - * - * @param setHeaders setHeaders - */ - public void setSetHeaders(final Map setHeaders) { - this.setHeaders = setHeaders; - } - - /** - * get replaceHeaderKeys. - * - * @return replaceHeaderKeys - */ - public Map getReplaceHeaderKeys() { - return replaceHeaderKeys; - } - - /** - * set replaceHeaderKeys. - * - * @param replaceHeaderKeys replaceHeaderKeys - */ - public void setReplaceHeaderKeys(final Map replaceHeaderKeys) { - this.replaceHeaderKeys = replaceHeaderKeys; - } - - /** - * get removeHeaderKeys. - * - * @return removeHeaderKeys - */ - public Set getRemoveHeaderKeys() { - return removeHeaderKeys; - } - - /** - * set removeHeaderKeys. - * - * @param removeHeaderKeys removeHeaderKeys - */ - public void setRemoveHeaderKeys(final Set removeHeaderKeys) { - this.removeHeaderKeys = removeHeaderKeys; - } - - /** - * get statusCode. - * - * @return statusCode - */ - public int getStatusCode() { - return statusCode; - } - - /** - * set statusCode. - * - * @param statusCode statusCode - */ - public void setStatusCode(final int statusCode) { - this.statusCode = statusCode; - } - - /** - * get addBodyKeys. - * - * @return addBodyKeys - */ - public List getAddBodyKeys() { - return addBodyKeys; - } - - /** - * set addBodyKeys. - * - * @param addBodyKeys addBodyKeys - */ - public void setAddBodyKeys(final List addBodyKeys) { - this.addBodyKeys = addBodyKeys; - } - - /** - * get replaceBodyKeys. - * - * @return replaceBodyKeys - */ - public List getReplaceBodyKeys() { - return replaceBodyKeys; - } - - /** - * set replaceBodyKeys. - * - * @param replaceBodyKeys replaceBodyKeys - */ - public void setReplaceBodyKeys(final List replaceBodyKeys) { - this.replaceBodyKeys = replaceBodyKeys; - } - - /** - * get removeBodyKeys. - * - * @return removeBodyKeys - */ - public Set getRemoveBodyKeys() { - return removeBodyKeys; - } - - /** - * set removeBodyKeys. - * - * @param removeBodyKeys removeBodyKeys - */ - public void setRemoveBodyKeys(final Set removeBodyKeys) { - this.removeBodyKeys = removeBodyKeys; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ModifyResponseRuleHandle that = (ModifyResponseRuleHandle) o; - return statusCode == that.statusCode && Objects.equals(addHeaders, that.addHeaders) - && Objects.equals(setHeaders, that.setHeaders) && Objects.equals(replaceHeaderKeys, that.replaceHeaderKeys) - && Objects.equals(removeHeaderKeys, that.removeHeaderKeys) && Objects.equals(addBodyKeys, that.addBodyKeys) - && Objects.equals(replaceBodyKeys, that.replaceBodyKeys) && Objects.equals(removeBodyKeys, that.removeBodyKeys); - } - - @Override - public int hashCode() { - return Objects.hash(addHeaders, setHeaders, replaceHeaderKeys, removeHeaderKeys, statusCode, addBodyKeys, replaceBodyKeys, removeBodyKeys); - } - - @Override - public String toString() { - return "ModifyResponseRuleHandle{" - + "addHeaders=" - + addHeaders - + ", setHeaders=" - + setHeaders - + ", replaceHeaderKeys=" - + replaceHeaderKeys - + ", removeHeaderKeys=" - + removeHeaderKeys - + ", statusCode=" - + statusCode - + ", addBodyKeys=" - + addBodyKeys - + ", replaceBodyKeys=" - + replaceBodyKeys - + ", removeBodyKeys=" - + removeBodyKeys - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandle.java deleted file mode 100644 index f6da0a3..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandle.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; - -import java.util.List; -import java.util.Objects; -import java.util.Set; - -/** - * Param mapping handle. - */ -public class ParamMappingRuleHandle implements RuleHandle { - - private Set removeParameterKeys; - - private List replaceParameterKeys; - - private List addParameterKeys; - - /** - * get removeParameterKeys. - * - * @return removeParameterKeys - */ - public Set getRemoveParameterKeys() { - return removeParameterKeys; - } - - /** - * set removeParameterKeys. - * - * @param removeParameterKeys removeParameterKeys - */ - public void setRemoveParameterKeys(final Set removeParameterKeys) { - this.removeParameterKeys = removeParameterKeys; - } - - /** - * get replaceParameterKeys. - * - * @return replaceParameterKeys - */ - public List getReplaceParameterKeys() { - return replaceParameterKeys; - } - - /** - * set replaceParameterKeys. - * - * @param replaceParameterKeys replaceParameterKeys - */ - public void setReplaceParameterKeys(final List replaceParameterKeys) { - this.replaceParameterKeys = replaceParameterKeys; - } - - /** - * get addParameterKeys. - * - * @return addParameterKeys - */ - public List getAddParameterKeys() { - return addParameterKeys; - } - - /** - * set addParameterKeys. - * - * @param addParameterKeys addParameterKeys - */ - public void setAddParameterKeys(final List addParameterKeys) { - this.addParameterKeys = addParameterKeys; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ParamMappingRuleHandle that = (ParamMappingRuleHandle) o; - return Objects.equals(removeParameterKeys, that.removeParameterKeys) && Objects.equals(replaceParameterKeys, that.replaceParameterKeys) - && Objects.equals(addParameterKeys, that.addParameterKeys); - } - - @Override - public int hashCode() { - return Objects.hash(removeParameterKeys, replaceParameterKeys, addParameterKeys); - } - - @Override - public String toString() { - return "ParamMappingRuleHandle{" - + "removeParameterKeys=" - + removeParameterKeys - + ", replaceParameterKeys=" - + replaceParameterKeys - + ", addParameterKeys=" - + addParameterKeys - + '}'; - } - - public static class ParamMapInfo { - - private String path; - - private String key; - - private String value; - - /** - * get path. - * - * @return path - */ - public String getPath() { - return path; - } - - /** - * set path. - * - * @param path path - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * get key. - * - * @return key - */ - public String getKey() { - return key; - } - - /** - * set key. - * - * @param key key - */ - public void setKey(final String key) { - this.key = key; - } - - /** - * get value. - * - * @return value - */ - public String getValue() { - return value; - } - - /** - * set value. - * - * @param value value - */ - public void setValue(final String value) { - this.value = value; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ParamMapInfo that = (ParamMapInfo) o; - return Objects.equals(path, that.path) && Objects.equals(key, that.key) && Objects.equals(value, that.value); - } - - @Override - public int hashCode() { - return Objects.hash(path, key, value); - } - - @Override - public String toString() { - return "ParamMapInfo{" - + "path='" - + path - + '\'' - + ", key='" - + key - + '\'' - + ", value='" - + value - + '\'' - + '}'; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandle.java deleted file mode 100644 index 577eb13..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandle.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; -import org.apache.shenyu.common.enums.LoadBalanceEnum; - -import java.util.Objects; - -/** - * The type Sofa rule handle. - */ - -public class SofaRuleHandle implements RuleHandle { - - /** - * retries. - */ - private Integer retries = 0; - - /** - * the loadBalance. - * {@linkplain LoadBalanceEnum} - */ - private String loadBalance = LoadBalanceEnum.RANDOM.getName(); - - /** - * timeout is required. - */ - private long timeout = Constants.TIME_OUT; - - /** - * get retries. - * - * @return retries - */ - public Integer getRetries() { - return retries; - } - - /** - * set retries. - * - * @param retries retries - */ - public void setRetries(final Integer retries) { - this.retries = retries; - } - - /** - * get loadBalance. - * - * @return loadBalance - */ - public String getLoadBalance() { - return loadBalance; - } - - /** - * set loadBalance. - * - * @param loadBalance loadBalance - */ - public void setLoadBalance(final String loadBalance) { - this.loadBalance = loadBalance; - } - - /** - * get timeout. - * - * @return timeout - */ - public long getTimeout() { - return timeout; - } - - /** - * set timeout. - * - * @param timeout timeout - */ - public void setTimeout(final long timeout) { - this.timeout = timeout; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - SofaRuleHandle that = (SofaRuleHandle) o; - return timeout == that.timeout && Objects.equals(retries, that.retries) && Objects.equals(loadBalance, that.loadBalance); - } - - @Override - public int hashCode() { - return Objects.hash(retries, loadBalance, timeout); - } - - @Override - public String toString() { - return "SofaRuleHandle{" - + "retries=" - + retries - + ", loadBalance='" - + loadBalance - + '\'' - + ", timeout=" - + timeout - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandle.java deleted file mode 100644 index ac91591..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandle.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; -import org.apache.shenyu.common.enums.LoadBalanceEnum; - -import java.util.Objects; - -/** - * The type Spring cloud rule handle. - */ -public class SpringCloudRuleHandle implements RuleHandle { - - /** - * this remote uri path. - */ - private String path; - - /** - * timeout is required. - */ - private long timeout = Constants.TIME_OUT; - - /** - * loadBalance. - * {@linkplain LoadBalanceEnum} - */ - private String loadBalance = LoadBalanceEnum.ROUND_ROBIN.getName(); - - /** - * New default instance spring cloud rule handle. - * - * @return the spring cloud rule handle - */ - public static SpringCloudRuleHandle newDefaultInstance() { - SpringCloudRuleHandle springCloudRuleHandle = new SpringCloudRuleHandle(); - springCloudRuleHandle.setTimeout(Constants.TIME_OUT); - springCloudRuleHandle.setLoadBalance(LoadBalanceEnum.ROUND_ROBIN.getName()); - return springCloudRuleHandle; - } - - /** - * get path. - * - * @return path path - */ - public String getPath() { - return path; - } - - /** - * set path. - * - * @param path path - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * get timeout. - * - * @return timeout timeout - */ - public long getTimeout() { - return timeout; - } - - /** - * set timeout. - * - * @param timeout timeout - */ - public void setTimeout(final long timeout) { - this.timeout = timeout; - } - - /** - * get loadBalance. - * - * @return loadBalance loadBalance - */ - public String getLoadBalance() { - return loadBalance; - } - - /** - * set loadBalance. - * - * @param loadBalance loadBalance - */ - public void setLoadBalance(final String loadBalance) { - this.loadBalance = loadBalance; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - SpringCloudRuleHandle that = (SpringCloudRuleHandle) o; - return timeout == that.timeout && Objects.equals(path, that.path); - } - - @Override - public int hashCode() { - return Objects.hash(path, timeout); - } - - @Override - public String toString() { - return "SpringCloudRuleHandle{" - + "path='" - + path - + '\'' - + ", timeout=" - + timeout - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandle.java deleted file mode 100644 index d3b1532..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandle.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.dto.convert.rule.RuleHandle; -import org.apache.shenyu.common.enums.LoadBalanceEnum; - -import java.util.Objects; - -/** - * The type WebSocket rule handle. - */ -public class WebSocketRuleHandle implements RuleHandle { - - /** - * loadBalance. - * {@linkplain LoadBalanceEnum} - */ - private String loadBalance = LoadBalanceEnum.RANDOM.getName(); - - /** - * http retry. - */ - private int retry; - - /** - * timeout is required. - */ - private long timeout = Constants.TIME_OUT; - - /** - * New default instance web socket rule handle. - * - * @return the web socket rule handle - */ - public static WebSocketRuleHandle newDefaultInstance() { - return new WebSocketRuleHandle(); - } - - /** - * get loadBalance. - * - * @return loadBalance load balance - */ - public String getLoadBalance() { - return loadBalance; - } - - /** - * set loadBalance. - * - * @param loadBalance loadBalance - */ - public void setLoadBalance(final String loadBalance) { - this.loadBalance = loadBalance; - } - - /** - * get retry. - * - * @return retry retry - */ - public int getRetry() { - return retry; - } - - /** - * set retry. - * - * @param retry retry - */ - public void setRetry(final int retry) { - this.retry = retry; - } - - /** - * get timeout. - * - * @return timeout timeout - */ - public long getTimeout() { - return timeout; - } - - /** - * set timeout. - * - * @param timeout timeout - */ - public void setTimeout(final long timeout) { - this.timeout = timeout; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - WebSocketRuleHandle that = (WebSocketRuleHandle) o; - return retry == that.retry && timeout == that.timeout && Objects.equals(loadBalance, that.loadBalance); - } - - @Override - public int hashCode() { - return Objects.hash(loadBalance, retry, timeout); - } - - @Override - public String toString() { - return "DivideRuleHandle{" - + "loadBalance='" - + loadBalance - + '\'' - + ", retry=" - + retry - + ", timeout=" - + timeout - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/CommonUpstream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/CommonUpstream.java deleted file mode 100644 index 4804d02..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/CommonUpstream.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import java.util.Objects; - -/** - * this is common upstream. - */ -public class CommonUpstream { - - /** - * this is http protocol. - */ - private String protocol; - - /** - * host. - */ - private String upstreamHost; - - /** - * url. - */ - private String upstreamUrl; - - /** - * false close/ true open. - */ - private boolean status = true; - - /** - * startup time. - */ - private long timestamp; - - /** - * Instantiates a new Common upstream. - */ - public CommonUpstream() { - - } - - /** - * Instantiates a new Common upstream. - * - * @param protocol the protocol - * @param upstreamHost the upstream host - * @param upstreamUrl the upstream url - * @param status the upstream status - * @param timestamp the upstream timestamp - */ - public CommonUpstream(final String protocol, final String upstreamHost, final String upstreamUrl, final boolean status, final long timestamp) { - this.protocol = protocol; - this.upstreamHost = upstreamHost; - this.upstreamUrl = upstreamUrl; - this.status = status; - this.timestamp = timestamp; - } - - /** - * get upstreamHost. - * - * @return upstreamHost upstream host - */ - public String getUpstreamHost() { - return upstreamHost; - } - - /** - * set upstreamHost. - * - * @param upstreamHost upstreamHost - */ - public void setUpstreamHost(final String upstreamHost) { - this.upstreamHost = upstreamHost; - } - - /** - * get protocol. - * - * @return protocol protocol - */ - public String getProtocol() { - return protocol; - } - - /** - * set protocol. - * - * @param protocol protocol - */ - public void setProtocol(final String protocol) { - this.protocol = protocol; - } - - /** - * get upstreamUrl. - * - * @return upstreamUrl upstream url - */ - public String getUpstreamUrl() { - return upstreamUrl; - } - - /** - * set upstreamUrl. - * - * @param upstreamUrl upstreamUrl - */ - public void setUpstreamUrl(final String upstreamUrl) { - this.upstreamUrl = upstreamUrl; - } - - /** - * get status. - * - * @return status boolean - */ - public boolean isStatus() { - return status; - } - - /** - * set status. - * - * @param status status - */ - public void setStatus(final boolean status) { - this.status = status; - } - - /** - * get timestamp. - * - * @return timestamp timestamp - */ - public long getTimestamp() { - return timestamp; - } - - /** - * set timestamp. - * - * @param timestamp timestamp - */ - public void setTimestamp(final long timestamp) { - this.timestamp = timestamp; - } - - /** - * Default status boolean. - * - * @return the boolean - */ - protected static boolean defaultStatus() { - return true; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - CommonUpstream that = (CommonUpstream) o; - return Objects.equals(upstreamHost, that.upstreamHost) && Objects.equals(protocol, that.protocol) && Objects.equals(upstreamUrl, that.upstreamUrl); - } - - @Override - public int hashCode() { - return Objects.hash(upstreamHost, protocol, upstreamUrl); - } - - @Override - public String toString() { - return "CommonUpstream{" - + "protocol='" - + protocol - + '\'' - + ", upstreamHost='" - + upstreamHost - + '\'' - + ", upstreamUrl='" - + upstreamUrl - + '\'' - + ", status=" - + status - + ", timestamp=" - + timestamp - + '}'; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DiscoveryUpstream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DiscoveryUpstream.java deleted file mode 100644 index a81217e..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DiscoveryUpstream.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -/** - * DiscoveryUpstream. - */ -public class DiscoveryUpstream extends CommonUpstream { - - private int weight; - - private String prop; - - /** - * getWeight. - * - * @return weight - */ - public int getWeight() { - return weight; - } - - /** - * setWeight. - * - * @param weight weight - */ - public void setWeight(final int weight) { - this.weight = weight; - } - - /** - * getProp. - * - * @return prop - */ - public String getProp() { - return prop; - } - - /** - * setProp. - * - * @param prop prop - */ - public void setProp(final String prop) { - this.prop = prop; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DivideUpstream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DivideUpstream.java deleted file mode 100644 index 2388e51..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DivideUpstream.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import java.util.Objects; - -/** - * this is divide upstream. - */ -public class DivideUpstream extends CommonUpstream { - - /** - * weight. - */ - private int weight; - - /** - * warmup. - */ - private int warmup; - - /** - * no args constructor. - */ - public DivideUpstream() { - } - - /** - * builder constructor. - * - * @param builder builder - */ - private DivideUpstream(final Builder builder) { - boolean statusValue = builder.statusValue; - if (!builder.statusSet) { - statusValue = defaultStatus(); - } - setUpstreamHost(builder.upstreamHost); - setProtocol(builder.protocol); - setUpstreamUrl(builder.upstreamUrl); - this.weight = builder.weight; - setStatus(statusValue); - setTimestamp(builder.timestamp); - this.warmup = builder.warmup; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get weight. - * - * @return weight - */ - public int getWeight() { - return weight; - } - - /** - * set weight. - * - * @param weight weight - */ - public void setWeight(final int weight) { - this.weight = weight; - } - - /** - * get warmup. - * - * @return warmup - */ - public int getWarmup() { - return warmup; - } - - /** - * set warmup. - * - * @param warmup warmup - */ - public void setWarmup(final int warmup) { - this.warmup = warmup; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - DivideUpstream that = (DivideUpstream) o; - return Objects.equals(getUpstreamHost(), that.getUpstreamHost()) && Objects.equals(getProtocol(), that.getProtocol()) && Objects.equals(getUpstreamUrl(), that.getUpstreamUrl()); - } - - @Override - public int hashCode() { - return Objects.hash(getUpstreamHost(), getProtocol(), getUpstreamUrl()); - } - - @Override - public String toString() { - return "DivideUpstream{" - + "upstreamHost='" - + getUpstreamHost() - + '\'' - + ", protocol='" - + getProtocol() - + '\'' - + ", upstreamUrl='" - + getUpstreamUrl() - + '\'' - + ", weight=" - + weight - + ", status=" - + isStatus() - + ", timestamp=" - + getTimestamp() - + ", warmup=" - + warmup - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * upstreamHost. - */ - private String upstreamHost; - - /** - * protocol. - */ - private String protocol; - - /** - * upstreamUrl. - */ - private String upstreamUrl; - - /** - * weight. - */ - private int weight; - - /** - * status. - */ - private boolean statusSet; - - /** - * status. - */ - private boolean statusValue; - - /** - * timestamp. - */ - private long timestamp; - - /** - * warmup. - */ - private int warmup; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return DivideUpstream - */ - public DivideUpstream build() { - return new DivideUpstream(this); - } - - /** - * build upstreamHost. - * - * @param upstreamHost upstreamHost - * @return this - */ - public Builder upstreamHost(final String upstreamHost) { - this.upstreamHost = upstreamHost; - return this; - } - - /** - * build protocol. - * - * @param protocol protocol - * @return this - */ - public Builder protocol(final String protocol) { - this.protocol = protocol; - return this; - } - - /** - * build upstreamUrl. - * - * @param upstreamUrl upstreamUrl - * @return this - */ - public Builder upstreamUrl(final String upstreamUrl) { - this.upstreamUrl = upstreamUrl; - return this; - } - - /** - * build weight. - * - * @param weight weight - * @return this - */ - public Builder weight(final int weight) { - this.weight = weight; - return this; - } - - /** - * build status. - * - * @param status status - * @return this - */ - public Builder status(final boolean status) { - this.statusValue = status; - this.statusSet = true; - return this; - } - - /** - * build timestamp. - * - * @param timestamp timestamp - * @return this - */ - public Builder timestamp(final long timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * build warmup. - * - * @param warmup warmup - * @return this - */ - public Builder warmup(final int warmup) { - this.warmup = warmup; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstream.java deleted file mode 100644 index 8761a71..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstream.java +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import java.util.Objects; - -/** - * The type Dubbo selector upstream. - */ -public final class DubboUpstream extends CommonUpstream { - - /** - * zookeeper url is required. - */ - private String registry; - - /** - * dubbo application name is required. - */ - private String appName; - - /** - * port. - */ - private int port; - - /** - * gray status. - */ - private Boolean gray; - - /** - * group. - */ - private String group; - - /** - * version. - */ - private String version; - - /** - * weight. - */ - private int weight; - - /** - * warmup. - */ - private int warmup; - - /** - * builder constructor. - * - * @param builder builder - */ - private DubboUpstream(final Builder builder) { - boolean statusValue = builder.statusValue; - if (!builder.statusSet) { - statusValue = defaultStatus(); - } - setUpstreamHost(builder.upstreamHost); - setProtocol(builder.protocol); - setUpstreamUrl(builder.upstreamUrl); - this.weight = builder.weight; - setStatus(statusValue); - setTimestamp(builder.timestamp); - this.warmup = builder.warmup; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get registry. - * - * @return registry - */ - public String getRegistry() { - return registry; - } - - /** - * set registry. - * - * @param registry registry - */ - public void setRegistry(final String registry) { - this.registry = registry; - } - - /** - * get appName. - * - * @return appName - */ - public String getAppName() { - return appName; - } - - /** - * set appName. - * - * @param appName appName - */ - public void setAppName(final String appName) { - this.appName = appName; - } - - /** - * get port. - * - * @return port - */ - public int getPort() { - return port; - } - - /** - * set port. - * - * @param port port - */ - public void setPort(final int port) { - this.port = port; - } - - /** - * Gets the value of gray. - * - * @return the value of gray - */ - public Boolean isGray() { - return gray; - } - - /** - * Sets the gray. - * - * @param gray gray - */ - public void setGray(final Boolean gray) { - this.gray = gray; - } - - /** - * Gets the value of weight. - * - * @return the value of weight - */ - public int getWeight() { - return weight; - } - - /** - * Sets the weight. - * - * @param weight weight - */ - public void setWeight(final int weight) { - this.weight = weight; - } - - /** - * Gets the value of warmup. - * - * @return the value of warmup - */ - public int getWarmup() { - return warmup; - } - - /** - * Sets the warmup. - * - * @param warmup warmup - */ - public void setWarmup(final int warmup) { - this.warmup = warmup; - } - - /** - * Gets the value of group. - * - * @return the value of group - */ - public String getGroup() { - return group; - } - - /** - * Sets the group. - * - * @param group group - */ - public void setGroup(final String group) { - this.group = group; - } - - /** - * Gets the value of version. - * - * @return the value of version - */ - public String getVersion() { - return version; - } - - /** - * Sets the version. - * - * @param version version - */ - public void setVersion(final String version) { - this.version = version; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DubboUpstream)) { - return false; - } - DubboUpstream that = (DubboUpstream) o; - return port == that.port - && Objects.equals(registry, that.registry) - && Objects.equals(appName, that.appName) - && Objects.equals(this.getProtocol(), that.getProtocol()) - && Objects.equals(this.getUpstreamUrl(), that.getUpstreamUrl()) - && Objects.equals(gray, that.gray) - && Objects.equals(group, that.group) - && Objects.equals(version, that.version); - } - - @Override - public int hashCode() { - return Objects.hash(registry, appName, port, gray, group, version); - } - - @Override - public String toString() { - return "DubboUpstream{" - + "registry='" + registry - + "', appName='" + appName - + "', protocol='" + this.getProtocol() - + "', port=" + port - + ", upstreamUrl='" + this.getUpstreamUrl() - + "', gray=" + gray - + ", weight=" + weight - + ", warmup=" + warmup - + ", status=" + isStatus() - + ", timestamp=" + getTimestamp() - + ", group='" + group - + ", version='" + version - + "'}"; - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * upstreamHost. - */ - private String upstreamHost; - - /** - * protocol. - */ - private String protocol; - - /** - * upstreamUrl. - */ - private String upstreamUrl; - - /** - * weight. - */ - private int weight; - - /** - * status. - */ - private boolean statusSet; - - /** - * status. - */ - private boolean statusValue; - - /** - * timestamp. - */ - private long timestamp; - - /** - * warmup. - */ - private int warmup; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return DivideUpstream - */ - public DubboUpstream build() { - return new DubboUpstream(this); - } - - /** - * build upstreamHost. - * - * @param upstreamHost upstreamHost - * @return this - */ - public DubboUpstream.Builder upstreamHost(final String upstreamHost) { - this.upstreamHost = upstreamHost; - return this; - } - - /** - * build protocol. - * - * @param protocol protocol - * @return this - */ - public DubboUpstream.Builder protocol(final String protocol) { - this.protocol = protocol; - return this; - } - - /** - * build upstreamUrl. - * - * @param upstreamUrl upstreamUrl - * @return this - */ - public DubboUpstream.Builder upstreamUrl(final String upstreamUrl) { - this.upstreamUrl = upstreamUrl; - return this; - } - - /** - * build weight. - * - * @param weight weight - * @return this - */ - public DubboUpstream.Builder weight(final int weight) { - this.weight = weight; - return this; - } - - /** - * build status. - * - * @param status status - * @return this - */ - public DubboUpstream.Builder status(final boolean status) { - this.statusValue = status; - this.statusSet = true; - return this; - } - - /** - * build timestamp. - * - * @param timestamp timestamp - * @return this - */ - public DubboUpstream.Builder timestamp(final long timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * build warmup. - * - * @param warmup warmup - * @return this - */ - public DubboUpstream.Builder warmup(final int warmup) { - this.warmup = warmup; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/GrpcUpstream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/GrpcUpstream.java deleted file mode 100644 index d41665b..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/GrpcUpstream.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import java.util.Objects; - -/** - * this is grpc upstream. - */ -public final class GrpcUpstream extends CommonUpstream { - - /** - * weight. - */ - private int weight; - - /** - * builder constructor. - * - * @param builder builder - */ - private GrpcUpstream(final Builder builder) { - boolean statusValue = builder.statusValue; - if (!builder.statusSet) { - statusValue = defaultStatus(); - } - setUpstreamHost(builder.upstreamHost); - setProtocol(builder.protocol); - setUpstreamUrl(builder.upstreamUrl); - this.weight = builder.weight; - setStatus(statusValue); - setTimestamp(builder.timestamp); - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get weight. - * - * @return weight - */ - public int getWeight() { - return weight; - } - - /** - * set weight. - * - * @param weight weight - */ - public void setWeight(final int weight) { - this.weight = weight; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - GrpcUpstream that = (GrpcUpstream) o; - return Objects.equals(getUpstreamHost(), that.getUpstreamHost()) && Objects.equals(getProtocol(), that.getProtocol()) && Objects.equals(getUpstreamUrl(), that.getUpstreamUrl()); - } - - @Override - public int hashCode() { - return Objects.hash(getUpstreamHost(), getProtocol(), getUpstreamUrl()); - } - - @Override - public String toString() { - return "GrpcUpstream{" - + "upstreamHost='" - + getUpstreamHost() - + '\'' - + ", protocol='" - + getProtocol() - + '\'' - + ", upstreamUrl='" - + getUpstreamUrl() - + '\'' - + ", weight=" - + weight - + ", status=" - + isStatus() - + ", timestamp=" - + getTimestamp() - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * upstreamHost. - */ - private String upstreamHost; - - /** - * protocol. - */ - private String protocol; - - /** - * upstreamUrl. - */ - private String upstreamUrl; - - /** - * weight. - */ - private int weight; - - /** - * status. - */ - private boolean statusSet; - - /** - * status. - */ - private boolean statusValue; - - /** - * timestamp. - */ - private long timestamp; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return DivideUpstream - */ - public GrpcUpstream build() { - return new GrpcUpstream(this); - } - - /** - * build upstreamHost. - * - * @param upstreamHost upstreamHost - * @return this - */ - public Builder upstreamHost(final String upstreamHost) { - this.upstreamHost = upstreamHost; - return this; - } - - /** - * build protocol. - * - * @param protocol protocol - * @return this - */ - public Builder protocol(final String protocol) { - this.protocol = protocol; - return this; - } - - /** - * build upstreamUrl. - * - * @param upstreamUrl upstreamUrl - * @return this - */ - public Builder upstreamUrl(final String upstreamUrl) { - this.upstreamUrl = upstreamUrl; - return this; - } - - /** - * build weight. - * - * @param weight weight - * @return this - */ - public Builder weight(final int weight) { - this.weight = weight; - return this; - } - - /** - * build status. - * - * @param status status - * @return this - */ - public Builder status(final boolean status) { - this.statusValue = status; - this.statusSet = true; - return this; - } - - /** - * build timestamp. - * - * @param timestamp timestamp - * @return this - */ - public Builder timestamp(final long timestamp) { - this.timestamp = timestamp; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandle.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandle.java deleted file mode 100644 index a4ec396..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandle.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import java.util.List; -import java.util.Objects; - -/** - * The type Spring cloud selector handle. - */ -public class SpringCloudSelectorHandle { - - /** - * this is register eureka serviceId. - */ - private String serviceId; - - /** - * this is gray. - */ - private boolean gray; - - /** - * The divideUpstreams. - */ - private List divideUpstreams; - - /** - * no args constructor. - */ - public SpringCloudSelectorHandle() { - } - - /** - * builder constructor. - * - * @param builder builder - */ - private SpringCloudSelectorHandle(final Builder builder) { - this.gray = builder.gray; - this.serviceId = builder.serviceId; - this.divideUpstreams = builder.divideUpstreams; - } - - /** - * class builder. - * - * @return class Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get serviceId. - * - * @return serviceId - */ - public String getServiceId() { - return serviceId; - } - - /** - * set serviceId. - * - * @param serviceId serviceId - */ - public void setServiceId(final String serviceId) { - this.serviceId = serviceId; - } - - /** - * get gray. - * - * @return the boolean - */ - public boolean getGray() { - return gray; - } - - /** - * set gray. - * - * @param gray gray - */ - public void setGray(final Boolean gray) { - this.gray = gray; - } - - /** - * get divideUpstreams. - * - * @return the divideUpstreams - */ - public List getDivideUpstreams() { - return divideUpstreams; - } - - /** - * set divideUpstreams. - * - * @param divideUpstreams divideUpstreams - */ - public void setDivideUpstreams(final List divideUpstreams) { - this.divideUpstreams = divideUpstreams; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - SpringCloudSelectorHandle that = (SpringCloudSelectorHandle) o; - return Objects.equals(serviceId, that.serviceId); - } - - @Override - public int hashCode() { - return Objects.hash(serviceId); - } - - @Override - public String toString() { - return "SpringCloudSelectorHandle{" - + "serviceId='" - + serviceId - + '\'' - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - /** - * serviceId. - */ - private String serviceId; - - /** - * this is gray. - */ - private boolean gray; - - /** - * The divideUpstreams. - */ - private List divideUpstreams; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return SpringCloudSelectorHandle - */ - public SpringCloudSelectorHandle build() { - return new SpringCloudSelectorHandle(this); - } - - /** - * build serviceId. - * - * @param serviceId serviceId - * @return this - */ - public Builder serviceId(final String serviceId) { - this.serviceId = serviceId; - return this; - } - - /** - * build gray. - * - * @param gray gray - * @return this - */ - public Builder gray(final boolean gray) { - this.gray = gray; - return this; - } - - /** - * build serviceId. - * - * @param divideUpstreams divideUpstreams - * @return this - */ - public Builder divideUpstreams(final List divideUpstreams) { - this.divideUpstreams = divideUpstreams; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/TarsUpstream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/TarsUpstream.java deleted file mode 100644 index 174f49c..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/TarsUpstream.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import java.util.Objects; - -/** - * this is tars upstream. - */ -public final class TarsUpstream extends CommonUpstream { - - /** - * weight. - */ - private int weight; - - /** - * warmup. - */ - private int warmup; - - /** - * builder constructor. - * - * @param builder builder - */ - private TarsUpstream(final Builder builder) { - boolean statusValue = builder.statusValue; - if (!builder.statusSet) { - statusValue = defaultStatus(); - } - setUpstreamHost(builder.upstreamHost); - setProtocol(builder.protocol); - setUpstreamUrl(builder.upstreamUrl); - this.weight = builder.weight; - setStatus(statusValue); - setTimestamp(builder.timestamp); - this.warmup = builder.warmup; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get weight. - * - * @return weight - */ - public int getWeight() { - return weight; - } - - /** - * set weight. - * - * @param weight weight - */ - public void setWeight(final int weight) { - this.weight = weight; - } - - /** - * get warmup. - * - * @return warmup - */ - public int getWarmup() { - return warmup; - } - - /** - * set warmup. - * - * @param warmup warmup - */ - public void setWarmup(final int warmup) { - this.warmup = warmup; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - TarsUpstream that = (TarsUpstream) o; - return Objects.equals(getUpstreamHost(), that.getUpstreamHost()) && Objects.equals(getProtocol(), that.getProtocol()) && Objects.equals(getUpstreamUrl(), that.getUpstreamUrl()); - } - - @Override - public int hashCode() { - return Objects.hash(getUpstreamHost(), getProtocol(), getUpstreamUrl()); - } - - @Override - public String toString() { - return "DivideUpstream{" - + "upstreamHost='" - + getUpstreamHost() - + '\'' - + ", protocol='" - + getProtocol() - + '\'' - + ", upstreamUrl='" - + getUpstreamUrl() - + '\'' - + ", weight=" - + weight - + ", status=" - + isStatus() - + ", timestamp=" - + getTimestamp() - + ", warmup=" - + warmup - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * upstreamHost. - */ - private String upstreamHost; - - /** - * protocol. - */ - private String protocol; - - /** - * upstreamUrl. - */ - private String upstreamUrl; - - /** - * weight. - */ - private int weight; - - /** - * status. - */ - private boolean statusSet; - - /** - * status. - */ - private boolean statusValue; - - /** - * timestamp. - */ - private long timestamp; - - /** - * warmup. - */ - private int warmup; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return DivideUpstream - */ - public TarsUpstream build() { - return new TarsUpstream(this); - } - - /** - * build upstreamHost. - * - * @param upstreamHost upstreamHost - * @return this - */ - public Builder upstreamHost(final String upstreamHost) { - this.upstreamHost = upstreamHost; - return this; - } - - /** - * build protocol. - * - * @param protocol protocol - * @return this - */ - public Builder protocol(final String protocol) { - this.protocol = protocol; - return this; - } - - /** - * build upstreamUrl. - * - * @param upstreamUrl upstreamUrl - * @return this - */ - public Builder upstreamUrl(final String upstreamUrl) { - this.upstreamUrl = upstreamUrl; - return this; - } - - /** - * build weight. - * - * @param weight weight - * @return this - */ - public Builder weight(final int weight) { - this.weight = weight; - return this; - } - - /** - * build status. - * - * @param status status - * @return this - */ - public Builder status(final boolean status) { - this.statusValue = status; - this.statusSet = true; - return this; - } - - /** - * build timestamp. - * - * @param timestamp timestamp - * @return this - */ - public Builder timestamp(final long timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * build warmup. - * - * @param warmup warmup - * @return this - */ - public Builder warmup(final int warmup) { - this.warmup = warmup; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/WebSocketUpstream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/WebSocketUpstream.java deleted file mode 100644 index dc229c4..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/WebSocketUpstream.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import java.util.Objects; - -/** - * this is WebSocket upstream. - */ -public final class WebSocketUpstream extends CommonUpstream { - - /** - * host. - */ - private String host; - - /** - * url. - */ - private String url; - - /** - * weight. - */ - private int weight; - - /** - * warmup. - */ - private int warmup; - - /** - * builder constructor. - * - * @param builder builder - */ - private WebSocketUpstream(final Builder builder) { - this.host = builder.host; - setUpstreamHost(builder.host); - setProtocol(builder.protocol); - this.url = builder.url; - setUpstreamUrl(builder.url); - this.weight = builder.weight; - setStatus(builder.status); - setTimestamp(builder.timestamp); - this.warmup = builder.warmup; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get host. - * - * @return host - */ - public String getHost() { - return host; - } - - /** - * set host. - * - * @param host upstreamHost - */ - public void setHost(final String host) { - this.host = host; - } - - /** - * get url. - * - * @return url - */ - public String getUrl() { - return url; - } - - /** - * set url. - * - * @param url url - */ - public void setUrl(final String url) { - this.url = url; - } - - /** - * get weight. - * - * @return weight - */ - public int getWeight() { - return weight; - } - - /** - * set weight. - * - * @param weight weight - */ - public void setWeight(final int weight) { - this.weight = weight; - } - - /** - * get warmup. - * - * @return warmup - */ - public int getWarmup() { - return warmup; - } - - /** - * set warmup. - * - * @param warmup warmup - */ - public void setWarmup(final int warmup) { - this.warmup = warmup; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - WebSocketUpstream that = (WebSocketUpstream) o; - return Objects.equals(host, that.host) && Objects.equals(getProtocol(), that.getProtocol()) && Objects.equals(url, that.url); - } - - @Override - public int hashCode() { - return Objects.hash(host, getProtocol(), url); - } - - @Override - public String toString() { - return "DivideUpstream{" - + "host='" - + host - + '\'' - + ", protocol='" - + getProtocol() - + '\'' - + ", url='" - + url - + '\'' - + ", weight=" - + weight - + ", status=" - + isStatus() - + ", timestamp=" - + getTimestamp() - + ", warmup=" - + warmup - + '}'; - } - - - /** - * class builder. - */ - public static final class Builder { - - /** - * host. - */ - private String host; - - /** - * protocol. - */ - private String protocol; - - /** - * url. - */ - private String url; - - /** - * weight. - */ - private int weight; - - /** - * status. - */ - private boolean status; - - - /** - * timestamp. - */ - private long timestamp; - - /** - * warmup. - */ - private int warmup; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return DivideUpstream - */ - public WebSocketUpstream build() { - return new WebSocketUpstream(this); - } - - /** - * build host. - * - * @param host host - * @return this - */ - public Builder host(final String host) { - this.host = host; - return this; - } - - /** - * build protocol. - * - * @param protocol protocol - * @return this - */ - public Builder protocol(final String protocol) { - this.protocol = protocol; - return this; - } - - /** - * build url. - * - * @param url url - * @return this - */ - public Builder upstreamUrl(final String url) { - this.url = url; - return this; - } - - /** - * build weight. - * - * @param weight weight - * @return this - */ - public Builder weight(final int weight) { - this.weight = weight; - return this; - } - - /** - * build status. - * - * @param status status - * @return this - */ - public Builder status(final boolean status) { - this.status = status; - return this; - } - - /** - * build timestamp. - * - * @param timestamp timestamp - * @return this - */ - public Builder timestamp(final long timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * build warmup. - * - * @param warmup warmup - * @return this - */ - public Builder warmup(final int warmup) { - this.warmup = warmup; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/ZombieUpstream.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/ZombieUpstream.java deleted file mode 100644 index 5521f21..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/ZombieUpstream.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -import java.util.Objects; - -/** - * this is zombie divide upstream. - */ -public class ZombieUpstream { - - /** - * common upstream. - */ - private CommonUpstream commonUpstream; - - /** - * total check times. - */ - private int zombieCheckTimes; - - /** - * origin selector name. - */ - private String selectorId; - - /** - * no args constructor. - */ - public ZombieUpstream() { - } - - /** - * builder constructor. - * - * @param builder builder - */ - private ZombieUpstream(final Builder builder) { - this.commonUpstream = builder.commonUpstream; - this.zombieCheckTimes = builder.zombieCheckTimes; - this.selectorId = builder.selectorId; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get commonUpstream. - * - * @return commonUpstream - */ - public CommonUpstream getCommonUpstream() { - return commonUpstream; - } - - /** - * set commonUpstream. - * - * @param commonUpstream commonUpstream - */ - public void setCommonUpstream(final CommonUpstream commonUpstream) { - this.commonUpstream = commonUpstream; - } - - /** - * get zombieCheckTimes. - * - * @return zombieCheckTimes - */ - public int getZombieCheckTimes() { - return zombieCheckTimes; - } - - /** - * set zombieCheckTimes. - * - * @param zombieCheckTimes zombieCheckTimes - */ - public void setZombieCheckTimes(final int zombieCheckTimes) { - this.zombieCheckTimes = zombieCheckTimes; - } - - /** - * get selectorId. - * - * @return selectorId - */ - public String getSelectorId() { - return selectorId; - } - - /** - * set selectorId. - * - * @param selectorId selectorId - */ - public void setSelectorName(final String selectorId) { - this.selectorId = selectorId; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - ZombieUpstream that = (ZombieUpstream) o; - return new EqualsBuilder() - .append(commonUpstream, that.commonUpstream) - .append(selectorId, that.selectorId) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(commonUpstream) - .append(selectorId) - .toHashCode(); - } - - @Override - public String toString() { - return "ZombieUpstream{" - + "commonUpstream=" - + commonUpstream - + ", zombieCheckTimes=" - + zombieCheckTimes - + ", selectorId='" - + selectorId - + '\'' - + '}'; - } - - /** - * create zombie upstream with Common upstream. - * - * @param commonUpstream {@linkplain CommonUpstream} origin divide upstream. - * @param zombieCheckTimes total check times. - * @param selectorId origin selector id. - * @return new zombie upstream. - */ - public static ZombieUpstream transform(final CommonUpstream commonUpstream, final int zombieCheckTimes, final String selectorId) { - return ZombieUpstream.builder().commonUpstream(commonUpstream).zombieCheckTimes(zombieCheckTimes).selectorId(selectorId).build(); - } - - /** - * class builder. - */ - public static final class Builder { - - /** - * commonUpstream. - */ - private CommonUpstream commonUpstream; - - /** - * zombieCheckTimes. - */ - private int zombieCheckTimes; - - /** - * selectorId. - */ - private String selectorId; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return ZombieUpstream - */ - public ZombieUpstream build() { - return new ZombieUpstream(this); - } - - /** - * build commonUpstream. - * - * @param commonUpstream commonUpstream - * @return this - */ - public Builder commonUpstream(final CommonUpstream commonUpstream) { - this.commonUpstream = commonUpstream; - return this; - } - - /** - * build zombieCheckTimes. - * - * @param zombieCheckTimes zombieCheckTimes - * @return this - */ - public Builder zombieCheckTimes(final int zombieCheckTimes) { - this.zombieCheckTimes = zombieCheckTimes; - return this; - } - - /** - * build selectorId. - * - * @param selectorId selectorId - * @return this - */ - public Builder selectorId(final String selectorId) { - this.selectorId = selectorId; - return this; - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminDataPermissionTypeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminDataPermissionTypeEnum.java deleted file mode 100644 index 9485ad8..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminDataPermissionTypeEnum.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * The admin data permission type enum. - * - */ -public enum AdminDataPermissionTypeEnum { - - /** - * selector type. - */ - SELECTOR, - - - /** - * rule type. - */ - RULE -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminDataSourceEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminDataSourceEnum.java deleted file mode 100644 index d144b69..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminDataSourceEnum.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * The admin data source enum. - */ -public enum AdminDataSourceEnum { - - /** - * h2. - */ - H2("h2"), - - /** - * mysql. - */ - MYSQL("mysql"), - - /** - * postgresql. - */ - POSTGRESQL("postgresql"), - - /** - * oracle. - */ - ORACLE("oracle"); - - - private final String value; - - /** - * all args constructor. - * - * @param value value - */ - AdminDataSourceEnum(final String value) { - this.value = value; - } - - /** - * get the value. - * - * @return value - */ - public String getValue() { - return value; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminPluginOperateEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminPluginOperateEnum.java deleted file mode 100644 index 0488621..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminPluginOperateEnum.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * the menu for plugin operate button. - */ - -public enum AdminPluginOperateEnum { - - /** - * add operate. - */ - ADD("add"), - - /** - * delete operate. - */ - DELETE("delete"), - - /** - * edit operate. - */ - EDIT("edit"), - - /** - * query operate. - */ - QUERY("query"), - - /** - * modify operate. - */ - SYNCHRONIZE("modify"); - - private final String name; - - /** - * all args constructor. - * - * @param name name - */ - AdminPluginOperateEnum(final String name) { - this.name = name; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminResourceEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminResourceEnum.java deleted file mode 100644 index 95818db..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/AdminResourceEnum.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * the admin resource type. - */ -public enum AdminResourceEnum { - - /** - * Main Menu. - */ - MAIN_MENU(0), - - /** - * Second Menu. - */ - SECOND_MENU(1), - - /** - * Button. - */ - THREE_MENU(2); - - private final int code; - - /** - * all args constructor. - * - * @param code code - */ - AdminResourceEnum(final int code) { - this.code = code; - } - - /** - * get code. - * - * @return code - */ - public int getCode() { - return code; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ConfigGroupEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ConfigGroupEnum.java deleted file mode 100644 index 1096425..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ConfigGroupEnum.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.apache.shenyu.common.exception.ShenyuException; - -import java.util.Arrays; -import java.util.Objects; - -/** - * configuration group. - */ -public enum ConfigGroupEnum { - - /** - * App auth config group enum. - */ - APP_AUTH, - - /** - * Plugin config group enum. - */ - PLUGIN, - - /** - * Rule config group enum. - */ - RULE, - - /** - * Selector config group enum. - */ - SELECTOR, - - /** - * Meta data config group enum. - */ - META_DATA, - - /** - * ProxySelector data group enum. - */ - PROXY_SELECTOR, - - /** - * discoveryUpstream data group enum. - */ - DISCOVER_UPSTREAM; - - /** - * Acquire by name config group enum. - * - * @param name the name - * @return the config group enum - */ - public static ConfigGroupEnum acquireByName(final String name) { - return Arrays.stream(ConfigGroupEnum.values()) - .filter(e -> Objects.equals(e.name(), name)) - .findFirst().orElseThrow(() -> new ShenyuException(String.format(" this ConfigGroupEnum can not support %s", name))); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/DataEventTypeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/DataEventTypeEnum.java deleted file mode 100644 index 39905c4..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/DataEventTypeEnum.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.apache.shenyu.common.exception.ShenyuException; - -import java.util.Arrays; -import java.util.Objects; - -/** - * The enum Data event type. - */ -public enum DataEventTypeEnum { - - /** - * delete event. - */ - DELETE, - - /** - * insert event. - */ - CREATE, - - /** - * update event. - */ - UPDATE, - - /** - * REFRESH data event type enum. - */ - REFRESH, - - /** - * RUNNING_MODE data event type enum. - */ - RUNNING_MODE, - - /** - * Myself data event type enum. - */ - MYSELF; - - /** - * Acquire by name data event type enum. - * - * @param name the name - * @return the data event type enum - */ - public static DataEventTypeEnum acquireByName(final String name) { - return Arrays.stream(DataEventTypeEnum.values()) - .filter(e -> Objects.equals(e.name(), name)) - .findFirst() - .orElseThrow(() -> new ShenyuException(String.format(" this DataEventTypeEnum can not support %s", name))); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/DataSyncEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/DataSyncEnum.java deleted file mode 100644 index ae585af..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/DataSyncEnum.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; - -/** - * The enum Data sync enum. - */ -public enum DataSyncEnum { - - /** - * Http data sync enum. - */ - HTTP("http"), - - /** - * Zookeeper data sync enum. - */ - ZOOKEEPER("zookeeper"), - - /** - * Websocket data sync enum. - */ - WEBSOCKET("websocket"); - - private final String name; - - /** - * all args constructor. - * - * @param name name - */ - DataSyncEnum(final String name) { - this.name = name; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Acquire by name data sync enum. - * - * @param name the name - * @return the data sync enum - */ - public static DataSyncEnum acquireByName(final String name) { - return Arrays.stream(DataSyncEnum.values()) - .filter(e -> e.getName().equals(name)).findFirst() - .orElse(DataSyncEnum.HTTP); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HttpMethodEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HttpMethodEnum.java deleted file mode 100644 index e620b3b..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HttpMethodEnum.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.apache.shenyu.common.exception.ShenyuException; - -import java.util.Arrays; - -/** - * this is http method support. - */ -public enum HttpMethodEnum { - - /** - * Get http method enum. - */ - GET("get", true), - - /** - * Post http method enum. - */ - POST("post", true), - - /** - * Put http method enum. - */ - PUT("put", true), - - /** - * Delete http method enum. - */ - DELETE("delete", true); - - private final String name; - - private final Boolean support; - - /** - * all args constructor. - * - * @param name name - * @param support support - */ - HttpMethodEnum(final String name, final Boolean support) { - this.name = name; - this.support = support; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * get support. - * - * @return support - */ - public Boolean getSupport() { - return support; - } - - /** - * convert by name. - * - * @param name name - * @return {@link HttpMethodEnum } - */ - public static HttpMethodEnum acquireByName(final String name) { - return Arrays.stream(HttpMethodEnum.values()) - .filter(e -> e.support && e.name.equals(name)).findFirst() - .orElseThrow(() -> new ShenyuException(String.format(" this http method can not support %s", name))); - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HttpSchemeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HttpSchemeEnum.java deleted file mode 100644 index 596cbb8..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HttpSchemeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * The http scheme enum. - */ -public enum HttpSchemeEnum { - - /** - * The http schema enum. - */ - HTTP("http"), - - /** - * The https schema enum. - */ - HTTPS("https"); - - private final String scheme; - - HttpSchemeEnum(final String scheme) { - this.scheme = scheme; - } - - /** - * get schema. - * @return String - */ - public String getScheme() { - return scheme; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnum.java deleted file mode 100644 index f8079e8..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnum.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * hystrix execution isolation strategy. - */ -public enum HystrixIsolationModeEnum { - /** - * thread pool mode. - */ - @SuppressWarnings("checkstyle:WhitespaceAfter") THREAD_POOL(0, "thread"), - /** - * semaphore mode. - */ - @SuppressWarnings("checkstyle:WhitespaceAfter") SEMAPHORE(1, "semaphore"); - - private final int code; - - private final String name; - - /** - * all args constructor. - * - * @param code code - * @param name name - */ - HystrixIsolationModeEnum(final int code, final String name) { - this.code = code; - this.name = name; - } - - /** - * get code. - * - * @return code - */ - public int getCode() { - return code; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/LoadBalanceEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/LoadBalanceEnum.java deleted file mode 100644 index fc8ef8f..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/LoadBalanceEnum.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * load balance enum. - */ -public enum LoadBalanceEnum { - - /** - * Hash load balance enum. - */ - HASH(1, "hash", true), - - /** - * Random load balance enum. - */ - RANDOM(2, "random", true), - - /** - * Round robin load balance enum. - */ - ROUND_ROBIN(3, "roundRobin", true), - - /** - * least activity load balance enum. - */ - LEAST_ACTIVITY(4, "leastActive", true), - - /** - * pick of 2 choices load balance enum. - */ - P2C(5, "p2c", true), - - /** - * shortest response load balance enum. - */ - SHORTEST_RESPONSE(6, "shortestResponse", true); - - private final int code; - - private final String name; - - private final boolean support; - - /** - * all args constructor. - * - * @param code code - * @param name name - * @param support support - */ - LoadBalanceEnum(final int code, final String name, final boolean support) { - this.code = code; - this.name = name; - this.support = support; - } - - /** - * get code. - * - * @return code - */ - public int getCode() { - return code; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * get support. - * - * @return support - */ - public boolean isSupport() { - return support; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/MatchModeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/MatchModeEnum.java deleted file mode 100644 index 7856456..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/MatchModeEnum.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * MatchModeEnum. - */ -public enum MatchModeEnum { - - /** - * And match mode enum. - */ - AND(0, "and"), - - /** - * Or match mode enum. - */ - OR(1, "or"); - - private final int code; - - private final String name; - - /** - * all args constructor. - * - * @param code code - * @param name name - */ - MatchModeEnum(final int code, final String name) { - this.code = code; - this.name = name; - } - - /** - * get code. - * - * @return code - */ - public int getCode() { - return code; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Judgment code and enum eq. - * - * @param code code. - * @param matchModeEnum enum - * @return true or false. - */ - public static boolean match(final Integer code, final MatchModeEnum matchModeEnum) { - return Objects.equals(matchModeEnum.getCode(), code); - } - - /** - * get match mode name by code. - * - * @param code match mode code. - * @return match mode name. - */ - public static String getMatchModeByCode(final int code) { - return Arrays.stream(MatchModeEnum.values()) - .filter(e -> e.code == code).findFirst() - .orElse(MatchModeEnum.AND) - .getName(); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/OperatorEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/OperatorEnum.java deleted file mode 100644 index fd0300f..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/OperatorEnum.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * OperatorEnum. - */ -public enum OperatorEnum { - - /** - * Match operator enum. - */ - MATCH("match", true), - - /** - * Eq operator enum. - */ - EQ("=", true), - - /** - * Regex operator enum. - */ - REGEX("regex", true), - - /** - * Gt operator enum. - */ - GT(">", false), - - /** - * Lt operator enum. - */ - LT("<", false), - - /** - * Contains operator enum. - */ - CONTAINS("contains", true), - - /** - * Starts with operator enum. - */ - STARTS_WITH("startsWith", true), - - /** - * Ends with operator enum. - */ - ENDS_WITH("endsWith", true), - - /** - * Time before operator enum. - */ - TIME_BEFORE("TimeBefore", true), - - /** - * Exclude operator enum. - */ - EXCLUDE("exclude", true), - - /** - * Time after operator enum. - */ - TIME_AFTER("TimeAfter", true), - - /** - * Path patter operator enum. - */ - PATH_PATTERN("pathPattern", true), - - /** - * Is blank operator enum. - */ - IS_BLANK("isBlank", true); - - private final String alias; - - private final Boolean support; - - /** - * all args constructor. - * - * @param alias alias - * @param support support - */ - OperatorEnum(final String alias, final Boolean support) { - this.alias = alias; - this.support = support; - } - - /** - * get alias. - * - * @return alias alias - */ - public String getAlias() { - return alias; - } - - /** - * get support. - * - * @return support support - */ - public Boolean getSupport() { - return support; - } - - /** - * acquire operator supports. - * - * @return operator support. - */ - public static List acquireSupport() { - return Arrays.stream(OperatorEnum.values()).filter(e -> e.support).collect(Collectors.toList()); - } - - /** - * get operator enum by alias. - * - * @param alias operator alias. - * @return operator enum. - */ - public static OperatorEnum getOperatorEnumByAlias(final String alias) { - return Arrays.stream(OperatorEnum.values()) - .filter(e -> e.getAlias().equals(alias) && e.support).findFirst() - .orElse(null); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ParamTypeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ParamTypeEnum.java deleted file mode 100644 index 9c2854a..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ParamTypeEnum.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Param Type. - */ -public enum ParamTypeEnum { - - /** - * Path variable param type enum. - */ - PATH("path", true), - - /** - * Form data param type enum. - */ - FORM_DATA("form-data", true), - - /** - * Post param type enum. - */ - POST("post", true), - - /** - * Uri param type enum. - */ - URI("uri", true), - - /** - * Query param type enum. - */ - QUERY("query", true), - - /** - * Host param type enum. - */ - HOST("host", true), - - /** - * Ip param type enum. - */ - IP("ip", true), - - /** - * Header param type enum. - */ - HEADER("header", true), - - /** - * Cookie param type enum. - */ - COOKIE("cookie", true), - - /** - * requestMethod param type enum. - * note:The front-end page needs to be adjusted because the field length is long - */ - REQUEST_METHOD("req_method", true), - - /** - * domain param type enum. - */ - DOMAIN("domain", true); - - private final String name; - - private final Boolean support; - - /** - * all args constructor. - * - * @param name name - * @param support support - */ - ParamTypeEnum(final String name, final Boolean support) { - this.name = name; - this.support = support; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * get support. - * - * @return support - */ - public Boolean getSupport() { - return support; - } - - /** - * acquire param type supports. - * - * @return param type support. - */ - public static List acquireSupport() { - return Arrays.stream(ParamTypeEnum.values()) - .filter(e -> e.support).collect(Collectors.toList()); - } - - /** - * get param type enum by name. - * - * @param name param type name. - * @return param type enum. - */ - public static ParamTypeEnum getParamTypeEnumByName(final String name) { - return Arrays.stream(ParamTypeEnum.values()) - .filter(e -> e.getName().equals(name) && e.support).findFirst() - .orElse(null); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginHandlerEventEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginHandlerEventEnum.java deleted file mode 100644 index 36b59d6..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginHandlerEventEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * plugin handler event. - */ -public enum PluginHandlerEventEnum { - - /** - * plugin enabled. - */ - ENABLED, - - /** - * plugin disabled. - */ - DISABLED, - - /** - * plugin deleted. - */ - DELETE, - - /** - * plugin sorted. - */ - SORTED -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginRoleEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginRoleEnum.java deleted file mode 100644 index 30f6c5c..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginRoleEnum.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * Plugin Role. - */ -public enum PluginRoleEnum { - - /** - * Sys plugin role enum. - */ - SYS(0, "sys"), - - /** - * Custom plugin role enum. - */ - CUSTOM(1, "custom"); - - private final Integer code; - - private final String name; - - /** - * all args constructor. - * - * @param code code - * @param name name - */ - PluginRoleEnum(final Integer code, final String name) { - this.code = code; - this.name = name; - } - - /** - * get code. - * - * @return code - */ - public Integer getCode() { - return code; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginTypeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginTypeEnum.java deleted file mode 100644 index 7d03d79..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/PluginTypeEnum.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * Plugin Type. - */ -public enum PluginTypeEnum { - - /** - * before plugin type enum. - */ - BEFORE("before"), - - /** - * function plugin type enum. - */ - FUNCTION("function"), - - /** - * last plugin type enum. - */ - LAST("last"); - - private final String name; - - /** - * all args constructor. - * - * @param name name - */ - PluginTypeEnum(final String name) { - this.name = name; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RateLimitEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RateLimitEnum.java deleted file mode 100644 index 6d6e989..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RateLimitEnum.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * rate limit. - */ -public enum RateLimitEnum { - - SLIDING_WINDOW("sliding_window_request_rate_limiter", "sliding_window_request_rate_limiter.lua"), - - LEAKY_BUCKET("request_leaky_rate_limiter", "request_leaky_rate_limiter.lua"), - - CONCURRENT("concurrent_request_rate_limiter", "concurrent_request_rate_limiter.lua"), - - TOKEN_BUCKET("request_rate_limiter", "request_rate_limiter.lua"); - - private final String keyName; - - private final String scriptName; - - RateLimitEnum(final String keyName, final String scriptName) { - this.keyName = keyName; - this.scriptName = scriptName; - } - - /** - * getKeyName. - * - * @return keyName - */ - public String getKeyName() { - return this.keyName; - } - - /** - * getScriptName. - * - * @return scriptName - */ - public String getScriptName() { - return this.scriptName; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RedisModeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RedisModeEnum.java deleted file mode 100644 index 9b90b7f..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RedisModeEnum.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; - -/** - * The enum Redis mode enum. - */ -public enum RedisModeEnum { - - /** - * Cluster redis mode enum. - */ - CLUSTER("cluster"), - - /** - * Sentinel redis mode enum. - */ - SENTINEL("sentinel"), - - /** - * Standalone redis mode enum. - */ - STANDALONE("standalone"); - - /** - * Redis Mode Name. - */ - private final String name; - - /** - * all args constructor. - * - * @param name name - */ - RedisModeEnum(final String name) { - this.name = name; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Acquire by name data sync enum. - * - * @param name redisModeName - * @return RedisModeEnum - */ - public static RedisModeEnum acquireByName(final String name) { - return Arrays.stream(RedisModeEnum.values()) - .filter(e -> e.getName().equals(name)).findFirst() - .orElse(RedisModeEnum.STANDALONE); - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ResultEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ResultEnum.java deleted file mode 100644 index 651f564..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/ResultEnum.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * ResultEnum. - */ -public enum ResultEnum { - - /** - * Success result enum. - */ - SUCCESS("success"), - - /** - * Time out result enum. - */ - TIME_OUT("timeOut"), - - /** - * Error result enum. - */ - ERROR("error"); - - private final String name; - - /** - * all args constructor. - * - * @param name name - */ - ResultEnum(final String name) { - this.name = name; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RetryEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RetryEnum.java deleted file mode 100644 index 3c1e41d..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RetryEnum.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * retry enum. - */ -public enum RetryEnum { - - /** - * Retry the previously failed call. - */ - CURRENT(1, "current", true), - - /** - * Retry other servers when failed. - */ - FAILOVER(2, "failover", true); - - private final int code; - - private final String name; - - private final boolean support; - - /** - * all args constructor. - * - * @param code code - * @param name name - * @param support support - */ - RetryEnum(final int code, final String name, final boolean support) { - this.code = code; - this.name = name; - this.support = support; - } - - /** - * get code. - * - * @return code - */ - public int getCode() { - return code; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * get support. - * - * @return support - */ - public boolean isSupport() { - return support; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RunningModeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RunningModeEnum.java deleted file mode 100644 index a388cca..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/RunningModeEnum.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * the running mode. - */ -public enum RunningModeEnum { - - /** - * standalone. - */ - STANDALONE, - - /** - * cluster. - */ - CLUSTER; - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/SelectorTypeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/SelectorTypeEnum.java deleted file mode 100644 index 09aca23..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/SelectorTypeEnum.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; - -/** - * SelectorTypeEnum. - */ -public enum SelectorTypeEnum { - - /** - * full selector type enum. - */ - FULL_FLOW(0, "full"), - - /** - * Or match mode enum. - */ - CUSTOM_FLOW(1, "custom"); - - private final int code; - - private final String name; - - /** - * all args constructor. - * - * @param code code - * @param name name - */ - SelectorTypeEnum(final int code, final String name) { - this.code = code; - this.name = name; - } - - /** - * get code. - * - * @return code - */ - public int getCode() { - return code; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * get selector type name by code. - * - * @param code selector type code. - * @return selector type name. - */ - public static String getSelectorTypeByCode(final int code) { - return Arrays.stream(SelectorTypeEnum.values()) - .filter(v -> v.getCode() == code) - .findFirst() - .map(SelectorTypeEnum::getName).orElse(null); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/SerializeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/SerializeEnum.java deleted file mode 100644 index 22bcc9c..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/SerializeEnum.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; -import java.util.Objects; - -/** - * SerializeEnum. - */ -public enum SerializeEnum { - - /** - * Jdk serialize protocol enum. - */ - JDK("jdk"), - - /** - * Kryo serialize protocol enum. - */ - KRYO("kryo"), - - /** - * Hessian serialize protocol enum. - */ - HESSIAN("hessian"), - - /** - * Protostuff serialize protocol enum. - */ - PROTOSTUFF("protostuff"); - - private final String serialize; - - SerializeEnum(final String serialize) { - this.serialize = serialize; - } - - /** - * get serialize. - * - * @return serialize serialize - */ - public String getSerialize() { - return serialize; - } - - /** - * Acquire serialize protocol serialize protocol enum. - * - * @param serialize the serialize protocol - * @return the serialize protocol enum - */ - public static SerializeEnum acquire(final String serialize) { - return Arrays.stream(SerializeEnum.values()) - .filter(v -> Objects.equals(v.getSerialize(), serialize)) - .findFirst().orElse(SerializeEnum.JDK); - - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieCacheTypeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieCacheTypeEnum.java deleted file mode 100644 index cf6ac76..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieCacheTypeEnum.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * Shenyu trie cache type enum. - */ -public enum TrieCacheTypeEnum { - - /** - * selector. - */ - SELECTOR("shenyuSelectorTrie"), - - /** - * rule. - */ - RULE("shenyuRuleTrie"); - - /** - * trie type, include selector and rule. - */ - private final String trieType; - - /** - * trie cache type enum. - * - * @param trieType trie type - */ - TrieCacheTypeEnum(final String trieType) { - this.trieType = trieType; - } - - /** - * get trie type. - * - * @return trie type - */ - public String getTrieType() { - return trieType; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieEventEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieEventEnum.java deleted file mode 100644 index 090e156..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieEventEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * Rule trie event enum. - */ -public enum TrieEventEnum { - - /** - * Shenyu Trie insert event. - */ - INSERT, - - /** - * Shenyu Trie update event. - */ - UPDATE, - - /** - * Shenyu Trie remove event. - */ - REMOVE -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieMatchModeEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieMatchModeEnum.java deleted file mode 100644 index a339cd1..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/TrieMatchModeEnum.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; - -/** - * Shenyu match mode event. - */ -public enum TrieMatchModeEnum { - /** - * ant path match. - */ - ANT_PATH_MATCH("antPathMatch"), - - /** - * path pattern. - */ - PATH_PATTERN("pathPattern"); - - private final String matchMode; - - TrieMatchModeEnum(final String matchMode) { - this.matchMode = matchMode; - } - - /** - * get trie match mode. - * - * @return match mode - */ - public String getMatchMode() { - return matchMode; - } - - /** - * get {@linkplain TrieMatchModeEnum} by match mode. - * - * @param matchMode match mode - * @return {@linkplain TrieMatchModeEnum} - */ - public static TrieMatchModeEnum acquireTrieMatch(final String matchMode) { - return Arrays.stream(TrieMatchModeEnum.values()) - .filter(e -> e.getMatchMode().equals(matchMode)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("Shenyu trie match mode is error, match mode:" + matchMode)); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/WafEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/WafEnum.java deleted file mode 100644 index cc41f33..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/WafEnum.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * WafEnum. - */ -public enum WafEnum { - - /** - * Reject waf enum. - */ - REJECT(0, "reject"), - - /** - * Allow waf enum. - */ - ALLOW(1, "allow"); - - private final int code; - - private final String name; - - /** - * all args constructor. - * - * @param code code - * @param name name - */ - WafEnum(final int code, final String name) { - this.code = code; - this.name = name; - } - - /** - * get code. - * - * @return code - */ - public int getCode() { - return code; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/WafModelEnum.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/WafModelEnum.java deleted file mode 100644 index 8a7bf56..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/enums/WafModelEnum.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -/** - * The enum Waf model enum. - */ -public enum WafModelEnum { - - /** - * BLACK waf model enum. - */ - BLACK("black"), - - /** - * Mixed waf model enum. - */ - MIXED("mixed"); - - private final String name; - - /** - * all args constructor. - * - * @param name name - */ - WafModelEnum(final String name) { - this.name = name; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/SerializerException.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/SerializerException.java deleted file mode 100644 index a51caf1..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/SerializerException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.exception; - -/** - * SerializerException. - */ -public class SerializerException extends RuntimeException { - - private static final long serialVersionUID = 8068509879445395353L; - - /** - * Instantiates a new Serializer exception. - * - * @param e the e - */ - public SerializerException(final Throwable e) { - super(e); - } - - /** - * Instantiates a new Serializer exception. - * - * @param message the message - */ - public SerializerException(final String message) { - super(message); - } - - /** - * Instantiates a new Serializer exception. - * - * @param message the message - * @param throwable the throwable - */ - public SerializerException(final String message, final Throwable throwable) { - super(message, throwable); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/ShenyuException.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/ShenyuException.java deleted file mode 100644 index 8fc026b..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/exception/ShenyuException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.exception; - -/** - * Shenyu Exception. - */ -public class ShenyuException extends RuntimeException { - - private static final long serialVersionUID = 8068509879445395353L; - - /** - * Instantiates a new Shenyu exception. - * - * @param e the e - */ - public ShenyuException(final Throwable e) { - super(e); - } - - /** - * Instantiates a new Shenyu exception. - * - * @param message the message - */ - public ShenyuException(final String message) { - super(message); - } - - /** - * Instantiates a new Shenyu exception. - * - * @param message the message - * @param throwable the throwable - */ - public ShenyuException(final String message, final Throwable throwable) { - super(message, throwable); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ContextPathUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ContextPathUtils.java deleted file mode 100644 index 0ac9787..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ContextPathUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.commons.lang3.StringUtils; - -/** - * The type Context path utils. - */ -public class ContextPathUtils { - - /** - * Build context path string. - * - * @param contextPath the context path - * @param appName the app name - * @return the string - */ - public static String buildContextPath(final String contextPath, final String appName) { - return UriUtils.repairData(StringUtils.isEmpty(contextPath) ? appName : contextPath); - } - - /** - * Build real node string. - * - * @param contextPath the context path - * @param appName the app name - * @return the string - */ - public static String buildRealNode(final String contextPath, final String appName) { - return UriUtils.removePrefix(StringUtils.isEmpty(contextPath) ? appName : contextPath); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java deleted file mode 100644 index c6eae61..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; - -/** - * DateUtils. - */ -public final class DateUtils { - - public static final String DATE_FORMAT_DATETIME = "yyyy-MM-dd HH:mm:ss"; - - public static final String DATE_FORMAT_DATETIME_MILLISECOND = "yyyy-MM-dd HH:mm:ss.SSS"; - - private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT_DATETIME); - - private DateUtils() { - } - - /** - * parse LocalDateTime. - * out put format: yyyy-MM-dd HH:mm:ss - * - * @param dataTime date String - * @return LocalDateTime: yyyy-MM-dd HH:mm:ss - * @see LocalDateTime - */ - public static LocalDateTime parseLocalDateTime(final String dataTime) { - return LocalDateTime.parse(dataTime, DateTimeFormatter.ofPattern(DATE_FORMAT_DATETIME)); - } - - /** - * Parse local date time local date time. - * - * @param dataTime the data time - * @param dateTimeFormatter the date time formatter - * @return the local date time - */ - public static LocalDateTime parseLocalDateTime(final String dataTime, final String dateTimeFormatter) { - return LocalDateTime.parse(dataTime, DateTimeFormatter.ofPattern(dateTimeFormatter)); - } - - /** - * acquireMinutesBetween. - * - * @param start this is start date. - * @param end this is start date. - * @return The number of days between start and end, if end is after start, - * returns a positive number, otherwise returns a negative number. - */ - public static long acquireMinutesBetween(final LocalDateTime start, final LocalDateTime end) { - return start.until(end, ChronoUnit.MINUTES); - } - - /** - * Acquire millis between long. - * - * @param start the start - * @param end the end - * @return the long - */ - public static long acquireMillisBetween(final LocalDateTime start, final LocalDateTime end) { - return start.until(end, ChronoUnit.MILLIS); - } - - /** - * Format local date time from timestamp local date time. - * - * @param timestamp the timestamp - * @return the local date time - */ - public static LocalDateTime formatLocalDateTimeFromTimestamp(final Long timestamp) { - return LocalDateTime.ofEpochSecond(timestamp / 1000, 0, ZoneOffset.ofHours(8)); - } - - /** - * Format local date time from timestamp by system time zone. - * - * @param timestamp the timestamp - * @return the local date time - */ - public static LocalDateTime formatLocalDateTimeFromTimestampBySystemTimezone(final Long timestamp) { - return LocalDateTime.ofEpochSecond(timestamp / 1000, 0, OffsetDateTime.now().getOffset()); - } - - /** - * Format local date time to string. - * use default pattern yyyy-MM-dd HH:mm:ss - * - * @param localDateTime the localDateTime - * @return the format string - */ - public static String localDateTimeToString(final LocalDateTime localDateTime) { - return DATE_TIME_FORMATTER.format(localDateTime); - } - - /** - * Format local date time to string. - * - * @param localDateTime the localDateTime - * @param pattern formatter pattern - * @return the format string - */ - public static String localDateTimeToString(final LocalDateTime localDateTime, final String pattern) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern); - return localDateTime.format(formatter); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/DigestUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/DigestUtils.java deleted file mode 100644 index 8fad0c8..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/DigestUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.common.exception.ShenyuException; - -import java.util.Optional; - -/** - * DigestUtils. - */ -public class DigestUtils { - - /** - * Calculates the SHA-512 digest and returns the value as a hex string. - * if data is null or "" ,it will return null. - * @param data – Data to digest - * @return SHA-512 digest as a hex string. - */ - public static String sha512Hex(final String data) { - return Optional.ofNullable(data).filter(StringUtils::isNoneEmpty).map(item -> { - try { - return org.apache.commons.codec.digest.DigestUtils.sha512Hex(data); - } catch (Exception e) { - throw new ShenyuException(e); - } - }).orElse(null); - } - - /** - * Calculates the MD5 digest and returns the value as a 32 character hex string. - * @param data Data to digest - * @return MD5 digest as a hex string - */ - public static String md5Hex(final String data) { - return org.apache.commons.codec.digest.DigestUtils.md5Hex(data); - } - - /** - * Calculates the MD5 digest and returns the value as a 32 character hex string. - * @param data Data to digest - * @return MD5 digest as a hex string - */ - public static String md5Hex(final byte[] data) { - return org.apache.commons.codec.digest.DigestUtils.md5Hex(data); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/FreshBeanHolder.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/FreshBeanHolder.java deleted file mode 100644 index 5898010..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/FreshBeanHolder.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import java.util.Objects; -import java.util.function.Function; - -public class FreshBeanHolder implements Function { - - private final Function function; - - private volatile O o; - - public FreshBeanHolder(final Function function) { - this.function = function; - } - - /** - * Apply. - * - * @param e e - * @return O o - */ - @Override - public O apply(final E e) { - if (Objects.nonNull(o)) { - return o; - } - return init(e); - } - - /** - * Init. - * - * @return bean - */ - synchronized O init(final E e) { - if (Objects.nonNull(o)) { - return o; - } - O res = function.apply(e); - o = res; - return res; - } - - /** - * Fresh. - * - * @param e e - */ - public void doFresh(final E e) { - O fresh = function.apply(e); - if (Objects.nonNull(fresh)) { - synchronized (this) { - this.o = fresh; - } - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/HmacHexUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/HmacHexUtils.java deleted file mode 100644 index fc40ea9..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/HmacHexUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.commons.codec.digest.HmacAlgorithms; -import org.apache.commons.codec.digest.HmacUtils; - -/** - * HmacUtils. - */ -public class HmacHexUtils { - - /** - * Returns a HmacMd5 Message Authentication Code (MAC) as hex string (lowercase). - * - * @param key The key - * @param valueToDigest The value to use to digest - * @return Message Authentication Code - */ - public static String hmacMd5Hex(final String key, final String valueToDigest) { - return getHmacHex(HmacAlgorithms.HMAC_MD5, key, valueToDigest); - } - - /** - * Returns a HmacSha256 Message Authentication Code (MAC) as hex string (lowercase). - * - * @param key The key - * @param valueToDigest The value to use to digest - * @return Message Authentication Code - */ - public static String hmacSha256Hex(final String key, final String valueToDigest) { - return getHmacHex(HmacAlgorithms.HMAC_SHA_256, key, valueToDigest); - - } - - /** - * Returns a HmacSha512 Message Authentication Code (MAC) as hex string (lowercase). - * - * @param key The key - * @param valueToDigest The value to use to digest - * @return Message Authentication Code - */ - public static String hmacSha512Hex(final String key, final String valueToDigest) { - return getHmacHex(HmacAlgorithms.HMAC_SHA_512, key, valueToDigest); - } - - private static String getHmacHex(final HmacAlgorithms algorithm, final String key, final String valueToDigest) { - return new HmacUtils(algorithm, key).hmacHex(valueToDigest); - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/JarDependencyUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/JarDependencyUtils.java deleted file mode 100644 index 999feee..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/JarDependencyUtils.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.shenyu.common.constant.AdminConstants; -import org.apache.shenyu.common.exception.ShenyuException; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.MethodNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -/** - * Jar package dependency tools. - */ -public class JarDependencyUtils { - - /** - * logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(JarDependencyUtils.class); - - /** - * Obtain the dependency tree of the jar package file at compile time. - * - * @param jarBytes Byte array of jar file - * @return dependency tree - */ - public static Set getDependencyTree(final byte[] jarBytes) { - Set dependencies = new HashSet<>(); - try (InputStream inputStream = new ByteArrayInputStream(jarBytes); - ZipInputStream zipInputStream = new ZipInputStream(inputStream)) { - ZipEntry entry; - while (Objects.nonNull(entry = zipInputStream.getNextEntry())) { - if (entry.getName().endsWith(".class")) { - ClassNode classNode = new ClassNode(Opcodes.ASM7); - ClassReader classReader = new ClassReader(zipInputStream); - classReader.accept(classNode, 0); - addDependencies(classNode.superName, dependencies); - for (String interfaceName : classNode.interfaces) { - addDependencies(interfaceName, dependencies); - } - for (FieldNode fieldNode : classNode.fields) { - addDependencies(Type.getType(fieldNode.desc).getClassName(), dependencies); - } - for (MethodNode methodNode : classNode.methods) { - addDependencies(Type.getReturnType(methodNode.desc).getClassName(), dependencies); - for (Type argumentType : Type.getArgumentTypes(methodNode.desc)) { - addDependencies(argumentType.getClassName(), dependencies); - } - } - } - } - return dependencies; - - } catch (Exception e) { - LOG.error("get dependency tree error", e); - throw new ShenyuException(AdminConstants.THE_PLUGIN_JAR_FILE_IS_NOT_CORRECT_OR_EXCEEDS_16_MB); - } - } - - /** - * Add dependencies. - * @param typeName type name - * @param dependencies dependencies - */ - private static void addDependencies(final String typeName, final Set dependencies) { - if (!typeName.startsWith("java") && !typeName.startsWith("javax")) { - dependencies.add(typeName.replace("/", ".")); - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/JsonUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/JsonUtils.java deleted file mode 100644 index a35cc5b..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/JsonUtils.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.json.JsonReadFeature; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.type.MapType; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; -import org.apache.shenyu.common.constant.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * JsonUtils. - */ -public final class JsonUtils { - - /** - * logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(JsonUtils.class); - - private static final ObjectMapper MAPPER = new ObjectMapper(); - - static { - JavaTimeModule javaTimeModule = new JavaTimeModule(); - javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); - javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); - javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); - javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); - MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS) - .configure(JsonParser.Feature.ALLOW_COMMENTS, true) - .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true) - .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true) - .configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true) - .setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) - .registerModule(javaTimeModule) - .addMixIn(Map.class, IgnoreType.class); - } - - /** - * To json string. - * - * @param object the object - * @return the string - */ - public static String toJson(final Object object) { - try { - return MAPPER.writeValueAsString(object); - } catch (IOException e) { - LOG.warn("write to json string error: " + object, e); - return Constants.EMPTY_JSON; - } - } - - /** - * Object to Map. - * - * @param object the object - * @return the converted map - */ - public static Map toMap(final Object object) { - try { - String json = MAPPER.writeValueAsString(object); - final MapType mapType = MAPPER.getTypeFactory().constructMapType(LinkedHashMap.class, String.class, Object.class); - return MAPPER.readValue(json, mapType); - } catch (IOException e) { - LOG.warn("write to map error: " + object, e); - return new LinkedHashMap<>(); - } - } - - /** - * String to Map. - * - * @param json the object - * @param valueTypeRef class - * @param generic - * @return the converted map - */ - public static Map jsonToMap(final String json, final Class valueTypeRef) { - try { - JavaType t = MAPPER.getTypeFactory().constructParametricType(HashMap.class, String.class, valueTypeRef); - return MAPPER.readValue(json, t); - } catch (IOException e) { - LOG.warn("write to map error: " + json, e); - return new LinkedHashMap<>(); - } - } - - /** - * String to Map. - * - * @param json the object - * @return the converted map - */ - public static Map jsonToMap(final String json) { - try { - final MapType mapType = MAPPER.getTypeFactory().constructMapType(LinkedHashMap.class, String.class, Object.class); - return MAPPER.readValue(json, mapType); - } catch (IOException e) { - LOG.warn("write to map error: " + json, e); - return new LinkedHashMap<>(); - } - } - - /** - * String to Object. - * - * @param json the object - * @param valueTypeRef class - * @param generic - * @return the converted map - */ - public static T jsonToObject(final String json, final Class valueTypeRef) { - try { - return MAPPER.readValue(json, valueTypeRef); - } catch (IOException e) { - LOG.warn("write to Object error: " + json, e); - return null; - } - } - - /** - * Remove class object. - * - * @param object the object - * @return the object - */ - public static Object removeClass(final Object object) { - if (object instanceof Map) { - Map map = (Map) object; - Object result = map.get("result"); - if (result instanceof Map) { - Map resultMap = (Map) result; - resultMap.remove("class"); - } - map.remove("class"); - } - return object; - } - - @JsonIgnoreProperties("class") - @interface IgnoreType { - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/LogUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/LogUtils.java deleted file mode 100644 index 1733a57..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/LogUtils.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.slf4j.Logger; -import java.util.Objects; -import java.util.function.Supplier; - -/** - * LogUtils. - */ -public final class LogUtils { - - /** - * debug log. - * @param logger logger - * @param format format - * @param supplier {@linkplain Supplier} - */ - public static void debug(final Logger logger, final String format, final Supplier supplier) { - if (logger.isDebugEnabled()) { - logger.debug(format, supplier.get()); - } - } - - /** - * debug log. - * @param logger logger - * @param format format - * @param objects objects - */ - public static void debug(final Logger logger, final String format, final Object... objects) { - if (logger.isDebugEnabled()) { - logger.debug(format, objects); - } - } - - /** - * debug log. - * @param logger logger - * @param supplier {@linkplain Supplier} - */ - public static void debug(final Logger logger, final Supplier supplier) { - if (logger.isDebugEnabled()) { - logger.debug(Objects.toString(supplier.get())); - } - } - - /** - * info log. - * - * @param logger logger - * @param format format - * @param supplier {@linkplain Supplier} - */ - public static void info(final Logger logger, final String format, final Supplier supplier) { - if (logger.isInfoEnabled()) { - logger.info(format, supplier.get()); - } - } - - /** - * info log. - * - * @param logger logger - * @param format format - * @param objects objects - */ - public static void info(final Logger logger, final String format, final Object... objects) { - if (logger.isInfoEnabled()) { - logger.info(format, objects); - } - } - - /** - * info log. - * - * @param logger logger - * @param supplier {@linkplain Supplier} - */ - public static void info(final Logger logger, final Supplier supplier) { - if (logger.isInfoEnabled()) { - logger.info(Objects.toString(supplier.get())); - } - } - - /** - * error log. - * - * @param logger logger - * @param format format - * @param supplier {@linkplain Supplier} - */ - public static void error(final Logger logger, final String format, final Supplier supplier) { - if (logger.isErrorEnabled()) { - logger.error(format, supplier.get()); - } - } - - /** - * error log. - * - * @param logger logger - * @param format format - * @param objects objects - */ - public static void error(final Logger logger, final String format, final Object... objects) { - if (logger.isErrorEnabled()) { - logger.error(format, objects); - } - } - - /** - * error log. - * - * @param logger logger - * @param supplier {@linkplain Supplier} - */ - public static void error(final Logger logger, final Supplier supplier) { - if (logger.isErrorEnabled()) { - logger.error(Objects.toString(supplier.get())); - } - } - - /** - * warn log. - * - * @param logger logger - * @param format format - * @param supplier {@linkplain Supplier} - */ - public static void warn(final Logger logger, final String format, final Supplier supplier) { - if (logger.isWarnEnabled()) { - logger.warn(format, supplier.get()); - } - } - - /** - * warn log. - * - * @param logger logger - * @param format format - * @param objects objects - */ - public static void warn(final Logger logger, final String format, final Object... objects) { - if (logger.isWarnEnabled()) { - logger.warn(format, objects); - } - } - - /** - * warn log. - * - * @param logger logger - * @param supplier {@linkplain Supplier} - */ - public static void warn(final Logger logger, final Supplier supplier) { - if (logger.isWarnEnabled()) { - logger.warn(Objects.toString(supplier.get())); - } - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/MapUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/MapUtils.java deleted file mode 100644 index d5338dd..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/MapUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -public class MapUtils { - - /** - * Transform to string map. - * - * @param map source map - * @return string map - */ - public static Map transStringMap(final Map map) { - return Optional.ofNullable(map) - .map(m -> m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> Objects.toString(e.getValue(), null)))) - .orElse(null); - } - - /** - * This is jdk8 performance bug, see: https://bugs.openjdk.java.net/browse/JDK-8161372. - * - * @param map source map - * @param key key - * @param mappingFunction mappingFunction - * @param k - * @param v - * @return v - */ - public static V computeIfAbsent(final Map map, final K key, final Function mappingFunction) { - V v = map.get(key); - if (Objects.nonNull(v)) { - return v; - } - return map.computeIfAbsent(key, mappingFunction); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ObjectTypeUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ObjectTypeUtils.java deleted file mode 100644 index 730c7d2..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ObjectTypeUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -/** - * ObjectTypeUtils. - */ -public final class ObjectTypeUtils { - - /** - * is basic type or not. - * @param object the object - * @return true is basic - */ - public static boolean isBasicType(final Object object) { - return object instanceof Integer - || object instanceof Byte - || object instanceof Long - || object instanceof Double - || object instanceof Float - || object instanceof Short - || object instanceof Boolean - || object instanceof CharSequence; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ParamCheckUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ParamCheckUtils.java deleted file mode 100644 index 513df4f..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ParamCheckUtils.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.shenyu.common.exception.ShenyuException; - -import java.util.Objects; - -/** - * The type Param check utils. - */ -public class ParamCheckUtils { - - /** - * Body is empty boolean. - * - * @param body the body - * @return the boolean - */ - public static boolean bodyIsEmpty(final String body) { - return Objects.isNull(body) || body.isEmpty() || "null".equals(body); - } - - /** - * Check params length. - * @param argsLength params length. - * @param typesLength types length. - */ - public static void checkParamsLength(final Integer argsLength, final Integer typesLength) { - if (argsLength < typesLength) { - throw new ShenyuException("args.length < types.length"); - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/PluginNameAdapter.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/PluginNameAdapter.java deleted file mode 100644 index 146768b..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/PluginNameAdapter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.shenyu.common.enums.PluginEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; - -/** - * The type Plugin name adapter. - */ -public class PluginNameAdapter { - - /** - * Rpc type adapter string. - * - * @param rpcType the rpc type - * @return the string - */ - public static String rpcTypeAdapter(final String rpcType) { - RpcTypeEnum rpcTypeEnum = RpcTypeEnum.acquireByName(rpcType); - switch (rpcTypeEnum) { - case GRPC: - return PluginEnum.GRPC.getName(); - case SPRING_CLOUD: - return PluginEnum.SPRING_CLOUD.getName(); - case DUBBO: - return PluginEnum.DUBBO.getName(); - case TARS: - return PluginEnum.TARS.getName(); - case SOFA: - return PluginEnum.SOFA.getName(); - case WEB_SOCKET: - return PluginEnum.WEB_SOCKET.getName(); - case MOTAN: - return PluginEnum.MOTAN.getName(); - case HTTP: - default: - return PluginEnum.DIVIDE.getName(); - } - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/SignUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/SignUtils.java deleted file mode 100644 index b0d9175..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/SignUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import com.google.common.collect.ImmutableMap; - -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; - -/** - * SignUtils. - */ -public final class SignUtils { - - public static final String SIGN_MD5 = "MD5"; - - public static final String SIGN_HMD5 = "HMD5"; - - public static final String SIGN_HS256 = "HS256"; - - public static final String SIGN_HS512 = "HS512"; - - private static final Map SIGN_FUNCTION_MAP = ImmutableMap.of( - SIGN_MD5, (key, data) -> DigestUtils.md5Hex(data + key), - SIGN_HMD5, HmacHexUtils::hmacMd5Hex, - SIGN_HS256, HmacHexUtils::hmacSha256Hex, - SIGN_HS512, HmacHexUtils::hmacSha512Hex - ); - - /** - * Returns signature of data as hex string (lowercase). - * - * @param algorithmName the name of sign algorithm - * @param key key - * @param data data to sign - * @return signature - * @throws NullPointerException if key or data is null - * @throws UnsupportedOperationException if algorithmName isn't supported - */ - public static String sign(final String algorithmName, final String key, final String data) { - if (Objects.isNull(key) || Objects.isNull(data)) { - throw new NullPointerException("Key or data is null."); - } - - return Optional.ofNullable(SIGN_FUNCTION_MAP.get(algorithmName)) - .orElseThrow(() -> new UnsupportedOperationException("unsupported sign algorithm:" + algorithmName)) - .sign(key, data); - } - - /** - * Generate key string. - * - * @return the string - */ - public static String generateKey() { - return UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); - } - - @FunctionalInterface - private interface SignFunction { - String sign(String key, String data); - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/Singleton.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/Singleton.java deleted file mode 100644 index 51c1144..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/Singleton.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Singleton. - */ -public enum Singleton { - - /** - * Inst singleton. - */ - INST; - - /** - * The Singles. - */ - private static final Map SINGLES = new ConcurrentHashMap<>(); - - /** - * Single. - * - * @param clazz the clazz - * @param o the o - */ - public void single(final Class clazz, final Object o) { - SINGLES.put(clazz.getName(), o); - } - - /** - * Get t. - * - * @param the type parameter - * @param clazz the clazz - * @return the t - */ - @SuppressWarnings("unchecked") - public T get(final Class clazz) { - return (T) SINGLES.get(clazz.getName()); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/SpiLoadFactory.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/SpiLoadFactory.java deleted file mode 100644 index 91d18fc..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/SpiLoadFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import java.util.Iterator; -import java.util.ServiceLoader; - -/** - * SpiLoadFactory. - */ -public class SpiLoadFactory { - - /** - * Load first s. - * - * @param the type parameter - * @param clazz the clazz - * @return the s - */ - public static S loadFirst(final Class clazz) { - final ServiceLoader loader = loadAll(clazz); - final Iterator iterator = loader.iterator(); - if (!iterator.hasNext()) { - throw new IllegalStateException(String.format( - "No implementation defined in /META-INF/services/%s, please check whether the file exists and has the right implementation class!", - clazz.getName())); - } - return iterator.next(); - } - - /** - * Load all service loader. - * - * @param the type parameter - * @param clazz the clazz - * @return the service loader - */ - public static ServiceLoader loadAll(final Class clazz) { - return ServiceLoader.load(clazz); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ThreadUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ThreadUtils.java deleted file mode 100644 index 5bdefef..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/ThreadUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import java.util.concurrent.TimeUnit; - -/** - * thread utils. - */ -public class ThreadUtils { - - /** - * sleep current thread. - * - * @param timeUnit the time unit - * @param time the time - */ - public static void sleep(final TimeUnit timeUnit, final int time) { - try { - timeUnit.sleep(time); - } catch (InterruptedException ex) { - Thread.currentThread().interrupt(); - } - } - -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UUIDUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UUIDUtils.java deleted file mode 100644 index 7c890a5..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UUIDUtils.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import java.util.Random; - -/** - * UUIDUtils. - */ -public final class UUIDUtils { - - private static final Random RANDOM = new Random(); - - private static final long WORKER_ID_BITS = 5L; - - private static final long DATACENTERIDBITS = 5L; - - private static final long MAX_WORKER_ID = ~(-1L << WORKER_ID_BITS); - - private static final long MAX_DATACENTER_ID = ~(-1L << DATACENTERIDBITS); - - private static final long SEQUENCE_BITS = 12L; - - private static final long WORKER_ID_SHIFT = SEQUENCE_BITS; - - private static final long DATACENTER_ID_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS; - - private static final long TIMESTAMP_LEFT_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS + DATACENTERIDBITS; - - private static final long SEQUENCE_MASK = ~(-1L << SEQUENCE_BITS); - - private static final UUIDUtils ID_WORKER_UTILS = new UUIDUtils(); - - private final long workerId; - - private final long datacenterId; - - private final long idepoch; - - private long sequence = '0'; - - private long lastTimestamp = -1L; - - private UUIDUtils() { - this(RANDOM.nextInt((int) MAX_WORKER_ID), RANDOM.nextInt((int) MAX_DATACENTER_ID), 1288834974657L); - } - - private UUIDUtils(final long workerId, final long datacenterId, final long idepoch) { - if (workerId > MAX_WORKER_ID || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", MAX_WORKER_ID)); - } - if (datacenterId > MAX_DATACENTER_ID || datacenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", MAX_DATACENTER_ID)); - } - this.workerId = workerId; - this.datacenterId = datacenterId; - this.idepoch = idepoch; - } - - /** - * Gets instance. - * - * @return the instance - */ - public static UUIDUtils getInstance() { - return ID_WORKER_UTILS; - } - - private synchronized long nextId() { - long timestamp = timeGen(); - if (timestamp < lastTimestamp) { - throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - if (lastTimestamp == timestamp) { - sequence = (sequence + 1) & SEQUENCE_MASK; - if (sequence == 0) { - timestamp = tilNextMillis(lastTimestamp); - } - } else { - sequence = 0L; - } - - lastTimestamp = timestamp; - - return ((timestamp - idepoch) << TIMESTAMP_LEFT_SHIFT) - | (datacenterId << DATACENTER_ID_SHIFT) - | (workerId << WORKER_ID_SHIFT) | sequence; - } - - private long tilNextMillis(final long lastTimestamp) { - long timestamp = timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = timeGen(); - } - return timestamp; - } - - private long timeGen() { - return System.currentTimeMillis(); - } - - /** - * generate short uuid. - * - * @return short uuid. - */ - public String generateShortUuid() { - return String.valueOf(ID_WORKER_UTILS.nextId()); - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UpstreamCheckUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UpstreamCheckUtils.java deleted file mode 100644 index bb16da8..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/UpstreamCheckUtils.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.common.constant.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.net.InetSocketAddress; -import java.net.Socket; - -/** - * The type Uri utils. - */ -public class UpstreamCheckUtils { - - private static final String HTTP = "http://"; - - private static final String HTTPS = "https://"; - - private static final int DEFAULT_TIMEOUT = 3000; - - /** - * logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(UpstreamCheckUtils.class); - - /** - * Check url boolean. - * - * @param url the url - * @return the boolean - */ - public static boolean checkUrl(final String url) { - return checkUrl(url, DEFAULT_TIMEOUT); - } - - /** - * Check url boolean. - * - * @param url the url - * @param timeout timeout - * @return the boolean - */ - public static boolean checkUrl(final String url, final int timeout) { - if (StringUtils.isBlank(url)) { - return false; - } - String[] hostPort; - if (url.startsWith(HTTP) || url.startsWith(HTTPS)) { - final String[] http = StringUtils.split(url, "\\/\\/"); - hostPort = StringUtils.split(http[1], Constants.COLONS); - } else { - hostPort = StringUtils.split(url, Constants.COLONS); - } - final boolean isHttps = url.startsWith(HTTPS); - final int port = hostPort.length > 1 ? Integer.parseInt(hostPort[1].trim()) : isHttps ? 443 : 80; - return isHostConnector(hostPort[0].trim(), port, timeout); - } - - private static boolean isHostConnector(final String host, final int port, final int timeout) { - try (Socket socket = new Socket()) { - socket.connect(new InetSocketAddress(host, port), timeout); - } catch (Exception e) { - LOG.error("socket connect is error. host:{} port:{} timeout:{}", host, port, timeout, e); - return false; - } - return true; - } -} diff --git a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/VersionUtils.java b/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/VersionUtils.java deleted file mode 100644 index eed49d1..0000000 --- a/shenyu-java-common/src/main/java/org/apache/shenyu/common/utils/VersionUtils.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.net.URL; -import java.security.CodeSource; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -/** - * VersionUtils. - */ -public final class VersionUtils { - - /** - * logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(VersionUtils.class); - - private static final String VERSION = getVersion(VersionUtils.class, "1.0.0"); - - private static final String JAR = ".jar"; - - private VersionUtils() { - } - - /** - * Gets version. - * - * @return the version - */ - public static String getVersion() { - return VERSION; - } - - /** - * Gets version. - * - * @param cls the cls - * @param defaultVersion the default version - * @return the version - */ - public static String getVersion(final Class cls, final String defaultVersion) { - // find version info from MANIFEST.MF first - String version = cls.getPackage().getImplementationVersion(); - if (StringUtils.isBlank(version)) { - version = cls.getPackage().getSpecificationVersion(); - } - if (StringUtils.isNoneBlank(version)) { - return version; - } - // guess version for jar file name if nothing's found from MANIFEST.MF - CodeSource codeSource = cls.getProtectionDomain().getCodeSource(); - - if (Objects.isNull(codeSource)) { - LOG.info("No codeSource for class {} when getVersion, use default version {}", cls.getName(), defaultVersion); - return defaultVersion; - } - String file = codeSource.getLocation().getFile(); - if (Objects.nonNull(file) && file.endsWith(JAR)) { - file = file.substring(0, file.length() - 4); - int i = file.lastIndexOf('/'); - if (i >= 0) { - file = file.substring(i + 1); - } - i = file.indexOf("-"); - if (i >= 0) { - file = file.substring(i + 1); - } - while (StringUtils.isNoneBlank(file) && !Character.isDigit(file.charAt(0))) { - i = file.indexOf("-"); - if (i < 0) { - break; - } - file = file.substring(i + 1); - } - version = file; - } - // return default version if no version info is found - return StringUtils.isBlank(version) ? defaultVersion : version; - } - - /** - * checkDuplicate,this method refers to the design of dubbo . - * @param cls cls - */ - public static void checkDuplicate(final Class cls) { - try { - String path = cls.getName().replace('.', '/') + ".class"; - Set files = readResources(path, cls); - // duplicated jar is found - if (files.size() > 1) { - String error = "Duplicate class " + path + " in " + files.size() + " jar " + files; - LOG.error("checkDuplicate error,{}", error); - } - } catch (Throwable e) { - LOG.error("checkDuplicate error,msg :{}", e.getMessage(), e); - } - } - - /** - * readResources. - * @param path path - * @param cls cls - * @return set - * @throws IOException ioexception - */ - private static Set readResources(final String path, final Class cls) throws IOException { - Enumeration urls = cls.getClassLoader().getResources(path); - Set files = new HashSet<>(); - while (urls.hasMoreElements()) { - URL url = urls.nextElement(); - if (Objects.nonNull(url)) { - String file = url.getFile(); - if (StringUtils.isNotEmpty(file)) { - files.add(file); - } - } - } - return files; - } -} - - diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeLRUMapTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeLRUMapTest.java deleted file mode 100644 index 7b50bc5..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeLRUMapTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.cache; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.Map; - -/** - * Test cases for MemorySafeLRUMapTest. - */ -public class MemorySafeLRUMapTest { - @Test - public void testPut() { - MemorySafeLRUMap lru = new MemorySafeLRUMap<>(1 << 10, 16); - lru.put("1", "1"); - Assert.assertEquals(1, lru.size()); - lru.put("2", "2"); - lru.put("3", "3"); - Assert.assertEquals(3, lru.size()); - } - - @Test - public void testLru() { - try { - MemorySafeLRUMap lru = new MemorySafeLRUMap(1, 1024) { - - private static final long serialVersionUID = 8897028073615563875L; - - @Override - public boolean isFull() { - //just for test - return size() > 0; - } - }; - lru.put(1, 1); - Assert.assertEquals(1, lru.size()); - lru.put(2, 2); - lru.put(3, 3); - Assert.assertEquals(1, lru.size()); - final Map.Entry entry = lru.entrySet().iterator().next(); - final Integer key = entry.getKey(); - final Integer value = entry.getValue(); - Assert.assertEquals(3, (int) key); - Assert.assertEquals(3, (int) value); - } catch (Throwable t) { - // due to rapid changes in JVM memory, the results of this test are not stable, just ignore - } - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMapTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMapTest.java deleted file mode 100644 index ced6bba..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMapTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.cache; - -import org.apache.shenyu.common.utils.ReflectUtils; -import org.junit.Assert; -import org.junit.Test; - -import java.lang.ref.WeakReference; -import java.util.Map; -import java.util.Set; - -/** - * Test cases for MemorySafeWindowTinyLFUMap. - */ -public class MemorySafeWindowTinyLFUMapTest { - - @Test - public void testPut() { - MemorySafeWindowTinyLFUMap lru = new MemorySafeWindowTinyLFUMap<>(1 << 10, 16); - lru.put("1", "1"); - Assert.assertEquals(1, lru.size()); - lru.put("2", "2"); - lru.put("3", "3"); - Assert.assertEquals(3, lru.size()); - } - - @Test - public void testWindowTinyLFU() { - try { - MemorySafeWindowTinyLFUMap cache = new MemorySafeWindowTinyLFUMap(1, 1024) { - - private static final long serialVersionUID = 8897028073615563875L; - - @Override - public synchronized boolean isFull() { - //just for test - return size() > 1; - } - - @Override - public synchronized void cleanUp() { - super.cleanUp(); - } - }; - cache.put(1, 1); - Assert.assertEquals(1, cache.size()); - cache.put(2, 2); - cache.put(3, 3); - cache.invalidate(); - cache.cleanUp(); - Assert.assertEquals(1, cache.size()); - final Map.Entry entry = cache.entrySet().iterator().next(); - final Integer key = entry.getKey(); - final Integer value = entry.getValue(); - Assert.assertEquals(3, (int) key); - Assert.assertEquals(3, (int) value); - } catch (Throwable t) { - // due to rapid changes in JVM memory, the results of this test are not stable, just ignore - } - } - - @Test - public void testWindowTinyLFUOutOufMemoryException() { - final int mb = 1024 * 1024; - for (int i = 0; i < 1000; i++) { - MemorySafeWindowTinyLFUMap instance = new MemorySafeWindowTinyLFUMap<>(1, 1024); - instance.put(String.valueOf(1), new Byte[mb]); - } - Set>> all = - (Set>>) ReflectUtils.getFieldValue(new MemorySafeWindowTinyLFUMap(1, 1024), "ALL"); - Assert.assertNotEquals(1000, all.size()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/WindowTinyLFUMapTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/WindowTinyLFUMapTest.java deleted file mode 100644 index 8996b98..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/cache/WindowTinyLFUMapTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.cache; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.Map; - -/** - * WindowTinyLFUMapTest. - */ -public class WindowTinyLFUMapTest { - - @Test - @SuppressWarnings("all") - public void weakKeyCache() { - Map map = new WindowTinyLFUMap<>(100, 100, Boolean.TRUE); - String key1 = new String("abc"); - String key2 = new String("abc"); - map.put(key1, "1"); - map.put(key2, "1"); - Assert.assertEquals(2, map.size()); - Assert.assertEquals(key1, key2); - Assert.assertNull(map.get("abc")); - } - - @Test - @SuppressWarnings("all") - public void strongKeyCache() { - Map map = new WindowTinyLFUMap<>(100, 100, Boolean.FALSE); - String key1 = new String("abc"); - String key2 = new String("abc"); - map.put(key1, "1"); - map.put(key2, "1"); - Assert.assertEquals(map.get(key1), map.get(key2)); - Assert.assertEquals(1, map.size()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitCalculatorTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitCalculatorTest.java deleted file mode 100644 index 2dbfe50..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitCalculatorTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * Test cases for MemoryLimitCalculator. - */ -public class MemoryLimitCalculatorTest { - - @Test - public void testCalculateWhenIllegalPercentage() { - float largerThanOne = 2; - float zero = 0; - float lessThanZero = -1; - assertThrows(IllegalArgumentException.class, () -> MemoryLimitCalculator.calculate(largerThanOne)); - assertThrows(IllegalArgumentException.class, () -> MemoryLimitCalculator.calculate(zero)); - assertThrows(IllegalArgumentException.class, () -> MemoryLimitCalculator.calculate(lessThanZero)); - } - - @Test - public void testCalculate() { - float percentage = 0.5f; - assertEquals((long) (MemoryLimitCalculator.maxAvailable() * percentage), MemoryLimitCalculator.calculate(percentage)); - } - - @Test - public void testDefaultCalculate() { - assertEquals((long) (MemoryLimitCalculator.maxAvailable() * 0.8), MemoryLimitCalculator.defaultLimit()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitedLinkedBlockingQueueTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitedLinkedBlockingQueueTest.java deleted file mode 100644 index fc604ef..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitedLinkedBlockingQueueTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import net.bytebuddy.agent.ByteBuddyAgent; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.lang.instrument.Instrumentation; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test cases for MemoryLimitedLinkedBlcokingQueue. - */ -public class MemoryLimitedLinkedBlockingQueueTest { - - private static Instrumentation instrumentation; - - @BeforeAll - public static void initialInstrumentation() { - ByteBuddyAgent.install(); - instrumentation = ByteBuddyAgent.getInstrumentation(); - } - - @Test - public void test() throws Exception { - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(1, instrumentation); - //an Runnable needs more than 1 byte of space, so it will fail here - assertThat(queue.offer(() -> { - }), is(false)); - - //will success - queue.setMemoryLimit(Integer.MAX_VALUE); - assertThat(queue.offer(() -> { - }), is(true)); - } - - @Test - public void testGetMemoryLimit() { - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(instrumentation); - assertEquals(queue.getMemoryLimit(), Integer.MAX_VALUE); - } - - @Test - public void testOfferWhenTimeout() throws InterruptedException { - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(1, instrumentation); - assertFalse(queue.offer(() -> { - }, 2, TimeUnit.SECONDS)); - } - - @Test - public void testPoll() { - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(instrumentation); - Integer testObject = 0; - queue.offer(testObject); - assertEquals(testObject, queue.poll()); - assertEquals(0, queue.getCurrentMemory()); - } - - @Test - public void testClear() { - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(instrumentation); - queue.offer(() -> { - }); - queue.clear(); - assertEquals(0, queue.getCurrentMemory()); - } - - @Test - public void testPut() throws InterruptedException, ExecutionException { - Integer testObject = 0; - long testObjectSize = instrumentation.getObjectSize(testObject); - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(2 * testObjectSize + 1, instrumentation); - queue.put(testObject); - queue.put(testObject); - assertEquals(2, queue.size()); - ExecutorService executorService = Executors.newFixedThreadPool(1); - Future putResult = executorService.submit(() -> { - try { - queue.put(testObject); - return Boolean.TRUE; - } catch (InterruptedException e) { - return Boolean.FALSE; - } - }); - Thread.sleep(2000); - queue.poll(); - assertTrue(putResult.get()); - assertEquals(2, queue.size()); - } - - @Test - void testTake() throws InterruptedException, ExecutionException { - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(instrumentation); - ExecutorService executorService = Executors.newFixedThreadPool(1); - Future takeResult = executorService.submit(queue::take); - Thread.sleep(2000); - queue.put(() -> { }); - takeResult.get(); - assertEquals(0, queue.size()); - } - - @Test - void testPollWhenTimeoutWithNull() throws InterruptedException { - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(instrumentation); - Runnable runnable = queue.poll(1, TimeUnit.SECONDS); - assertNull(runnable); - } - - @Test - void testRemoveSuccess() throws InterruptedException { - MemoryLimitedLinkedBlockingQueue queue = new MemoryLimitedLinkedBlockingQueue<>(instrumentation); - Integer testObject = 0; - queue.put(testObject); - assertTrue(queue.remove(testObject)); - assertEquals(0, queue.getCurrentMemory()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitedTaskQueueTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitedTaskQueueTest.java deleted file mode 100644 index f195ee8..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimitedTaskQueueTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import net.bytebuddy.agent.ByteBuddyAgent; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.lang.instrument.Instrumentation; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test cases for MemoryLimitedTaskQueue. - */ -public class MemoryLimitedTaskQueueTest { - - private static Instrumentation instrumentation; - - @BeforeAll - public static void initializeInstrumentation() { - ByteBuddyAgent.install(); - instrumentation = ByteBuddyAgent.getInstrumentation(); - } - - @Test - public void testOffer() { - MemoryLimitedTaskQueue memoryLimitedTaskQueue = new MemoryLimitedTaskQueue<>(instrumentation); - assertTrue(memoryLimitedTaskQueue.doOffer(() -> { })); - } - - @Test - public void testOfferWhenMemoryNotSufficient() { - MemoryLimitedTaskQueue memoryLimitedTaskQueue = new MemoryLimitedTaskQueue<>(1, instrumentation); - assertFalse(memoryLimitedTaskQueue.doOffer(() -> { })); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimiterTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimiterTest.java deleted file mode 100644 index d16a991..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemoryLimiterTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import net.bytebuddy.agent.ByteBuddyAgent; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.lang.instrument.Instrumentation; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - - -/** - * Test cases for MemoryLimiter. - */ -public final class MemoryLimiterTest { - - private static Instrumentation instrumentation; - - private static Object testObject; - - private static long testObjectSize; - - @BeforeAll - public static void initializeInstrumentation() { - ByteBuddyAgent.install(); - instrumentation = ByteBuddyAgent.getInstrumentation(); - testObject = Integer.MAX_VALUE; - testObjectSize = instrumentation.getObjectSize(testObject); - } - - @Test - public void testCreateMemoryLimiterWhenIllegal() { - long lessThanZero = -1; - assertThrows(IllegalArgumentException.class, () -> new MemoryLimiter(lessThanZero, instrumentation)); - } - - @Test - public void testSetMemoryLimiterWhenIllegal() { - long lessThanZero = -1; - MemoryLimiter memoryLimiter = new MemoryLimiter(instrumentation); - assertThrows(IllegalArgumentException.class, () -> memoryLimiter.setMemoryLimit(lessThanZero)); - } - - @Test - public void testAcquireWhenNullObject() { - MemoryLimiter memoryLimiter = new MemoryLimiter(instrumentation); - assertThrows(NullPointerException.class, () -> memoryLimiter.acquire(null)); - assertThrows(NullPointerException.class, () -> memoryLimiter.acquire(null, 10, TimeUnit.SECONDS)); - assertThrows(NullPointerException.class, () -> memoryLimiter.acquireInterruptibly(null)); - } - - @Test - public void testAcquireWhenEqualToLimit() { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize, instrumentation); - assertFalse(memoryLimiter.acquire(testObject)); - } - - @Test - public void testAcquireWhenExceedLimit() { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize + 1, instrumentation); - assertTrue(memoryLimiter.acquire(testObject)); - memoryLimiter.setMemoryLimit(testObjectSize - 1); - assertFalse(memoryLimiter.acquire(testObject)); - memoryLimiter.setMemoryLimit(testObjectSize + 1); - assertFalse(memoryLimiter.acquire(testObject)); - } - - @Test - public void testAcquireConcurrent() throws Exception { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize * 2 + 1, instrumentation); - ExecutorService executorService = Executors.newFixedThreadPool(2); - // two thread acquire concurrently. - for (int i = 0; i < 2; i++) { - Future acquireResult = executorService.submit(() -> memoryLimiter.acquire(testObject)); - assertTrue(acquireResult.get()); - } - assertEquals(testObjectSize * 2, memoryLimiter.getCurrentMemory()); - executorService.shutdown(); - } - - @Test - public void testAcquireWithTimeWaitNotRelease() throws InterruptedException { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize + 1, instrumentation); - memoryLimiter.acquire(testObject); - assertFalse(memoryLimiter.acquire(testObject, 1, TimeUnit.SECONDS)); - } - - @Test - public void testAcquireWithTimeWaitAfterRelease() throws Exception { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize + 1, instrumentation); - memoryLimiter.acquire(testObject); - ExecutorService executorService = Executors.newFixedThreadPool(1); - Future acquireResult = executorService.submit(() -> memoryLimiter.acquire(testObject, 4, TimeUnit.SECONDS)); - Thread.sleep(2000); - memoryLimiter.release(testObject); - assertTrue(acquireResult.get()); - assertEquals(testObjectSize, memoryLimiter.getCurrentMemory()); - executorService.shutdown(); - } - - @Test - public void testAcquireWaitForNotify() throws Exception { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize + 1, instrumentation); - memoryLimiter.acquire(testObject); - ExecutorService executorService = Executors.newFixedThreadPool(1); - Future acquireResult = executorService.submit(() -> { - try { - memoryLimiter.acquireInterruptibly(testObject); - return Boolean.TRUE; - } catch (InterruptedException e) { - return Boolean.FALSE; - } - }); - Thread.sleep(3000); - memoryLimiter.release(testObject); - assertTrue(acquireResult.get()); - assertEquals(testObjectSize, memoryLimiter.getCurrentMemory()); - executorService.shutdown(); - } - - @Test - public void testReleaseWhenNullObject() throws InterruptedException { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize + 1, instrumentation); - memoryLimiter.acquire(testObject); - - memoryLimiter.release(null); - assertEquals(testObjectSize, memoryLimiter.getCurrentMemory()); - - memoryLimiter.releaseInterruptibly(null); - assertEquals(testObjectSize, memoryLimiter.getCurrentMemory()); - - memoryLimiter.releaseInterruptibly(null, 1, TimeUnit.SECONDS); - assertEquals(testObjectSize, memoryLimiter.getCurrentMemory()); - } - - @Test - public void testReleaseInterruptiblyWaitForNotify() throws Exception { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize + 1, instrumentation); - ExecutorService executorService = Executors.newFixedThreadPool(1); - Future acquireResult = executorService.submit(() -> { - try { - memoryLimiter.releaseInterruptibly(testObject); - return Boolean.TRUE; - } catch (InterruptedException e) { - return Boolean.FALSE; - } - }); - Thread.sleep(3000); - memoryLimiter.acquire(testObject); - assertTrue(acquireResult.get()); - assertEquals(0, memoryLimiter.getCurrentMemory()); - executorService.shutdown(); - } - - @Test - public void testReleaseInterruptiblyWithTimeWait() throws Exception { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize + 1, instrumentation); - ExecutorService executorService = Executors.newFixedThreadPool(1); - Future acquireResult = executorService.submit(() -> { - try { - memoryLimiter.releaseInterruptibly(testObject, 4, TimeUnit.SECONDS); - return Boolean.TRUE; - } catch (InterruptedException e) { - return Boolean.FALSE; - } - }); - Thread.sleep(2000); - memoryLimiter.acquire(testObject); - assertTrue(acquireResult.get()); - assertEquals(0, memoryLimiter.getCurrentMemory()); - executorService.shutdown(); - } - - @Test - public void testRemainMemory() { - MemoryLimiter memoryLimiter = new MemoryLimiter(testObjectSize + 1, instrumentation); - memoryLimiter.acquire(testObject); - assertEquals(1, memoryLimiter.getCurrentRemainMemory()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemorySafeLinkedBlockingQueueTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemorySafeLinkedBlockingQueueTest.java deleted file mode 100644 index 8968a97..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/MemorySafeLinkedBlockingQueueTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class MemorySafeLinkedBlockingQueueTest { - @Test - public void test() throws Exception { - MemorySafeLinkedBlockingQueue queue = new MemorySafeLinkedBlockingQueue<>(Integer.MAX_VALUE); - // all memory is reserved for JVM, so it will fail here - assertThat(queue.offer(() -> { - }), is(false)); - - // only 1 Byte memory is reserved for the JVM, so this will succeed - queue.setMaxFreeMemory(1); - assertThat(queue.offer(() -> { - }), is(true)); - } - - @Test - public void testCustomReject() throws Exception { - MemorySafeLinkedBlockingQueue queue = new MemorySafeLinkedBlockingQueue<>(Integer.MAX_VALUE); - queue.setRejector(new AbortPolicy<>()); - assertThrows(RejectException.class, () -> queue.offer(() -> { - })); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactoryTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactoryTest.java deleted file mode 100644 index 6ac2179..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadFactoryTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import org.junit.jupiter.api.Test; - -import java.util.concurrent.ThreadFactory; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.notNullValue; - -/** - * Test cases for ShenyuThreadFactory. - */ -public final class ShenyuThreadFactoryTest { - - private static final String NAME_PREFIX = "shenyu##thread##"; - - @Test - public void testCreate() { - ThreadFactory threadFactory = ShenyuThreadFactory.create(NAME_PREFIX, true); - assertThat(threadFactory, notNullValue()); - } - - @Test - public void testCustomCreate() { - ThreadFactory threadFactory = ShenyuThreadFactory.create(NAME_PREFIX, true, 2); - Thread thread = threadFactory.newThread(() -> Thread.currentThread().getId()); - assertThat(thread, notNullValue()); - } - - @Test - public void testNewThread() { - ThreadFactory threadFactory = ShenyuThreadFactory.create(NAME_PREFIX, true); - threadFactory.newThread(() -> Thread.currentThread().setName("NAME_PREFIX")); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadPoolExecutorTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadPoolExecutorTest.java deleted file mode 100644 index a8b3e71..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/concurrent/ShenyuThreadPoolExecutorTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.concurrent; - -import net.bytebuddy.agent.ByteBuddyAgent; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.lang.instrument.Instrumentation; -import java.util.concurrent.TimeUnit; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * Test cases for ShenyuThreadPoolExecutor. - */ -public class ShenyuThreadPoolExecutorTest { - - private static Instrumentation instrumentation; - - @BeforeAll - public static void initialExecutor() { - ByteBuddyAgent.install(); - instrumentation = ByteBuddyAgent.getInstrumentation(); - } - - private ShenyuThreadPoolExecutor getTestExecutor(final TaskQueue taskQueue) { - return new ShenyuThreadPoolExecutor(5, 10, 100, TimeUnit.SECONDS, taskQueue, ShenyuThreadFactory.create("Test", false), (r, e) -> { - }); - } - - @Test - public void testNullCommand() { - ShenyuThreadPoolExecutor executor = getTestExecutor(new MemoryLimitedTaskQueue<>(instrumentation)); - assertThrows(NullPointerException.class, () -> executor.execute(null)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/config/ShenyuConfigTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/config/ShenyuConfigTest.java deleted file mode 100644 index 4f9bdf5..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/config/ShenyuConfigTest.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.config; - -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test cases for ShenyuConfig. - */ -public class ShenyuConfigTest { - - private final ShenyuConfig config = new ShenyuConfig(); - - /** - * test of shenyuConfig. - * - * @return shenyuConfig - */ - public ShenyuConfig getConfig() { - return this.config; - } - - @Test - public void testShenyuConfig() { - ShenyuConfig.CrossFilterConfig cross = config.getCross(); - ShenyuConfig.SwitchConfig switchConfig = config.getSwitchConfig(); - ShenyuConfig.ExcludePath exclude = config.getExclude(); - ShenyuConfig.FallbackPath fallback = config.getFallback(); - ShenyuConfig.FileConfig file = config.getFile(); - ShenyuConfig.ExtPlugin extPlugin = config.getExtPlugin(); - ShenyuConfig.Local local = config.getLocal(); - ShenyuConfig.RibbonConfig ribbon = config.getRibbon(); - ShenyuConfig.MetricsConfig metrics = config.getMetrics(); - ShenyuConfig.Scheduler scheduler = config.getScheduler(); - ShenyuConfig.SharedPool sharedPool = config.getSharedPool(); - ShenyuConfig.WebsocketConfig websocket = config.getWebsocket(); - ShenyuConfig.UpstreamCheck upstreamCheck = config.getUpstreamCheck(); - - notEmptyElements(cross, switchConfig, exclude, fallback, file, - extPlugin, local, ribbon, metrics, scheduler, sharedPool, websocket, upstreamCheck); - } - - private void notEmptyElements(final Object... objects) { - assertTrue(ArrayUtils.isNotEmpty(objects)); - Arrays.stream(objects).forEach(val -> { - assertNotNull(val, "val must not be null"); - if (val instanceof String) { - assertTrue(StringUtils.isNotEmpty((String) val), "val must not be empty"); - } - }); - } - - @Test - public void testUpstreamCheck() { - ShenyuConfig.UpstreamCheck upstreamCheck = config.getUpstreamCheck(); - upstreamCheck.setEnabled(false); - upstreamCheck.setPoolSize(10); - upstreamCheck.setHealthyThreshold(4); - upstreamCheck.setTimeout(10); - upstreamCheck.setInterval(5); - upstreamCheck.setUnhealthyThreshold(5); - upstreamCheck.setPrintEnabled(false); - upstreamCheck.setPrintInterval(5); - - notEmptyElements(upstreamCheck.getEnabled(), upstreamCheck.getPoolSize(), upstreamCheck.getHealthyThreshold(), upstreamCheck.getTimeout(), - upstreamCheck.getInterval(), upstreamCheck.getUnhealthyThreshold(), upstreamCheck.getPrintInterval(), upstreamCheck.getPrintEnabled()); - } - - @Test - public void testWebsocketConfig() { - ShenyuConfig.WebsocketConfig websocket = config.getWebsocket(); - websocket.setMaxFramePayloadSize(5); - websocket.setEnableProxyPing(true); - assertEquals(5, (int) websocket.getMaxFramePayloadSize()); - assertEquals(true, websocket.getEnableProxyPing()); - } - - @Test - public void testSharedPool() { - ShenyuConfig.SharedPool sharedPool = config.getSharedPool(); - sharedPool.setCorePoolSize(3); - sharedPool.setEnable(true); - sharedPool.setMaximumPoolSize(5); - sharedPool.setPrefix("test-"); - sharedPool.setKeepAliveTime(1000L); - sharedPool.setMaxWorkQueueMemory(1024L); - - notEmptyElements(sharedPool.getCorePoolSize(), sharedPool.getEnable(), sharedPool.getMaximumPoolSize(), - sharedPool.getPrefix(), sharedPool.getKeepAliveTime(), sharedPool.getMaxWorkQueueMemory()); - } - - @Test - public void testScheduler() { - ShenyuConfig.Scheduler scheduler = config.getScheduler(); - scheduler.setEnabled(true); - scheduler.setThreads(5); - scheduler.setType("test"); - - Boolean enabled = scheduler.getEnabled(); - Integer threads = scheduler.getThreads(); - String type = scheduler.getType(); - - notEmptyElements(enabled, type, threads); - } - - @Test - public void testMetricsConfig() { - ShenyuConfig.MetricsConfig metrics = config.getMetrics(); - metrics.setPort(123); - metrics.setEnabled(true); - metrics.setName("test"); - metrics.setHost("test"); - metrics.setJmxConfig("jmxConfig"); - metrics.setProps(new Properties()); - - boolean enabled = metrics.getEnabled(); - - assertTrue(enabled, "result not excepted"); - String jmxConfig = metrics.getJmxConfig(); - Properties props = metrics.getProps(); - String host = metrics.getHost(); - String name = metrics.getName(); - Integer port = metrics.getPort(); - - notEmptyElements(jmxConfig, props, host, name, port); - } - - @Test - public void testRibbonConfig() { - ShenyuConfig.Local local = config.getLocal(); - local.setEnabled(true); - local.setSha512Key("test"); - Boolean enabled = local.getEnabled(); - String sha512Key = local.getSha512Key(); - - notEmptyElements(enabled, sha512Key); - } - - @Test - public void testLocal() { - ShenyuConfig.Local local = config.getLocal(); - local.setEnabled(true); - local.setSha512Key("test"); - Boolean enabled = local.getEnabled(); - String sha512Key = local.getSha512Key(); - - notEmptyElements(enabled, sha512Key); - } - - @Test - public void testExtPlugin() { - ShenyuConfig.ExtPlugin extPlugin = config.getExtPlugin(); - extPlugin.setThreads(5); - extPlugin.setPath("test"); - extPlugin.setEnabled(true); - extPlugin.setScheduleDelay(5); - - String path = extPlugin.getPath(); - Integer threads = extPlugin.getThreads(); - Boolean enabled = extPlugin.getEnabled(); - Integer scheduleDelay = extPlugin.getScheduleDelay(); - Integer scheduleTime = extPlugin.getScheduleTime(); - - notEmptyElements(enabled, path, scheduleTime, scheduleDelay, threads); - } - - @Test - public void testFileConfig() { - ShenyuConfig.FileConfig fileConfig = config.getFile(); - fileConfig.setMaxSize(10); - fileConfig.setEnabled(true); - - Boolean enabled = fileConfig.getEnabled(); - Integer maxSize = fileConfig.getMaxSize(); - - notEmptyElements(maxSize, enabled); - } - - @Test - public void testFallbackPath() { - ShenyuConfig.FallbackPath fallback = config.getFallback(); - fallback.setEnabled(true); - fallback.setPaths(Collections.emptyList()); - - List paths = fallback.getPaths(); - Boolean enabled = fallback.getEnabled(); - - notEmptyElements(paths, enabled); - } - - @Test - public void testExcludePath() { - ShenyuConfig.ExcludePath exclude = config.getExclude(); - exclude.setEnabled(true); - exclude.setPaths(Collections.emptyList()); - - List paths = exclude.getPaths(); - Boolean enabled = exclude.getEnabled(); - - notEmptyElements(paths, enabled); - } - - @Test - public void testSwitchConfig() { - ShenyuConfig.SwitchConfig switchConfig = config.getSwitchConfig(); - switchConfig.setLocal(true); - Boolean local = switchConfig.getLocal(); - - notEmptyElements(local); - } - - @Test - public void testCrossFilterConfig() { - ShenyuConfig.CrossFilterConfig cross = config.getCross(); - cross.setAllowCredentials(false); - cross.setEnabled(false); - cross.setAllowedExpose("test"); - cross.setAllowedMethods("test"); - cross.setAllowedHeaders("test"); - cross.setMaxAge("test"); - - String allowedExpose = cross.getAllowedExpose(); - String allowedHeaders = cross.getAllowedHeaders(); - ShenyuConfig.CrossFilterConfig.AllowedOriginConfig allowedOrigin = cross.getAllowedOrigin(); - Boolean enabled = cross.getEnabled(); - String maxAge = cross.getMaxAge(); - String allowedMethods = cross.getAllowedMethods(); - - notEmptyElements(allowedExpose, allowedHeaders, allowedOrigin, enabled, maxAge, allowedMethods); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/constant/DefaultPathConstantsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/constant/DefaultPathConstantsTest.java deleted file mode 100644 index 8458cb4..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/constant/DefaultPathConstantsTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; - -/** - * Test cases for ZkPathConstants. - */ -public final class DefaultPathConstantsTest { - - private static final String APP_AUTH_PARENT = "/shenyu/auth"; - - private static final String META_DATA_PARENT = "/shenyu/metaData"; - - private static final String PLUGIN_PARENT = "/shenyu/plugin"; - - private static final String SELECTOR_PARENT = "/shenyu/selector"; - - private static final String RULE_PARENT = "/shenyu/rule"; - - private static final String SELECTOR_JOIN_RULE = "-"; - - private static final String SEPARATOR = "/"; - - @Test - public void testBuildAppAuthPath() { - String appKey = RandomStringUtils.randomAlphanumeric(10); - String appAuthPath = DefaultPathConstants.buildAppAuthPath(appKey); - assertThat(appAuthPath, notNullValue()); - assertThat(String.join(SEPARATOR, APP_AUTH_PARENT, appKey), equalTo(appAuthPath)); - } - - @Test - public void testBuildMetaDataPath() { - String metadata = RandomStringUtils.randomAlphanumeric(10); - String metaDataPath = DefaultPathConstants.buildMetaDataPath(metadata); - assertThat(metaDataPath, notNullValue()); - assertThat(String.join(SEPARATOR, META_DATA_PARENT, metadata), equalTo(metaDataPath)); - } - - @Test - public void testBuildPluginParentPath() { - String pluginParentPath = DefaultPathConstants.buildPluginParentPath(); - assertThat(pluginParentPath, notNullValue()); - assertThat(PLUGIN_PARENT, equalTo(pluginParentPath)); - } - - @Test - public void testBuildPluginPath() { - String pluginName = RandomStringUtils.randomAlphanumeric(10); - String pluginPath = DefaultPathConstants.buildPluginPath(pluginName); - assertThat(pluginPath, notNullValue()); - assertThat(String.join(SEPARATOR, PLUGIN_PARENT, pluginName), equalTo(pluginPath)); - assertThat(String.join(SEPARATOR, DefaultPathConstants.buildPluginParentPath(), pluginName), equalTo(pluginPath)); - } - - @Test - public void testBuildSelectorParentPath() { - String pluginName = RandomStringUtils.randomAlphanumeric(10); - String selectorParentPath = DefaultPathConstants.buildSelectorParentPath(pluginName); - assertThat(selectorParentPath, notNullValue()); - assertThat(String.join(SEPARATOR, SELECTOR_PARENT, pluginName), equalTo(selectorParentPath)); - } - - @Test - public void testBuildSelectorRealPath() { - String pluginName = RandomStringUtils.randomAlphanumeric(10); - String selectorId = RandomStringUtils.randomAlphanumeric(10); - String selectorRealPath = DefaultPathConstants.buildSelectorRealPath(pluginName, selectorId); - assertThat(selectorRealPath, notNullValue()); - assertThat(String.join(SEPARATOR, SELECTOR_PARENT, pluginName, selectorId), equalTo(selectorRealPath)); - } - - @Test - public void testBuildRuleParentPath() { - String pluginName = RandomStringUtils.randomAlphanumeric(10); - String ruleParentPath = DefaultPathConstants.buildRuleParentPath(pluginName); - assertThat(ruleParentPath, notNullValue()); - assertThat(String.join(SEPARATOR, RULE_PARENT, pluginName), equalTo(ruleParentPath)); - } - - @Test - public void testBuildRulePath() { - String pluginName = RandomStringUtils.randomAlphanumeric(10); - String selectorId = RandomStringUtils.randomAlphanumeric(10); - String ruleId = RandomStringUtils.randomAlphanumeric(10); - String rulePath = DefaultPathConstants.buildRulePath(pluginName, selectorId, ruleId); - assertThat(rulePath, notNullValue()); - assertThat(String.join(SEPARATOR, RULE_PARENT, pluginName, String.join(SELECTOR_JOIN_RULE, selectorId, ruleId)), equalTo(rulePath)); - assertThat(String.join(SEPARATOR, DefaultPathConstants.buildRuleParentPath(pluginName), String.join(SELECTOR_JOIN_RULE, selectorId, ruleId)), equalTo(rulePath)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/constant/RedisKeyConstantsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/constant/RedisKeyConstantsTest.java deleted file mode 100644 index 74e4398..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/constant/RedisKeyConstantsTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.constant; - -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; - -/** - * Test cases for RedisKeyConstants. - */ -public final class RedisKeyConstantsTest { - - public static final String PLUGIN_INFO = ":info"; - - public static final String PLUGIN_SELECTOR = ":selector"; - - @Test - public void testPlugInfoKey() { - String mockPlugin = "MockPlugin"; - String mokPluginInfoKey = RedisKeyConstants.pluginInfoKey(mockPlugin); - assertThat(mockPlugin, notNullValue()); - assertThat(String.join("", mockPlugin, PLUGIN_INFO), equalTo(mokPluginInfoKey)); - } - - @Test - public void testPluginSelectorKey() { - String mockPlugin = "MockPlugin"; - String mockPluginSelectorKey = RedisKeyConstants.pluginSelectorKey(mockPlugin); - assertThat(mockPlugin, notNullValue()); - assertThat(String.join("", mockPlugin, PLUGIN_SELECTOR), equalTo(mockPluginSelectorKey)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AppAuthDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AppAuthDataTest.java deleted file mode 100644 index e302fef..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AppAuthDataTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.nullValue; - -/** - * Test case for AppAuthData. - */ -public class AppAuthDataTest { - - @Test - public void testBuilderAndGetterSetter() { - AppAuthData appAuthData = AppAuthData.builder().appKey("appKey").appSecret("appSecret").enabled(true) - .open(true).pathDataList(new ArrayList<>(0)).paramDataList(new ArrayList<>(0)) - .build(); - - assertThat(appAuthData.getAppKey(), is("appKey")); - assertThat(appAuthData.getAppSecret(), is("appSecret")); - assertThat(appAuthData.getEnabled(), is(true)); - assertThat(appAuthData.getOpen(), is(true)); - assertThat(appAuthData.getPathDataList(), notNullValue()); - assertThat(appAuthData.getParamDataList(), notNullValue()); - - appAuthData.setAppKey("otherAppKey"); - appAuthData.setAppSecret("otherAppSecret"); - appAuthData.setEnabled(false); - appAuthData.setOpen(false); - appAuthData.setPathDataList(null); - appAuthData.setParamDataList(null); - - assertThat(appAuthData.getAppKey(), is("otherAppKey")); - assertThat(appAuthData.getAppSecret(), is("otherAppSecret")); - assertThat(appAuthData.getEnabled(), is(false)); - assertThat(appAuthData.getOpen(), is(false)); - assertThat(appAuthData.getPathDataList(), nullValue()); - assertThat(appAuthData.getParamDataList(), nullValue()); - } - - @Test - public void testEqualsAndHashCode() { - AppAuthData appAuthData1 = AppAuthData.builder().appKey("appKey").appSecret("appSecret").enabled(true) - .open(true).pathDataList(new ArrayList<>(0)).paramDataList(new ArrayList<>(0)) - .build(); - AppAuthData appAuthData2 = AppAuthData.builder().appKey("appKey").appSecret("appSecret").enabled(true) - .open(true).pathDataList(new ArrayList<>(0)).paramDataList(new ArrayList<>(0)) - .build(); - - Set set = new HashSet<>(); - set.add(appAuthData1); - set.add(appAuthData2); - - assertThat(set, hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AuthParamDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AuthParamDataTest.java deleted file mode 100644 index cad0656..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AuthParamDataTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for AuthParamData. - */ -public class AuthParamDataTest { - - @Test - public void testGetterSetter() { - AuthParamData authParamData = new AuthParamData(); - authParamData.setAppName("appName"); - authParamData.setAppParam("appParam"); - - assertThat(authParamData.getAppName(), is("appName")); - assertThat(authParamData.getAppParam(), is("appParam")); - } - - @Test - public void testEqualsAndHashCode() { - AuthParamData authParamData1 = new AuthParamData("appName", "appParam"); - AuthParamData authParamData2 = new AuthParamData("appName", "appParam"); - - Set set = new HashSet<>(); - set.add(authParamData1); - set.add(authParamData2); - - assertThat(set, hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AuthPathDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AuthPathDataTest.java deleted file mode 100644 index 1356305..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/AuthPathDataTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for AuthPathData. - */ -public class AuthPathDataTest { - - @Test - public void testBuilderAndGetterSetter() { - AuthPathData authPathData = AuthPathData.builder().appName("appName").enabled(true).path("path").build(); - - assertThat(authPathData.getAppName(), is("appName")); - assertThat(authPathData.getEnabled(), is(true)); - assertThat(authPathData.getPath(), is("path")); - - authPathData.setAppName("otherAppName"); - authPathData.setPath("otherPath"); - authPathData.setEnabled(false); - - assertThat(authPathData.getAppName(), is("otherAppName")); - assertThat(authPathData.getEnabled(), is(false)); - assertThat(authPathData.getPath(), is("otherPath")); - } - - @Test - public void testEqualsAndHashCode() { - AuthPathData authPathData1 = AuthPathData.builder().appName("appName").enabled(true).path("path").build(); - AuthPathData authPathData2 = AuthPathData.builder().appName("appName").enabled(true).path("path").build(); - - Set set = new HashSet<>(); - set.add(authPathData1); - set.add(authPathData2); - - assertThat(set, hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/ConditionDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/ConditionDataTest.java deleted file mode 100644 index c04a802..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/ConditionDataTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for ConditionData. - */ -public class ConditionDataTest { - - @Test - public void testGetterSetter() { - ConditionData conditionData = new ConditionData(); - conditionData.setOperator("operator"); - conditionData.setParamName("paramName"); - conditionData.setParamType("paramType"); - conditionData.setParamValue("paramValue"); - - assertThat(conditionData.getOperator(), is("operator")); - assertThat(conditionData.getParamName(), is("paramName")); - assertThat(conditionData.getParamType(), is("paramType")); - assertThat(conditionData.getParamValue(), is("paramValue")); - } - - @Test - public void testEqualsAndHashCode() { - ConditionData conditionData1 = new ConditionData(); - ConditionData conditionData2 = new ConditionData(); - - Set set = new HashSet<>(); - set.add(conditionData1); - set.add(conditionData2); - - assertThat(set, hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/ConfigDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/ConfigDataTest.java deleted file mode 100644 index 25da590..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/ConfigDataTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.Collections; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - - -/** - * Test case for ConfigData. - */ -public class ConfigDataTest { - - private static final String MD5 = "b48bacc7f914ee90162cd91865b83a3d"; - - private static final long LAST_MODIFY_TIME = System.currentTimeMillis(); - - @Test - public void testToString() { - ConfigData configData = new ConfigData<>(); - configData.setLastModifyTime(LAST_MODIFY_TIME); - configData.setMd5(MD5); - configData.setData(Collections.emptyList()); - assertNotNull(configData.toString()); - } - - /** - * just improve code coverage. - */ - @Test - public void testGetterSetter() { - ConfigData configData = new ConfigData<>(MD5, LAST_MODIFY_TIME, Collections.emptyList()); - assertEquals(configData.getData(), Collections.emptyList()); - assertEquals(configData.getMd5(), MD5); - assertEquals(configData.getLastModifyTime(), LAST_MODIFY_TIME); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/MetaDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/MetaDataTest.java deleted file mode 100644 index 32ebf44..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/MetaDataTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.apache.commons.lang3.StringUtils; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * Test case for MetaData. - */ -public class MetaDataTest { - - private static final String CONTEXT_PATH = "/shenyu"; - - private static final String PATH = CONTEXT_PATH + "/context/path"; - - @Test - public void testUpdateContextPath() { - MetaData metaData = new MetaData("id", "appName", "contextPath", "path", "rpcType", - "serviceName", "methodName", "parameterTypes", "rpcExt", true); - metaData.setPath(PATH); - metaData.updateContextPath(); - assertEquals(metaData.getContextPath(), CONTEXT_PATH); - } - - /** - * just improve code coverage. - */ - @Test - public void testGetterSetter() { - MetaData metaData = MetaData.builder().id("id").appName("appName").contextPath("contextPath") - .path(PATH).rpcType("rpcType").serviceName("serviceName").methodName("methodName") - .parameterTypes("parameterTypes").rpcExt("rpcExt").enabled(true).build(); - metaData.setId("id"); - assertTrue(StringUtils.equals(metaData.getId(), "id")); - metaData.setAppName("appName"); - assertTrue(StringUtils.equals(metaData.getAppName(), "appName")); - metaData.setContextPath("contextPath"); - assertTrue(StringUtils.equals(metaData.getContextPath(), "contextPath")); - metaData.setPath(PATH); - assertTrue(StringUtils.equals(metaData.getPath(), PATH)); - metaData.setRpcType("rpcType"); - assertTrue(StringUtils.equals(metaData.getRpcType(), "rpcType")); - metaData.setServiceName("serviceName"); - assertTrue(StringUtils.equals(metaData.getServiceName(), "serviceName")); - metaData.setMethodName("methodName"); - assertTrue(StringUtils.equals(metaData.getMethodName(), "methodName")); - metaData.setParameterTypes("parameterTypes"); - assertTrue(StringUtils.equals(metaData.getParameterTypes(), "parameterTypes")); - metaData.setRpcExt("rpcExt"); - assertTrue(StringUtils.equals(metaData.getRpcExt(), "rpcExt")); - metaData.setEnabled(true); - assertEquals(metaData.getEnabled(), true); - assertNotNull(metaData.toString()); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/PluginDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/PluginDataTest.java deleted file mode 100644 index cd950df..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/PluginDataTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; - -/** - * Test case for PluginData. - */ -public class PluginDataTest { - - @Test - public void testBuilderAndGetterSetter() { - PluginData pluginData = PluginData.builder().id("id").name("name").config("config") - .role("role").enabled(true).sort(0).build(); - - assertThat(pluginData.getId(), is("id")); - assertThat(pluginData.getName(), is("name")); - assertThat(pluginData.getConfig(), is("config")); - assertThat(pluginData.getRole(), is("role")); - assertThat(pluginData.getEnabled(), is(true)); - assertThat(pluginData.getSort(), is(0)); - - pluginData.setId("newId"); - pluginData.setName("newName"); - pluginData.setConfig("newConfig"); - pluginData.setRole("newRole"); - pluginData.setEnabled(false); - pluginData.setSort(-1); - - assertThat(pluginData.getId(), is("newId")); - assertThat(pluginData.getName(), is("newName")); - assertThat(pluginData.getConfig(), is("newConfig")); - assertThat(pluginData.getRole(), is("newRole")); - assertThat(pluginData.getEnabled(), is(false)); - assertThat(pluginData.getSort(), is(-1)); - } - - @Test - public void testEqualsAndHashCode() { - PluginData pluginData1 = PluginData.builder().id("id").name("name").config("config") - .role("role").enabled(true).sort(0).build(); - PluginData pluginData2 = PluginData.builder().id("id").name("name").config("config") - .role("role").enabled(true).sort(0).build(); - - Set set = new HashSet<>(); - set.add(pluginData1); - set.add(pluginData2); - - assertThat(set, hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/RuleDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/RuleDataTest.java deleted file mode 100644 index fd91fe4..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/RuleDataTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.nullValue; - -/** - * Test case for RuleData. - */ -public class RuleDataTest { - - @Test - public void testBuilderAndGetterSetter() { - RuleData ruleData = RuleData.builder().id("id").name("name").pluginName("pluginName") - .selectorId("selectorId").matchMode(1).sort(0).enabled(true).loged(true) - .handle("handle").conditionDataList(new ArrayList<>()).build(); - - assertThat(ruleData.getId(), is("id")); - assertThat(ruleData.getName(), is("name")); - assertThat(ruleData.getPluginName(), is("pluginName")); - assertThat(ruleData.getSelectorId(), is("selectorId")); - assertThat(ruleData.getMatchMode(), is(1)); - assertThat(ruleData.getSort(), is(0)); - assertThat(ruleData.getEnabled(), is(true)); - assertThat(ruleData.getLoged(), is(true)); - assertThat(ruleData.getHandle(), is("handle")); - assertThat(ruleData.getConditionDataList(), hasSize(0)); - - ruleData.setId("newId"); - ruleData.setName("newName"); - ruleData.setPluginName("newPlugin"); - ruleData.setSelectorId("newSelector"); - ruleData.setMatchMode(0); - ruleData.setSort(99); - ruleData.setEnabled(false); - ruleData.setLoged(false); - ruleData.setHandle("newHandle"); - ruleData.setConditionDataList(null); - - assertThat(ruleData.getId(), is("newId")); - assertThat(ruleData.getName(), is("newName")); - assertThat(ruleData.getPluginName(), is("newPlugin")); - assertThat(ruleData.getSelectorId(), is("newSelector")); - assertThat(ruleData.getMatchMode(), is(0)); - assertThat(ruleData.getSort(), is(99)); - assertThat(ruleData.getEnabled(), is(false)); - assertThat(ruleData.getLoged(), is(false)); - assertThat(ruleData.getHandle(), is("newHandle")); - assertThat(ruleData.getConditionDataList(), is(nullValue())); - } - - @Test - public void testEqualsAndHashCode() { - RuleData ruleData1 = RuleData.builder().id("id").name("name").pluginName("pluginName") - .selectorId("selectorId").matchMode(1).sort(0).enabled(true).loged(true) - .handle("handle").conditionDataList(new ArrayList<>()).build(); - RuleData ruleData2 = RuleData.builder().id("id").name("name").pluginName("pluginName") - .selectorId("selectorId").matchMode(1).sort(0).enabled(true).loged(true) - .handle("handle").conditionDataList(new ArrayList<>()).build(); - - Set set = new HashSet<>(); - set.add(ruleData1); - set.add(ruleData2); - - assertThat(set, hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/SelectorDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/SelectorDataTest.java deleted file mode 100644 index 7609fd6..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/SelectorDataTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.nullValue; - -/** - * Test case for SelectorData. - */ -public class SelectorDataTest { - - @Test - public void testBuilderAndGetterSetter() { - SelectorData selectorData = SelectorData.builder().id("id").pluginId("pluginId").pluginName("pluginName") - .name("name").matchMode(0).type(0).sort(0).enabled(true) - .logged(true).continued(true).handle("handle").conditionList(new ArrayList<>(1)).build(); - - assertThat(selectorData.getId(), is("id")); - assertThat(selectorData.getName(), is("name")); - assertThat(selectorData.getPluginId(), is("pluginId")); - assertThat(selectorData.getPluginName(), is("pluginName")); - assertThat(selectorData.getName(), is("name")); - assertThat(selectorData.getMatchMode(), is(0)); - assertThat(selectorData.getType(), is(0)); - assertThat(selectorData.getSort(), is(0)); - assertThat(selectorData.getEnabled(), is(true)); - assertThat(selectorData.getLogged(), is(true)); - assertThat(selectorData.getContinued(), is(true)); - assertThat(selectorData.getHandle(), is("handle")); - assertThat(selectorData.getConditionList(), hasSize(0)); - - selectorData.setId("newId"); - selectorData.setName("newName"); - selectorData.setPluginId("newPluginId"); - selectorData.setPluginName("newPlugin"); - selectorData.setName("newName"); - selectorData.setMatchMode(1); - selectorData.setType(1); - selectorData.setSort(99); - selectorData.setEnabled(false); - selectorData.setLogged(false); - selectorData.setContinued(false); - selectorData.setHandle("newHandle"); - selectorData.setConditionList(null); - - assertThat(selectorData.getId(), is("newId")); - assertThat(selectorData.getName(), is("newName")); - assertThat(selectorData.getPluginId(), is("newPluginId")); - assertThat(selectorData.getPluginName(), is("newPlugin")); - assertThat(selectorData.getName(), is("newName")); - assertThat(selectorData.getMatchMode(), is(1)); - assertThat(selectorData.getType(), is(1)); - assertThat(selectorData.getSort(), is(99)); - assertThat(selectorData.getEnabled(), is(false)); - assertThat(selectorData.getLogged(), is(false)); - assertThat(selectorData.getContinued(), is(false)); - assertThat(selectorData.getHandle(), is("newHandle")); - assertThat(selectorData.getConditionList(), is(nullValue())); - } - - @Test - public void testEqualsAndHashCode() { - SelectorData selectorData1 = SelectorData.builder().id("id").pluginId("pluginId").pluginName("pluginName") - .name("name").matchMode(0).type(0).sort(0).enabled(true) - .logged(true).continued(true).handle("handle").conditionList(new ArrayList<>(1)).build(); - SelectorData selectorData2 = SelectorData.builder().id("id").pluginId("pluginId").pluginName("pluginName") - .name("name").matchMode(0).type(0).sort(0).enabled(true) - .logged(true).continued(true).handle("handle").conditionList(new ArrayList<>(1)).build(); - - Set set = new HashSet<>(); - set.add(selectorData1); - set.add(selectorData2); - - assertThat(set, hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/WebsocketDataTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/WebsocketDataTest.java deleted file mode 100644 index 311a75a..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/WebsocketDataTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for WebsocketData. - */ -public class WebsocketDataTest { - - @Test - public void testGetterSetter() { - WebsocketData websocketData = new WebsocketData<>( - "groupType", "eventType", Collections.singletonList(new AppAuthData())); - - websocketData.setGroupType("groupType1"); - websocketData.setEventType("eventType1"); - websocketData.setData(Arrays.asList(new AppAuthData(), new AppAuthData())); - - assertThat(websocketData.getGroupType(), is("groupType1")); - assertThat(websocketData.getEventType(), is("eventType1")); - assertThat(websocketData.getData(), hasSize(2)); - } - - @Test - public void testEqualsAndHashCode() { - WebsocketData websocketData1 = new WebsocketData<>( - "groupType", "eventType", Collections.singletonList(new AppAuthData())); - WebsocketData websocketData2 = new WebsocketData<>( - "groupType", "eventType", Collections.singletonList(new AppAuthData())); - - Set set = new HashSet<>(); - set.add(websocketData1); - set.add(websocketData2); - - assertThat(set, hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/DubboRegisterConfigTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/DubboRegisterConfigTest.java deleted file mode 100644 index 2012dc6..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/DubboRegisterConfigTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for DubboRegisterConfig. - */ -public class DubboRegisterConfigTest { - - @Test - public void testGetterSetter() { - DubboRegisterConfig config = new DubboRegisterConfig(); - config.setRegister("reg"); - config.setGroup("group"); - config.setProtocol("protocol"); - config.setThreadpool("threadPool"); - config.setCorethreads(10); - config.setThreads(10); - config.setQueues(2); - - assertThat(config.getRegister(), is("reg")); - assertThat(config.getGroup(), is("group")); - assertThat(config.getProtocol(), is("protocol")); - assertThat(config.getThreadpool(), is("threadPool")); - assertThat(config.getCorethreads(), is(10)); - assertThat(config.getThreads(), is(10)); - assertThat(config.getQueues(), is(2)); - } - - @Test - public void testEqualsAndHashCode() { - DubboRegisterConfig config1 = new DubboRegisterConfig(); - DubboRegisterConfig config2 = new DubboRegisterConfig(); - - assertThat(ImmutableSet.of(config1, config2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/GrpcRegisterConfigTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/GrpcRegisterConfigTest.java deleted file mode 100644 index 8b4f4dc..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/GrpcRegisterConfigTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for GrpcRegisterConfig. - */ -public class GrpcRegisterConfigTest { - - @Test - public void testGetterSetter() { - GrpcRegisterConfig config = new GrpcRegisterConfig(); - config.setThreadpool("threadPool"); - - assertThat(config.getThreadpool(), is("threadPool")); - } - - @Test - public void testEqualsAndHashCode() { - GrpcRegisterConfig config1 = new GrpcRegisterConfig(); - GrpcRegisterConfig config2 = new GrpcRegisterConfig(); - - config1.setThreadpool("threadPool"); - config2.setThreadpool("threadPool"); - - assertThat(ImmutableSet.of(config1, config2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/MotanRegisterConfigTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/MotanRegisterConfigTest.java deleted file mode 100644 index 8471d2d..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/MotanRegisterConfigTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for MotanRegisterConfig. - */ -public class MotanRegisterConfigTest { - - @Test - public void testGetterSetter() { - MotanRegisterConfig config = new MotanRegisterConfig(); - config.setRegisterAddress("reg"); - config.setRegisterProtocol("zk"); - config.setCorethreads(10); - config.setThreads(10); - config.setQueues(2); - - assertThat(config.getRegisterAddress(), is("reg")); - assertThat(config.getRegisterProtocol(), is("zk")); - assertThat(config.getCorethreads(), is(10)); - assertThat(config.getThreads(), is(10)); - assertThat(config.getQueues(), is(2)); - } - - @Test - public void testEqualsAndHashCode() { - MotanRegisterConfig config1 = new MotanRegisterConfig(); - MotanRegisterConfig config2 = new MotanRegisterConfig(); - - assertThat(ImmutableSet.of(config1, config2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/SofaRegisterConfigTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/SofaRegisterConfigTest.java deleted file mode 100644 index 584125f..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/SofaRegisterConfigTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for SofaRegisterConfig. - */ -public class SofaRegisterConfigTest { - - @Test - public void testGetterSetter() { - SofaRegisterConfig config = new SofaRegisterConfig(); - config.setRegister("reg"); - config.setGroup("group"); - config.setProtocol("protocol"); - - assertThat(config.getRegister(), is("reg")); - assertThat(config.getGroup(), is("group")); - assertThat(config.getProtocol(), is("protocol")); - } - - @Test - public void testEqualsAndHashCode() { - SofaRegisterConfig config1 = new SofaRegisterConfig(); - SofaRegisterConfig config2 = new SofaRegisterConfig(); - - assertThat(ImmutableSet.of(config1, config2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/TarsRegisterConfigTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/TarsRegisterConfigTest.java deleted file mode 100644 index 644e4dd..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/TarsRegisterConfigTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.plugin; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for TarsRegisterConfigTest. - */ -public class TarsRegisterConfigTest { - - @Test - public void testGetterSetter() { - TarsRegisterConfig config = new TarsRegisterConfig(); - config.setCorethreads(10); - config.setThreads(10); - config.setQueues(2); - config.setThreadpool("threadPool"); - - assertThat(config.getCorethreads(), is(10)); - assertThat(config.getThreads(), is(10)); - assertThat(config.getQueues(), is(2)); - assertThat(config.getThreadpool(), is("threadPool")); - } - - @Test - public void testEqualsAndHashCode() { - TarsRegisterConfig config1 = new TarsRegisterConfig(); - TarsRegisterConfig config2 = new TarsRegisterConfig(); - - assertThat(ImmutableSet.of(config1, config2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/GeneralContextHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/GeneralContextHandleTest.java deleted file mode 100644 index 7022293..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/GeneralContextHandleTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for GeneralContextHandle. - */ -public class GeneralContextHandleTest { - - @Test - public void testGetterSetter() { - GeneralContextHandle handle = new GeneralContextHandle(); - handle.setGeneralContextKey("contextKey"); - handle.setGeneralContextType("contextType"); - handle.setGeneralContextValue("contextValue"); - - assertThat(handle.getGeneralContextKey(), is("contextKey")); - assertThat(handle.getGeneralContextType(), is("contextType")); - assertThat(handle.getGeneralContextValue(), is("contextValue")); - } - - @Test - public void testEqualsAndHashCode() { - GeneralContextHandle handle1 = new GeneralContextHandle("type", "key", "val"); - GeneralContextHandle handle2 = new GeneralContextHandle("type", "key", "val"); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/HystrixHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/HystrixHandleTest.java deleted file mode 100644 index fcd0c7f..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/HystrixHandleTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.enums.HystrixIsolationModeEnum; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; - -/** - * Test case for HystrixHandle. - */ -public class HystrixHandleTest { - - @Test - public void testGetterSetter() { - HystrixHandle handle = new HystrixHandle(); - handle.setGroupKey("groupKey"); - handle.setCommandKey("commandKey"); - handle.setMaxConcurrentRequests(10); - handle.setErrorThresholdPercentage(50); - handle.setRequestVolumeThreshold(50); - handle.setSleepWindowInMilliseconds(1000); - handle.setTimeout(1000L); - handle.setCallBackUri("uri"); - handle.setExecutionIsolationStrategy(HystrixIsolationModeEnum.THREAD_POOL.getCode()); - handle.setHystrixThreadPoolConfig(new HystrixHandle.HystrixThreadPoolConfig()); - - assertThat(handle.getGroupKey(), is("groupKey")); - assertThat(handle.getCommandKey(), is("commandKey")); - assertThat(handle.getMaxConcurrentRequests(), is(10)); - assertThat(handle.getErrorThresholdPercentage(), is(50)); - assertThat(handle.getRequestVolumeThreshold(), is(50)); - assertThat(handle.getSleepWindowInMilliseconds(), is(1000)); - assertThat(handle.getTimeout(), is(1000L)); - assertThat(handle.getCallBackUri(), is("uri")); - assertThat(handle.getExecutionIsolationStrategy(), is(HystrixIsolationModeEnum.THREAD_POOL.getCode())); - assertThat(handle.getHystrixThreadPoolConfig(), is(notNullValue())); - } - - @Test - public void testEqualsAndHashCode() { - HystrixHandle handle1 = new HystrixHandle(); - HystrixHandle handle2 = new HystrixHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - - @Test - public void testGetterSetterOfHystrixThreadPoolConfig() { - HystrixHandle.HystrixThreadPoolConfig config = new HystrixHandle.HystrixThreadPoolConfig(); - config.setCoreSize(10); - config.setMaximumSize(20); - config.setKeepAliveTimeMinutes(2); - config.setMaxQueueSize(5); - - assertThat(config.getCoreSize(), is(10)); - assertThat(config.getMaximumSize(), is(20)); - assertThat(config.getKeepAliveTimeMinutes(), is(2)); - assertThat(config.getMaxQueueSize(), is(5)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/MockHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/MockHandleTest.java deleted file mode 100644 index 9916d43..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/MockHandleTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for MockHandle. - */ -public class MockHandleTest { - - @Test - public void testSetterGetter() { - MockHandle handle = new MockHandle(); - handle.setHttpStatusCode(200); - handle.setResponseContent("OK"); - - assertThat(handle.getHttpStatusCode(), is(200)); - assertThat(handle.getResponseContent(), is("OK")); - } - - @Test - public void testEqualsAndHashCode() { - MockHandle handle1 = new MockHandle(); - MockHandle handle2 = new MockHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RateLimiterHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RateLimiterHandleTest.java deleted file mode 100644 index c9d97fd..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RateLimiterHandleTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.closeTo; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for RateLimiterHandle. - */ -public class RateLimiterHandleTest { - - @Test - public void testGetterSetter() { - RateLimiterHandle handle = new RateLimiterHandle(); - handle.setAlgorithmName("algorithmName"); - handle.setReplenishRate(500); - handle.setBurstCapacity(1000); - handle.setRequestCount(2.0); - handle.setLoged(true); - handle.setKeyResolverName("resolverName"); - - assertThat(handle.getAlgorithmName(), is("algorithmName")); - assertThat(handle.getReplenishRate(), closeTo(500, 0.1)); - assertThat(handle.getBurstCapacity(), closeTo(1000, 0.1)); - assertThat(handle.getRequestCount(), closeTo(2.0, 0.1)); - assertThat(handle.isLoged(), is(true)); - assertThat(handle.getKeyResolverName(), is("resolverName")); - } - - @Test - public void testEqualsAndHashCode() { - RateLimiterHandle handle1 = new RateLimiterHandle(); - RateLimiterHandle handle2 = new RateLimiterHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RedirectHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RedirectHandleTest.java deleted file mode 100644 index 4bd005c..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RedirectHandleTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for RedirectHandle. - */ -public class RedirectHandleTest { - - @Test - public void testGetterSetter() { - RedirectHandle handle = new RedirectHandle(); - handle.setRedirectURI("uri"); - - assertThat(handle.getRedirectURI(), is("uri")); - } - - @Test - public void testEqualsAndHashCode() { - RedirectHandle handle1 = new RedirectHandle(); - RedirectHandle handle2 = new RedirectHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RequestHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RequestHandleTest.java deleted file mode 100644 index d2d6c20..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RequestHandleTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; -import org.mockito.internal.util.collections.Sets; - -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasEntry; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * Test case for RequestHandle. - */ -public class RequestHandleTest { - - @Test - public void testGetterSetter() { - RequestHandle handle = new RequestHandle(); - handle.setHeader(handle.new ShenyuRequestHeader()); - handle.setParameter(handle.new ShenyuRequestParameter()); - handle.setCookie(handle.new ShenyuCookie()); - - assertThat(handle.getHeader(), is(notNullValue())); - assertThat(handle.getParameter(), is(notNullValue())); - assertThat(handle.getCookie(), is(notNullValue())); - } - - @Test - public void testEqualsAndHashCode() { - RequestHandle handle1 = new RequestHandle(); - RequestHandle handle2 = new RequestHandle(); - - Set set = new HashSet<>(); - set.add(handle1); - set.add(handle2); - - assertThat(set, hasSize(1)); - } - - @Test - public void testIsEmptyConfig() { - RequestHandle handle = new RequestHandle(); - handle.setHeader(handle.new ShenyuRequestHeader()); - handle.setParameter(handle.new ShenyuRequestParameter()); - handle.setCookie(handle.new ShenyuCookie()); - - assertThat(handle.isEmptyConfig(), is(true)); - } - - @Test - public void testShenyuRequestHeader() { - RequestHandle handle = new RequestHandle(); - RequestHandle.ShenyuRequestHeader header = handle.new ShenyuRequestHeader( - ImmutableMap.of("addKey", "addValue"), ImmutableMap.of("replaceKey", "newKey"), - ImmutableMap.of("setKey", "newValue"), Sets.newSet("removeKey") - ); - - assertThat(header.isNotEmptyConfig(), is(true)); - assertThat(header.getAddHeaders(), hasEntry("addKey", "addValue")); - assertThat(header.getReplaceHeaderKeys(), hasEntry("replaceKey", "newKey")); - assertThat(header.getSetHeaders(), hasEntry("setKey", "newValue")); - assertThat(header.getRemoveHeaderKeys(), hasItems("removeKey")); - - RequestHandle.ShenyuRequestHeader header1 = handle.new ShenyuRequestHeader(); - header1.setAddHeaders(ImmutableMap.of("addKey", "addValue")); - header1.setReplaceHeaderKeys(ImmutableMap.of("replaceKey", "newKey")); - header1.setSetHeaders(ImmutableMap.of("setKey", "newValue")); - header1.setRemoveHeaderKeys(ImmutableSet.of("removeKey")); - - assertThat(ImmutableSet.of(header, header1), hasSize(1)); - } - - @Test - public void testShenyuRequestParameter() { - RequestHandle handle = new RequestHandle(); - RequestHandle.ShenyuRequestParameter parameter = handle.new ShenyuRequestParameter( - ImmutableMap.of("addKey", "addValue"), ImmutableMap.of("replaceKey", "newKey"), - ImmutableMap.of("setKey", "newValue"), Sets.newSet("removeKey") - ); - - assertThat(parameter.isNotEmptyConfig(), is(true)); - assertThat(parameter.getAddParameters(), hasEntry("addKey", "addValue")); - assertThat(parameter.getReplaceParameterKeys(), hasEntry("replaceKey", "newKey")); - assertThat(parameter.getSetParameters(), hasEntry("setKey", "newValue")); - assertThat(parameter.getRemoveParameterKeys(), hasItems("removeKey")); - - RequestHandle.ShenyuRequestParameter parameter1 = handle.new ShenyuRequestParameter(); - parameter1.setAddParameters(ImmutableMap.of("addKey", "addValue")); - parameter1.setReplaceParameterKeys(ImmutableMap.of("replaceKey", "newKey")); - parameter1.setSetParameters(ImmutableMap.of("setKey", "newValue")); - parameter1.setRemoveParameterKeys(ImmutableSet.of("removeKey")); - - assertThat(ImmutableSet.of(parameter, parameter1), hasSize(1)); - } - - @Test - public void testShenyuCookie() { - RequestHandle handle = new RequestHandle(); - RequestHandle.ShenyuCookie cookie = handle.new ShenyuCookie( - ImmutableMap.of("addKey", "addValue"), ImmutableMap.of("replaceKey", "newKey"), - ImmutableMap.of("setKey", "newValue"), Sets.newSet("removeKey") - ); - - assertThat(cookie.isNotEmptyConfig(), is(true)); - assertThat(cookie.getAddCookies(), hasEntry("addKey", "addValue")); - assertThat(cookie.getReplaceCookieKeys(), hasEntry("replaceKey", "newKey")); - assertThat(cookie.getSetCookies(), hasEntry("setKey", "newValue")); - assertThat(cookie.getRemoveCookieKeys(), hasItems("removeKey")); - - RequestHandle.ShenyuCookie cookie1 = handle.new ShenyuCookie(); - cookie1.setAddCookies(ImmutableMap.of("addKey", "addValue")); - cookie1.setReplaceCookieKeys(ImmutableMap.of("replaceKey", "newKey")); - cookie1.setSetCookies(ImmutableMap.of("setKey", "newValue")); - cookie1.setRemoveCookieKeys(ImmutableSet.of("removeKey")); - - assertThat(ImmutableSet.of(cookie, cookie1), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandleTest.java deleted file mode 100644 index 86fb686..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandleTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.constant.Constants; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.comparesEqualTo; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for Resilience4JHandle. - */ -public class Resilience4JHandleTest { - - @Test - public void testGetterSetter() { - Resilience4JHandle handle = new Resilience4JHandle(); - handle.setTimeoutDurationRate(1000); - handle.setLimitRefreshPeriod(200); - handle.setLimitForPeriod(100); - handle.setCircuitEnable(0); - handle.setTimeoutDuration(100L); - handle.setFallbackUri("fallbackUri"); - handle.setSlidingWindowSize(200); - handle.setSlidingWindowType(2); - handle.setMinimumNumberOfCalls(100); - handle.setWaitIntervalFunctionInOpenState(20); - handle.setPermittedNumberOfCallsInHalfOpenState(10); - handle.setFailureRateThreshold(60F); - handle.setAutomaticTransitionFromOpenToHalfOpenEnabled(false); - - assertThat(handle.getTimeoutDurationRate(), is(1000)); - assertThat(handle.getLimitRefreshPeriod(), is(200)); - assertThat(handle.getLimitForPeriod(), is(100)); - assertThat(handle.getCircuitEnable(), is(0)); - assertThat(handle.getTimeoutDuration(), is(100L)); - assertThat(handle.getFallbackUri(), is("fallbackUri")); - assertThat(handle.getSlidingWindowSize(), is(200)); - assertThat(handle.getSlidingWindowType(), is(2)); - assertThat(handle.getMinimumNumberOfCalls(), is(100)); - assertThat(handle.getWaitIntervalFunctionInOpenState(), is(20)); - assertThat(handle.getPermittedNumberOfCallsInHalfOpenState(), is(10)); - assertThat(handle.getFailureRateThreshold(), is(comparesEqualTo(60F))); - assertThat(handle.getAutomaticTransitionFromOpenToHalfOpenEnabled(), is(false)); - } - - @Test - public void testEqualsAndHashCode() { - Resilience4JHandle handle1 = new Resilience4JHandle(); - Resilience4JHandle handle2 = new Resilience4JHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - - @Test - public void testCheckData() { - Resilience4JHandle handle = new Resilience4JHandle(); - handle.setTimeoutDurationRate(-1); - handle.setLimitRefreshPeriod(-2); - handle.setLimitForPeriod(-3); - handle.setCircuitEnable(-4); - handle.setTimeoutDuration(-5); - handle.setFallbackUri("uri"); - handle.setSlidingWindowSize(-6); - handle.setSlidingWindowType(-7); - handle.setMinimumNumberOfCalls(-8); - handle.setWaitIntervalFunctionInOpenState(-9); - handle.setPermittedNumberOfCallsInHalfOpenState(-10); - handle.setFailureRateThreshold(-11); - - handle.checkData(handle); - - assertThat(handle.getTimeoutDurationRate(), is(Constants.TIMEOUT_DURATION_RATE)); - assertThat(handle.getLimitRefreshPeriod(), is(Constants.LIMIT_REFRESH_PERIOD)); - assertThat(handle.getLimitForPeriod(), is(Constants.LIMIT_FOR_PERIOD)); - assertThat(handle.getCircuitEnable(), is(Constants.CIRCUIT_DISABLE)); - assertThat(handle.getTimeoutDuration(), is(Constants.TIMEOUT_DURATION)); - assertThat(handle.getFallbackUri(), is("uri")); - assertThat(handle.getSlidingWindowSize(), is(Constants.SLIDING_WINDOW_SIZE)); - assertThat(handle.getSlidingWindowType(), is(Constants.SLIDING_WINDOW_TYPE)); - assertThat(handle.getMinimumNumberOfCalls(), is(Constants.MINIMUM_NUMBER_OF_CALLS)); - assertThat(handle.getWaitIntervalFunctionInOpenState(), is(Constants.WAIT_INTERVAL_FUNCTION_IN_OPEN_STATE)); - assertThat(handle.getPermittedNumberOfCallsInHalfOpenState(), is(Constants.PERMITTED_NUMBER_OF_CALLS_IN_HALF_OPEN_STATE)); - assertThat(handle.getFailureRateThreshold(), is(Constants.FAILURE_RATE_THRESHOLD)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RewriteHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RewriteHandleTest.java deleted file mode 100644 index 5ec74c0..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RewriteHandleTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for RewriteHandle. - */ -public class RewriteHandleTest { - - @Test - public void testGetterSetter() { - RewriteHandle handle = new RewriteHandle(); - handle.setRegex("regex"); - handle.setReplace("replace"); - - assertThat(handle.getRegex(), is("regex")); - assertThat(handle.getReplace(), is("replace")); - } - - @Test - public void testEqualsAndHashCode() { - RewriteHandle handle1 = new RewriteHandle(); - RewriteHandle handle2 = new RewriteHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleTest.java deleted file mode 100644 index e692723..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/RuleHandleTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import org.apache.shenyu.common.utils.GsonUtils; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class RuleHandleTest { - - @Test - public void testToJson() { - assertNotNull(new RuleTest().toJson()); - assertEquals(GsonUtils.getInstance().toJson(new RuleTest()), new RuleTest().toJson()); - } - - static class RuleTest implements RuleHandle { - - private final String id = "1"; - - private final String name = "rule-handle"; - - @Override - public String toJson() { - return RuleHandle.super.toJson(); - } - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/SentinelHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/SentinelHandleTest.java deleted file mode 100644 index 1955f4a..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/SentinelHandleTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.constant.Constants; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.number.IsCloseTo.closeTo; - -/** - * Test case for SentinelHandle. - */ -public class SentinelHandleTest { - - @Test - public void testGetterSetter() { - SentinelHandle handle = new SentinelHandle(); - handle.setFlowRuleEnable(0); - handle.setFlowRuleGrade(2); - handle.setFlowRuleCount(10); - handle.setFlowRuleControlBehavior(0); - handle.setDegradeRuleEnable(0); - handle.setDegradeRuleGrade(2); - handle.setDegradeRuleCount(Double.valueOf(10)); - handle.setDegradeRuleTimeWindow(100); - handle.setDegradeRuleMinRequestAmount(200); - handle.setDegradeRuleSlowRatioThreshold(Double.valueOf(10)); - handle.setDegradeRuleStatIntervals(100); - handle.setFallbackUri("fallbackUri"); - handle.setFlowRuleMaxQueueingTimeMs(500); - handle.setFlowRuleWarmUpPeriodSec(10); - - assertThat(handle.getFlowRuleEnable(), is(0)); - assertThat(handle.getFlowRuleGrade(), is(2)); - assertThat(handle.getFlowRuleCount(), is(10)); - assertThat(handle.getFlowRuleControlBehavior(), is(0)); - assertThat(handle.getDegradeRuleEnable(), is(0)); - assertThat(handle.getDegradeRuleGrade(), is(2)); - assertThat(handle.getDegradeRuleCount(), closeTo(10, 0.1)); - assertThat(handle.getDegradeRuleTimeWindow(), is(100)); - assertThat(handle.getDegradeRuleMinRequestAmount(), is(200)); - assertThat(handle.getDegradeRuleSlowRatioThreshold(), closeTo(10, 0.1)); - assertThat(handle.getDegradeRuleStatIntervals(), is(100)); - assertThat(handle.getFallbackUri(), is("fallbackUri")); - assertThat(handle.getFlowRuleMaxQueueingTimeMs(), is(500)); - assertThat(handle.getFlowRuleWarmUpPeriodSec(), is(10)); - } - - @Test - public void testEqualsAndHashCode() { - SentinelHandle handle1 = new SentinelHandle(); - SentinelHandle handle2 = new SentinelHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - - @Test - public void testCheckData() { - SentinelHandle handle = new SentinelHandle(); - handle.setFlowRuleEnable(0); - handle.setDegradeRuleEnable(1); - - handle.checkData(); - - assertThat(handle.getFlowRuleEnable(), is(0)); - assertThat(handle.getDegradeRuleEnable(), is(1)); - - handle.setFlowRuleEnable(-1); - handle.setDegradeRuleEnable(3); - - handle.checkData(); - - assertThat(handle.getFlowRuleEnable(), is(Constants.SENTINEL_ENABLE_FLOW_RULE)); - assertThat(handle.getDegradeRuleEnable(), is(Constants.SENTINEL_ENABLE_DEGRADE_RULE)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/WafHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/WafHandleTest.java deleted file mode 100644 index 245a1f8..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/WafHandleTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for WafHandle. - */ -public class WafHandleTest { - - @Test - public void testGetterSetter() { - WafHandle handle = new WafHandle(); - handle.setPermission("permission"); - handle.setStatusCode("status"); - - assertThat(handle.getPermission(), is("permission")); - assertThat(handle.getStatusCode(), is("status")); - } - - @Test - public void testEqualsAndHashCode() { - WafHandle handle1 = new WafHandle(); - WafHandle handle2 = new WafHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/CacheRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/CacheRuleHandleTest.java deleted file mode 100644 index 06d1f6f..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/CacheRuleHandleTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -/** - * Test case for CacheRuleHandle. - */ -public class CacheRuleHandleTest { - - @Test - public void testGetterSetter() { - CacheRuleHandle handle = new CacheRuleHandle(); - - handle.setTimeoutSeconds(120L); - - assertThat(handle.getTimeoutSeconds(), is(120L)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingRuleHandleTest.java deleted file mode 100644 index 1e49184..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ContextMappingRuleHandleTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for ContextMappingRuleHandle. - */ -public class ContextMappingRuleHandleTest { - - @Test - public void testGetterSetter() { - ContextMappingRuleHandle handle = new ContextMappingRuleHandle(); - - handle.setAddPrefix("addPrefix"); - handle.setContextPath("contextPath"); - - assertThat(handle.getAddPrefix(), is("addPrefix")); - assertThat(handle.getContextPath(), is("contextPath")); - } - - @Test - public void testEqualsAndHashCode() { - ContextMappingRuleHandle handle1 = new ContextMappingRuleHandle(); - ContextMappingRuleHandle handle2 = new ContextMappingRuleHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandleTest.java deleted file mode 100644 index 1b11ee1..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/DivideRuleHandleTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.enums.LoadBalanceEnum; -import org.apache.shenyu.common.enums.RetryEnum; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for DivideRuleHandle. - */ -public class DivideRuleHandleTest { - - @Test - public void testGetterSetter() { - DivideRuleHandle handle = new DivideRuleHandle(); - - handle.setLoadBalance(LoadBalanceEnum.HASH.getName()); - handle.setRetryStrategy(RetryEnum.FAILOVER.getName()); - handle.setRetry(1); - handle.setTimeout(1000L); - handle.setHeaderMaxSize(100L); - handle.setRequestMaxSize(200L); - - assertThat(handle.getLoadBalance(), is(LoadBalanceEnum.HASH.getName())); - assertThat(handle.getRetryStrategy(), is(RetryEnum.FAILOVER.getName())); - assertThat(handle.getRetry(), is(1)); - assertThat(handle.getTimeout(), is(1000L)); - assertThat(handle.getHeaderMaxSize(), is(100L)); - assertThat(handle.getRequestMaxSize(), is(200L)); - } - - @Test - public void testEqualsAndHashCode() { - DivideRuleHandle handle1 = new DivideRuleHandle(); - DivideRuleHandle handle2 = new DivideRuleHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandleTest.java deleted file mode 100644 index 6ed9c41..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/DubboRuleHandleTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.enums.LoadBalanceEnum; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for DubboRuleHandle. - */ -public class DubboRuleHandleTest { - - @Test - public void testGetterSetter() { - DubboRuleHandle handle = new DubboRuleHandle(); - - handle.setLoadBalance(LoadBalanceEnum.HASH.getName()); - handle.setTimeout(1000L); - handle.setVersion("version"); - handle.setGroup("group"); - handle.setRetries(10); - - assertThat(handle.getLoadBalance(), is(LoadBalanceEnum.HASH.getName())); - assertThat(handle.getTimeout(), is(1000L)); - assertThat(handle.getVersion(), is("version")); - assertThat(handle.getGroup(), is("group")); - assertThat(handle.getRetries(), is(10)); - } - - @Test - public void testEqualsAndHashCode() { - DubboRuleHandle handle1 = new DubboRuleHandle(); - DubboRuleHandle handle2 = new DubboRuleHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/KeyAuthRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/KeyAuthRuleHandleTest.java deleted file mode 100644 index a0a0b59..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/KeyAuthRuleHandleTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test cases for {@link KeyAuthRuleHandle}. - */ -public class KeyAuthRuleHandleTest { - - @Test - public void testGetterAndSetter() { - KeyAuthRuleHandle keyAuthRuleHandle = new KeyAuthRuleHandle(); - - keyAuthRuleHandle.setKeyName("apiKey"); - keyAuthRuleHandle.setKey("123456"); - - assertEquals(keyAuthRuleHandle.getKeyName(), "apiKey"); - assertEquals(keyAuthRuleHandle.getKey(), "123456"); - - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java deleted file mode 100644 index 695c425..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.dto.convert.rule.impl.ParamMappingRuleHandle.ParamMapInfo; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; - -/** - * Test case for ModifyResponseRuleHandle. - */ -public class ModifyResponseRuleHandleTest { - - @Test - public void testGetterSetter() { - ModifyResponseRuleHandle handle = new ModifyResponseRuleHandle(); - - handle.setAddHeaders(new HashMap<>()); - handle.setSetHeaders(new HashMap<>()); - handle.setReplaceHeaderKeys(new HashMap<>()); - handle.setRemoveHeaderKeys(new HashSet<>()); - handle.setStatusCode(1); - handle.setAddBodyKeys(Collections.singletonList(new ParamMapInfo())); - handle.setReplaceBodyKeys(Collections.singletonList(new ParamMapInfo())); - handle.setRemoveBodyKeys(new HashSet<>()); - - assertThat(handle.getAddHeaders(), is(notNullValue())); - assertThat(handle.getSetHeaders(), is(notNullValue())); - assertThat(handle.getReplaceHeaderKeys(), is(notNullValue())); - assertThat(handle.getRemoveHeaderKeys(), is(notNullValue())); - assertThat(handle.getRemoveBodyKeys(), is(notNullValue())); - assertThat(handle.getStatusCode(), is(1)); - assertThat(handle.getAddBodyKeys(), hasSize(1)); - assertThat(handle.getReplaceBodyKeys(), hasSize(1)); - } - - @Test - public void testEqualsAndHashCode() { - ModifyResponseRuleHandle handle1 = new ModifyResponseRuleHandle(); - ModifyResponseRuleHandle handle2 = new ModifyResponseRuleHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandleTest.java deleted file mode 100644 index 90dada1..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandleTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.dto.convert.rule.impl.ParamMappingRuleHandle.ParamMapInfo; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.HashSet; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; - -/** - * Test case for ParamMappingRuleHandle. - */ -public class ParamMappingRuleHandleTest { - - @Test - public void testGetterSetterOfParamMapInfo() { - ParamMappingRuleHandle.ParamMapInfo paramMapInfo = new ParamMappingRuleHandle.ParamMapInfo(); - - paramMapInfo.setKey("key"); - paramMapInfo.setPath("path"); - paramMapInfo.setValue("value"); - - assertThat(paramMapInfo.getKey(), is("key")); - assertThat(paramMapInfo.getPath(), is("path")); - assertThat(paramMapInfo.getValue(), is("value")); - } - - @Test - public void testGetterSetter() { - ParamMappingRuleHandle handle = new ParamMappingRuleHandle(); - - handle.setRemoveParameterKeys(new HashSet<>()); - handle.setReplaceParameterKeys(Collections.singletonList(new ParamMapInfo())); - handle.setAddParameterKeys(Collections.singletonList(new ParamMapInfo())); - - assertThat(handle.getRemoveParameterKeys(), is(notNullValue())); - assertThat(handle.getReplaceParameterKeys(), is(notNullValue())); - assertThat(handle.getAddParameterKeys(), is(notNullValue())); - } - - @Test - public void testEqualsAndHashCode() { - ParamMappingRuleHandle handle1 = new ParamMappingRuleHandle(); - ParamMappingRuleHandle handle2 = new ParamMappingRuleHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandleTest.java deleted file mode 100644 index 70d06f7..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/SofaRuleHandleTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.enums.LoadBalanceEnum; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for SofaRuleHandle. - */ -public class SofaRuleHandleTest { - - @Test - public void testGetterSetter() { - SofaRuleHandle handle = new SofaRuleHandle(); - - handle.setRetries(10); - handle.setLoadBalance(LoadBalanceEnum.HASH.getName()); - handle.setTimeout(200L); - - assertThat(handle.getTimeout(), is(200L)); - assertThat(handle.getRetries(), is(10)); - assertThat(handle.getLoadBalance(), is(LoadBalanceEnum.HASH.getName())); - } - - @Test - public void testEqualsAndHashCode() { - SofaRuleHandle handle1 = new SofaRuleHandle(); - SofaRuleHandle handle2 = new SofaRuleHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandleTest.java deleted file mode 100644 index 02dc881..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/SpringCloudRuleHandleTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.enums.LoadBalanceEnum; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for SpringCloudRuleHandle. - */ -public class SpringCloudRuleHandleTest { - - @Test - public void testGetterSetter() { - SpringCloudRuleHandle handle = new SpringCloudRuleHandle(); - - handle.setPath("path"); - handle.setTimeout(1000L); - handle.setLoadBalance(LoadBalanceEnum.HASH.getName()); - - assertThat(handle.getPath(), is("path")); - assertThat(handle.getTimeout(), is(1000L)); - assertThat(handle.getLoadBalance(), is(LoadBalanceEnum.HASH.getName())); - } - - @Test - public void testEqualsAndHashCode() { - SpringCloudRuleHandle handle1 = new SpringCloudRuleHandle(); - SpringCloudRuleHandle handle2 = new SpringCloudRuleHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandleTest.java deleted file mode 100644 index de8999a..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/WebSocketRuleHandleTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.rule.impl; - -import com.google.common.collect.ImmutableSet; -import org.apache.shenyu.common.enums.LoadBalanceEnum; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for WebSocketRuleHandle. - */ -public class WebSocketRuleHandleTest { - - @Test - public void testGetterSetter() { - WebSocketRuleHandle handle = new WebSocketRuleHandle(); - - handle.setLoadBalance(LoadBalanceEnum.HASH.getName()); - handle.setRetry(10); - handle.setTimeout(1000L); - - assertThat(handle.getLoadBalance(), is(LoadBalanceEnum.HASH.getName())); - assertThat(handle.getRetry(), is(10)); - assertThat(handle.getTimeout(), is(1000L)); - } - - @Test - public void testEqualsAndHashCode() { - WebSocketRuleHandle handle1 = new WebSocketRuleHandle(); - WebSocketRuleHandle handle2 = new WebSocketRuleHandle(); - - assertThat(ImmutableSet.of(handle1, handle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/CommonUpstreamTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/CommonUpstreamTest.java deleted file mode 100644 index 83c13fd..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/CommonUpstreamTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for CommonUpstream. - */ -public class CommonUpstreamTest { - - @Test - public void testGetterSetter() { - CommonUpstream upstream = new CommonUpstream(); - upstream.setProtocol("protocol"); - upstream.setUpstreamHost("host"); - upstream.setUpstreamUrl("url"); - upstream.setStatus(true); - upstream.setTimestamp(1650549243L); - - assertThat(upstream.getProtocol(), is("protocol")); - assertThat(upstream.getUpstreamHost(), is("host")); - assertThat(upstream.getUpstreamUrl(), is("url")); - assertThat(upstream.isStatus(), is(true)); - assertThat(upstream.getTimestamp(), is(1650549243L)); - } - - @Test - public void testEqualsAndHashCode() { - CommonUpstream upstream1 = new CommonUpstream("protocol", "host", "url", true, System.currentTimeMillis()); - CommonUpstream upstream2 = new CommonUpstream("protocol", "host", "url", true, System.currentTimeMillis()); - - assertThat(ImmutableSet.of(upstream1, upstream2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/DivideUpstreamTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/DivideUpstreamTest.java deleted file mode 100644 index 001b93e..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/DivideUpstreamTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for DivideUpstream. - */ -public class DivideUpstreamTest { - - @Test - public void testBuilderAndGetterSetter() { - DivideUpstream upstream = DivideUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).weight(100).build(); - - assertThat(upstream.getWeight(), is(100)); - assertThat(upstream.getWarmup(), is(50)); - - upstream.setWeight(50); - upstream.setWarmup(100); - - assertThat(upstream.getWeight(), is(50)); - assertThat(upstream.getWarmup(), is(100)); - } - - @Test - public void testEqualsAndHashCode() { - DivideUpstream upstream1 = DivideUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).weight(100).build(); - DivideUpstream upstream2 = DivideUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).weight(100).build(); - - assertThat(ImmutableSet.of(upstream1, upstream2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstreamTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstreamTest.java deleted file mode 100644 index acb140c..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstreamTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for DubboUpstream. - */ -public class DubboUpstreamTest { - - @Test - public void testBuilderAndGetterSetter() { - DubboUpstream upstream = DubboUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).weight(100).build(); - - upstream.setRegistry("reg"); - upstream.setAppName("appName"); - upstream.setPort(9080); - upstream.setGray(true); - upstream.setGroup("group"); - upstream.setVersion("version"); - upstream.setWeight(50); - upstream.setWarmup(100); - - assertThat(upstream.getRegistry(), is("reg")); - assertThat(upstream.getAppName(), is("appName")); - assertThat(upstream.getPort(), is(9080)); - assertThat(upstream.isGray(), is(true)); - assertThat(upstream.getGroup(), is("group")); - assertThat(upstream.getVersion(), is("version")); - assertThat(upstream.getWeight(), is(50)); - assertThat(upstream.getWarmup(), is(100)); - } - - @Test - public void testEqualsAndHashCode() { - DubboUpstream upstream1 = DubboUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).weight(100).build(); - DubboUpstream upstream2 = DubboUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).weight(100).build(); - - assertThat(ImmutableSet.of(upstream1, upstream2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/GrpcUpstreamTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/GrpcUpstreamTest.java deleted file mode 100644 index d8130fd..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/GrpcUpstreamTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for GrpcUpstream. - */ -public class GrpcUpstreamTest { - - @Test - public void testBuilderAndGetterSetter() { - GrpcUpstream upstream = GrpcUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).timestamp(1650549243L).build(); - - upstream.setWeight(50); - - assertThat(upstream.getWeight(), is(50)); - } - - @Test - public void testEqualsAndHashCode() { - GrpcUpstream upstream1 = GrpcUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).timestamp(1650549243L).build(); - GrpcUpstream upstream2 = GrpcUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).timestamp(1650549243L).build(); - - assertThat(ImmutableSet.of(upstream1, upstream2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandleTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandleTest.java deleted file mode 100644 index 5c5198b..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandleTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.Collections; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for SpringCloudSelectorHandle. - */ -public class SpringCloudSelectorHandleTest { - - @Test - public void testBuilderAndGetterSetter() { - SpringCloudSelectorHandle selectorHandle = SpringCloudSelectorHandle.builder().serviceId("serviceId") - .gray(true).divideUpstreams(Collections.singletonList(new DivideUpstream())).build(); - - selectorHandle.setServiceId("serviceId1"); - selectorHandle.setGray(false); - selectorHandle.setDivideUpstreams(Arrays.asList(new DivideUpstream(), new DivideUpstream())); - - assertThat(selectorHandle.getGray(), is(false)); - assertThat(selectorHandle.getServiceId(), is("serviceId1")); - assertThat(selectorHandle.getDivideUpstreams(), hasSize(2)); - } - - @Test - public void testEqualsAndHashCode() { - SpringCloudSelectorHandle selectorHandle1 = SpringCloudSelectorHandle.builder().serviceId("serviceId").build(); - SpringCloudSelectorHandle selectorHandle2 = SpringCloudSelectorHandle.builder().serviceId("serviceId").build(); - - assertThat(ImmutableSet.of(selectorHandle1, selectorHandle2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/TarsUpstreamTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/TarsUpstreamTest.java deleted file mode 100644 index d9059dd..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/TarsUpstreamTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for TarsUpstream. - */ -public class TarsUpstreamTest { - - @Test - public void testBuilderAndGetterSetter() { - TarsUpstream upstream = TarsUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).build(); - - upstream.setWeight(50); - upstream.setWarmup(100); - - assertThat(upstream.getWeight(), is(50)); - assertThat(upstream.getWarmup(), is(100)); - } - - @Test - public void testEqualsAndHashCode() { - TarsUpstream upstream1 = TarsUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).build(); - TarsUpstream upstream2 = TarsUpstream.builder().protocol("protocol").upstreamHost("host").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).build(); - - assertThat(ImmutableSet.of(upstream1, upstream2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/WebSocketUpstreamTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/WebSocketUpstreamTest.java deleted file mode 100644 index b117c02..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/WebSocketUpstreamTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.core.Is.is; - -/** - * Test case for WebSocketUpstream. - */ -public class WebSocketUpstreamTest { - - @Test - public void testBuilderAndGetterSetter() { - WebSocketUpstream upstream = WebSocketUpstream.builder().protocol("protocol").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).build(); - - upstream.setWeight(50); - upstream.setWarmup(100); - upstream.setHost("host"); - upstream.setUrl("url"); - - assertThat(upstream.getWeight(), is(50)); - assertThat(upstream.getWarmup(), is(100)); - assertThat(upstream.getHost(), is("host")); - assertThat(upstream.getUrl(), is("url")); - } - - @Test - public void testEqualsAndHashCode() { - WebSocketUpstream upstream1 = WebSocketUpstream.builder().protocol("protocol").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).build(); - WebSocketUpstream upstream2 = WebSocketUpstream.builder().protocol("protocol").upstreamUrl("url") - .status(true).warmup(50).timestamp(1650549243L).build(); - - assertThat(ImmutableSet.of(upstream1, upstream2), hasSize(1)); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/ZombieUpstreamTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/ZombieUpstreamTest.java deleted file mode 100644 index 2a0b213..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/ZombieUpstreamTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.dto.convert.selector; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * Test case for ZombieUpstream. - */ -public class ZombieUpstreamTest { - - @Test - public void testBuilderAndGetterSetter() { - ZombieUpstream upstream = ZombieUpstream.builder().selectorId("id").zombieCheckTimes(10) - .commonUpstream(new CommonUpstream()).build(); - - upstream.setSelectorName("newId"); - upstream.setZombieCheckTimes(5); - upstream.setCommonUpstream(null); - - assertThat(upstream.getSelectorId(), is("newId")); - assertThat(upstream.getZombieCheckTimes(), is(5)); - assertThat(upstream.getCommonUpstream(), is(nullValue())); - } - - @Test - public void testEqualsAndHashCode() { - CommonUpstream commonUpstream = new CommonUpstream(); - commonUpstream.setProtocol("protocol"); - commonUpstream.setUpstreamHost("host"); - commonUpstream.setUpstreamUrl("url"); - commonUpstream.setStatus(true); - commonUpstream.setTimestamp(1650549243L); - - ZombieUpstream upstream1 = ZombieUpstream.builder().selectorId("id").zombieCheckTimes(10) - .commonUpstream(commonUpstream).build(); - ZombieUpstream upstream2 = ZombieUpstream.builder().selectorId("id").zombieCheckTimes(10) - .commonUpstream(commonUpstream).build(); - - assertThat(ImmutableSet.of(upstream1, upstream2), hasSize(1)); - } - - @Test - public void testTransform() { - ZombieUpstream upstream = ZombieUpstream.transform(new CommonUpstream(), 10, "id"); - - assertThat(upstream, is(notNullValue())); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminDataPermissionTypeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminDataPermissionTypeEnumTest.java deleted file mode 100644 index 4a07352..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminDataPermissionTypeEnumTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class AdminDataPermissionTypeEnumTest { - - @Test - public void testEvent() { - Arrays.stream(AdminDataPermissionTypeEnum.values()) - .forEach(adminData -> assertEquals(adminData, AdminDataPermissionTypeEnum.valueOf(adminData.name()))); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminDataSourceEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminDataSourceEnumTest.java deleted file mode 100644 index 4b54670..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminDataSourceEnumTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class AdminDataSourceEnumTest { - - @Test - public void testName() { - assertEquals("h2", AdminDataSourceEnum.H2.getValue()); - assertEquals("mysql", AdminDataSourceEnum.MYSQL.getValue()); - assertEquals("postgresql", AdminDataSourceEnum.POSTGRESQL.getValue()); - assertEquals("oracle", AdminDataSourceEnum.ORACLE.getValue()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminPluginOperateEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminPluginOperateEnumTest.java deleted file mode 100644 index d55c9f0..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminPluginOperateEnumTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class AdminPluginOperateEnumTest { - @Test - public void testName() { - assertEquals("add", AdminPluginOperateEnum.ADD.getName()); - assertEquals("delete", AdminPluginOperateEnum.DELETE.getName()); - assertEquals("edit", AdminPluginOperateEnum.EDIT.getName()); - assertEquals("query", AdminPluginOperateEnum.QUERY.getName()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminResourceEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminResourceEnumTest.java deleted file mode 100644 index 5d34e70..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/AdminResourceEnumTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class AdminResourceEnumTest { - @Test - public void testGetCode() { - assertEquals(0, AdminResourceEnum.MAIN_MENU.getCode()); - assertEquals(1, AdminResourceEnum.SECOND_MENU.getCode()); - assertEquals(2, AdminResourceEnum.THREE_MENU.getCode()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiHttpMethodEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiHttpMethodEnumTest.java deleted file mode 100644 index 32d616c..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiHttpMethodEnumTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.apache.shenyu.common.exception.ShenyuException; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * Test Cases for ApiHttpMethodEnum. - */ -public class ApiHttpMethodEnumTest { - - @Test - public void testGetName() { - Arrays.stream(ApiHttpMethodEnum.values()) - .forEach(apiHttpMethodEnum -> assertEquals(apiHttpMethodEnum.toString(), ApiHttpMethodEnum.valueOf(apiHttpMethodEnum.name()).getName())); - } - - @Test - public void testGetValue() { - assertEquals(0, ApiHttpMethodEnum.GET.getValue()); - assertEquals(1, ApiHttpMethodEnum.HEAD.getValue()); - assertEquals(2, ApiHttpMethodEnum.POST.getValue()); - assertEquals(3, ApiHttpMethodEnum.PUT.getValue()); - assertEquals(4, ApiHttpMethodEnum.PATCH.getValue()); - assertEquals(5, ApiHttpMethodEnum.DELETE.getValue()); - assertEquals(6, ApiHttpMethodEnum.OPTIONS.getValue()); - assertEquals(7, ApiHttpMethodEnum.TRACE.getValue()); - assertEquals(8, ApiHttpMethodEnum.NOT_HTTP.getValue()); - } - - @Test - public void testGetValueByName() { - assertEquals(0, ApiHttpMethodEnum.getValueByName("GET")); - assertEquals(1, ApiHttpMethodEnum.getValueByName("HEAD")); - assertEquals(2, ApiHttpMethodEnum.getValueByName("POST")); - assertEquals(3, ApiHttpMethodEnum.getValueByName("PUT")); - assertEquals(4, ApiHttpMethodEnum.getValueByName("PATCH")); - assertEquals(5, ApiHttpMethodEnum.getValueByName("DELETE")); - assertEquals(6, ApiHttpMethodEnum.getValueByName("OPTIONS")); - assertEquals(7, ApiHttpMethodEnum.getValueByName("TRACE")); - assertEquals(8, ApiHttpMethodEnum.getValueByName("NOT_HTTP")); - } - - @Test - public void testGetValueByNameException() { - assertThrows(ShenyuException.class, () -> ApiHttpMethodEnum.getValueByName("abc")); - } - - @Test - public void testOf() { - Arrays.stream(ApiHttpMethodEnum.values()) - .forEach(apiHttpMethodEnum -> assertEquals(apiHttpMethodEnum, ApiHttpMethodEnum.of(apiHttpMethodEnum.name()))); - } - - @Test - public void testOfException() { - assertThrows(ShenyuException.class, () -> ApiHttpMethodEnum.of("abc")); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiSourceEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiSourceEnumTest.java deleted file mode 100644 index 1fbab23..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiSourceEnumTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test Cases for ApiSourceEnum. - */ -public class ApiSourceEnumTest { - - @Test - public void testGetName() { - assertEquals("swagger", ApiSourceEnum.SWAGGER.getName()); - assertEquals("annotation_generation", ApiSourceEnum.ANNOTATION_GENERATION.getName()); - assertEquals("create_manually", ApiSourceEnum.CREATE_MANUALLY.getName()); - assertEquals("import_swagger", ApiSourceEnum.IMPORT_SWAGGER.getName()); - assertEquals("import_yapi", ApiSourceEnum.IMPORT_YAPI.getName()); - } - - @Test - public void testGetValue() { - assertEquals(0, ApiSourceEnum.SWAGGER.getValue()); - assertEquals(1, ApiSourceEnum.ANNOTATION_GENERATION.getValue()); - assertEquals(2, ApiSourceEnum.CREATE_MANUALLY.getValue()); - assertEquals(3, ApiSourceEnum.IMPORT_SWAGGER.getValue()); - assertEquals(4, ApiSourceEnum.IMPORT_YAPI.getValue()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiStateEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiStateEnumTest.java deleted file mode 100644 index c596e11..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ApiStateEnumTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test Cases for ApiStateEnum. - */ -public class ApiStateEnumTest { - - @Test - public void testGetState() { - assertEquals(0, ApiStateEnum.UNPUBLISHED.getState()); - assertEquals(1, ApiStateEnum.PUBLISHED.getState()); - assertEquals(2, ApiStateEnum.OFFLINE.getState()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ConfigGroupEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ConfigGroupEnumTest.java deleted file mode 100644 index 475f888..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ConfigGroupEnumTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.apache.shenyu.common.exception.ShenyuException; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.not; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * Test Cases for ConfigGroupEnum. - */ -public final class ConfigGroupEnumTest { - - @Test - public void testAcquireByName() { - assertThat(ConfigGroupEnum.APP_AUTH, equalTo(ConfigGroupEnum.acquireByName(ConfigGroupEnum.APP_AUTH.name()))); - assertThat(ConfigGroupEnum.APP_AUTH, not(ConfigGroupEnum.acquireByName(ConfigGroupEnum.PLUGIN.name()))); - - Exception exception = assertThrows(ShenyuException.class, () -> ConfigGroupEnum.acquireByName("unknown")); - assertEquals(" this ConfigGroupEnum can not support unknown", exception.getMessage()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/DataEventTypeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/DataEventTypeEnumTest.java deleted file mode 100644 index f3c8d5f..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/DataEventTypeEnumTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.apache.shenyu.common.exception.ShenyuException; -import org.hamcrest.Matchers; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; - - -/** - * Test Cases for DataEventTypeEnum. - */ -public final class DataEventTypeEnumTest { - - @Test - public void testGetDataEventTypeByName() { - Arrays.stream(DataEventTypeEnum.values()) - .forEach(e -> assertThat(e, Matchers.equalTo(DataEventTypeEnum.acquireByName(e.name())))); - } - - @Test - public void testAcquireByNameInvalid() { - assertThrows(ShenyuException.class, () -> DataEventTypeEnum.acquireByName("invalidName")); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/DataSyncEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/DataSyncEnumTest.java deleted file mode 100644 index 14942b1..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/DataSyncEnumTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test Cases for DataSyncEnum. - */ -public final class DataSyncEnumTest { - - @Test - public void testAcquireByName() { - assertEquals(DataSyncEnum.HTTP, DataSyncEnum.acquireByName(DataSyncEnum.HTTP.getName())); - assertEquals(DataSyncEnum.ZOOKEEPER, DataSyncEnum.acquireByName(DataSyncEnum.ZOOKEEPER.getName())); - assertEquals(DataSyncEnum.WEBSOCKET, DataSyncEnum.acquireByName(DataSyncEnum.WEBSOCKET.getName())); - assertEquals(DataSyncEnum.HTTP, DataSyncEnum.acquireByName(null)); - assertEquals(DataSyncEnum.HTTP, DataSyncEnum.acquireByName("")); - String notExist = "N"; - assertEquals(DataSyncEnum.HTTP, DataSyncEnum.acquireByName(notExist)); - - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/HttpMethodEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/HttpMethodEnumTest.java deleted file mode 100644 index a2c6330..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/HttpMethodEnumTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import java.util.Arrays; -import org.apache.shenyu.common.exception.ShenyuException; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** Test Cases for HttpMethodEnum. */ -public final class HttpMethodEnumTest { - - @Test - public void testGetName() { - assertEquals("delete", HttpMethodEnum.DELETE.getName()); - assertEquals("get", HttpMethodEnum.GET.getName()); - assertEquals("post", HttpMethodEnum.POST.getName()); - assertEquals("put", HttpMethodEnum.PUT.getName()); - } - - @Test - public void testSupport() { - assertTrue(HttpMethodEnum.DELETE.getSupport()); - assertTrue(HttpMethodEnum.GET.getSupport()); - assertTrue(HttpMethodEnum.POST.getSupport()); - assertTrue(HttpMethodEnum.PUT.getSupport()); - } - - @Test - public void testAcquireByNameValid() { - Arrays.stream(HttpMethodEnum.values()) - .forEach(e -> assertEquals(e, HttpMethodEnum.acquireByName(e.getName()))); - } - - @Test - public void testAcquireByNameInvalid() { - String httpMethodName = "InvalidName"; - assertThrows(ShenyuException.class, () -> HttpMethodEnum.acquireByName(httpMethodName)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnumTest.java deleted file mode 100644 index 8210275..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/HystrixIsolationModeEnumTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test case for HystrixIsolationModeEnum. - */ -public final class HystrixIsolationModeEnumTest { - - @Test - public void testGetCode() { - assertEquals(0, HystrixIsolationModeEnum.THREAD_POOL.getCode()); - assertEquals(1, HystrixIsolationModeEnum.SEMAPHORE.getCode()); - } - - @Test - public void testGetName() { - assertEquals("thread", HystrixIsolationModeEnum.THREAD_POOL.getName()); - assertEquals("semaphore", HystrixIsolationModeEnum.SEMAPHORE.getName()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/LoadBalanceEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/LoadBalanceEnumTest.java deleted file mode 100644 index d4a5c67..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/LoadBalanceEnumTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test case for LoadBalanceEnum. - */ -public final class LoadBalanceEnumTest { - - @Test - public void testHashLoadBalance() { - assertEquals(1, LoadBalanceEnum.HASH.getCode()); - assertEquals("hash", LoadBalanceEnum.HASH.getName()); - assertTrue(LoadBalanceEnum.HASH.isSupport()); - } - - @Test - public void testRandomLoadBalance() { - assertEquals(2, LoadBalanceEnum.RANDOM.getCode()); - assertEquals("random", LoadBalanceEnum.RANDOM.getName()); - assertTrue(LoadBalanceEnum.RANDOM.isSupport()); - } - - @Test - public void testRoundRobinLoadBalance() { - assertEquals(3, LoadBalanceEnum.ROUND_ROBIN.getCode()); - assertEquals("roundRobin", LoadBalanceEnum.ROUND_ROBIN.getName()); - assertTrue(LoadBalanceEnum.ROUND_ROBIN.isSupport()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/MatchModeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/MatchModeEnumTest.java deleted file mode 100644 index 5a7619b..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/MatchModeEnumTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; - -/** - * Test Cases for MatchModeEnum. - */ -public final class MatchModeEnumTest { - - @Test - public void testGetMatchModeByCode() { - MatchModeEnum andModeEnum = MatchModeEnum.AND; - String andEnumName = MatchModeEnum.getMatchModeByCode(andModeEnum.getCode()); - MatchModeEnum orModeEnum = MatchModeEnum.OR; - String orEnumName = MatchModeEnum.getMatchModeByCode(orModeEnum.getCode()); - assertEquals(andModeEnum.getName(), andEnumName); - assertEquals(orModeEnum.getName(), orEnumName); - assertNotEquals(andEnumName, orEnumName); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/OperatorEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/OperatorEnumTest.java deleted file mode 100644 index b4e8c03..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/OperatorEnumTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertEquals; - - -/** - * Test Cases for OperatorEnum. - */ -public final class OperatorEnumTest { - - /** - * test acquireSupport method. - */ - @Test - public void testAcquireSupport() { - List enums = OperatorEnum.acquireSupport(); - assertTrue(enums.contains(OperatorEnum.MATCH)); - assertTrue(enums.contains(OperatorEnum.EQ)); - assertTrue(enums.contains(OperatorEnum.REGEX)); - assertTrue(enums.contains(OperatorEnum.CONTAINS)); - assertTrue(enums.contains(OperatorEnum.PATH_PATTERN)); - assertTrue(enums.contains(OperatorEnum.TIME_BEFORE)); - assertTrue(enums.contains(OperatorEnum.TIME_AFTER)); - assertTrue(enums.contains(OperatorEnum.STARTS_WITH)); - assertTrue(enums.contains(OperatorEnum.ENDS_WITH)); - assertTrue(enums.contains(OperatorEnum.EXCLUDE)); - assertFalse(enums.contains(OperatorEnum.GT)); - assertFalse(enums.contains(OperatorEnum.LT)); - } - - /** - * test getOperatorEnumByAlias method. - */ - @Test - public void testAcquireByNameInvalid() { - assertEquals(OperatorEnum.MATCH, OperatorEnum.getOperatorEnumByAlias("match")); - assertEquals(OperatorEnum.EQ, OperatorEnum.getOperatorEnumByAlias("=")); - assertEquals(OperatorEnum.REGEX, OperatorEnum.getOperatorEnumByAlias("regex")); - assertEquals(OperatorEnum.CONTAINS, OperatorEnum.getOperatorEnumByAlias("contains")); - } - - @Test - public void testGetSupport() { - Arrays.stream(OperatorEnum.values()) - .forEach(operatorEnum -> assertEquals(operatorEnum.getSupport(), OperatorEnum.valueOf(operatorEnum.name()).getSupport())); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ParamTypeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ParamTypeEnumTest.java deleted file mode 100644 index 1acc6fc..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ParamTypeEnumTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test Cases for ParamTypeEnum. - */ -public final class ParamTypeEnumTest { - - @Test - public void testGetName() { - assertEquals("cookie", ParamTypeEnum.COOKIE.getName()); - assertEquals("req_method", ParamTypeEnum.REQUEST_METHOD.getName()); - assertEquals("header", ParamTypeEnum.HEADER.getName()); - assertEquals("ip", ParamTypeEnum.IP.getName()); - assertEquals("host", ParamTypeEnum.HOST.getName()); - assertEquals("query", ParamTypeEnum.QUERY.getName()); - assertEquals("uri", ParamTypeEnum.URI.getName()); - assertEquals("post", ParamTypeEnum.POST.getName()); - assertEquals("form-data", ParamTypeEnum.FORM_DATA.getName()); - assertEquals("path", ParamTypeEnum.PATH.getName()); - } - - @Test - public void testSupport() { - assertTrue(ParamTypeEnum.COOKIE.getSupport()); - assertTrue(ParamTypeEnum.REQUEST_METHOD.getSupport()); - assertTrue(ParamTypeEnum.HEADER.getSupport()); - assertTrue(ParamTypeEnum.IP.getSupport()); - assertTrue(ParamTypeEnum.HOST.getSupport()); - assertTrue(ParamTypeEnum.QUERY.getSupport()); - assertTrue(ParamTypeEnum.URI.getSupport()); - assertTrue(ParamTypeEnum.POST.getSupport()); - assertTrue(ParamTypeEnum.FORM_DATA.getSupport()); - } - - @Test - public void testAcquireSupport() { - List supportParamTypeList = - Arrays.stream(ParamTypeEnum.values()) - .filter(ParamTypeEnum::getSupport) - .collect(Collectors.toList()); - assertEquals(ParamTypeEnum.acquireSupport(), supportParamTypeList); - } - - @Test - public void testGetParamTypeEnumByNameValid() { - Arrays.stream(ParamTypeEnum.values()) - .filter(ParamTypeEnum::getSupport) - .forEach(paramTypeEnum -> assertEquals( - paramTypeEnum, ParamTypeEnum.getParamTypeEnumByName(paramTypeEnum.getName()))); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginEnumTest.java deleted file mode 100644 index 03efac4..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginEnumTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test Cases for PluginEnum. - */ -public final class PluginEnumTest { - - @Test - public void testGetPluginEnumByName() { - Arrays.stream(PluginEnum.values()) - .forEach(pluginEnum -> assertEquals(pluginEnum, PluginEnum.getPluginEnumByName(pluginEnum.getName()))); - } - - @Test - public void testGetPluginEnumByNameInvalid() { - assertEquals(PluginEnum.GLOBAL, PluginEnum.getPluginEnumByName("invalidName")); - } - - @Test - public void testGetUpstreamNames() { - List list = PluginEnum.getUpstreamNames(); - assert !list.isEmpty(); - } - - @Test - public void testGetCode() { - Arrays.stream(PluginEnum.values()) - .forEach(pluginEnum -> assertEquals(pluginEnum.getCode(), PluginEnum.getPluginEnumByName(pluginEnum.getName()).getCode())); - } - - @Test - public void testGetRole() { - Arrays.stream(PluginEnum.values()) - .forEach(pluginEnum -> assertEquals(pluginEnum.getRole(), PluginEnum.getPluginEnumByName(pluginEnum.getName()).getRole())); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginHandlerEventEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginHandlerEventEnumTest.java deleted file mode 100644 index a3a7f63..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginHandlerEventEnumTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class PluginHandlerEventEnumTest { - - @Test - public void testEvent() { - Arrays.stream(PluginHandlerEventEnum.values()) - .forEach(pluginHandler -> assertEquals(pluginHandler, PluginHandlerEventEnum.valueOf(pluginHandler.name()))); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginRoleEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginRoleEnumTest.java deleted file mode 100644 index 129d6e8..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginRoleEnumTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test Cases for PluginRoleEnum. - */ -public final class PluginRoleEnumTest { - - @Test - public void testGetCode() { - assertEquals(0, PluginRoleEnum.SYS.getCode().intValue()); - assertEquals(1, PluginRoleEnum.CUSTOM.getCode().intValue()); - } - - @Test - public void testGetName() { - assertEquals("sys", PluginRoleEnum.SYS.getName()); - assertEquals("custom", PluginRoleEnum.CUSTOM.getName()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginTypeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginTypeEnumTest.java deleted file mode 100644 index b7946ff..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/PluginTypeEnumTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class PluginTypeEnumTest { - - @Test - public void testName() { - assertEquals("before", PluginTypeEnum.BEFORE.getName()); - assertEquals("function", PluginTypeEnum.FUNCTION.getName()); - assertEquals("last", PluginTypeEnum.LAST.getName()); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RateLimitEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RateLimitEnumTest.java deleted file mode 100644 index a3c4b08..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RateLimitEnumTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class RateLimitEnumTest { - - @Test - public void testGetKeyName() { - assertEquals("concurrent_request_rate_limiter", RateLimitEnum.CONCURRENT.getKeyName()); - assertEquals("request_leaky_rate_limiter", RateLimitEnum.LEAKY_BUCKET.getKeyName()); - assertEquals("sliding_window_request_rate_limiter", RateLimitEnum.SLIDING_WINDOW.getKeyName()); - assertEquals("request_rate_limiter", RateLimitEnum.TOKEN_BUCKET.getKeyName()); - } - - @Test - public void testGetScriptName() { - assertEquals("concurrent_request_rate_limiter.lua", RateLimitEnum.CONCURRENT.getScriptName()); - assertEquals("request_leaky_rate_limiter.lua", RateLimitEnum.LEAKY_BUCKET.getScriptName()); - assertEquals("sliding_window_request_rate_limiter.lua", RateLimitEnum.SLIDING_WINDOW.getScriptName()); - assertEquals("request_rate_limiter.lua", RateLimitEnum.TOKEN_BUCKET.getScriptName()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RedisModeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RedisModeEnumTest.java deleted file mode 100644 index 1266e62..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RedisModeEnumTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; - -/** - * Test Cases for RedisModeEnum. - */ -public class RedisModeEnumTest { - - @Test - public void testAcquireByName() { - assertEquals(RedisModeEnum.CLUSTER, RedisModeEnum.acquireByName(RedisModeEnum.CLUSTER.getName())); - assertEquals(RedisModeEnum.SENTINEL, RedisModeEnum.acquireByName(RedisModeEnum.SENTINEL.getName())); - assertEquals(RedisModeEnum.STANDALONE, RedisModeEnum.acquireByName(RedisModeEnum.STANDALONE.getName())); - assertNotEquals(RedisModeEnum.STANDALONE, RedisModeEnum.acquireByName(RedisModeEnum.CLUSTER.getName())); - - assertEquals(RedisModeEnum.STANDALONE, RedisModeEnum.acquireByName(null)); - assertEquals(RedisModeEnum.STANDALONE, RedisModeEnum.acquireByName("")); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ResultEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ResultEnumTest.java deleted file mode 100644 index ad4a040..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/ResultEnumTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test case for ResultEnum. - */ -public final class ResultEnumTest { - - @Test - public void testGetName() { - assertEquals("success", ResultEnum.SUCCESS.getName()); - assertEquals("timeOut", ResultEnum.TIME_OUT.getName()); - assertEquals("error", ResultEnum.ERROR.getName()); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RetryEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RetryEnumTest.java deleted file mode 100644 index 49f894c..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RetryEnumTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class RetryEnumTest { - - @Test - public void testRetryCode() { - assertEquals(1, RetryEnum.CURRENT.getCode()); - assertEquals(2, RetryEnum.FAILOVER.getCode()); - } - - @Test - public void testRetryName() { - assertEquals("current", RetryEnum.CURRENT.getName()); - assertEquals("failover", RetryEnum.FAILOVER.getName()); - } - - @Test - public void testSupport() { - assertTrue(RetryEnum.CURRENT.isSupport()); - assertTrue(RetryEnum.FAILOVER.isSupport()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RpcTypeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RpcTypeEnumTest.java deleted file mode 100644 index 23ced2f..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/RpcTypeEnumTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.apache.shenyu.common.exception.ShenyuException; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class RpcTypeEnumTest { - @Test - public void testGetName() { - assertEquals("grpc", RpcTypeEnum.GRPC.getName()); - assertEquals("dubbo", RpcTypeEnum.DUBBO.getName()); - assertEquals("http", RpcTypeEnum.HTTP.getName()); - assertEquals("motan", RpcTypeEnum.MOTAN.getName()); - assertEquals("sofa", RpcTypeEnum.SOFA.getName()); - assertEquals("springCloud", RpcTypeEnum.SPRING_CLOUD.getName()); - assertEquals("tars", RpcTypeEnum.TARS.getName()); - assertEquals("websocket", RpcTypeEnum.WEB_SOCKET.getName()); - } - - @Test - public void testSupport() { - assertTrue(RpcTypeEnum.GRPC.getSupport()); - assertTrue(RpcTypeEnum.DUBBO.getSupport()); - assertTrue(RpcTypeEnum.HTTP.getSupport()); - assertTrue(RpcTypeEnum.MOTAN.getSupport()); - assertTrue(RpcTypeEnum.SOFA.getSupport()); - assertTrue(RpcTypeEnum.SPRING_CLOUD.getSupport()); - assertTrue(RpcTypeEnum.TARS.getSupport()); - assertTrue(RpcTypeEnum.WEB_SOCKET.getSupport()); - } - - @Test - public void testAcquireSupport() { - List supportRpcTypeList = - Arrays.stream(RpcTypeEnum.values()) - .filter(RpcTypeEnum::getSupport) - .collect(Collectors.toList()); - assertEquals(RpcTypeEnum.acquireSupports(), supportRpcTypeList); - } - - @Test - public void testGetRpcTypeEnumByNameValid() { - Arrays.stream(RpcTypeEnum.values()) - .filter(RpcTypeEnum::getSupport) - .forEach( - rpcTypeEnum -> - assertEquals(rpcTypeEnum, RpcTypeEnum.acquireByName(rpcTypeEnum.getName()))); - } - - @Test - public void testAcquireSupportURIs() { - List rpcTypeEnumList = RpcTypeEnum.acquireSupportURIs(); - assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.GRPC)); - assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.HTTP)); - assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.TARS)); - } - - @Test - public void testAcquireSupportMetadatas() { - List rpcTypeEnumList = RpcTypeEnum.acquireSupportMetadatas(); - assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.DUBBO)); - assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.GRPC)); - assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.SPRING_CLOUD)); - assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.SOFA)); - assertTrue(rpcTypeEnumList.contains(RpcTypeEnum.TARS)); - } - - @Test - public void testGetRpcTypeEnumByNameInvalid() { - assertThrows(ShenyuException.class, () -> RpcTypeEnum.acquireByName("InvalidName")); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/SelectorTypeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/SelectorTypeEnumTest.java deleted file mode 100644 index 8149cad..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/SelectorTypeEnumTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; - -/** - * Test Cases for SelectorTypeEnum. - */ -public final class SelectorTypeEnumTest { - - @Test - public void testGetMatchModeByCode() { - SelectorTypeEnum fullFlowEnum = SelectorTypeEnum.FULL_FLOW; - String fullFlowName = SelectorTypeEnum.getSelectorTypeByCode(fullFlowEnum.getCode()); - SelectorTypeEnum customFlowEnum = SelectorTypeEnum.CUSTOM_FLOW; - String customFlowName = SelectorTypeEnum.getSelectorTypeByCode(customFlowEnum.getCode()); - assertEquals(fullFlowEnum.getName(), fullFlowName); - assertEquals(customFlowEnum.getName(), customFlowName); - assertNotEquals(fullFlowName, customFlowName); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/SerializeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/SerializeEnumTest.java deleted file mode 100644 index 4f033a5..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/SerializeEnumTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test case for SerializeEnum. - */ -public final class SerializeEnumTest { - - /** - * test SerializeEnum#getSerialize. - */ - @Test - public void testGetSerialize() { - assertEquals(SerializeEnum.JDK.getSerialize(), "jdk"); - assertEquals(SerializeEnum.KRYO.getSerialize(), "kryo"); - assertEquals(SerializeEnum.HESSIAN.getSerialize(), "hessian"); - assertEquals(SerializeEnum.PROTOSTUFF.getSerialize(), "protostuff"); - } - - /** - * test SerializeEnum#acquire. - */ - @Test - public void testAcquire() { - assertEquals(SerializeEnum.acquire("unknown"), SerializeEnum.JDK); - assertEquals(SerializeEnum.acquire("jdk"), SerializeEnum.JDK); - assertEquals(SerializeEnum.acquire("kryo"), SerializeEnum.KRYO); - assertEquals(SerializeEnum.acquire("hessian"), SerializeEnum.HESSIAN); - assertEquals(SerializeEnum.acquire("protostuff"), SerializeEnum.PROTOSTUFF); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/TrieEventEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/TrieEventEnumTest.java deleted file mode 100644 index 1ddf190..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/TrieEventEnumTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test Cases for RuleTrieEventEnum. - */ -public class TrieEventEnumTest { - - @Test - public void testEvent() { - Arrays.stream(TrieEventEnum.values()) - .forEach(trieEventEnum -> assertEquals(trieEventEnum, TrieEventEnum.valueOf(trieEventEnum.name()))); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/TrieMatchModeEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/TrieMatchModeEnumTest.java deleted file mode 100644 index d6c572d..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/TrieMatchModeEnumTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * Test Cases for TrieMatchModeEnum. - */ -public class TrieMatchModeEnumTest { - - @Test - public void testGetMatchMode() { - assertEquals("antPathMatch", TrieMatchModeEnum.ANT_PATH_MATCH.getMatchMode()); - assertEquals("pathPattern", TrieMatchModeEnum.PATH_PATTERN.getMatchMode()); - } - - @Test - public void testAcquireTrieMatch() { - assertEquals(TrieMatchModeEnum.ANT_PATH_MATCH, TrieMatchModeEnum.acquireTrieMatch("antPathMatch")); - assertEquals(TrieMatchModeEnum.PATH_PATTERN, TrieMatchModeEnum.acquireTrieMatch("pathPattern")); - } - - @Test - public void testAcquireTrieMatchException() { - assertThrows(IllegalArgumentException.class, () -> TrieMatchModeEnum.acquireTrieMatch("abc")); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/WafEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/WafEnumTest.java deleted file mode 100644 index ec0cd70..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/WafEnumTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class WafEnumTest { - @Test - public void testGetCode() { - assertEquals(0, WafEnum.REJECT.getCode()); - assertEquals(1, WafEnum.ALLOW.getCode()); - } - - @Test - public void testGetName() { - assertEquals("reject", WafEnum.REJECT.getName()); - assertEquals("allow", WafEnum.ALLOW.getName()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/WafModelEnumTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/WafModelEnumTest.java deleted file mode 100644 index 5057312..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/enums/WafModelEnumTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.enums; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test case for WafModelEnum. - */ -public final class WafModelEnumTest { - - @Test - public void testGetName() { - assertEquals("black", WafModelEnum.BLACK.getName()); - assertEquals("mixed", WafModelEnum.MIXED.getName()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/CommonErrorCodeTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/CommonErrorCodeTest.java deleted file mode 100644 index d810f56..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/CommonErrorCodeTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.exception; - -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -/** - * Test case for {@link CommonErrorCode}. - */ -public final class CommonErrorCodeTest { - - @Test - public void testCommonErrorCode() { - assertThat(CommonErrorCode.SUCCESSFUL, is(200)); - assertThat(CommonErrorCode.ERROR, is(500)); - assertThat(CommonErrorCode.TOKEN_ERROR, is(600)); - assertThat(CommonErrorCode.TOKEN_NO_PERMISSION, is(601)); - assertThat(CommonErrorCode.NOT_FOUND_EXCEPTION, is(404)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java deleted file mode 100644 index 3cdbbe4..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.exception; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test case for {@link SerializerException}. - */ -public final class SerializerExceptionTest { - - @Test - public void testAcquireByThrowable() { - String message = "error throwable"; - Throwable throwable = new Throwable(message); - SerializerException serializerException = new SerializerException(throwable); - - assertEquals(serializerException.getCause().getMessage(), message); - assertEquals(serializerException.getCause(), throwable); - } - - @Test - public void testAcquireByMessage() { - String message = "error"; - SerializerException serializerException = new SerializerException(message); - assertEquals(serializerException.getMessage(), message); - } - - @Test - public void testAcquireByMessageAndThrowable() { - String message = "error message"; - String throwableMessage = "error throwable"; - Throwable throwable = new Throwable(throwableMessage); - SerializerException serializerException = new SerializerException(message, throwable); - assertEquals(serializerException.getMessage(), message); - assertEquals(serializerException.getCause().getMessage(), throwableMessage); - assertEquals(serializerException.getCause(), throwable); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java deleted file mode 100644 index cb02f90..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.exception; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test case for {@link ShenyuException}. - */ -public final class ShenyuExceptionTest { - - @Test - public void testAcquireByThrowable() { - String message = "error throwable"; - Throwable throwable = new Throwable(message); - ShenyuException shenyuException = new ShenyuException(throwable); - assertEquals(shenyuException.getCause().getMessage(), message); - assertEquals(shenyuException.getCause(), throwable); - } - - @Test - public void testAcquireByMessage() { - String message = "error"; - ShenyuException shenyuException = new ShenyuException(message); - assertEquals(shenyuException.getMessage(), message); - } - - @Test - public void testAcquireByMessageAndThrowable() { - String message = "error message"; - String throwableMessage = "error throwable"; - Throwable throwable = new Throwable(throwableMessage); - ShenyuException shenyuException = new ShenyuException(message, throwable); - assertEquals(shenyuException.getMessage(), message); - assertEquals(shenyuException.getCause().getMessage(), throwableMessage); - assertEquals(shenyuException.getCause(), throwable); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/timer/HierarchicalWheelTimerTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/timer/HierarchicalWheelTimerTest.java deleted file mode 100644 index 755d42a..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/timer/HierarchicalWheelTimerTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.timer; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertSame; - -/** - * HierarchicalWheelTimerTest . - */ -public class HierarchicalWheelTimerTest { - - /** - * The Timer. - */ - private Timer timer; - - /** - * The Timer task list. - */ - private TimerTaskList timerTaskList; - - /** - * The Task count. - */ - private final AtomicInteger taskCount = new AtomicInteger(0); - - /** - * Sets up. - */ - @BeforeEach - public void setUp() { - timer = WheelTimerFactory.newWheelTimer(); - timerTaskList = new TimerTaskList(taskCount); - } - - /** - * Test timer. - */ - @Test - public void testTimer() { - for (int i = 0; i < 100; i++) { - timer.add(new TimerTask(1 + i, TimeUnit.SECONDS) { - @Override - public void run(final TaskEntity taskEntity) { - - } - }); - } - assertEquals(timer.size(), 100); - } - - /** - * Test timer cancel. - */ - @Test - public void testTimerCancel() { - TimerTask timerTask = new TimerTask(100000) { - @Override - public void run(final TaskEntity taskEntity) { - } - }; - timer.add(timerTask); - assertEquals(timer.size(), 1); - timerTask.cancel(); - assertEquals(timer.size(), 0); - } - - /** - * Test list foreach. - */ - @Test - public void testListForeach() { - TimerTask timerTask = new TimerTask(100000) { - @Override - public void run(final TaskEntity taskEntity) { - - } - }; - timerTaskList.add(new TimerTaskList.TimerTaskEntry(timer, timerTask, -1L)); - assertEquals(taskCount.get(), 1); - timerTaskList.foreach(timerTask1 -> assertSame(timerTask1, timerTask1)); - } - - /** - * Test list iterator. - */ - @Test - public void testListIterator() { - TimerTask timerTask = new TimerTask(100000) { - @Override - public void run(final TaskEntity taskEntity) { - } - }; - timerTaskList.add(new TimerTaskList.TimerTaskEntry(timer, timerTask, -1L)); - assertEquals(taskCount.get(), 1); - for (final TimerTask task : timerTaskList) { - assertSame(timerTask, timerTask); - } - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/timer/WheelTimerFactoryTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/timer/WheelTimerFactoryTest.java deleted file mode 100644 index 269a88c..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/timer/WheelTimerFactoryTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.timer; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertSame; - -/** - * WheelTimerFactoryTest . - */ -public class WheelTimerFactoryTest { - - /** - * Test get shared. - */ - @Test - public void testGetShared() { - Timer sharedTimer1 = WheelTimerFactory.getSharedTimer(); - Timer sharedTimer2 = WheelTimerFactory.getSharedTimer(); - assertSame(sharedTimer1, sharedTimer2); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ContextPathUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ContextPathUtilsTest.java deleted file mode 100644 index 180f184..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ContextPathUtilsTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class ContextPathUtilsTest { - - @Test - public void testBuildContextPath() { - final String url = "/contextPath/service"; - final String appName = "/app"; - assertEquals(url, ContextPathUtils.buildContextPath(url, appName)); - assertEquals(appName, ContextPathUtils.buildContextPath("", appName)); - } - - @Test - public void testBuildRealNode() { - final String url = "/contextPath/service"; - final String appName = "/app"; - assertEquals(url.substring(1), ContextPathUtils.buildRealNode(url, appName)); - assertEquals(appName.substring(1), ContextPathUtils.buildRealNode("", appName)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/DateUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/DateUtilsTest.java deleted file mode 100644 index 1771d85..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/DateUtilsTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; - -import static org.junit.jupiter.api.Assertions.assertEquals; - - -/** - * Test Cases for DateUtils. - */ -public final class DateUtilsTest { - - @Test - public void testLocalDateTimeToString() { - LocalDateTime localDateTime = LocalDateTime.of(2020, 1, 1, 23, 50, 0, 0); - assertEquals("2020-01-01 23:50:00", DateUtils.localDateTimeToString(localDateTime)); - } - - @Test - public void testLocalDateTimeToStringWithPattern() { - LocalDateTime localDateTime = LocalDateTime.of(2020, 1, 1, 23, 50, 0, 0); - assertEquals("2020-01-01", DateUtils.localDateTimeToString(localDateTime, "yyyy-MM-dd")); - } - - @Test - public void testAcquireMinutesBetween() { - LocalDateTime start = LocalDateTime.now(); - LocalDateTime end = start.plusMinutes(3); - assertEquals(3, DateUtils.acquireMinutesBetween(start, end)); - } - - @Test - public void testFormatLocalDateTimeFromTimestamp() { - LocalDateTime localDateTime1 = LocalDateTime.now(ZoneOffset.ofHours(8)); - LocalDateTime localDateTime2 = DateUtils.formatLocalDateTimeFromTimestamp(ZonedDateTime.of(localDateTime1, ZoneOffset.ofHours(8)).toInstant().toEpochMilli()); - assertEquals(localDateTime1.getYear(), localDateTime2.getYear()); - assertEquals(localDateTime1.getDayOfMonth(), localDateTime2.getDayOfMonth()); - assertEquals(localDateTime1.getMonth(), localDateTime2.getMonth()); - assertEquals(localDateTime1.getHour(), localDateTime2.getHour()); - assertEquals(localDateTime1.getMinute(), localDateTime2.getMinute()); - assertEquals(localDateTime1.getSecond(), localDateTime2.getSecond()); - } - - @Test - public void testFormatLocalDateTimeFromTimestampBySystemTimezone() { - LocalDateTime localDateTime1 = LocalDateTime.now(); - LocalDateTime localDateTime2 = DateUtils.formatLocalDateTimeFromTimestampBySystemTimezone(ZonedDateTime.of(localDateTime1, ZoneId.systemDefault()).toInstant().toEpochMilli()); - assertEquals(localDateTime1.getYear(), localDateTime2.getYear()); - assertEquals(localDateTime1.getDayOfMonth(), localDateTime2.getDayOfMonth()); - assertEquals(localDateTime1.getMonth(), localDateTime2.getMonth()); - assertEquals(localDateTime1.getHour(), localDateTime2.getHour()); - assertEquals(localDateTime1.getMinute(), localDateTime2.getMinute()); - assertEquals(localDateTime1.getSecond(), localDateTime2.getSecond()); - } - - @Test - public void testParseLocalDateTime() { - LocalDateTime localDateTime1 = LocalDateTime.of(2020, 1, 1, 0, 0, 1, 0); - LocalDateTime localDateTime2 = DateUtils.parseLocalDateTime("2020-01-01 00:00:01"); - assertEquals(localDateTime1.getYear(), localDateTime2.getYear()); - assertEquals(localDateTime1.getDayOfMonth(), localDateTime2.getDayOfMonth()); - assertEquals(localDateTime1.getMonth(), localDateTime2.getMonth()); - assertEquals(localDateTime1.getHour(), localDateTime2.getHour()); - assertEquals(localDateTime1.getMinute(), localDateTime2.getMinute()); - assertEquals(localDateTime1.getSecond(), localDateTime2.getSecond()); - LocalDateTime localDateTime = DateUtils.parseLocalDateTime("1991-08-02T08:30:11", "yyyy-MM-dd'T'HH:mm:ss"); - assertEquals(localDateTime.getYear(), 1991); - } - - @Test - public void testAcquireMillisBetween() { - LocalDateTime start = LocalDateTime.now(); - LocalDateTime end = start.plusMinutes(1); - assertEquals(60 * 1000, DateUtils.acquireMillisBetween(start, end)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/DigestUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/DigestUtilsTest.java deleted file mode 100644 index dfd14d2..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/DigestUtilsTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.NullAndEmptySource; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class DigestUtilsTest { - @Test - public void testSha512Hex() { - assertThat(DigestUtils.sha512Hex("123456"), - is("ba3253876aed6bc22d4a6ff53d8406c6ad864195ed144ab5c87621b6c233b548baeae6956df346ec8c17f5ea10f35ee3cbc514797ed7ddd3145464e2a0bab413")); - } - - @ParameterizedTest - @NullAndEmptySource - public void testSha512HexForNullOrEmpty(final String src) { - assertThat(DigestUtils.sha512Hex(src), nullValue()); - } - - @Test - public void testMd5Hex() { - final String md5 = "e10adc3949ba59abbe56e057f20f883e"; - assertEquals(md5, DigestUtils.md5Hex("123456")); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/FreshBeanHolderTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/FreshBeanHolderTest.java deleted file mode 100644 index e6b550d..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/FreshBeanHolderTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import java.util.function.Function; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class FreshBeanHolderTest { - - @Test - public void testApply() { - Function function = Function.identity(); - FreshBeanHolder freshBeanHolder = new FreshBeanHolder<>(function); - assertEquals("hello", freshBeanHolder.apply("hello")); - } - - @Test - public void testDoFresh() { - Function function = Function.identity(); - FreshBeanHolder freshBeanHolder = new FreshBeanHolder<>(function); - freshBeanHolder.doFresh("hello world"); - assertEquals("hello world", freshBeanHolder.apply("hello")); - } - - @Test - public void testInit() { - Function function = Function.identity(); - FreshBeanHolder freshBeanHolder = new FreshBeanHolder<>(function); - freshBeanHolder.init("hello world"); - assertEquals("hello world", freshBeanHolder.init("hello")); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java deleted file mode 100644 index 1737453..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java +++ /dev/null @@ -1,847 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; -import org.apache.commons.lang3.tuple.Pair; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.math.BigDecimal; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.comparesEqualTo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * Test cases for GsonUtils. - */ -public class GsonUtilsTest { - - private static final String EXPECTED_JSON = "{\"bool\":true,\"iNumber\":1,\"fNumber\":1.0,\"dNumber\":1.0," - + "\"bigDecimal\":1,\"string\":\"test\",\"testList\":[\"list_string_0\",\"list_string_1\"," - + "\"list_string_2\",\"list_string_3\",\"list_string_4\",\"list_string_5\",\"list_string_6\"," - + "\"list_string_7\",\"list_string_8\",\"list_string_9\"],\"testMap\":{\"map_key_2\":\"map_value_2\"," - + "\"map_key_1\":\"map_value_1\",\"map_key_0\":\"map_value_0\",\"map_key_9\":\"map_value_9\"," - + "\"map_key_8\":\"map_value_8\",\"map_key_7\":\"map_value_7\",\"map_key_6\":\"map_value_6\"," - + "\"map_key_5\":\"map_value_5\",\"map_key_4\":\"map_value_4\",\"map_key_3\":\"map_value_3\"}," - + "\"emptyList\":[],\"emptyMap\":{},\"nestedMap\":{\"map_2\":{},\"map_1\":{\"map_key_2\":\"map_value_2\"," - + "\"map_key_1\":\"map_value_1\",\"map_key_0\":\"map_value_0\",\"map_key_9\":\"map_value_9\"," - + "\"map_key_8\":\"map_value_8\",\"map_key_7\":\"map_value_7\",\"map_key_6\":\"map_value_6\"," - + "\"map_key_5\":\"map_value_5\",\"map_key_4\":\"map_value_4\",\"map_key_3\":\"map_value_3\"}," - + "\"bool\":false}}"; - - /** - * test method about {@link GsonUtils#toJson(java.lang.Object)}. - */ - @Test - public void testToJson() { - TestObject testObject = generateTestObject(); - JsonElement expectedJson = JsonParser.parseString(EXPECTED_JSON); - JsonElement objectJson = JsonParser.parseString(GsonUtils.getInstance().toJson(testObject)); - - assertEquals(expectedJson, objectJson); - } - - /** - * test method about {@link GsonUtils#fromJson(JsonElement, Class)}. - */ - @Test - public void testFromJsonAboutJsonElement() { - TestObject testObject = generateTestObject(); - - JsonObject jsonObject = JsonParser.parseString(EXPECTED_JSON).getAsJsonObject(); - TestObject parseObject = GsonUtils.getInstance().fromJson(jsonObject, TestObject.class); - - assertEquals(testObject, parseObject); - } - - /** - * test method about {@link GsonUtils#fromJson(String, Class)}. - */ - @Test - public void testFromJsonAboutString() { - TestObject testObject = generateTestObject(); - - assertEquals(testObject, GsonUtils.getInstance().fromJson(EXPECTED_JSON, TestObject.class)); - } - - /** - * test method about {@link GsonUtils#fromList(String, Class)}. - */ - @Test - public void testFromList() { - List testList = ImmutableList.of("123", "test", "测试"); - - String testJson = "[\"123\",\"test\",\"测试\"]"; - - assertEquals(testList, GsonUtils.getInstance().fromList(testJson, String.class)); - } - - /** - * test method about {@link GsonUtils#toGetParam(String)}. - */ - @Test - public void testToGetParam() { - Map param = ImmutableMap.of("id", "123", "name", "test", "data", "测试"); - - String json = GsonUtils.getGson().toJson(param, new TypeToken>() { - }.getType()); - - String resultParam = GsonUtils.getInstance().toGetParam(json); - Map resultMap = Arrays.stream(resultParam.split("&")) - .collect(Collectors.toMap(s -> s.split("=")[0], s -> s.split("=")[1])); - - param.forEach((key, value) -> { - assertTrue(resultMap.containsKey(key)); - assertEquals(value, resultMap.get(key)); - }); - - assertEquals("", GsonUtils.getInstance().toGetParam("")); - } - - /** - * test method {@link GsonUtils#toListMap(String)}. - */ - @Test - public void testToListMap() { - Map map = ImmutableMap.of("id", "123", "name", "test", "data", "测试"); - List> list = ImmutableList.of(ImmutableMap.copyOf(map), ImmutableMap.copyOf(map), - ImmutableMap.copyOf(map)); - - String json = "[{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"}," - + "{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"}," - + "{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"}]"; - - assertEquals(list, GsonUtils.getInstance().toListMap(json)); - } - - /** - * test method {@link GsonUtils#toObjectMap(java.lang.String)}. - */ - @Test - public void testToObjectMap() { - Map map = ImmutableMap.of("id", 123L, "name", "test", "double", 1.0D, - "boolean", true, "data", generateTestObject()); - - String json = "{\"name\":\"test\",\"id\":123,\"double\":1.0,\"boolean\":true,\"data\":" + EXPECTED_JSON + "}"; - - Map parseMap = GsonUtils.getInstance().toObjectMap(json); - map.forEach((key, value) -> { - assertTrue(parseMap.containsKey(key)); - Object jsonValue = parseMap.get(key); - if (jsonValue instanceof JsonElement) { - assertEquals(value, GsonUtils.getInstance().fromJson((JsonElement) jsonValue, TestObject.class)); - } else { - assertEquals(value, parseMap.get(key)); - } - }); - - assertNull(GsonUtils.getInstance().toObjectMap(null)); - } - - /** - * test method {@link GsonUtils#toObjectMap(java.lang.String, java.lang.Class)}. - */ - @Test - public void testToObjectMapWithClazz() { - Map map = ImmutableMap.of("data", generateTestObject()); - - String json = "{\"data\":" + EXPECTED_JSON + "}"; - - Map parseMap = GsonUtils.getInstance().toObjectMap(json, TestObject.class); - map.forEach((key, value) -> { - assertTrue(parseMap.containsKey(key)); - assertEquals(value, parseMap.get(key)); - }); - - assertNull(GsonUtils.getInstance().toObjectMap(null, String.class)); - } - - /** - * test method {@link GsonUtils#toObjectMapList(java.lang.String, java.lang.Class)}. - */ - @Test - public void testToObjectMapList() { - List listFirst = ImmutableList.of("111", "222"); - List listSecond = ImmutableList.of("333", "555"); - Map> map = ImmutableMap.of("data1", listFirst, "data2", listSecond); - - String json = "{\"data1\":[\"111\",\"222\"],\"data2\":[\"333\",\"555\"]}"; - Map> parseMap = GsonUtils.getInstance().toObjectMapList(json, String.class); - map.forEach((key, value) -> { - assertTrue(parseMap.containsKey(key)); - assertEquals(value, parseMap.get(key)); - }); - - assertNull(GsonUtils.getInstance().toObjectMapList(null, String.class)); - } - - /** - * test method {@link GsonUtils#toTreeMap(String)}. - */ - @Test - public void testToTreeMap() { - Map map = ImmutableMap.of("id", 123L, "name", "test", "double", - 1.0D, "boolean", true, "data", generateTestObject()); - - String json = "{\"name\":\"test\",\"id\":123,\"double\":1.0,\"boolean\":true,\"data\":" - + EXPECTED_JSON + "}"; - - Map parseMap = GsonUtils.getInstance().toTreeMap(json); - - map.forEach((key, value) -> { - assertTrue(parseMap.containsKey(key)); - Object jsonValue = parseMap.get(key); - if (jsonValue instanceof JsonElement) { - assertEquals(value, GsonUtils.getInstance().fromJson((JsonElement) jsonValue, TestObject.class)); - } else { - assertEquals(value, parseMap.get(key)); - } - }); - - assertNull(GsonUtils.getInstance().toObjectMap(null)); - } - - /** - * test method {@link GsonUtils#convertToMap(String)}. - */ - @Test - public void testConvertToMap() { - List innerList = ImmutableList.of(1, 2, 3); - Map innerMap = ImmutableMap.of("id", 123, "name", "shenyu"); - Map map = ImmutableMap.of("code", 200, "message", "test", - "data", innerMap, "list", innerList); - - String testJson = "{\"code\":200,\"message\":\"test\"," - + "\"data\":{\"id\":123,\"name\":\"shenyu\"},\"list\":[1,2,3]}"; - Map parseMap = GsonUtils.getInstance().convertToMap(testJson); - - map.forEach((key, value) -> { - assertTrue(parseMap.containsKey(key)); - if (value instanceof Map) { - Map tempMap = (Map) parseMap.get(key); - ((Map) value).forEach((key1, value1) -> { - assertTrue(tempMap.containsKey(key1)); - assertEquals(value1.toString(), tempMap.get(key1).toString()); - }); - } else if (value instanceof List) { - List tempList = (List) parseMap.get(key); - List tempValue = (List) value; - for (int i = 0; i < tempValue.size(); i++) { - assertEquals(tempValue.get(i).toString(), tempList.get(i).toString()); - } - } else { - assertEquals(value.toString(), parseMap.get(key).toString()); - } - }); - - assertNull(GsonUtils.getInstance().convertToMap(null)); - } - - @Test - public void testPairGson() { - Pair testPair = Pair.of("1", "2"); - - String testJson = "{\"left\":\"1\",\"right\":\"2\"}"; - Pair resultPair = GsonUtils.getInstance().fromJson(testJson, Pair.class); - - String testListJson = "[{\"left\":\"int\",\"right\":\"param1\"},{\"left\":\"java.lang.Integer\",\"right\":\"param2\"}]"; - List listPair = GsonUtils.getInstance().fromList(testListJson, Pair.class); - String resultListJson = GsonUtils.getInstance().toJson(listPair); - - assertThat(resultListJson, comparesEqualTo(testListJson)); - assertThat(resultPair.getLeft(), comparesEqualTo(testPair.getLeft())); - assertThat(resultPair.getRight(), comparesEqualTo(testPair.getRight())); - } - - private static TestObject generateTestObject() { - List testList = Lists.newLinkedList(); - Map testMap = Maps.newHashMap(); - for (int i = 0; i < 10; i++) { - testList.add("list_string_" + i); - testMap.put("map_key_" + i, "map_value_" + i); - } - - return TestObject.builder() - .bool(true) - .iNumber(1) - .fNumber(1.0f) - .dNumber(1.0d) - .bigDecimal(BigDecimal.ONE) - .string("test") - .nullObject(null) - .testList(testList) - .testMap(testMap) - .emptyList(Lists.newLinkedList()) - .emptyMap(Maps.newHashMap()) - .nestedMap(new HashMap() { - { - put("map_1", testMap); - put("map_2", Maps.newHashMap()); - put("bool", false); - } - }) - .build(); - } - - @Test - public void testDurationGson() { - LocalDateTime start = LocalDateTime.of(2022, 1, 1, 1, 1, 1); - LocalDateTime end = LocalDateTime.of(2022, 1, 2, 2, 2, 2); - Duration expectDuration = Duration.between(start, end); - String testStringDuration = "PT25H1M1S"; - Duration testDuration = GsonUtils.getInstance().fromJson(testStringDuration, Duration.class); - assertEquals(expectDuration, testDuration); - } - - @Test - public void testFromCurrentList() { - Map map = ImmutableMap.of("id", "123", "name", "test", "data", "测试"); - List> list = ImmutableList.of(ImmutableMap.copyOf(map), ImmutableMap.copyOf(map), - ImmutableMap.copyOf(map)); - String json = "[{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"}," - + "{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"}," - + "{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"}]"; - List testList = GsonUtils.getInstance().fromCurrentList(json, map.getClass()); - Assertions.assertEquals(list, testList); - } - - private static class TestObject { - private Boolean bool; - - private Integer iNumber; - - private Float fNumber; - - private Double dNumber; - - private BigDecimal bigDecimal; - - private String string; - - private Object nullObject; - - private List testList; - - private Map testMap; - - private List emptyList; - - private Map emptyMap; - - private Map nestedMap; - - /** - * no args constructor. - */ - TestObject() { - } - - /** - * builder constructor. - * - * @param builder builder - */ - private TestObject(final Builder builder) { - this.bool = builder.bool; - this.iNumber = builder.iNumber; - this.fNumber = builder.fNumber; - this.dNumber = builder.dNumber; - this.bigDecimal = builder.bigDecimal; - this.string = builder.string; - this.nullObject = builder.nullObject; - this.testList = builder.testList; - this.testMap = builder.testMap; - this.emptyList = builder.emptyList; - this.emptyMap = builder.emptyMap; - this.nestedMap = builder.nestedMap; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get bool. - * - * @return bool - */ - public Boolean getBool() { - return bool; - } - - /** - * set bool. - * - * @param bool bool - */ - public void setBool(final Boolean bool) { - this.bool = bool; - } - - /** - * get iNumber. - * - * @return iNumber - */ - public Integer getiNumber() { - return iNumber; - } - - /** - * set iNumber. - * - * @param iNumber iNumber - */ - public void setiNumber(final Integer iNumber) { - this.iNumber = iNumber; - } - - /** - * get fNumber. - * - * @return fNumber - */ - public Float getfNumber() { - return fNumber; - } - - /** - * set fNumber. - * - * @param fNumber fNumber - */ - public void setfNumber(final Float fNumber) { - this.fNumber = fNumber; - } - - /** - * get dNumber. - * - * @return dNumber - */ - public Double getdNumber() { - return dNumber; - } - - /** - * set dNumber. - * - * @param dNumber dNumber - */ - public void setdNumber(final Double dNumber) { - this.dNumber = dNumber; - } - - /** - * get bigDecimal. - * - * @return bigDecimal - */ - public BigDecimal getBigDecimal() { - return bigDecimal; - } - - /** - * set bigDecimal. - * - * @param bigDecimal bigDecimal - */ - public void setBigDecimal(final BigDecimal bigDecimal) { - this.bigDecimal = bigDecimal; - } - - /** - * get string. - * - * @return string - */ - public String getString() { - return string; - } - - /** - * set string. - * - * @param string string - */ - public void setString(final String string) { - this.string = string; - } - - /** - * get nullObject. - * - * @return nullObject - */ - public Object getNullObject() { - return nullObject; - } - - /** - * set nullObject. - * - * @param nullObject nullObject - */ - public void setNullObject(final Object nullObject) { - this.nullObject = nullObject; - } - - /** - * get testList. - * - * @return testList - */ - public List getTestList() { - return testList; - } - - /** - * set testList. - * - * @param testList testList - */ - public void setTestList(final List testList) { - this.testList = testList; - } - - /** - * get testMap. - * - * @return testMap - */ - public Map getTestMap() { - return testMap; - } - - /** - * set testMap. - * - * @param testMap testMap - */ - public void setTestMap(final Map testMap) { - this.testMap = testMap; - } - - /** - * get emptyList. - * - * @return emptyList - */ - public List getEmptyList() { - return emptyList; - } - - /** - * set emptyList. - * - * @param emptyList emptyList - */ - public void setEmptyList(final List emptyList) { - this.emptyList = emptyList; - } - - /** - * get emptyMap. - * - * @return emptyMap - */ - public Map getEmptyMap() { - return emptyMap; - } - - /** - * set emptyMap. - * - * @param emptyMap emptyMap - */ - public void setEmptyMap(final Map emptyMap) { - this.emptyMap = emptyMap; - } - - /** - * get nestedMap. - * - * @return nestedMap - */ - public Map getNestedMap() { - return nestedMap; - } - - /** - * set nestedMap. - * - * @param nestedMap nestedMap - */ - public void setNestedMap(final Map nestedMap) { - this.nestedMap = nestedMap; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - TestObject that = (TestObject) o; - return Objects.equals(bool, that.bool) && Objects.equals(iNumber, that.iNumber) && Objects.equals(fNumber, that.fNumber) && Objects.equals(dNumber, that.dNumber) - && Objects.equals(bigDecimal, that.bigDecimal) && Objects.equals(string, that.string) && Objects.equals(nullObject, that.nullObject) - && Objects.equals(testList, that.testList) && Objects.equals(testMap, that.testMap) && Objects.equals(emptyList, that.emptyList) - && Objects.equals(emptyMap, that.emptyMap) && Objects.equals(nestedMap, that.nestedMap); - } - - @Override - public int hashCode() { - return Objects.hash(bool, iNumber, fNumber, dNumber, bigDecimal, string, nullObject, testList, testMap, emptyList, emptyMap, nestedMap); - } - - @Override - public String toString() { - return "TestObject{" - + "bool=" - + bool - + ", iNumber=" - + iNumber - + ", fNumber=" - + fNumber - + ", dNumber=" - + dNumber - + ", bigDecimal=" - + bigDecimal - + ", string='" - + string - + '\'' - + ", nullObject=" - + nullObject - + ", testList=" - + testList - + ", testMap=" - + testMap - + ", emptyList=" - + emptyList - + ", emptyMap=" - + emptyMap - + ", nestedMap=" - + nestedMap - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - private Boolean bool; - - private Integer iNumber; - - private Float fNumber; - - private Double dNumber; - - private BigDecimal bigDecimal; - - private String string; - - private Object nullObject; - - private List testList; - - private Map testMap; - - private List emptyList; - - private Map emptyMap; - - private Map nestedMap; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return TestObject - */ - public TestObject build() { - return new TestObject(this); - } - - /** - * build bool. - * - * @param bool bool - * @return this - */ - public Builder bool(final Boolean bool) { - this.bool = bool; - return this; - } - - /** - * build iNumber. - * - * @param iNumber iNumber - * @return this - */ - public Builder iNumber(final Integer iNumber) { - this.iNumber = iNumber; - return this; - } - - /** - * build fNumber. - * - * @param fNumber fNumber - * @return this - */ - public Builder fNumber(final Float fNumber) { - this.fNumber = fNumber; - return this; - } - - /** - * build dNumber. - * - * @param dNumber dNumber - * @return this - */ - public Builder dNumber(final Double dNumber) { - this.dNumber = dNumber; - return this; - } - - /** - * return bigDecimal. - * - * @param bigDecimal bigDecimal - * @return this - */ - public Builder bigDecimal(final BigDecimal bigDecimal) { - this.bigDecimal = bigDecimal; - return this; - } - - /** - * build string. - * - * @param string string - * @return this - */ - public Builder string(final String string) { - this.string = string; - return this; - } - - /** - * build nullObject. - * - * @param nullObject nullObject - * @return this - */ - public Builder nullObject(final Object nullObject) { - this.nullObject = nullObject; - return this; - } - - /** - * build testList. - * - * @param testList testList - * @return this - */ - public Builder testList(final List testList) { - this.testList = testList; - return this; - } - - /** - * build testMap. - * - * @param testMap testMap - * @return this - */ - public Builder testMap(final Map testMap) { - this.testMap = testMap; - return this; - } - - /** - * build emptyList. - * - * @param emptyList emptyList - * @return this - */ - public Builder emptyList(final List emptyList) { - this.emptyList = emptyList; - return this; - } - - /** - * build emptyMap. - * - * @param emptyMap emptyMap - * @return this - */ - public Builder emptyMap(final Map emptyMap) { - this.emptyMap = emptyMap; - return this; - } - - /** - * build nestedMap. - * - * @param nestedMap nestedMap - * @return this - */ - public Builder nestedMap(final Map nestedMap) { - this.nestedMap = nestedMap; - return this; - } - } - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/HmacHexUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/HmacHexUtilsTest.java deleted file mode 100644 index e8b0f2b..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/HmacHexUtilsTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test cases for HmacUtils. - */ -public class HmacHexUtilsTest { - - @Test - public void testHmacMd5Hex() { - assertEquals(HmacHexUtils.hmacMd5Hex("testKey", "testValue"), "3024ffb5567372102ca6775cf8140cb1"); - } - - @Test - public void testHmacSha256Hex() { - assertEquals(HmacHexUtils.hmacSha256Hex("testKey", "testValue"), - "c52d1ebe5e779f5b337dc8f515bf594bd44a7007cb3f4ab1f6c5a15149bed793"); - } - - @Test - public void testHmacSha512Hex() { - assertEquals(HmacHexUtils.hmacSha512Hex("testKey", "testValue"), - "99997ffdee76da2f016fe4ee9256c3361c7dc9f1588be5cabeca9e541f8224db00b10260f4885eaaf29edab66574237058d43f5644b47e0fc13e66b89dbcde68"); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/IpUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/IpUtilsTest.java deleted file mode 100644 index 77629ae..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/IpUtilsTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; - -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.util.Vector; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; - -/** - * Test case for {@link IpUtils}. - */ -public final class IpUtilsTest { - - private MockedStatic networkInterfaceMockedStatic; - - @BeforeEach - public void setUp() { - networkInterfaceMockedStatic = mockStatic(NetworkInterface.class); - } - - @AfterEach - public void close() { - networkInterfaceMockedStatic.close(); - } - - @Test - public void testGetHost() throws Exception { - // first net card - Vector addresses1 = new Vector<>(); - addresses1.add(InetAddress.getByAddress("local-host", new byte[]{(byte) 192, (byte) 168, (byte) 50, (byte) 66})); - NetworkInterface nic1 = mock(NetworkInterface.class); - when(nic1.getInetAddresses()).thenReturn(addresses1.elements()); - when(nic1.getName()).thenReturn("local"); - // second net card - Vector addresses2 = new Vector<>(); - addresses2.add(InetAddress.getByAddress("eth0-host", new byte[]{(byte) 172, (byte) 168, (byte) 166, (byte) 12})); - NetworkInterface nic2 = mock(NetworkInterface.class); - when(nic2.getInetAddresses()).thenReturn(addresses2.elements()); - when(nic2.getName()).thenReturn("eth0"); - // third net card - Vector addresses3 = new Vector<>(); - addresses3.add(InetAddress.getByAddress("eth1-host", new byte[]{(byte) 10, (byte) 150, (byte) 111, (byte) 66})); - NetworkInterface nic3 = mock(NetworkInterface.class); - when(nic3.getInetAddresses()).thenReturn(addresses3.elements()); - when(nic3.getName()).thenReturn("eth1"); - // add all - Vector nics = new Vector<>(); - nics.add(nic1); - nics.add(nic2); - nics.add(nic3); - networkInterfaceMockedStatic.when((MockedStatic.Verification) NetworkInterface.getNetworkInterfaces()).thenReturn(nics.elements()); - String prefix1 = "172.168"; - assertEquals("172.168.166.12", IpUtils.getHost(prefix1)); - } - - @Test - public void testGetHostHasNotMatchPrefix() throws Exception { - // first net card - Vector addresses1 = new Vector<>(); - addresses1.add(InetAddress.getByAddress("local-host", new byte[]{(byte) 192, (byte) 168, (byte) 50, (byte) 66})); - NetworkInterface nic1 = mock(NetworkInterface.class); - when(nic1.getInetAddresses()).thenReturn(addresses1.elements()); - when(nic1.getName()).thenReturn("local"); - // second net card - Vector addresses2 = new Vector<>(); - addresses2.add(InetAddress.getByAddress("eth0-host", new byte[]{(byte) 172, (byte) 168, (byte) 166, (byte) 12})); - NetworkInterface nic2 = mock(NetworkInterface.class); - when(nic2.getInetAddresses()).thenReturn(addresses2.elements()); - when(nic2.getName()).thenReturn("eth0"); - // third net card - Vector addresses3 = new Vector<>(); - addresses3.add(InetAddress.getByAddress("eth1-host", new byte[]{(byte) 10, (byte) 150, (byte) 111, (byte) 66})); - NetworkInterface nic3 = mock(NetworkInterface.class); - when(nic3.getInetAddresses()).thenReturn(addresses3.elements()); - when(nic3.getName()).thenReturn("eth1"); - // add all - Vector nics = new Vector<>(); - nics.add(nic1); - nics.add(nic2); - nics.add(nic3); - networkInterfaceMockedStatic.when((MockedStatic.Verification) NetworkInterface.getNetworkInterfaces()).thenReturn(nics.elements()); - assertEquals("172.168.166.12", IpUtils.getHost()); - } - - @Test - public void testIsCompleteHost() { - assertTrue(IpUtils.isCompleteHost("192.168.1.166")); - assertFalse(IpUtils.isCompleteHost("192.168.")); - assertFalse(IpUtils.isCompleteHost("192..")); - } - - @Test - public void testGetHostWithException() throws Exception { - networkInterfaceMockedStatic.when((MockedStatic.Verification) NetworkInterface.getNetworkInterfaces()) - .thenThrow(SocketException.class); - assertEquals("127.0.0.1", IpUtils.getHost()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/JarDependencyUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/JarDependencyUtilsTest.java deleted file mode 100644 index e7921c4..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/JarDependencyUtilsTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import java.io.ByteArrayInputStream; -import java.lang.reflect.Field; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import org.junit.jupiter.api.Test; -import org.mockito.MockedConstruction; -import org.mockito.MockedStatic; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.MethodNode; - -import com.google.common.collect.Lists; - -import static org.junit.jupiter.api.Assertions.assertThrowsExactly; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mockConstruction; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.apache.shenyu.common.exception.ShenyuException; - -/** - * Test cases for JarDependencyUtils. - */ -public class JarDependencyUtilsTest { - - @Test - public void test() { - try (MockedConstruction byteStream = mockConstruction(ByteArrayInputStream.class); - MockedConstruction zipStream = mockConstruction(ZipInputStream.class, (mock, context) -> { - when(mock.getNextEntry()).thenReturn(new ZipEntry("abc.class")).thenReturn(null); - }); - MockedConstruction classNode = mockConstruction(ClassNode.class, (mock, context) -> { - Field superName = ClassNode.class.getDeclaredField("superName"); - superName.set(mock, "superName"); - Field interfaces = ClassNode.class.getDeclaredField("interfaces"); - interfaces.set(mock, Lists.newArrayList("interface")); - FieldNode fieldNode = mock(FieldNode.class); - Field fieldDesc = FieldNode.class.getDeclaredField("desc"); - fieldDesc.set(fieldNode, "desc"); - Field fields = ClassNode.class.getDeclaredField("fields"); - fields.set(mock, Lists.newArrayList(fieldNode)); - MethodNode methodNode = mock(MethodNode.class); - Field methodDesc = MethodNode.class.getDeclaredField("desc"); - methodDesc.set(methodNode, "desc"); - Field methods = ClassNode.class.getDeclaredField("methods"); - methods.set(mock, Lists.newArrayList(methodNode)); - }); - MockedConstruction classReader = mockConstruction(ClassReader.class); - MockedStatic type = mockStatic(Type.class)) { - when(Type.getType(anyString())).thenReturn(Type.BOOLEAN_TYPE); - when(Type.getReturnType(anyString())).thenReturn(Type.CHAR_TYPE); - when(Type.getArgumentTypes(anyString())).thenReturn(new Type[] {Type.INT_TYPE}); - assertNotNull(JarDependencyUtils.getDependencyTree(null)); - } - } - - @Test - public void testException() { - assertThrowsExactly(ShenyuException.class, () -> JarDependencyUtils.getDependencyTree(null)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/JsonUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/JsonUtilsTest.java deleted file mode 100644 index fce531d..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/JsonUtilsTest.java +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.shenyu.common.constant.Constants; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import org.junit.jupiter.api.Test; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * Test cases for JsonUtils. - */ -public final class JsonUtilsTest { - - private static final String EXPECTED_JSON = "{\"id\":123,\"name\":\"test object\",\"deleted\":false," - + "\"testList\":[\"test_string_0\",\"test_string_1\",\"test_string_2\",\"test_string_3\",\"test_string_4\",\"test_string_5\"," - + "\"test_string_6\",\"test_string_7\",\"test_string_8\",\"test_string_9\"],\"testMap\"" - + ":{\"test_map_9\":\"test_value_9\",\"test_map_8\":\"test_value_8\",\"test_map_3\":\"test_value_3\"," - + "\"test_map_2\":\"test_value_2\",\"test_map_1\":\"test_value_1\",\"test_map_0\":\"test_value_0\"," - + "\"test_map_7\":\"test_value_7\",\"test_map_6\":\"test_value_6\",\"test_map_5\":\"test_value_5\",\"test_map_4\":\"test_value_4\"}," - + "\"nullObject\":null,\"emptyList\":[],\"emptyMap\":{},\"nestedMap\":{\"boolean\":false,\"map2\":{},\"map1\":{\"test_map_9\":\"test_value_9\"," - + "\"test_map_8\":\"test_value_8\",\"test_map_3\":\"test_value_3\",\"test_map_2\":\"test_value_2\",\"test_map_1\":\"test_value_1\"," - + "\"test_map_0\":\"test_value_0\",\"test_map_7\":\"test_value_7\"," - + "\"test_map_6\":\"test_value_6\",\"test_map_5\":\"test_value_5\",\"test_map_4\":\"test_value_4\"},\"testInt\":100}}"; - - @Test - public void toJson() { - List testList = new LinkedList<>(); - Map testMap = new HashMap<>(); - for (int i = 0; i < 10; i++) { - testList.add("test_string_" + i); - testMap.put("test_map_" + i, "test_value_" + i); - } - TestObject object = TestObject.builder() - .id(123) - .name("test object") - .deleted(false) - .testList(testList) - .testMap(testMap) - .nullObject(null) - .emptyList(new LinkedList<>()) - .emptyMap(new HashMap<>()) - .nestedMap(new HashMap() { - { - put("map1", testMap); - put("map2", new HashMap<>()); - put("boolean", false); - put("testInt", 100); - put("class", "nestedClass"); - } - }) - .build(); - JsonElement expectedJson = JsonParser.parseString(EXPECTED_JSON); - JsonElement objectJson = JsonParser.parseString(JsonUtils.toJson(object)); - assertEquals(expectedJson, objectJson); - - Object o = new Object(); - assertEquals(Constants.EMPTY_JSON, JsonUtils.toJson(o)); - } - - @Test - public void testJsonToMap() { - Map stringObjectMap = JsonUtils.jsonToMap(EXPECTED_JSON); - assertEquals(stringObjectMap.get("name"), "test object"); - } - - @Test - public void removeClass() { - Map> testMap = new HashMap<>(); - Map testSubMap = new HashMap<>(); - testSubMap.put("class", "NullPointerException.class"); - testSubMap.put("not_class", "ClassNotFoundException.class"); - testMap.put("class", testSubMap); - testMap.put("not_class", testSubMap); - JsonUtils.removeClass(testMap); - assertNull(testMap.getOrDefault("class", null)); - assertEquals(testMap.get("not_class").get("not_class"), "ClassNotFoundException.class"); - - testMap = new HashMap<>(); - testMap.put("result", testSubMap); - JsonUtils.removeClass(testMap); - assertNotNull(testMap.getOrDefault("result", null)); - assertEquals(testMap.get("result").get("not_class"), "ClassNotFoundException.class"); - } - - @Test - public void testJsonToObject() { - TestObject testObject = JsonUtils.jsonToObject(EXPECTED_JSON, TestObject.class); - assertNotNull(testObject); - assertEquals(testObject.getName(), "test object"); - } - - @Test - public void testJsonToMapByValueTypeRef() { - Map stringObjectMap = JsonUtils.jsonToMap(EXPECTED_JSON, Object.class); - assertEquals(stringObjectMap.get("name"), "test object"); - } - - @Test - public void testToMap() { - TestObject testObject = JsonUtils.jsonToObject(EXPECTED_JSON, TestObject.class); - Map testObjectMap = JsonUtils.toMap(testObject); - assertNotNull(testObjectMap); - assertEquals(testObjectMap.get("name"), "test object"); - } - - static class TestObject { - - private int id; - - private String name; - - private boolean deleted; - - private List testList; - - private Map testMap; - - private Object nullObject; - - private List emptyList; - - private Map emptyMap; - - private Map nestedMap; - - /** - * no args constructor. - */ - TestObject() { - } - - /** - * builder constructor. - * - * @param builder builder - */ - private TestObject(final Builder builder) { - this.id = builder.id; - this.name = builder.name; - this.deleted = builder.deleted; - this.testList = builder.testList; - this.testMap = builder.testMap; - this.nullObject = builder.nullObject; - this.emptyList = builder.emptyList; - this.emptyMap = builder.emptyMap; - this.nestedMap = builder.nestedMap; - } - - /** - * class builder. - * - * @return Builder - */ - public static Builder builder() { - return new Builder(); - } - - /** - * get id. - * - * @return id - */ - public int getId() { - return id; - } - - /** - * set id. - * - * @param id id - */ - public void setId(final int id) { - this.id = id; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * get deleted. - * - * @return deleted - */ - public boolean isDeleted() { - return deleted; - } - - /** - * set deleted. - * - * @param deleted deleted - */ - public void setDeleted(final boolean deleted) { - this.deleted = deleted; - } - - /** - * get testList. - * - * @return testList - */ - public List getTestList() { - return testList; - } - - /** - * set testList. - * - * @param testList testList - */ - public void setTestList(final List testList) { - this.testList = testList; - } - - /** - * get testMap. - * - * @return testMap - */ - public Map getTestMap() { - return testMap; - } - - /** - * set testMap. - * - * @param testMap testMap - */ - public void setTestMap(final Map testMap) { - this.testMap = testMap; - } - - /** - * get nullObject. - * - * @return nullObject - */ - public Object getNullObject() { - return nullObject; - } - - /** - * set nullObject. - * - * @param nullObject nullObject - */ - public void setNullObject(final Object nullObject) { - this.nullObject = nullObject; - } - - /** - * get emptyList. - * - * @return emptyList - */ - public List getEmptyList() { - return emptyList; - } - - /** - * set emptyList. - * - * @param emptyList emptyList - */ - public void setEmptyList(final List emptyList) { - this.emptyList = emptyList; - } - - /** - * get emptyMap. - * - * @return emptyMap - */ - public Map getEmptyMap() { - return emptyMap; - } - - /** - * set emptyMap. - * - * @param emptyMap emptyMap - */ - public void setEmptyMap(final Map emptyMap) { - this.emptyMap = emptyMap; - } - - /** - * get nestedMap. - * - * @return nestedMap - */ - public Map getNestedMap() { - return nestedMap; - } - - /** - * set nestedMap. - * - * @param nestedMap nestedMap - */ - public void setNestedMap(final Map nestedMap) { - this.nestedMap = nestedMap; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - TestObject that = (TestObject) o; - return id == that.id && deleted == that.deleted && Objects.equals(name, that.name) && Objects.equals(testList, that.testList) - && Objects.equals(testMap, that.testMap) && Objects.equals(nullObject, that.nullObject) - && Objects.equals(emptyList, that.emptyList) && Objects.equals(emptyMap, that.emptyMap) && Objects.equals(nestedMap, that.nestedMap); - } - - @Override - public int hashCode() { - return Objects.hash(id, name, deleted, testList, testMap, nullObject, emptyList, emptyMap, nestedMap); - } - - @Override - public String toString() { - return "TestObject{" - + "id=" - + id - + ", name='" - + name - + '\'' - + ", deleted=" - + deleted - + ", testList=" - + testList - + ", testMap=" - + testMap - + ", nullObject=" - + nullObject - + ", emptyList=" - + emptyList - + ", emptyMap=" - + emptyMap - + ", nestedMap=" - + nestedMap - + '}'; - } - - /** - * class builder. - */ - public static final class Builder { - - private int id; - - private String name; - - private boolean deleted; - - private List testList; - - private Map testMap; - - private Object nullObject; - - private List emptyList; - - private Map emptyMap; - - private Map nestedMap; - - /** - * no args constructor. - */ - private Builder() { - } - - /** - * build new Object. - * - * @return TestObject - */ - public TestObject build() { - return new TestObject(this); - } - - /** - * build id. - * - * @param id id - * @return this - */ - public Builder id(final int id) { - this.id = id; - return this; - } - - /** - * build name. - * - * @param name name - * @return this - */ - public Builder name(final String name) { - this.name = name; - return this; - } - - /** - * build deleted. - * - * @param deleted deleted - * @return this - */ - public Builder deleted(final boolean deleted) { - this.deleted = deleted; - return this; - } - - /** - * build testList. - * - * @param testList testList - * @return this - */ - public Builder testList(final List testList) { - this.testList = testList; - return this; - } - - /** - * build testMap. - * - * @param testMap testMap - * @return this - */ - public Builder testMap(final Map testMap) { - this.testMap = testMap; - return this; - } - - /** - * build nullObject. - * - * @param nullObject nullObject - * @return this - */ - public Builder nullObject(final Object nullObject) { - this.nullObject = nullObject; - return this; - } - - /** - * build emptyList. - * - * @param emptyList emptyList - * @return this - */ - public Builder emptyList(final List emptyList) { - this.emptyList = emptyList; - return this; - } - - /** - * build emptyMap. - * - * @param emptyMap emptyMap - * @return this - */ - public Builder emptyMap(final Map emptyMap) { - this.emptyMap = emptyMap; - return this; - } - - /** - * build nestedMap. - * - * @param nestedMap nestedMap - * @return this - */ - public Builder nestedMap(final Map nestedMap) { - this.nestedMap = nestedMap; - return this; - } - } - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ListUtilTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ListUtilTest.java deleted file mode 100644 index dc2ae7c..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ListUtilTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.util.Collections; - -/** - * ListUtilTest. - */ -public class ListUtilTest { - - @Test - public void testListUtil() { - Assertions.assertNotNull(ListUtil.emptyIsDefault(Collections.emptyList(), Collections.singletonList(1))); - Assertions.assertNotNull(ListUtil.findFirst(Collections.singletonList(1), res -> res == 1)); - Assertions.assertNull(ListUtil.findFirst(Collections.singletonList(1), res -> false)); - Assertions.assertNull(ListUtil.findFirst(Collections.emptyList(), res -> false)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/LogUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/LogUtilsTest.java deleted file mode 100644 index 9fb1b99..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/LogUtilsTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; - -import java.util.function.Supplier; - -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Test case for {@link LogUtils}. - */ -public final class LogUtilsTest { - - private Logger logger; - - private Supplier supplier; - - @BeforeEach - public void setUp() { - logger = spy(Logger.class); - supplier = mock(Supplier.class); - when(supplier.get()).thenReturn("Test case for LogUtils"); - } - - @Test - public void testAtLeastOnceDebugWithFormat() { - when(logger.isDebugEnabled()).thenReturn(true); - LogUtils.debug(logger, "testDebug: {}", supplier); - verify(supplier, atLeastOnce()).get(); - } - - @Test - public void testNeverDebugWithFormat() { - when(logger.isDebugEnabled()).thenReturn(false); - LogUtils.debug(logger, "testDebug: {}", supplier); - verify(supplier, never()).get(); - } - - @Test - public void testAtLeastOnceDebug() { - when(logger.isDebugEnabled()).thenReturn(true); - LogUtils.debug(logger, supplier); - verify(supplier, atLeastOnce()).get(); - } - - @Test - public void testNeverDebug() { - when(logger.isDebugEnabled()).thenReturn(false); - LogUtils.debug(logger, supplier); - verify(supplier, never()).get(); - } - - @Test - public void testAtLeastOnceInfoWithFormat() { - when(logger.isInfoEnabled()).thenReturn(true); - LogUtils.info(logger, "testInfo: {}", supplier); - verify(supplier, atLeastOnce()).get(); - } - - @Test - public void testNeverInfoWithFormat() { - when(logger.isInfoEnabled()).thenReturn(false); - LogUtils.info(logger, "testInfo: {}", supplier); - verify(supplier, never()).get(); - } - - @Test - public void testAtLeastOnceInfo() { - when(logger.isInfoEnabled()).thenReturn(true); - LogUtils.info(logger, supplier); - verify(supplier, atLeastOnce()).get(); - } - - @Test - public void testNeverInfo() { - when(logger.isInfoEnabled()).thenReturn(false); - LogUtils.info(logger, supplier); - verify(supplier, never()).get(); - } - - @Test - public void testAtLeastOnceErrorFormat() { - when(logger.isErrorEnabled()).thenReturn(true); - LogUtils.error(logger, "testError: {}", supplier); - verify(supplier, atLeastOnce()).get(); - } - - @Test - public void testNeverErrorFormat() { - when(logger.isErrorEnabled()).thenReturn(false); - LogUtils.error(logger, "testError: {}", supplier); - verify(supplier, never()).get(); - } - - @Test - public void testAtLeastOnceError() { - when(logger.isErrorEnabled()).thenReturn(true); - LogUtils.error(logger, supplier); - verify(supplier, atLeastOnce()).get(); - } - - @Test - public void testNeverError() { - when(logger.isErrorEnabled()).thenReturn(false); - LogUtils.error(logger, supplier); - verify(supplier, never()).get(); - } - - @Test - public void testAtLeastOnceWarnWithFormat() { - when(logger.isWarnEnabled()).thenReturn(true); - LogUtils.warn(logger, "testWarn: {}", supplier); - verify(supplier, atLeastOnce()).get(); - } - - @Test - public void testNeverWarnWithFormat() { - when(logger.isWarnEnabled()).thenReturn(false); - LogUtils.warn(logger, "testWarn: {}", supplier); - verify(supplier, never()).get(); - } - - @Test - public void testAtLeastOnceWarn() { - when(logger.isWarnEnabled()).thenReturn(true); - LogUtils.warn(logger, supplier); - verify(supplier, atLeastOnce()).get(); - } - - @Test - public void testNeverWarn() { - when(logger.isWarnEnabled()).thenReturn(false); - LogUtils.warn(logger, supplier); - verify(supplier, never()).get(); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/MapUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/MapUtilsTest.java deleted file mode 100644 index 29c097a..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/MapUtilsTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class MapUtilsTest { - - @Test - public void testTransStringMap() { - Map jsonParams = new HashMap<>(); - jsonParams.put("a", 1); - jsonParams.put("b", 2); - Map stringStringMap = MapUtils.transStringMap(jsonParams); - assertEquals(stringStringMap.get("a").getClass(), String.class); - assertEquals(stringStringMap.get("a"), "1"); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ObjectTypeUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ObjectTypeUtilsTest.java deleted file mode 100644 index d71f8af..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ObjectTypeUtilsTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ObjectTypeUtilsTest { - - @Test - public void testIsBasicType() { - Object o = 1; - assertTrue(ObjectTypeUtils.isBasicType(o)); - o = new Short("1"); - assertTrue(ObjectTypeUtils.isBasicType(o)); - o = new Long("1"); - assertTrue(ObjectTypeUtils.isBasicType(o)); - o = new Double("1"); - assertTrue(ObjectTypeUtils.isBasicType(o)); - o = new Float("1"); - assertTrue(ObjectTypeUtils.isBasicType(o)); - o = Boolean.TRUE; - assertTrue(ObjectTypeUtils.isBasicType(o)); - CharSequence str = "hello world"; - assertTrue(ObjectTypeUtils.isBasicType(str)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ParamCheckUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ParamCheckUtilsTest.java deleted file mode 100644 index 14ae3cf..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ParamCheckUtilsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.shenyu.common.exception.ShenyuException; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test cases for ParamCheckUtils. - */ -public final class ParamCheckUtilsTest { - - @Test - public void testBodyIsEmpty() { - assertTrue(ParamCheckUtils.bodyIsEmpty(null)); - assertTrue(ParamCheckUtils.bodyIsEmpty("")); - assertTrue(ParamCheckUtils.bodyIsEmpty("null")); - assertFalse(ParamCheckUtils.bodyIsEmpty("123")); - } - - @Test - public void testcheckParamsLength() { - assertDoesNotThrow(() -> { - ParamCheckUtils.checkParamsLength(2, 2); }); - } - - @Test - public void testcheckParamsLengthException() { - Throwable exception = assertThrows(ShenyuException.class, () -> { - ParamCheckUtils.checkParamsLength(1, 2); - }); - assertEquals("args.length < types.length", exception.getMessage()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/PathUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/PathUtilsTest.java deleted file mode 100644 index cad939b..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/PathUtilsTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.shenyu.common.constant.AdminConstants; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -public class PathUtilsTest { - private static final String URI_WRAPPER = "springCloud/test/**"; - - private static final String URI = "springCloud/test"; - - private static final String URI_SLASH = "springCloud/test/"; - - @Test - public void testDecoratorPath() { - String uri = PathUtils.decoratorPath(URI); - assertThat(uri, is(URI + AdminConstants.URI_SUFFIX)); - - uri = PathUtils.decoratorPath(URI_WRAPPER); - assertThat(uri, is(URI + AdminConstants.URI_SUFFIX)); - } - - @Test - public void decoratorContextPath() { - String uri = PathUtils.decoratorContextPath(URI); - assertThat(uri, is(URI)); - - uri = PathUtils.decoratorContextPath(URI_WRAPPER); - assertThat(uri, is(URI)); - } - - @Test - public void testDecoratorPathWithSlash() { - String uri = PathUtils.decoratorPathWithSlash(URI); - assertThat(uri, is(URI + AdminConstants.URI_SLASH_SUFFIX)); - - uri = PathUtils.decoratorContextPath(URI_SLASH); - assertThat(uri, is(URI + AdminConstants.URI_SLASH_SUFFIX)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/PluginNameAdapterTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/PluginNameAdapterTest.java deleted file mode 100644 index 2b83082..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/PluginNameAdapterTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.shenyu.common.enums.PluginEnum; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class PluginNameAdapterTest { - - @Test - public void testRpcTypeAdapter() { - Arrays.stream(RpcTypeEnum.values()) - .filter(rpcTypeEnum -> !RpcTypeEnum.HTTP.getName().equals(rpcTypeEnum.getName())) - .forEach(rpcTypeEnum -> assertEquals(PluginNameAdapter.rpcTypeAdapter(rpcTypeEnum.getName()), - PluginEnum.getPluginEnumByName(rpcTypeEnum.getName()).getName())); - - assertEquals(PluginNameAdapter.rpcTypeAdapter(RpcTypeEnum.HTTP.getName()), PluginEnum.DIVIDE.getName()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ReflectUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ReflectUtilsTest.java deleted file mode 100644 index 2cce46b..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ReflectUtilsTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test cases for ReflectUtils. - */ -public final class ReflectUtilsTest { - - @Test - public void testGetFieldValue() { - final Reflect reflect = new Reflect(); - final ReflectNonField reflectNonField = new ReflectNonField(); - assertEquals("1", ReflectUtils.getFieldValue(reflect, "a")); - assertNull(ReflectUtils.getFieldValue(reflect, "")); - assertNull(ReflectUtils.getFieldValue(null, "a")); - assertNull(ReflectUtils.getFieldValue(reflectNonField, "a")); - } - - @Test - public void testSetFieldValue() { - final Reflect reflect = new Reflect(); - ReflectUtils.setFieldValue(reflect, "a", "2"); - assertEquals("2", ReflectUtils.getFieldValue(reflect, "a")); - } - - @Test - public void testInvokeStaticMethod() { - final Reflect reflect = new Reflect(); - assertEquals("1", ReflectUtils.invokeStaticMethod(reflect.getClass(), "methodStaticA")); - assertNull(ReflectUtils.invokeStaticMethod(reflect.getClass(), "methodB")); - } - - @Test - public void testInvokeMethod() { - final Reflect reflect = new Reflect(); - assertEquals("1", ReflectUtils.invokeMethod(reflect, "methodA")); - } - - @Test - public void testIsPrimitives() { - final Reflect reflect = new Reflect(); - Integer[] test = new Integer[]{}; - assertFalse(ReflectUtils.isPrimitives(reflect.getClass())); - assertFalse(ReflectUtils.isPrimitives(reflect.getClass())); - assertTrue(ReflectUtils.isPrimitives(test.getClass())); - } - - static class Reflect { - private final String a = "1"; - - public static String methodStaticA() { - return "1"; - } - - public String methodA() { - return "1"; - } - } - - static class ReflectNonField { - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java deleted file mode 100644 index a1330f2..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrowsExactly; - -/** - * Test cases for SignUtils. - */ -public final class SignUtilsTest { - - @Test - public void testGenerateMd5Sign() { - - assertThat(SignUtils.sign(SignUtils.SIGN_MD5, "test", "a1b2"), - is("7aa98f7d67f8e4730e2d1d3902295ce6")); - } - - @Test - public void testGeneratesSignWithNullKeyOrNullData() { - - assertThrowsExactly(NullPointerException.class, - () -> SignUtils.sign(SignUtils.SIGN_HS256, "key", null)); - - assertThrowsExactly(NullPointerException.class, - () -> SignUtils.sign(SignUtils.SIGN_HS256, null, "data")); - } - - @Test - public void testGeneratesSignWithUnsupportedAlgorithm() { - - assertThrowsExactly(UnsupportedOperationException.class, - () -> SignUtils.sign("supported_algorithm", "key", "data")); - } - - @Test - public void testGenerateKey() { - assertNotNull(SignUtils.generateKey()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SingletonTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SingletonTest.java deleted file mode 100644 index 68a1179..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SingletonTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class SingletonTest { - - @Test - public void testSingle() { - Singleton.INST.single(this.getClass(), this); - assertNotNull(Singleton.INST.get(this.getClass())); - assertEquals(this, Singleton.INST.get(this.getClass())); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiImpl.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiImpl.java deleted file mode 100644 index 4017f29..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -public class SpiImpl implements SpiInterface { -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiInterface.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiInterface.java deleted file mode 100644 index fcc7b5f..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiInterface.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -public interface SpiInterface { -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiLoadFactoryTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiLoadFactoryTest.java deleted file mode 100644 index bb961cf..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/SpiLoadFactoryTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * Test Cases for SpiLoadFactory. - */ -public class SpiLoadFactoryTest { - - @Test - public void testLoadFirst() { - assertNotNull(SpiLoadFactory.loadFirst(SpiInterface.class)); - } - - @Test - public void testLoadFirstNoDefined() { - assertThrows(IllegalStateException.class, () -> SpiLoadFactory.loadFirst(List.class)); - } - - @Test - public void testLoadAll() { - assertNotNull(SpiLoadFactory.loadAll(SpiInterface.class)); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java deleted file mode 100644 index 1e0d6c2..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import java.util.concurrent.TimeUnit; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -/** - * Test Cases for ThreadUtils. - */ -public final class ThreadUtilsTest { - - private TimeUnit timeUnit; - - @BeforeEach - public void setUp() { - timeUnit = mock(TimeUnit.class); - } - - @Test - public void testSleep() throws InterruptedException { - ThreadUtils.sleep(timeUnit, 1); - verify(timeUnit, times(1)).sleep(eq(1L)); - } - - @Test - public void testSleepInterrupt() throws InterruptedException { - doThrow(InterruptedException.class).when(timeUnit).sleep(1); - ThreadUtils.sleep(timeUnit, 1); - verify(timeUnit, times(1)).sleep(eq(1L)); - assertTrue(Thread.interrupted()); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UUIDUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UUIDUtilsTest.java deleted file mode 100644 index 9f80dd2..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UUIDUtilsTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.apache.commons.lang3.StringUtils; -import org.junit.jupiter.api.Test; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.greaterThan; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Test cases for UUIDUtils. - */ -public final class UUIDUtilsTest { - - @Test - public void testGetInstance() { - UUIDUtils uuidUtils = UUIDUtils.getInstance(); - assertNotNull(uuidUtils); - } - - @Test - public void testGenerateShortUuid() { - String shortUuid = UUIDUtils.getInstance().generateShortUuid(); - assertTrue(StringUtils.isNotEmpty(shortUuid)); - assertEquals(19, shortUuid.length()); - } - - @Test - public void testConstructor() throws Exception { - Class uUIDUtilsClass = UUIDUtils.getInstance().getClass(); - Class[] p = {long.class, long.class, long.class}; - Constructor constructor = uUIDUtilsClass.getDeclaredConstructor(p); - constructor.setAccessible(true); - try { - constructor.newInstance(-1L, 10L, 10L); - } catch (InvocationTargetException ex) { - assertTrue(ex.getCause().getMessage().startsWith("worker Id can't be greater than")); - } - - try { - constructor.newInstance(10L, -1L, 10L); - } catch (InvocationTargetException ex) { - assertTrue(ex.getCause().getMessage().startsWith("datacenter Id can't be greater than")); - } - } - - @Test - public void testTilNextMillis() throws Exception { - Class uUIDUtilsClass = UUIDUtils.getInstance().getClass(); - Class[] p = {long.class}; - Method method = uUIDUtilsClass.getDeclaredMethod("tilNextMillis", p); - method.setAccessible(true); - long lastTimestamp = System.currentTimeMillis(); - long result = (long) method.invoke(UUIDUtils.getInstance(), lastTimestamp); - assertThat(result, greaterThan(lastTimestamp)); - } - - @Test - public void testNextIdException() throws Exception { - UUIDUtils uuidUtils = UUIDUtils.getInstance(); - Class uUIDUtilsClass = uuidUtils.getClass(); - Field field = uUIDUtilsClass.getDeclaredField("lastTimestamp"); - field.setAccessible(true); - field.set(uuidUtils, 1617757060000L); - - Method method = uUIDUtilsClass.getDeclaredMethod("nextId"); - method.setAccessible(true); - try { - method.invoke(UUIDUtils.getInstance()); - } catch (InvocationTargetException ex) { - assertTrue(ex.getCause().getMessage().startsWith("Clock moved backwards.")); - } - } - - @Test - public void testNextId() throws Exception { - UUIDUtils uuidUtils = UUIDUtils.getInstance(); - Class uUIDUtilsClass = uuidUtils.getClass(); - Field field = uUIDUtilsClass.getDeclaredField("lastTimestamp"); - field.setAccessible(true); - field.set(uuidUtils, System.currentTimeMillis()); - - Method method = uUIDUtilsClass.getDeclaredMethod("nextId"); - method.setAccessible(true); - method.invoke(UUIDUtils.getInstance()); - } - -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UpstreamCheckUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UpstreamCheckUtilsTest.java deleted file mode 100644 index 47d86db..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UpstreamCheckUtilsTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.net.ServerSocket; -import java.net.Socket; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Test cases for UpstreamCheckUtils. - */ -public final class UpstreamCheckUtilsTest { - - private static final Logger LOG = LoggerFactory.getLogger(UpstreamCheckUtilsTest.class); - - private volatile int port = -1; - - @Test - public void testBlank() { - assertFalse(UpstreamCheckUtils.checkUrl("")); - } - - @Test - @Disabled - public void testSocketConnect() { - Runnable runnable = () -> { - ServerSocket serverSocket; - try { - serverSocket = new ServerSocket(0); - port = serverSocket.getLocalPort(); - Socket socket = serverSocket.accept(); - socket.close(); - } catch (IOException e) { - LOG.error(e.getMessage()); - } - }; - new Thread(runnable).start(); - - while (port == -1) { - Thread.yield(); - } - - assertTrue(UpstreamCheckUtils.checkUrl("127.0.0.1:" + port)); - assertFalse(UpstreamCheckUtils.checkUrl("http://127.0.0.1:" + (port == 0 ? port + 1 : port - 1))); - assertTrue(UpstreamCheckUtils.checkUrl("http://127.0.0.1:" + port)); - assertTrue(UpstreamCheckUtils.checkUrl("https://shenyu.apache.org")); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UriUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UriUtilsTest.java deleted file mode 100644 index b4a686a..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/UriUtilsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import java.net.URI; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNotEquals; - -/** - * Test cases for UriUtils. - */ -public final class UriUtilsTest { - - @Test - void createUri() { - URI uri = UriUtils.createUri("https://example.com"); - assertEquals("https://example.com", uri.toString()); - - uri = UriUtils.createUri(null); - assertNull(uri); - - uri = UriUtils.createUri(""); - assertNull(uri); - - uri = UriUtils.createUri("https", "example.com", "/http"); - assertEquals("https://example.com/http", uri.toString()); - } - - @Test - void repairData() { - String ret = UriUtils.repairData("http"); - assertEquals("/http", ret); - - ret = UriUtils.repairData("/http"); - assertEquals("/http", ret); - } - - @Test - void removePrefix() { - String ret = UriUtils.removePrefix("http"); - assertEquals("http", ret); - - ret = UriUtils.removePrefix("/http"); - assertEquals("http", ret); - } - - @Test - void getPathWithParams() { - URI uri = UriUtils.createUri("https://example.com"); - assertNotNull(uri); - String ret = UriUtils.getPathWithParams(uri); - assertEquals("", ret); - - uri = UriUtils.createUri("https://example.com/path"); - assertNotNull(uri); - ret = UriUtils.getPathWithParams(uri); - assertEquals("/path", ret); - - uri = UriUtils.createUri("https://example.com/path?key=val"); - assertNotNull(uri); - ret = UriUtils.getPathWithParams(uri); - assertEquals("/path?key=val", ret); - - uri = UriUtils.createUri("/path?key=val"); - assertNotNull(uri); - ret = UriUtils.getPathWithParams(uri); - assertEquals("/path?key=val", ret); - } - - @Test - void appendScheme() { - String uri = UriUtils.appendScheme("example.com", "http"); - assertEquals("http://example.com", uri); - - uri = UriUtils.appendScheme("example.com", "https"); - assertEquals("https://example.com", uri); - - uri = UriUtils.appendScheme("https://example.com", "http"); - assertEquals("https://example.com", uri); - assertNotEquals("http://example.com", uri); - - uri = UriUtils.appendScheme("http://example.com", "https"); - assertEquals("http://example.com", uri); - assertNotEquals("https://example.com", uri); - } -} diff --git a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/VersionUtilsTest.java b/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/VersionUtilsTest.java deleted file mode 100644 index e6ff68e..0000000 --- a/shenyu-java-common/src/test/java/org/apache/shenyu/common/utils/VersionUtilsTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.common.utils; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * Test cases for VersionUtils. - */ -public final class VersionUtilsTest { - - @Test - public void testFromDefaultVersion() { - String version = VersionUtils.getVersion(); - assertNotNull(version); - } - - @Test - public void testFromImplementationVersion() throws ClassNotFoundException { - String version = VersionUtils.getVersion(Class.forName("java.lang.String"), "2.0.2"); - assertNotNull(version); - } -} diff --git a/shenyu-java-common/src/test/resources/META-INF/services/org.apache.shenyu.common.utils.SpiInterface b/shenyu-java-common/src/test/resources/META-INF/services/org.apache.shenyu.common.utils.SpiInterface deleted file mode 100644 index 545a12d..0000000 --- a/shenyu-java-common/src/test/resources/META-INF/services/org.apache.shenyu.common.utils.SpiInterface +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -org.apache.shenyu.common.utils.SpiImpl \ No newline at end of file diff --git a/shenyu-java-examples/pom.xml b/shenyu-java-examples/pom.xml deleted file mode 100644 index 1f63d64..0000000 --- a/shenyu-java-examples/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - 4.0.0 - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - pom - - - org.springframework.boot - spring-boot-starter-parent - 2.7.18 - - - - - 3.7.0 - 2.5 - 0.40.1 - 3.4.0 - 2.10.0 - - - - shenyu-java-examples-common - shenyu-java-examples-http - shenyu-java-examples-http-swagger2 - shenyu-java-examples-https - shenyu-java-examples-dubbo - shenyu-java-examples-springcloud - shenyu-java-examples-eureka - shenyu-java-examples-sofa - shenyu-java-examples-tars - shenyu-java-examples-grpc - shenyu-java-examples-motan - shenyu-java-examples-websocket - shenyu-java-examples-springmvc - shenyu-java-examples-springmvc-tomcat - - - - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - ${project.build.sourceEncoding} - - - - org.codehaus.mojo - versions-maven-plugin - ${versions-maven-plugin.version} - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - /../script/shenyu_checkstyle.xml - /../script/checkstyle-header.txt - true - **/transfer/**/* - - - - validate - validate - - check - - - - - - - - - - mac-apple-silicon - - - mac - aarch64 - - - - osx-x86_64 - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-common/pom.xml b/shenyu-java-examples/shenyu-java-examples-common/pom.xml deleted file mode 100644 index 4a3e40f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-common/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - - shenyu-java-examples-common - - - 8 - 8 - - - - - org.springframework.boot - spring-boot-starter-aop - - - diff --git a/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/InterceptorConfiguration.java b/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/InterceptorConfiguration.java deleted file mode 100644 index f721ef2..0000000 --- a/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/InterceptorConfiguration.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.common.aop; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class InterceptorConfiguration { - - /** - * define a bean with the name logInterceptor. - * @return logInterceptor - */ - @Bean - public LogInterceptor logInterceptor() { - return new LogInterceptor(); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/Log.java b/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/Log.java deleted file mode 100644 index eccdcb8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/Log.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.common.aop; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Log { -} diff --git a/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/LogInterceptor.java b/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/LogInterceptor.java deleted file mode 100644 index a450000..0000000 --- a/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/LogInterceptor.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.common.aop; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Aspect -public class LogInterceptor { - - private static final Logger log = LoggerFactory.getLogger(LogInterceptor.class); - - /** - * log annotation pointcut. - */ - @Pointcut("@annotation(org.apache.shenyu.examples.common.aop.Log)") - public void logPointcut() { - //just for pointcut - } - - /** - * define log pointcut with around advice. - * @param point joinPoint - * @return the result of proceeding - */ - @Around("logPointcut()") - public Object around(final ProceedingJoinPoint point) { - try { - log.info("before"); - return point.proceed(point.getArgs()); - } catch (Throwable throwable) { - log.error("log point cut throw exception:", throwable); - } finally { - log.info("after"); - } - return null; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/package-info.java b/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/package-info.java deleted file mode 100644 index 05699a0..0000000 --- a/shenyu-java-examples/shenyu-java-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -/** - * package-info. - */ -package org.apache.shenyu.examples.common.aop; diff --git a/shenyu-java-examples/shenyu-java-examples-common/src/main/resources/META-INF/spring.factories b/shenyu-java-examples/shenyu-java-examples-common/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 9c5516e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-common/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.examples.common.aop.InterceptorConfiguration diff --git a/shenyu-java-examples/shenyu-java-examples-common/src/main/resources/META-INF/spring.provides b/shenyu-java-examples/shenyu-java-examples-common/src/main/resources/META-INF/spring.provides deleted file mode 100644 index ad70cf8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-common/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1 +0,0 @@ -provides: shenyu-examples-common \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/pom.xml b/shenyu-java-examples/shenyu-java-examples-dubbo/pom.xml deleted file mode 100644 index 84aff52..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-dubbo - pom - - - shenyu-java-examples-dubbo-api - shenyu-java-examples-apache-dubbo-service - shenyu-java-examples-apache-dubbo-service-annotation - shenyu-java-examples-apache-dubbo-service-xml - - - - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - org.apache.shenyu - shenyu-java-examples-dubbo-api - ${project.version} - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/pom.xml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/pom.xml deleted file mode 100644 index 93e9437..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/pom.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - shenyu-java-examples-dubbo - org.apache.shenyu - 2.7.1-SNAPSHOT - - 4.0.0 - - shenyu-examples-java-apache-dubbo-service-annotation - - - 5.2.1 - 2.2.4 - 3.2.11 - 3.7.2 - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-apache-dubbo - ${project.version} - - - - - - - org.apache.shenyu - shenyu-java-examples-dubbo-api - - - - org.springframework.boot - spring-boot-starter-web - - - org.apache.shenyu - shenyu-java-examples-common - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-autoconfigure - - - - - org.apache.dubbo - dubbo-spring-boot-starter - ${apache.dubbo.version} - - - - - org.apache.dubbo - dubbo-registry-nacos - ${apache.dubbo.version} - - - - - - org.apache.curator - curator-client - ${curator.version} - - - - org.apache.curator - curator-framework - ${curator.version} - - - - org.apache.curator - curator-recipes - ${curator.version} - - - - org.apache.zookeeper - zookeeper - ${zookeeper.version} - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/http/apache-dubbo-class-test-api.http b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/http/apache-dubbo-class-test-api.http deleted file mode 100644 index 0236a62..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/http/apache-dubbo-class-test-api.http +++ /dev/null @@ -1,191 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy orderSave -POST http://localhost:9195/dubbo/demo/findById -Accept: application/json -Content-Type: application/json - -{ - "id": "123" -} - -### shengyu getway proxy findAll -GET http://localhost:9195/dubbo/demo/findAll -Accept: application/json - - -### shengyu getway proxy insert -POST http://localhost:9195/dubbo/demo/insert -Accept: application/json -Content-Type: application/json - -{ - "id": "123", - "name": "test" -} - -### shengyu getway proxy findList -GET http://localhost:9195/dubbo/demo/findList -Accept: application/json - -### shengyu getway proxy findByIdsAndName -GET http://localhost:9195/dubbo/demo/findByIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByArrayIdsAndName -GET http://localhost:9195/dubbo/demo/findByArrayIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByStringArray -GET http://localhost:9195/dubbo/demo/findByStringArray -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - "123", - "124", - "125" - ] -} - -### shengyu getway proxy findByListId -GET http://localhost:9195/dubbo/demo/findByListId -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ] -} - -### shengyu getway proxy batchSave -PUT http://localhost:9195/dubbo/demo/batchSave -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ] -} - -### shengyu getway proxy batchSaveAndNameAndId -PUT http://localhost:9195/dubbo/demo/batchSaveAndNameAndId -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ], - "id": "123", - "name": "test" -} - -### shengyu getway proxy saveComplexBeanTest -PUT http://localhost:9195/dubbo/demo/saveComplexBeanTest -Accept: application/json -Content-Type: application/json - -{ - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } -} - -### shengyu getway proxy saveComplexBeanTestAndName -PUT http://localhost:9195/dubbo/demo/saveComplexBeanTestAndName -Accept: application/json -Content-Type: application/json - -## The order of the parameters is important -{ - "complexBeanTest": { - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } - }, - "name": "name" -} - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/http/apache-dubbo-test-api.http b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/http/apache-dubbo-test-api.http deleted file mode 100644 index afe37b6..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/http/apache-dubbo-test-api.http +++ /dev/null @@ -1,187 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy orderSave -POST http://localhost:9195/dubbo/findById -Accept: application/json -Content-Type: application/json - -{ - "id": "123" -} - -### shengyu getway proxy findAll -GET http://localhost:9195/dubbo/findAll -Accept: application/json - - -### shengyu getway proxy insert -POST http://localhost:9195/dubbo/insert -Accept: application/json -Content-Type: application/json - -{ - "id": "123", - "name": "test" -} - -### shengyu getway proxy findByIdsAndName -GET http://localhost:9195/dubbo/findByIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByArrayIdsAndName -GET http://localhost:9195/dubbo/findByArrayIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByStringArray -GET http://localhost:9195/dubbo/findByStringArray -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - "123", - "124", - "125" - ] -} - -### shengyu getway proxy findByListId -GET http://localhost:9195/dubbo/findByListId -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ] -} - -### shengyu getway proxy batchSave -PUT http://localhost:9195/dubbo/batchSave -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ] -} - -### shengyu getway proxy batchSaveAndNameAndId -PUT http://localhost:9195/dubbo/batchSaveAndNameAndId -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ], - "id": "123", - "name": "test" -} - -### shengyu getway proxy saveComplexBeanTest -PUT http://localhost:9195/dubbo/saveComplexBeanTest -Accept: application/json -Content-Type: application/json - -{ - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } -} - -### shengyu getway proxy saveComplexBeanTestAndName -PUT http://localhost:9195/dubbo/saveComplexBeanTestAndName -Accept: application/json -Content-Type: application/json - -## The order of the parameters is important -{ - "complexBeanTest": { - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } - }, - "name": "name" -} - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/TestApacheDubboAnnotationApplication.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/TestApacheDubboAnnotationApplication.java deleted file mode 100644 index 5cb7d87..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/TestApacheDubboAnnotationApplication.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.annotation; - -import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * TestDubboApplication. - */ -@SpringBootApplication -@EnableDubbo -public class TestApacheDubboAnnotationApplication { - - /** - * Main Entrance. - * - * @param args startup arguments - */ - public static void main(final String[] args) { - SpringApplication.run(TestApacheDubboAnnotationApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboClassMultiParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboClassMultiParamServiceImpl.java deleted file mode 100644 index c009b02..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboClassMultiParamServiceImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.annotation.impl; - -import org.apache.shenyu.client.apache.dubbo.annotation.ShenyuDubboService; -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.examples.dubbo.api.entity.ComplexBeanTest; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.service.DubboClassMultiParamService; -import org.springframework.lang.NonNull; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * The type Dubbo multi param service. - */ -@ShenyuDubboService("/demo") -@ApiModule(value = "demo") -public class DubboClassMultiParamServiceImpl implements DubboClassMultiParamService { - - @Override - @ShenyuDubboClient("/findByIdsAndName") - @ApiDoc(desc = "findByIdsAndName") - public DubboTest findByIdsAndName(final List ids, final String name) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByArrayIdsAndName") - @ApiDoc(desc = "findByArrayIdsAndName") - public DubboTest findByArrayIdsAndName(final Integer[] ids, final String name) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByArrayIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByStringArray") - @ApiDoc(desc = "findByStringArray") - public DubboTest findByStringArray(final String[] ids) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByStringArray"); - } - - @Override - @ShenyuDubboClient("/findByListId") - @ApiDoc(desc = "findByListId") - public DubboTest findByListId(final List ids) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByListId"); - } - - @Override - @ShenyuDubboClient("/batchSave") - @ApiDoc(desc = "batchSave") - public DubboTest batchSave(final List dubboTestList) { - return new DubboTest(join(dubboTestList, DubboTest::getId), - "hello world shenyu apache dubbo param batchSave :" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/batchSaveAndNameAndId") - @ApiDoc(desc = "batchSaveAndNameAndId") - public DubboTest batchSaveAndNameAndId(final List dubboTestList, final String id, final String name) { - return new DubboTest(id, "hello world shenyu apache dubbo param batchSaveAndNameAndId :" - + name + ":" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTest") - @ApiDoc(desc = "saveComplexBeanTest") - public DubboTest saveComplexBeanTest(final ComplexBeanTest complexBeanTest) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu apache dubbo param saveComplexBeanTest :" + complexBeanTest.getDubboTest().getName()); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTestAndName") - @ApiDoc(desc = "saveComplexBeanTestAndName") - public DubboTest saveComplexBeanTestAndName(final ComplexBeanTest complexBeanTest, final String name) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu alibaba dubbo param saveComplexBeanTestAndName :" + complexBeanTest.getDubboTest().getName() + "-" + name); - } - - @Override - @ShenyuDubboClient("/bigRequestBody") - @ApiDoc(desc = "bigRequestBody") - public DubboTest saveBigRequestBody(final DubboTest dubboTest) { - return dubboTest; - } - - private String join(final @NonNull List list, final Function mapper) { - return list.stream() - .map(mapper) - .collect(Collectors.joining("-")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboClassTestServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboClassTestServiceImpl.java deleted file mode 100644 index f4a7f1f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboClassTestServiceImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.annotation.impl; - -import org.apache.dubbo.rpc.RpcContext; -import org.apache.shenyu.client.apache.dubbo.annotation.ShenyuDubboService; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.entity.ListResp; -import org.apache.shenyu.examples.dubbo.api.service.DubboClassTestService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collections; -import java.util.Random; - -/** - * The type Dubbo service. - */ -@ShenyuDubboService("/demo/**") -public class DubboClassTestServiceImpl implements DubboClassTestService { - - private static final Logger LOGGER = LoggerFactory.getLogger(DubboClassTestServiceImpl.class); - - @Override - public DubboTest findById(final String id) { - LOGGER.info(GsonUtils.getInstance().toJson(RpcContext.getContext().getObjectAttachments())); - return new DubboTest(id, "hello world shenyu Apache, findById"); - } - - @Override - public DubboTest findAll() { - return new DubboTest(String.valueOf(new Random().nextInt()), "hello world shenyu Apache, findAll"); - } - - @Override - public DubboTest insert(final DubboTest dubboTest) { - dubboTest.setName("hello world shenyu Apache Dubbo: " + dubboTest.getName()); - return dubboTest; - } - - @Override - public ListResp findList() { - return new ListResp(1, Collections.singletonList(new DubboTest("1", "test"))); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboMultiParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboMultiParamServiceImpl.java deleted file mode 100644 index 73be1eb..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboMultiParamServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.annotation.impl; - -import org.apache.dubbo.config.annotation.DubboService; -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.examples.dubbo.api.entity.ComplexBeanTest; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.service.DubboMultiParamService; -import org.springframework.lang.NonNull; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * The type Dubbo multi param service. - */ -@DubboService -@ApiModule(value = "dubboMultiParamService") -public class DubboMultiParamServiceImpl implements DubboMultiParamService { - - @Override - @ShenyuDubboClient("/findByIdsAndName") - @ApiDoc(desc = "findByIdsAndName") - public DubboTest findByIdsAndName(final List ids, final String name) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByArrayIdsAndName") - @ApiDoc(desc = "findByArrayIdsAndName") - public DubboTest findByArrayIdsAndName(final Integer[] ids, final String name) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByArrayIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByStringArray") - @ApiDoc(desc = "findByStringArray") - public DubboTest findByStringArray(final String[] ids) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByStringArray"); - } - - @Override - @ShenyuDubboClient("/findByListId") - @ApiDoc(desc = "findByListId") - public DubboTest findByListId(final List ids) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByListId"); - } - - @Override - @ShenyuDubboClient("/batchSave") - @ApiDoc(desc = "batchSave") - public DubboTest batchSave(final List dubboTestList) { - return new DubboTest(join(dubboTestList, DubboTest::getId), - "hello world shenyu apache dubbo param batchSave :" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/batchSaveAndNameAndId") - @ApiDoc(desc = "batchSaveAndNameAndId") - public DubboTest batchSaveAndNameAndId(final List dubboTestList, final String id, final String name) { - return new DubboTest(id, "hello world shenyu apache dubbo param batchSaveAndNameAndId :" - + name + ":" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTest") - @ApiDoc(desc = "saveComplexBeanTest") - public DubboTest saveComplexBeanTest(final ComplexBeanTest complexBeanTest) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu apache dubbo param saveComplexBeanTest :" + complexBeanTest.getDubboTest().getName()); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTestAndName") - @ApiDoc(desc = "saveComplexBeanTestAndName") - public DubboTest saveComplexBeanTestAndName(final ComplexBeanTest complexBeanTest, final String name) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu alibaba dubbo param saveComplexBeanTestAndName :" + complexBeanTest.getDubboTest().getName() + "-" + name); - } - - private String join(final @NonNull List list, final Function mapper) { - return list.stream() - .map(mapper) - .collect(Collectors.joining("-")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java deleted file mode 100644 index acdd6af..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/annotation/impl/DubboTestServiceImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.annotation.impl; - -import org.apache.dubbo.config.annotation.DubboService; -import org.apache.dubbo.rpc.RpcContext; -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.entity.ListResp; -import org.apache.shenyu.examples.dubbo.api.service.DubboTestService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collections; -import java.util.Random; - -/** - * The type Dubbo service. - */ -@DubboService -@ApiModule(value = "dubboTestService") -public class DubboTestServiceImpl implements DubboTestService { - - private static final Logger LOGGER = LoggerFactory.getLogger(DubboTestServiceImpl.class); - - @Override - @ShenyuDubboClient("/findById") - @Log - @ApiDoc(desc = "findById") - public DubboTest findById(final String id) { - LOGGER.info(GsonUtils.getInstance().toJson(RpcContext.getContext().getAttachments())); - return new DubboTest(id, "hello world shenyu Apache, findById"); - } - - @Override - @ShenyuDubboClient("/findAll") - @ApiDoc(desc = "findAll") - public DubboTest findAll() { - return new DubboTest(String.valueOf(new Random().nextInt()), "hello world shenyu Apache, findAll"); - } - - @Override - @ShenyuDubboClient("/insert") - @ApiDoc(desc = "insert") - public DubboTest insert(final DubboTest dubboTest) { - dubboTest.setName("hello world shenyu Apache Dubbo: " + dubboTest.getName()); - return dubboTest; - } - - @Override - @ShenyuDubboClient("/findList") - @ApiDoc(desc = "findList") - public ListResp findList() { - return new ListResp(1, Collections.singletonList(new DubboTest("1", "test"))); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/resources/application.yml deleted file mode 100644 index 3f9582d..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-annotation/src/main/resources/application.yml +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8011 - address: 0.0.0.0 - servlet: - context-path: / -spring: - main: - allow-bean-definition-overriding: true - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - dubbo: - props: - contextPath: /dubbo - appName: dubbo - -dubbo: - application: - name: test-dubbo-service - registry: - address: nacos://127.0.0.1:8848 - protocol: - name: dubbo - port: 20888 - scan: - base-packages: org.apache.shenyu.examples.apache.dubbo.service.annotation.impl diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/Dockerfile b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/Dockerfile deleted file mode 100644 index ff1f5d4..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM amazoncorretto:17.0.11-alpine3.19 - -ENV APP_NAME shenyu-java-examples-apache-dubbo-service-xml -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8011 -EXPOSE 20888 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/pom.xml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/pom.xml deleted file mode 100644 index 10acee1..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/pom.xml +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples-dubbo - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-apache-dubbo-service-xml - - - 5.2.1 - 2.2.4 - 3.2.11 - 3.7.2 - - - - - org.apache.shenyu - shenyu-client-java-apache-dubbo - ${project.version} - - - - - - - org.apache.shenyu - shenyu-java-examples-dubbo-api - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - org.apache.shenyu - shenyu-java-examples-common - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-autoconfigure - - - - - org.apache.dubbo - dubbo - ${apache.dubbo.version} - - - - - - org.apache.dubbo - dubbo-registry-nacos - ${apache.dubbo.version} - - - - - com.alibaba.nacos - nacos-client - ${nacos-client.version} - - - - org.apache.curator - curator-client - ${curator.version} - - - org.apache.curator - curator-framework - ${curator.version} - - - org.apache.curator - curator-recipes - ${curator.version} - - - org.apache.curator - curator-x-discovery - ${curator.version} - - - - org.apache.zookeeper - zookeeper - ${zookeeper.version} - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - - - shenyu-java-examples-apache-dubbo-service-xml - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.apache.dubbo.service.xml.TestApacheDubboXmlApplication - true - - - - - - - - example - - shenyu-java-examples-apache-dubbo-service-xml - shenyu-java-examples-apache-dubbo-service-xml - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-java-examples-apache-dubbo-service-xml - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/http/apache-dubbo-class-test-api.http b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/http/apache-dubbo-class-test-api.http deleted file mode 100644 index 0236a62..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/http/apache-dubbo-class-test-api.http +++ /dev/null @@ -1,191 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy orderSave -POST http://localhost:9195/dubbo/demo/findById -Accept: application/json -Content-Type: application/json - -{ - "id": "123" -} - -### shengyu getway proxy findAll -GET http://localhost:9195/dubbo/demo/findAll -Accept: application/json - - -### shengyu getway proxy insert -POST http://localhost:9195/dubbo/demo/insert -Accept: application/json -Content-Type: application/json - -{ - "id": "123", - "name": "test" -} - -### shengyu getway proxy findList -GET http://localhost:9195/dubbo/demo/findList -Accept: application/json - -### shengyu getway proxy findByIdsAndName -GET http://localhost:9195/dubbo/demo/findByIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByArrayIdsAndName -GET http://localhost:9195/dubbo/demo/findByArrayIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByStringArray -GET http://localhost:9195/dubbo/demo/findByStringArray -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - "123", - "124", - "125" - ] -} - -### shengyu getway proxy findByListId -GET http://localhost:9195/dubbo/demo/findByListId -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ] -} - -### shengyu getway proxy batchSave -PUT http://localhost:9195/dubbo/demo/batchSave -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ] -} - -### shengyu getway proxy batchSaveAndNameAndId -PUT http://localhost:9195/dubbo/demo/batchSaveAndNameAndId -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ], - "id": "123", - "name": "test" -} - -### shengyu getway proxy saveComplexBeanTest -PUT http://localhost:9195/dubbo/demo/saveComplexBeanTest -Accept: application/json -Content-Type: application/json - -{ - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } -} - -### shengyu getway proxy saveComplexBeanTestAndName -PUT http://localhost:9195/dubbo/demo/saveComplexBeanTestAndName -Accept: application/json -Content-Type: application/json - -## The order of the parameters is important -{ - "complexBeanTest": { - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } - }, - "name": "name" -} - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/http/apache-dubbo-test-api.http b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/http/apache-dubbo-test-api.http deleted file mode 100644 index c5289b8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/http/apache-dubbo-test-api.http +++ /dev/null @@ -1,191 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy orderSave -POST http://localhost:9195/dubbo/findById -Accept: application/json -Content-Type: application/json - -{ - "id": "123" -} - -### shengyu getway proxy findAll -GET http://localhost:9195/dubbo/findAll -Accept: application/json - - -### shengyu getway proxy insert -POST http://localhost:9195/dubbo/insert -Accept: application/json -Content-Type: application/json - -{ - "id": "123", - "name": "test" -} - -### shengyu getway proxy findList -GET http://localhost:9195/dubbo/findList -Accept: application/json - -### shengyu getway proxy findByIdsAndName -GET http://localhost:9195/dubbo/findByIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByArrayIdsAndName -GET http://localhost:9195/dubbo/findByArrayIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByStringArray -GET http://localhost:9195/dubbo/findByStringArray -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - "123", - "124", - "125" - ] -} - -### shengyu getway proxy findByListId -GET http://localhost:9195/dubbo/findByListId -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ] -} - -### shengyu getway proxy batchSave -PUT http://localhost:9195/dubbo/batchSave -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ] -} - -### shengyu getway proxy batchSaveAndNameAndId -PUT http://localhost:9195/dubbo/batchSaveAndNameAndId -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ], - "id": "123", - "name": "test" -} - -### shengyu getway proxy saveComplexBeanTest -PUT http://localhost:9195/dubbo/saveComplexBeanTest -Accept: application/json -Content-Type: application/json - -{ - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } -} - -### shengyu getway proxy saveComplexBeanTestAndName -PUT http://localhost:9195/dubbo/saveComplexBeanTestAndName -Accept: application/json -Content-Type: application/json - -## The order of the parameters is important -{ - "complexBeanTest": { - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } - }, - "name": "name" -} - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/TestApacheDubboXmlApplication.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/TestApacheDubboXmlApplication.java deleted file mode 100644 index f3a962a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/TestApacheDubboXmlApplication.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.xml; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ImportResource; - -/** - * Demo show users how to use shenyu-client-apache-dubbo jar in their apache dubbo project. - */ -@SpringBootApplication -@ImportResource({"classpath:spring-dubbo.xml", "classpath:shenyu.xml"}) -public class TestApacheDubboXmlApplication { - - /** - * Main Entrance. - * @param args startup arguments - */ - public static void main(final String[] args) { - SpringApplication.run(TestApacheDubboXmlApplication.class, args); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboClassMultiParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboClassMultiParamServiceImpl.java deleted file mode 100644 index 07c97cc..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboClassMultiParamServiceImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.xml.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.examples.dubbo.api.entity.ComplexBeanTest; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.service.DubboClassMultiParamService; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * The type Dubbo multi param service. - */ -@Service("dubboClassMultiParamService") -@ShenyuDubboClient("/demo") -@ApiModule(value = "dubboClassMultiParamService") -public class DubboClassMultiParamServiceImpl implements DubboClassMultiParamService { - - @Override - @ShenyuDubboClient("/findByIdsAndName") - @ApiDoc(desc = "findByIdsAndName") - public DubboTest findByIdsAndName(final List ids, final String name) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByArrayIdsAndName") - @ApiDoc(desc = "findByArrayIdsAndName") - public DubboTest findByArrayIdsAndName(final Integer[] ids, final String name) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByArrayIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByStringArray") - @ApiDoc(desc = "findByStringArray") - public DubboTest findByStringArray(final String[] ids) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByStringArray"); - } - - @Override - @ShenyuDubboClient("/findByListId") - @ApiDoc(desc = "findByListId") - public DubboTest findByListId(final List ids) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByListId"); - } - - @Override - @ShenyuDubboClient("/batchSave") - @ApiDoc(desc = "batchSave") - public DubboTest batchSave(final List dubboTestList) { - return new DubboTest(join(dubboTestList, DubboTest::getId), - "hello world shenyu apache dubbo param batchSave :" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/batchSaveAndNameAndId") - @ApiDoc(desc = "batchSaveAndNameAndId") - public DubboTest batchSaveAndNameAndId(final List dubboTestList, final String id, final String name) { - return new DubboTest(id, "hello world shenyu apache dubbo param batchSaveAndNameAndId :" - + name + ":" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTest") - @ApiDoc(desc = "saveComplexBeanTest") - public DubboTest saveComplexBeanTest(final ComplexBeanTest complexBeanTest) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu apache dubbo param saveComplexBeanTest :" + complexBeanTest.getDubboTest().getName()); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTestAndName") - @ApiDoc(desc = "saveComplexBeanTestAndName") - public DubboTest saveComplexBeanTestAndName(final ComplexBeanTest complexBeanTest, final String name) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu alibaba dubbo param saveComplexBeanTestAndName :" + complexBeanTest.getDubboTest().getName() + "-" + name); - } - - @Override - @ShenyuDubboClient("/bigRequestBody") - @ApiDoc(desc = "bigRequestBody") - public DubboTest saveBigRequestBody(final DubboTest dubboTest) { - return dubboTest; - } - - private String join(final @NonNull List list, final Function mapper) { - return list.stream() - .map(mapper) - .collect(Collectors.joining("-")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboClassTestServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboClassTestServiceImpl.java deleted file mode 100644 index 80b968b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboClassTestServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.xml.impl; - -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.entity.ListResp; -import org.apache.shenyu.examples.dubbo.api.service.DubboClassTestService; -import org.springframework.stereotype.Service; - -import java.util.Collections; -import java.util.Random; - -/** - * DubboTestServiceImpl. - */ -@Service("dubboClassTestService") -@ShenyuDubboClient("/demo/**") -public class DubboClassTestServiceImpl implements DubboClassTestService { - - @Override - public DubboTest findById(final String id) { - return new DubboTest(id, "hello world shenyu Apache, findById"); - } - - @Override - public DubboTest findAll() { - return new DubboTest(String.valueOf(new Random().nextInt()), "hello world shenyu Apache, findAll"); - } - - @Override - public DubboTest insert(final DubboTest dubboTest) { - dubboTest.setName("hello world shenyu Apache Dubbo: " + dubboTest.getName()); - return dubboTest; - } - - @Override - public ListResp findList() { - return new ListResp(1, Collections.singletonList(new DubboTest("1", "test"))); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboMultiParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboMultiParamServiceImpl.java deleted file mode 100644 index 8599962..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboMultiParamServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.xml.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.examples.dubbo.api.entity.ComplexBeanTest; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.service.DubboMultiParamService; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * The type Dubbo multi param service. - */ -@Service("dubboMultiParamService") -@ApiModule(value = "dubboMultiParamService") -public class DubboMultiParamServiceImpl implements DubboMultiParamService { - - @Override - @ShenyuDubboClient("/findByIdsAndName") - @ApiDoc(desc = "findByIdsAndName") - public DubboTest findByIdsAndName(final List ids, final String name) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByArrayIdsAndName") - @ApiDoc(desc = "findByArrayIdsAndName") - public DubboTest findByArrayIdsAndName(final Integer[] ids, final String name) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByArrayIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByStringArray") - @ApiDoc(desc = "findByStringArray") - public DubboTest findByStringArray(final String[] ids) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByStringArray"); - } - - @Override - @ShenyuDubboClient("/findByListId") - @ApiDoc(desc = "findByListId") - public DubboTest findByListId(final List ids) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByListId"); - } - - @Override - @ShenyuDubboClient("/batchSave") - @ApiDoc(desc = "batchSave") - public DubboTest batchSave(final List dubboTestList) { - return new DubboTest(join(dubboTestList, DubboTest::getId), - "hello world shenyu apache dubbo param batchSave :" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/batchSaveAndNameAndId") - @ApiDoc(desc = "batchSaveAndNameAndId") - public DubboTest batchSaveAndNameAndId(final List dubboTestList, final String id, final String name) { - return new DubboTest(id, "hello world shenyu apache dubbo param batchSaveAndNameAndId :" - + name + ":" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTest") - @ApiDoc(desc = "saveComplexBeanTest") - public DubboTest saveComplexBeanTest(final ComplexBeanTest complexBeanTest) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu apache dubbo param saveComplexBeanTest :" + complexBeanTest.getDubboTest().getName()); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTestAndName") - @ApiDoc(desc = "saveComplexBeanTestAndName") - public DubboTest saveComplexBeanTestAndName(final ComplexBeanTest complexBeanTest, final String name) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu alibaba dubbo param saveComplexBeanTestAndName :" + complexBeanTest.getDubboTest().getName() + "-" + name); - } - - private String join(final @NonNull List list, final Function mapper) { - return list.stream() - .map(mapper) - .collect(Collectors.joining("-")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboTestServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboTestServiceImpl.java deleted file mode 100644 index 1261588..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/xml/impl/DubboTestServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.xml.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.entity.ListResp; -import org.apache.shenyu.examples.dubbo.api.service.DubboTestService; -import org.springframework.stereotype.Service; - -import java.util.Collections; -import java.util.Random; - -/** - * DubboTestServiceImpl. - */ -@Service("dubboTestService") -@ApiModule(value = "dubboTestService") -public class DubboTestServiceImpl implements DubboTestService { - - @Override - @ShenyuDubboClient("/findById") - @Log - @ApiDoc(desc = "findById") - public DubboTest findById(final String id) { - return new DubboTest(id, "hello world shenyu Apache, findById"); - } - - @Override - @ShenyuDubboClient("/findAll") - @ApiDoc(desc = "findAll") - public DubboTest findAll() { - return new DubboTest(String.valueOf(new Random().nextInt()), "hello world shenyu Apache, findAll"); - } - - @Override - @ShenyuDubboClient("/insert") - @ApiDoc(desc = "insert") - public DubboTest insert(final DubboTest dubboTest) { - dubboTest.setName("hello world shenyu Apache Dubbo: " + dubboTest.getName()); - return dubboTest; - } - - @Override - @ShenyuDubboClient("/findList") - @ApiDoc(desc = "findList") - public ListResp findList() { - return new ListResp(1, Collections.singletonList(new DubboTest("1", "test"))); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/application.yml deleted file mode 100644 index 3b66722..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/application.yml +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8011 - address: 0.0.0.0 - servlet: - context-path: / -spring: - main: - allow-bean-definition-overriding: true -dubbo: - registry: - address: zookeeper://localhost:2181 - port: 20888 \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/shenyu.xml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/shenyu.xml deleted file mode 100644 index 8cf4b32..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/shenyu.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - admin - 123456 - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/spring-dubbo.xml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/spring-dubbo.xml deleted file mode 100644 index b187dad..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service-xml/src/main/resources/spring-dubbo.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/Dockerfile b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/Dockerfile deleted file mode 100644 index 0bcaf01..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM amazoncorretto:17.0.11-alpine3.19 - -ENV APP_NAME shenyu-examples-apache-dubbo-service -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8011 -EXPOSE 20888 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/ingress.yml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/ingress.yml deleted file mode 100644 index 315230f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/ingress.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -apiVersion: v1 -kind: Service -metadata: - name: dubbo-find-id - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-dubbo-enabled: 'true' - shenyu.apache.org/plugin-dubbo-app-name: dubbo - shenyu.apache.org/plugin-dubbo-path: /findById - shenyu.apache.org/plugin-dubbo-rpc-type: dubbo - shenyu.apache.org/plugin-dubbo-service-name: org.apache.shenyu.examples.dubbo.api.service.DubboTestService - shenyu.apache.org/plugin-dubbo-method-name: findById - shenyu.apache.org/plugin-dubbo-params-type: java.lang.String - shenyu.apache.org/plugin-dubbo-rpc-expand: | - {"group":"","version":"v0.0.2","loadbalance":"random","retries":2,"timeout":10000,"url":"","sent":false,"cluster":"failover","protocol":"dubbo"} -# shenyu.apache.org/zookeeper-register-address: zookeeper://shenyu-zk:2181 -spec: - selector: - app: shenyu-java-examples-apache-dubbo-service - ports: - - port: 8011 - ---- - -apiVersion: v1 -kind: Service -metadata: - name: dubbo-find-all - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-dubbo-enabled: 'true' - shenyu.apache.org/plugin-dubbo-app-name: dubbo - shenyu.apache.org/plugin-dubbo-path: /findAll - shenyu.apache.org/plugin-dubbo-rpc-type: dubbo - shenyu.apache.org/plugin-dubbo-service-name: org.apache.shenyu.examples.dubbo.api.service.DubboTestService - shenyu.apache.org/plugin-dubbo-method-name: findAll - shenyu.apache.org/plugin-dubbo-rpc-expand: | - {"group":"","version":"v0.0.2","loadbalance":"random","retries":2,"timeout":10000,"url":"","sent":false,"cluster":"failover","protocol":"dubbo"} -spec: - selector: - app: shenyu-java-examples-apache-dubbo-service - ports: - - port: 8011 - ---- - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - namespace: shenyu-ingress - labels: - shenyu.apache.org/metadata-labels-1: dubbo-find-id - shenyu.apache.org/metadata-labels-2: dubbo-find-all - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-dubbo-enabled: 'true' - shenyu.apache.org/zookeeper-register-address: zookeeper://shenyu-zk:2181 - shenyu.apache.org/upstreams-protocol: dubbo://,dubbo:// - name: demo-ingress -spec: - rules: - - http: - paths: - - backend: - service: - name: shenyu-java-examples-apache-dubbo-service - port: - number: 20888 # please use dubbo protocol port - path: /** - pathType: ImplementationSpecific diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/shenyu-examples-dubbo.yml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/shenyu-examples-dubbo.yml deleted file mode 100644 index 2338320..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/shenyu-examples-dubbo.yml +++ /dev/null @@ -1,84 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-examples-dubbo-deployment - namespace: shenyu-ingress - labels: - app: shenyu-examples-dubbo - all: shenyu-examples-dubbo -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-examples-dubbo - all: shenyu-examples-dubbo - strategy: {} - template: - metadata: - labels: - app: shenyu-examples-dubbo - all: shenyu-examples-dubbo - spec: - containers: - - image: shenyu-examples-apache-dubbo-service - name: shenyu-java-examples-dubbo - livenessProbe: - initialDelaySeconds: 30 - periodSeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 3 - exec: - command: - - /bin/sh - - "-c" - - wget -q -O - http://localhost:8081/actuator/health | grep UP || exit 1 - env: - - name: shenyu.register.serverLists - value: http://shenyu-admin:9095 - - name: dubbo.registry.address - value: zookeeper://shenyu-zk:2181 - ports: - - containerPort: 8011 - - containerPort: 20888 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-examples-apache-dubbo-service - namespace: shenyu-ingress - labels: - app: shenyu-examples-dubbo - all: shenyu-examples-dubbo -spec: - selector: - app: shenyu-examples-dubbo - all: shenyu-examples-dubbo - type: NodePort - ports: - - name: "8011" - port: 8011 - targetPort: 8011 - nodePort: 31187 -status: - loadBalancer: {} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/shenyu-zookeeper.yml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/shenyu-zookeeper.yml deleted file mode 100644 index 3823508..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/k8s/shenyu-zookeeper.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: v1 -kind: Namespace -metadata: - name: shenyu-ingress - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-dubbo - name: shenyu-zk -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-zk - all: shenyu-examples-dubbo - strategy: {} - template: - metadata: - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-dubbo - spec: - containers: - - image: zookeeper:latest - name: shenyu-zk - resources: {} - ports: - - containerPort: 2181 - name: client - - containerPort: 2888 - name: server - - containerPort: 3888 - name: leader-election - - containerPort: 8080 - name: website - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-zk - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-dubbo -spec: - type: NodePort - selector: - app: shenyu-zk - all: shenyu-examples-dubbo - ports: - - name: "client" - port: 2181 - targetPort: 2181 - - name: "server" - port: 2888 - targetPort: 2888 - - name: "election" - port: 3888 - targetPort: 3888 - - name: "website" - port: 8080 - targetPort: 8080 diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/pom.xml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/pom.xml deleted file mode 100644 index 9e7c473..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/pom.xml +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples-dubbo - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-apache-dubbo-service - - - 5.2.1 - 2.2.4 - 3.2.11 - 3.7.2 - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-apache-dubbo - ${project.version} - - - - - - - org.apache.shenyu - shenyu-java-examples-dubbo-api - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - org.apache.shenyu - shenyu-java-examples-common - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-autoconfigure - - - - - org.apache.dubbo - dubbo - ${apache.dubbo.version} - - - - - - org.apache.dubbo - dubbo-registry-nacos - ${apache.dubbo.version} - - - - - com.alibaba.nacos - nacos-client - ${nacos-client.version} - - - - org.apache.curator - curator-client - ${curator.version} - - - zookeeper - org.apache.zookeeper - - - - - org.apache.curator - curator-framework - ${curator.version} - - - org.apache.curator - curator-recipes - ${curator.version} - - - org.apache.curator - curator-x-discovery - ${curator.version} - - - - org.apache.zookeeper - zookeeper - ${zookeeper.version} - - - org.slf4j - slf4j-log4j12 - - - log4j - log4j - - - - - - - shenyu-java-examples-apache-dubbo-service - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.apache.dubbo.service.TestApacheDubboApplication - true - - - - - - - - example - - shenyu-java-examples-apache-dubbo-service - shenyu-java-examples-apache-dubbo-service - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-java-examples-apache-dubbo-service - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/http/apache-dubbo-test-api.http b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/http/apache-dubbo-test-api.http deleted file mode 100644 index afe37b6..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/http/apache-dubbo-test-api.http +++ /dev/null @@ -1,187 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy orderSave -POST http://localhost:9195/dubbo/findById -Accept: application/json -Content-Type: application/json - -{ - "id": "123" -} - -### shengyu getway proxy findAll -GET http://localhost:9195/dubbo/findAll -Accept: application/json - - -### shengyu getway proxy insert -POST http://localhost:9195/dubbo/insert -Accept: application/json -Content-Type: application/json - -{ - "id": "123", - "name": "test" -} - -### shengyu getway proxy findByIdsAndName -GET http://localhost:9195/dubbo/findByIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByArrayIdsAndName -GET http://localhost:9195/dubbo/findByArrayIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByStringArray -GET http://localhost:9195/dubbo/findByStringArray -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - "123", - "124", - "125" - ] -} - -### shengyu getway proxy findByListId -GET http://localhost:9195/dubbo/findByListId -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ] -} - -### shengyu getway proxy batchSave -PUT http://localhost:9195/dubbo/batchSave -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ] -} - -### shengyu getway proxy batchSaveAndNameAndId -PUT http://localhost:9195/dubbo/batchSaveAndNameAndId -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ], - "id": "123", - "name": "test" -} - -### shengyu getway proxy saveComplexBeanTest -PUT http://localhost:9195/dubbo/saveComplexBeanTest -Accept: application/json -Content-Type: application/json - -{ - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } -} - -### shengyu getway proxy saveComplexBeanTestAndName -PUT http://localhost:9195/dubbo/saveComplexBeanTestAndName -Accept: application/json -Content-Type: application/json - -## The order of the parameters is important -{ - "complexBeanTest": { - "dubboTest": { - "id": "123", - "name": "test" - }, - "idLists": [ - "123", - "124" - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } - }, - "name": "name" -} - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/TestApacheDubboApplication.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/TestApacheDubboApplication.java deleted file mode 100644 index 7792ff5..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/TestApacheDubboApplication.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ImportResource; - -/** - * TestDubboApplication. - */ -@SpringBootApplication -@ImportResource("classpath:spring-dubbo.xml") -public class TestApacheDubboApplication { - - /** - * Main Entrance. - * - * @param args startup arguments - */ - public static void main(final String[] args) { - SpringApplication.run(TestApacheDubboApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/impl/DubboMultiParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/impl/DubboMultiParamServiceImpl.java deleted file mode 100644 index ed04eea..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/impl/DubboMultiParamServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.examples.dubbo.api.entity.ComplexBeanTest; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.service.DubboMultiParamService; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * The type Dubbo multi param service. - */ -@Service("dubboMultiParamService") -@ApiModule(value = "dubboMultiParamService") -public class DubboMultiParamServiceImpl implements DubboMultiParamService { - - @Override - @ShenyuDubboClient("/findByIdsAndName") - @ApiDoc(desc = "findByIdsAndName") - public DubboTest findByIdsAndName(final List ids, final String name) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByArrayIdsAndName") - @ApiDoc(desc = "findByArrayIdsAndName") - public DubboTest findByArrayIdsAndName(final Integer[] ids, final String name) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByArrayIdsAndName :" + name); - } - - @Override - @ShenyuDubboClient("/findByStringArray") - @ApiDoc(desc = "findByStringArray") - public DubboTest findByStringArray(final String[] ids) { - return new DubboTest(Arrays.toString(ids), "hello world shenyu apache dubbo param findByStringArray"); - } - - @Override - @ShenyuDubboClient("/findByListId") - @ApiDoc(desc = "findByListId") - public DubboTest findByListId(final List ids) { - return new DubboTest(ids.toString(), "hello world shenyu apache dubbo param findByListId"); - } - - @Override - @ShenyuDubboClient("/batchSave") - @ApiDoc(desc = "batchSave") - public DubboTest batchSave(final List dubboTestList) { - return new DubboTest(join(dubboTestList, DubboTest::getId), - "hello world shenyu apache dubbo param batchSave :" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/batchSaveAndNameAndId") - @ApiDoc(desc = "batchSaveAndNameAndId") - public DubboTest batchSaveAndNameAndId(final List dubboTestList, final String id, final String name) { - return new DubboTest(id, "hello world shenyu apache dubbo param batchSaveAndNameAndId :" - + name + ":" + join(dubboTestList, DubboTest::getName)); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTest") - @ApiDoc(desc = "saveComplexBeanTest") - public DubboTest saveComplexBeanTest(final ComplexBeanTest complexBeanTest) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu apache dubbo param saveComplexBeanTest :" + complexBeanTest.getDubboTest().getName()); - } - - @Override - @ShenyuDubboClient("/saveComplexBeanTestAndName") - @ApiDoc(desc = "saveComplexBeanTestAndName") - public DubboTest saveComplexBeanTestAndName(final ComplexBeanTest complexBeanTest, final String name) { - return new DubboTest(complexBeanTest.getIdLists().toString(), - "hello world shenyu alibaba dubbo param saveComplexBeanTestAndName :" + complexBeanTest.getDubboTest().getName() + "-" + name); - } - - private String join(final @NonNull List list, final Function mapper) { - return list.stream() - .map(mapper) - .collect(Collectors.joining("-")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/impl/DubboTestServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/impl/DubboTestServiceImpl.java deleted file mode 100644 index 40441c4..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/java/org/apache/shenyu/examples/apache/dubbo/service/impl/DubboTestServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.apache.dubbo.service.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.dubbo.common.annotation.ShenyuDubboClient; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.entity.ListResp; -import org.apache.shenyu.examples.dubbo.api.service.DubboTestService; -import org.springframework.stereotype.Service; - -import java.util.Collections; -import java.util.Random; - -/** - * DubboTestServiceImpl. - */ -@Service("dubboTestService") -@ApiModule(value = "dubboTestService") -public class DubboTestServiceImpl implements DubboTestService { - - @Override - @ShenyuDubboClient("/findById") - @Log - @ApiDoc(desc = "findById") - public DubboTest findById(final String id) { - return new DubboTest(id, "hello world shenyu Apache, findById"); - } - - @Override - @ShenyuDubboClient("/findAll") - @ApiDoc(desc = "findAll") - public DubboTest findAll() { - return new DubboTest(String.valueOf(new Random().nextInt()), "hello world shenyu Apache, findAll"); - } - - @Override - @ShenyuDubboClient("/insert") - @ApiDoc(desc = "insert") - public DubboTest insert(final DubboTest dubboTest) { - dubboTest.setName("hello world shenyu Apache Dubbo: " + dubboTest.getName()); - return dubboTest; - } - - @Override - @ShenyuDubboClient("/findList") - @ApiDoc(desc = "findList") - public ListResp findList() { - return new ListResp(1, Collections.singletonList(new DubboTest("1", "test"))); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/resources/application.yml deleted file mode 100644 index a697163..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/resources/application.yml +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8011 - address: 0.0.0.0 - servlet: - context-path: / -spring: - main: - allow-bean-definition-overriding: true -dubbo: - registry: - address: zookeeper://localhost:2181 - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - dubbo: - props: - contextPath: /dubbo - appName: dubbo diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/resources/spring-dubbo.xml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/resources/spring-dubbo.xml deleted file mode 100644 index 560e7d1..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-apache-dubbo-service/src/main/resources/spring-dubbo.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/pom.xml b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/pom.xml deleted file mode 100644 index caf05fb..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples-dubbo - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-dubbo-api - - - shenyu-java-examples-dubbo-api - - diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/ComplexBeanTest.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/ComplexBeanTest.java deleted file mode 100644 index b5806b8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/ComplexBeanTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.dubbo.api.entity; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; - -/** - * The type Complex bean test. - */ -public class ComplexBeanTest implements Serializable { - - private DubboTest dubboTest; - - private List idLists; - - private Map idMaps; - - public ComplexBeanTest() { - } - - public ComplexBeanTest(final DubboTest dubboTest, final List idLists, final Map idMaps) { - this.dubboTest = dubboTest; - this.idLists = idLists; - this.idMaps = idMaps; - } - - /** - * Get dubboTest. - * - * @return dubboTest - */ - public DubboTest getDubboTest() { - return dubboTest; - } - - /** - * Set dubboTest. - * - * @param dubboTest dubboTest - */ - public void setDubboTest(final DubboTest dubboTest) { - this.dubboTest = dubboTest; - } - - /** - * Get idLists. - * - * @return idLists - */ - public List getIdLists() { - return idLists; - } - - /** - * Set idLists. - * - * @param idLists idLists - */ - public void setIdLists(final List idLists) { - this.idLists = idLists; - } - - /** - * Get idMaps. - * - * @return idMaps - */ - public Map getIdMaps() { - return idMaps; - } - - /** - * Set idMaps. - * - * @param idMaps idMaps - */ - public void setIdMaps(final Map idMaps) { - this.idMaps = idMaps; - } - - @Override - public String toString() { - return new StringJoiner(", ", ComplexBeanTest.class.getSimpleName() + "[", "]") - .add("dubboTest=" + dubboTest) - .add("idLists=" + idLists) - .add("idMaps=" + idMaps) - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/DubboTest.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/DubboTest.java deleted file mode 100644 index 3a8cf60..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/DubboTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.dubbo.api.entity; - -import java.util.StringJoiner; - -/** - * DubboTest. - */ -public class DubboTest { - - private String id; - - private String name; - - public DubboTest() { - } - - public DubboTest(final String id, final String name) { - this.id = id; - this.name = name; - } - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - @Override - public String toString() { - return new StringJoiner(", ", DubboTest.class.getSimpleName() + "[", "]") - .add("id='" + id + "'") - .add("name='" + name + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/ListResp.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/ListResp.java deleted file mode 100644 index efb4763..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/entity/ListResp.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.dubbo.api.entity; - -import java.util.List; - -public class ListResp { - - private Integer total; - - private List users; - - public ListResp() { - } - - public ListResp(final Integer total, final List users) { - this.total = total; - this.users = users; - } - - /** - * Get total. - * - * @return total - */ - public Integer getTotal() { - return total; - } - - /** - * Set total. - * - * @param total total - */ - public void setTotal(final Integer total) { - this.total = total; - } - - /** - * Get users. - * - * @return users - */ - public List getUsers() { - return users; - } - - /** - * Set users. - * - * @param users users - */ - public void setUsers(final List users) { - this.users = users; - } - - @Override - public String toString() { - return "ListResp{" + "total=" + total + ", users=" + users + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboClassMultiParamService.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboClassMultiParamService.java deleted file mode 100644 index c8ebc93..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboClassMultiParamService.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.dubbo.api.service; - -import org.apache.shenyu.examples.dubbo.api.entity.ComplexBeanTest; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; - -import java.util.List; - -/** - * The interface Dubbo class multi param service. - */ -public interface DubboClassMultiParamService { - - /** - * Find by ids and name dubbo test. - * body: {"ids":["1232","456"],"name":"hello world"} - * - * @param ids the ids - * @param name the name - * @return the dubbo test - */ - DubboTest findByIdsAndName(List ids, String name); - - /** - * Find by array ids and name dubbo test. - * body :{"ids":[123,4561],"name":"hello world"} - * - * @param ids the ids - * @param name the name - * @return the dubbo test - */ - DubboTest findByArrayIdsAndName(Integer[] ids, String name); - - /** - * Find by string array dubbo test. - * body :{"ids":["1232","456"]} - * - * @param ids the ids - * @return the dubbo test - */ - DubboTest findByStringArray(String[] ids); - - /** - * Find by list id dubbo test. - * body :{"ids":["1232","456"]} - * - * @param ids the ids - * @return the dubbo test - */ - DubboTest findByListId(List ids); - - /** - * Batch save dubbo test. - * body :{"dubboTestList":[{"id":"123","name":"xiaoyu"},{"id":"456","name":"myth"}]} - * - * @param dubboTestList the dubbo test list - * @return the dubbo test - */ - DubboTest batchSave(List dubboTestList); - - /** - * Batch save and name and id dubbo test. - * body: {"dubboTestList":[{"id":"123","name":"xiaoyu"},{"id":"456","name":"myth"}],"id":"789","name":"ttt"} - * - * @param dubboTestList the dubbo test list - * @param id the id - * @param name the name - * @return the dubbo test - */ - DubboTest batchSaveAndNameAndId(List dubboTestList, String id, String name); - - /** - * Save complex bean test dubbo test. - * body : {"dubboTest":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}} - * - * @param complexBeanTest the complex bean test - * @return the dubbo test - */ - DubboTest saveComplexBeanTest(ComplexBeanTest complexBeanTest); - - /** - * Save complex bean test and name dubbo test. - * body : {"complexBeanTest":{"dubboTest":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}},"name":"xiaoyu"} - * @param complexBeanTest the complex bean test - * @param name the name - * @return the dubbo test - */ - DubboTest saveComplexBeanTestAndName(ComplexBeanTest complexBeanTest, String name); - - - /** - * save dubbo test for big request body. - * - * @param dubboTest dubbo test - * @return the dubbo test - */ - DubboTest saveBigRequestBody(DubboTest dubboTest); -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboClassTestService.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboClassTestService.java deleted file mode 100644 index ccafb9c..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboClassTestService.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.dubbo.api.service; - -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.entity.ListResp; - -/** - * DubboClassTestService. - */ -public interface DubboClassTestService { - - /** - * find by id. - * body:{"id":"1223"} - * - * @param id id - * @return DubboTest dubbo test - */ - DubboTest findById(String id); - - /** - * Find all dubbo test. - * - * @return the dubbo test - */ - DubboTest findAll(); - - /** - * Insert dubbo test. - * body :{"id":"122344","name":"xiaoyu"} - * - * @param dubboTest the dubbo test - * @return the dubbo test - */ - DubboTest insert(DubboTest dubboTest); - - /** - * findList. - * - * @return {@linkplain ListResp} - */ - ListResp findList(); -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboMultiParamService.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboMultiParamService.java deleted file mode 100644 index a1c4255..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboMultiParamService.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.dubbo.api.service; - -import java.util.List; -import org.apache.shenyu.examples.dubbo.api.entity.ComplexBeanTest; -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; - -/** - * The interface Dubbo multi param service. - */ -public interface DubboMultiParamService { - - /** - * Find by ids and name dubbo test. - * body: {"ids":["1232","456"],"name":"hello world"} - * - * @param ids the ids - * @param name the name - * @return the dubbo test - */ - DubboTest findByIdsAndName(List ids, String name); - - /** - * Find by array ids and name dubbo test. - * body :{"ids":[123,4561],"name":"hello world"} - * - * @param ids the ids - * @param name the name - * @return the dubbo test - */ - DubboTest findByArrayIdsAndName(Integer[] ids, String name); - - /** - * Find by string array dubbo test. - * body :{"ids":["1232","456"]} - * - * @param ids the ids - * @return the dubbo test - */ - DubboTest findByStringArray(String[] ids); - - /** - * Find by list id dubbo test. - * body :{"ids":["1232","456"]} - * - * @param ids the ids - * @return the dubbo test - */ - DubboTest findByListId(List ids); - - /** - * Batch save dubbo test. - * body :{"dubboTestList":[{"id":"123","name":"xiaoyu"},{"id":"456","name":"myth"}]} - * - * @param dubboTestList the dubbo test list - * @return the dubbo test - */ - DubboTest batchSave(List dubboTestList); - - /** - * Batch save and name and id dubbo test. - * body: {"dubboTestList":[{"id":"123","name":"xiaoyu"},{"id":"456","name":"myth"}],"id":"789","name":"ttt"} - * - * @param dubboTestList the dubbo test list - * @param id the id - * @param name the name - * @return the dubbo test - */ - DubboTest batchSaveAndNameAndId(List dubboTestList, String id, String name); - - /** - * Save complex bean test dubbo test. - * body : {"dubboTest":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}} - * - * @param complexBeanTest the complex bean test - * @return the dubbo test - */ - DubboTest saveComplexBeanTest(ComplexBeanTest complexBeanTest); - - /** - * Save complex bean test and name dubbo test. - * body : {"complexBeanTest":{"dubboTest":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}},"name":"xiaoyu"} - * @param complexBeanTest the complex bean test - * @param name the name - * @return the dubbo test - */ - DubboTest saveComplexBeanTestAndName(ComplexBeanTest complexBeanTest, String name); -} diff --git a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboTestService.java b/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboTestService.java deleted file mode 100644 index eb9c38c..0000000 --- a/shenyu-java-examples/shenyu-java-examples-dubbo/shenyu-java-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboTestService.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.dubbo.api.service; - -import org.apache.shenyu.examples.dubbo.api.entity.DubboTest; -import org.apache.shenyu.examples.dubbo.api.entity.ListResp; - -/** - * DubboTestService. - */ -public interface DubboTestService { - - /** - * find by id. - * body:{"id":"1223"} - * - * @param id id - * @return DubboTest dubbo test - */ - DubboTest findById(String id); - - /** - * Find all dubbo test. - * - * @return the dubbo test - */ - DubboTest findAll(); - - /** - * Insert dubbo test. - * body :{"id":"122344","name":"xiaoyu"} - * - * @param dubboTest the dubbo test - * @return the dubbo test - */ - DubboTest insert(DubboTest dubboTest); - - /** - * findList. - * - * @return {@linkplain ListResp} - */ - ListResp findList(); -} diff --git a/shenyu-java-examples/shenyu-java-examples-eureka/Dockerfile b/shenyu-java-examples/shenyu-java-examples-eureka/Dockerfile deleted file mode 100644 index ef303fb..0000000 --- a/shenyu-java-examples/shenyu-java-examples-eureka/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-examples-eureka -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8761 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-eureka/k8s/shenyu-examples-eureka.yml b/shenyu-java-examples/shenyu-java-examples-eureka/k8s/shenyu-examples-eureka.yml deleted file mode 100644 index fd996d2..0000000 --- a/shenyu-java-examples/shenyu-java-examples-eureka/k8s/shenyu-examples-eureka.yml +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-java-examples-eureka-deployment - namespace: shenyu-ingress - labels: - app: shenyu-java-examples-eureka - all: shenyu-java-examples-eureka -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-java-examples-eureka - all: shenyu-java-examples-eureka - strategy: {} - template: - metadata: - namespace: shenyu-ingress - labels: - app: shenyu-java-examples-eureka - all: shenyu-java-examples-eureka - spec: - containers: - - image: shenyu-java-examples-eureka - name: shenyu-java-examples-eureka - env: - - name: eureka.instance.client.serviceUrl.defaultZone - value: http://shenyu-examples-eureka:8761 - ports: - - containerPort: 8761 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-java-examples-eureka - namespace: shenyu-ingress -spec: - selector: - app: shenyu-java-examples-eureka - ports: - - protocol: TCP - port: 8761 - diff --git a/shenyu-java-examples/shenyu-java-examples-eureka/pom.xml b/shenyu-java-examples/shenyu-java-examples-eureka/pom.xml deleted file mode 100644 index 596737a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-eureka/pom.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-eureka - - - 2021.0.2 - 1.19.4 - 3.1.2 - 3.0.4 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - org.glassfish.jersey - jersey-bom - ${jersey-bom.version} - pom - - - - - - - org.springframework.cloud - spring-cloud-starter - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-server - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - - org.springframework.boot - spring-boot-starter-web - - - - com.sun.jersey - jersey-client - ${jersey.version} - - - com.sun.jersey - jersey-core - ${jersey.version} - - - com.sun.jersey.contribs - jersey-apache-client4 - ${jersey.version} - - - - org.springframework.boot - spring-boot-starter-aop - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - shenyu-java-examples-eureka - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.eureka.EurekaServerApplication - true - - - - - - - - example - - shenyu-examples-eureka - shenyu-examples-eureka - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-examples-eureka - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-eureka/src/main/java/org/apache/shenyu/examples/eureka/EurekaServerApplication.java b/shenyu-java-examples/shenyu-java-examples-eureka/src/main/java/org/apache/shenyu/examples/eureka/EurekaServerApplication.java deleted file mode 100644 index d08706a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-eureka/src/main/java/org/apache/shenyu/examples/eureka/EurekaServerApplication.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.eureka; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; - -/** - * The type Eureka server application. - */ -@EnableEurekaServer -@SpringBootApplication -public class EurekaServerApplication { - - /** - * Main. - * - * @param args the args - */ - public static void main(final String[] args) { - new SpringApplicationBuilder(EurekaServerApplication.class).run(args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-eureka/src/main/resources/bootstrap.yml b/shenyu-java-examples/shenyu-java-examples-eureka/src/main/resources/bootstrap.yml deleted file mode 100644 index 8311623..0000000 --- a/shenyu-java-examples/shenyu-java-examples-eureka/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8761 - -spring: - application: - name: springcloud-eureka - -eureka: - instance: - hostname: ${hostname:localhost} - preferIpAddress: true - lease-renewal-interval-in-seconds: 2 - lease-expiration-duration-in-seconds: 6 - server: - peerEurekaNodesUpdateIntervalMs: 60000 - enableSelfPreservation: false - evictionIntervalTimerInMs: 5000 - client: - registerWithEureka: false - fetchRegistry: false - serviceUrl: - defaultZone: http://localhost:8761/eureka/ - healthcheck: - enabled: true - eurekaServiceUrlPollIntervalSeconds: 60 - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/Dockerfile b/shenyu-java-examples/shenyu-java-examples-grpc/Dockerfile deleted file mode 100644 index 6120552..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-java-examples-grpc -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 55290 -EXPOSE 8080 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/k8s/ingress.yml b/shenyu-java-examples/shenyu-java-examples-grpc/k8s/ingress.yml deleted file mode 100644 index 254a0f4..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/k8s/ingress.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -apiVersion: v1 -kind: Service -metadata: - name: echo - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-grpc-enabled: 'true' - shenyu.apache.org/plugin-grpc-app-name: 127.0.0.1:38080 - shenyu.apache.org/plugin-context-path-path: /grpc - shenyu.apache.org/plugin-grpc-path: /grpc/echo - shenyu.apache.org/plugin-grpc-rpc-type: grpc - shenyu.apache.org/plugin-grpc-service-name: echo.EchoService - shenyu.apache.org/plugin-grpc-method-name: echo - shenyu.apache.org/plugin-grpc-params-type: echo.EchoRequest,io.grpc.stub.StreamObserver - shenyu.apache.org/plugin-grpc-rpc-expand: | - {"timeout":5000,"methodType":"UNARY"} -spec: - selector: - app: shenyu-java-examples-grpc-service - ports: - - port: 38080 - ---- - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - namespace: shenyu-ingress - labels: - shenyu.apache.org/metadata-labels-1: echo - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-grpc-enabled: 'true' - name: demo-ingress -spec: - rules: - - http: - paths: - - backend: - service: - name: shenyu-java-examples-grpc-service - port: - number: 38080 - path: /grpc/ - pathType: Prefix diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/k8s/shenyu-examples-grpc.yml b/shenyu-java-examples/shenyu-java-examples-grpc/k8s/shenyu-examples-grpc.yml deleted file mode 100644 index bdfb960..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/k8s/shenyu-examples-grpc.yml +++ /dev/null @@ -1,93 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: v1 -kind: Namespace -metadata: - name: shenyu-ingress ---- - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-java-examples-grpc-deployment - namespace: shenyu-ingress - labels: - app: shenyu-java-examples-grpc - all: shenyu-java-examples-grpc -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-java-examples-grpc - all: shenyu-java-examples-grpc - strategy: {} - template: - metadata: - namespace: shenyu-ingress - labels: - app: shenyu-java-examples-grpc - all: shenyu-java-examples-grpc - spec: - containers: - - image: shenyu-java-examples-grpc - name: shenyu-java-examples-grpc - livenessProbe: - initialDelaySeconds: 30 - periodSeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 3 - exec: - command: - - /bin/sh - - "-c" - - wget -q -O - http://localhost:55290/actuator/health | grep UP || exit 1 - env: - - name: shenyu.register.serverLists - value: http://shenyu-admin:9095 - ports: - - containerPort: 55290 - - containerPort: 8080 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-java-examples-grpc-service - namespace: shenyu-ingress - labels: - app: shenyu-java-examples-grpc - all: shenyu-java-examples-grpc -spec: - selector: - app: shenyu-java-examples-grpc - all: shenyu-java-examples-grpc - type: NodePort - ports: - - name: "55290" - port: 55290 - targetPort: 55290 - nodePort: 31183 - - name: "8080" - port: 8080 - targetPort: 8080 - nodePort: 31184 -status: - loadBalancer: {} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/pom.xml b/shenyu-java-examples/shenyu-java-examples-grpc/pom.xml deleted file mode 100644 index ee04c38..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/pom.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-grpc - - - 1.48.0 - 3.21.12 - 1.6.2 - - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-web - - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-grpc - ${project.version} - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.apache.shenyu - shenyu-discovery-zookeeper - 2.6.1 - - - - - - - - - - kr.motd.maven - os-maven-plugin - ${os-maven-plugin.version} - - - shenyu-java-examples-grpc - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.6.1 - true - - com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} - grpc-java - io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} - src/main/resources/proto - - - - - compile - compile-custom - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.grpc.ShenyuTestGrpcApplication - true - - - - - - - - example - - shenyu-java-examples-grpc - shenyu-java-examples-grpc - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-java-examples-grpc - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/http/grpc-class-annotation-test-api.http b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/http/grpc-class-annotation-test-api.http deleted file mode 100644 index 6e11962..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/http/grpc-class-annotation-test-api.http +++ /dev/null @@ -1,76 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - -### shengyu gateway proxy helloService#hello -POST http://localhost:9195/grpc/helloService/hello -Accept: application/json -Content-Type: application/json - -{ - "data":[ - { - "data": "zhangSan" - } - ] -} - -### shengyu gateway proxy helloService#helloEveryOne -POST http://localhost:9195/grpc/helloService/helloEveryOne -Accept: application/json -Content-Type: application/json - -{ - "data": [ - { - "data": "zhangSan" - }, - { - "data": "lisi" - } - ] -} - -### shengyu gateway proxy eventService#sendEvent -POST http://localhost:9195/grpc/eventService/sendEvent -Accept: application/json -Content-Type: application/json - -{ - "data":[ - { - "data": "startup" - } - ] -} - -### shengyu gateway proxy eventService#sendEventStream -POST http://localhost:9195/grpc/eventService/sendEventStream -Accept: application/json -Content-Type: application/json - -{ - "data": [ - { - "data": "startup" - }, - { - "data": "pause" - } - ] -} - diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/http/grpc-test-api.http b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/http/grpc-test-api.http deleted file mode 100644 index 0336012..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/http/grpc-test-api.http +++ /dev/null @@ -1,87 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - -### shengyu getway proxy echo -POST http://localhost:9195/grpc/echo -Accept: application/json -Content-Type: application/json - -{ - "data": [ - { - "message": "hello grpc" - } - ] -} - -### create the file grpc-test-api.http under src/main/http/ -### shengyu getway proxy unaryFun -POST http://localhost:9195/grpc/unaryFun -Accept: application/json -Content-Type: application/json - -{ - "data": [ - { - "message": "hello grpc" - } - ] -} -### shengyu getway proxy bidiStreamingFun -POST http://localhost:9195/grpc/bidiStreamingFun -Accept: application/json -Content-Type: application/json - -{ - "data": [ - { - "message": "hello grpc" - } - ] -} -### shengyu getway proxy bidiStreamingFun -POST http://localhost:9195/grpc/serverStreamingFun -Accept: application/json -Content-Type: application/json - -{ - "data": [ - { - "message": "hello grpc" - }, - { - "message": "hello grpc" - } - ] -} - -### shengyu getway proxy clientStreamingFun -POST http://localhost:9195/grpc/serverStreamingFun -Accept: application/json -Content-Type: application/json - -{ - "data": [ - { - "message": "hello grpc" - }, - { - "message": "hello grpc" - } - ] -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/ShenyuGrpcServerBuilder.java b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/ShenyuGrpcServerBuilder.java deleted file mode 100644 index bf4b031..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/ShenyuGrpcServerBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.grpc; - -import io.grpc.ServerBuilder; -import org.apache.shenyu.client.grpc.server.GrpcServerBuilder; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -/** - * Grpc ServerBuilder. - */ -@Component -public class ShenyuGrpcServerBuilder implements GrpcServerBuilder { - - @Value("${shenyu.client.grpc.props.port}") - private Integer port; - - @Override - public ServerBuilder buildServerBuilder() { - return ServerBuilder.forPort(port); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/ShenyuTestGrpcApplication.java b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/ShenyuTestGrpcApplication.java deleted file mode 100644 index f8eba10..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/ShenyuTestGrpcApplication.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.grpc; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * ShenyuTestGrpcApplication. - */ -@SpringBootApplication -public class ShenyuTestGrpcApplication { - - /** - * main. - * - * @param args args - */ - public static void main(final String[] args) { - SpringApplication.run(ShenyuTestGrpcApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/controller/GrpcTestController.java b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/controller/GrpcTestController.java deleted file mode 100644 index 5e1d7b9..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/controller/GrpcTestController.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.grpc.controller; - -import echo.EchoRequest; -import echo.EchoResponse; -import echo.EchoServiceGrpc; -import io.grpc.Channel; -import io.grpc.ManagedChannelBuilder; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * GrpcTestController. - */ -@RestController -@RequestMapping("/test/grpc") -public class GrpcTestController { - - private final Channel channel = channel(); - - /** - * test grpc. - * - * @return hello world - */ - @GetMapping("/hello") - public String hello() { - EchoServiceGrpc.EchoServiceBlockingStub stub = EchoServiceGrpc.newBlockingStub(channel); - EchoRequest request = EchoRequest.newBuilder().setMessage("hello").build(); - EchoResponse response = stub.echo(request); - return response.getMessage(); - } - - private Channel channel() { - return ManagedChannelBuilder.forAddress("127.0.0.1", 8080) - .usePlaintext().build(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/demo/EventServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/demo/EventServiceImpl.java deleted file mode 100644 index 37e6757..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/demo/EventServiceImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.grpc.demo; - -import event.EventRequest; -import event.EventResponse; -import event.EventServiceGrpc; - -import io.grpc.stub.StreamObserver; -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.grpc.common.annotation.ShenyuGrpcClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -@ShenyuGrpcClient("/eventService") -@Service -@ApiModule(value = "eventService") -public class EventServiceImpl extends EventServiceGrpc.EventServiceImplBase { - - private static final Logger LOG = LoggerFactory.getLogger(EventServiceImpl.class); - - @ShenyuGrpcClient("/sendEvent") - @ApiDoc(desc = "sendEvent") - @Override - public void sendEvent(final EventRequest request, final StreamObserver responseObserver) { - EventResponse response = EventResponse.newBuilder().setData("received event:" + request.getData()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } - - @ShenyuGrpcClient("/sendEventStream") - @ApiDoc(desc = "sendEventStream") - @Override - public StreamObserver sendEventStream(final StreamObserver responseObserver) { - return new StreamObserver() { - @Override - public void onNext(final EventRequest request) { - EventResponse responseData = EventResponse.newBuilder() - .setData("received event:" + request.getData()) - .build(); - responseObserver.onNext(responseData); - } - - @Override - public void onError(final Throwable t) { - LOG.error(t.getMessage()); - } - - @Override - public void onCompleted() { - EventResponse responseData = EventResponse.newBuilder() - .setData("event onCompleted") - .build(); - responseObserver.onNext(responseData); - responseObserver.onCompleted(); - } - }; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/demo/HelloServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/demo/HelloServiceImpl.java deleted file mode 100644 index ca7260f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/demo/HelloServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.grpc.demo; - -import hello.HelloRequest; -import hello.HelloResponse; -import hello.HelloServiceGrpc; - -import io.grpc.stub.StreamObserver; -import org.apache.shenyu.client.grpc.common.annotation.ShenyuGrpcClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -@ShenyuGrpcClient("/helloService/**") -@Service -public class HelloServiceImpl extends HelloServiceGrpc.HelloServiceImplBase { - - private static final Logger LOG = LoggerFactory.getLogger(HelloServiceImpl.class); - - @Override - public void hello(final HelloRequest request, final StreamObserver responseObserver) { - HelloResponse response = HelloResponse.newBuilder().setData("hello: " + request.getData()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } - - @Override - public StreamObserver helloEveryOne(final StreamObserver responseObserver) { - return new StreamObserver() { - @Override - public void onNext(final HelloRequest request) { - HelloResponse responseData = HelloResponse.newBuilder() - .setData("hello: " + request.getData()) - .build(); - responseObserver.onNext(responseData); - } - - @Override - public void onError(final Throwable t) { - LOG.error(t.getMessage()); - } - - @Override - public void onCompleted() { - HelloResponse responseData = HelloResponse.newBuilder() - .setData("hello onCompleted") - .build(); - responseObserver.onNext(responseData); - responseObserver.onCompleted(); - } - }; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/echo/EchoServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/echo/EchoServiceImpl.java deleted file mode 100644 index ae1de45..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/echo/EchoServiceImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.grpc.echo; - -import echo.EchoRequest; -import echo.EchoResponse; -import echo.EchoServiceGrpc; -import echo.Trace; -import io.grpc.stub.StreamObserver; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -import org.apache.shenyu.client.grpc.common.annotation.ShenyuGrpcClient; -import org.apache.shenyu.examples.common.aop.Log; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -@Service -public class EchoServiceImpl extends EchoServiceGrpc.EchoServiceImplBase { - - private static final Logger LOG = LoggerFactory.getLogger(EchoServiceImpl.class); - - @Override - @Log - @ShenyuGrpcClient("/echo") - public void echo(final EchoRequest request, final StreamObserver responseObserver) { - LOG.info("Received: {}", request.getMessage()); - EchoResponse.Builder response = EchoResponse.newBuilder() - .setMessage("ReceivedHELLO") - .addTraces(Trace.newBuilder().setHost(getHostname()).build()); - responseObserver.onNext(response.build()); - responseObserver.onCompleted(); - } - - private String getHostname() { - try { - return InetAddress.getLocalHost().getHostName() + "(" + InetAddress.getLocalHost().getHostAddress() + ")"; - } catch (UnknownHostException e) { - return ""; - } - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/stream/StreamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/stream/StreamServiceImpl.java deleted file mode 100644 index 07549e6..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/java/org/apache/shenyu/examples/grpc/stream/StreamServiceImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.grpc.stream; - -import io.grpc.stub.StreamObserver; -import org.apache.shenyu.client.grpc.common.annotation.ShenyuGrpcClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; -import stream.RequestData; -import stream.ResponseData; -import stream.StreamServiceGrpc; - -@Service -public class StreamServiceImpl extends StreamServiceGrpc.StreamServiceImplBase { - - private static final Logger LOG = LoggerFactory.getLogger(StreamServiceImpl.class); - - @Override - @ShenyuGrpcClient("/unaryFun") - public void unaryFun(final RequestData request, final StreamObserver responseObserver) { - LOG.info("unaryFun received:{}", request.getText()); - - ResponseData responseData = ResponseData.newBuilder() - .setText("unaryFun response: hello gRPC") - .build(); - responseObserver.onNext(responseData); - responseObserver.onCompleted(); - } - - @Override - @ShenyuGrpcClient("/serverStreamingFun") - public void serverStreamingFun(final RequestData request, final StreamObserver responseObserver) { - LOG.info("serverStreamingFun received:{}", request.getText()); - - for (int i = 0; i < 10; i++) { - ResponseData responseData = ResponseData.newBuilder() - .setText("serverStreamingFun response: hello " + i) - .build(); - responseObserver.onNext(responseData); - } - - responseObserver.onCompleted(); - } - - @Override - @ShenyuGrpcClient("/clientStreamingFun") - public StreamObserver clientStreamingFun(final StreamObserver responseObserver) { - - return new StreamObserver() { - - private final ResponseData.Builder builder = ResponseData.newBuilder(); - - @Override - public void onNext(final RequestData value) { - LOG.info("clientStreamingFun received: {}", value.getText()); - } - - @Override - public void onError(final Throwable t) { - LOG.error(t.getMessage()); - } - - @Override - public void onCompleted() { - builder.setText("clientStreamingFun onCompleted"); - responseObserver.onNext(builder.build()); - responseObserver.onCompleted(); - } - }; - } - - @Override - @ShenyuGrpcClient("/bidiStreamingFun") - public StreamObserver bidiStreamingFun(final StreamObserver responseObserver) { - - return new StreamObserver() { - - private final ResponseData.Builder builder = ResponseData.newBuilder(); - - @Override - public void onNext(final RequestData value) { - LOG.info("bidiStreamingFun received: {}", value.getText()); - ResponseData responseData = ResponseData.newBuilder() - .setText("bidiStreamingFun response: hello") - .build(); - responseObserver.onNext(responseData); - } - - @Override - public void onError(final Throwable t) { - LOG.error(t.getMessage()); - } - - @Override - public void onCompleted() { - builder.setText("bidiStreamingFun onCompleted"); - responseObserver.onNext(builder.build()); - responseObserver.onCompleted(); - } - - }; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/application.yml deleted file mode 100644 index 2c8b64d..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/application.yml +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 55290 - servlet: - context-path: /grpc - address: 0.0.0.0 - -spring: - application: - name: grpc-test - - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - grpc: - props: - contextPath: /grpc - appName: grpc - ipAndPort: 127.0.0.1:38080 - port: 38080 -# discovery: -# enable: true -# type: zookeeper -# serverList: 127.0.0.1:2181 -# registerPath: /shenyu/discovery/${spring.application.name} -# props: -# baseSleepTimeMilliseconds: 1000 -# maxRetries: 4 -# maxSleepTimeMilliseconds: 5000 -# connectionTimeoutMilliseconds: 60000 -# sessionTimeoutMilliseconds: 8 -# type: etcd -# serverList: http://127.0.0.1:2379 -# registerPath: shenyu_discovery_${spring.application.name} -# type: eureka -# serverList: http://127.0.0.1:8761/eureka -# registerPath: shenyu_discovery_${spring.application.name} - -logging: - level: - root: info - org.apache.shenyu: debug - diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/echo.proto b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/echo.proto deleted file mode 100644 index 1511aa6..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/echo.proto +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -syntax = "proto3"; - -package echo; - -option java_multiple_files = true; - - -service EchoService { - rpc echo (EchoRequest) returns (EchoResponse) {} -} - -message EchoRequest { - string message = 1; -} - -message EchoResponse { - string message = 1; - repeated Trace traces = 2; -} - -message Trace { - string host = 1; -} diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/event.proto b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/event.proto deleted file mode 100644 index 6b04eb3..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/event.proto +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -syntax = "proto3"; - -package event; - -option java_multiple_files = true; - - -service EventService { - rpc sendEvent (EventRequest) returns (EventResponse) {} - - rpc sendEventStream(stream EventRequest) returns (stream EventResponse) {} -} - -message EventRequest { - string data = 1; -} - -message EventResponse { - string data = 1; -} - diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/hello.proto b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/hello.proto deleted file mode 100644 index a78f5f9..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/hello.proto +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -syntax = "proto3"; - -package hello; - -option java_multiple_files = true; - - -service HelloService { - rpc hello (HelloRequest) returns (HelloResponse) {} - - rpc helloEveryOne(stream HelloRequest) returns (stream HelloResponse) {} -} - -message HelloRequest { - string data = 1; -} - -message HelloResponse { - string data = 1; -} - diff --git a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/stream.proto b/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/stream.proto deleted file mode 100644 index 606c472..0000000 --- a/shenyu-java-examples/shenyu-java-examples-grpc/src/main/resources/proto/stream.proto +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -syntax = "proto3"; - -package stream; - -option java_multiple_files = true; - - -service StreamService { - - rpc unaryFun(RequestData) returns (ResponseData){} - - rpc serverStreamingFun(RequestData) returns (stream ResponseData){} - - rpc clientStreamingFun(stream RequestData) returns (ResponseData){} - - rpc bidiStreamingFun(stream RequestData) returns (stream ResponseData){} - -} - -message RequestData { - string text = 1; -} - -message ResponseData { - string text = 1; -} \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/Dockerfile b/shenyu-java-examples/shenyu-java-examples-http-swagger2/Dockerfile deleted file mode 100644 index db84066..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-examples-http-swagger2 -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8190 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/script/healthcheck.sh b/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/script/healthcheck.sh deleted file mode 100644 index 19d6eaf..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/script/healthcheck.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -PRGDIR=`dirname "$0"` -for service in `grep -v -E "^$|^#" ${PRGDIR}/services.list` -do - for loop in `seq 1 30` - do - status=`curl -o /dev/null -s -w %{http_code} $service` - echo -e "curl $service response $status" - - if [ $status -eq 200 ]; then - break - fi - - sleep 2 - done -done - -sleep 5 - -status=`curl -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type:application/json" http://localhost:31195/http/order/save --data '{"name":"test", "id": 123}'` - -sleep 3 - -if [ $status -eq 200 ]; then - echo -e "Success to send request: $status" - echo -e "\n-------------------" - exit 0 -fi -echo -e "Failed to send request from shenyu-bootstrap to http example: $status" -echo -e "\n-------------------" -exit 1 diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/script/services.list b/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/script/services.list deleted file mode 100644 index 912051f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/script/services.list +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -http://localhost:31095/actuator/health -http://localhost:31195/actuator/health -http://localhost:31189/actuator/health diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-deployment.yml b/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-deployment.yml deleted file mode 100644 index 415ca0b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-deployment.yml +++ /dev/null @@ -1,82 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-admin - labels: - app: shenyu-admin - all: shenyu-examples-http-swagger2 -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-admin - all: shenyu-examples-http-swagger2 - template: - metadata: - labels: - app: shenyu-admin - all: shenyu-examples-http-swagger2 - spec: - containers: - - name: shenyu-admin - image: apache/shenyu-admin:latest - resources: {} - env: - - name: SPRING_PROFILES_ACTIVE - value: h2 - - name: shenyu.database.init_script - value: sql-script/h2/schema.sql - ports: - - containerPort: 9095 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-bootstrap - labels: - app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 - template: - metadata: - labels: - app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 - spec: - containers: - - name: shenyu-bootstrap - image: apache/shenyu-bootstrap:latest - resources: {} - env: - - name: shenyu.sync.websocket.urls - value: ws://shenyu-admin:9095/websocket - ports: - - containerPort: 9195 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-examples-http-deployment.yml b/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-examples-http-deployment.yml deleted file mode 100644 index f1eb68d..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-examples-http-deployment.yml +++ /dev/null @@ -1,91 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-examples-http-swagger2-deployment - labels: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 - strategy: {} - template: - metadata: - labels: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 - spec: - containers: - - image: shenyu-examples-http-swagger2 - name: shenyu-java-examples-java-http-swagger2 - livenessProbe: - exec: - command: - - wget -q -O - http://localhost:8190/actuator/health | grep UP || exit 1 - initialDelaySeconds: 10 - failureThreshold: 3 - timeoutSeconds: 2 - env: - - name: shenyu.register.serverLists - value: http://shenyu-admin:9095 - ports: - - containerPort: 8190 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: shenyu-zk - all: shenyu-examples-http-swagger2 - name: shenyu-zk -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-zk - all: shenyu-examples-http-swagger2 - strategy: {} - template: - metadata: - labels: - app: shenyu-zk - all: shenyu-examples-http-swagger2 - spec: - containers: - - image: zookeeper:3.5 - name: shenyu-zk - resources: {} - ports: - - containerPort: 2181 - name: client - - containerPort: 2888 - name: server - - containerPort: 3888 - name: leader-election - - containerPort: 8080 - name: website - restartPolicy: Always -status: {} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-examples-http-service.yml b/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-examples-http-service.yml deleted file mode 100644 index d2166b1..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-examples-http-service.yml +++ /dev/null @@ -1,62 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: v1 -kind: Service -metadata: - name: shenyu-examples-http-swagger2-service - labels: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 -spec: - selector: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 - type: NodePort - ports: - - name: "8190" - port: 8190 - targetPort: 8190 - nodePort: 31189 -status: - loadBalancer: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-zk - labels: - app: shenyu-zk - all: shenyu-examples-http-swagger2 -spec: - type: NodePort - selector: - app: shenyu-zk - all: shenyu-examples-http-swagger2 - ports: - - name: "client" - port: 2181 - targetPort: 2181 - - name: "server" - port: 2888 - targetPort: 2888 - - name: "election" - port: 3888 - targetPort: 3888 - - name: "website" - port: 8080 - targetPort: 8080 diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-service.yml b/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-service.yml deleted file mode 100644 index 63e38f8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/k8s/shenyu-service.yml +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: v1 -kind: Service -metadata: - name: shenyu-admin - labels: - app: shenyu-admin - all: shenyu-examples-http-swagger2 -spec: - type: NodePort - selector: - app: shenyu-admin - all: shenyu-examples-http-swagger2 - ports: - - name: "9095" - port: 9095 - targetPort: 9095 - nodePort: 31095 - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-bootstrap - labels: - app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 -spec: - type: NodePort - selector: - app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 - ports: - - name: "9195" - port: 9195 - targetPort: 9195 - nodePort: 31195 \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/pom.xml b/shenyu-java-examples/shenyu-java-examples-http-swagger2/pom.xml deleted file mode 100644 index d8c9576..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/pom.xml +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-http-swagger2 - - - 3.3.2 - 21.0 - 4.4 - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-springmvc - ${project.version} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-logging - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-starter-web - - - - io.springfox - springfox-swagger2 - - - io.springfox - springfox-swagger-ui - - - - - shenyu-examples-http-swagger2 - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.http.ShenyuTestSwaggerApplication - true - - - - - - - - example - - shenyu-examples-http-swagger2 - shenyu-examples-http-swagger2 - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-examples-http-swagger2 - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/ShenyuTestSwaggerApplication.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/ShenyuTestSwaggerApplication.java deleted file mode 100644 index cb2b6ce..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/ShenyuTestSwaggerApplication.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * ShenyuTestSwaggerApplication. - */ -@SpringBootApplication -public class ShenyuTestSwaggerApplication { - - /** - * main. - * - * @param args args - */ - public static void main(final String[] args) { - SpringApplication.run(ShenyuTestSwaggerApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java deleted file mode 100644 index 063d3c9..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.config; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import org.apache.shenyu.examples.http.router.ShenyuTestHttpRouter; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.scheduler.Scheduler; -import reactor.core.scheduler.Schedulers; - -/** - * HttpServerConfig. - */ -@Configuration -public class HttpServerConfig { - - /** - * define a bean with name monoRouterFunction for test. - * - * @param shenyuTestHttpRouter shenyuTestHttpRouter - * @return route functions - */ - @Bean - public RouterFunction monoRouterFunction(final ShenyuTestHttpRouter shenyuTestHttpRouter) { - return shenyuTestHttpRouter.routes(); - } - - /** - * define scheduler bean. - * - * @return Scheduler bean. - */ - @Bean - public Scheduler scheduler() { - ExecutorService threadPool = new ThreadPoolExecutor(100, 100, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue<>(), - runnable -> { - Thread thread = new Thread(runnable, "http-exe"); - thread.setDaemon(false); - if (thread.getPriority() != Thread.NORM_PRIORITY) { - thread.setPriority(Thread.NORM_PRIORITY); - } - return thread; - }); - return Schedulers.fromExecutor(threadPool); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java deleted file mode 100644 index 4ff4791..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.config; - -import io.swagger.annotations.ApiOperation; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.utils.VersionUtils; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.ParameterBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.schema.ModelRef; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.service.Parameter; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; - -import java.util.ArrayList; -import java.util.List; - -/** - * Configuration class for Swagger API document. - */ -@Configuration -@EnableSwagger2WebMvc -public class SwaggerConfiguration { - - private static final String DEFAULT_SWAGGER_API_VERSION = "2.3.0"; - - private static final String TITLE = "shenyu-java-examples-java-http-swagger2 API"; - - private static final String DESCRIPTION = "shenyu-java-examples-java-http-swagger2 API"; - - private static final String CONTACT_NAME = "ShenYu"; - - private static final String CONTACT_URL = "https://github.com/apache/shenyu"; - - private static final String CONTACT_EMAIL = "dev@shenyu.apache.org"; - - private static final String TOKEN_DESCRIPTION = "user auth"; - - private static final String TOKEN_MODEL_REF_TYPE = "string"; - - private static final String TOKEN_PARAMETER_TYPE = "header"; - - private static boolean enable = true; - - public SwaggerConfiguration() { - } - - /** - * Configure The Docket with Swagger. - * - * @return Docket {@linkplain Docket} - */ - @Bean - public Docket createRestApi() { - ParameterBuilder commonParam = new ParameterBuilder(); - - // X-Access-Token - List pars = new ArrayList<>(); - commonParam.name(Constants.X_ACCESS_TOKEN) - .description(TOKEN_DESCRIPTION) - .modelRef(new ModelRef(TOKEN_MODEL_REF_TYPE)) - .parameterType(TOKEN_PARAMETER_TYPE) - .required(false); - pars.add(commonParam.build()); - - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(this.apiInfo()) - .enable(enable) - .globalOperationParameters(pars) - .select() - .apis(RequestHandlerSelectors.basePackage("org.apache.shenyu.examples.http.controller")) - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - .paths(PathSelectors.any()) - .build(); - } - -// /** -// * use bean to be compatible with springboot 2.6.8. -// * -// * @return BeanPostProcessor -// */ -// @Bean -// public BeanPostProcessor springfoxBeanHandler() { -// return new BeanPostProcessor() { -// @Override -// public Object postProcessAfterInitialization(final Object bean, -// final String beanName) throws BeansException { -// if (bean instanceof WebMvcRequestHandlerProvider) { -// customizeSpringfoxHandlerMappings(getHandlerMappings(bean)); -// } -// return bean; -// } -// -// private void customizeSpringfoxHandlerMappings( -// final List mappings) { -// List copy = mappings.stream() -// .filter(mapping -> Objects.isNull(mapping.getPatternParser())) -// .collect(Collectors.toList()); -// mappings.clear(); -// mappings.addAll(copy); -// } -// -// @SuppressWarnings("unchecked") -// private List getHandlerMappings(final Object bean) { -// try { -// Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings"); -// field.setAccessible(true); -// return (List) field.get(bean); -// } catch (IllegalArgumentException | IllegalAccessException e) { -// throw new IllegalStateException(e); -// } -// } -// }; -// } - - /** - * Fetch version information from pom.xml and set title, version, description, - * contact for Swagger API document. - * - * @return Api info - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title(TITLE).description(DESCRIPTION) - .version(VersionUtils.getVersion(getClass(), DEFAULT_SWAGGER_API_VERSION)) - .contact(new Contact(CONTACT_NAME, CONTACT_URL, CONTACT_EMAIL)) - .build(); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java deleted file mode 100644 index a922024..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import com.google.common.collect.ImmutableMap; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import java.util.Arrays; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.examples.http.dto.UserDTO; -import org.apache.shenyu.examples.http.result.ResultBean; -import org.apache.shenyu.examples.http.result.TreeResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * TestController. - */ -@RestController -@RequestMapping("/test") -@ShenyuSpringMvcClient("/test/**") -@Api(tags = "HttpBaseTestAPI") -public class HttpTestController { - - private static final Logger LOGGER = LoggerFactory.getLogger(HttpTestController.class); - - /** - * Post user dto. - * - * @param userDTO the user dto - * @return the user dto - */ - @ApiOperation(value = "payment", notes = "The user pays the order.", position = -100) - @PostMapping("/payment") - public UserDTO post(@RequestBody final UserDTO userDTO) { - return userDTO; - } - - /** - * Find by user id string. - * - * @param userId the user id - * @return the string - */ - @ApiOperation(value = "findByUserId", notes = "Query the user information with the user ID.") - @ApiImplicitParam(value = "user id", name = "userId", required = true, dataType = "string", example = "100000") - @GetMapping("/findByUserId") - public UserDTO findByUserId(@RequestParam("userId") final String userId) { - return buildUser(userId, "hello world"); - } - - /** - * Find by user id string. - * - * @param userId the user id - * @param name name - * @return the string - */ - @ApiOperation(value = "findByUserIdName", notes = "Query user information with user ID and name.") - @ApiImplicitParams(value = { - @ApiImplicitParam(value = "user id", name = "userId", required = true, dataTypeClass = String.class, example = "100000"), - @ApiImplicitParam(value = "user name", name = "name", dataTypeClass = String.class, example = "shenyu") - }) - @GetMapping("/findByUserIdName") - public UserDTO findByUserId(@RequestParam("userId") final String userId, @RequestParam("name") final String name) { - return buildUser(userId, name); - } - - /** - * Find user dto by page. - * - * @param keyword the keyword - * @param page the page - * @param pageSize the page size - * @return the user dto - */ - @ApiOperation(value = "findByPage", notes = "Find user dto by page.") - @GetMapping("/findByPage") - public UserDTO findByPage(final String keyword, final Integer page, final Integer pageSize) { - return buildUser(keyword, "hello world keyword is " + keyword + " page is " + page + " pageSize is " + pageSize); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @ApiOperation(value = "getPathVariable", notes = "Gets path variable.") - @GetMapping("/path/{id}") - public UserDTO getPathVariable(@PathVariable("id") final String id, @RequestParam("name") final String name) { - return buildUser(id, name); - } - - /** - * Test rest ful string. - * - * @param id the id - * @return the string - */ - @ApiOperation(value = "testRestFul", notes = "Test rest ful string") - @GetMapping("/path/{id}/name") - public UserDTO testRestFul(@PathVariable("id") final String id) { - return buildUser(id, "hello world"); - } - - /** - * Put path variable and body string. - * - * @param id the id - * @param userDTO the user dto - * @return the string - */ - @PutMapping("/putPathBody/{id}") - public UserDTO putPathVariableAndBody(@PathVariable("id") final String id, @RequestBody final UserDTO userDTO) { - userDTO.setUserId(id); - userDTO.setUserName("hello world"); - return userDTO; - } - - /** - * the waf pass. - * - * @return response. result bean - */ - @PostMapping("/waf/pass") - public ResultBean pass() { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - return response; - } - - /** - * the waf deny. - * - * @return response. result bean - */ - @PostMapping("/waf/deny") - public ResultBean deny() { - ResultBean response = new ResultBean(); - response.setCode(403); - response.setMsg("deny"); - return response; - } - - /** - * request Pass. - * - * @param requestParameter the requestParameter. - * @return ResultBean result bean - */ - @GetMapping("/request/parameter/pass") - public ResultBean requestParameter(@RequestParam("requestParameter") final String requestParameter) { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - Map param = new HashMap<>(); - param.put("requestParameter", requestParameter); - response.setData(param); - return response; - } - - /** - * request Pass. - * - * @param requestHeader the requestHeader. - * @return ResultBean result bean - */ - @GetMapping("/request/header/pass") - public ResultBean requestHeader(@RequestHeader("requestHeader") final String requestHeader) { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - Map param = new HashMap<>(); - param.put("requestHeader", requestHeader); - response.setData(param); - return response; - } - - /** - * request Pass. - * - * @param cookie the cookie. - * @return ResultBean result bean - */ - @GetMapping("/request/cookie/pass") - public ResultBean requestCookie(@CookieValue("cookie") final String cookie) { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - Map param = new HashMap<>(); - param.put("cookie", cookie); - response.setData(param); - return response; - } - - /** - * post sentinel. - * - * @return response. result bean - */ - @PostMapping("/sentinel/pass") - public ResultBean sentinelPass() { - return pass(); - } - - /** - * modify response. - * - * @param exchange exchange - * @return response mono - */ - @GetMapping(path = "/modifyResponse") - public Mono modifyResponse(final ServerWebExchange exchange) { - exchange.getResponse().getHeaders().add("useByModifyResponse", String.valueOf(true)); - exchange.getResponse().getHeaders().add("setHeadersExist", String.valueOf(true)); - exchange.getResponse().getHeaders().add("replaceHeaderKeys", String.valueOf(true)); - exchange.getResponse().getHeaders().add("removeHeaderKeys", String.valueOf(true)); - final Map body = ImmutableMap.builder() - .put("originReplaceBodyKeys", true) - .put("removeBodyKeys", true) - .build(); - return Mono.just(GsonUtils.getInstance().toJson(body)); - } - - /** - * modify request. - * - * @param userDTO request body - * @param cookie cookie - * @param requestHeader header - * @param requestParameter parameter - * @return result - */ - @ApiOperation(value = "modifyRequestWithHeaderAndCookie", notes = "modify request with header and cookie.") - @PostMapping(path = "/modifyRequest") - public Map modifyRequest(@RequestBody final UserDTO userDTO, - @CookieValue(value = "cookie", defaultValue = "") final String cookie, - @RequestHeader(value = "requestHeader", defaultValue = "") final String requestHeader, - @RequestParam(value = "requestParameter", defaultValue = "") final String requestParameter) { - Map result = new HashMap<>(); - result.put("body", userDTO); - result.put("cookie", cookie); - result.put("header", requestHeader); - result.put("parameter", requestParameter); - return result; - } - - /** - * Return Tree structure data. - * - * @param param param - * @return TreeResult - */ - @ApiOperation(value = "retureTreeData", notes = "Return Tree structure data.") - @PostMapping("/tree/v1") - public TreeResult tree(final UserDTO param) { - int id = 0; - TreeResult parent = new TreeResult(); - parent.setId(++id); - parent.setName("parentNode" + param.getUserName()); - parent.setParentId(0); - - TreeResult child1 = new TreeResult(); - child1.setId(++id); - child1.setName("childNode1"); - child1.setParentId(1); - - TreeResult child2 = new TreeResult(); - child2.setId(++id); - child2.setName("childNode2"); - child2.setParentId(1); - - parent.setChildren(Arrays.asList(child1, child2)); - return parent; - } - - /** - * download file. - * - * @param body file content - * @return file - * @throws IOException io exception - */ - @GetMapping(path = "/download") - public ResponseEntity downloadFile( - @RequestParam(value = "body", defaultValue = "") final String body) throws IOException { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); - - String downloadFileName = URLEncoder.encode("downloadFile.txt", "UTF-8"); - headers.setContentDispositionFormData("attachment", downloadFileName); - - return new ResponseEntity<>(body.getBytes(StandardCharsets.UTF_8), headers, HttpStatus.CREATED); - } - - /** - * upload file and print. - * - * @param filePart upload file - * @return OK - * @throws IOException io exception - */ - @PostMapping(path = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public String downloadFile(@RequestPart("file") final FilePart filePart) throws IOException { - LOGGER.info("file name: {}", filePart.filename()); - Path tempFile = Files.createTempFile(String.valueOf(System.currentTimeMillis()), filePart.filename()); - filePart.transferTo(tempFile.toFile()); - try (BufferedReader bufferedReader = new BufferedReader(new FileReader(tempFile.toFile()))) { - String line = bufferedReader.readLine(); - while (Objects.nonNull(line)) { - LOGGER.info(line); - line = bufferedReader.readLine(); - } - } - return "OK"; - } - - /** - * Return bad request code. - * - * @return response. result bean - */ - @GetMapping("/request/badrequest") - @ResponseStatus(HttpStatus.BAD_REQUEST) - public ResultBean badRequest() { - ResultBean response = new ResultBean(); - response.setCode(400); - return response; - } - - /** - * Return bad request code. - * - * @return response. result bean - */ - @GetMapping("/request/accepted") - @ResponseStatus(HttpStatus.ACCEPTED) - public ResultBean accepted() { - ResultBean response = new ResultBean(); - response.setCode(202); - return response; - } - - /** - * Return bad request code. - * - * @return response. result bean - */ - @GetMapping("/success") - public ResultBean success() { - ResultBean response = new ResultBean(); - response.setCode(200); - return response; - } - - private UserDTO buildUser(final String id, final String name) { - UserDTO userDTO = new UserDTO(); - userDTO.setUserId(id); - userDTO.setUserName(name); - return userDTO; - } - - /** - * pass endpoint for hystrix plugin. - * - * @return response. result bean - */ - @GetMapping("/hystrix/pass") - public ResultBean hystrixPass() { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - return response; - } - - /** - * fallback endpoint for hystrix plugin. - * - * @return response. result bean - */ - @GetMapping("/hystrix/fallback") - public ResultBean hystrixFallback() { - ResultBean response = new ResultBean(); - response.setCode(429); - response.setMsg("fallback"); - return response; - } - - /** - * test pass for cache plugin. - * - * @return response. result bean - */ - @GetMapping("/cache") - public ResultBean testCache() { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg(new Date().toString()); - return response; - } - - /** - * test null response body. - * - * @return response body - */ - @GetMapping("/nullResponse") - public Object testResponseBodyIsNull() { - return null; - } - - /** - * test big request body. - * - * @param params request body - * @return the result of post - */ - @PostMapping("/bigRequestBody") - public ResultBean postBigRequestBody(@RequestBody final UserDTO params) { - ResultBean resultBean = new ResultBean(); - resultBean.setCode(200); - resultBean.setData(params); - return resultBean; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java deleted file mode 100644 index be9c4f6..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * OauthController. - */ -@RestController -@RequestMapping("/oauth") -@ShenyuSpringMvcClient("/oauth") -public class OauthController { - - /** - * Test oauth2 code request. - * - * @return String - */ - @GetMapping("/authorize") - public String testCode() { - return "authorize"; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java deleted file mode 100644 index a96380c..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.examples.http.dto.OAuth2DTO; -import org.apache.shenyu.examples.http.dto.OrderDTO; -import org.springframework.http.HttpHeaders; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.Objects; - -/** - * TestController. - */ -@Api(tags = "Order API", position = 2) -@RestController -@RequestMapping("/order") -@ShenyuSpringMvcClient("/order") -public class OrderController { - - /** - * Save order dto. - * - * @param orderDTO the order dto - * @return the order dto - */ - @ApiOperation(value = "save", notes = "save the order.") - @PostMapping("/save") - @ShenyuSpringMvcClient("/save") - public OrderDTO save(@RequestBody final OrderDTO orderDTO) { - orderDTO.setName("hello world save order"); - return orderDTO; - } - - /** - * Find by id order dto. - * - * @param id the id - * @return the order dto - */ - @ApiOperation(value = "findById", notes = "find order info by id.") - @GetMapping("/findById") - @ShenyuSpringMvcClient("/findById") - public OrderDTO findById(@RequestParam("id") final String id) { - return build(id, "hello world findById"); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @ApiOperation(value = "getPathVariable", notes = "get path variable.") - @GetMapping("/path/{id}/{name}") - @ShenyuSpringMvcClient("/path/**") - public OrderDTO getPathVariable(@PathVariable("id") final String id, @PathVariable("name") final String name) { - return build(id, "hello world restful: " + name); - } - - /** - * Test restful order dto. - * - * @param id the id - * @return the order dto - */ - @GetMapping("/path/{id}/name") - @ShenyuSpringMvcClient("/path/**/name") - public OrderDTO testRestFul(@PathVariable("id") final String id) { - return build(id, "hello world restful inline " + id); - } - - /** - * Test oauth2 request. - * - * @param request request with the oauth2 headers - * @return the oauth2 dto - */ - @GetMapping("/oauth2/test") - @ShenyuSpringMvcClient("/oauth2/test") - public OAuth2DTO testRestFul(final ServerHttpRequest request) { - HttpHeaders headers = request.getHeaders(); - List tokens = headers.get("Authorization"); - OAuth2DTO oAuth2DTO = new OAuth2DTO(); - oAuth2DTO.setToken(Objects.isNull(tokens) ? "no authorization" : tokens.get(0)); - return oAuth2DTO; - } - - private OrderDTO build(final String id, final String name) { - OrderDTO orderDTO = new OrderDTO(); - orderDTO.setId(id); - orderDTO.setName(name); - return orderDTO; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java deleted file mode 100644 index 22b8539..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -/** - * RequestController. - */ -@Api(tags = "RequestController", position = 1) -@RestController -@RequestMapping("/request") -@ShenyuSpringMvcClient("/request/**") -public class RequestController { - - private static final Logger LOGGER = LoggerFactory.getLogger(RequestController.class); - - /** - * Test for header annotation. - * - * @param headerKey1 one RequestHeader key - * @param serverHttpRequest request - * @return response - */ - @ApiOperation(value = "testRequestHeader", notes = "test request header.") - @GetMapping(path = "/header") - public Mono testRequestHeader(@RequestHeader("header_key1") final String headerKey1, - final ServerHttpRequest serverHttpRequest) { - LOGGER.info("header_key1:{}, receive headers: {}", headerKey1, serverHttpRequest.getHeaders()); - return successMono(serverHttpRequest.getHeaders()); - } - - /** - * Test for param annotation. - * - * @param parameterKey1 one RequestParam key - * @param serverHttpRequest request - * @return response - */ - @ApiOperation(value = "testRequestParameter", notes = "test request parameter.") - @PostMapping(path = "/parameter") - public Mono testRequestParameter(@RequestParam("parameter_key1") final String parameterKey1, - final ServerHttpRequest serverHttpRequest) { - LOGGER.info("parameter_key1: {}, receive param: {}", parameterKey1, serverHttpRequest.getQueryParams()); - return successMono(serverHttpRequest.getQueryParams()); - } - - /** - * Test for cookie annotation. - * - * @param userId a cookie key with the name userId - * @param serverHttpRequest request - * @return response - */ - @ApiOperation(value = "testRequestCookie", notes = "test request parameter.") - @GetMapping(path = "/cookie") - public Mono testRequestCookie(@CookieValue("userId") final String userId, - final ServerHttpRequest serverHttpRequest) { - LOGGER.info("userId:{}, receive Cookies: {}", userId, serverHttpRequest.getCookies()); - return successMono(serverHttpRequest.getCookies()); - } - - private Mono successMono(final Object body) { - return Mono.just("response success: " + body); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java deleted file mode 100644 index 7fdb261..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import io.swagger.annotations.ApiOperation; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * ShenyuClientPathController. - */ -@RestController -public class ShenyuClientPathController { - - private static final Logger LOG = LoggerFactory.getLogger(ShenyuClientPathController.class); - - private static final String HELLO_SUFFIX = "I'm Shenyu-Gateway System. Welcome!"; - - /** - * hello. - * - * @return result - */ - @RequestMapping("shenyu/client/hello") - @ShenyuSpringMvcClient("shenyu/client/hello") - public String hello() { - return "hello! " + HELLO_SUFFIX; - } - - /** - * hello. br - * no support gateway. - * - * @param name say hello user name - * @return result - */ - @ApiOperation(value = "hello", notes = "Shenyu-Gateway System said hello to you.") - @RequestMapping("shenyu/client/hi") - @ShenyuSpringMvcClient("shenyu/client/hi") - public String hello(final String name) { - return "hi! " + name + "! " + HELLO_SUFFIX; - } - - /** - * timeout. - * - * @return result - */ - @RequestMapping("shenyu/client/timeout") - @ShenyuSpringMvcClient("shenyu/client/timeout") - public String timeout() { - LOG.info("timeout"); - try { - Thread.sleep(10000); - } catch (InterruptedException ignored) { - } - return "hello! " + HELLO_SUFFIX; - } - - /** - * hi. - * - * @param name name - * @return result - */ - @PostMapping("shenyu/client/post/hi") - @ShenyuSpringMvcClient(desc = "shenyu client annotation register") - public String post(final String name) { - return "[post method result]:hi! " + name + "! " + HELLO_SUFFIX; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java deleted file mode 100644 index 15130d8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * SpringMvcMappingPathController. - */ -@RestController -@ShenyuSpringMvcClient(desc = "spring annotation register") -@Api(value = "springMvcMappingPathController") -public class SpringMvcMappingPathController { - - private static final String HELLO_SUFFIX = "I'm Shenyu-Gateway System. Welcome!"; - - /** - * hello. - * - * @return result - */ - @RequestMapping("hello") - @ApiOperation(value = "hello", notes = "say hello.") - public String hello() { - return "hello! " + HELLO_SUFFIX; - } - - /** - * hi. - * - * @param name name - * @return result - */ - @RequestMapping("hi") - @ApiOperation(value = "hi", notes = "say hello to name.") - public String hello(final String name) { - return "hi! " + name + "! " + HELLO_SUFFIX; - } - - /** - * hi. - * - * @param name name - * @return result - */ - @PostMapping("post/hi") - @ApiOperation(value = "postHi", notes = "post hi.") - public String post(final String name) { - return "[post method result]:hi! " + name + "! " + HELLO_SUFFIX; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java deleted file mode 100644 index 93d1e9a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import java.util.stream.Collectors; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.http.MediaType; -import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -/** - * UploadController. - */ -@RestController -@RequestMapping("/upload") -@ShenyuSpringMvcClient("/upload/**") -@Api(tags = "upload api") -public class UploadController { - - /** - * webFlux uploadFile. - * - * @param file the file you upload - * @return response - */ - @PostMapping(value = "/webFluxSingle", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.TEXT_PLAIN_VALUE}) - @ApiOperation(value = "webFluxSingle", notes = "upload webFluxSingle.") - public Mono webFluxSingle(@RequestPart("file") final FilePart file) { - return Mono.just(file.filename()); - } - - /** - * webFlux uploadFiles. - * - * @param files the file you upload - * @return response - */ - @PostMapping(value = "/webFluxFiles", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.TEXT_PLAIN_VALUE}) - @ApiOperation(value = "webFluxFiles", notes = "upload webFluxFiles.") - public Mono webFluxFiles(@RequestPart(value = "files", required = false) final Flux files) { - return files.map(FilePart::filename).collect(Collectors.joining(",")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java deleted file mode 100644 index d0b8ca8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -import io.swagger.annotations.ApiModelProperty; - -public class OAuth2DTO { - - @ApiModelProperty(value = "token", example = "afte6789try") - private String token; - - /** - * Get token. - * - * @return token - */ - public String getToken() { - return token; - } - - /** - * Set token. - * - * @param token token - */ - public void setToken(final String token) { - this.token = token; - } - - @Override - public String toString() { - return "OAuth2DTO{" + "token='" + token + '\'' + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java deleted file mode 100644 index 6f10246..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -import io.swagger.annotations.ApiModelProperty; -import java.io.Serializable; -import java.util.Date; -import java.util.StringJoiner; - -/** - * The type Order dto. - */ -public class OrderDTO implements Serializable { - - @ApiModelProperty(value = "id", required = true, example = "100000") - private String id; - - @ApiModelProperty(value = "name", required = true, example = "jack") - private String name; - - @ApiModelProperty(value = "createTime", example = "2023-08-01 10:10:01") - private Date createTime; - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * get createTime. - * @return createTime - */ - public Date getCreateTime() { - return createTime; - } - - /** - * setCreateTime. - * @param createTime createTime - */ - public void setCreateTime(final Date createTime) { - this.createTime = createTime; - } - - @Override - public String toString() { - return new StringJoiner(", ", OrderDTO.class.getSimpleName() + "[", "]") - .add("id='" + id + "'") - .add("name='" + name + "'") - .add("createTime='" + createTime + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java deleted file mode 100644 index ab506d8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -import io.swagger.annotations.ApiModelProperty; -import java.util.StringJoiner; - -/** - * The type Request dto. - */ -public class RequestDTO { - - @ApiModelProperty(value = "module", required = true, example = "usercenter") - private String module; - - @ApiModelProperty(value = "method", required = true, example = "findByUserId", position = 1) - private String method; - - @ApiModelProperty(value = "content", example = "hello,shenyu") - private String content; - - @ApiModelProperty(value = "extInfo", example = "extended information", position = 2) - private String extInfo; - - public RequestDTO() { - } - - public RequestDTO(final String module, final String method, final String content, final String extInfo) { - this.module = module; - this.method = method; - this.content = content; - this.extInfo = extInfo; - } - - /** - * Get module. - * - * @return module - */ - public String getModule() { - return module; - } - - /** - * Set module. - * - * @param module module - */ - public void setModule(final String module) { - this.module = module; - } - - /** - * Get method. - * - * @return method - */ - public String getMethod() { - return method; - } - - /** - * Set method. - * - * @param method method - */ - public void setMethod(final String method) { - this.method = method; - } - - /** - * Get content. - * - * @return content - */ - public String getContent() { - return content; - } - - /** - * Set content. - * - * @param content content - */ - public void setContent(final String content) { - this.content = content; - } - - /** - * Get extInfo. - * - * @return extInfo - */ - public String getExtInfo() { - return extInfo; - } - - /** - * Set extInfo. - * - * @param extInfo extInfo - */ - public void setExtInfo(final String extInfo) { - this.extInfo = extInfo; - } - - @Override - public String toString() { - return new StringJoiner(", ", RequestDTO.class.getSimpleName() + "[", "]") - .add("module='" + module + "'") - .add("method='" + method + "'") - .add("content='" + content + "'") - .add("extInfo='" + extInfo + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java deleted file mode 100644 index 0a39802..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -import io.swagger.annotations.ApiModelProperty; -import java.util.List; -import java.util.Map; - -/** - * The type User dto. - */ -public class UserDTO { - - @ApiModelProperty(value = "user id", required = true, example = "100000") - private String userId; - - @ApiModelProperty(value = "user name", example = "shenyu") - private String userName; - - @ApiModelProperty(value = "main order", example = "") - private OrderDTO mainOrder; - - @ApiModelProperty(value = "order list", required = true, dataType = "List", example = "") - private List orderDetailList; - - @ApiModelProperty(value = "order map", example = "") - private Map orderDetailMap; - - /** - * Get userId. - * - * @return userId - */ - public String getUserId() { - return userId; - } - - /** - * Set userId. - * - * @param userId userId - */ - public void setUserId(final String userId) { - this.userId = userId; - } - - /** - * Get userName. - * - * @return userName - */ - public String getUserName() { - return userName; - } - - /** - * Set userName. - * - * @param userName userName - */ - public void setUserName(final String userName) { - this.userName = userName; - } - - /** - * getMainOrder. - * - * @return OrderDTO - */ - public OrderDTO getMainOrder() { - return mainOrder; - } - - /** - * setMainOrder. - * - * @param mainOrder mainOrder - */ - public void setMainOrder(final OrderDTO mainOrder) { - this.mainOrder = mainOrder; - } - - /** - * getOrderDetailList. - * - * @return List - */ - public List getOrderDetailList() { - return orderDetailList; - } - - /** - * setOrderDetailList. - * - * @param orderDetailList orderDetailList - */ - public void setOrderDetailList(final List orderDetailList) { - this.orderDetailList = orderDetailList; - } - - /** - * getOrderDetailMap. - * - * @return Map - */ - public Map getOrderDetailMap() { - return orderDetailMap; - } - - /** - * setOrderDetailMap. - * - * @param orderDetailMap orderDetailMap - */ - public void setOrderDetailMap(final Map orderDetailMap) { - this.orderDetailMap = orderDetailMap; - } - - @Override - public String toString() { - return "UserDTO{" - + "userId='" - + userId - + '\'' - + ", userName='" - + userName - + '\'' - + ", mainOrder=" - + mainOrder - + ", orderDetailList=" - + orderDetailList - + ", orderDetailMap=" - + orderDetailMap - + '}'; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java deleted file mode 100644 index 4814ab5..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.result; - -/** - * ResultBean. - */ -public class ResultBean { - - private Integer code; - - private String msg; - - private Object data; - - public ResultBean() { - } - - public ResultBean(final Integer code, final String msg, final Object data) { - this.code = code; - this.msg = msg; - this.data = data; - } - - /** - * Get code. - * - * @return code - */ - public Integer getCode() { - return code; - } - - /** - * Set code. - * - * @param code code - */ - public void setCode(final Integer code) { - this.code = code; - } - - /** - * Get msg. - * - * @return msg - */ - public String getMsg() { - return msg; - } - - /** - * Set msg. - * - * @param msg msg - */ - public void setMsg(final String msg) { - this.msg = msg; - } - - /** - * Get data. - * - * @return data - */ - public Object getData() { - return data; - } - - /** - * Set data. - * - * @param data data - */ - public void setData(final Object data) { - this.data = data; - } - - @Override - public String toString() { - return "ResultBean{" + "code=" + code + ", msg='" + msg + '\'' + ", data=" + data + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java deleted file mode 100755 index c5f7f83..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.result; - -import io.swagger.annotations.ApiModelProperty; -import java.util.List; - -public class TreeResult { - @ApiModelProperty(value = "id", required = true, example = "123") - private Integer id; - - @ApiModelProperty(value = "name", required = true, example = "shenyu") - private String name; - - @ApiModelProperty(value = "parent id") - private Integer parentId; - - @ApiModelProperty(value = "children node list", example = "list") - private List children; - - /** - * get id. - * - * @return Integer - */ - public Integer getId() { - return id; - } - - /** - * setId. - * - * @param id id - */ - public void setId(final Integer id) { - this.id = id; - } - - /** - * get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * setName. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * getParentId. - * - * @return parentId - */ - public Integer getParentId() { - return parentId; - } - - /** - * setParentId. - * - * @param parentId parentId - */ - public void setParentId(final Integer parentId) { - this.parentId = parentId; - } - - /** - * getChildren. - * - * @return list - */ - public List getChildren() { - return children; - } - - /** - * setChildren. - * - * @param children children - */ - public void setChildren(final List children) { - this.children = children; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java deleted file mode 100644 index 9316b99..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.router; - -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.shenyu.examples.http.result.ResultBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; - -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RequestPredicates.path; -import static org.springframework.web.reactive.function.server.RouterFunctions.nest; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -/** - * The type shenyu test http router. - */ -@Component -public class ShenyuTestHttpRouter { - - private static final Logger LOG = LoggerFactory.getLogger(ShenyuTestHttpRouter.class); - - private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger(1); - - /** - * Routes router function. - * - * @return the router function - */ - public RouterFunction routes() { - return nest(path("/test"), - route(POST("/helloWorld2") - .and(accept(APPLICATION_JSON)), this::postHandler) - .and(route(GET("/rewrite"), this::rewriteHandler)) - .and(route(GET("/pdm"), this::pdmHttpGet)) - .and(route(GET("/oms"), this::omsHttpGet)) - .and(route(GET("/timeout"), this::testRetry))); - } - - @NonNull - private Mono testRetry(final ServerRequest req) { - int i = ATOMIC_INTEGER.incrementAndGet(); - LOG.info("Retry count: " + i); - ResultBean resultBean = new ResultBean(1, "msg", "this is retry hello world"); - return ok().body(Mono.just(resultBean), ResultBean.class); - } - - @NonNull - private Mono pdmHttpGet(final ServerRequest req) { - ResultBean resultBean = new ResultBean(1, "msg", "this is pdm get hello world"); - return ok().body(Mono.just(resultBean), ResultBean.class); - } - - @NonNull - private Mono omsHttpGet(final ServerRequest req) { - ResultBean resultBean = new ResultBean(1, "msg", "this is oms get hello world"); - return ok().body(Mono.just(resultBean), ResultBean.class); - } - - @NonNull - private Mono rewriteHandler(final ServerRequest req) { - ResultBean resultBean = new ResultBean(1, "msg", "this is rewrite hello world"); - return ok().body(Mono.just(resultBean), ResultBean.class); - } - - @NonNull - private Mono postHandler(final ServerRequest req) { - final Mono string = req.bodyToMono(String.class); - return ok().body(string, String.class); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/resources/application.yml deleted file mode 100644 index a3662a0..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http-swagger2/src/main/resources/application.yml +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8190 - address: 0.0.0.0 - tomcat: - max-http-form-post-size: 100MB - servlet: - context-path: /http-swagger2 # should be the same as shenyu.client.http.contextPath - -shenyu: - register: - registerType: http - serverLists: http://127.0.0.1:9095 - props: - username: admin - password: 123456 - client: - http: - props: - contextPath: /http-swagger2 - appName: http-swagger2 -# port: 8190 -# discovery: -# enable: true -# protocol: http:// #https:// -# type: zookeeper -# serverList: 127.0.0.1:2181 -# registerPath: /shenyu/discovery/demo_swagger2_common -# props: -# baseSleepTimeMilliseconds: 1000 -# maxRetries: 4 -# maxSleepTimeMilliseconds: 5000 -# connectionTimeoutMilliseconds: 60000 -# sessionTimeoutMilliseconds: 8 -# type: etcd -# serverList: http://127.0.0.1:2379 -# registerPath: shenyu_discovery_demo_${shenyu.client.http.props.appName} -# type: eureka -# serverList: http://127.0.0.1:8761/eureka -# registerPath: shenyu_discovery_demo_http-swagger3 - -spring: - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - mvc: - pathmatch: - matching-strategy: ant_path_matcher - -logging: - level: - root: info - org.springframework.boot: info - org.apache.ibatis: info - org.apache.shenyu.test.bonuspoint: info - org.apache.shenyu.test.lottery: debug - org.apache.shenyu.test: debug - diff --git a/shenyu-java-examples/shenyu-java-examples-http/Dockerfile b/shenyu-java-examples/shenyu-java-examples-http/Dockerfile deleted file mode 100644 index d6b53f4..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-examples-http -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8189 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-http/k8s/ingress.yml b/shenyu-java-examples/shenyu-java-examples-http/k8s/ingress.yml deleted file mode 100644 index 94b7163..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/k8s/ingress.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/loadbalancer: p2c - shenyu.apache.org/upstreams-protocol: http://,http:// - name: demo-ingress -spec: - rules: - - http: - paths: - - backend: - service: - name: shenyu-java-examples-java-http-service - port: - number: 8189 - path: /** - pathType: ImplementationSpecific diff --git a/shenyu-java-examples/shenyu-java-examples-http/k8s/script/healthcheck.sh b/shenyu-java-examples/shenyu-java-examples-http/k8s/script/healthcheck.sh deleted file mode 100644 index 89a4dbd..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/k8s/script/healthcheck.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -kubectl -n kube-system get pods | grep Evicted |awk '{print$1}'|xargs kubectl -n kube-system delete pods - -kubectl get pod -o wide - -PRGDIR=`dirname "$0"` -for service in `grep -v -E "^$|^#" ${PRGDIR}/services.list` -do - for loop in `seq 1 30` - do - status=`curl -o /dev/null -s -w %{http_code} $service` - echo -e "curl $service response $status" - - if [ $status -eq 200 ]; then - break - fi - - sleep 2 - done -done - -sleep 5 - -status=`curl -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type:application/json" http://localhost:31195/http/order/save --data '{"name":"test", "id": 123}'` - -sleep 3 - -if [ $status -eq 200 ]; then - echo -e "Success to send request: $status" - echo -e "\n-------------------" - exit 0 -fi -echo -e "Failed to send request from shenyu-bootstrap to http example: $status" -echo -e "\n-------------------" -exit 1 diff --git a/shenyu-java-examples/shenyu-java-examples-http/k8s/script/services.list b/shenyu-java-examples/shenyu-java-examples-http/k8s/script/services.list deleted file mode 100644 index 912051f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/k8s/script/services.list +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -http://localhost:31095/actuator/health -http://localhost:31195/actuator/health -http://localhost:31189/actuator/health diff --git a/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-deployment.yml b/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-deployment.yml deleted file mode 100644 index 7b0bc67..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-deployment.yml +++ /dev/null @@ -1,82 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-admin - labels: - app: shenyu-admin - all: shenyu-examples-http -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-admin - all: shenyu-examples-http - template: - metadata: - labels: - app: shenyu-admin - all: shenyu-examples-http - spec: - containers: - - name: shenyu-admin - image: apache/shenyu-admin:latest - resources: {} - env: - - name: SPRING_PROFILES_ACTIVE - value: h2 - - name: shenyu.database.init_script - value: sql-script/h2/schema.sql - ports: - - containerPort: 9095 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-bootstrap - labels: - app: shenyu-bootstrap - all: shenyu-examples-http -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-bootstrap - all: shenyu-examples-http - template: - metadata: - labels: - app: shenyu-bootstrap - all: shenyu-examples-http - spec: - containers: - - name: shenyu-bootstrap - image: apache/shenyu-bootstrap:latest - resources: {} - env: - - name: shenyu.sync.websocket.urls - value: ws://shenyu-admin:9095/websocket - ports: - - containerPort: 9195 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-examples-http.yml b/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-examples-http.yml deleted file mode 100644 index 693f867..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-examples-http.yml +++ /dev/null @@ -1,77 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-examples-http-deployment - labels: - app: shenyu-examples-http - all: shenyu-examples-http -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-examples-http - all: shenyu-examples-http - strategy: {} - template: - metadata: - labels: - app: shenyu-examples-http - all: shenyu-examples-http - spec: - containers: - - image: shenyu-examples-http - name: shenyu-java-examples-java-http - livenessProbe: - exec: - command: - - /bin/sh - - "-c" - - wget -q -O - http://localhost:8189/actuator/health | grep UP || exit 1 - initialDelaySeconds: 10 - failureThreshold: 3 - timeoutSeconds: 2 - env: - - name: shenyu.register.serverLists - value: http://shenyu-admin:9095 - ports: - - containerPort: 8189 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-examples-http-service - labels: - app: shenyu-examples-http - all: shenyu-examples-http -spec: - selector: - app: shenyu-examples-http - all: shenyu-examples-http - type: NodePort - ports: - - name: "8189" - port: 8189 - targetPort: 8189 - nodePort: 31189 -status: - loadBalancer: {} diff --git a/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-service.yml b/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-service.yml deleted file mode 100644 index 9ee0ce9..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-service.yml +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: v1 -kind: Service -metadata: - name: shenyu-admin - labels: - app: shenyu-admin - all: shenyu-examples-http -spec: - type: NodePort - selector: - app: shenyu-admin - all: shenyu-examples-http - ports: - - name: "9095" - port: 9095 - targetPort: 9095 - nodePort: 31095 - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-bootstrap - labels: - app: shenyu-bootstrap - all: shenyu-examples-http -spec: - type: NodePort - selector: - app: shenyu-bootstrap - all: shenyu-examples-http - ports: - - name: "9195" - port: 9195 - targetPort: 9195 - nodePort: 31195 \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-zookeeper.yml b/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-zookeeper.yml deleted file mode 100644 index a089efd..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/k8s/shenyu-zookeeper.yml +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: shenyu-zk - all: shenyu-examples-http - name: shenyu-zk -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-zk - all: shenyu-examples-http - strategy: {} - template: - metadata: - labels: - app: shenyu-zk - all: shenyu-examples-http - spec: - containers: - - image: zookeeper:latest - name: shenyu-zk - resources: {} - ports: - - containerPort: 2181 - name: client - - containerPort: 2888 - name: server - - containerPort: 3888 - name: leader-election - - containerPort: 8080 - name: website - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-zk - labels: - app: shenyu-zk - all: shenyu-examples-http -spec: - type: NodePort - selector: - app: shenyu-zk - all: shenyu-examples-http - ports: - - name: "client" - port: 2181 - targetPort: 2181 - - name: "server" - port: 2888 - targetPort: 2888 - - name: "election" - port: 3888 - targetPort: 3888 - - name: "website" - port: 8080 - targetPort: 8080 diff --git a/shenyu-java-examples/shenyu-java-examples-http/pom.xml b/shenyu-java-examples/shenyu-java-examples-http/pom.xml deleted file mode 100644 index 5a77394..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/pom.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-http - - - 3.3.2 - 21.0 - 4.4 - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-springmvc - ${project.version} - - - - org.springframework.boot - spring-boot-starter - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-logging - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - - - shenyu-examples-http - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.http.ShenyuTestHttpApplication - true - - - - - - - - example - - shenyu-examples-http - shenyu-examples-http - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-examples-http - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/http/http-test-api-local.http b/shenyu-java-examples/shenyu-java-examples-http/src/main/http/http-test-api-local.http deleted file mode 100644 index da56aae..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/http/http-test-api-local.http +++ /dev/null @@ -1,185 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -# Not practical gateway, start it separately -# if you used IDEA, start example project. click green button.Quick access! - -### example local orderSave -POST http://localhost:8189/hello -Accept: application/json -Content-Type: application/json - -### example local orderSave -POST http://localhost:8189/hi?name=Tom -Accept: application/json -Content-Type: application/json - -### example local orderSave -POST http://localhost:8189/post/hi?name=Tom -Accept: application/json -Content-Type: application/json - -### example local orderSave -POST http://localhost:8189/shenyu/client/hello -Accept: application/json -Content-Type: application/json - -### example local orderSave -POST http://localhost:8189/shenyu/client/hi?name=Tom -Accept: application/json -Content-Type: application/json - -### example local orderSave -POST http://localhost:8189/shenyu/client/post/hi?name=Tom -Accept: application/json -Content-Type: application/json - -### example local orderSave -POST http://localhost:8189/order/save -Accept: application/json -Content-Type: application/json - -{ - "id": 123, - "name": "order" -} -### example local orderSave -GET http://localhost:8189/order/findById?id=123 -Accept: application/json -Content-Type: application/json - -### example local path -GET http://localhost:8189/order/path/123/hahah -Accept: application/json -Content-Type: application/json - -### example local path -GET http://localhost:8189/order/path/123/name -Accept: application/json -Content-Type: application/json - -### example local oauth2 -GET http://localhost:8189/order/oauth2/test -Accept: application/json -Content-Type: application/json -Authorization:AuthorizationContext - -### example local payment -POST http://localhost:8189/test/payment -Accept: application/json -Content-Type: application/json - -{ - "userId": 123, - "userName": "name" -} - -### example local findByUserId -GET http://localhost:8189/test/findByUserId?userId=123 -Accept: application/json -Content-Type: application/json - -### example local findByUserId -GET http://localhost:8189/test/findByUserId?userId=123%5D%2D -Accept: application/json -Content-Type: application/json - -### example local findByUserId -GET http://localhost:8189/test/findByUserId?userId=123%5D%2D%2Casd -Accept: application/json -Content-Type: application/json - -### example local findByUserId -GET http://localhost:8189/test/findByUserId?userId=123%5D%2D,asd -Accept: application/json -Content-Type: application/json - -### example local path -GET http://localhost:8189/test/path/123?name=haha -Accept: application/json -Content-Type: application/json - -### example local path -GET http://localhost:8189/test/path/123/name -Accept: application/json -Content-Type: application/json - -### example local waf pass -POST http://localhost:8189/test/waf/pass -Accept: application/json -Content-Type: application/json - -### example local waf deny -POST http://localhost:8189/test/waf/deny -Accept: application/json -Content-Type: application/json - -### example local request parameter pass -GET http://localhost:8189/test/request/parameter/pass?requestParameter=test -Accept: application/json -Content-Type: application/json - -### shengyu local request -GET http://localhost:8189/request/header -header_key1: shenyu_request_plugin -Accept: application/json -Content-Type: application/json - -### shengyu local request -POST http://localhost:8189/request/parameter?parameter_key1=shenyu_request_plugin -Accept: application/json -Content-Type: application/json - -### shengyu local request -GET http://localhost:8189/request/cookie -Cookie: userId=1 -Accept: application/json -Content-Type: application/json - -### example webFluxSingle -POST http://localhost:8189/upload/webFluxSingle -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt" -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - -### example webFluxFiles -POST http://localhost:8189/upload/webFluxFiles -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="1.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="2.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/2.txt - ---WebAppBoundary-- diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/http/http-test-api.http b/shenyu-java-examples/shenyu-java-examples-http/src/main/http/http-test-api.http deleted file mode 100644 index 728b04a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/http/http-test-api.http +++ /dev/null @@ -1,236 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -# Use gateway proxy -# if you used IDEA, start example project. click green button.Quick access! - -### shengyu getway test timeout -POST http://localhost:9195/http/shenyu/client/timeout -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy hello -POST http://localhost:9195/http/shenyu/client/hello -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy hi -POST http://localhost:9195/http/shenyu/client/hi?name=Tom -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy hi -POST http://localhost:9195/http/shenyu/client/post/hi?name=Tom -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy hello -POST http://localhost:9195/http/hello -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy hi -POST http://localhost:9195/http/hi?name=Tom -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy hi -POST http://localhost:9195/http/post/hi?name=Tom -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy orderSave -POST http://localhost:9195/http/order/save -Accept: application/json -Content-Type: application/json - -{ - "id": 123, - "name": "order" -} -### shengyu getway proxy orderSave -GET http://localhost:9195/http/order/findById?id=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/http/order/path/123/hahah -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/http/order/path/123/name -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy oauth2 -GET http://localhost:9195/http/order/oauth2/test -Accept: application/json -Content-Type: application/json -Authorization:AuthorizationContext - -### shengyu getway proxy payment -POST http://localhost:9195/http/test/payment -Accept: application/json -Content-Type: application/json - -{ - "userId": 123, - "userName": "name" -} -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=123%5D%2D -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=1# -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=1#1 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=1%25 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=123%20zcq -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=#123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=%25 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserIdName?userId=#&name=shenyu -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=123%5D%2D%2Casd -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=%5B%27z%27%2C%27zc%27%2C%27zz%27%5D -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy findByUserId -GET http://localhost:9195/http/test/findByUserId?userId=['z','zc','zz'] -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/http/test/path/123?name=haha -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/http/test/path/123/name -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy waf pass -POST http://localhost:9195/http/test/waf/pass -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy waf deny -POST http://localhost:9195/http/test/waf/deny -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy request parameter pass -GET http://localhost:9195/http/test/request/parameter/pass?requestParameter=test -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy request -GET http://localhost:9195/http/request/header -header_key1: shenyu_request_plugin -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy request -POST http://localhost:9195/http/request/parameter?parameter_key1=shenyu_request_plugin -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy request -GET http://localhost:9195/http/request/cookie -Cookie: userId=1 -Accept: application/json -Content-Type: application/json - - -### shengyu getway proxy bigObject -POST http://localhost:9195/http/test/bigObject -Accept: application/json -Content-Type: application/json - - -### shengyu getway proxy example webFluxSingle -POST http://localhost:9195/http/upload/webFluxSingle -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt" -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - -### shengyu getway proxy example webFluxFiles -POST http://localhost:9195/http/upload/webFluxFiles -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="1.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="2.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/2.txt - ---WebAppBoundary-- diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/ShenyuTestHttpApplication.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/ShenyuTestHttpApplication.java deleted file mode 100644 index d1d7e88..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/ShenyuTestHttpApplication.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * ShenyuTestHttpApplication. - */ -@SpringBootApplication -public class ShenyuTestHttpApplication { - - /** - * main. - * - * @param args args - */ - public static void main(final String[] args) { - SpringApplication.run(ShenyuTestHttpApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java deleted file mode 100644 index 1e80701..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.config; - -import org.apache.shenyu.examples.http.router.ShenyuTestHttpRouter; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.scheduler.Scheduler; -import reactor.core.scheduler.Schedulers; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -/** - * HttpServerConfig. - */ -@Configuration -public class HttpServerConfig { - - /** - * define a bean with name monoRouterFunction for test. - * @param shenyuTestHttpRouter shenyuTestHttpRouter - * @return route functions - */ - @Bean - public RouterFunction monoRouterFunction(final ShenyuTestHttpRouter shenyuTestHttpRouter) { - return shenyuTestHttpRouter.routes(); - } - - /** - * define scheduler bean. - * @return Scheduler bean. - */ - @Bean - public Scheduler scheduler() { - ExecutorService threadPool = new ThreadPoolExecutor(100, 100, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue<>(), - runnable -> { - Thread thread = new Thread(runnable, "http-exe"); - thread.setDaemon(false); - if (thread.getPriority() != Thread.NORM_PRIORITY) { - thread.setPriority(Thread.NORM_PRIORITY); - } - return thread; - }); - return Schedulers.fromExecutor(threadPool); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java deleted file mode 100644 index 40f6a0e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import com.google.common.collect.ImmutableMap; -import java.util.Objects; -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.common.utils.GsonUtils; -import org.apache.shenyu.examples.http.dto.BigObject; -import org.apache.shenyu.examples.http.dto.UserDTO; -import org.apache.shenyu.examples.http.result.ResultBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * TestController. - */ -@RestController -@RequestMapping("/test") -@ShenyuSpringMvcClient("/test/**") -@ApiModule("/test") -public class HttpTestController { - - private static final Integer SIZE = 20000; - - private static final Logger LOGGER = LoggerFactory.getLogger(HttpTestController.class); - - /** - * Post user dto. - * - * @param userDTO the user dto - * @return the user dto - */ - @PostMapping("/payment") - @ApiDoc(desc = "payment") - public UserDTO post(@RequestBody final UserDTO userDTO) { - return userDTO; - } - - /** - * Find by user id string. - * - * @param userId the user id - * @return the string - */ - @GetMapping("/findByUserId") - @ApiDoc(desc = "findByUserId") - public UserDTO findByUserId(@RequestParam("userId") final String userId) { - return buildUser(userId, "hello world"); - } - - /** - * Find by user id string. - * - * @param userId the user id - * @param name name - * @return the string - */ - @GetMapping("/findByUserIdName") - @ApiDoc(desc = "findByUserIdName") - public UserDTO findByUserId(@RequestParam("userId") final String userId, @RequestParam("name") final String name) { - return buildUser(userId, name); - } - - /** - * Find by page user dto. - * - * @param keyword the keyword - * @param page the page - * @param pageSize the page size - * @return the user dto - */ - @GetMapping("/findByPage") - @ApiDoc(desc = "findByPage") - public UserDTO findByPage(final String keyword, final Integer page, final Integer pageSize) { - return buildUser(keyword, "hello world keyword is " + keyword + " page is " + page + " pageSize is " + pageSize); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @GetMapping("/path/{id}") - @ApiDoc(desc = "path/{id}") - public UserDTO getPathVariable(@PathVariable("id") final String id, @RequestParam("name") final String name) { - return buildUser(id, name); - } - - - /** - * Test rest ful string. - * - * @param id the id - * @return the string - */ - @GetMapping("/path/{id}/name") - @ApiDoc(desc = "path/{id}/name") - public UserDTO testRestFul(@PathVariable("id") final String id) { - return buildUser(id, "hello world"); - } - - - /** - * Put path variable and body string. - * - * @param id the id - * @param userDTO the user dto - * @return the string - */ - @PutMapping("/putPathBody/{id}") - public UserDTO putPathVariableAndBody(@PathVariable("id") final String id, @RequestBody final UserDTO userDTO) { - userDTO.setUserId(id); - userDTO.setUserName("hello world"); - return userDTO; - } - - /** - * the waf pass. - * - * @return response. result bean - */ - @PostMapping("/waf/pass") - public ResultBean pass() { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - return response; - } - - /** - * the waf deny. - * - * @return response. result bean - */ - @PostMapping("/waf/deny") - public ResultBean deny() { - ResultBean response = new ResultBean(); - response.setCode(403); - response.setMsg("deny"); - return response; - } - - /** - * request Pass. - * - * @param requestParameter the requestParameter. - * @return ResultBean result bean - */ - @GetMapping("/request/parameter/pass") - public ResultBean requestParameter(@RequestParam("requestParameter") final String requestParameter) { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - Map param = new HashMap<>(); - param.put("requestParameter", requestParameter); - response.setData(param); - return response; - } - - /** - * request Pass. - * - * @param requestHeader the requestHeader. - * @return ResultBean result bean - */ - @GetMapping("/request/header/pass") - public ResultBean requestHeader(@RequestHeader("requestHeader") final String requestHeader) { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - Map param = new HashMap<>(); - param.put("requestHeader", requestHeader); - response.setData(param); - return response; - } - - /** - * request Pass. - * - * @param cookie the cookie. - * @return ResultBean result bean - */ - @GetMapping("/request/cookie/pass") - public ResultBean requestCookie(@CookieValue("cookie") final String cookie) { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - Map param = new HashMap<>(); - param.put("cookie", cookie); - response.setData(param); - return response; - } - - /** - * post sentinel. - * - * @return response. result bean - */ - @PostMapping("/sentinel/pass") - public ResultBean sentinelPass() { - return pass(); - } - - /** - * modify response. - * - * @param exchange exchange - * @return response mono - */ - @GetMapping(path = "/modifyResponse") - public Mono modifyResponse(final ServerWebExchange exchange) { - exchange.getResponse().getHeaders().add("useByModifyResponse", String.valueOf(true)); - exchange.getResponse().getHeaders().add("setHeadersExist", String.valueOf(true)); - exchange.getResponse().getHeaders().add("replaceHeaderKeys", String.valueOf(true)); - exchange.getResponse().getHeaders().add("removeHeaderKeys", String.valueOf(true)); - final Map body = ImmutableMap.builder() - .put("originReplaceBodyKeys", true) - .put("removeBodyKeys", true) - .build(); - return Mono.just(GsonUtils.getInstance().toJson(body)); - } - - - /** - * modify request. - * - * @param userDTO request body - * @param cookie cookie - * @param requestHeader header - * @param requestParameter parameter - * @return result - */ - @PostMapping(path = "/modifyRequest") - public Map modifyRequest(@RequestBody final UserDTO userDTO, - @CookieValue(value = "cookie", defaultValue = "") final String cookie, - @RequestHeader(value = "requestHeader", defaultValue = "") final String requestHeader, - @RequestParam(value = "requestParameter", defaultValue = "") final String requestParameter) { - Map result = new HashMap<>(); - result.put("body", userDTO); - result.put("cookie", cookie); - result.put("header", requestHeader); - result.put("parameter", requestParameter); - return result; - } - - /** - * download file. - * - * @param body file content - * @return file - * @throws IOException io exception - */ - @GetMapping(path = "/download") - public ResponseEntity downloadFile(@RequestParam(value = "body", defaultValue = "") final String body) throws IOException { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); - - String downloadFileName = URLEncoder.encode("downloadFile.txt", "UTF-8"); - headers.setContentDispositionFormData("attachment", downloadFileName); - - return new ResponseEntity<>(body.getBytes(StandardCharsets.UTF_8), headers, HttpStatus.CREATED); - } - - - /** - * upload file and print. - * - * @param filePart upload file - * @return OK - * @throws IOException io exception - */ - @PostMapping(path = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public String downloadFile(@RequestPart("file") final FilePart filePart) throws IOException { - LOGGER.info("file name: {}", filePart.filename()); - Path tempFile = Files.createTempFile(String.valueOf(System.currentTimeMillis()), filePart.filename()); - filePart.transferTo(tempFile.toFile()); - try (BufferedReader bufferedReader = new BufferedReader(new FileReader(tempFile.toFile()))) { - String line = bufferedReader.readLine(); - while (Objects.nonNull(line)) { - LOGGER.info(line); - line = bufferedReader.readLine(); - } - } - return "OK"; - } - - /** - * Return bad request code. - * - * @return response. result bean - */ - @GetMapping("/request/badrequest") - @ResponseStatus(HttpStatus.BAD_REQUEST) - public ResultBean badRequest() { - ResultBean response = new ResultBean(); - response.setCode(400); - return response; - } - - /** - * Return bad request code. - * - * @return response. result bean - */ - @GetMapping("/request/accepted") - @ResponseStatus(HttpStatus.ACCEPTED) - public ResultBean accepted() { - ResultBean response = new ResultBean(); - response.setCode(202); - return response; - } - - /** - * Return bad request code. - * - * @return response. result bean - */ - @GetMapping("/success") - public ResultBean success() { - ResultBean response = new ResultBean(); - response.setCode(200); - return response; - } - - private UserDTO buildUser(final String id, final String name) { - UserDTO userDTO = new UserDTO(); - userDTO.setUserId(id); - userDTO.setUserName(name); - return userDTO; - } - - /** - * pass endpoint for hystrix plugin. - * - * @return response. result bean - */ - @GetMapping ("/hystrix/pass") - public ResultBean hystrixPass() { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - return response; - } - - /** - * fallback endpoint for hystrix plugin. - * - * @return response. result bean - */ - @GetMapping("/hystrix/fallback") - public ResultBean hystrixFallback() { - ResultBean response = new ResultBean(); - response.setCode(429); - response.setMsg("fallback"); - return response; - } - - /** - * test pass for cache plugin. - * - * @return response. result bean - */ - @GetMapping("/cache") - public ResultBean testCache() { - ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg(new Date().toString()); - return response; - } - - /** - * test null response body. - * - * @return response body - */ - @GetMapping("/nullResponse") - public Object testResponseBodyIsNull() { - return null; - } - - - /** - * test big request body. - * - * @param params request body - * @return the result of post - */ - @PostMapping("/bigRequestBody") - public ResultBean postBigRequestBody(@RequestBody final UserDTO params) { - ResultBean resultBean = new ResultBean(); - resultBean.setCode(200); - resultBean.setData(params); - return resultBean; - } - - /** - * big object. - * @return big object - */ - @PostMapping("/bigObject") - public BigObject bigObject() { - BigObject bigObject = new BigObject(); - bigObject.setId(1); - String[] obj = new String[SIZE]; - for (int i = 0; i < SIZE; i++) { - obj[i] = String.valueOf(i); - } - bigObject.setObj(obj); - return bigObject; - } - - /** - * test blank query. - * - * @return response body - */ - @PostMapping("/ /query") - public ResultBean blankQuery() { - ResultBean resultBean = new ResultBean(); - resultBean.setCode(200); - resultBean.setData("test blank query"); - return resultBean; - } - - /** - * test blank query with params. - * - * @param param params - * @return response body - */ - @PostMapping("/query") - public ResultBean blankQueryWithParams(@RequestParam("param") final String param) { - ResultBean resultBean = new ResultBean(); - resultBean.setCode(200); - resultBean.setData(param); - return resultBean; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java deleted file mode 100644 index 7bfab2d..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * OauthController. - */ -@RestController -@RequestMapping("/oauth") -@ShenyuSpringMvcClient("/oauth") -@ApiModule(value = "oauth") -public class OauthController { - - /** - * Test oauth2 code request. - * - * @return String - */ - @GetMapping("/authorize") - @ApiDoc(desc = "authorize") - public String testCode() { - return "authorize"; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java deleted file mode 100644 index f7b6434..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.examples.http.dto.OAuth2DTO; -import org.apache.shenyu.examples.http.dto.OrderDTO; -import org.springframework.http.HttpHeaders; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.Objects; - -/** - * TestController. - */ -@RestController -@RequestMapping("/order") -@ShenyuSpringMvcClient("/order") -@ApiModule(value = "order") -public class OrderController { - - /** - * Save order dto. - * - * @param orderDTO the order dto - * @return the order dto - */ - @PostMapping("/save") - @ShenyuSpringMvcClient("/save") - @ApiDoc(desc = "save") - public OrderDTO save(@RequestBody final OrderDTO orderDTO) { - orderDTO.setName("hello world save order"); - return orderDTO; - } - - /** - * Find by id order dto. - * - * @param id the id - * @return the order dto - */ - @GetMapping("/findById") - @ShenyuSpringMvcClient("/findById") - @ApiDoc(desc = "findById") - public OrderDTO findById(@RequestParam("id") final String id) { - return build(id, "hello world findById"); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @GetMapping("/path/{id}/{name}") - @ShenyuSpringMvcClient("/path/**") - @ApiDoc(desc = "path/**") - public OrderDTO getPathVariable(@PathVariable("id") final String id, @PathVariable("name") final String name) { - return build(id, "hello world restful: " + name); - } - - /** - * Test restful order dto. - * - * @param id the id - * @return the order dto - */ - @GetMapping("/path/{id}/name") - @ShenyuSpringMvcClient("/path/**/name") - @ApiDoc(desc = "path/**/name") - public OrderDTO testRestFul(@PathVariable("id") final String id) { - return build(id, "hello world restful inline " + id); - } - - /** - * Test oauth2 request. - * @param request request with the oauth2 headers - * @return the oauth2 dto - */ - @GetMapping("/oauth2/test") - @ShenyuSpringMvcClient("/oauth2/test") - @ApiDoc(desc = "oauth2/test") - public OAuth2DTO testRestFul(final ServerHttpRequest request) { - HttpHeaders headers = request.getHeaders(); - List tokens = headers.get("Authorization"); - OAuth2DTO oAuth2DTO = new OAuth2DTO(); - oAuth2DTO.setToken(Objects.isNull(tokens) ? "no authorization" : tokens.get(0)); - return oAuth2DTO; - } - - /** - * Test blank uri order dto. - * - * @return the order dto - */ - @GetMapping("/ /uri/test") - @ShenyuSpringMvcClient("/ /uri/test") - @ApiDoc(desc = "test") - public OrderDTO testWhiteSpaceWithUri() { - return build("1", "hello world testBlankUri"); - } - - private OrderDTO build(final String id, final String name) { - OrderDTO orderDTO = new OrderDTO(); - orderDTO.setId(id); - orderDTO.setName(name); - return orderDTO; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java deleted file mode 100644 index a56fa4e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -/** - * RequestController. - */ -@RestController -@RequestMapping("/request") -@ShenyuSpringMvcClient("/request/**") -public class RequestController { - - private static final Logger LOGGER = LoggerFactory.getLogger(RequestController.class); - - /** - * Test for header annotation. - * @param headerKey1 one RequestHeader key - * @param serverHttpRequest request - * @return response - */ - @GetMapping(path = "/header") - public Mono testRequestHeader(@RequestHeader("header_key1") final String headerKey1, - final ServerHttpRequest serverHttpRequest) { - LOGGER.info("header_key1:{}, receive headers: {}", headerKey1, serverHttpRequest.getHeaders()); - return successMono(serverHttpRequest.getHeaders()); - } - - /** - * Test for param annotation. - * @param parameterKey1 one RequestParam key - * @param serverHttpRequest request - * @return response - */ - @PostMapping(path = "/parameter") - public Mono testRequestParameter(@RequestParam("parameter_key1") final String parameterKey1, - final ServerHttpRequest serverHttpRequest) { - LOGGER.info("parameter_key1: {}, receive param: {}", parameterKey1, serverHttpRequest.getQueryParams()); - return successMono(serverHttpRequest.getQueryParams()); - } - - /** - * Test for cookie annotation. - * @param userId a cookie key with the name userId - * @param serverHttpRequest request - * @return response - */ - @GetMapping(path = "/cookie") - public Mono testRequestCookie(@CookieValue("userId") final String userId, - final ServerHttpRequest serverHttpRequest) { - LOGGER.info("userId:{}, receive Cookies: {}", userId, serverHttpRequest.getCookies()); - return successMono(serverHttpRequest.getCookies()); - } - - private Mono successMono(final Object body) { - return Mono.just("response success: " + body); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java deleted file mode 100644 index 69d2479..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * ShenyuClientPathController. - */ -@RestController -@ApiModule(value = "shenyuClientPathController") -public class ShenyuClientPathController { - - private static final Logger LOG = LoggerFactory.getLogger(ShenyuClientPathController.class); - - private static final String HELLO_SUFFIX = "I'm Shenyu-Gateway System. Welcome!"; - - /** - * hello. - * - * @return result - */ - @RequestMapping("shenyu/client/hello") - @ShenyuSpringMvcClient("shenyu/client/hello") - @ApiDoc(desc = "shenyu/client/hello") - public String hello() { - return "hello! " + HELLO_SUFFIX; - } - - /** - * hello. br - * no support gateway. - * - * @param name say hello user name - * @return result - */ - @RequestMapping("shenyu/client/hi") - @ShenyuSpringMvcClient("shenyu/client/hi") - @ApiDoc(desc = "shenyu/client/hi") - public String hello(final String name) { - return "hi! " + name + "! " + HELLO_SUFFIX; - } - - /** - * timeout. - * - * @return result - */ - @RequestMapping("shenyu/client/timeout") - @ShenyuSpringMvcClient("shenyu/client/timeout") - @ApiDoc(desc = "shenyu/client/timeout") - public String timeout() { - LOG.info("timeout"); - try { - Thread.sleep(10000); - } catch (InterruptedException ignored) { - } - return "hello! " + HELLO_SUFFIX; - } - - /** - * hi. - * - * @param name name - * @return result - */ - @PostMapping("shenyu/client/post/hi") - @ShenyuSpringMvcClient(desc = "shenyu client annotation register") - @ApiDoc(desc = "shenyu/client/post/hi") - public String post(final String name) { - return "[post method result]:hi! " + name + "! " + HELLO_SUFFIX; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java deleted file mode 100644 index e335eb4..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * SpringMvcMappingPathController. - */ -@RestController -@ShenyuSpringMvcClient(desc = "spring annotation register") -@ApiModule(value = "springMvcMappingPathController") -public class SpringMvcMappingPathController { - - private static final String HELLO_SUFFIX = "I'm Shenyu-Gateway System. Welcome!"; - - /** - * hello. - * - * @return result - */ - @RequestMapping("hello") - @ApiDoc(desc = "hello") - public String hello() { - return "hello! " + HELLO_SUFFIX; - } - - /** - * hi. - * - * @param name name - * @return result - */ - @RequestMapping("hi") - @ApiDoc(desc = "hi") - public String hello(final String name) { - return "hi! " + name + "! " + HELLO_SUFFIX; - } - - /** - * hi. - * - * @param name name - * @return result - */ - @PostMapping("post/hi") - @ApiDoc(desc = "post/hi") - public String post(final String name) { - return "[post method result]:hi! " + name + "! " + HELLO_SUFFIX; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java deleted file mode 100644 index d57f12a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.http.MediaType; -import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.stream.Collectors; - -/** - * UploadController. - */ -@RestController -@RequestMapping("/upload") -@ShenyuSpringMvcClient("/upload/**") -@ApiModule(value = "upload") -public class UploadController { - - /** - * webFlux uploadFile. - * @param file the file you upload - * @return response - */ - @PostMapping(value = "/webFluxSingle", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.TEXT_PLAIN_VALUE}) - @ApiDoc(desc = "webFluxSingle") - public Mono webFluxSingle(@RequestPart("file") final FilePart file) { - return Mono.just(file.filename()); - } - - /** - * webFlux uploadFiles. - * @param files the file you upload - * @return response - */ - @PostMapping(value = "/webFluxFiles", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.TEXT_PLAIN_VALUE}) - @ApiDoc(desc = "webFluxFiles") - public Mono webFluxFiles(@RequestPart(value = "files", required = false) final Flux files) { - return files.map(FilePart::filename).collect(Collectors.joining(",")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/BigObject.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/BigObject.java deleted file mode 100644 index 21ac2ee..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/BigObject.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -/** - * big object. - */ -public class BigObject { - - private String[] obj; - - private Integer id; - - /** - * get id. - * @return id - */ - public Integer getId() { - return id; - } - - /** - * set id. - * @param id id - */ - public void setId(final Integer id) { - this.id = id; - } - - - /** - * get obj. - * - * @return String[] - */ - public String[] getObj() { - return obj; - } - - /** - * set obj. - * - * @param obj obj - */ - public void setObj(final String[] obj) { - this.obj = obj; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java deleted file mode 100644 index f617185..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -public class OAuth2DTO { - - private String token; - - /** - * Get token. - * - * @return token - */ - public String getToken() { - return token; - } - - /** - * Set token. - * - * @param token token - */ - public void setToken(final String token) { - this.token = token; - } - - @Override - public String toString() { - return "OAuth2DTO{" + "token='" + token + '\'' + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java deleted file mode 100644 index bc4b28b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -import java.io.Serializable; -import java.util.StringJoiner; - -/** - * The type Order dto. - */ -public class OrderDTO implements Serializable { - - private String id; - - private String name; - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - @Override - public String toString() { - return new StringJoiner(", ", OrderDTO.class.getSimpleName() + "[", "]") - .add("id='" + id + "'") - .add("name='" + name + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java deleted file mode 100644 index f33dc94..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -import java.util.StringJoiner; - -/** - * The type Request dto. - */ -public class RequestDTO { - - private String module; - - private String method; - - private String content; - - private String extInfo; - - public RequestDTO() { - } - - public RequestDTO(final String module, final String method, final String content, final String extInfo) { - this.module = module; - this.method = method; - this.content = content; - this.extInfo = extInfo; - } - - /** - * Get module. - * - * @return module - */ - public String getModule() { - return module; - } - - /** - * Set module. - * - * @param module module - */ - public void setModule(final String module) { - this.module = module; - } - - /** - * Get method. - * - * @return method - */ - public String getMethod() { - return method; - } - - /** - * Set method. - * - * @param method method - */ - public void setMethod(final String method) { - this.method = method; - } - - /** - * Get content. - * - * @return content - */ - public String getContent() { - return content; - } - - /** - * Set content. - * - * @param content content - */ - public void setContent(final String content) { - this.content = content; - } - - /** - * Get extInfo. - * - * @return extInfo - */ - public String getExtInfo() { - return extInfo; - } - - /** - * Set extInfo. - * - * @param extInfo extInfo - */ - public void setExtInfo(final String extInfo) { - this.extInfo = extInfo; - } - - @Override - public String toString() { - return new StringJoiner(", ", RequestDTO.class.getSimpleName() + "[", "]") - .add("module='" + module + "'") - .add("method='" + method + "'") - .add("content='" + content + "'") - .add("extInfo='" + extInfo + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java deleted file mode 100644 index 8f14fd5..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.dto; - -import java.util.StringJoiner; - -/** - * The type User dto. - */ -public class UserDTO { - - private String userId; - - private String userName; - - /** - * Get userId. - * - * @return userId - */ - public String getUserId() { - return userId; - } - - /** - * Set userId. - * - * @param userId userId - */ - public void setUserId(final String userId) { - this.userId = userId; - } - - /** - * Get userName. - * - * @return userName - */ - public String getUserName() { - return userName; - } - - /** - * Set userName. - * - * @param userName userName - */ - public void setUserName(final String userName) { - this.userName = userName; - } - - @Override - public String toString() { - return new StringJoiner(", ", UserDTO.class.getSimpleName() + "[", "]") - .add("userId='" + userId + "'") - .add("userName='" + userName + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java deleted file mode 100644 index 4814ab5..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.result; - -/** - * ResultBean. - */ -public class ResultBean { - - private Integer code; - - private String msg; - - private Object data; - - public ResultBean() { - } - - public ResultBean(final Integer code, final String msg, final Object data) { - this.code = code; - this.msg = msg; - this.data = data; - } - - /** - * Get code. - * - * @return code - */ - public Integer getCode() { - return code; - } - - /** - * Set code. - * - * @param code code - */ - public void setCode(final Integer code) { - this.code = code; - } - - /** - * Get msg. - * - * @return msg - */ - public String getMsg() { - return msg; - } - - /** - * Set msg. - * - * @param msg msg - */ - public void setMsg(final String msg) { - this.msg = msg; - } - - /** - * Get data. - * - * @return data - */ - public Object getData() { - return data; - } - - /** - * Set data. - * - * @param data data - */ - public void setData(final Object data) { - this.data = data; - } - - @Override - public String toString() { - return "ResultBean{" + "code=" + code + ", msg='" + msg + '\'' + ", data=" + data + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java b/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java deleted file mode 100644 index 42fadc2..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.http.router; - -import org.apache.shenyu.examples.http.result.ResultBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; -import reactor.core.publisher.Mono; - -import java.util.concurrent.atomic.AtomicInteger; - -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RequestPredicates.path; -import static org.springframework.web.reactive.function.server.RouterFunctions.nest; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -/** - * The type shenyu test http router. - */ -@Component -public class ShenyuTestHttpRouter { - - private static final Logger LOG = LoggerFactory.getLogger(ShenyuTestHttpRouter.class); - - private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger(1); - - /** - * Routes router function. - * - * @return the router function - */ - public RouterFunction routes() { - return nest(path("/test"), - route(POST("/helloWorld2") - .and(accept(APPLICATION_JSON)), this::postHandler) - .and(route(GET("/rewrite"), this::rewriteHandler)) - .and(route(GET("/pdm"), this::pdmHttpGet)) - .and(route(GET("/oms"), this::omsHttpGet)) - .and(route(GET("/timeout"), this::testRetry))); - } - - @NonNull - private Mono testRetry(final ServerRequest req) { - int i = ATOMIC_INTEGER.incrementAndGet(); - LOG.info("Retry count: " + i); - ResultBean resultBean = new ResultBean(1, "msg", "this is retry hello world"); - return ok().body(Mono.just(resultBean), ResultBean.class); - } - - @NonNull - private Mono pdmHttpGet(final ServerRequest req) { - ResultBean resultBean = new ResultBean(1, "msg", "this is pdm get hello world"); - return ok().body(Mono.just(resultBean), ResultBean.class); - } - - @NonNull - private Mono omsHttpGet(final ServerRequest req) { - ResultBean resultBean = new ResultBean(1, "msg", "this is oms get hello world"); - return ok().body(Mono.just(resultBean), ResultBean.class); - } - - @NonNull - private Mono rewriteHandler(final ServerRequest req) { - ResultBean resultBean = new ResultBean(1, "msg", "this is rewrite hello world"); - return ok().body(Mono.just(resultBean), ResultBean.class); - } - - @NonNull - private Mono postHandler(final ServerRequest req) { - final Mono string = req.bodyToMono(String.class); - return ok().body(string, String.class); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-http/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-http/src/main/resources/application.yml deleted file mode 100644 index 1ebaab4..0000000 --- a/shenyu-java-examples/shenyu-java-examples-http/src/main/resources/application.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8189 - address: 0.0.0.0 - tomcat: - max-http-form-post-size: 100MB - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - http: - props: - contextPath: /http - appName: http - # port: 8189 -# discovery: -# enable: true -# protocol: http:// # https:// -# type: zookeeper -# serverList: 127.0.0.1:2181 -# registerPath: /shenyu/discovery/http_example -# props: -# baseSleepTimeMilliseconds: 1000 -# maxRetries: 4 -# maxSleepTimeMilliseconds: 5000 -# connectionTimeoutMilliseconds: 60000 -# sessionTimeoutMilliseconds: 8 -# type: etcd -# serverList: http://127.0.0.1:2379 -# registerPath: shenyu_discovery_http_example -# type: eureka -# serverList: http://127.0.0.1:8761/eureka -# registerPath: shenyu_discovery_http_example -spring: - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - -logging: - level: - root: info - org.springframework.boot: info - org.apache.ibatis: info - org.apache.shenyu.test.bonuspoint: info - org.apache.shenyu.test.lottery: debug - org.apache.shenyu.test: debug - diff --git a/shenyu-java-examples/shenyu-java-examples-https/Dockerfile b/shenyu-java-examples/shenyu-java-examples-https/Dockerfile deleted file mode 100644 index eec4c68..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-examples-https -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} - -EXPOSE 8080 -EXPOSE 8190 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-https/pom.xml b/shenyu-java-examples/shenyu-java-examples-https/pom.xml deleted file mode 100644 index c8b8ec5..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/pom.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-https - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-springmvc - ${project.version} - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-logging - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - shenyu-java-examples-https - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.https.ShenyuTestHttpsApplication - true - - - - - - - - example - - shenyu-examples-https - shenyu-examples-https - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-examples-https - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/http/https-test-api-local.http b/shenyu-java-examples/shenyu-java-examples-https/src/main/http/https-test-api-local.http deleted file mode 100644 index 30660f4..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/src/main/http/https-test-api-local.http +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -# Use gateway proxy -# if you used IDEA, start example project. click green button.Quick access! - -### shengyu https example -GET https://localhost:8190/order/findById?id=3 -Accept: application/json -Content-Type: application/json - - -### shengyu https upload file example -POST https://localhost:8190/upload/file -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt"; -Content-Type: multipart/form-data - -< ../../../../shenyu-examples-common/src/main/resources/1.txt ---WebAppBoundary-- diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/http/https-test-api.http b/shenyu-java-examples/shenyu-java-examples-https/src/main/http/https-test-api.http deleted file mode 100644 index 10750c8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/src/main/http/https-test-api.http +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -# Use gateway proxy -# if you used IDEA, start example project. click green button.Quick access! - -### shengyu https example -GET http://localhost:9195/order/order/findById?id=3 -Accept: application/json -Content-Type: application/json - - -### shengyu https upload file example -POST http://localhost:9195/order/upload/file -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt"; -Content-Type: multipart/form-data - -< ../../../../shenyu-examples-common/src/main/resources/1.txt ---WebAppBoundary-- diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/ShenyuTestHttpsApplication.java b/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/ShenyuTestHttpsApplication.java deleted file mode 100644 index 761f5a3..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/ShenyuTestHttpsApplication.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.https; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * ShenyuTestHttpsApplication. - */ -@SpringBootApplication -public class ShenyuTestHttpsApplication { - - /** - * main. - * - * @param args args - */ - public static void main(final String[] args) { - SpringApplication.run(ShenyuTestHttpsApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/configuration/HttpsConfiguration.java b/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/configuration/HttpsConfiguration.java deleted file mode 100644 index ca4af33..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/configuration/HttpsConfiguration.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.https.configuration; - -import org.apache.catalina.Context; -import org.apache.catalina.connector.Connector; -import org.apache.tomcat.util.descriptor.web.SecurityCollection; -import org.apache.tomcat.util.descriptor.web.SecurityConstraint; -import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - - -/** - * The type Https configuration. - */ -@Configuration -public class HttpsConfiguration { - - /** - * Servlet container configurable servlet web server factory. - * - * @return the configurable servlet web server factory - */ - @Bean - public ConfigurableServletWebServerFactory servletContainer() { - TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory() { - @Override - protected void postProcessContext(final Context context) { - SecurityConstraint securityConstraint = new SecurityConstraint(); - securityConstraint.setUserConstraint("CONFIDENTIAL"); - SecurityCollection collection = new SecurityCollection(); - collection.addPattern("/*"); - securityConstraint.addCollection(collection); - context.addConstraint(securityConstraint); - } - }; - factory.addAdditionalTomcatConnectors(getHttpConnector()); - return factory; - } - - private Connector getHttpConnector() { - Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); - connector.setScheme("http"); - connector.setPort(8080); - connector.setSecure(false); - connector.setRedirectPort(8190); - return connector; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/controller/OrderController.java b/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/controller/OrderController.java deleted file mode 100644 index 807c0aa..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/controller/OrderController.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.https.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.examples.https.dto.OrderDTO; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * TestController. - */ -@RestController -@RequestMapping("/order") -@ShenyuSpringMvcClient("/order") -@ApiModule(value = "order") -public class OrderController { - - /** - * Find by id order dto. - * - * @param id the id - * @return the order dto - */ - @GetMapping("/findById") - @ShenyuSpringMvcClient("/findById") - @ApiDoc(desc = "findById") - public OrderDTO findById(@RequestParam("id") final String id) { - OrderDTO dto = new OrderDTO(); - dto.setId(id); - return dto; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/controller/UploadController.java b/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/controller/UploadController.java deleted file mode 100644 index dd4a8c0..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/controller/UploadController.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.https.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * UploadController. - */ -@RestController -@RequestMapping("/upload") -@ShenyuSpringMvcClient("/upload/**") -@ApiModule(value = "upload") -public class UploadController { - - /** - * upload file. - * - * @param file file - * @return filename - */ - @PostMapping(value = "/file", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) - @ShenyuSpringMvcClient("/file") - @ApiDoc(desc = "file") - public String uploadFile(@RequestPart("file") final MultipartFile file) { - return file.getOriginalFilename(); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/dto/OrderDTO.java b/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/dto/OrderDTO.java deleted file mode 100644 index 7b735f0..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/src/main/java/org/apache/shenyu/examples/https/dto/OrderDTO.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.https.dto; - -import java.io.Serializable; -import java.util.StringJoiner; - -/** - * The type Order dto. - */ -public class OrderDTO implements Serializable { - - private String id; - - private String name; - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - @Override - public String toString() { - return new StringJoiner(", ", OrderDTO.class.getSimpleName() + "[", "]") - .add("id='" + id + "'") - .add("name='" + name + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-https/src/main/resources/application.yml deleted file mode 100644 index 2d5b69e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-https/src/main/resources/application.yml +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8190 - address: 0.0.0.0 - ssl: - key-store: classpath:keystore.p12 - key-password: 123456 - key-store-password: 123456 - key-alias: shenyu - key-store-type: PKCS12 - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - http: - props: - contextPath: /order - protocol: https:// - appName: order - port: 8190 - -logging: - level: - root: info - org.springframework.boot: info - org.apache.ibatis: info - org.apache.shenyu.examples.bonuspoint: info - org.apache.shenyu.examples.lottery: debug - org.apache.shenyu.examples: debug - diff --git a/shenyu-java-examples/shenyu-java-examples-https/src/main/resources/keystore.p12 b/shenyu-java-examples/shenyu-java-examples-https/src/main/resources/keystore.p12 deleted file mode 100644 index a9a3b08..0000000 Binary files a/shenyu-java-examples/shenyu-java-examples-https/src/main/resources/keystore.p12 and /dev/null differ diff --git a/shenyu-java-examples/shenyu-java-examples-motan/pom.xml b/shenyu-java-examples/shenyu-java-examples-motan/pom.xml deleted file mode 100644 index 726e91e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - - shenyu-java-examples-motan - pom - - shenyu-java-examples-motan-service - shenyu-java-examples-motan-api - - - diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/pom.xml b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/pom.xml deleted file mode 100644 index 121faea..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/pom.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples-motan - 2.7.1-SNAPSHOT - - 4.0.0 - - shenyu-java-examples-motan-api - - - 1.2.1 - - - - - com.weibo - motan-core - ${motan.version} - - - - com.weibo - motan-transport-netty4 - ${motan.version} - - - - com.weibo - motan-springsupport - ${motan.version} - - - - com.weibo - motan-registry-zookeeper - ${motan.version} - - - - - shenyu-java-examples-motan-api - - - org.codehaus.mojo - build-helper-maven-plugin - 1.10 - - - generate-sources - - add-source - - - - ${project.build.directory}/generated-sources/annotations - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.7.0 - - ${java.version} - ${java.version} - ${project.build.sourceEncoding} - -proc:none - - - - process-annotations - generate-sources - - compile - - - true - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanClassDemoService.java b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanClassDemoService.java deleted file mode 100644 index c7a378a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanClassDemoService.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.motan.service; - -import com.weibo.api.motan.transport.async.MotanAsync; - -import java.util.List; - -/** - * Motan class demo interface. - */ -@MotanAsync -public interface MotanClassDemoService { - - /** - * hello demo for Motan. - * @param name the name to hello - * @return response - */ - String hello(String name); - - /** - * timeout for Motan. - * @param seconds seconds to timeout - * @return response - */ - String testTimeOut(long seconds); - - /** - * pojo as a parameter for test generalized call. - * @param motanTest pojo - * @return the motanTest - */ - MotanTest save(MotanTest motanTest); - - /** - * List pojo as a parameter for test generalized call. - * Unfortunately, motan doesn't support this right now. - * @param motanTestList pojo list - * @return the motanTest - */ - MotanTest batchSave(List motanTestList); -} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanDemoService.java b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanDemoService.java deleted file mode 100644 index 05e7021..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanDemoService.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.motan.service; - -import com.weibo.api.motan.transport.async.MotanAsync; - -/** - * Motan demo interface. - */ -@MotanAsync -public interface MotanDemoService { - - /** - * hi demo for Motan. - * @return response - */ - String hi(); - - /** - * hello demo for Motan. - * @param name the name to hello - * @return response - */ - String hello(String name); - - /** - * timeout for Motan. - * @param seconds seconds to timeout - * @return response - */ - String testTimeOut(long seconds); -} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanTest.java b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanTest.java deleted file mode 100644 index 9bd3484..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-api/src/main/java/org/apache/shenyu/examples/motan/service/MotanTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.motan.service; - -import java.io.Serializable; -import java.util.StringJoiner; - -/** - * MotanTest. - */ -public class MotanTest implements Serializable { - - private String id; - - private String name; - - public MotanTest() { - } - - public MotanTest(final String id, final String name) { - this.id = id; - this.name = name; - } - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - @Override - public String toString() { - return new StringJoiner(", ", MotanTest.class.getSimpleName() + "[", "]") - .add("id='" + id + "'") - .add("name='" + name + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/Dockerfile b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/Dockerfile deleted file mode 100644 index 0bac119..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-examples-motan -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8081 -EXPOSE 8002 - -CMD java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.net.util=ALL-UNNAMED -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/ingress.yml b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/ingress.yml deleted file mode 100644 index 3a7e4ac..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/ingress.yml +++ /dev/null @@ -1,89 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: v1 -kind: Service -metadata: - name: motan-demo-hello - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-motan-enabled: 'true' - shenyu.apache.org/plugin-motan-app-name: motan - shenyu.apache.org/plugin-motan-path: /demo/hello - shenyu.apache.org/plugin-motan-rpc-type: motan - shenyu.apache.org/plugin-motan-service-name: org.apache.shenyu.examples.motan.service.MotanDemoService - shenyu.apache.org/plugin-motan-method-name: hello - shenyu.apache.org/plugin-motan-params-type: java.lang.String - shenyu.apache.org/plugin-motan-rpc-expand: | - {"methodInfo":[{"methodName":"hello","params":[{"left":"java.lang.String","right":"name"}]}],"group":"motan-shenyu-rpc","timeout":2000,"rpcProtocol":"motan2"} - shenyu.apache.org/zookeeper-register-address: shenyu-zk:2181 -spec: - selector: - app: shenyu-java-examples-motan-service - ports: - - port: 8081 # Assuming this is the motan service port - ---- - -apiVersion: v1 -kind: Service -metadata: - name: motan-demo-test-hello - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-motan-enabled: 'true' - shenyu.apache.org/plugin-motan-app-name: motan - shenyu.apache.org/plugin-motan-path: /demoTest/hello - shenyu.apache.org/plugin-motan-rpc-type: motan - shenyu.apache.org/plugin-motan-service-name: org.apache.shenyu.examples.motan.service.MotanDemoService - shenyu.apache.org/plugin-motan-method-name: hello - shenyu.apache.org/plugin-motan-params-type: java.lang.String - shenyu.apache.org/zookeeper-register-address: shenyu-zk:2181 - shenyu.apache.org/plugin-motan-rpc-expand: | - {"methodInfo":[{"methodName":"hello","params":[{"left":"java.lang.String","right":"name"}]}],"group":"motan-shenyu-rpc","timeout":2000,"rpcProtocol":"motan2"} -spec: - selector: - app: shenyu-java-examples-motan-service - ports: - - port: 8081 # Assuming this is the motan service port - ---- - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - namespace: shenyu-ingress - labels: - shenyu.apache.org/metadata-labels-1: motan-demo-hello - shenyu.apache.org/metadata-labels-2: motan-demo-test-hello - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-motan-enabled: 'true' - shenyu.apache.org/zookeeper-register-address: shenyu-zk:2181 - name: demo-ingress -spec: - rules: - - http: - paths: - - backend: - service: - name: shenyu-java-examples-motan-service - port: - number: 8081 - path: /** - pathType: ImplementationSpecific diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/shenyu-examples-motan.yml b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/shenyu-examples-motan.yml deleted file mode 100644 index 2efb850..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/shenyu-examples-motan.yml +++ /dev/null @@ -1,88 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-examples-motan-deployment - namespace: shenyu-ingress - labels: - app: shenyu-examples-motan - all: shenyu-examples-motan -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-examples-motan - all: shenyu-examples-motan - strategy: {} - template: - metadata: - namespace: shenyu-ingress - labels: - app: shenyu-examples-motan - all: shenyu-examples-motan - spec: - containers: - - image: shenyu-examples-motan - name: shenyu-examples-motan - livenessProbe: - exec: - command: - - /bin/sh - - "-c" - - wget -q -O - http://localhost:8081/actuator/health | grep UP || exit 1 - initialDelaySeconds: 10 - failureThreshold: 3 - timeoutSeconds: 2 - env: - - name: shenyu.register.serverLists - value: http://shenyu-admin:9095 - - name: motan.registry.protocol - value: zookeeper - - name: motan.registry.address - value: shenyu-zk:2181 - ports: - - containerPort: 8081 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-examples-motan-service - namespace: shenyu-ingress - labels: - app: shenyu-examples-motan - all: shenyu-examples-motan -spec: - selector: - app: shenyu-examples-motan - all: shenyu-examples-motan - type: NodePort - ports: - - name: "8081" - port: 8081 - targetPort: 8081 - nodePort: 31193 - - name: "8082" - port: 8082 - targetPort: 8082 - nodePort: 31191 -status: - loadBalancer: {} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/shenyu-zookeeper.yml b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/shenyu-zookeeper.yml deleted file mode 100644 index 6baac49..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/k8s/shenyu-zookeeper.yml +++ /dev/null @@ -1,81 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-motan - name: shenyu-zk -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-zk - all: shenyu-examples-motan - strategy: {} - template: - metadata: - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-motan - spec: - containers: - - image: zookeeper:3.5.5 - name: shenyu-zk - resources: {} - ports: - - containerPort: 2181 - name: client - - containerPort: 2888 - name: server - - containerPort: 3888 - name: leader-election - - containerPort: 8080 - name: website - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-zk - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-motan -spec: - type: NodePort - selector: - app: shenyu-zk - all: shenyu-examples-motan - ports: - - name: "client" - port: 2181 - targetPort: 2181 - - name: "server" - port: 2888 - targetPort: 2888 - - name: "election" - port: 3888 - targetPort: 3888 - - name: "website" - port: 8080 - targetPort: 8080 diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/pom.xml b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/pom.xml deleted file mode 100644 index f74f399..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/pom.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples-motan - 2.7.1-SNAPSHOT - - 4.0.0 - - shenyu-java-examples-motan-service - - - 3.7.2 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - org.springframework - spring-context - - - org.apache.shenyu - shenyu-java-examples-motan-api - ${project.version} - - - zookeeper - org.apache.zookeeper - - - - - zookeeper - org.apache.zookeeper - ${zookeeper.version} - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-motan - ${project.version} - - - - - shenyu-java-examples-motan - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.motan.service.TestMotanApplication - true - - - - - - - - example - - shenyu-java-examples-motan - shenyu-java-examples-motan - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-java-examples-motan - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/http/motan-class-test-api.http b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/http/motan-class-test-api.http deleted file mode 100644 index 6d88480..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/http/motan-class-test-api.http +++ /dev/null @@ -1,49 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - -### shengyu getway proxy hello -GET http://localhost:9195/motan/demoTest/hello -Accept: application/json -Content-Type: application/json - -{ - "name": "order" -} - -### shengyu getway proxy timeout -GET http://localhost:9195/motan/demoTest/testTimeOut -Accept: application/json -Content-Type: application/json - -{ - "timeout": "1" -} - - -### shengyu getway proxy save -POST http://localhost:9195/motan/demoTest/save -Accept: application/json -Content-Type: application/json - -{ - "motanTest": - { - "id": "999", - "name": "dinglang" - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/http/motan-test-api.http b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/http/motan-test-api.http deleted file mode 100644 index 5fc8565..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/http/motan-test-api.http +++ /dev/null @@ -1,35 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - -### shengyu getway proxy hello -GET http://localhost:9195/motan/demo/hello -Accept: application/json -Content-Type: application/json - -{ - "name": "order" -} - -### shengyu getway proxy timeout -GET http://localhost:9195/motan/demo/testTimeOut -Accept: application/json -Content-Type: application/json - -{ - "timeout": "1" -} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/TestMotanApplication.java b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/TestMotanApplication.java deleted file mode 100644 index c1b6ecd..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/TestMotanApplication.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.motan.service; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Motan service starter. - */ -@SpringBootApplication -public class TestMotanApplication { - - /** - * Main Entrance. - * - * @param args startup arguments - */ - public static void main(final String[] args) { - SpringApplication.run(TestMotanApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanClassDemoServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanClassDemoServiceImpl.java deleted file mode 100644 index 51a28d5..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanClassDemoServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.motan.service.impl; - -import org.apache.shenyu.client.motan.common.annotation.ShenyuMotanService; -import org.apache.shenyu.examples.motan.service.MotanClassDemoService; -import org.apache.shenyu.examples.motan.service.MotanTest; -import org.apache.shenyu.springboot.starter.client.motan.ShenyuMotanClientConfiguration; -import org.springframework.lang.NonNull; - -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * Motan Class demo service. - * - *

Default motan service name is "motan2", If you want to inject other services, - * please refer to {@link ShenyuMotanClientConfiguration} - */ -@ShenyuMotanService(value = "/demoTest/**", export = "motan2:8002") -public class MotanClassDemoServiceImpl implements MotanClassDemoService { - - @Override - public String hello(final String name) { - return "hello " + name; - } - - @Override - public String testTimeOut(final long seconds) { - try { - Thread.sleep(seconds * 1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - return "hello seconds " + seconds + "s"; - } - - @Override - public MotanTest save(final MotanTest motanTest) { - return motanTest; - } - - @Override - public MotanTest batchSave(final List motanTestList) { - return new MotanTest(join(motanTestList, MotanTest::getId), "hello world shenyu motan param batchSave :" + join(motanTestList, MotanTest::getName)); - } - - private String join(final @NonNull List list, final Function mapper) { - return list.stream() - .map(mapper) - .collect(Collectors.joining("-")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanDemoServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanDemoServiceImpl.java deleted file mode 100644 index 6cd3bbe..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/java/org/apache/shenyu/examples/motan/service/impl/MotanDemoServiceImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.motan.service.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.motan.common.annotation.ShenyuMotanClient; -import org.apache.shenyu.client.motan.common.annotation.ShenyuMotanService; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.motan.service.MotanDemoService; -import org.apache.shenyu.springboot.starter.client.motan.ShenyuMotanClientConfiguration; - -/** - * Motan demo service. - * - *

Default motan service name is "motan2", If you want to inject other services, - * please refer to {@link ShenyuMotanClientConfiguration} - */ -@ShenyuMotanService(value = "/demo", export = "motan2:8002") -@ApiModule("MotanDemoService") -public class MotanDemoServiceImpl implements MotanDemoService { - - @Override - @ShenyuMotanClient(value = "/hi") - @Log - @ApiDoc(desc = "hi") - public String hi() { - return "{\"say\":\"hi\"}"; - } - - @Override - @ShenyuMotanClient(value = "/hello") - @Log - @ApiDoc(desc = "hello") - public String hello(final String name) { - return "hello " + name; - } - - @Override - @ShenyuMotanClient(value = "/timeout") - @ApiDoc(desc = "timeout") - public String testTimeOut(final long seconds) { - try { - Thread.sleep(seconds * 1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - return "hello seconds " + seconds + "s"; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/resources/application.yml deleted file mode 100644 index ca65d49..0000000 --- a/shenyu-java-examples/shenyu-java-examples-motan/shenyu-java-examples-motan-service/src/main/resources/application.yml +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8081 - servlet: - context-path: / - address: 0.0.0.0 - -spring: - application: - name: motan-exmaples - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - motan: - props: - contextPath: /motan - ipAndPort: motan - appName: motan - port: 8081 - package-path: org.apache.shenyu.examples.motan.service - basicServiceConfig: - exportPort: 8002 - protocol: - name: motan2 -motan: - registry: - protocol: zk - address: 127.0.0.1:2181 - -logging: - level: - root: info - org.apache.shenyu: debug diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/README.md b/shenyu-java-examples/shenyu-java-examples-sofa/README.md deleted file mode 100644 index 080d096..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Shenyu example Sofa -*** -## Run -You can run server with http/zookeeper/etcd register center - -### run with etcd register center -#### Shenyu-Admin config -add etcd register center dependency in shenyu-admin: - -```xml - - org.apache.shenyu - shenyu-register-server-etcd - ${project.version} - -``` - -set etcd register config in shenyu-admin: - -```yaml -shenyu: - register: - registerType: etcd - serverLists : http://localhost:2379 -``` - -#### shenyu-java-examples-sofa-service config -set etcd register config: - -```yaml -shenyu: - client: - registerType: etcd #http #zookeeper #etcd - serverLists: http://localhost:2379 #http://localhost:9095 #localhost:2181 #http://localhost:2379 - props: - contextPath: /sofa - appName: sofa - port: 8888 -``` - -run TestSofaApplication diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/pom.xml b/shenyu-java-examples/shenyu-java-examples-sofa/pom.xml deleted file mode 100644 index 2b36da2..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-sofa - pom - - - shenyu-java-examples-sofa-api - shenyu-java-examples-sofa-service - - - - - - org.apache.shenyu - shenyu-java-examples-sofa-api - ${project.version} - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/pom.xml b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/pom.xml deleted file mode 100644 index eaa9d30..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples-sofa - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-sofa-api - - - shenyu-java-examples-sofa-api - - diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/entity/SofaComplexTypeBean.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/entity/SofaComplexTypeBean.java deleted file mode 100644 index 3d986a9..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/entity/SofaComplexTypeBean.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.api.entity; - -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; - -/** - * Sofa complex type bean. - */ -public class SofaComplexTypeBean { - - private SofaSimpleTypeBean sofaSimpleTypeBean; - - private List idLists; - - private Map idMaps; - - public SofaComplexTypeBean() { - } - - public SofaComplexTypeBean(final SofaSimpleTypeBean sofaSimpleTypeBean, final List idLists, final Map idMaps) { - this.sofaSimpleTypeBean = sofaSimpleTypeBean; - this.idLists = idLists; - this.idMaps = idMaps; - } - - /** - * Get sofaSimpleTypeBean. - * - * @return sofaSimpleTypeBean - */ - public SofaSimpleTypeBean getSofaSimpleTypeBean() { - return sofaSimpleTypeBean; - } - - /** - * Set sofaSimpleTypeBean. - * - * @param sofaSimpleTypeBean sofaSimpleTypeBean - */ - public void setSofaSimpleTypeBean(final SofaSimpleTypeBean sofaSimpleTypeBean) { - this.sofaSimpleTypeBean = sofaSimpleTypeBean; - } - - /** - * Get idLists. - * - * @return idLists - */ - public List getIdLists() { - return idLists; - } - - /** - * Set idLists. - * - * @param idLists idLists - */ - public void setIdLists(final List idLists) { - this.idLists = idLists; - } - - /** - * Get idMaps. - * - * @return idMaps - */ - public Map getIdMaps() { - return idMaps; - } - - /** - * Set idMaps. - * - * @param idMaps idMaps - */ - public void setIdMaps(final Map idMaps) { - this.idMaps = idMaps; - } - - @Override - public String toString() { - return new StringJoiner(", ", SofaComplexTypeBean.class.getSimpleName() + "[", "]") - .add("sofaSimpleTypeBean=" + sofaSimpleTypeBean) - .add("idLists=" + idLists) - .add("idMaps=" + idMaps) - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/entity/SofaSimpleTypeBean.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/entity/SofaSimpleTypeBean.java deleted file mode 100644 index 45b2751..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/entity/SofaSimpleTypeBean.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.api.entity; - -import java.io.Serializable; - -/** - * Sofa simple type Bean. - */ -public class SofaSimpleTypeBean implements Serializable { - - private String id; - - private String name; - - public SofaSimpleTypeBean() { - } - - public SofaSimpleTypeBean(final String id, final String name) { - this.id = id; - this.name = name; - } - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - @Override - public String toString() { - return "SofaSimpleTypeBean{" - + "id='" + id + '\'' - + ", name='" + name + '\'' - + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaClientMultiParamService.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaClientMultiParamService.java deleted file mode 100644 index 0f363b7..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaClientMultiParamService.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.api.service; - -import org.apache.shenyu.examples.sofa.api.entity.SofaComplexTypeBean; -import org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean; - -import java.util.List; -import java.util.Map; - -/** - * Sofa multi parameter service. - */ -public interface SofaClientMultiParamService { - - /** - * Find by ids and name. - * body: {"ids":["1232","456"],"name":"hello world"} - * - * @param ids the ids - * @param name the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findByIdsAndName(List ids, String name); - - /** - * Find by array ids and name. - * body :{"ids":[123,4561],"name":"hello world"} - * - * @param ids the ids - * @param name the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findByArrayIdsAndName(Integer[] ids, String name); - - /** - * Find by string array. - * body :{"ids":["1232","456"]} - * - * @param ids the ids - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findByStringArray(String[] ids); - - /** - * Find by list id. - * body :{"ids":["1232","456"]} - * - * @param ids the ids - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findByListId(List ids); - - /** - * Batch save SofaSimpleTypeBean. - * body :{"sofaTestList":[{"id":"123","name":"xiaoyu"},{"id":"456","name":"myth"}]} - * - * @param sofaTestList the sofa test list - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean batchSave(List sofaTestList); - - /** - * Batch save name and id. - * body: {"sofaTestList":[{"id":"123","name":"xiaoyu"},{"id":"456","name":"myth"}],"id":"789","name":"ttt"} - * - * @param sofaTestList the sofa test list. - * @param id the id - * @param name the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean batchSaveNameAndId(List sofaTestList, String id, String name); - - - /** - * Save sofa complex type bean. - * body : {"sofaSimpleTypeBean":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}} - * - * @param sofaComplexTypeBean the sofa complex type bean. - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean saveComplexBean(SofaComplexTypeBean sofaComplexTypeBean); - - - /** - * Save complex bean test and name dubbo test. - * body : {"sofaComplexTypeBean":{"sofaSimpleTypeBean":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}},"name":"xiaoyu"} - * - * @param sofaComplexTypeBean the sofa complex type bean. - * @param name the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean saveComplexBeanAndName(SofaComplexTypeBean sofaComplexTypeBean, String name); - - /** - * Save complex bean test and name dubbo test. - * body : {"sofaComplexTypeBean":[{"sofaSimpleTypeBean":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}}], - * "sofaSimpleTypeBeanList":[{"id":"123","name":"xiaoyu"}]} - * - * @param sofaComplexTypeBeanList the sofa complex type bean. - * @param sofaSimpleTypeBeanMap the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean saveTwoList(List sofaComplexTypeBeanList, - Map sofaSimpleTypeBeanMap); - -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaClientSingleParamService.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaClientSingleParamService.java deleted file mode 100644 index c363bdf..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaClientSingleParamService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.api.service; - -import org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean; - -/** - * Sofa single parameter service. - */ -public interface SofaClientSingleParamService { - - /** - * find by id. - * body:{"id":"1223"} - * - * @param id id - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findById(String id); - - /** - * Find all dubbo test. - * - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findAll(); - - /** - * Insert dubbo test. - * body :{"id":"122344","name":"xiaoyu"} - * - * @param sofaSimpleTypeBean the simple type parameters. - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean insert(SofaSimpleTypeBean sofaSimpleTypeBean); -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaMultiParamService.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaMultiParamService.java deleted file mode 100644 index dbd899b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaMultiParamService.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.api.service; - -import org.apache.shenyu.examples.sofa.api.entity.SofaComplexTypeBean; -import org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean; - -import java.util.List; -import java.util.Map; - -/** - * Sofa multi parameter service. - */ -public interface SofaMultiParamService { - - /** - * Find by ids and name. - * body: {"ids":["1232","456"],"name":"hello world"} - * - * @param ids the ids - * @param name the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findByIdsAndName(List ids, String name); - - /** - * Find by array ids and name. - * body :{"ids":[123,4561],"name":"hello world"} - * - * @param ids the ids - * @param name the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findByArrayIdsAndName(Integer[] ids, String name); - - /** - * Find by string array. - * body :{"ids":["1232","456"]} - * - * @param ids the ids - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findByStringArray(String[] ids); - - /** - * Find by list id. - * body :{"ids":["1232","456"]} - * - * @param ids the ids - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findByListId(List ids); - - /** - * Batch save SofaSimpleTypeBean. - * body :{"sofaTestList":[{"id":"123","name":"xiaoyu"},{"id":"456","name":"myth"}]} - * - * @param sofaTestList the sofa test list - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean batchSave(List sofaTestList); - - /** - * Batch save name and id. - * body: {"sofaTestList":[{"id":"123","name":"xiaoyu"},{"id":"456","name":"myth"}],"id":"789","name":"ttt"} - * - * @param sofaTestList the sofa test list. - * @param id the id - * @param name the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean batchSaveNameAndId(List sofaTestList, String id, String name); - - - /** - * Save sofa complex type bean. - * body : {"sofaSimpleTypeBean":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}} - * - * @param sofaComplexTypeBean the sofa complex type bean. - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean saveComplexBean(SofaComplexTypeBean sofaComplexTypeBean); - - - /** - * Save complex bean test and name dubbo test. - * body : {"sofaComplexTypeBean":{"sofaSimpleTypeBean":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}},"name":"xiaoyu"} - * - * @param sofaComplexTypeBean the sofa complex type bean. - * @param name the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean saveComplexBeanAndName(SofaComplexTypeBean sofaComplexTypeBean, String name); - - /** - * Save complex bean test and name dubbo test. - * body : {"sofaComplexTypeBean":[{"sofaSimpleTypeBean":{"id":"123","name":"xiaoyu"},"idLists":["456","789"],"idMaps":{"id2":"2","id1":"1"}}], - * "sofaSimpleTypeBeanList":[{"id":"123","name":"xiaoyu"}]} - * - * @param sofaComplexTypeBeanList the sofa complex type bean. - * @param sofaSimpleTypeBeanMap the name - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean saveTwoList(List sofaComplexTypeBeanList, Map sofaSimpleTypeBeanMap); - -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaSingleParamService.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaSingleParamService.java deleted file mode 100644 index c8ffece..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaSingleParamService.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.api.service; - -import org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean; - -/** - * Sofa single parameter service. - */ -public interface SofaSingleParamService { - - /** - * find by id. - * body:{"id":"1223"} - * - * @param id id - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findById(String id); - - /** - * Find all dubbo test. - * - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean findAll(); - - /** - * Insert dubbo test. - * body :{"id":"122344","name":"xiaoyu"} - * - * @param sofaSimpleTypeBean the simple type parameters. - * @return SofaSimpleTypeBean - */ - SofaSimpleTypeBean insert(SofaSimpleTypeBean sofaSimpleTypeBean); - -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/Dockerfile b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/Dockerfile deleted file mode 100644 index 866cb04..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-examples-sofa -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 28011 -EXPOSE 8888 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/ingress.yml b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/ingress.yml deleted file mode 100644 index d932e01..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/ingress.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -apiVersion: v1 -kind: Service -metadata: - name: sofa-find-id - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-sofa-enabled: 'true' - shenyu.apache.org/plugin-sofa-app-name: sofa - shenyu.apache.org/plugin-context-path-path: /sofa - shenyu.apache.org/plugin-sofa-path: /sofa/findById - shenyu.apache.org/plugin-sofa-rpc-type: sofa - shenyu.apache.org/plugin-sofa-service-name: org.apache.shenyu.examples.sofa.api.service.SofaSingleParamService - shenyu.apache.org/plugin-sofa-method-name: findById - shenyu.apache.org/plugin-sofa-params-type: java.lang.String - shenyu.apache.org/plugin-sofa-rpc-expand: | - {"loadbalance":"hash","retries":3,"timeout":-1} -spec: - selector: - app: shenyu-examples-sofa - ports: - - port: 8888 - ---- - -apiVersion: v1 -kind: Service -metadata: - name: sofa-find-all - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-sofa-enabled: 'true' - shenyu.apache.org/plugin-context-path-path: /sofa - shenyu.apache.org/plugin-sofa-app-name: sofa - shenyu.apache.org/plugin-sofa-path: /sofa/findAll - shenyu.apache.org/plugin-sofa-rpc-type: sofa - shenyu.apache.org/plugin-sofa-service-name: org.apache.shenyu.examples.sofa.api.service.SofaSingleParamService - shenyu.apache.org/plugin-sofa-method-name: findAll - shenyu.apache.org/plugin-sofa-rpc-expand: | - {"loadbalance":"hash","retries":3,"timeout":-1} -spec: - selector: - app: shenyu-examples-sofa - ports: - - port: 8888 - ---- - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - namespace: shenyu-ingress - labels: - shenyu.apache.org/metadata-labels-1: sofa-find-id - shenyu.apache.org/metadata-labels-2: sofa-find-all - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-sofa-enabled: 'true' - shenyu.apache.org/zookeeper-register-address: shenyu-zk:2181 - name: demo-ingress -spec: - rules: - - http: - paths: - - backend: - service: - name: shenyu-java-examples-sofa - port: - number: 8888 - path: /sofa/ - pathType: Prefix diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/shenyu-examples-sofa.yml b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/shenyu-examples-sofa.yml deleted file mode 100644 index ed3d7cc..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/shenyu-examples-sofa.yml +++ /dev/null @@ -1,88 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-examples-sofa-deployment - namespace: shenyu-ingress - labels: - app: shenyu-examples-sofa - all: shenyu-examples-sofa -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-examples-sofa - all: shenyu-examples-sofa - strategy: {} - template: - metadata: - labels: - app: shenyu-examples-sofa - all: shenyu-examples-sofa - spec: - containers: - - image: shenyu-examples-sofa - name: shenyu-java-examples-sofa - livenessProbe: - initialDelaySeconds: 30 - periodSeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 3 - exec: - command: - - /bin/sh - - "-c" - - wget -q -O - http://localhost:8081/actuator/health | grep UP || exit 1 - env: - - name: shenyu.register.serverLists - value: http://shenyu-admin:9095 - - name: com.alipay.sofa.rpc.registry-address - value: zookeeper://shenyu-zk:2181 - ports: - - containerPort: 28011 - - containerPort: 8888 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-java-examples-sofa-service - namespace: shenyu-ingress - labels: - app: shenyu-examples-sofa - all: shenyu-examples-sofa -spec: - selector: - app: shenyu-examples-sofa - all: shenyu-examples-sofa - type: NodePort - ports: - - name: "8888" - port: 8888 - targetPort: 8888 - nodePort: 31111 - - name: "28011" - port: 28011 - targetPort: 28011 - nodePort: 31112 -status: - loadBalancer: {} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/shenyu-zookeeper.yml b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/shenyu-zookeeper.yml deleted file mode 100644 index 8f4f193..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/k8s/shenyu-zookeeper.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: v1 -kind: Namespace -metadata: - name: shenyu-ingress - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-sofa - name: shenyu-zk -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-zk - all: shenyu-examples-sofa - strategy: {} - template: - metadata: - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-sofa - spec: - containers: - - image: zookeeper:latest - name: shenyu-zk - resources: {} - ports: - - containerPort: 2181 - name: client - - containerPort: 2888 - name: server - - containerPort: 3888 - name: leader-election - - containerPort: 8080 - name: website - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-zk - namespace: shenyu-ingress - labels: - app: shenyu-zk - all: shenyu-examples-sofa -spec: - type: NodePort - selector: - app: shenyu-zk - all: shenyu-examples-sofa - ports: - - name: "client" - port: 2181 - targetPort: 2181 - - name: "server" - port: 2888 - targetPort: 2888 - - name: "election" - port: 3888 - targetPort: 3888 - - name: "website" - port: 8080 - targetPort: 8080 diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/pom.xml b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/pom.xml deleted file mode 100644 index 68b5534..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/pom.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples-sofa - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-sofa-service - - - 3.22.0 - 3.22.0 - 4.3.0 - 1.8.6 - - - - - com.alipay.sofa - healthcheck-sofa-boot-starter - ${healthcheck-sofa-boot-starter.version} - - - com.alipay.sofa - rpc-sofa-boot-starter - ${rpc-sofa-boot-starter.version} - - - sofa-common-tools - com.alipay.sofa.common - - - - - com.alipay.sofa.common - sofa-common-tools - 1.3.11 - - - - org.springframework.boot - spring-boot-starter - - - - org.apache.curator - curator-client - ${curator.version} - - - org.apache.curator - curator-framework - ${curator.version} - - - org.apache.curator - curator-recipes - ${curator.version} - - - - - - - org.apache.shenyu - shenyu-java-examples-sofa-api - ${project.version} - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-sofa - ${project.version} - - - guava - com.google.guava - - - snakeyaml - org.yaml - - - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-web - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - io.micrometer - micrometer-core - ${micrometer.version} - compile - - - - - shenyu-java-examples-sofa - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.sofa.service.TestSofaApplication - true - - - - - - - - example - - shenyu-java-examples-sofa - shenyu-java-examples-sofa - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-java-examples-sofa - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/http/sofa-test-api.http b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/http/sofa-test-api.http deleted file mode 100644 index 3f29522..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/http/sofa-test-api.http +++ /dev/null @@ -1,221 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy findById -POST http://localhost:9195/sofa/findById -Accept: application/json -Content-Type: application/json - -{ - "id": "123" -} - -### shengyu getway proxy findAll -GET http://localhost:9195/sofa/findAll -Accept: application/json - - -### shengyu getway proxy insert -POST http://localhost:9195/sofa/insert -Accept: application/json -Content-Type: application/json - -{ - "sofaSimpleTypeBean": { - "id": 123, - "name": "test" - } -} - -### shengyu getway proxy findByIdsAndName -GET http://localhost:9195/sofa/findByIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByArrayIdsAndName -GET http://localhost:9195/sofa/findByArrayIdsAndName -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ], - "name": "test" -} - -### shengyu getway proxy findByStringArray -GET http://localhost:9195/sofa/findByStringArray -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ] -} - -### shengyu getway proxy findByListId -GET http://localhost:9195/sofa/findByListId -Accept: application/json -Content-Type: application/json - -{ - "ids": [ - 123, - 124, - 125 - ] -} - -### shengyu getway proxy batchSave -PUT http://localhost:9195/sofa/batchSave -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ] -} - -### shengyu getway proxy batchSaveNameAndId -PUT http://localhost:9195/sofa/batchSaveNameAndId -Accept: application/json -Content-Type: application/json - -{ - "sofaTestList": [ - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - }, - { - "id": "123", - "name": "test" - } - ], - "id": "123", - "name": "test" -} - -### shengyu getway proxy saveComplexBean -PUT http://localhost:9195/sofa/saveComplexBean -Accept: application/json -Content-Type: application/json - -{ - "sofaComplexTypeBean": { - "sofaSimpleTypeBean": { - "id": "123", - "name": "test" - }, - "idLists": [ - 123, - 124 - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } - } -} - -### shengyu getway proxy saveComplexBeanAndName -PUT http://localhost:9195/sofa/saveComplexBeanAndName -Accept: application/json -Content-Type: application/json - -{ - "sofaComplexTypeBean": { - "sofaSimpleTypeBean": { - "id": "123", - "name": "test" - }, - "idLists": [ - 123, - 124 - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } - }, - "name": "name" -} - -### shengyu getway proxy saveTwoList -PUT http://localhost:9195/sofa/saveTwoList -Accept: application/json -Content-Type: application/json - -{ - "sofaComplexTypeBeanList": [ - { - "sofaSimpleTypeBean": { - "id": "123", - "name": "test" - }, - "idLists": [ - 123, - 124 - ], - "idMaps": { - "abc": "abc", - "cbd": "cbd" - } - } - ], - "sofaSimpleTypeBeanMap": { - "testKey1": { - "id": "123", - "name": "test" - }, - "testKey2": { - "id": "123", - "name": "test" - } - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/TestSofaApplication.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/TestSofaApplication.java deleted file mode 100644 index f97e1e8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/TestSofaApplication.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.service; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ImportResource; - -/** - * Sofa service starter. - */ -@SpringBootApplication -@ImportResource(locations = { "classpath*:invoke-server-example.xml"}) -public class TestSofaApplication { - - /** - * Main Entrance. - * - * @param args startup arguments - */ - public static void main(final String[] args) { - SpringApplication.run(TestSofaApplication.class, args); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaClientMultiParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaClientMultiParamServiceImpl.java deleted file mode 100644 index 813b7f6..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaClientMultiParamServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.service.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.sofa.common.annotation.ShenyuSofaClient; -import org.apache.shenyu.examples.sofa.api.entity.SofaComplexTypeBean; -import org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean; -import org.apache.shenyu.examples.sofa.api.service.SofaClientMultiParamService; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Sofa multi parameter service. - */ -@ShenyuSofaClient("/demo") -@Service -@ApiModule(value = "demo") -public class SofaClientMultiParamServiceImpl implements SofaClientMultiParamService { - - @Override - @ShenyuSofaClient("/findByIdsAndName") - @ApiDoc(desc = "findByIdsAndName") - public SofaSimpleTypeBean findByIdsAndName(final List ids, final String name) { - return new SofaSimpleTypeBean(ids.toString(), "hello world shenyu sofa param findByIdsAndName :" + name); - } - - @Override - @ShenyuSofaClient("/findByArrayIdsAndName") - @ApiDoc(desc = "findByArrayIdsAndName") - public SofaSimpleTypeBean findByArrayIdsAndName(final Integer[] ids, final String name) { - return new SofaSimpleTypeBean(Arrays.toString(ids), "hello world shenyu sofa param findByArrayIdsAndName :" + name); - } - - @Override - @ShenyuSofaClient("/findByStringArray") - @ApiDoc(desc = "findByStringArray") - public SofaSimpleTypeBean findByStringArray(final String[] ids) { - return new SofaSimpleTypeBean(Arrays.toString(ids), "hello world shenyu sofa param findByStringArray"); - } - - @Override - @ShenyuSofaClient("/findByListId") - @ApiDoc(desc = "findByListId") - public SofaSimpleTypeBean findByListId(final List ids) { - return new SofaSimpleTypeBean(ids.toString(), "hello world shenyu sofa param findByListId"); - } - - @Override - @ShenyuSofaClient("/batchSave") - @ApiDoc(desc = "batchSave") - public SofaSimpleTypeBean batchSave(final List sofaTestList) { - final String id = sofaTestList.stream().map(SofaSimpleTypeBean::getId).collect(Collectors.joining("-")); - final String name = "hello world shenyu sofa param batchSave :" - + sofaTestList.stream() - .map(SofaSimpleTypeBean::getName) - .collect(Collectors.joining("-")); - return new SofaSimpleTypeBean(id, name); - } - - @Override - @ShenyuSofaClient("/batchSaveNameAndId") - @ApiDoc(desc = "batchSaveNameAndId") - public SofaSimpleTypeBean batchSaveNameAndId(final List sofaTestList, final String id, final String name) { - final String newName = "hello world shenyu sofa param batchSaveAndNameAndId :" + name + ":" - + sofaTestList.stream() - .map(SofaSimpleTypeBean::getName) - .collect(Collectors.joining("-")); - return new SofaSimpleTypeBean(id, newName); - } - - @Override - @ShenyuSofaClient("/saveComplexBean") - @ApiDoc(desc = "saveComplexBean") - public SofaSimpleTypeBean saveComplexBean(final SofaComplexTypeBean sofaComplexTypeBean) { - final String id = sofaComplexTypeBean.getIdLists().toString(); - final String typeName = "hello world shenyu sofa param saveComplexBean :" + sofaComplexTypeBean.getSofaSimpleTypeBean().getName(); - return new SofaSimpleTypeBean(id, typeName); - } - - @Override - @ShenyuSofaClient("/saveComplexBeanAndName") - @ApiDoc(desc = "saveComplexBeanAndName") - public SofaSimpleTypeBean saveComplexBeanAndName(final SofaComplexTypeBean sofaComplexTypeBean, final String name) { - final String id = sofaComplexTypeBean.getIdLists().toString(); - final String typeName = "hello world shenyu sofa param saveComplexBeanAndName :" + sofaComplexTypeBean.getSofaSimpleTypeBean().getName() + "-" + name; - return new SofaSimpleTypeBean(id, typeName); - } - - @Override - @ShenyuSofaClient("/saveTwoList") - @ApiDoc(desc = "saveTwoList") - public SofaSimpleTypeBean saveTwoList(final List sofaComplexTypeBeanList, final Map sofaSimpleTypeBeanMap) { - SofaSimpleTypeBean simpleTypeBean = new SofaSimpleTypeBean(); - if (!CollectionUtils.isEmpty(sofaComplexTypeBeanList) && !CollectionUtils.isEmpty(sofaSimpleTypeBeanMap)) { - final SofaComplexTypeBean firstBean = sofaComplexTypeBeanList.get(0); - final Optional firstTypeOptional = sofaSimpleTypeBeanMap.values().stream().findFirst(); - simpleTypeBean.setId(firstBean.getIdLists().toString()); - simpleTypeBean.setName("hello world shenyu sofa param saveTwoList :" + firstBean.getSofaSimpleTypeBean().getName() - + "-" + firstTypeOptional.map(SofaSimpleTypeBean::getName)); - } - return simpleTypeBean; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaClientSingleParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaClientSingleParamServiceImpl.java deleted file mode 100644 index 859bbc0..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaClientSingleParamServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.service.impl; - -import org.apache.shenyu.client.sofa.common.annotation.ShenyuSofaClient; -import org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean; -import org.apache.shenyu.examples.sofa.api.service.SofaClientSingleParamService; -import org.springframework.stereotype.Service; - -import java.util.Random; - -/** - * Sofa single param service. - */ -@ShenyuSofaClient("/demo/**") -@Service -public class SofaClientSingleParamServiceImpl implements SofaClientSingleParamService { - - @Override - @ShenyuSofaClient("/findById") - public SofaSimpleTypeBean findById(final String id) { - return new SofaSimpleTypeBean(id, "hello world shenyu Sofa, findById"); - } - - @Override - @ShenyuSofaClient("/findAll") - public SofaSimpleTypeBean findAll() { - return new SofaSimpleTypeBean(String.valueOf(new Random().nextInt()), "hello world shenyu Sofa , findAll"); - } - - @Override - @ShenyuSofaClient("/insert") - public SofaSimpleTypeBean insert(final SofaSimpleTypeBean sofaSimpleTypeBean) { - sofaSimpleTypeBean.setName("hello world shenyu Sofa: " + sofaSimpleTypeBean.getName()); - return sofaSimpleTypeBean; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaMultiParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaMultiParamServiceImpl.java deleted file mode 100644 index 67f4f74..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaMultiParamServiceImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.service.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.sofa.common.annotation.ShenyuSofaClient; -import org.apache.shenyu.examples.sofa.api.entity.SofaComplexTypeBean; -import org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean; -import org.apache.shenyu.examples.sofa.api.service.SofaMultiParamService; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Sofa multi parameter service. - */ -@Service("sofaMultiParamService") -@ApiModule(value = "sofaMultiParamService") -public class SofaMultiParamServiceImpl implements SofaMultiParamService { - - @Override - @ShenyuSofaClient("/findByIdsAndName") - @ApiDoc(desc = "findByIdsAndName") - public SofaSimpleTypeBean findByIdsAndName(final List ids, final String name) { - return new SofaSimpleTypeBean(ids.toString(), "hello world shenyu sofa param findByIdsAndName :" + name); - } - - @Override - @ShenyuSofaClient("/findByArrayIdsAndName") - @ApiDoc(desc = "findByArrayIdsAndName") - public SofaSimpleTypeBean findByArrayIdsAndName(final Integer[] ids, final String name) { - return new SofaSimpleTypeBean(Arrays.toString(ids), "hello world shenyu sofa param findByArrayIdsAndName :" + name); - } - - @Override - @ShenyuSofaClient("/findByStringArray") - @ApiDoc(desc = "findByStringArray") - public SofaSimpleTypeBean findByStringArray(final String[] ids) { - return new SofaSimpleTypeBean(Arrays.toString(ids), "hello world shenyu sofa param findByStringArray"); - } - - @Override - @ShenyuSofaClient("/findByListId") - @ApiDoc(desc = "findByListId") - public SofaSimpleTypeBean findByListId(final List ids) { - return new SofaSimpleTypeBean(ids.toString(), "hello world shenyu sofa param findByListId"); - } - - @Override - @ShenyuSofaClient("/batchSave") - @ApiDoc(desc = "batchSave") - public SofaSimpleTypeBean batchSave(final List sofaTestList) { - final String id = sofaTestList.stream().map(SofaSimpleTypeBean::getId).collect(Collectors.joining("-")); - final String name = "hello world shenyu sofa param batchSave :" - + sofaTestList.stream() - .map(SofaSimpleTypeBean::getName) - .collect(Collectors.joining("-")); - return new SofaSimpleTypeBean(id, name); - } - - @Override - @ShenyuSofaClient("/batchSaveNameAndId") - @ApiDoc(desc = "batchSaveNameAndId") - public SofaSimpleTypeBean batchSaveNameAndId(final List sofaTestList, final String id, final String name) { - final String newName = "hello world shenyu sofa param batchSaveAndNameAndId :" + name + ":" - + sofaTestList.stream() - .map(SofaSimpleTypeBean::getName) - .collect(Collectors.joining("-")); - return new SofaSimpleTypeBean(id, newName); - } - - @Override - @ShenyuSofaClient("/saveComplexBean") - @ApiDoc(desc = "saveComplexBean") - public SofaSimpleTypeBean saveComplexBean(final SofaComplexTypeBean sofaComplexTypeBean) { - final String id = sofaComplexTypeBean.getIdLists().toString(); - final String typeName = "hello world shenyu sofa param saveComplexBean :" + sofaComplexTypeBean.getSofaSimpleTypeBean().getName(); - return new SofaSimpleTypeBean(id, typeName); - } - - @Override - @ShenyuSofaClient("/saveComplexBeanAndName") - @ApiDoc(desc = "saveComplexBeanAndName") - public SofaSimpleTypeBean saveComplexBeanAndName(final SofaComplexTypeBean sofaComplexTypeBean, final String name) { - final String id = sofaComplexTypeBean.getIdLists().toString(); - final String typeName = "hello world shenyu sofa param saveComplexBeanAndName :" + sofaComplexTypeBean.getSofaSimpleTypeBean().getName() + "-" + name; - return new SofaSimpleTypeBean(id, typeName); - } - - @Override - @ShenyuSofaClient("/saveTwoList") - @ApiDoc(desc = "saveTwoList") - public SofaSimpleTypeBean saveTwoList(final List sofaComplexTypeBeanList, final Map sofaSimpleTypeBeanMap) { - SofaSimpleTypeBean simpleTypeBean = new SofaSimpleTypeBean(); - if (!CollectionUtils.isEmpty(sofaComplexTypeBeanList) && !CollectionUtils.isEmpty(sofaSimpleTypeBeanMap)) { - final SofaComplexTypeBean firstBean = sofaComplexTypeBeanList.get(0); - final Optional firstTypeOptional = sofaSimpleTypeBeanMap.values().stream().findFirst(); - simpleTypeBean.setId(firstBean.getIdLists().toString()); - simpleTypeBean.setName("hello world shenyu sofa param saveTwoList :" + firstBean.getSofaSimpleTypeBean().getName() - + "-" + firstTypeOptional.map(SofaSimpleTypeBean::getName)); - } - return simpleTypeBean; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaSingleParamServiceImpl.java b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaSingleParamServiceImpl.java deleted file mode 100644 index 806bbda..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/java/org/apache/shenyu/examples/sofa/service/impl/SofaSingleParamServiceImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.sofa.service.impl; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.sofa.common.annotation.ShenyuSofaClient; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.sofa.api.entity.SofaSimpleTypeBean; -import org.apache.shenyu.examples.sofa.api.service.SofaSingleParamService; -import org.springframework.stereotype.Service; - -import java.util.Random; - -/** - * Sofa single param service. - */ -@Service("sofaSingleParamService") -@ApiModule(value = "sofaSingleParamService") -public class SofaSingleParamServiceImpl implements SofaSingleParamService { - - @Override - @ShenyuSofaClient("/findById") - @Log - @ApiDoc(desc = "findById") - public SofaSimpleTypeBean findById(final String id) { - return new SofaSimpleTypeBean(id, "hello world shenyu Sofa, findById"); - } - - @Override - @ShenyuSofaClient("/findAll") - @ApiDoc(desc = "findAll") - public SofaSimpleTypeBean findAll() { - return new SofaSimpleTypeBean(String.valueOf(new Random().nextInt()), "hello world shenyu Sofa , findAll"); - } - - @Override - @ShenyuSofaClient("/insert") - @ApiDoc(desc = "insert") - public SofaSimpleTypeBean insert(final SofaSimpleTypeBean sofaSimpleTypeBean) { - sofaSimpleTypeBean.setName("hello world shenyu Sofa: " + sofaSimpleTypeBean.getName()); - return sofaSimpleTypeBean; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/resources/application.yml deleted file mode 100644 index ede4465..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/resources/application.yml +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 28011 - address: 0.0.0.0 - servlet: - context-path: / -spring: - main: - allow-bean-definition-overriding: true - application: - name: sofa -com: - alipay: - sofa: - rpc: - registry-address: zookeeper://127.0.0.1:2181 - bolt-port: 8888 - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - sofa: - props: - contextPath: /sofa - ipAndPort: sofa - appName: sofa - port: 8888 diff --git a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/resources/invoke-server-example.xml b/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/resources/invoke-server-example.xml deleted file mode 100644 index 7567eef..0000000 --- a/shenyu-java-examples/shenyu-java-examples-sofa/shenyu-java-examples-sofa-service/src/main/resources/invoke-server-example.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/Dockerfile b/shenyu-java-examples/shenyu-java-examples-springcloud/Dockerfile deleted file mode 100644 index 776dc28..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-examples-springcloud -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8761 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/README.md b/shenyu-java-examples/shenyu-java-examples-springcloud/README.md deleted file mode 100644 index f83b1a2..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Shenyu example SpringCloud -*** -## Run -first you should run eureka: shenyu-example-eureka - -Then you can run server with http/zookeeper/etcd register center - -### run with etcd register center -#### Shenyu-Admin config -add etcd register center dependency in shenyu-admin: - -```xml - - org.apache.shenyu - shenyu-register-server-etcd - ${project.version} - -``` - -set etcd register config in shenyu-admin: - -```yaml -shenyu: - register: - registerType: etcd - serverLists : http://localhost:2379 -``` - -#### shenyu-examples-springcloud config -set etcd register config: - -```yaml -shenyu: - client: - registerType: etcd - serverLists: http://localhost:2379 - props: - contextPath: /springcloud -``` - -run ShenyuTestSpringCloudApplication diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/k8s/ingress.yml b/shenyu-java-examples/shenyu-java-examples-springcloud/k8s/ingress.yml deleted file mode 100644 index 0b386f1..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/k8s/ingress.yml +++ /dev/null @@ -1,84 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: v1 -kind: Service -metadata: - name: spring-cloud-test - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/loadbalancer: roundRobin - shenyu.apache.org/plugin-spring-cloud-enabled: 'true' - shenyu.apache.org/plugin-spring-cloud-app-name: springCloud-test - shenyu.apache.org/plugin-spring-cloud-path: /new/feature/get/mapping/path - shenyu.apache.org/plugin-spring-cloud-rpc-type: springCloud - shenyu.apache.org/plugin-spring-cloud-service-name: org.apache.shenyu.examples.springcloud.controller.NewFeatureController - shenyu.apache.org/plugin-spring-cloud-method-name: getMappingUrl -spec: - selector: - app: shenyu-java-examples-springcloud-service - ports: - - port: 8884 # Assuming this is the spring cloud service port - ---- - -apiVersion: v1 -kind: Service -metadata: - name: spring-cloud-save - namespace: shenyu-ingress - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/loadbalancer: roundRobin - shenyu.apache.org/plugin-spring-cloud-enabled: 'true' - shenyu.apache.org/plugin-spring-cloud-app-name: springCloud-test - shenyu.apache.org/plugin-spring-cloud-path: /order/save - shenyu.apache.org/plugin-spring-cloud-rpc-type: springCloud - shenyu.apache.org/plugin-spring-cloud-service-name: org.apache.shenyu.examples.springcloud.controller.OrderController - shenyu.apache.org/plugin-spring-cloud-method-name: save - shenyu.apache.org/plugin-spring-cloud-params-type: org.apache.shenyu.examples.springcloud.dto.OrderDTO -spec: - selector: - app: shenyu-java-examples-springcloud-service - ports: - - port: 8884 # Assuming this is the Spring Cloud service port - ---- - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - namespace: shenyu-ingress - labels: - shenyu.apache.org/metadata-labels-1: spring-cloud-test - shenyu.apache.org/metadata-labels-2: spring-cloud-save - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/plugin-spring-cloud-enabled: 'true' - shenyu.apache.org/upstreams-protocol: http://,http:// - name: demo-ingress -spec: - rules: - - http: - paths: - - backend: - service: - name: shenyu-java-examples-springcloud-service - port: - number: 8884 - path: /** - pathType: ImplementationSpecific diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/k8s/shenyu-examples-springcloud.yml b/shenyu-java-examples/shenyu-java-examples-springcloud/k8s/shenyu-examples-springcloud.yml deleted file mode 100644 index e5e841f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/k8s/shenyu-examples-springcloud.yml +++ /dev/null @@ -1,81 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-examples-springcloud-deployment - namespace: shenyu-ingress - labels: - app: shenyu-examples-springcloud - all: shenyu-examples-springcloud -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-examples-springcloud - all: shenyu-examples-springcloud - strategy: {} - template: - metadata: - labels: - app: shenyu-examples-springcloud - all: shenyu-examples-springcloud - spec: - containers: - - image: shenyu-examples-springcloud - name: shenyu-java-examples-springcloud - livenessProbe: - exec: - command: - - /bin/sh - - "-c" - - wget -q -O - http://localhost:8884/actuator/health | grep UP || exit 1 - initialDelaySeconds: 10 - failureThreshold: 3 - timeoutSeconds: 2 - env: - - name: shenyu.register.serverLists - value: http://shenyu-admin:9095 - - name: eureka.client.serviceUrl.defaultZone - value: http://shenyu-examples-eureka:8761/eureka/ - ports: - - containerPort: 8884 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-examples-springcloud-service - namespace: shenyu-ingress - labels: - app: shenyu-examples-springcloud - all: shenyu-examples-springcloud -spec: - selector: - app: shenyu-examples-springcloud - all: shenyu-examples-springcloud - type: NodePort - ports: - - name: "8884" - port: 8884 - targetPort: 8884 - nodePort: 31192 -status: - loadBalancer: {} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/pom.xml b/shenyu-java-examples/shenyu-java-examples-springcloud/pom.xml deleted file mode 100644 index 086aac0..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/pom.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-springcloud - - - 3.1.2 - 2021.0.1.0 - 3.1.2 - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-springcloud - ${project.version} - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-web - - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - ${nacos-discovery.version} - - - spring-cloud-context - org.springframework.cloud - - - spring-cloud-commons - org.springframework.cloud - - - - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - ${eureka-client.version} - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.cloud - spring-cloud-commons - ${spring-cloud.version} - - - org.projectlombok - lombok - - - - - - shenyu-examples-springcloud - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.springcloud.ShenyuTestSpringCloudApplication - true - - - - - - - - example - - shenyu-examples-springcloud - shenyu-examples-springcloud - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-examples-springcloud - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/http/spring-cloud-test-api-local.http b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/http/spring-cloud-test-api-local.http deleted file mode 100644 index 1b6e65e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/http/spring-cloud-test-api-local.http +++ /dev/null @@ -1,107 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - -### example local orderSave -POST http://localhost:8884/order/save -Accept: application/json -Content-Type: application/json - -{ - "id": 123, - "name": "order" -} - -### example local orderSave -GET http://localhost:8884/order/findById?id=123 -Accept: application/json -Content-Type: application/json - -### example local path -GET http://localhost:8884/order/path/123/hahah -Accept: application/json -Content-Type: application/json - -### example local path -GET http://localhost:8884/order/path/123/name -Accept: application/json -Content-Type: application/json - -### example local findByUserId -GET http://localhost:8884/test/findByUserId?userId=123 -Accept: application/json -Content-Type: application/json - - -### example local not support -POST http://localhost:8884/new/feature/gateway/not -Accept: application/json -Content-Type: application/json - -## must is success - -### example local used request mapping path -POST http://localhost:8884/new/feature/request/mapping/path -Accept: application/json -Content-Type: application/json - -### example local used request mapping path -GET http://localhost:8884/new/feature/request/mapping/path -Accept: application/json -Content-Type: application/json - -### example local used get mapping path -GET http://localhost:8884/new/feature/get/mapping/path -Accept: application/json -Content-Type: application/json - -### example local used post mapping path -POST http://localhost:8884/new/feature/post/mapping/path -Accept: application/json -Content-Type: application/json - -### example local used put mapping path -PUT http://localhost:8884/new/feature/put/mapping/path -Accept: application/json -Content-Type: application/json - -### example local used delete mapping path -DELETE http://localhost:8884/new/feature/delete/mapping/path -Accept: application/json -Content-Type: application/json - -### example local used get mapping path [class annotation] -GET http://localhost:8884/class/annotation/get -Accept: application/json -Content-Type: application/json - -### example local used post mapping path [class annotation] -POST http://localhost:8884/class/annotation/post -Accept: application/json -Content-Type: application/json - -### shengyu local used upload file -POST http://localhost:8884/upload/file -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt"; -Content-Type: multipart/form-data - -< ../../../../shenyu-java-examples-common/src/main/resources/1.txt ---WebAppBoundary-- diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/http/spring-cloud-test-api.http b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/http/spring-cloud-test-api.http deleted file mode 100644 index 24fe91b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/http/spring-cloud-test-api.http +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - -### shengyu getway proxy orderSave -POST http://localhost:9195/springcloud/order/save -Accept: application/json -Content-Type: application/json - -{ - "id": 123, - "name": "order" -} - - -### shengyu getway proxy orderSave -GET http://localhost:9195/springcloud/order/findById?id=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/springcloud/order/path/123/hahah -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/springcloud/order/path/123/name -Accept: application/json -Content-Type: application/json - - -### shengyu getway proxy findByUserId -GET http://localhost:9195/springcloud/test/findByUserId?userId=123 -Accept: application/json -Content-Type: application/json - - -### shengyu getway proxy not support -POST http://localhost:9195/springcloud/new/feature/gateway/not -Accept: application/json -Content-Type: application/json - -## must is fail - -### shengyu getway proxy used request mapping path -POST http://localhost:9195/springcloud/new/feature/request/mapping/path -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy used request mapping path -GET http://localhost:9195/springcloud/new/feature/request/mapping/path -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy used get mapping path -GET http://localhost:9195/springcloud/new/feature/get/mapping/path -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy used post mapping path -POST http://localhost:9195/springcloud/new/feature/post/mapping/path -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy used put mapping path -PUT http://localhost:9195/springcloud/new/feature/put/mapping/path -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy used delete mapping path -DELETE http://localhost:9195/springcloud/new/feature/delete/mapping/path -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy used get mapping path [class annotation] -GET http://localhost:9195/springcloud/class/annotation/get -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy used post mapping path [class annotation] -POST http://localhost:9195/springcloud/class/annotation/post -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy used upload file -POST http://localhost:9195/springcloud/upload/file -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt"; -Content-Type: multipart/form-data - -< ../../../../shenyu-java-examples-common/src/main/resources/1.txt ---WebAppBoundary-- diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/ShenyuTestSpringCloudApplication.java b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/ShenyuTestSpringCloudApplication.java deleted file mode 100644 index 6ab36cc..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/ShenyuTestSpringCloudApplication.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springcloud; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; - -/** - * ShenyuTestSpringCloudApplication. - */ -@SpringBootApplication -@EnableDiscoveryClient -public class ShenyuTestSpringCloudApplication { - - /** - * main. - * - * @param args args - */ - public static void main(final String[] args) { - SpringApplication.run(ShenyuTestSpringCloudApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/AllController.java b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/AllController.java deleted file mode 100644 index a8595d7..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/AllController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springcloud.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; -import org.apache.shenyu.examples.springcloud.dto.EntityResult; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * AllController. - */ -@RestController -@ShenyuSpringCloudClient -@ApiModule(value = "allController") -public class AllController { - - /** - * [class annotation] Do not use shenyu annotation path. used post mapping path. - * - * @return result - */ - @PostMapping("/class/annotation/post") - @ApiDoc(desc = "class/annotation/post") - public EntityResult postMappingUrl() { - return new EntityResult(200, "[class annotation] Do not use shenyu annotation path. used post mapping path"); - } - - /** - * [class annotation] Do not use shenyu annotation path. used post mapping path. - * - * @return result - */ - @GetMapping("/class/annotation/get") - @ApiDoc(desc = "class/annotation/get") - public EntityResult getMappingUrl() { - return new EntityResult(200, "[class annotation] Do not use shenyu annotation path. used get mapping path"); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/NewFeatureController.java b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/NewFeatureController.java deleted file mode 100644 index 7bbd5d5..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/NewFeatureController.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springcloud.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; -import org.apache.shenyu.examples.springcloud.dto.EntityResult; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * NewFeatureController. - */ -@RestController -@RequestMapping("new/feature") -@ApiModule(value = "newFeatureController") -public class NewFeatureController { - - /** - * no support gateway access api. - * - * @return result - */ - @RequestMapping("/gateway/not") - @ApiDoc(desc = "gateway/not") - public EntityResult noSupportGateway() { - return new EntityResult(200, "no support gateway access"); - } - - /** - * Do not use shenyu annotation path. used request mapping path. - * - * @return result - */ - @RequestMapping("/request/mapping/path") - @ShenyuSpringCloudClient - @ApiDoc(desc = "request/mapping/path") - public EntityResult requestMappingUrl() { - return new EntityResult(200, "Do not use shenyu annotation path. used request mapping path"); - } - - /** - * Do not use shenyu annotation path. used post mapping path. - * - * @return result - */ - @PostMapping("/post/mapping/path") - @ShenyuSpringCloudClient - @ApiDoc(desc = "post/mapping/path") - public EntityResult postMappingUrl() { - return new EntityResult(200, "Do not use shenyu annotation path. used post mapping path"); - } - - /** - * Do not use shenyu annotation path. used post mapping path. - * - * @return result - */ - @GetMapping("/get/mapping/path") - @ShenyuSpringCloudClient - @ApiDoc(desc = "get/mapping/path") - public EntityResult getMappingUrl() { - return new EntityResult(200, "Do not use shenyu annotation path. used get mapping path"); - } - - /** - * Do not use shenyu annotation path. used put mapping path. - * - * @return result - */ - @PutMapping("/put/mapping/path") - @ShenyuSpringCloudClient - @ApiDoc(desc = "put/mapping/path") - public EntityResult putMappingUrl() { - return new EntityResult(200, "Do not use shenyu annotation path. used put mapping path"); - } - - /** - * Do not use shenyu annotation path. used put mapping path. - * - * @return result - */ - @DeleteMapping("/delete/mapping/path") - @ShenyuSpringCloudClient - @ApiDoc(desc = "delete/mapping/path") - public EntityResult deleteMappingUrl() { - return new EntityResult(200, "Do not use shenyu annotation path. used delete mapping path"); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/OrderController.java b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/OrderController.java deleted file mode 100644 index a1e90d7..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/OrderController.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springcloud.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springcloud.annotation.ShenyuGetMapping; -import org.apache.shenyu.client.springcloud.annotation.ShenyuPostMapping; -import org.apache.shenyu.client.springcloud.annotation.ShenyuRequestMapping; -import org.apache.shenyu.examples.springcloud.dto.OrderDTO; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * OrderController. - */ -@RestController -@ShenyuRequestMapping("/order") -@ApiModule(value = "order") -public class OrderController { - - /** - * Save order dto. - * - * @param orderDTO the order dto - * @return the order dto - */ - @ShenyuPostMapping("/save") - @ApiDoc(desc = "save") - public OrderDTO save(@RequestBody final OrderDTO orderDTO) { - orderDTO.setName("hello world spring cloud save order"); - return orderDTO; - } - - /** - * Find by id order dto. - * - * @param id the id - * @return the order dto - */ - @ShenyuGetMapping("/findById") - @ApiDoc(desc = "findById") - public OrderDTO findById(@RequestParam("id") final String id) { - return buildOrder(id, "hello world spring cloud findById"); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @ShenyuGetMapping("/path/{id}/{name}") - @ApiDoc(desc = "path/{id}/{name}") - public OrderDTO getPathVariable(@PathVariable("id") final String id, @PathVariable("name") final String name) { - return buildOrder(id, "hello world spring cloud restful: " + name); - } - - /** - * Test rest ful order dto. - * - * @param id the id - * @return the order dto - */ - @ShenyuGetMapping("/path/{id}/name") - @ApiDoc(desc = "path/{id}/name") - public OrderDTO testRestFul(@PathVariable("id") final String id) { - return buildOrder(id, "hello world spring cloud restful inline " + id); - } - - private OrderDTO buildOrder(final String id, final String name) { - OrderDTO orderDTO = new OrderDTO(); - orderDTO.setId(id); - orderDTO.setName(name); - return orderDTO; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/TestController.java b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/TestController.java deleted file mode 100644 index 0c626ac..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/TestController.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springcloud.controller; - -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.springcloud.dto.UserDTO; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * TestController. - */ -@RestController -@RequestMapping("/test") -@ShenyuSpringCloudClient(path = "/test/**") -public class TestController { - - - /** - * Post string. - * - * @param userDTO the user dto - * @return the string - */ - @PostMapping("/save") - public UserDTO post(@RequestBody final UserDTO userDTO) { - userDTO.setUserName("hello world spring cloud save user"); - return userDTO; - } - - /** - * Find by user id user dto. - * - * @param userId the user id - * @return the user dto - */ - @Log - @GetMapping("/findByUserId") - public UserDTO findByUserId(@RequestParam("userId") final String userId) { - UserDTO userDTO = new UserDTO(); - userDTO.setUserId(userId); - userDTO.setUserName("hello world spring cloud findBy user"); - return userDTO; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/UploadController.java b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/UploadController.java deleted file mode 100644 index 7c30f3f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/controller/UploadController.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springcloud.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springcloud.annotation.ShenyuSpringCloudClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * UploadController. - */ -@RestController -@RequestMapping("/upload") -@ShenyuSpringCloudClient(path = "/upload") -@ApiModule(value = "upload") -public class UploadController { - - /** - * Upload file. - * - * @param file file - * @return filename - */ - @PostMapping(value = "/file", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) - @ShenyuSpringCloudClient(path = "/file") - @ApiDoc(desc = "file") - public String post(@RequestPart("file")final MultipartFile file) { - return file.getOriginalFilename(); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/OrderDTO.java b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/OrderDTO.java deleted file mode 100644 index 4783ec4..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/OrderDTO.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springcloud.dto; - -import java.io.Serializable; -import java.util.StringJoiner; - -/** - * The type Order dto. - */ -public class OrderDTO implements Serializable { - - private String id; - - private String name; - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - @Override - public String toString() { - return new StringJoiner(", ", OrderDTO.class.getSimpleName() + "[", "]") - .add("id='" + id + "'") - .add("name='" + name + "'") - .toString(); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/UserDTO.java b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/UserDTO.java deleted file mode 100644 index 313649b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/java/org/apache/shenyu/examples/springcloud/dto/UserDTO.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springcloud.dto; - -import java.util.StringJoiner; - -/** - * The type User dto. - */ -public class UserDTO { - - private String userId; - - private String userName; - - /** - * Get userId. - * - * @return userId - */ - public String getUserId() { - return userId; - } - - /** - * Set userId. - * - * @param userId userId - */ - public void setUserId(final String userId) { - this.userId = userId; - } - - /** - * Get userName. - * - * @return userName - */ - public String getUserName() { - return userName; - } - - /** - * Set userName. - * - * @param userName userName - */ - public void setUserName(final String userName) { - this.userName = userName; - } - - @Override - public String toString() { - return new StringJoiner(", ", UserDTO.class.getSimpleName() + "[", "]") - .add("userId='" + userId + "'") - .add("userName='" + userName + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/resources/application.yml deleted file mode 100644 index 9a5b889..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springcloud/src/main/resources/application.yml +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8884 - address: 0.0.0.0 - -spring: - application: - name: springCloud-test - cloud: - loadbalancer: - ribbon: - enabled: true - discovery: - enabled: true - nacos: - discovery: - server-addr: 127.0.0.1:8848 # Spring Cloud Alibaba Dubbo use this. - enabled: false - namespace: ShenyuRegisterCenter - -eureka: - client: - enabled: true - serviceUrl: - defaultZone: http://localhost:8761/eureka/ - instance: - prefer-ip-address: true - - -springCloud-test: - ribbon.NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - nacosNameSpace: ShenyuRegisterCenter - client: - springCloud: - props: - contextPath: /springcloud - addPrefixed: false -# port: 8884 - -logging: - level: - root: info - org.apache.shenyu: debug diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/pom.xml b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/pom.xml deleted file mode 100644 index 32474da..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - shenyu-java-examples - org.apache.shenyu - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-springmvc-tomcat - - - UTF-8 - 8 - 8 - - - - - org.apache.shenyu - shenyu-client-java-springmvc - ${project.version} - - - - org.springframework - spring-webmvc - - - - javax.servlet - javax.servlet-api - - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/http/http-test-api-local.http b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/http/http-test-api-local.http deleted file mode 100644 index 4a81b9a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/http/http-test-api-local.http +++ /dev/null @@ -1,122 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy orderSave -POST http://localhost:8290/order/save -Accept: application/json -Content-Type: application/json - -{ - "id": 123, - "name": "order" -} - -### shengyu getway proxy orderSave -GET http://localhost:8290/order/findById?id=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:8290/order/path/123/hahah -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:8290/order/path/123/name -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy oauth2 -GET http://localhost:8290/order/oauth2/test -Accept: application/json -Content-Type: application/json -Authorization:AuthorizationContext - -### shengyu getway proxy payment -POST http://localhost:8290/test/payment -Accept: application/json -Content-Type: application/json - -{ - "userId": 123, - "userName": "name" -} - -### shengyu getway proxy findByUserId -GET http://localhost:8290/test/findByUserId?userId=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:8290/test/path/123?name=haha -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:8290/test/path/123/name -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy waf pass -POST http://localhost:8290/test/waf/pass -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy waf deny -POST http://localhost:8290/test/waf/deny -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy request parameter pass -GET http://localhost:8290/test/request/parameter/pass?requestParameter=test -Accept: application/json -Content-Type: application/json - -### example singleFile -POST http://localhost:8290/upload/singleFile -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt" -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - - -### example files -POST http://localhost:8290/upload/files -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="1.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="2.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/2.txt - ---WebAppBoundary-- \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/http/http-test-api.http b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/http/http-test-api.http deleted file mode 100644 index 0acba49..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/http/http-test-api.http +++ /dev/null @@ -1,123 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy orderSave -POST http://localhost:9195/springmvc/order/save -Accept: application/json -Content-Type: application/json - -{ - "id": 123, - "name": "order" -} - -### shengyu getway proxy orderSave -GET http://localhost:9195/springmvc/order/findById?id=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/springmvc/order/path/123/hahah -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/springmvc/order/path/123/name -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy oauth2 -GET http://localhost:9195/springmvc/order/oauth2/test -Accept: application/json -Content-Type: application/json -Authorization:AuthorizationContext - -### shengyu getway proxy payment -POST http://localhost:9195/springmvc/test/payment -Accept: application/json -Content-Type: application/json - -{ - "userId": 123, - "userName": "name" -} - -### shengyu getway proxy findByUserId -GET http://localhost:9195/springmvc/test/findByUserId?userId=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/springmvc/test/path/123?name=haha -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/springmvc/test/path/123/name -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy waf pass -POST http://localhost:9195/springmvc/test/waf/pass -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy waf deny -POST http://localhost:9195/springmvc/test/waf/deny -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy request parameter pass -GET http://localhost:9195/springmvc/test/request/parameter/pass?requestParameter=test -Accept: application/json -Content-Type: application/json - - -### shengyu getway prox example singleFile -POST http://localhost:9195/springmvc/upload/singleFile -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt" -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - - -### shengyu getway prox example files -POST http://localhost:9195/springmvc/upload/files -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="1.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="2.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/2.txt - ---WebAppBoundary-- \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/HttpTestController.java b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/HttpTestController.java deleted file mode 100644 index 553de52..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/HttpTestController.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.controller; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.springmvc.dto.UserDTO; -import org.apache.shenyu.examples.springmvc.result.ResultBean; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * TestController. - */ -@RestController -@RequestMapping("/test") -@ShenyuSpringMvcClient("/test/**") -public class HttpTestController { - - /** - * Post user dto. - * - * @param userDTO the user dto - * @return the user dto - */ - @PostMapping("/payment") - public UserDTO post(@RequestBody final UserDTO userDTO) { - return userDTO; - } - - /** - * Find by user id string. - * - * @param userId the user id - * @return the string - */ - @GetMapping("/findByUserId") - public UserDTO findByUserId(@RequestParam("userId") final String userId) { - return buildUser(userId, "hello world"); - } - - /** - * Find by page user dto. - * - * @param keyword the keyword - * @param page the page - * @param pageSize the page size - * @return the user dto - */ - @GetMapping("/findByPage") - public UserDTO findByPage(final String keyword, final Integer page, final Integer pageSize) { - return buildUser(keyword, "hello world keyword is" + keyword + " page is" + page + " pageSize is" + pageSize); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @GetMapping("/path/{id}") - public UserDTO getPathVariable(@PathVariable("id") final String id, @RequestParam("name") final String name) { - return buildUser(id, name); - } - - - /** - * Test rest ful string. - * - * @param id the id - * @return the string - */ - @Log - @GetMapping("/path/{id}/name") - public UserDTO testRestFul(@PathVariable("id") final String id) { - return buildUser(id, "hello world"); - } - - - /** - * Put path variable and body string. - * - * @param id the id - * @param userDTO the user dto - * @return the string - */ - @PutMapping("/putPathBody/{id}") - public UserDTO putPathVariableAndBody(@PathVariable("id") final String id, @RequestBody final UserDTO userDTO) { - userDTO.setUserId(id); - userDTO.setUserName("hello world"); - return userDTO; - } - - /** - * the waf pass. - * - * @return response. result bean - */ - @PostMapping("/waf/pass") - public ResultBean pass() { - final ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - return response; - } - - /** - * the waf deny. - * - * @return response. result bean - */ - @PostMapping("/waf/deny") - public ResultBean deny() { - final ResultBean response = new ResultBean(); - response.setCode(403); - response.setMsg("deny"); - return response; - } - - /** - * request Pass. - * - * @param requestParameter the requestParameter. - * @return ResultBean result bean - */ - @GetMapping("/request/parameter/pass") - public ResultBean requestParameter(@RequestParam("requestParameter") final String requestParameter) { - final ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - final Map param = new HashMap<>(); - param.put("requestParameter", requestParameter); - response.setData(param); - return response; - } - - /** - * request Pass. - * - * @param requestHeader the requestHeader. - * @return ResultBean result bean - */ - @GetMapping("/request/header/pass") - public ResultBean requestHeader(@RequestHeader("requestHeader") final String requestHeader) { - final ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - final Map param = new HashMap<>(); - param.put("requestHeader", requestHeader); - response.setData(param); - return response; - } - - /** - * request Pass. - * - * @param cookie the cookie. - * @return ResultBean result bean - */ - @GetMapping("/request/cookie/pass") - public ResultBean requestCookie(@CookieValue("cookie") final String cookie) { - final ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - final Map param = new HashMap<>(); - param.put("cookie", cookie); - response.setData(param); - return response; - } - - /** - * post sentinel. - * - * @return response. result bean - */ - @PostMapping("/sentinel/pass") - public ResultBean sentinelPass() { - return pass(); - } - - private UserDTO buildUser(final String id, final String name) { - final UserDTO userDTO = new UserDTO(); - userDTO.setUserId(id); - userDTO.setUserName(name); - return userDTO; - } -} - diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/OrderController.java b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/OrderController.java deleted file mode 100644 index 191797f..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/OrderController.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.controller; - -import java.util.Objects; -import javax.servlet.http.HttpServletRequest; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.examples.springmvc.dto.OAuth2DTO; -import org.apache.shenyu.examples.springmvc.dto.OrderDTO; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * TestController. - */ -@RestController -@RequestMapping("/order") -@ShenyuSpringMvcClient("/order") -@ApiModule(value = "order") -public class OrderController { - - /** - * Save order dto. - * - * @param orderDTO the order dto - * @return the order dto - */ - @PostMapping("/save") - @ShenyuSpringMvcClient("/save") - @ApiDoc(desc = "save") - public OrderDTO save(@RequestBody final OrderDTO orderDTO) { - orderDTO.setName("hello world save order"); - return orderDTO; - } - - /** - * Find by id order dto. - * - * @param id the id - * @return the order dto - */ - @GetMapping("/findById") - @ShenyuSpringMvcClient("/findById") - @ApiDoc(desc = "findById") - public OrderDTO findById(@RequestParam("id") final String id) { - return build(id, "hello world findById"); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @GetMapping("/path/{id}/{name}") - @ShenyuSpringMvcClient("/path/**") - @ApiDoc(desc = "path/{id}/{name}") - public OrderDTO getPathVariable(@PathVariable("id") final String id, @PathVariable("name") final String name) { - return build(id, "hello world restful: " + name); - } - - /** - * Test rest ful order dto. - * - * @param id the id - * @return the order dto - */ - @GetMapping("/path/{id}/name") - @ShenyuSpringMvcClient("/path/**/name") - @ApiDoc(desc = "path/{id}/name") - public OrderDTO testRestFul(@PathVariable("id") final String id) { - return build(id, "hello world restful inline " + id); - } - - /** - * Test oauth2 request. - * @param request request with the oauth2 headers - * @return the oauth2 dto - */ - @GetMapping("/oauth2/test") - @ShenyuSpringMvcClient("/oauth2/test") - @ApiDoc(desc = "oauth2/test") - public OAuth2DTO testRestFul(final HttpServletRequest request) { - final String token = request.getHeader("Authorization"); - final OAuth2DTO oAuth2DTO = new OAuth2DTO(); - oAuth2DTO.setToken(Objects.isNull(token) ? "no authorization" : token); - return oAuth2DTO; - } - - private OrderDTO build(final String id, final String name) { - final OrderDTO orderDTO = new OrderDTO(); - orderDTO.setId(id); - orderDTO.setName(name); - return orderDTO; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/UploadController.java b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/UploadController.java deleted file mode 100644 index 1d6d905..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/controller/UploadController.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -import java.util.Arrays; -import java.util.stream.Collectors; - -/** - * UploadController. - */ -@RestController -@RequestMapping("/upload") -@ShenyuSpringMvcClient("/upload") -@ApiModule(value = "upload") -public class UploadController { - - /** - * mvc uploadFile. - * @param file file - * @return response - */ - @PostMapping(value = "/singleFile") - @ApiDoc(desc = "singleFile") - public String singleFile(@RequestParam("file") final MultipartFile file) { - return file.getOriginalFilename(); - } - - /** - * mvc uploadFiles. - * @param files files. - * @return response - */ - @PostMapping(value = "/files") - @ApiDoc(desc = "files") - public String files(@RequestParam("files") final MultipartFile[] files) { - return Arrays.stream(files).map(MultipartFile::getOriginalFilename).collect(Collectors.joining(",")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/OAuth2DTO.java b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/OAuth2DTO.java deleted file mode 100644 index 522c894..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/OAuth2DTO.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.dto; - -/** - * The type OAuth Authorization dto. - */ -public class OAuth2DTO { - - /** - * oauth token. - */ - private String token; - - /** - * Get token. - * - * @return token - */ - public String getToken() { - return token; - } - - /** - * Set token. - * - * @param token token - */ - public void setToken(final String token) { - this.token = token; - } - - @Override - public String toString() { - return "OAuth2DTO{" + "token='" + token + '\'' + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/OrderDTO.java b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/OrderDTO.java deleted file mode 100644 index 9b56fbc..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/OrderDTO.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.dto; - -import java.io.Serializable; -import java.util.StringJoiner; - -/** - * The type Order dto. - */ -public class OrderDTO implements Serializable { - - private static final long serialVersionUID = 852118216655025857L; - - private String id; - - private String name; - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - @Override - public String toString() { - return new StringJoiner(", ", OrderDTO.class.getSimpleName() + "[", "]") - .add("id='" + id + "'") - .add("name='" + name + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/UserDTO.java b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/UserDTO.java deleted file mode 100644 index 8e6eeb7..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/dto/UserDTO.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.dto; - -import java.util.StringJoiner; - -/** - * The type User dto. - */ -public class UserDTO { - - /** - * user id. - */ - private String userId; - - /** - * username. - */ - private String userName; - - /** - * Get userId. - * - * @return userId - */ - public String getUserId() { - return userId; - } - - /** - * Set userId. - * - * @param userId userId - */ - public void setUserId(final String userId) { - this.userId = userId; - } - - /** - * Get userName. - * - * @return userName - */ - public String getUserName() { - return userName; - } - - /** - * Set userName. - * - * @param userName userName - */ - public void setUserName(final String userName) { - this.userName = userName; - } - - @Override - public String toString() { - return new StringJoiner(", ", UserDTO.class.getSimpleName() + "[", "]") - .add("userId='" + userId + "'") - .add("userName='" + userName + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/result/ResultBean.java b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/result/ResultBean.java deleted file mode 100644 index c4d7026..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/java/org/apache/shenyu/examples/springmvc/result/ResultBean.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.result; - -/** - * ResultBean. - */ -public class ResultBean { - - /** - * code describe status. - */ - private Integer code; - - /** - * msg describe result. - */ - private String msg; - - /** - * result data. - */ - private Object data; - - public ResultBean() { - } - - public ResultBean(final Integer code, final String msg, final Object data) { - this.code = code; - this.msg = msg; - this.data = data; - } - - /** - * Get code. - * - * @return code - */ - public Integer getCode() { - return code; - } - - /** - * Set code. - * - * @param code code - */ - public void setCode(final Integer code) { - this.code = code; - } - - /** - * Get msg. - * - * @return msg - */ - public String getMsg() { - return msg; - } - - /** - * Set msg. - * - * @param msg msg - */ - public void setMsg(final String msg) { - this.msg = msg; - } - - /** - * Get data. - * - * @return data - */ - public Object getData() { - return data; - } - - /** - * Set data. - * - * @param data data - */ - public void setData(final Object data) { - this.data = data; - } - - @Override - public String toString() { - return "ResultBean{" + "code=" + code + ", msg='" + msg + '\'' + ", data=" + data + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/application.properties b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/application.properties deleted file mode 100644 index 858afe6..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/application.properties +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server.port=8290 -server.address=0.0.0.0 -server.servlet.context-path=/ -server.tomcat.max-swallow-size=100MB -spring.main.allow-bean-definition-overriding=true -spring.servlet.multipart.max-file-size=100MB -spring.servlet.multipart.max-request-size=100MB diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/context/shenyu.xml b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/context/shenyu.xml deleted file mode 100644 index 52c556e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/context/shenyu.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/spring-mvc.xml b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/spring-mvc.xml deleted file mode 100644 index 77b3313..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/resources/spring-mvc.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - application/json;charset=UTF-8 - application/x-www-form-urlencoded;charset=UTF-8 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/webapp/WEB-INF/web.xml b/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 84f2333..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc-tomcat/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - org.springframework.web.util.IntrospectorCleanupListener - - - - encodingFilter - org.springframework.web.filter.CharacterEncodingFilter - - encoding - UTF-8 - - - forceEncoding - true - - - - encodingFilter - /* - - - - dispatcherServlet - org.springframework.web.servlet.DispatcherServlet - - contextConfigLocation - classpath:spring-mvc.xml - - 1 - - - dispatcherServlet - / - - diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/Dockerfile b/shenyu-java-examples/shenyu-java-examples-springmvc/Dockerfile deleted file mode 100644 index 1251fe8..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-examples-springmvc -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8289 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/pom.xml b/shenyu-java-examples/shenyu-java-examples-springmvc/pom.xml deleted file mode 100644 index bb4d442..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-springmvc - - - UTF-8 - 1.8 - 1.8 - - - - - org.apache.shenyu - shenyu-client-java-springmvc - ${project.version} - - - - org.springframework.boot - spring-boot-starter-web - - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - - - shenyu-examples-springmvc - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.springmvc.TestSpringMvcApplication - true - - - - - - - - example - - shenyu-examples-springmvc - shenyu-examples-springmvc - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-examples-springmvc - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/http/http-test-api-local.http b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/http/http-test-api-local.http deleted file mode 100644 index fbe9408..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/http/http-test-api-local.http +++ /dev/null @@ -1,123 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### orderSave -POST http://localhost:8289/order/save -Accept: application/json -Content-Type: application/json - -{ - "id": 123, - "name": "order" -} - -### findById -GET http://localhost:8289/order/findById?id=123 -Accept: application/json -Content-Type: application/json - -### path -GET http://localhost:8289/order/path/123/hahah -Accept: application/json -Content-Type: application/json - -### path -GET http://localhost:8289/order/path/123/name -Accept: application/json -Content-Type: application/json - -### oauth2 -GET http://localhost:8289/order/oauth2/test -Accept: application/json -Content-Type: application/json -Authorization:AuthorizationContext - -### payment -POST http://localhost:8289/test/payment -Accept: application/json -Content-Type: application/json - -{ - "userId": 123, - "userName": "name" -} - -### findByUserId -GET http://localhost:8289/test/findByUserId?userId=123 -Accept: application/json -Content-Type: application/json - -### path -GET http://localhost:8289/test/path/123?name=haha -Accept: application/json -Content-Type: application/json - -### path -GET http://localhost:8289/test/path/123/name -Accept: application/json -Content-Type: application/json - -### waf pass -POST http://localhost:8289/test/waf/pass -Accept: application/json -Content-Type: application/json - -### waf deny -POST http://localhost:8289/test/waf/deny -Accept: application/json -Content-Type: application/json - -### request parameter pass -GET http://localhost:8289/test/request/parameter/pass?requestParameter=test -Accept: application/json -Content-Type: application/json - - -### example singleFile -POST http://localhost:8289/upload/singleFile -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt" -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - - -### example files -POST http://localhost:8289/upload/files -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="1.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="2.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/2.txt - ---WebAppBoundary-- \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/http/http-test-api.http b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/http/http-test-api.http deleted file mode 100644 index e36f006..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/http/http-test-api.http +++ /dev/null @@ -1,123 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -### shengyu getway proxy orderSave -POST http://localhost:9195/mvc/order/save -Accept: application/json -Content-Type: application/json - -{ - "id": 123, - "name": "order" -} - -### shengyu getway proxy orderSave -GET http://localhost:9195/mvc/order/findById?id=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/mvc/order/path/123/hahah -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/mvc/order/path/123/name -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy oauth2 -GET http://localhost:9195/mvc/order/oauth2/test -Accept: application/json -Content-Type: application/json -Authorization:AuthorizationContext - -### shengyu getway proxy payment -POST http://localhost:9195/mvc/test/payment -Accept: application/json -Content-Type: application/json - -{ - "userId": 123, - "userName": "name" -} - -### shengyu getway proxy findByUserId -GET http://localhost:9195/mvc/test/findByUserId?userId=123 -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/mvc/test/path/123?name=haha -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy path -GET http://localhost:9195/mvc/test/path/123/name -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy waf pass -POST http://localhost:9195/mvc/test/waf/pass -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy waf deny -POST http://localhost:9195/mvc/test/waf/deny -Accept: application/json -Content-Type: application/json - -### shengyu getway proxy request parameter pass -GET http://localhost:9195/mvc/test/request/parameter/pass?requestParameter=test -Accept: application/json -Content-Type: application/json - - -### shengyu getway proxy example singleFile -POST http://localhost:9195/mvc/upload/singleFile -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="file"; filename="1.txt" -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - - -### shengyu getway proxy example files -POST http://localhost:9195/mvc/upload/files -Cache-Control: no-cache -Content-Type: multipart/form-data; boundary=WebAppBoundary - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="1.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/1.txt - ---WebAppBoundary-- - ---WebAppBoundary -Content-Disposition: form-data; name="files"; filename="2.txt"; -Content-Type: multipart/form-data -# you need to change your local path -< /Users/Code/shenyu/shenyu-examples/shenyu-examples-common/src/main/resources/2.txt - ---WebAppBoundary-- \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/TestSpringMvcApplication.java b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/TestSpringMvcApplication.java deleted file mode 100644 index d2ed937..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/TestSpringMvcApplication.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ImportResource; - -/** - * TestSpringMvcApplication. - */ -@SpringBootApplication -@ImportResource(locations = {"classpath:context/shenyu.xml"}) -public class TestSpringMvcApplication { - - /** - * Main Entrance. - * - * @param args startup arguments - */ - public static void main(final String[] args) { - SpringApplication.run(TestSpringMvcApplication.class, args); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/HttpTestController.java b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/HttpTestController.java deleted file mode 100644 index 553de52..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/HttpTestController.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.controller; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.springmvc.dto.UserDTO; -import org.apache.shenyu.examples.springmvc.result.ResultBean; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * TestController. - */ -@RestController -@RequestMapping("/test") -@ShenyuSpringMvcClient("/test/**") -public class HttpTestController { - - /** - * Post user dto. - * - * @param userDTO the user dto - * @return the user dto - */ - @PostMapping("/payment") - public UserDTO post(@RequestBody final UserDTO userDTO) { - return userDTO; - } - - /** - * Find by user id string. - * - * @param userId the user id - * @return the string - */ - @GetMapping("/findByUserId") - public UserDTO findByUserId(@RequestParam("userId") final String userId) { - return buildUser(userId, "hello world"); - } - - /** - * Find by page user dto. - * - * @param keyword the keyword - * @param page the page - * @param pageSize the page size - * @return the user dto - */ - @GetMapping("/findByPage") - public UserDTO findByPage(final String keyword, final Integer page, final Integer pageSize) { - return buildUser(keyword, "hello world keyword is" + keyword + " page is" + page + " pageSize is" + pageSize); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @GetMapping("/path/{id}") - public UserDTO getPathVariable(@PathVariable("id") final String id, @RequestParam("name") final String name) { - return buildUser(id, name); - } - - - /** - * Test rest ful string. - * - * @param id the id - * @return the string - */ - @Log - @GetMapping("/path/{id}/name") - public UserDTO testRestFul(@PathVariable("id") final String id) { - return buildUser(id, "hello world"); - } - - - /** - * Put path variable and body string. - * - * @param id the id - * @param userDTO the user dto - * @return the string - */ - @PutMapping("/putPathBody/{id}") - public UserDTO putPathVariableAndBody(@PathVariable("id") final String id, @RequestBody final UserDTO userDTO) { - userDTO.setUserId(id); - userDTO.setUserName("hello world"); - return userDTO; - } - - /** - * the waf pass. - * - * @return response. result bean - */ - @PostMapping("/waf/pass") - public ResultBean pass() { - final ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - return response; - } - - /** - * the waf deny. - * - * @return response. result bean - */ - @PostMapping("/waf/deny") - public ResultBean deny() { - final ResultBean response = new ResultBean(); - response.setCode(403); - response.setMsg("deny"); - return response; - } - - /** - * request Pass. - * - * @param requestParameter the requestParameter. - * @return ResultBean result bean - */ - @GetMapping("/request/parameter/pass") - public ResultBean requestParameter(@RequestParam("requestParameter") final String requestParameter) { - final ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - final Map param = new HashMap<>(); - param.put("requestParameter", requestParameter); - response.setData(param); - return response; - } - - /** - * request Pass. - * - * @param requestHeader the requestHeader. - * @return ResultBean result bean - */ - @GetMapping("/request/header/pass") - public ResultBean requestHeader(@RequestHeader("requestHeader") final String requestHeader) { - final ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - final Map param = new HashMap<>(); - param.put("requestHeader", requestHeader); - response.setData(param); - return response; - } - - /** - * request Pass. - * - * @param cookie the cookie. - * @return ResultBean result bean - */ - @GetMapping("/request/cookie/pass") - public ResultBean requestCookie(@CookieValue("cookie") final String cookie) { - final ResultBean response = new ResultBean(); - response.setCode(200); - response.setMsg("pass"); - - final Map param = new HashMap<>(); - param.put("cookie", cookie); - response.setData(param); - return response; - } - - /** - * post sentinel. - * - * @return response. result bean - */ - @PostMapping("/sentinel/pass") - public ResultBean sentinelPass() { - return pass(); - } - - private UserDTO buildUser(final String id, final String name) { - final UserDTO userDTO = new UserDTO(); - userDTO.setUserId(id); - userDTO.setUserName(name); - return userDTO; - } -} - diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/OrderController.java b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/OrderController.java deleted file mode 100644 index cba3e59..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/OrderController.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuGetMapping; -import org.apache.shenyu.client.springmvc.annotation.ShenyuPostMapping; -import org.apache.shenyu.client.springmvc.annotation.ShenyuRequestMapping; -import org.apache.shenyu.examples.springmvc.dto.OAuth2DTO; -import org.apache.shenyu.examples.springmvc.dto.OrderDTO; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.util.Objects; - -/** - * TestController. - */ -@RestController -@ShenyuRequestMapping("/order") -@ApiModule(value = "order") -public class OrderController { - - /** - * Save order dto. - * - * @param orderDTO the order dto - * @return the order dto - */ - @ShenyuPostMapping("/save") - @ApiDoc(desc = "save") - public OrderDTO save(@RequestBody final OrderDTO orderDTO) { - orderDTO.setName("hello world save order"); - return orderDTO; - } - - /** - * Find by id order dto. - * - * @param id the id - * @return the order dto - */ - @ShenyuGetMapping("/findById") - @ApiDoc(desc = "findById") - public OrderDTO findById(@RequestParam("id") final String id) { - return build(id, "hello world findById"); - } - - /** - * Gets path variable. - * - * @param id the id - * @param name the name - * @return the path variable - */ - @ShenyuGetMapping("/path/{id}/{name}") - @ApiDoc(desc = "path/{id}/{name}") - public OrderDTO getPathVariable(@PathVariable("id") final String id, @PathVariable("name") final String name) { - return build(id, "hello world restful: " + name); - } - - /** - * Test rest ful order dto. - * - * @param id the id - * @return the order dto - */ - @ShenyuGetMapping("/path/{id}/name") - @ApiDoc(desc = "path/{id}/name") - public OrderDTO testRestFul(@PathVariable("id") final String id) { - return build(id, "hello world restful inline " + id); - } - - /** - * Test oauth2 request. - * @param request request with the oauth2 headers - * @return the oauth2 dto - */ - @ShenyuGetMapping("/oauth2/test") - @ApiDoc(desc = "oauth2/test") - public OAuth2DTO testRestFul(final HttpServletRequest request) { - final String token = request.getHeader("Authorization"); - final OAuth2DTO oAuth2DTO = new OAuth2DTO(); - oAuth2DTO.setToken(Objects.isNull(token) ? "no authorization" : token); - return oAuth2DTO; - } - - private OrderDTO build(final String id, final String name) { - final OrderDTO orderDTO = new OrderDTO(); - orderDTO.setId(id); - orderDTO.setName(name); - return orderDTO; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/UploadController.java b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/UploadController.java deleted file mode 100644 index 5b242bd..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/controller/UploadController.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.controller; - -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -import java.util.Arrays; -import java.util.stream.Collectors; - -/** - * UploadController. - */ -@RestController -@RequestMapping("/upload") -@ShenyuSpringMvcClient("/upload") -@ApiModule(value = "upload") -public class UploadController { - - /** - * mvc upload single file. - * @param file file. - * @return response - */ - @PostMapping(value = "/singleFile") - @ApiDoc(desc = "singleFile") - public String singleFile(@RequestParam("file") final MultipartFile file) { - return file.getOriginalFilename(); - } - - /** - * mvc upload multiple files. - * @param files files. - * @return response - */ - @PostMapping(value = "/files") - @ApiDoc(desc = "files") - public String files(@RequestParam("files") final MultipartFile[] files) { - return Arrays.stream(files).map(MultipartFile::getOriginalFilename).collect(Collectors.joining(",")); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/OAuth2DTO.java b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/OAuth2DTO.java deleted file mode 100644 index 522c894..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/OAuth2DTO.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.dto; - -/** - * The type OAuth Authorization dto. - */ -public class OAuth2DTO { - - /** - * oauth token. - */ - private String token; - - /** - * Get token. - * - * @return token - */ - public String getToken() { - return token; - } - - /** - * Set token. - * - * @param token token - */ - public void setToken(final String token) { - this.token = token; - } - - @Override - public String toString() { - return "OAuth2DTO{" + "token='" + token + '\'' + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/OrderDTO.java b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/OrderDTO.java deleted file mode 100644 index 9b56fbc..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/OrderDTO.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.dto; - -import java.io.Serializable; -import java.util.StringJoiner; - -/** - * The type Order dto. - */ -public class OrderDTO implements Serializable { - - private static final long serialVersionUID = 852118216655025857L; - - private String id; - - private String name; - - /** - * Get id. - * - * @return id - */ - public String getId() { - return id; - } - - /** - * Set id. - * - * @param id id - */ - public void setId(final String id) { - this.id = id; - } - - /** - * Get name. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Set name. - * - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - @Override - public String toString() { - return new StringJoiner(", ", OrderDTO.class.getSimpleName() + "[", "]") - .add("id='" + id + "'") - .add("name='" + name + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/UserDTO.java b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/UserDTO.java deleted file mode 100644 index 3f0fb32..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/dto/UserDTO.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.dto; - -import java.util.StringJoiner; - -/** - * The type User dto. - */ -public class UserDTO { - - /** - * user id. - */ - private String userId; - - /** - * username. - */ - private String userName; - - /** - * Get userId. - * - * @return userId - */ - public String getUserId() { - return userId; - } - - /** - * Set userId. - * - * @param userId userId - */ - public void setUserId(final String userId) { - this.userId = userId; - } - - /** - * Get userName. - * - * @return userName - */ - public String getUserName() { - return userName; - } - - /** - * Set userName. - * - * @param userName userName - */ - public void setUserName(final String userName) { - this.userName = userName; - } - - @Override - public String toString() { - return new StringJoiner(", ", UserDTO.class.getSimpleName() + "[", "]") - .add("userId='" + userId + "'") - .add("userName='" + userName + "'") - .toString(); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/result/ResultBean.java b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/result/ResultBean.java deleted file mode 100644 index c4d7026..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/java/org/apache/shenyu/examples/springmvc/result/ResultBean.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.springmvc.result; - -/** - * ResultBean. - */ -public class ResultBean { - - /** - * code describe status. - */ - private Integer code; - - /** - * msg describe result. - */ - private String msg; - - /** - * result data. - */ - private Object data; - - public ResultBean() { - } - - public ResultBean(final Integer code, final String msg, final Object data) { - this.code = code; - this.msg = msg; - this.data = data; - } - - /** - * Get code. - * - * @return code - */ - public Integer getCode() { - return code; - } - - /** - * Set code. - * - * @param code code - */ - public void setCode(final Integer code) { - this.code = code; - } - - /** - * Get msg. - * - * @return msg - */ - public String getMsg() { - return msg; - } - - /** - * Set msg. - * - * @param msg msg - */ - public void setMsg(final String msg) { - this.msg = msg; - } - - /** - * Get data. - * - * @return data - */ - public Object getData() { - return data; - } - - /** - * Set data. - * - * @param data data - */ - public void setData(final Object data) { - this.data = data; - } - - @Override - public String toString() { - return "ResultBean{" + "code=" + code + ", msg='" + msg + '\'' + ", data=" + data + '}'; - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/resources/application.yml deleted file mode 100644 index 9fb5a6a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/resources/application.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8289 - address: 0.0.0.0 - servlet: - context-path: / - tomcat: - max-http-form-post-size: 100MB -spring: - main: - allow-bean-definition-overriding: true - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/resources/context/shenyu.xml b/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/resources/context/shenyu.xml deleted file mode 100644 index ba85c0a..0000000 --- a/shenyu-java-examples/shenyu-java-examples-springmvc/src/main/resources/context/shenyu.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-tars/README.md b/shenyu-java-examples/shenyu-java-examples-tars/README.md deleted file mode 100644 index 224959b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Shenyu Example Tars -*** -## Run -1.set vm options : - -```text --Dconfig=D:\Code\Java\shenyu\shenyu-examples\shenyu-examples-tars\src\main\resources\ShenyuExampleServer.ShenyuExampleApp.config.conf -``` - -2.run ShenyuTestTarsApplication \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-tars/pom.xml b/shenyu-java-examples/shenyu-java-examples-tars/pom.xml deleted file mode 100644 index 16bc57e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/pom.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-tars - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-web - - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-tars - ${project.version} - - - - - - - - - - - - - com.tencent.tars - tars-spring-boot-starter - 1.7.2 - - - org.springframework.boot - spring-boot-dependencies - - - - - - - - - com.tencent.tars - tars-maven-plugin - 1.7.2 - - - - - ${basedir}/src/main/resources/test.tars - - - UTF-8 - - true - - UTF-8 - - ${basedir}/src/main/java - - org.apache.shenyu.examples.tars.servant. - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - - - conf/ - - - - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.tars.ShenyuTestTarsApplication - - - - - repackage - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/http/tars-test-api.http b/shenyu-java-examples/shenyu-java-examples-tars/src/main/http/tars-test-api.http deleted file mode 100644 index 665445e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/http/tars-test-api.http +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - -### shengyu getway proxy hello -GET http://localhost:9195/tars/hello -Accept: application/json -Content-Type: application/json - -{ - "no": 123, - "name": "order" -} - -### shengyu getway proxy helloInt -GET http://localhost:9195/tars/helloInt -Accept: application/json -Content-Type: application/json - -{ - "no": 123, - "name": "order" -} diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/ShenyuTestTarsApplication.java b/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/ShenyuTestTarsApplication.java deleted file mode 100644 index 9a92621..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/ShenyuTestTarsApplication.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.tars; - -import com.qq.tars.spring.annotation.EnableTarsServer; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * ShenyuTestTarsApplication. - */ -@SpringBootApplication -@EnableTarsServer -public class ShenyuTestTarsApplication { - - /** - * main. - * - * @param args args - */ - public static void main(final String[] args) { - SpringApplication.run(ShenyuTestTarsApplication.class, args); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/HelloServant.java b/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/HelloServant.java deleted file mode 100644 index 38d22eb..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/HelloServant.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -// ********************************************************************** -// This file was generated by a TARS parser! -// TARS version 1.7.2. -// ********************************************************************** - -package org.apache.shenyu.examples.tars.servant.testapp; - -import com.qq.tars.protocol.annotation.Servant; -import com.qq.tars.protocol.tars.annotation.TarsMethodParameter; - -@Servant -public interface HelloServant { - - /** - * Test hello for tar. - * @param no a param with name no - * @param name a param with name name - * @return result - */ - String hello(@TarsMethodParameter(name = "no") int no, @TarsMethodParameter(name = "name") String name); - - /** - * Test hello int for tar. - * @param no a param with name no - * @param name a param with name name - * @return result - */ - int helloInt(@TarsMethodParameter(name = "no") int no, @TarsMethodParameter(name = "name") String name); - -} diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/OrderServant.java b/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/OrderServant.java deleted file mode 100644 index d843d12..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/OrderServant.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -// ********************************************************************** -// This file was generated by a TARS parser! -// TARS version 1.7.2. -// ********************************************************************** - -package org.apache.shenyu.examples.tars.servant.testapp; - -import com.qq.tars.protocol.annotation.Servant; -import com.qq.tars.protocol.tars.annotation.TarsMethodParameter; - -@Servant -public interface OrderServant { - - /** - * Test hello for tar. - * @param no a param with name no - * @param name a param with name name - * @return result - */ - String hello(@TarsMethodParameter(name = "no") int no, @TarsMethodParameter(name = "name") String name); - - /** - * Test hello int for tar. - * @param no a param with name no - * @param name a param with name name - * @return result - */ - int helloInt(@TarsMethodParameter(name = "no") int no, @TarsMethodParameter(name = "name") String name); - -} diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/UserServant.java b/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/UserServant.java deleted file mode 100644 index 07c8c00..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/UserServant.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -// ********************************************************************** -// This file was generated by a TARS parser! -// TARS version 1.7.2. -// ********************************************************************** - -package org.apache.shenyu.examples.tars.servant.testapp; - -import com.qq.tars.protocol.annotation.Servant; -import com.qq.tars.protocol.tars.annotation.TarsMethodParameter; - -@Servant -public interface UserServant { - - /** - * Test hello for tar. - * @param no a param with name no - * @param name a param with name name - * @return result - */ - String hello(@TarsMethodParameter(name = "no") int no, @TarsMethodParameter(name = "name") String name); - - /** - * Test hello int for tar. - * @param no a param with name no - * @param name a param with name name - * @return result - */ - int helloInt(@TarsMethodParameter(name = "no") int no, @TarsMethodParameter(name = "name") String name); - -} diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/HelloServantImpl.java b/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/HelloServantImpl.java deleted file mode 100644 index 42c16b5..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/HelloServantImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.tars.servant.testapp.impl; - -import com.qq.tars.spring.annotation.TarsServant; -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsClient; -import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsService; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.tars.servant.testapp.HelloServant; - -@TarsServant("HelloObj") -@ShenyuTarsService(serviceName = "ShenyuExampleServer.ShenyuExampleApp.HelloObj") -@ApiModule(value = "HelloObj") -public class HelloServantImpl implements HelloServant { - - @Override - @ShenyuTarsClient("/hello") - @ApiDoc(desc = "hello") - public String hello(final int no, final String name) { - return String.format("hello no=%s, name=%s, time=%s", no, name, System.currentTimeMillis()); - } - - @Log - @Override - @ShenyuTarsClient("/helloInt") - @ApiDoc(desc = "helloInt") - public int helloInt(final int no, final String name) { - return 1; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/OrderServantImpl.java b/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/OrderServantImpl.java deleted file mode 100644 index f39a711..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/OrderServantImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.tars.servant.testapp.impl; - -import com.qq.tars.spring.annotation.TarsServant; -import org.apache.shenyu.client.apidocs.annotations.ApiDoc; -import org.apache.shenyu.client.apidocs.annotations.ApiModule; -import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsClient; -import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsService; -import org.apache.shenyu.examples.tars.servant.testapp.OrderServant; - -@TarsServant("OrderObj") -@ShenyuTarsClient("/order") -@ShenyuTarsService(serviceName = "ShenyuExampleServer.ShenyuExampleApp.OrderObj") -@ApiModule(value = "order") -public class OrderServantImpl implements OrderServant { - - @Override - @ShenyuTarsClient("/hello") - @ApiDoc(desc = "hello") - public String hello(final int no, final String name) { - return String.format("hello no=%s, name=%s, time=%s", no, name, System.currentTimeMillis()); - } - - @Override - @ShenyuTarsClient("/helloInt") - @ApiDoc(desc = "helloInt") - public int helloInt(final int no, final String name) { - return 1; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/UserServantImpl.java b/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/UserServantImpl.java deleted file mode 100644 index f204d77..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/java/org/apache/shenyu/examples/tars/servant/testapp/impl/UserServantImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.tars.servant.testapp.impl; - -import com.qq.tars.spring.annotation.TarsServant; -import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsClient; -import org.apache.shenyu.client.tars.common.annotation.ShenyuTarsService; -import org.apache.shenyu.examples.tars.servant.testapp.UserServant; - -@TarsServant("UserObj") -@ShenyuTarsClient("/user/**") -@ShenyuTarsService(serviceName = "ShenyuExampleServer.ShenyuExampleApp.UserObj") -public class UserServantImpl implements UserServant { - - @Override - public String hello(final int no, final String name) { - return String.format("hello no=%s, name=%s, time=%s", no, name, System.currentTimeMillis()); - } - - @Override - public int helloInt(final int no, final String name) { - return 1; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/ShenyuExampleServer.ShenyuExampleApp.config.conf b/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/ShenyuExampleServer.ShenyuExampleApp.config.conf deleted file mode 100644 index e96e6eb..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/ShenyuExampleServer.ShenyuExampleApp.config.conf +++ /dev/null @@ -1,97 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - - - enableset=n - setdivision=NULL - - node=tars.tarsnode.ServerObj@tcp -h 192.168.41.103 -p 19386 -t 60000 - lognum=10 - logLevel=DEBUG - deactivating-timeout=3000 - app=ShenyuExampleServer - server=ShenyuExampleApp - localip=192.168.41.103 - local=tcp -h 127.0.0.1 -p 21715 -t 3000 - basepath=/usr/local/app/tars/tarsnode/data/ShenyuExampleServer.ShenyuExampleApp/bin/ - datapath=/usr/local/app/tars/tarsnode/data/ShenyuExampleServer.ShenyuExampleApp/data/ - logpath=/usr/local/app/tars/app_log/ - loglevel=DEBUG - logsize=15M - log=tars.tarslog.LogObj - config=tars.tarsconfig.ConfigObj - notify=tars.tarsnotify.NotifyObj - classpath=/usr/local/app/tars/tarsnode/data/ShenyuExampleServer.ShenyuExampleApp/bin//conf:/usr/local/app/tars/tarsnode/data/ShenyuExampleServer.ShenyuExampleApp/bin//WEB-INF/classes:/usr/local/app/tars/tarsnode/data/ShenyuExampleServer.ShenyuExampleApp/bin//WEB-INF/lib - jvmparams=-Dcom.sun.management.jmxremote.ssl\=false -Dcom.sun.management.jmxremote.authenticate\=false -Xms2g -Xmx2g -Xmn1g -Xss1024k -XX:CMSInitiatingOccupancyFraction\=60 -XX:+CMSParallelRemarkEnabled -XX:+CMSScavengeBeforeRemark -verbosegc -XX:+PrintGCDetails -XX:ErrorFile\=/usr/local/app/tars/app_log/ShenyuExampleServer/ShenyuExampleApp/jvm_error.log - sessiontimeout=120000 - sessioncheckinterval=60000 - tcpnodelay=true - udpbuffersize=8192 - charsetname=UTF-8 - backupfiles=conf - packageFormat=jar - mainclass=-jar /usr/local/app/tars/tarsnode/data/ShenyuExampleServer.ShenyuExampleApp/bin/ShenyuExampleServer.ShenyuExampleApp.jar - - allow - endpoint=tcp -h 192.168.41.103 -p 21715 -t 60000 - handlegroup=ShenyuExampleServer.ShenyuExampleApp.HelloObjAdapter - maxconns=100000 - protocol=tars - queuecap=50000 - queuetimeout=20000 - servant=ShenyuExampleServer.ShenyuExampleApp.HelloObj - threads=5 - - - allow - endpoint=tcp -h 192.168.41.103 -p 21716 -t 60000 - handlegroup=ShenyuExampleServer.ShenyuExampleApp.OrderObjAdapter - maxconns=100000 - protocol=tars - queuecap=50000 - queuetimeout=20000 - servant=ShenyuExampleServer.ShenyuExampleApp.OrderObj - threads=5 - - - allow - endpoint=tcp -h 192.168.41.103 -p 21717 -t 60000 - handlegroup=ShenyuExampleServer.ShenyuExampleApp.UserObjAdapter - maxconns=100000 - protocol=tars - queuecap=50000 - queuetimeout=20000 - servant=ShenyuExampleServer.ShenyuExampleApp.UserObj - threads=5 - - - - asyncthread=3 - locator=tars.tarsregistry.QueryObj@tcp -h 192.168.41.103 -p 17890 - sync-invoke-timeout=20000 - async-invoke-timeout=20000 - refresh-endpoint-interval=60000 - stat=tars.tarsstat.StatObj - property=tars.tarsproperty.PropertyObj - report-interval=60000 - modulename=ShenyuExampleServer.ShenyuExampleApp - sample-rate=100000 - max-sample-count=50 - - - diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/application.yml deleted file mode 100644 index cf9d4f6..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/application.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 55290 - servlet: - context-path: / - address: 0.0.0.0 - -spring: - application: - name: tars-test - -logging: - level: - root: info - org.apache.shenyu: debug - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - tars: - props: - contextPath: /tars - appName: tars - port: 21715 - host: 192.168.41.103 \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/test.tars b/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/test.tars deleted file mode 100644 index d7927f1..0000000 --- a/shenyu-java-examples/shenyu-java-examples-tars/src/main/resources/test.tars +++ /dev/null @@ -1,35 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -module TestApp -{ - interface Hello - { - string hello(int no, string name); - int helloInt(int no, string name); - }; - interface Order - { - string hello(int no, string name); - int helloInt(int no, string name); - }; - interface User - { - string hello(int no, string name); - int helloInt(int no, string name); - }; -}; diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/pom.xml b/shenyu-java-examples/shenyu-java-examples-websocket/pom.xml deleted file mode 100644 index 806a46b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-java-examples - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-java-examples-websocket - pom - - - shenyu-example-spring-annotation-websocket - shenyu-example-spring-native-websocket - shenyu-example-spring-reactive-websocket - - - - - - org.apache.shenyu - shenyu-java-examples-common - ${project.version} - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/Dockerfile b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/Dockerfile deleted file mode 100644 index 6bac3df..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-example-spring-annotation-websocket -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8001 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/k8s/ingress.yml b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/k8s/ingress.yml deleted file mode 100644 index daa4e55..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/k8s/ingress.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - annotations: - kubernetes.io/ingress.class: shenyu - shenyu.apache.org/loadbalancer: random - shenyu.apache.org/plugin-web-socket-enabled : "true" - name: demo-ingress -spec: - rules: - - http: - paths: - - backend: - service: - name: shenyu-example-spring-annotation-websocket - port: - number: 8001 - path: /** - pathType: ImplementationSpecific diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/k8s/shenyu-example-spring-annotation-websocket.yml b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/k8s/shenyu-example-spring-annotation-websocket.yml deleted file mode 100644 index 0767297..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/k8s/shenyu-example-spring-annotation-websocket.yml +++ /dev/null @@ -1,79 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: shenyu-example-spring-annotation-websocket-deployment - labels: - app: shenyu-example-spring-annotation-websocket - all: shenyu-example-spring-annotation-websocket -spec: - replicas: 1 - selector: - matchLabels: - app: shenyu-example-spring-annotation-websocket - all: shenyu-example-spring-annotation-websocket - strategy: {} - template: - metadata: - labels: - app: shenyu-example-spring-annotation-websocket - all: shenyu-example-spring-annotation-websocket - spec: - containers: - - image: shenyu-example-spring-annotation-websocket - name: shenyu-example-spring-annotation-websocket - livenessProbe: - initialDelaySeconds: 30 - periodSeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 3 - exec: - command: - - /bin/sh - - "-c" - - wget -q -O - http://localhost:8001/actuator/health | grep UP || exit 1 - env: - - name: shenyu.register.serverLists - value: http://shenyu-admin:9095 - ports: - - containerPort: 8001 - imagePullPolicy: IfNotPresent - restartPolicy: Always -status: {} - ---- -apiVersion: v1 -kind: Service -metadata: - name: shenyu-example-spring-annotation-websocket - labels: - app: shenyu-example-spring-annotation-websocket - all: shenyu-example-spring-annotation-websocket -spec: - selector: - app: shenyu-example-spring-annotation-websocket - all: shenyu-example-spring-annotation-websocket - type: NodePort - ports: - - name: "8001" - port: 8001 - targetPort: 8001 - nodePort: 31188 -status: - loadBalancer: {} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/pom.xml b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/pom.xml deleted file mode 100644 index 248757e..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - shenyu-java-examples-websocket - org.apache.shenyu - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-example-spring-annotation-websocket - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-spring-websocket - ${project.version} - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-websocket - - - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - - - shenyu-example-spring-annotation-websocket - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.websocket.TestAnnotationWebsocketApplication - true - - - - - - - - example - - shenyu-example-spring-annotation-websocket - shenyu-example-spring-annotation-websocket - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-example-spring-annotation-websocket - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestAnnotationWebsocketApplication.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestAnnotationWebsocketApplication.java deleted file mode 100644 index f0d8f93..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestAnnotationWebsocketApplication.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.web.socket.WebSocketSession; - -import java.util.HashMap; -import java.util.Map; - -/** - * TestAnnotationWebsocketApplication. - */ -@SpringBootApplication -public class TestAnnotationWebsocketApplication { - - /** - * Main Entrance. - * @param args startup arguments - */ - public static void main(final String[] args) { - SpringApplication.run(TestAnnotationWebsocketApplication.class, args); - } - - /** - * Use map as simple cache. - * @return session cache - */ - @Bean - public Map onlineUserCache() { - return new HashMap<>(); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfig.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfig.java deleted file mode 100644 index 80c563c..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.config.annotation.EnableWebSocket; -import org.springframework.web.socket.server.standard.ServerEndpointExporter; - -/** - * The type Web socket configuration. - */ -@Configuration -@EnableWebSocket -public class WebSocketConfig { - - /** - * define a ServerEndpointExporter bean. - * @return ServerEndpointExporter - */ - @Bean - public ServerEndpointExporter serverEndpoint() { - return new ServerEndpointExporter(); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/service/SaveFile.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/service/SaveFile.java deleted file mode 100644 index f3b3e40..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/service/SaveFile.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.service; - -import java.util.Map; - -public interface SaveFile { - - /** - * according to the param to save files from content. - * @param content content - * @param param param - * @return success - */ - boolean saveFileFromBytes(byte[] content, Map param); -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/service/SaveFileImpl.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/service/SaveFileImpl.java deleted file mode 100644 index 33f9c51..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/service/SaveFileImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.service; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import java.io.File; -import java.io.FileOutputStream; -import java.util.Map; - -@Service -public class SaveFileImpl implements SaveFile { - - private static final Logger LOG = LoggerFactory.getLogger(SaveFileImpl.class); - - @Override - public boolean saveFileFromBytes(final byte[] b, final Map map) { - // get the file object from the map - File file = (File) map.get("file"); - // determine whether the path exists, create it if it does not exist - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } - - try (FileOutputStream fstream = new FileOutputStream(file, true)) { - fstream.write(b); - } catch (Exception e) { - LOG.error("saveFileFromBytes error", e); - return false; - } - return true; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/ws/UploadController.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/ws/UploadController.java deleted file mode 100644 index f008d42..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/ws/UploadController.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.ws; - -import org.apache.shenyu.client.spring.websocket.annotation.ShenyuServerEndpoint; -import org.apache.shenyu.examples.websocket.service.SaveFile; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; - -import javax.websocket.OnClose; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -@Controller -@ShenyuServerEndpoint("/upload") -public class UploadController { - - private static final Logger LOG = LoggerFactory.getLogger(UploadController.class); - - @Autowired - private SaveFile saveFile; - - /** - * connect successful. - * @param session session - */ - @OnOpen - public void onOpen(final Session session) { - LOG.info("connect successful"); - } - - /** - * connect close. - * @param session used for verify - */ - @OnClose - public void onClose(final Session session) { - LOG.info("connect1 closed"); - } - - /** - * receive message. - * @param message message content - * @param session session - */ - @OnMessage - public void onMessage(final String message, final Session session) { - try { - session.getBasicRemote().sendText("ok"); - } catch (IOException e) { - LOG.error("UpLoadController onMessage error", e); - } - } - - /** - * receive message of bytes. - * @param message message bytes - * @param session session - */ - @OnMessage - public void onMessage(final byte[] message, final Session session) { - File file = (File) session.getUserProperties().get("file"); - try { - Map param = new HashMap<>(2); - param.put("file", file); - saveFile.saveFileFromBytes(message, param); - session.getBasicRemote().sendText("ok"); - } catch (Exception e) { - LOG.error("UpLoadController onMessage", e); - } - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/ws/WsServerEndpoint.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/ws/WsServerEndpoint.java deleted file mode 100644 index 6a82457..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/java/org/apache/shenyu/examples/websocket/ws/WsServerEndpoint.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.ws; - -import org.apache.shenyu.client.spring.websocket.annotation.ShenyuServerEndpoint; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import javax.websocket.OnClose; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; - -/** - * WsServerEndpoint. - */ -@Component -@ShenyuServerEndpoint("/myWs") -public class WsServerEndpoint { - - private static final Logger LOG = LoggerFactory.getLogger(WsServerEndpoint.class); - - /** - * connect successful. - * @param session session - */ - @OnOpen - public void onOpen(final Session session) { - LOG.info("connect successful"); - } - - /** - * connect close. - * @param session session - */ - @OnClose - public void onClose(final Session session) { - LOG.info("connect closed"); - } - - /** - * received message. - * @param text message - * @return response - */ - @OnMessage - public String onMsg(final String text) { - return "server send message:" + text; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/resources/application.yml deleted file mode 100644 index 17c158c..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-annotation-websocket/src/main/resources/application.yml +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8001 - address: 0.0.0.0 - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - websocket: - props: - contextPath: /ws-annotation - appName: ws-annotation - port: 8001 - - # discovery: - # enable: true - # type: zookeeper - # serverList: 127.0.0.1:2181 - # registerPath: /shenyu/discovery/http_example - # props: - # baseSleepTimeMilliseconds: 1000 - # maxRetries: 4 - # maxSleepTimeMilliseconds: 5000 - # connectionTimeoutMilliseconds: 60000 - # sessionTimeoutMilliseconds: 8 - # type: etcd - # serverList: http://127.0.0.1:2379 - # registerPath: shenyu_discovery_http_example - # type: eureka - # serverList: http://127.0.0.1:8761/eureka - # registerPath: shenyu_discovery_http_example - -logging: - level: - root: info - org.springframework.boot: info - org.apache.ibatis: info - org.apache.shenyu.bonuspoint: info - org.apache.shenyu.lottery: debug - org.apache.shenyu: debug \ No newline at end of file diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/Dockerfile b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/Dockerfile deleted file mode 100644 index 2733edb..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -FROM eclipse-temurin:17-centos7 - -ENV APP_NAME shenyu-example-spring-native-websocket -ENV LOCAL_PATH /opt/${APP_NAME} - -RUN mkdir -p ${LOCAL_PATH} - -ADD target/${APP_NAME}.jar ${LOCAL_PATH} - -WORKDIR ${LOCAL_PATH} -EXPOSE 8848 - -CMD java -jar ${APP_NAME}.jar diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/pom.xml b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/pom.xml deleted file mode 100644 index e5f8e64..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/pom.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - shenyu-java-examples-websocket - org.apache.shenyu - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-example-spring-native-websocket - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-spring-websocket - ${project.version} - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-springmvc - ${project.version} - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-websocket - - - org.apache.shenyu - shenyu-java-examples-common - - - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - org.apache.shenyu - shenyu-discovery-zookeeper - 2.6.1 - - - - - shenyu-example-spring-native-websocket - - - org.springframework.boot - spring-boot-maven-plugin - - org.apache.shenyu.examples.websocket.TestNativeWebsocketApplication - true - - - - - - - - example - - shenyu-example-spring-native-websocket - shenyu-example-spring-native-websocket - latest - - - false - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - - - shenyu-example-spring-native-websocket - - ${project.basedir} - - - - - - - start - - build - - - - - - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestNativeWebsocketApplication.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestNativeWebsocketApplication.java deleted file mode 100644 index acf5cdb..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestNativeWebsocketApplication.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * TestNativeWebsocketApplication. - */ -@SpringBootApplication -public class TestNativeWebsocketApplication { - - /** - * Main Entrance. - * @param args startup arguments - */ - public static void main(final String[] args) { - SpringApplication.run(TestNativeWebsocketApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfig.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfig.java deleted file mode 100644 index ccd4b73..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfig.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.config; - -import org.apache.shenyu.examples.websocket.handler.HttpAuthHandler; -import org.apache.shenyu.examples.websocket.interceptor.WebSocketInterceptor; -import org.apache.shenyu.client.spring.websocket.annotation.ShenyuSpringWebSocketClient; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.config.annotation.EnableWebSocket; -import org.springframework.web.socket.config.annotation.WebSocketConfigurer; -import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; - -/** - * The type Web socket configuration. - * eg: ws://127.0.0.1:9195/ws-native/myWebSocket?token=shenyu - */ -@Configuration -@EnableWebSocket -@ShenyuSpringWebSocketClient("/myWebSocket") -public class WebSocketConfig implements WebSocketConfigurer { - - @Autowired - private HttpAuthHandler httpAuthHandler; - - @Autowired - private WebSocketInterceptor myInterceptor; - - @Override - public void registerWebSocketHandlers(final WebSocketHandlerRegistry registry) { - registry.addHandler(httpAuthHandler, "myWebSocket") - .addInterceptors(myInterceptor) - .setAllowedOrigins("*"); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WsSessionManager.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WsSessionManager.java deleted file mode 100644 index b42d0b3..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WsSessionManager.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.config; - -import java.util.Objects; -import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.socket.WebSocketSession; - -import java.io.IOException; -import java.util.concurrent.ConcurrentHashMap; - -/** - * WsSessionManager. - */ -@Slf4j -public class WsSessionManager { - - private static final Logger LOG = LoggerFactory.getLogger(WsSessionManager.class); - - /** - * save the connection session. - */ - private static final ConcurrentHashMap SESSION_POOL = new ConcurrentHashMap<>(); - - /** - * add session. - * @param key key - * @param session session - */ - public static void add(final String key, final WebSocketSession session) { - log.info("add session: {}", key); - SESSION_POOL.put(key, session); - } - - /** - * Deleting a session will return the deleted session. - * @param key key - * @return the session just removed - */ - public static WebSocketSession remove(final String key) { - log.info("remove session: {}", key); - return SESSION_POOL.remove(key); - } - - /** - * Delete and close the connection synchronously. - * @param key key - */ - public static void removeAndClose(final String key) { - WebSocketSession session = remove(key); - if (Objects.nonNull(session)) { - try { - session.close(); - } catch (IOException e) { - log.error("session:{} close failed !", key, e); - } - } - } - - /** - * Get session. - * @param key key - * @return session - */ - public static WebSocketSession get(final String key) { - return SESSION_POOL.get(key); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/controller/TestHttpController.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/controller/TestHttpController.java deleted file mode 100644 index 5488b35..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/controller/TestHttpController.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.controller; - -import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; -import org.apache.shenyu.examples.common.aop.Log; -import org.apache.shenyu.examples.websocket.config.WsSessionManager; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.socket.BinaryMessage; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; - -import java.io.IOException; -import java.util.Objects; - -/** - * TestController. - */ -@Controller -@RequestMapping("/ws") -@ShenyuSpringMvcClient("/ws/**") -public class TestHttpController { - - private static final Logger LOG = LoggerFactory.getLogger(TestHttpController.class); - - /** - * Send message. - * @param token session key - * @param msg text-type message - * @return response - */ - @RequestMapping("/sendMsg") - @Log - @ResponseBody - public String sendMsg(final String token, final String msg) { - WebSocketSession webSocketSession = WsSessionManager.get(token); - if (Objects.isNull(webSocketSession)) { - return "User login has expired"; - } - try { - webSocketSession.sendMessage(new TextMessage(msg)); - } catch (IOException e) { - LOG.error("throw exception when sending message.", e); - } - return "Message sent successfully"; - } - - /** - * Upload files. - * @param token session key - * @param file file - * @return response - */ - @PostMapping(value = "/upload") - @Log - @ResponseBody - public String file(final String token, @RequestParam("file") final MultipartFile file) { - try { - WebSocketSession webSocketSession = WsSessionManager.get(token); - if (Objects.isNull(webSocketSession)) { - return "User login has expired"; - } - if (file.getOriginalFilename().endsWith(".bin")) { - webSocketSession.sendMessage(new BinaryMessage(file.getBytes())); - } - } catch (Exception e) { - // ignore exception - } - return "ok"; - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/HttpAuthHandler.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/HttpAuthHandler.java deleted file mode 100644 index ccbaf18..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/HttpAuthHandler.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.handler; - -import java.util.Objects; -import org.apache.shenyu.examples.websocket.config.WsSessionManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import org.springframework.web.socket.CloseStatus; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; -import org.springframework.web.socket.handler.TextWebSocketHandler; - -/** - * HttpAuthHandler. - */ -@Component -public class HttpAuthHandler extends TextWebSocketHandler { - - private static final Logger LOG = LoggerFactory.getLogger(HttpAuthHandler.class); - - /** - * socket create a success event. - * - * @param session session - * @throws Exception exception - */ - @Override - public void afterConnectionEstablished(final WebSocketSession session) throws Exception { - LOG.info("The connection has been established successfully."); - Object token = session.getAttributes().get("token"); - if (Objects.nonNull(token)) { - // The user is successfully connected and put into the online user cache. - WsSessionManager.add(token.toString(), session); - } else { - throw new RuntimeException("User login has expired!"); - } - } - - /** - * Receive message events. - * - * @param session session - * @param message message - * @throws Exception exception - */ - @Override - protected void handleTextMessage(final WebSocketSession session, final TextMessage message) throws Exception { - // Get the message from the client. - String payload = message.getPayload(); - Object token = session.getAttributes().get("token"); - LOG.info("server received {}, sent {}", token, payload); - boolean isTestClose = Objects.nonNull(token) && Objects.equals(token, "testCloseStatus") || Objects.equals(payload, "testCloseStatus"); - if (isTestClose) { - session.close(new CloseStatus(4400, "test:apache shenyu server close, return closeStatus")); - } else { - session.sendMessage(new TextMessage("apache shenyu server send to " + token + " message : -> " + payload)); - } - } - - /** - * when socket disconnected. - * - * @param session session - * @param status close status - * @throws Exception exception - */ - @Override - public void afterConnectionClosed(final WebSocketSession session, final CloseStatus status) throws Exception { - Object token = session.getAttributes().get("token"); - LOG.info("closed with status: {}", status); - if (Objects.nonNull(token)) { - // The user exits and removes the cache. - WsSessionManager.remove(token.toString()); - } - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/interceptor/WebSocketInterceptor.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/interceptor/WebSocketInterceptor.java deleted file mode 100644 index 764464b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/java/org/apache/shenyu/examples/websocket/interceptor/WebSocketInterceptor.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.interceptor; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.server.ServerHttpRequest; -import org.springframework.http.server.ServerHttpResponse; -import org.springframework.stereotype.Component; -import org.springframework.web.socket.WebSocketHandler; -import org.springframework.web.socket.server.HandshakeInterceptor; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -/** - * MyInterceptor for websocket. - */ -@Component -public class WebSocketInterceptor implements HandshakeInterceptor { - - private static final Logger LOG = LoggerFactory.getLogger(WebSocketInterceptor.class); - - /** - * Before handshake. - * @param request request - * @param response response - * @param wsHandler websocketHandler - * @param attributes attributes - * @return enable handshake - * @throws Exception exception - */ - @Override - public boolean beforeHandshake(final ServerHttpRequest request, - final ServerHttpResponse response, - final WebSocketHandler wsHandler, - final Map attributes) throws Exception { - LOG.info("Shake hands."); - UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(request.getURI().toString()).build(); - Map paramMap = uriComponents.getQueryParams().toSingleValueMap(); - String uid = paramMap.get("token"); - if (StringUtils.isNotBlank(uid)) { - attributes.put("token", uid); - LOG.info("user token " + uid + " shook hands successfully!"); - return true; - } - LOG.info("user login has expired"); - return false; - } - - /** - * After shaking hands. - * @param request request - * @param response response - * @param wsHandler websocketHandler - * @param exception exception - */ - @Override - public void afterHandshake(final ServerHttpRequest request, - final ServerHttpResponse response, - final WebSocketHandler wsHandler, - final Exception exception) { - LOG.info("Handshake complete"); - } - -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/resources/application.yml deleted file mode 100644 index 790365b..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-native-websocket/src/main/resources/application.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8868 - address: 0.0.0.0 - -shenyu: - common: - contextPath: /ws-native - appName: ws-native - port: 8868 - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - websocket: - props: - contextPath: ${shenyu.common.contextPath} - appName: ${shenyu.common.appName} - port: ${shenyu.common.port} - http: - props: - contextPath: ${shenyu.common.contextPath} - appName: ${shenyu.common.appName} - port: ${shenyu.common.port} -# discovery: -# enable: true -# type: zookeeper -# serverList: 127.0.0.1:2181 -# registerPath: /shenyu/discovery/http_example -# props: -# baseSleepTimeMilliseconds: 1000 -# maxRetries: 4 -# maxSleepTimeMilliseconds: 5000 -# connectionTimeoutMilliseconds: 60000 -# sessionTimeoutMilliseconds: 8 -# type: etcd -# serverList: http://127.0.0.1:2379 -# registerPath: shenyu_discovery_http_example -# type: eureka -# serverList: http://127.0.0.1:8761/eureka -# registerPath: shenyu_discovery_http_example - -logging: - level: - root: debug - org.springframework.boot: debug - org.apache.ibatis: debug - org.apache.shenyu.bonuspoint: debug - org.apache.shenyu.lottery: debug - org.apache.shenyu: debug diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/pom.xml b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/pom.xml deleted file mode 100644 index 5764ad2..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - shenyu-java-examples-websocket - org.apache.shenyu - 2.7.1-SNAPSHOT - - 4.0.0 - - shenyu-example-spring-reactive-websocket - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-spring-websocket - ${project.version} - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-logging - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.apache.shenyu - shenyu-java-examples-common - - - - io.netty - netty-all - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestReactiveWebsocketApplication.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestReactiveWebsocketApplication.java deleted file mode 100644 index 1876713..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/TestReactiveWebsocketApplication.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * TestReactiveWebsocketApplication. - */ -@SpringBootApplication -public class TestReactiveWebsocketApplication { - - /** - * main. - * - * @param args args - */ - public static void main(final String[] args) { - SpringApplication.run(TestReactiveWebsocketApplication.class, args); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfiguration.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfiguration.java deleted file mode 100644 index 770595d..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/config/WebSocketConfiguration.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.config; - -import org.apache.shenyu.client.spring.websocket.annotation.ShenyuSpringWebSocketClient; -import org.apache.shenyu.examples.websocket.handler.EchoHandler; -import org.apache.shenyu.examples.websocket.handler.UploadFileHandler; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; -import org.springframework.web.reactive.HandlerMapping; -import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping; -import org.springframework.web.reactive.socket.WebSocketHandler; -import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter; - -import java.util.HashMap; -import java.util.Map; - -/** - * The type Web socket configuration. - */ -@Configuration -@ShenyuSpringWebSocketClient("/websocket/**") -public class WebSocketConfiguration { - - /** - * Web socket mapping handler mapping. - * - * @param echoHandler the echo handler - * @return the handler mapping - */ - @Bean - public HandlerMapping webSocketMapping(final EchoHandler echoHandler) { - final Map map = new HashMap<>(1); - map.put("/websocket/chat", echoHandler); - final SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); - mapping.setOrder(Ordered.HIGHEST_PRECEDENCE); - mapping.setUrlMap(map); - return mapping; - } - - /** - * define a websocket handler Mapping bean. - * @param uploadFileHandler upload file handler - * @return handlerMapping - */ - @Bean - public HandlerMapping websocketFileMapping(final UploadFileHandler uploadFileHandler) { - final Map map = new HashMap<>(1); - map.put("/websocket/upload", uploadFileHandler); - final SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); - mapping.setOrder(Ordered.HIGHEST_PRECEDENCE); - mapping.setUrlMap(map); - return mapping; - } - - /** - * Handler adapter web socket handler adapter. - * @return the web socket handler adapter - */ - @Bean - public WebSocketHandlerAdapter handlerAdapter() { - return new WebSocketHandlerAdapter(); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/EchoHandler.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/EchoHandler.java deleted file mode 100644 index 40b6864..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/EchoHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.handler; - -import org.apache.shenyu.examples.common.aop.Log; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.socket.WebSocketHandler; -import org.springframework.web.reactive.socket.WebSocketSession; -import reactor.core.publisher.Mono; - -/** - * The type Echo handler. - */ -@Component -public class EchoHandler implements WebSocketHandler { - - @Override - @NonNull - @Log - public Mono handle(final WebSocketSession session) { - return session.send( - session.receive() - .map(msg -> session.textMessage( - "result apache shenyu : -> " + msg.getPayloadAsText()))); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/UploadFileHandler.java b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/UploadFileHandler.java deleted file mode 100644 index 72e1b96..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/java/org/apache/shenyu/examples/websocket/handler/UploadFileHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.examples.websocket.handler; - -import org.apache.shenyu.examples.common.aop.Log; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.socket.WebSocketHandler; -import org.springframework.web.reactive.socket.WebSocketSession; -import reactor.core.publisher.Mono; - -@Component -public class UploadFileHandler implements WebSocketHandler { - - - /** - * Handle by upload handler. - * @param session session - * @return void - */ - @Override - @NonNull - @Log - public Mono handle(final WebSocketSession session) { - return session.send( - session.receive() - .map(msg -> session.binaryMessage(msg.getNativeMessage()))); - } -} diff --git a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/resources/application.yml b/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/resources/application.yml deleted file mode 100644 index 57780ea..0000000 --- a/shenyu-java-examples/shenyu-java-examples-websocket/shenyu-example-spring-reactive-websocket/src/main/resources/application.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -server: - port: 8004 - address: 0.0.0.0 - - -shenyu: - register: - registerType: http - serverLists: http://localhost:9095 - props: - username: admin - password: 123456 - client: - websocket: - props: - contextPath: /ws-reactive - appName: ws-reactive - port: 8004 - # discovery: - # enable: true - # type: zookeeper - # serverList: 127.0.0.1:2181 - # registerPath: /shenyu/discovery/http_example - # props: - # baseSleepTimeMilliseconds: 1000 - # maxRetries: 4 - # maxSleepTimeMilliseconds: 5000 - # connectionTimeoutMilliseconds: 60000 - # sessionTimeoutMilliseconds: 8 - # type: etcd - # serverList: http://127.0.0.1:2379 - # registerPath: shenyu_discovery_http_example - # type: eureka - # serverList: http://127.0.0.1:8761/eureka - # registerPath: shenyu_discovery_http_example - - -logging: - level: - root: debug - org.springframework.boot: debug - org.apache.ibatis: debug - org.apache.shenyu.bonuspoint: debug - org.apache.shenyu.lottery: debug - org.apache.shenyu: debug - diff --git a/shenyu-register-java-client/pom.xml b/shenyu-register-java-client/pom.xml deleted file mode 100644 index 6e091b5..0000000 --- a/shenyu-register-java-client/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-register-java-client - pom - - - shenyu-register-java-client-api - shenyu-register-java-client-http - - diff --git a/shenyu-register-java-client/shenyu-register-java-client-api/pom.xml b/shenyu-register-java-client/shenyu-register-java-client-api/pom.xml deleted file mode 100644 index 596f2bf..0000000 --- a/shenyu-register-java-client/shenyu-register-java-client-api/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-register-java-client - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-register-java-client-api - - - - org.apache.shenyu - shenyu-register-java-common - ${project.version} - - - org.apache.shenyu - shenyu-java-common - ${project.version} - - - org.apache.shenyu - shenyu-spi - 2.6.1 - - - - diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/pom.xml b/shenyu-register-java-client/shenyu-register-java-client-http/pom.xml deleted file mode 100644 index bad7ddd..0000000 --- a/shenyu-register-java-client/shenyu-register-java-client-http/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-register-java-client - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-register-java-client-http - - - - - org.apache.shenyu - shenyu-register-java-client-api - ${project.version} - - - com.squareup.okhttp3 - okhttp - - - com.google.code.gson - gson - - - com.github.tomakehurst - wiremock-standalone - ${wiremock.version} - test - - - org.hamcrest - hamcrest - 2.2 - test - - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.8.2 - test - - - org.junit.jupiter - junit-jupiter-params - 5.8.2 - test - - - - junit - junit - 4.13.2 - test - - - diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/resources/META-INF/shenyu/org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository b/shenyu-register-java-client/shenyu-register-java-client-http/src/main/resources/META-INF/shenyu/org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository deleted file mode 100644 index 13cb8ad..0000000 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/main/resources/META-INF/shenyu/org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -http=org.apache.shenyu.register.client.http.HttpClientRegisterRepository diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/OkHttpToolsTest.java b/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/OkHttpToolsTest.java deleted file mode 100644 index cfbb502..0000000 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/OkHttpToolsTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.register.client.http.utils; - -import okhttp3.Call; -import okhttp3.Headers; -import okhttp3.OkHttpClient; -import okhttp3.Response; -import okhttp3.ResponseBody; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * Test case for {@link OkHttpTools}. - */ -public final class OkHttpToolsTest { - - private final String url = "http://localhost:9095"; - - private String getUrl; - - private String postUrl; - - private final String json = "{\"appName\":\"shenyu\"}"; - - private final Map request = new HashMap<>(); - - @BeforeEach - public void setUpWireMock() { - getUrl = url + "/get"; - postUrl = url + "/post"; - } - - @Test - public void testPostReturnString() throws IllegalAccessException, NoSuchFieldException, IOException { - final Field client = OkHttpTools.class.getDeclaredField("client"); - client.setAccessible(true); - final OkHttpClient okHttpClient = mock(OkHttpClient.class); - client.set(OkHttpTools.getInstance(), okHttpClient); - final Call call = mock(Call.class); - when(okHttpClient.newCall(any())).thenReturn(call); - final Response response = mock(Response.class); - when(call.execute()).thenReturn(response); - final ResponseBody responseBody = mock(ResponseBody.class); - when(response.body()).thenReturn(responseBody); - when(responseBody.string()).thenReturn("body"); - Assertions.assertDoesNotThrow(() -> OkHttpTools.getInstance().post(postUrl, json)); - Headers headers = Headers.of().newBuilder().build(); - Assertions.assertDoesNotThrow(() -> OkHttpTools.getInstance().post(postUrl, json, headers)); - } - - @Test - public void testGetReturnString() throws IllegalAccessException, NoSuchFieldException, IOException { - final Field client = OkHttpTools.class.getDeclaredField("client"); - client.setAccessible(true); - final OkHttpClient okHttpClient = mock(OkHttpClient.class); - client.set(OkHttpTools.getInstance(), okHttpClient); - final Call call = mock(Call.class); - when(okHttpClient.newCall(any())).thenReturn(call); - final Response response = mock(Response.class); - when(call.execute()).thenReturn(response); - final ResponseBody responseBody = mock(ResponseBody.class); - when(response.body()).thenReturn(responseBody); - when(responseBody.string()).thenReturn("body"); - request.put("get", "request"); - Assertions.assertDoesNotThrow(() -> OkHttpTools.getInstance().get(getUrl, request)); - Assertions.assertDoesNotThrow(() -> OkHttpTools.getInstance().get(getUrl, "userName", "passWord")); - } -} diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/RegisterUtilsTest.java b/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/RegisterUtilsTest.java deleted file mode 100644 index a61b18f..0000000 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/RegisterUtilsTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.register.client.http.utils; - -import com.google.gson.Gson; -import okhttp3.Headers; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.register.common.enums.RegisterTypeEnum; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * Test case for {@link RegisterUtils}. - */ -public final class RegisterUtilsTest { - - private final Gson gson = new Gson(); - - private OkHttpTools okHttpTools; - - private String json; - - private String url; - - private String accessToken; - - @BeforeEach - public void setUp() { - okHttpTools = mock(OkHttpTools.class); - Map jsonMap = new HashMap<>(); - jsonMap.put("appName", "dubbo"); - jsonMap.put("contextPath", "/dubbo"); - jsonMap.put("path", "/dubbo/findByArrayIdsAndName"); - jsonMap.put("pathDesc", ""); - jsonMap.put("serviceName", "org.apache.shenyu.examples.dubbo.api.service.DubboMultiParamService"); - jsonMap.put("ruleName", "/dubbo/findByArrayIdsAndName"); - jsonMap.put("parameterTypes", "[Ljava.lang.Integer;,java.lang.String"); - jsonMap.put("rpcExt", "{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}"); - jsonMap.put("enabled", true); - json = gson.toJson(jsonMap); - url = "http://localhost:9095/shenyu-client/dubbo-register"; - accessToken = "accessToken"; - } - - @Test - public void testDoRegisterWhenSuccess() throws IOException { - when(okHttpTools.post(url, json)).thenReturn("success"); - Headers headers = new Headers.Builder().add(Constants.X_ACCESS_TOKEN, accessToken).build(); - when(okHttpTools.post(url, json, headers)).thenReturn("success"); - - try (MockedStatic okHttpToolsMockedStatic = mockStatic(OkHttpTools.class)) { - okHttpToolsMockedStatic.when(OkHttpTools::getInstance).thenReturn(okHttpTools); - RegisterUtils.doRegister(json, url, RegisterTypeEnum.DUBBO.getName()); - verify(okHttpTools, times(1)).post(eq(url), eq(json)); - RegisterUtils.doRegister(json, url, RegisterTypeEnum.DUBBO.getName(), accessToken); - verify(okHttpTools, times(1)).post(eq(url), eq(json)); - } - } - - @Test - public void testDoRegisterWhenError() throws IOException { - when(okHttpTools.post(url, json)).thenReturn("Error parameter!"); - Headers headers = new Headers.Builder().add(Constants.X_ACCESS_TOKEN, accessToken).build(); - when(okHttpTools.post(url, json, headers)).thenReturn("Error parameter!"); - try (MockedStatic okHttpToolsMockedStatic = mockStatic(OkHttpTools.class)) { - okHttpToolsMockedStatic.when(OkHttpTools::getInstance).thenReturn(okHttpTools); - RegisterUtils.doRegister(json, url, RegisterTypeEnum.DUBBO.getName()); - verify(okHttpTools, times(1)).post(eq(url), eq(json)); - RegisterUtils.doRegister(json, url, RegisterTypeEnum.DUBBO.getName(), accessToken); - verify(okHttpTools, times(1)).post(eq(url), eq(json)); - - RegisterUtils.doRegister(json, url, RegisterTypeEnum.DUBBO.getName(), null); - } - } - - @Test - public void testDoRegisterWhenThrowException() throws IOException { - when(okHttpTools.post(url, json)).thenThrow(IOException.class); - assertThrows(IOException.class, () -> { - try (MockedStatic okHttpToolsMockedStatic = mockStatic(OkHttpTools.class)) { - okHttpToolsMockedStatic.when(OkHttpTools::getInstance).thenReturn(okHttpTools); - RegisterUtils.doRegister(json, url, RegisterTypeEnum.DUBBO.getName()); - verify(okHttpTools, times(1)).post(eq(url), eq(json)); - } - }); - } - - @Test - public void testDoLogin() throws IOException { - final String userName = "userName"; - final String password = "password"; - final String token = "token"; - Map loginMap = new HashMap<>(2); - loginMap.put(Constants.LOGIN_NAME, userName); - loginMap.put(Constants.PASS_WORD, password); - when(okHttpTools.get(url, loginMap)).thenReturn("{\"code\":200,\"data\":{\"token\":\"" + token + "\"}}"); - try (MockedStatic okHttpToolsMockedStatic = mockStatic(OkHttpTools.class)) { - okHttpToolsMockedStatic.when(OkHttpTools::getInstance).thenReturn(okHttpTools); - Optional objectOptional = RegisterUtils.doLogin(userName, password, url); - Assertions.assertEquals(token, objectOptional.get()); - } - } - - @Test - public void testDoLoginError() throws IOException { - final String userName = "userName"; - final String password = "password"; - Map loginMap = new HashMap<>(2); - loginMap.put(Constants.LOGIN_NAME, userName); - loginMap.put(Constants.PASS_WORD, password); - when(okHttpTools.get(url, loginMap)).thenReturn("{\"code\":300}"); - try (MockedStatic okHttpToolsMockedStatic = mockStatic(OkHttpTools.class)) { - okHttpToolsMockedStatic.when(OkHttpTools::getInstance).thenReturn(okHttpTools); - Optional objectOptional = RegisterUtils.doLogin(userName, password, url); - Assertions.assertFalse(objectOptional.isPresent()); - } - } -} diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/RuntimeUtilsTest.java b/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/RuntimeUtilsTest.java deleted file mode 100644 index 45326f1..0000000 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/RuntimeUtilsTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.register.client.http.utils; - -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; - -/** - * Test case for {@link RuntimeUtils}. - */ -class RuntimeUtilsTest { - - @Test - void listenByOther() throws IOException { - try (MockedStatic systemUtilsMockedStatic = mockStatic(SystemUtils.class)) { - systemUtilsMockedStatic.when(SystemUtils::getCurrentPID).thenReturn("0"); - systemUtilsMockedStatic.when(SystemUtils::isWindows).thenReturn(true); - assertDoesNotThrow(() -> RuntimeUtils.listenByOther(9095)); - - systemUtilsMockedStatic.when(SystemUtils::isWindows).thenReturn(false); - assertDoesNotThrow(() -> RuntimeUtils.listenByOther(9095)); - } - try (MockedStatic runtimeMockedStatic = mockStatic(Runtime.class)) { - runtimeMockedStatic.when(Runtime::getRuntime).thenThrow(RuntimeException.class); - assertFalse(RuntimeUtils.listenByOther(9095)); - final Runtime runtime = mock(Runtime.class); - runtimeMockedStatic.when(Runtime::getRuntime).thenReturn(runtime); - final Process process = mock(Process.class); - when(runtime.exec(any(String[].class))).thenReturn(process); - final String text = "LISTEN xx:" + 9095 + " xx "; - InputStream stream = new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)); - when(process.getInputStream()).thenReturn(stream); - assertFalse(RuntimeUtils.listenByOther(9095)); - when(runtime.exec(any(String[].class))).thenReturn(null); - assertFalse(RuntimeUtils.listenByOther(9095)); - } - assertFalse(RuntimeUtils.listenByOther(9095)); - assertFalse(RuntimeUtils.listenByOther(99999)); - assertFalse(RuntimeUtils.listenByOther(0)); - } -} diff --git a/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/SystemUtilsTest.java b/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/SystemUtilsTest.java deleted file mode 100644 index c4f04f8..0000000 --- a/shenyu-register-java-client/shenyu-register-java-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/SystemUtilsTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.register.client.http.utils; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Test case for {@link SystemUtils}. - */ -class SystemUtilsTest { - - @Test - void getOsNameTest() { - Assertions.assertDoesNotThrow(SystemUtils::getOsName); - } -} diff --git a/shenyu-register-java-common/pom.xml b/shenyu-register-java-common/pom.xml deleted file mode 100644 index 9c113c5..0000000 --- a/shenyu-register-java-common/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-register-java-common - - - - org.apache.shenyu - shenyu-disruptor - 2.6.1 - - - diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuClientConfig.java b/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuClientConfig.java deleted file mode 100644 index b5d1c3e..0000000 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/config/ShenyuClientConfig.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.register.common.config; - - - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * The type Shenyu client config. - */ -public final class ShenyuClientConfig { - - private Map client = new HashMap() { - @Override - public ClientPropertiesConfig get(final Object key) { - ClientPropertiesConfig config = super.get(key); - if (Objects.isNull(key) || Objects.isNull(config)) { - throw new RuntimeException("key is null or invalid, you should checkout property of " + key); - } - return config; - } - }; - - /** - * Gets client. - * - * @return the client - */ - public Map getClient() { - return client; - } - - /** - * Sets client. - * - * @param client the client - */ - public void setClient(final Map client) { - this.client = client; - } - - /** - * this client properties config. - */ - public static class ClientPropertiesConfig extends PropertiesConfig { - - } -} diff --git a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/path/RegisterPathConstants.java b/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/path/RegisterPathConstants.java deleted file mode 100644 index cd8059f..0000000 --- a/shenyu-register-java-common/src/main/java/org/apache/shenyu/register/common/path/RegisterPathConstants.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.register.common.path; - -/** - * register center path constants. - */ -public class RegisterPathConstants { - - /** - * uri register path pattern. - * e.g. /shenyu/register/uri/{rpcType}/{context}/{urlInstance} - */ - public static final String REGISTER_URI_INSTANCE_PATH = "/shenyu/register/uri/*/*/*"; - - /** - * metadata register path pattern. - * e.g. /shenyu/register/metadata/{rpcType}/{context}/{metadata} - */ - public static final String REGISTER_METADATA_INSTANCE_PATH = "/shenyu/register/metadata/*/*/*"; - - /** - * root path of register center. - */ - public static final String ROOT_PATH = "/shenyu/register"; - - /** - * root path of uri register. - */ - public static final String REGISTER_URI_INSTANCE_ROOT_PATH = ROOT_PATH + "/uri"; - - /** - * root path of metadata register. - */ - public static final String REGISTER_METADATA_INSTANCE_ROOT_PATH = ROOT_PATH + "/metadata"; - - /** - * constants of separator. - */ - private static final String SEPARATOR = "/"; - - /** - * Dot separator. - */ - private static final String DOT_SEPARATOR = "."; - - /** - * build child path of "/shenyu/register/metadata/{rpcType}/". - * - * @param rpcType rpc type - * @return path string - */ - public static String buildMetaDataContextPathParent(final String rpcType) { - return String.join(SEPARATOR, REGISTER_METADATA_INSTANCE_ROOT_PATH, rpcType); - } - - /** - * build child path of "/shenyu/register/metadata/{rpcType}/{contextPath}/". - * - * @param rpcType rpc type - * @param contextPath context path - * @return path string - */ - public static String buildMetaDataParentPath(final String rpcType, final String contextPath) { - return String.join(SEPARATOR, REGISTER_METADATA_INSTANCE_ROOT_PATH, rpcType, contextPath); - } - - /** - * Build uri path string. - * build child path of "/shenyu/register/uri/{rpcType}/". - * - * @param rpcType the rpc type - * @return the string - */ - public static String buildURIContextPathParent(final String rpcType) { - return String.join(SEPARATOR, REGISTER_URI_INSTANCE_ROOT_PATH, rpcType); - } - - /** - * Build uri path string. - * build child path of "/shenyu/register/uri/{rpcType}/{contextPath}/". - * - * @param rpcType the rpc type - * @param contextPath the context path - * @return the string - */ - public static String buildURIParentPath(final String rpcType, final String contextPath) { - return String.join(SEPARATOR, REGISTER_URI_INSTANCE_ROOT_PATH, rpcType, contextPath); - } - - /** - * Build instance parent path string. - * build child path of "/shenyu/register/instance/ - * - * @return the string - */ - public static String buildInstanceParentPath() { - return buildInstanceParentPath("instance"); - } - - /** - * Build instance parent path string. - * build child path of "/shenyu/register/instance/ - * - * @param registerServiceName registerServiceName - * @return the string - */ - public static String buildInstanceParentPath(final String registerServiceName) { - return String.join(SEPARATOR, ROOT_PATH, registerServiceName); - } - - /** - * Build real node string. - * - * @param nodePath the node path - * @param nodeName the node name - * @return the string - */ - public static String buildRealNode(final String nodePath, final String nodeName) { - return String.join(SEPARATOR, nodePath, nodeName); - } - - /** - * Build nacos instance service path string. - * build child path of "shenyu.register.service.{rpcType}". - * - * @param rpcType the rpc type - * @return the string - */ - public static String buildServiceInstancePath(final String rpcType) { - return String.join(SEPARATOR, ROOT_PATH, "service", rpcType) - .replace("/", DOT_SEPARATOR).substring(1); - } - - /** - * Build nacos config service path string. - * build child path of "shenyu.register.service.{rpcType}.{contextPath}". - * - * @param rpcType the rpc type - * @param contextPath the context path - * @return the string - */ - public static String buildServiceConfigPath(final String rpcType, final String contextPath) { - final String serviceConfigPathOrigin = String.join(SEPARATOR, ROOT_PATH, "service", rpcType, contextPath) - .replace("/", DOT_SEPARATOR).replace("*", ""); - final String serviceConfigPathAfterSubstring = serviceConfigPathOrigin.substring(1); - if (serviceConfigPathAfterSubstring.endsWith(".")) { - return serviceConfigPathAfterSubstring.substring(0, serviceConfigPathAfterSubstring.length() - 1); - } - return serviceConfigPathAfterSubstring; - } - - /** - * Build node name by DOT_SEPARATOR. - * - * @param serviceName the service name - * @param methodName the method name - * @return the string - */ - public static String buildNodeName(final String serviceName, final String methodName) { - return String.join(DOT_SEPARATOR, serviceName, methodName); - } - -} diff --git a/shenyu-spring-boot-starter-java-client/pom.xml b/shenyu-spring-boot-starter-java-client/pom.xml deleted file mode 100644 index 0f1438e..0000000 --- a/shenyu-spring-boot-starter-java-client/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-client-java - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-spring-boot-starter-java-client - pom - - - shenyu-spring-boot-starter-java-client-springmvc - shenyu-spring-boot-starter-java-client-springcloud - shenyu-spring-boot-starter-java-client-apache-dubbo - shenyu-spring-boot-starter-java-client-sofa - shenyu-spring-boot-starter-java-client-tars - shenyu-spring-boot-starter-java-client-grpc - shenyu-spring-boot-starter-java-client-common - shenyu-spring-boot-starter-java-client-motan - shenyu-spring-boot-starter-java-client-spring-websocket - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-starter-webflux - test - - - org.assertj - assertj-core - test - - - diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/java/org/apache/shenyu/springboot/starter/client/apache/dubbo/ShenyuApacheDubboClientConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/java/org/apache/shenyu/springboot/starter/client/apache/dubbo/ShenyuApacheDubboClientConfiguration.java deleted file mode 100644 index a8ac2bc..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/java/org/apache/shenyu/springboot/starter/client/apache/dubbo/ShenyuApacheDubboClientConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.apache.dubbo; - -import org.apache.shenyu.client.apache.dubbo.ApacheDubboServiceBeanListener; -import org.apache.shenyu.common.utils.VersionUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * The type shenyu apache dubbo client configuration. - */ -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuApacheDubboClientConfiguration { - - static { - VersionUtils.checkDuplicate(ShenyuApacheDubboClientConfiguration.class); - } - - /** - * Apache dubbo service bean listener. - * - * @param clientConfig the client config - * @param shenyuClientRegisterRepository the shenyu client register repository - * @return the apache dubbo service bean listener - */ - @Bean - public ApacheDubboServiceBeanListener apacheDubboServiceBeanListener(final ShenyuClientConfig clientConfig, - final ShenyuClientRegisterRepository shenyuClientRegisterRepository) { - return new ApacheDubboServiceBeanListener(clientConfig, shenyuClientRegisterRepository); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring.factories deleted file mode 100644 index c5c54e9..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.springboot.starter.client.apache.dubbo.ShenyuApacheDubboClientConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring.provides b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 2639135..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -provides: shenyu-spring-boot-starter-java-client-apache-dubbo diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 4611af1..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.apache.shenyu.springboot.starter.client.apache.dubbo.ShenyuApacheDubboClientConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/test/java/org/apache/shenyu/springboot/starter/client/apache/dubbo/ShenyuApacheDubboClientConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/test/java/org/apache/shenyu/springboot/starter/client/apache/dubbo/ShenyuApacheDubboClientConfigurationTest.java deleted file mode 100644 index 3d766a2..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/test/java/org/apache/shenyu/springboot/starter/client/apache/dubbo/ShenyuApacheDubboClientConfigurationTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.apache.dubbo; - -import org.apache.shenyu.client.apache.dubbo.ApacheDubboServiceBeanListener; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -/** - * Test case for {@link ShenyuApacheDubboClientConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -@PropertySource(value = "classpath:application.properties") -public class ShenyuApacheDubboClientConfigurationTest { - - @Test - public void testShenyuApacheDubboClientConfiguration() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuApacheDubboClientConfiguration.class)) - .withBean(ShenyuApacheDubboClientConfigurationTest.class) - .withPropertyValues("debug=true") - .run( - context -> { - ApacheDubboServiceBeanListener listener = context.getBean("apacheDubboServiceBeanListener", ApacheDubboServiceBeanListener.class); - assertNotNull(listener); - } - ); - registerUtilsMockedStatic.close(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/test/resources/application.properties b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/test/resources/application.properties deleted file mode 100644 index fbd7297..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-apache-dubbo/src/test/resources/application.properties +++ /dev/null @@ -1,33 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -dubbo.registry.address=zookeeper://localhost:2181 - -# more see shenyu-register-center module -shenyu.register.register-type=http -shenyu.register.serverLists=http://localhost:9095 -shenyu.register.props.username=admin -shenyu.register.props.password=123456 - -# more see org.apache.shenyu.client.core.shutdown.ShenyuClientShutdownHook.TakeoverOtherHooksThread.class -shenyu.register.props[shutdownWaitTime]=3000 -shenyu.register.props[delayOtherHooksExecTime]=2000 -shenyu.register.props[applicationShutdownHooksClassName]=java.lang.ApplicationShutdownHooks -shenyu.register.props[applicationShutdownHooksFieldName]=hooks - -shenyu.client.dubbo.props[contextPath]=/dubbo -shenyu.client.dubbo.props[appName]=apache-dubbo -shenyu.client.dubbo.props[host]=localhost -shenyu.client.dubbo.props[port]=20888 diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/pom.xml b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/pom.xml deleted file mode 100644 index e9ad319..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-spring-boot-starter-java-client-common - - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.apache.shenyu - shenyu-client-java-core - ${project.version} - - - diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/java/org/apache/shenyu/springboot/starter/client/common/config/ShenyuClientCommonBeanConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/java/org/apache/shenyu/springboot/starter/client/common/config/ShenyuClientCommonBeanConfiguration.java deleted file mode 100644 index 948d75a..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/java/org/apache/shenyu/springboot/starter/client/common/config/ShenyuClientCommonBeanConfiguration.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.common.config; - -import org.apache.shenyu.client.core.register.ShenyuClientRegisterRepositoryFactory; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuDiscoveryConfig; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * The type shenyu client common bean configuration. - */ -@Configuration -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuClientCommonBeanConfiguration { - - /** - * Register the register repository for http client bean post processor. - * - * @param config the config - * @return the client register repository - */ - @Bean - public ShenyuClientRegisterRepository shenyuClientRegisterRepository(final ShenyuRegisterCenterConfig config) { - return ShenyuClientRegisterRepositoryFactory.newInstance(config); - } - - /** - * Shenyu Register Center Config. - * - * @return the Register Center Config - */ - @Bean - @ConfigurationProperties(prefix = "shenyu.register") - public ShenyuRegisterCenterConfig shenyuRegisterCenterConfig() { - return new ShenyuRegisterCenterConfig(); - } - - /** - * Shenyu client config. - * - * @return the shenyu client config - */ - @Bean - @ConfigurationProperties(prefix = "shenyu") - public ShenyuClientConfig shenyuClientConfig() { - return new ShenyuClientConfig(); - } - - /** - * Shenyu discovery config. - * - * @return the shenyu discovery config - */ - @Bean - @ConditionalOnProperty(prefix = "shenyu.discovery", name = "enable", havingValue = "true") - @ConfigurationProperties(prefix = "shenyu.discovery") - public ShenyuDiscoveryConfig shenyuDiscoveryConfig() { - return new ShenyuDiscoveryConfig(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/resources/META-INF/spring.factories deleted file mode 100644 index f76ca4f..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 77a7621..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/test/java/org/apache/shenyu/springboot/starter/client/common/config/ShenyuClientCommonBeanConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/test/java/org/apache/shenyu/springboot/starter/client/common/config/ShenyuClientCommonBeanConfigurationTest.java deleted file mode 100644 index 7e0027e..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-common/src/test/java/org/apache/shenyu/springboot/starter/client/common/config/ShenyuClientCommonBeanConfigurationTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.common.config; - -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuDiscoveryConfig; -import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig; -import org.apache.shenyu.register.common.enums.RegisterTypeEnum; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -/** - * Test case for {@link ShenyuClientCommonBeanConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -public class ShenyuClientCommonBeanConfigurationTest { - - private ApplicationContextRunner applicationContextRunner; - - @BeforeEach - public void before() { - applicationContextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuClientCommonBeanConfiguration.class)) - .withBean(ShenyuClientCommonBeanConfigurationTest.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "shenyu.client.dubbo.props[contextPath]=/common", - "shenyu.client.dubbo.props[appName]=common", - "shenyu.client.dubbo.props[host]=localhost", - "shenyu.discovery.name=local", - "shenyu.discovery.enable=true", - "shenyu.discovery.type=local", - "shenyu.discovery.serverList=20888", - "shenyu.discovery.props[sleep]=1000", - "shenyu.discovery.props[maxRetry]=3" - - ); - } - - @Test - public void testShenyuClientRegisterRepository() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - ShenyuClientRegisterRepository repository = context.getBean("shenyuClientRegisterRepository", ShenyuClientRegisterRepository.class); - assertNotNull(repository); - }); - registerUtilsMockedStatic.close(); - } - - @Test - public void testShenyuRegisterCenterConfig() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - ShenyuRegisterCenterConfig config = context.getBean("shenyuRegisterCenterConfig", ShenyuRegisterCenterConfig.class); - assertNotNull(config); - assertThat(config.getRegisterType()).isEqualTo(RegisterTypeEnum.HTTP.getName()); - }); - registerUtilsMockedStatic.close(); - } - - @Test - public void testShenyuClientConfig() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - ShenyuClientConfig config = context.getBean("shenyuClientConfig", ShenyuClientConfig.class); - assertNotNull(config); - assertThat(config.getClient()).containsKey("dubbo"); - }); - registerUtilsMockedStatic.close(); - } - - @Test - public void testShenyuDiscoveryConfig() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - ShenyuDiscoveryConfig config = context.getBean("shenyuDiscoveryConfig", ShenyuDiscoveryConfig.class); - assertNotNull(config); - assertThat(config.getType()).isEqualTo("local"); - }); - registerUtilsMockedStatic.close(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/pom.xml b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/pom.xml deleted file mode 100644 index 16ec2b7..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-spring-boot-starter-java-client-grpc - - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.apache.shenyu - shenyu-client-java-grpc - ${project.version} - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-common - ${project.version} - - - org.apache.shenyu - shenyu-client-java-autoconfig - ${project.version} - - - diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcClientConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcClientConfiguration.java deleted file mode 100644 index bf9f18a..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcClientConfiguration.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.springboot.starter.client.grpc; - -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.ClientRegisterConfigImpl; -import org.apache.shenyu.client.grpc.GrpcClientEventListener; -import org.apache.shenyu.client.grpc.server.GrpcServerBuilder; -import org.apache.shenyu.client.grpc.server.GrpcServerRunner; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.VersionUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; - -import java.util.Objects; -import java.util.Properties; - -/** - * Grpc type client bean postprocessor. - */ -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuGrpcClientConfiguration { - - static { - VersionUtils.checkDuplicate(ShenyuGrpcClientConfiguration.class); - } - - /** - * Grpc client event listener. - * - * @param clientConfig the client config - * @param env env - * @param shenyuClientRegisterRepository the shenyu client register repository - * @return the grpc client bean post processor - */ - @Bean - public GrpcClientEventListener grpcClientEventListener(final ShenyuClientConfig clientConfig, - final Environment env, - final ShenyuClientRegisterRepository shenyuClientRegisterRepository) { - ShenyuClientConfig.ClientPropertiesConfig clientPropertiesConfig = clientConfig.getClient().get(RpcTypeEnum.GRPC.getName()); - Properties props = Objects.isNull(clientPropertiesConfig) ? null : clientPropertiesConfig.getProps(); - String discoveryMode = env.getProperty("shenyu.discovery.type", ShenyuClientConstants.DISCOVERY_LOCAL_MODE); - if (Objects.nonNull(props)) { - props.setProperty(ShenyuClientConstants.DISCOVERY_LOCAL_MODE_KEY, Boolean.valueOf(ShenyuClientConstants.DISCOVERY_LOCAL_MODE.equals(discoveryMode)).toString()); - } - return new GrpcClientEventListener(clientConfig, shenyuClientRegisterRepository); - } - - /** - * Grpc Server. - * - * @param grpcServerBuilder grpcServerBuilder - * @param grpcClientEventListener grpcClientEventListener - * @return the grpc server - */ - @Bean - public GrpcServerRunner grpcServer(final GrpcServerBuilder grpcServerBuilder, - final GrpcClientEventListener grpcClientEventListener) { - return new GrpcServerRunner(grpcServerBuilder, grpcClientEventListener); - } - - /** - * ClientRegisterConfig Bean. - * - * @param shenyuClientConfig shenyuClientConfig - * @param applicationContext applicationContext - * @param env env - * @return clientRegisterConfig - */ - @Bean("grpcClientRegisterConfig") - public ClientRegisterConfig clientRegisterConfig(final ShenyuClientConfig shenyuClientConfig, - final ApplicationContext applicationContext, - final Environment env) { - return new ClientRegisterConfigImpl(shenyuClientConfig, RpcTypeEnum.GRPC, applicationContext, env); - } - -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcDiscoveryConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcDiscoveryConfiguration.java deleted file mode 100644 index 8d1fb71..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcDiscoveryConfiguration.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.springboot.starter.client.grpc; - -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; -import org.apache.shenyu.client.core.register.ClientDiscoveryConfigRefreshedEventListener; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.InstanceRegisterListener; -import org.apache.shenyu.common.dto.DiscoveryUpstreamData; -import org.apache.shenyu.common.enums.PluginEnum; -import org.apache.shenyu.register.client.http.HttpClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuDiscoveryConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -public class ShenyuGrpcDiscoveryConfiguration { - - /** - * InstanceRegisterListener. - * - * @param clientRegisterConfig clientRegisterConfig - * @param shenyuDiscoveryConfig shenyuDiscoveryConfig - * @param shenyuClientConfig shenyuClientConfig - * @return InstanceRegisterListener - */ - @Bean("grpcInstanceRegisterListener") - @ConditionalOnBean(ShenyuDiscoveryConfig.class) - public InstanceRegisterListener instanceRegisterListener(final ClientRegisterConfig clientRegisterConfig, - final ShenyuDiscoveryConfig shenyuDiscoveryConfig, - final ShenyuClientConfig shenyuClientConfig) { - DiscoveryUpstreamData discoveryUpstreamData = new DiscoveryUpstreamData(); - discoveryUpstreamData.setUrl(clientRegisterConfig.getHost() + ":" + clientRegisterConfig.getPort()); - discoveryUpstreamData.setStatus(0); - discoveryUpstreamData.setWeight(50); - discoveryUpstreamData.setProtocol(Optional.ofNullable(shenyuDiscoveryConfig.getProtocol()).orElse(ShenyuClientConstants.HTTP)); - discoveryUpstreamData.setNamespaceId(shenyuClientConfig.getNamespace()); - return new InstanceRegisterListener(discoveryUpstreamData, shenyuDiscoveryConfig); - } - - /** - * clientDiscoveryConfigRefreshedEventListener. - * - * @param shenyuDiscoveryConfig shenyuDiscoveryConfig - * @param httpClientRegisterRepository httpClientRegisterRepository - * @param clientRegisterConfig clientRegisterConfig - * @param shenyuClientConfig shenyuClientConfig - * @return ClientDiscoveryConfigRefreshedEventListener - */ - @Bean("GrpcClientDiscoveryConfigRefreshedEventListener") - @ConditionalOnProperty(prefix = "shenyu.discovery", name = "serverList", matchIfMissing = false) - @ConditionalOnBean(ShenyuDiscoveryConfig.class) - public ClientDiscoveryConfigRefreshedEventListener clientDiscoveryConfigRefreshedEventListener(final ShenyuDiscoveryConfig shenyuDiscoveryConfig, - final HttpClientRegisterRepository httpClientRegisterRepository, - final ClientRegisterConfig clientRegisterConfig, - final ShenyuClientConfig shenyuClientConfig) { - return new ClientDiscoveryConfigRefreshedEventListener(shenyuDiscoveryConfig, httpClientRegisterRepository, clientRegisterConfig, PluginEnum.GRPC, shenyuClientConfig); - } - -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring.factories deleted file mode 100644 index df60c49..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.springboot.starter.client.grpc.ShenyuGrpcClientConfiguration,\ -org.apache.springboot.starter.client.grpc.ShenyuGrpcDiscoveryConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring.provides b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 8e8276b..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -provides: shenyu-spring-boot-starter-java-client-grpc diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 83b6db7..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.apache.springboot.starter.client.grpc.ShenyuGrpcClientConfiguration -org.apache.springboot.starter.client.grpc.ShenyuGrpcDiscoveryConfiguration \ No newline at end of file diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/test/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcClientConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/test/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcClientConfigurationTest.java deleted file mode 100644 index 42b19df..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/test/java/org/apache/springboot/starter/client/grpc/ShenyuGrpcClientConfigurationTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.springboot.starter.client.grpc; - -import org.apache.shenyu.client.grpc.GrpcClientEventListener; -import org.apache.shenyu.client.grpc.server.GrpcServerRunner; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -/** - * Test case for {@link ShenyuGrpcClientConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -@ComponentScan(value = "org.apache.springboot.starter.client.grpc.server") -public class ShenyuGrpcClientConfigurationTest { - - private ApplicationContextRunner applicationContextRunner; - - @BeforeEach - public void before() { - applicationContextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuGrpcClientConfiguration.class)) - .withBean(ShenyuGrpcClientConfigurationTest.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "shenyu.client.grpc.props[contextPath]=/grpc", - "shenyu.client.grpc.props[appName]=grpc", - "shenyu.client.grpc.props[ipAndPort]=127.0.0.1:8080", - "shenyu.client.grpc.props[port]=8080" - ); - } - - @Test - public void testGrpcClientBeanPostProcessor() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.of("token")); - applicationContextRunner.run(context -> { - GrpcClientEventListener listener = context.getBean("grpcClientEventListener", GrpcClientEventListener.class); - assertNotNull(listener); - }); - registerUtilsMockedStatic.close(); - } - - @Test - public void testGrpcContextRefreshedEventListener() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.of("token")); - applicationContextRunner.run(context -> { - GrpcClientEventListener listener = context.getBean("grpcClientEventListener", GrpcClientEventListener.class); - assertNotNull(listener); - }); - registerUtilsMockedStatic.close(); - } - - @Test - public void testGrpcServerRunner() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.of("token")); - applicationContextRunner.run(context -> { - GrpcServerRunner runner = context.getBean("grpcServer", GrpcServerRunner.class); - assertNotNull(runner); - }); - registerUtilsMockedStatic.close(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/test/java/org/apache/springboot/starter/client/grpc/server/ShenyuGrpcServerBuilderTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/test/java/org/apache/springboot/starter/client/grpc/server/ShenyuGrpcServerBuilderTest.java deleted file mode 100644 index 762711d..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-grpc/src/test/java/org/apache/springboot/starter/client/grpc/server/ShenyuGrpcServerBuilderTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.springboot.starter.client.grpc.server; - -import io.grpc.ServerBuilder; -import org.apache.shenyu.client.grpc.server.GrpcServerBuilder; -import org.springframework.stereotype.Component; - -/** - * Grpc ServerBuilder Test. - */ -@Component -public class ShenyuGrpcServerBuilderTest implements GrpcServerBuilder { - - @Override - public ServerBuilder buildServerBuilder() { - return ServerBuilder.forPort(8080); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/ShenyuMotanClientConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/ShenyuMotanClientConfiguration.java deleted file mode 100644 index 14ca497..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/ShenyuMotanClientConfiguration.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.motan; - -import com.weibo.api.motan.common.MotanConstants; -import com.weibo.api.motan.config.springsupport.AnnotationBean; -import com.weibo.api.motan.config.springsupport.BasicServiceConfigBean; -import com.weibo.api.motan.config.springsupport.ProtocolConfigBean; -import com.weibo.api.motan.config.springsupport.RegistryConfigBean; -import com.weibo.api.motan.util.MotanSwitcherUtil; -import org.apache.shenyu.client.motan.MotanServiceEventListener; -import org.apache.shenyu.common.utils.VersionUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.apache.shenyu.springboot.starter.client.motan.property.RegistryConfig; -import org.apache.shenyu.springboot.starter.client.motan.property.ShenyuMotanConfig; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.event.ContextRefreshedEvent; - -/** - * Motan type client event listener. - */ -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuMotanClientConfiguration implements ApplicationListener { - - static { - VersionUtils.checkDuplicate(ShenyuMotanClientConfiguration.class); - } - - /** - * Motan service event listener. - * - * @param clientConfig the client config - * @param shenyuClientRegisterRepository the shenyuClientRegisterRepository - * @return the motan service event listener - */ - @Bean - public MotanServiceEventListener motanServiceEventListener(final ShenyuClientConfig clientConfig, final ShenyuClientRegisterRepository shenyuClientRegisterRepository) { - return new MotanServiceEventListener(clientConfig, shenyuClientRegisterRepository); - } - - /** - * Motan registry. - * - * @return registryProperties - */ - @Bean - @ConfigurationProperties(prefix = "motan.registry") - public RegistryConfig registryProperties() { - return new RegistryConfig(); - } - - /** - * Shenyu motan properties. - * - * @return shenyuMotanProperties - */ - @Bean - @ConfigurationProperties(prefix = "shenyu.client.motan") - public ShenyuMotanConfig shenyuMotanProperties() { - return new ShenyuMotanConfig(); - } - - /** - * Define the annotation bean, set the scan package. - * - *

The packagePath seems to be better set in ShenyuMotanConfig, - * but if so, the parameters in the configuration file can not be read, - * using @Value can, probably related to the bean loading timing. - * - * @param packagePath package path - * @return annotationBean - */ - - @Bean - public AnnotationBean motanAnnotationBean(@Value("${shenyu.client.motan.package-path}")final String packagePath) { - AnnotationBean motanAnnotationBean = new AnnotationBean(); - motanAnnotationBean.setPackage(packagePath); - return motanAnnotationBean; - } - - /** - * Define a bean with name of ProtocolConfigBean. - * - *

The protocol id、name are "motan2",service export like this "motan2:8001". - * - * @param shenyuMotanConfig shenyu motan config - * @return ProtocolConfigBean - */ - @Bean("motan2") - public ProtocolConfigBean protocolConfig(final ShenyuMotanConfig shenyuMotanConfig) { - ProtocolConfigBean config = new ProtocolConfigBean(); - config.setDefault(shenyuMotanConfig.getProtocol().isDefault()); - config.setName("motan2"); - config.setMaxContentLength(shenyuMotanConfig.getProtocol().getMaxContentLength()); - return config; - } - - /** - * Define a bean with name of ProtocolConfigBean. - * - *

The protocol id、name are "motan",service export like this "motan:8001". - * @param shenyuMotanConfig shenyu motan config - * @return ProtocolConfigBean - */ - @Bean("motan") - public ProtocolConfigBean motanProtocolConfig(final ShenyuMotanConfig shenyuMotanConfig) { - ProtocolConfigBean config = new ProtocolConfigBean(); - config.setDefault(shenyuMotanConfig.getProtocol().isDefault()); - config.setName("motan"); - config.setMaxContentLength(shenyuMotanConfig.getProtocol().getMaxContentLength()); - return config; - } - - /** - * Define a bean with name registryConfig1 of RegistryConfigBean. - * - * @param registryConfig registry registryConfig - * @return registryConfig - */ - @Bean - public RegistryConfigBean registryConfig(final RegistryConfig registryConfig) { - RegistryConfigBean config = new RegistryConfigBean(); - config.setRegProtocol(registryConfig.getProtocol()); - config.setAddress(registryConfig.getAddress()); - return config; - } - - /** - * Define a bean with name baseServiceConfig of BasicServiceConfigBean. - * - * @param shenyuMotanConfig shenyu motan shenyuMotanConfig - * @return baseServiceConfig - */ - @Bean - public BasicServiceConfigBean baseServiceConfig(final ShenyuMotanConfig shenyuMotanConfig) { - BasicServiceConfigBean config = new BasicServiceConfigBean(); - config.setExport(String.format("%s:%s", shenyuMotanConfig.getProtocol().getName(), shenyuMotanConfig.getBasicServiceConfig().getExportPort())); - config.setGroup(shenyuMotanConfig.getBasicServiceConfig().getGroup()); - config.setAccessLog(shenyuMotanConfig.getBasicServiceConfig().isAccessLog()); - config.setShareChannel(shenyuMotanConfig.getBasicServiceConfig().isShareChannel()); - config.setModule(shenyuMotanConfig.getBasicServiceConfig().getModule()); - config.setApplication(shenyuMotanConfig.getBasicServiceConfig().getApplication()); - config.setRegistry(shenyuMotanConfig.getBasicServiceConfig().getRegistry()); - config.setRequestTimeout(shenyuMotanConfig.getBasicServiceConfig().getRequestTimeout()); - return config; - } - - @Override - public void onApplicationEvent(final ContextRefreshedEvent event) { - ShenyuMotanConfig shenyuMotanConfig = event.getApplicationContext().getBean(ShenyuMotanConfig.class); - MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, shenyuMotanConfig.getBasicServiceConfig().getRegistryHeartBeatSwitcher()); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/property/RegistryConfig.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/property/RegistryConfig.java deleted file mode 100644 index 095c24f..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/property/RegistryConfig.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.motan.property; - -/** - * Motan Registry config. - */ -public class RegistryConfig { - - private String protocol; - - private String address; - - /** - * Get the protocol. - * - * @return the protocol - */ - public String getProtocol() { - return protocol; - } - - /** - * Set the protocol. - * - * @param protocol the protocol - */ - public void setProtocol(final String protocol) { - this.protocol = protocol; - } - - /** - * Get the address. - * - * @return the address - */ - public String getAddress() { - return address; - } - - /** - * Set the address. - * - * @param address the address - */ - public void setAddress(final String address) { - this.address = address; - } - -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/property/ShenyuMotanConfig.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/property/ShenyuMotanConfig.java deleted file mode 100644 index d4c7464..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/java/org/apache/shenyu/springboot/starter/client/motan/property/ShenyuMotanConfig.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.motan.property; - -import org.apache.commons.lang3.StringUtils; - -/** - * Shenyu motan properties. - */ -public class ShenyuMotanConfig { - - private Protocol protocol = new Protocol(); - - private BasicServiceConfig basicServiceConfig = new BasicServiceConfig(); - - /** - * Get the protocol config. - * @return protocol config - */ - public Protocol getProtocol() { - return protocol; - } - - /** - * Set the protocol config. - * @param protocol protocol config - */ - public void setProtocol(final Protocol protocol) { - this.protocol = protocol; - } - - /** - * Get the BasicServiceConfig. - * @return basicServiceConfig - */ - public BasicServiceConfig getBasicServiceConfig() { - return basicServiceConfig; - } - - /** - * Set the basicServiceConfig. - * @param basicServiceConfig basicServiceConfig - */ - public void setBasicServiceConfig(final BasicServiceConfig basicServiceConfig) { - this.basicServiceConfig = basicServiceConfig; - } - - public static class Protocol { - - private boolean isDefault = true; - - private String name; - - private Integer maxContentLength = 1048576; - - /** - * Get is default. - * @return isDefault isDefault - */ - public boolean isDefault() { - return isDefault; - } - - /** - * Set is default. - * @param isDefault isDefault - */ - public void setDefault(final boolean isDefault) { - this.isDefault = isDefault; - } - - /** - * Get the name. - * @return name - */ - public String getName() { - if (StringUtils.isNotEmpty(name)) { - return name; - } else { - return "motan2"; - } - } - - /** - * Set the name. - * @param name name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * Get the maxContentLength. - * @return maxContentLength - */ - public Integer getMaxContentLength() { - return maxContentLength; - } - - /** - * Set the maxContentLength. - * @param maxContentLength maxContentLength - */ - public void setMaxContentLength(final Integer maxContentLength) { - this.maxContentLength = maxContentLength; - } - } - - public static class BasicServiceConfig { - - private String exportPort; - - private String group = "motan-shenyu-rpc"; - - private boolean accessLog; - - private boolean shareChannel = true; - - private String module; - - private String application; - - private String registry = "registryConfig"; - - private Integer requestTimeout = 2000; - - private boolean registryHeartBeatSwitcher = true; - - /** - * Get the exportPort. - * @return exportPort - */ - public String getExportPort() { - return exportPort; - } - - /** - * Set the exportPort. - * @param exportPort exportPort - */ - public void setExportPort(final String exportPort) { - this.exportPort = exportPort; - } - - /** - * Get the group. - * @return group - */ - public String getGroup() { - return group; - } - - /** - * Set the group. - * @param group group - */ - public void setGroup(final String group) { - this.group = group; - } - - /** - * Get the accessLog. - * @return accessLog - */ - public boolean isAccessLog() { - return accessLog; - } - - /** - * Set the accessLog. - * @param accessLog accessLog - */ - public void setAccessLog(final boolean accessLog) { - this.accessLog = accessLog; - } - - /** - * Get the shareChannel. - * @return shareChannel - */ - public boolean isShareChannel() { - return shareChannel; - } - - /** - * Set the shareChannel. - * @param shareChannel shareChannel - */ - public void setShareChannel(final boolean shareChannel) { - this.shareChannel = shareChannel; - } - - /** - * Get the module. - * @return module - */ - public String getModule() { - return module; - } - - /** - * Set the module. - * @param module module - */ - public void setModule(final String module) { - this.module = module; - } - - /** - * Get the application. - * @return application - */ - public String getApplication() { - return application; - } - - /** - * Set the application. - * @param application application - */ - public void setApplication(final String application) { - this.application = application; - } - - /** - * Get the registry. - * @return registry - */ - public String getRegistry() { - return registry; - } - - /** - * Set the registry. - * @param registry registry - */ - public void setRegistry(final String registry) { - this.registry = registry; - } - - /** - * Get the requestTimeout. - * @return requestTimeout - */ - public Integer getRequestTimeout() { - return requestTimeout; - } - - /** - * Set the requestTimeout. - * @param requestTimeout requestTimeout - */ - public void setRequestTimeout(final Integer requestTimeout) { - this.requestTimeout = requestTimeout; - } - - /** - * Get the registryHeartBeatSwitcher. - * @return registryHeartBeatSwitcher - */ - public boolean getRegistryHeartBeatSwitcher() { - return registryHeartBeatSwitcher; - } - - /** - * Set the registryHeartBeatSwitcher. - * @param registryHeartBeatSwitcher registryHeartBeatSwitcher - */ - public void setRegistryHeartBeatSwitcher(final boolean registryHeartBeatSwitcher) { - this.registryHeartBeatSwitcher = registryHeartBeatSwitcher; - } - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring.factories deleted file mode 100644 index f704de2..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.springboot.starter.client.motan.ShenyuMotanClientConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring.provides b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring.provides deleted file mode 100644 index c2419be..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -provides: shenyu-spring-boot-starter-java-client-motan diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 1f02777..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.apache.shenyu.springboot.starter.client.motan.ShenyuMotanClientConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/test/java/org/apache/shenyu/springboot/starter/client/motan/ShenyuMotanClientConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/test/java/org/apache/shenyu/springboot/starter/client/motan/ShenyuMotanClientConfigurationTest.java deleted file mode 100644 index fd13b8a..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-motan/src/test/java/org/apache/shenyu/springboot/starter/client/motan/ShenyuMotanClientConfigurationTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.motan; - -import com.weibo.api.motan.config.springsupport.ProtocolConfigBean; -import org.apache.shenyu.client.motan.MotanServiceEventListener; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -/** - * Test case for {@link ShenyuMotanClientConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -public class ShenyuMotanClientConfigurationTest { - - @Test - public void testMotanServiceEventListener() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuMotanClientConfiguration.class)) - .withBean(ShenyuMotanClientConfigurationTest.class) - .withBean(ProtocolConfigBean.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "shenyu.client.motan.props[contextPath]=/motan", - "shenyu.client.motan.props[appName]=motan", - "shenyu.client.motan.props[host]=127.0.0.1", - "shenyu.client.motan.props[port]=8081", - "shenyu.client.motan.basicServiceConfig.exportPort=8002" - ) - .run(context -> { - MotanServiceEventListener motanServiceEventListener = context.getBean("motanServiceEventListener", MotanServiceEventListener.class); - assertNotNull(motanServiceEventListener); - }); - registerUtilsMockedStatic.close(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/java/org/apache/shenyu/springboot/starter/client/sofa/ShenyuSofaClientConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/java/org/apache/shenyu/springboot/starter/client/sofa/ShenyuSofaClientConfiguration.java deleted file mode 100644 index ca8fe17..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/java/org/apache/shenyu/springboot/starter/client/sofa/ShenyuSofaClientConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.sofa; - -import org.apache.shenyu.client.sofa.SofaServiceEventListener; -import org.apache.shenyu.common.utils.VersionUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Sofa type client event listener. - */ -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuSofaClientConfiguration { - - static { - VersionUtils.checkDuplicate(ShenyuSofaClientConfiguration.class); - } - - /** - * Sofa service event listener. - * - * @param clientConfig the client config - * @param shenyuClientRegisterRepository the shenyuClientRegisterRepository - * @return the sofa service event listener - */ - @Bean - public SofaServiceEventListener sofaServiceEventListener(final ShenyuClientConfig clientConfig, final ShenyuClientRegisterRepository shenyuClientRegisterRepository) { - return new SofaServiceEventListener(clientConfig, shenyuClientRegisterRepository); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 4f9afdc..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.springboot.starter.client.sofa.ShenyuSofaClientConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring.provides b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 80c3a10..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -provides: shenyu-spring-boot-starter-java-client-sofa diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 78d2ff8..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.apache.shenyu.springboot.starter.client.sofa.ShenyuSofaClientConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/test/java/org/apache/shenyu/springboot/starter/client/sofa/ShenyuSofaClientConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/test/java/org/apache/shenyu/springboot/starter/client/sofa/ShenyuSofaClientConfigurationTest.java deleted file mode 100644 index 415b614..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-sofa/src/test/java/org/apache/shenyu/springboot/starter/client/sofa/ShenyuSofaClientConfigurationTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.sofa; - -import org.apache.shenyu.client.sofa.SofaServiceEventListener; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -/** - * Test case for {@link ShenyuSofaClientConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -public class ShenyuSofaClientConfigurationTest { - - private ApplicationContextRunner applicationContextRunner; - - @BeforeEach - public void before() { - applicationContextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuSofaClientConfiguration.class)) - .withBean(ShenyuSofaClientConfigurationTest.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "shenyu.client.sofa.props[contextPath]=/sofa", - "shenyu.client.sofa.props[appName]=sofa", - "shenyu.client.sofa.props[host]=127.0.0.1", - "shenyu.client.sofa.props[port]=8888" - ); - } - - @Test - public void testSofaServiceEventListener() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - SofaServiceEventListener eventListener = context.getBean("sofaServiceEventListener", SofaServiceEventListener.class); - assertNotNull(eventListener); - assertEquals(eventListener.getAppName(), "sofa"); - assertEquals(eventListener.getHost(), "127.0.0.1"); - assertEquals(eventListener.getPort(), "8888"); - assertEquals(eventListener.getContextPath(), "/sofa"); - }); - registerUtilsMockedStatic.close(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketClientConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketClientConfiguration.java deleted file mode 100644 index 3a31e8a..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketClientConfiguration.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.spring.websocket; - -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.ClientRegisterConfigImpl; -import org.apache.shenyu.client.spring.websocket.init.SpringWebSocketClientEventListener; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.VersionUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; - -import java.util.Objects; -import java.util.Properties; - -/** - * The type shenyu websocket client http configuration. - */ -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuSpringWebSocketClientConfiguration { - - static { - VersionUtils.checkDuplicate(ShenyuSpringWebSocketClientConfiguration.class); - } - - /** - * Spring web socket client event listener. - * - * @param clientConfig the client config - * @param shenyuClientRegisterRepository the shenyu client register repository - * @param env env - * @return the spring web socket client event listener - */ - @Bean - public SpringWebSocketClientEventListener springWebSocketClientEventListener( - final ShenyuClientConfig clientConfig, - final Environment env, - final ShenyuClientRegisterRepository shenyuClientRegisterRepository) { - ShenyuClientConfig.ClientPropertiesConfig clientPropertiesConfig = clientConfig.getClient().get(RpcTypeEnum.WEB_SOCKET.getName()); - Properties props = Objects.isNull(clientPropertiesConfig) ? null : clientPropertiesConfig.getProps(); - String discoveryMode = env.getProperty("shenyu.discovery.type", ShenyuClientConstants.DISCOVERY_LOCAL_MODE); - if (Objects.nonNull(props)) { - props.setProperty(ShenyuClientConstants.DISCOVERY_LOCAL_MODE_KEY, Boolean.valueOf(ShenyuClientConstants.DISCOVERY_LOCAL_MODE.equals(discoveryMode)).toString()); - } - return new SpringWebSocketClientEventListener(clientConfig, shenyuClientRegisterRepository); - } - - /** - * ClientRegisterConfig Bean. - * - * @param shenyuClientConfig shenyuClientConfig - * @param applicationContext applicationContext - * @param env env - * @return clientRegisterConfig - */ - @Bean("webSocketClientRegisterConfig") - public ClientRegisterConfig clientRegisterConfig(final ShenyuClientConfig shenyuClientConfig, - final ApplicationContext applicationContext, - final Environment env) { - return new ClientRegisterConfigImpl(shenyuClientConfig, RpcTypeEnum.WEB_SOCKET, applicationContext, env); - } - -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketDiscoveryConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketDiscoveryConfiguration.java deleted file mode 100644 index 99e2bae..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketDiscoveryConfiguration.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.spring.websocket; - -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; -import org.apache.shenyu.client.core.register.ClientDiscoveryConfigRefreshedEventListener; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.InstanceRegisterListener; -import org.apache.shenyu.client.spring.websocket.init.SpringWebSocketClientEventListener; -import org.apache.shenyu.common.dto.DiscoveryUpstreamData; -import org.apache.shenyu.common.enums.PluginEnum; -import org.apache.shenyu.register.client.http.HttpClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuDiscoveryConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -public class ShenyuSpringWebSocketDiscoveryConfiguration { - - /** - * clientDiscoveryConfigRefreshedEventListener. - * - * @param shenyuDiscoveryConfig shenyuDiscoveryConfig - * @param httpClientRegisterRepository httpClientRegisterRepository - * @param clientRegisterConfig clientRegisterConfig - * @param shenyuClientConfig shenyuClientConfig - * @return ClientDiscoveryConfigRefreshedEventListener - */ - @Bean("WebSocketClientDiscoveryConfigRefreshedEventListener") - @ConditionalOnProperty(prefix = "shenyu.discovery", name = "serverList", matchIfMissing = false) - @ConditionalOnBean(ShenyuDiscoveryConfig.class) - public ClientDiscoveryConfigRefreshedEventListener clientDiscoveryConfigRefreshedEventListener(final ShenyuDiscoveryConfig shenyuDiscoveryConfig, - final HttpClientRegisterRepository httpClientRegisterRepository, - final ClientRegisterConfig clientRegisterConfig, - final ShenyuClientConfig shenyuClientConfig) { - return new ClientDiscoveryConfigRefreshedEventListener(shenyuDiscoveryConfig, httpClientRegisterRepository, clientRegisterConfig, PluginEnum.WEB_SOCKET, shenyuClientConfig); - } - - /** - * InstanceRegisterListener. - * - * @param eventListener eventListener - * @param shenyuDiscoveryConfig discoveryConfig - * @param shenyuClientConfig shenyuClientConfig - * @return InstanceRegisterListener - */ - @Bean("websocketInstanceRegisterListener") - @ConditionalOnBean(ShenyuDiscoveryConfig.class) - public InstanceRegisterListener instanceRegisterListener(final SpringWebSocketClientEventListener eventListener, - final ShenyuDiscoveryConfig shenyuDiscoveryConfig, - final ShenyuClientConfig shenyuClientConfig) { - DiscoveryUpstreamData discoveryUpstreamData = new DiscoveryUpstreamData(); - discoveryUpstreamData.setProtocol(ShenyuClientConstants.WS); - discoveryUpstreamData.setStatus(0); - discoveryUpstreamData.setWeight(50); - discoveryUpstreamData.setUrl(eventListener.getHost() + ":" + eventListener.getPort()); - discoveryUpstreamData.setNamespaceId(shenyuClientConfig.getNamespace()); - return new InstanceRegisterListener(discoveryUpstreamData, shenyuDiscoveryConfig); - } - -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 2482fc8..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.springboot.starter.client.spring.websocket.ShenyuSpringWebSocketClientConfiguration,\ -org.apache.shenyu.springboot.starter.client.spring.websocket.ShenyuSpringWebSocketDiscoveryConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring.provides b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring.provides deleted file mode 100644 index accece7..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -provides: shenyu-spring-boot-starter-java-client-spring-websocket diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 3dc5898..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.apache.shenyu.springboot.starter.client.spring.websocket.ShenyuSpringWebSocketClientConfiguration -org.apache.shenyu.springboot.starter.client.spring.websocket.ShenyuSpringWebSocketDiscoveryConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/test/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketClientConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/test/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketClientConfigurationTest.java deleted file mode 100644 index 939280c..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-spring-websocket/src/test/java/org/apache/shenyu/springboot/starter/client/spring/websocket/ShenyuSpringWebSocketClientConfigurationTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.spring.websocket; - -import org.apache.shenyu.client.spring.websocket.init.SpringWebSocketClientEventListener; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -/** - * Test case for {@link ShenyuSpringWebSocketClientConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -public class ShenyuSpringWebSocketClientConfigurationTest { - - private ApplicationContextRunner applicationContextRunner; - - @BeforeEach - public void before() { - applicationContextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuSpringWebSocketClientConfiguration.class)) - .withBean(ShenyuSpringWebSocketClientConfigurationTest.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "shenyu.client.websocket.props[contextPath]=/websocket", - "shenyu.client.websocket.props[appName]=websocket", - "shenyu.client.websocket.props[port]=8001" - ); - } - - @Test - public void testSpringWebSocketClientEventListener() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - SpringWebSocketClientEventListener eventListener = context.getBean("springWebSocketClientEventListener", SpringWebSocketClientEventListener.class); - assertNotNull(eventListener); - }); - registerUtilsMockedStatic.close(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/pom.xml b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/pom.xml deleted file mode 100644 index 7981959..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-spring-boot-starter-java-client-springcloud - - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.apache.shenyu - shenyu-client-java-springcloud - ${project.version} - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-common - ${project.version} - - - org.apache.shenyu - shenyu-client-java-autoconfig - ${project.version} - - - diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientConfiguration.java deleted file mode 100644 index 014197b..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientConfiguration.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.springcloud; - -import org.apache.shenyu.client.auto.config.ClientRegisterConfiguration; -import org.apache.shenyu.client.springcloud.init.SpringCloudClientEventListener; -import org.apache.shenyu.common.utils.VersionUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; - -/** - * The type shenyu spring cloud client configuration. - */ -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuSpringCloudClientConfiguration { - - static { - VersionUtils.checkDuplicate(ShenyuSpringCloudClientConfiguration.class); - } - - /** - * Spring cloud client bean post processor. - * - * @param clientConfig the client config - * @param shenyuClientRegisterRepository the shenyu client register repository - * @param env the env - * @return the spring cloud client bean post processor - */ - @Bean - @ConditionalOnMissingBean(ClientRegisterConfiguration.class) - public SpringCloudClientEventListener springCloudClientEventListener(final ShenyuClientConfig clientConfig, - final ShenyuClientRegisterRepository shenyuClientRegisterRepository, - final Environment env) { - return new SpringCloudClientEventListener(clientConfig, shenyuClientRegisterRepository, env); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientInfoRegisterConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientInfoRegisterConfiguration.java deleted file mode 100644 index cd2138c..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientInfoRegisterConfiguration.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.springcloud; - -import org.apache.shenyu.client.auto.config.ClientRegisterConfiguration; -import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.ClientRegisterConfigImpl; -import org.apache.shenyu.client.core.register.matcher.ExtractorProcessor; -import org.apache.shenyu.client.core.register.registrar.AbstractApiDocRegistrar; -import org.apache.shenyu.client.core.register.registrar.AbstractApiMetaRegistrar; -import org.apache.shenyu.client.core.register.registrar.HttpApiDocRegistrar; -import org.apache.shenyu.client.springcloud.proceeor.register.ShenyuSpringCloudClientProcessorImpl; -import org.apache.shenyu.client.springcloud.register.SpringCloudApiBeansExtractor; -import org.apache.shenyu.client.springcloud.register.SpringCloudApiMetaRegister; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; - -import java.util.List; - -@Configuration(proxyBeanMethods = false) -@ConditionalOnBean(ClientRegisterConfiguration.class) -public class ShenyuSpringCloudClientInfoRegisterConfiguration { - - public ShenyuSpringCloudClientInfoRegisterConfiguration() { - } - - /** - * ApiBeansExtractor Bean. - * - * @param extractorProcessorList extractorProcessorList. - * @return apiBeansExtractor - */ - @Bean - @ConditionalOnMissingBean - public SpringCloudApiBeansExtractor springCloudApiBeansExtractor(final List extractorProcessorList) { - final SpringCloudApiBeansExtractor extractor = SpringCloudApiBeansExtractor.buildDefaultSpringCloudApiBeansExtractor(); - for (ExtractorProcessor processor : extractorProcessorList) { - extractor.addExtractorProcessor(processor); - } - return extractor; - } - - /** - * ShenyuSpringCloudClientProcessorImpl. - * - * @return ShenyuSpringCloudClientProcessorImpl - */ - @Bean - public ShenyuSpringCloudClientProcessorImpl shenyuSpringCloudClientProcessor() { - return new ShenyuSpringCloudClientProcessorImpl(); - } - - /** - * Builds ApiMetaRegistrar Bean. - * - * @param publisher publisher - * @param clientRegisterConfig clientRegisterConfig - * @return ApiMetaRegistrar - */ - @Bean(name = "ApiMetaRegistrar") - @ConditionalOnProperty(value = "shenyu.register.api.meta.enabled", matchIfMissing = true, havingValue = "true") - public AbstractApiMetaRegistrar buildApiMetaRegistrar(final ShenyuClientRegisterEventPublisher publisher, - final ClientRegisterConfig clientRegisterConfig) { - - return new SpringCloudApiMetaRegister(publisher, clientRegisterConfig); - } - - /** - * Builds ApiDocRegistrar Bean. - * - * @param publisher publisher - * @param clientRegisterConfig clientRegisterConfig - * @return ApiDocRegistrar - */ - @Bean(name = "ApiDocRegistrar") - @ConditionalOnProperty(value = "shenyu.register.api.data.enabled", matchIfMissing = true, havingValue = "true") - public AbstractApiDocRegistrar buildApiDocRegistrar(final ShenyuClientRegisterEventPublisher publisher, - final ClientRegisterConfig clientRegisterConfig) { - return new HttpApiDocRegistrar(publisher, clientRegisterConfig); - } - - /** - * ClientRegisterConfig Bean. - * - * @param shenyuClientConfig shenyuClientConfig - * @param applicationContext applicationContext - * @param env env - * @return clientRegisterConfig - */ - @Bean - public ClientRegisterConfig clientRegisterConfig(final ShenyuClientConfig shenyuClientConfig, - final ApplicationContext applicationContext, - final Environment env) { - return new ClientRegisterConfigImpl(shenyuClientConfig, RpcTypeEnum.SPRING_CLOUD, applicationContext, env); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 6ad9bee..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.springboot.starter.client.springcloud.ShenyuSpringCloudClientConfiguration,\ -org.apache.shenyu.springboot.starter.client.springcloud.ShenyuSpringCloudClientInfoRegisterConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring.provides b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 18500f1..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -provides: shenyu-spring-boot-starter-java-client-springcloud diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 5f2964d..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - - -org.apache.shenyu.springboot.starter.client.springcloud.ShenyuSpringCloudClientConfiguration -org.apache.shenyu.springboot.starter.client.springcloud.ShenyuSpringCloudClientInfoRegisterConfiguration \ No newline at end of file diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/test/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/test/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientConfigurationTest.java deleted file mode 100644 index 37b45c0..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springcloud/src/test/java/org/apache/shenyu/springboot/starter/client/springcloud/ShenyuSpringCloudClientConfigurationTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.springcloud; - -import org.apache.shenyu.client.springcloud.init.SpringCloudClientEventListener; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -/** - * Test case for {@link ShenyuSpringCloudClientConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -public class ShenyuSpringCloudClientConfigurationTest { - - private ApplicationContextRunner applicationContextRunner; - - @BeforeEach - public void before() { - applicationContextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuSpringCloudClientConfiguration.class)) - .withBean(ShenyuSpringCloudClientConfigurationTest.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "spring.application.name=springcloud", - "shenyu.client.springCloud.props[contextPath]=/springcloud", - "shenyu.client.springCloud.props[port]=8884" - ); - } - - @Test - public void testSpringCloudClientBeanPostProcessor() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - SpringCloudClientEventListener repository = context.getBean("springCloudClientEventListener", SpringCloudClientEventListener.class); - assertNotNull(repository); - }); - registerUtilsMockedStatic.close(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/pom.xml b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/pom.xml deleted file mode 100644 index 0546036..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-spring-boot-starter-java-client-springmvc - - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.apache.shenyu - shenyu-client-java-springmvc - ${project.version} - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-common - ${project.version} - - - org.apache.shenyu - shenyu-client-java-autoconfig - ${project.version} - - - diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientConfiguration.java deleted file mode 100644 index a095735..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientConfiguration.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.springmvc; - -import java.util.Objects; -import java.util.Optional; -import org.apache.commons.lang3.StringUtils; -import org.apache.shenyu.client.auto.config.ClientRegisterConfiguration; -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.ClientRegisterConfigImpl; -import org.apache.shenyu.client.springmvc.init.SpringMvcClientEventListener; -import org.apache.shenyu.common.enums.RpcTypeEnum; -import org.apache.shenyu.common.utils.VersionUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuClientConfig.ClientPropertiesConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.core.env.Environment; - -import java.util.Properties; - -/** - * The type shenyu spring mvc client configuration. - */ -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuSpringMvcClientConfiguration { - - static { - VersionUtils.checkDuplicate(ShenyuSpringMvcClientConfiguration.class); - } - - /** - * Spring mvc client event listener. - * - * @param clientConfig the client config - * @param shenyuClientRegisterRepository the shenyu client register repository - * @param env the env - * @return the spring mvc client event listener - */ - @Bean - @ConditionalOnMissingBean(ClientRegisterConfiguration.class) - public SpringMvcClientEventListener springHttpClientEventListener(final ShenyuClientConfig clientConfig, - final ShenyuClientRegisterRepository shenyuClientRegisterRepository, - final Environment env) { - ClientPropertiesConfig clientPropertiesConfig = clientConfig.getClient().get(RpcTypeEnum.HTTP.getName()); - Properties props = Optional.ofNullable(clientPropertiesConfig).map(ClientPropertiesConfig::getProps).orElse(null); - String applicationName = env.getProperty("spring.application.name"); - String discoveryMode = env.getProperty("shenyu.discovery.type", ShenyuClientConstants.DISCOVERY_LOCAL_MODE); - if (Objects.nonNull(props)) { - String appName = props.getProperty(ShenyuClientConstants.APP_NAME); - if (StringUtils.isBlank(appName) && StringUtils.isBlank(applicationName)) { - throw new IllegalArgumentException("spring.application.name or shenyu.client.http.props.appName must not be empty"); - } - if (StringUtils.isBlank(appName)) { - props.setProperty(ShenyuClientConstants.APP_NAME, applicationName); - } - String contextPath = props.getProperty(ShenyuClientConstants.CONTEXT_PATH); - if (StringUtils.isBlank(contextPath)) { - props.setProperty(ShenyuClientConstants.CONTEXT_PATH, String.format("/%s", applicationName)); - } - props.setProperty(ShenyuClientConstants.DISCOVERY_LOCAL_MODE_KEY, Boolean.valueOf(ShenyuClientConstants.DISCOVERY_LOCAL_MODE.equals(discoveryMode)).toString()); - } - return new SpringMvcClientEventListener(clientConfig, shenyuClientRegisterRepository, env); - } - - /** - * ClientRegisterConfig Bean. - * - * @param shenyuClientConfig shenyuClientConfig - * @param applicationContext applicationContext - * @param env env - * @return clientRegisterConfig - */ - @Bean("springMvcClientRegisterConfig") - @Primary - public ClientRegisterConfig clientRegisterConfig(final ShenyuClientConfig shenyuClientConfig, - final ApplicationContext applicationContext, - final Environment env) { - return new ClientRegisterConfigImpl(shenyuClientConfig, RpcTypeEnum.HTTP, applicationContext, env); - } - -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientInfoRegisterConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientInfoRegisterConfiguration.java deleted file mode 100644 index a3e3894..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientInfoRegisterConfiguration.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.springmvc; - -import org.apache.shenyu.client.auto.config.ClientRegisterConfiguration; -import org.apache.shenyu.client.core.disruptor.ShenyuClientRegisterEventPublisher; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.matcher.ExtractorProcessor; -import org.apache.shenyu.client.core.register.registrar.AbstractApiDocRegistrar; -import org.apache.shenyu.client.core.register.registrar.AbstractApiMetaRegistrar; -import org.apache.shenyu.client.core.register.registrar.HttpApiDocRegistrar; -import org.apache.shenyu.client.springmvc.proceeor.register.ShenyuSpringMvcClientProcessorImpl; -import org.apache.shenyu.client.springmvc.register.SpringMvcApiBeansExtractor; -import org.apache.shenyu.client.springmvc.register.SpringMvcApiMetaRegister; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.List; - -@Configuration(proxyBeanMethods = false) -@ConditionalOnBean(ClientRegisterConfiguration.class) -public class ShenyuSpringMvcClientInfoRegisterConfiguration { - - public ShenyuSpringMvcClientInfoRegisterConfiguration() { - } - - /** - * ApiBeansExtractor Bean. - * - * @param extractorProcessorList extractorProcessorList - * @return apiBeansExtractor - */ - @Bean - @ConditionalOnMissingBean - public SpringMvcApiBeansExtractor springMvcApiBeansExtractor(final List extractorProcessorList) { - final SpringMvcApiBeansExtractor extractor = SpringMvcApiBeansExtractor.buildDefaultSpringMvcApiBeansExtractor(); - for (ExtractorProcessor processor : extractorProcessorList) { - extractor.addExtractorProcessor(processor); - } - return extractor; - } - - /** - * shenyuSpringMvcClientProcessor. - * - * @return shenyuSpringMvcClientProcessor - */ - @Bean - public ShenyuSpringMvcClientProcessorImpl shenyuSpringMvcClientProcessor() { - return new ShenyuSpringMvcClientProcessorImpl(); - } - - /** - * Builds ApiMetaRegistrar Bean. - * - * @param publisher publisher - * @param clientRegisterConfig clientRegisterConfig - * @return ApiMetaRegistrar - */ - public AbstractApiMetaRegistrar buildApiMetaRegistrar(final ShenyuClientRegisterEventPublisher publisher, - final ClientRegisterConfig clientRegisterConfig) { - - return new SpringMvcApiMetaRegister(publisher, clientRegisterConfig); - } - - /** - * Builds ApiDocRegistrar Bean. - * - * @param publisher publisher - * @param clientRegisterConfig clientRegisterConfig - * @return ApiDocRegistrar - */ - public AbstractApiDocRegistrar buildApiDocRegistrar(final ShenyuClientRegisterEventPublisher publisher, - final ClientRegisterConfig clientRegisterConfig) { - return new HttpApiDocRegistrar(publisher, clientRegisterConfig); - } - -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcDiscoveryConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcDiscoveryConfiguration.java deleted file mode 100644 index 61a4930..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcDiscoveryConfiguration.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.springmvc; - -import org.apache.shenyu.client.core.constant.ShenyuClientConstants; -import org.apache.shenyu.client.core.register.ClientDiscoveryConfigRefreshedEventListener; -import org.apache.shenyu.client.core.register.ClientRegisterConfig; -import org.apache.shenyu.client.core.register.InstanceRegisterListener; -import org.apache.shenyu.common.dto.DiscoveryUpstreamData; -import org.apache.shenyu.common.enums.PluginEnum; -import org.apache.shenyu.register.client.http.HttpClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.register.common.config.ShenyuDiscoveryConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -import java.util.Optional; - -@Configuration -@ConditionalOnBean(ClientRegisterConfig.class) -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -public class ShenyuSpringMvcDiscoveryConfiguration { - - - /** - * clientDiscoveryConfigRefreshedEventListener Bean. - * - * @param shenyuDiscoveryConfig shenyuDiscoveryConfig - * @param httpClientRegisterRepository httpClientRegisterRepository - * @param clientRegisterConfig clientRegisterConfig - * @param shenyuClientConfig shenyuClientConfig - * @return ClientDiscoveryConfigRefreshedEventListener - */ - @Bean("SpringMvcClientDiscoveryConfigRefreshedEventListener") - @ConditionalOnProperty(prefix = "shenyu.discovery", name = "serverList", matchIfMissing = false) - @ConditionalOnBean(ShenyuDiscoveryConfig.class) - public ClientDiscoveryConfigRefreshedEventListener clientDiscoveryConfigRefreshedEventListener(final ShenyuDiscoveryConfig shenyuDiscoveryConfig, - final HttpClientRegisterRepository httpClientRegisterRepository, - final ClientRegisterConfig clientRegisterConfig, - final ShenyuClientConfig shenyuClientConfig) { - return new ClientDiscoveryConfigRefreshedEventListener(shenyuDiscoveryConfig, httpClientRegisterRepository, clientRegisterConfig, PluginEnum.DIVIDE, shenyuClientConfig); - } - - /** - * InstanceRegisterListener. - * - * @param clientRegisterConfig clientRegisterConfig - * @param shenyuDiscoveryConfig shenyuDiscoveryConfig - * @param shenyuClientConfig shenyuClientConfig - * @return InstanceRegisterListener - */ - @Bean("springmvcInstanceRegisterListener") - @ConditionalOnBean(ShenyuDiscoveryConfig.class) - @Primary - public InstanceRegisterListener instanceRegisterListener(final ClientRegisterConfig clientRegisterConfig, - final ShenyuDiscoveryConfig shenyuDiscoveryConfig, - final ShenyuClientConfig shenyuClientConfig) { - DiscoveryUpstreamData discoveryUpstreamData = new DiscoveryUpstreamData(); - discoveryUpstreamData.setUrl(clientRegisterConfig.getHost() + ":" + clientRegisterConfig.getPort()); - discoveryUpstreamData.setStatus(0); - discoveryUpstreamData.setWeight(50); - discoveryUpstreamData.setProtocol(Optional.ofNullable(shenyuDiscoveryConfig.getProtocol()).orElse(ShenyuClientConstants.HTTP)); - discoveryUpstreamData.setNamespaceId(shenyuClientConfig.getNamespace()); - return new InstanceRegisterListener(discoveryUpstreamData, shenyuDiscoveryConfig); - } - -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 31e130c..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.springboot.starter.client.springmvc.ShenyuSpringMvcClientConfiguration,\ -org.apache.shenyu.springboot.starter.client.springmvc.ShenyuSpringMvcClientInfoRegisterConfiguration,\ -org.apache.shenyu.springboot.starter.client.springmvc.ShenyuSpringMvcDiscoveryConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring.provides b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 6c09dca..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -provides: shenyu-spring-boot-starter-java-client-springmvc diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 4c08506..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.apache.shenyu.springboot.starter.client.springmvc.ShenyuSpringMvcClientConfiguration -org.apache.shenyu.springboot.starter.client.springmvc.ShenyuSpringMvcClientInfoRegisterConfiguration -org.apache.shenyu.springboot.starter.client.springmvc.ShenyuSpringMvcDiscoveryConfiguration \ No newline at end of file diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/test/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/test/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientConfigurationTest.java deleted file mode 100644 index 761d05a..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-springmvc/src/test/java/org/apache/shenyu/springboot/starter/client/springmvc/ShenyuSpringMvcClientConfigurationTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.springmvc; - -import org.apache.shenyu.client.springmvc.init.SpringMvcClientEventListener; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; -import static org.springframework.test.util.AssertionErrors.assertEquals; - -/** - * Test case for {@link ShenyuSpringMvcClientConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -public class ShenyuSpringMvcClientConfigurationTest { - - private ApplicationContextRunner applicationContextRunner; - - @BeforeEach - public void before() { - applicationContextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuSpringMvcClientConfiguration.class)) - .withBean(ShenyuSpringMvcClientConfigurationTest.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "shenyu.client.http.props[contextPath]=/http", - "shenyu.client.http.props[appName]=http", - "shenyu.client.http.props[port]=8189" - ); - } - - @BeforeEach - public void beforeWithDefault() { - applicationContextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuSpringMvcClientConfiguration.class)) - .withBean(ShenyuSpringMvcClientConfigurationTest.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "spring.application.name=test-for-http", - "shenyu.client.http.props[port]=8189" - ); - } - - @Test - public void testSpringMvcClientEventListener() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - SpringMvcClientEventListener processor = context.getBean("springHttpClientEventListener", SpringMvcClientEventListener.class); - assertNotNull(processor); - }); - registerUtilsMockedStatic.close(); - } - - @Test - public void testSpringMvcClientEventListenerWithDefault() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - SpringMvcClientEventListener processor = context.getBean("springHttpClientEventListener", SpringMvcClientEventListener.class); - assertEquals("default-appName", "test-for-http", processor.getAppName()); - assertEquals("default-contextPath", "/test-for-http", processor.getContextPath()); - }); - registerUtilsMockedStatic.close(); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/pom.xml b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/pom.xml deleted file mode 100644 index 2b23e67..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client - 2.7.1-SNAPSHOT - - 4.0.0 - shenyu-spring-boot-starter-java-client-tars - - - - org.mockito - mockito-inline - 3.3.3 - test - - - org.apache.shenyu - shenyu-client-java-tars - ${project.version} - - - - org.apache.shenyu - shenyu-spring-boot-starter-java-client-common - ${project.version} - - - diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/java/org/apache/shenyu/springboot/starter/client/tars/ShenyuTarsClientConfiguration.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/java/org/apache/shenyu/springboot/starter/client/tars/ShenyuTarsClientConfiguration.java deleted file mode 100644 index 1e1861f..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/java/org/apache/shenyu/springboot/starter/client/tars/ShenyuTarsClientConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.tars; - -import org.apache.shenyu.client.tars.TarsServiceBeanEventListener; -import org.apache.shenyu.common.utils.VersionUtils; -import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository; -import org.apache.shenyu.register.common.config.ShenyuClientConfig; -import org.apache.shenyu.springboot.starter.client.common.config.ShenyuClientCommonBeanConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Tars type client bean postprocessor. - */ -@Configuration -@ImportAutoConfiguration(ShenyuClientCommonBeanConfiguration.class) -@ConditionalOnProperty(value = "shenyu.register.enabled", matchIfMissing = true, havingValue = "true") -public class ShenyuTarsClientConfiguration { - - static { - VersionUtils.checkDuplicate(ShenyuTarsClientConfiguration.class); - } - - /** - * Tars service bean post processor. - * - * @param clientConfig the client config - * @param shenyuClientRegisterRepository the shenyuClientRegisterRepository - * @return the tars service bean post processor - */ - @Bean - public TarsServiceBeanEventListener tarsServiceBeanEventListener(final ShenyuClientConfig clientConfig, final ShenyuClientRegisterRepository shenyuClientRegisterRepository) { - return new TarsServiceBeanEventListener(clientConfig, shenyuClientRegisterRepository); - } -} diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring.factories b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 60a0ce1..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.shenyu.springboot.starter.client.tars.ShenyuTarsClientConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring.provides b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 1a84051..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -provides: shenyu-spring-boot-starter-java-client-tars diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index e145b17..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -org.apache.shenyu.springboot.starter.client.tars.ShenyuTarsClientConfiguration diff --git a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/test/java/org/apache/shenyu/springboot/starter/client/tars/ShenyuTarsClientConfigurationTest.java b/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/test/java/org/apache/shenyu/springboot/starter/client/tars/ShenyuTarsClientConfigurationTest.java deleted file mode 100644 index 41d8eb8..0000000 --- a/shenyu-spring-boot-starter-java-client/shenyu-spring-boot-starter-java-client-tars/src/test/java/org/apache/shenyu/springboot/starter/client/tars/ShenyuTarsClientConfigurationTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.shenyu.springboot.starter.client.tars; - -import org.apache.shenyu.client.tars.TarsServiceBeanEventListener; -import org.apache.shenyu.register.client.http.utils.RegisterUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Configuration; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mockStatic; - -/** - * Test case for {@link ShenyuTarsClientConfiguration}. - */ -@Configuration -@EnableConfigurationProperties -public class ShenyuTarsClientConfigurationTest { - - private ApplicationContextRunner applicationContextRunner; - - @BeforeEach - public void before() { - applicationContextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(ShenyuTarsClientConfiguration.class)) - .withBean(ShenyuTarsClientConfigurationTest.class) - .withPropertyValues( - "debug=true", - "shenyu.register.registerType=http", - "shenyu.register.serverLists=http://localhost:9095", - "shenyu.register.props.username=admin", - "shenyu.register.props.password=123456", - "shenyu.client.tars.props[contextPath]=/tars", - "shenyu.client.tars.props[appName]=tars", - "shenyu.client.tars.props[host]=127.0.0.1", - "shenyu.client.tars.props[port]=21715" - ); - } - - @Test - public void testTarsServiceBeanPostProcessor() { - MockedStatic registerUtilsMockedStatic = mockStatic(RegisterUtils.class); - registerUtilsMockedStatic.when(() -> RegisterUtils.doLogin(any(), any(), any())).thenReturn(Optional.ofNullable("token")); - applicationContextRunner.run(context -> { - TarsServiceBeanEventListener listener = context.getBean("tarsServiceBeanEventListener", TarsServiceBeanEventListener.class); - assertNotNull(listener); - }); - registerUtilsMockedStatic.close(); - } -}