diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/Identity.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/base/Identity.java similarity index 98% rename from neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/Identity.java rename to neutrino-core/src/main/java/fun/asgc/neutrino/core/base/Identity.java index 2a77330e..e640867e 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/Identity.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/base/Identity.java @@ -19,7 +19,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package fun.asgc.neutrino.core.bean; +package fun.asgc.neutrino.core.base; /** * Identity 用于标识一个身份。 diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/AbstractBeanFactory.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/AbstractBeanFactory.java index e8d0688e..f927f299 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/AbstractBeanFactory.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/AbstractBeanFactory.java @@ -48,7 +48,7 @@ public abstract class AbstractBeanFactory implements BeanFactory, BeanRegistry, /** * 父工厂 */ - private AbstractBeanFactory parent; + protected AbstractBeanFactory parent; /** * bean缓存 */ diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/BeanIdentity.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/BeanIdentity.java index 6963d5ca..e4dfb18e 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/BeanIdentity.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/BeanIdentity.java @@ -21,6 +21,7 @@ */ package fun.asgc.neutrino.core.bean; +import fun.asgc.neutrino.core.base.Identity; import fun.asgc.neutrino.core.util.Assert; /** diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/BeanWrapper.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/BeanWrapper.java index ed68c649..032dd9cb 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/BeanWrapper.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/BeanWrapper.java @@ -87,9 +87,11 @@ public class BeanWrapper implements LifeCycle { @Override public void destroy() { - if (!hasInstance()) { + if (BeanStatus.DESTROY == status) { return; } + this.setStatus(BeanStatus.DESTROY); + Set methods = ReflectUtil.getMethods(type); if (CollectionUtil.notEmpty(methods)) { for (Method method : methods) { diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/SimpleBeanFactory.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/SimpleBeanFactory.java index 48605f5f..ea44118d 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/SimpleBeanFactory.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/bean/SimpleBeanFactory.java @@ -356,4 +356,16 @@ public class SimpleBeanFactory extends AbstractBeanFactory { } return null; } + + /** + * BeanWrapper集合 + * @return + */ + public List beanWrapperList() { + return FunctionUtil.mergeList( + () -> null == parent ? null : + parent instanceof SimpleBeanFactory ? ((SimpleBeanFactory)parent).beanWrapperList() : null, + () -> beanCache.values().stream().collect(Collectors.toList()) + ); + } } diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/util/FunctionUtil.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/util/FunctionUtil.java index d5da171b..567394d9 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/util/FunctionUtil.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/util/FunctionUtil.java @@ -24,6 +24,8 @@ package fun.asgc.neutrino.core.util; import fun.asgc.neutrino.core.aop.AopCallback; import fun.asgc.neutrino.core.base.CodeBlock; +import java.util.ArrayList; +import java.util.List; import java.util.function.Supplier; /** @@ -81,4 +83,26 @@ public class FunctionUtil { return null; } + /** + * 合并list + * @param suppliers + * @param + * @return + */ + public static List mergeList(Supplier> ...suppliers) { + List list = new ArrayList<>(); + if (null != suppliers && suppliers.length > 0) { + for (Supplier> supplier : suppliers) { + if (null == supplier) { + continue; + } + List tmpList = supplier.get(); + if (CollectionUtil.isEmpty(tmpList)) { + continue; + } + list.addAll(tmpList); + } + } + return list; + } } diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java index 3ddb09fe..4026be5e 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/HttpRequestHandler.java @@ -25,6 +25,7 @@ import fun.asgc.neutrino.core.annotation.Autowired; import fun.asgc.neutrino.core.annotation.Component; import fun.asgc.neutrino.core.annotation.NonIntercept; import fun.asgc.neutrino.core.context.ApplicationConfig; +import fun.asgc.neutrino.core.web.router.DefaultHttpRouter; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.http.FullHttpRequest; @@ -38,6 +39,8 @@ import io.netty.handler.codec.http.FullHttpRequest; public class HttpRequestHandler { @Autowired private ApplicationConfig applicationConfig; + @Autowired + private DefaultHttpRouter defaultHttpRouter; public void handle(ChannelHandlerContext context, FullHttpRequest request) { // TODO diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationContext.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationContext.java index fb62f99e..f009d9dd 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationContext.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/WebApplicationContext.java @@ -21,10 +21,12 @@ */ package fun.asgc.neutrino.core.web; +import com.google.common.collect.Sets; import fun.asgc.neutrino.core.annotation.*; import fun.asgc.neutrino.core.bean.SimpleBeanFactory; import fun.asgc.neutrino.core.context.ApplicationContext; import fun.asgc.neutrino.core.context.ApplicationRunner; +import fun.asgc.neutrino.core.web.router.DefaultHttpRouter; import lombok.Data; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; @@ -63,8 +65,15 @@ public class WebApplicationContext implements ApplicationRunner { @Override public void run(String[] args) throws Exception { - this.webApplicationBeanFactory.registerBean(HttpRequestHandler.class); - this.webApplicationBeanFactory.registerBean(WebApplicationServer.class); + this.webApplicationBeanFactory.register( + Sets.newHashSet( + DefaultHttpRouter.class, + HttpRequestHandler.class, + WebApplicationServer.class + ) + ); +// this.webApplicationBeanFactory.registerBean(HttpRequestHandler.class); +// this.webApplicationBeanFactory.registerBean(WebApplicationServer.class); } } diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/RequestMapping.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/RequestMapping.java new file mode 100644 index 00000000..7404b8e8 --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/annotation/RequestMapping.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.annotation; + +import fun.asgc.neutrino.core.web.HttpMethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author: aoshiguchen + * @date: 2022/7/16 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE,ElementType.METHOD}) +public @interface RequestMapping { + String[] value() default {}; + HttpMethod[] method() default {}; +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/DefaultHttpRouter.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/DefaultHttpRouter.java new file mode 100644 index 00000000..f0f32365 --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/DefaultHttpRouter.java @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.router; + +import fun.asgc.neutrino.core.annotation.*; +import fun.asgc.neutrino.core.bean.BeanWrapper; +import fun.asgc.neutrino.core.bean.SimpleBeanFactory; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 默认的http路由器 + * @author: aoshiguchen + * @date: 2022/7/16 + */ +@Slf4j +@NonIntercept +@Component +public class DefaultHttpRouter implements HttpRouter { + /** + * 路由缓存 + */ + private Map routeCache = new ConcurrentHashMap<>(256); + @Autowired + private SimpleBeanFactory webApplicationBeanFactory; + + @Init + public void init() { + log.debug("Http路由器初始化..."); + List beanWrapperList = webApplicationBeanFactory.beanWrapperList(); + // TODO 路由初始化 + } + + @Override + public HttpRouteResult route(HttpRouteParam httpRouteParam) { + HttpRouteIdentity identity = new HttpRouteIdentity(httpRouteParam.getMethod(), httpRouteParam.getUrl()); + HttpRouteInfo httpRouteInfo = routeCache.get(identity); + if (null == httpRouteInfo) { + return null; + } + if (HttpRouterType.PAGE == httpRouteInfo.getType()) { + return new HttpRouteResult() + .setType(httpRouteInfo.getType()) + .setPageLocation(httpRouteInfo.getPageLocation()); + } + return new HttpRouteResult() + .setType(httpRouteInfo.getType()) + .setMethod(httpRouteInfo.getMethod()) + .setInstance(webApplicationBeanFactory.getBean(httpRouteInfo.getBeanIdentity())); + } + + @Destroy + public void destroy() { + log.debug("Http路由器销毁..."); + } + +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteIdentity.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteIdentity.java new file mode 100644 index 00000000..8549b501 --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteIdentity.java @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.router; + +import fun.asgc.neutrino.core.base.Identity; +import fun.asgc.neutrino.core.util.Assert; +import fun.asgc.neutrino.core.web.HttpMethod; + +/** + * http路由唯一标识 + * @author: aoshiguchen + * @date: 2022/7/16 + */ +public class HttpRouteIdentity implements Identity { + + /** + * http方法 + */ + private HttpMethod method; + /** + * url + */ + private String url; + /** + * hashCode + */ + private int identityHashCode; + + @Override + public boolean isOnly() { + return true; + } + + public HttpRouteIdentity(HttpMethod method, String url) { + Assert.notNull(method, "http方法不能为空!"); + Assert.notEmpty(url, "url不能为空!"); + this.method = method; + this.url = url; + this.identityHashCode = System.identityHashCode(url); + } + + public HttpMethod getMethod() { + return method; + } + + public String getUrl() { + return url; + } + + @Override + public boolean equals(Object obj) { + if (null == obj) { + return false; + } + if (obj == this) { + return true; + } + if (!(obj instanceof HttpRouteIdentity)) { + return false; + } + HttpRouteIdentity httpRouteIdentity = (HttpRouteIdentity)obj; + return this.method.equals(httpRouteIdentity.getMethod()) && this.url.equals(httpRouteIdentity.getUrl()); + } + + @Override + public int hashCode() { + return identityHashCode; + } +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteInfo.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteInfo.java new file mode 100644 index 00000000..de251bcd --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteInfo.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.router; + +import fun.asgc.neutrino.core.bean.BeanIdentity; +import lombok.Data; + +import java.lang.reflect.Method; + +/** + * http路由信息 + * @author: aoshiguchen + * @date: 2022/7/16 + */ +@Data +public class HttpRouteInfo { + /** + * 路由类型 + */ + private HttpRouterType type; + /** + * bean唯一标识 + */ + private BeanIdentity beanIdentity; + /** + * 方法 + */ + private Method method; + /** + * 页面位置 + */ + private String pageLocation; +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteParam.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteParam.java new file mode 100644 index 00000000..b59c94bb --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteParam.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.router; + +import fun.asgc.neutrino.core.web.HttpMethod; +import lombok.Data; + +/** + * http路由参数 + * @author: aoshiguchen + * @date: 2022/7/16 + */ +@Data +public class HttpRouteParam { + private HttpMethod method; + private String url; +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteResult.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteResult.java new file mode 100644 index 00000000..b62b218a --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouteResult.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.router; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.lang.reflect.Method; + +/** + * http路由结果 + * @author: aoshiguchen + * @date: 2022/7/16 + */ +@Accessors(chain = true) +@Data +public class HttpRouteResult { + /** + * 路由类型 + */ + private HttpRouterType type; + /** + * 实例 + */ + private Object instance; + /** + * 方法 + */ + private Method method; + /** + * 页面位置 + */ + private String pageLocation; +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouter.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouter.java new file mode 100644 index 00000000..a441e2e0 --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouter.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.router; + +/** + * http路由器 + * @author: aoshiguchen + * @date: 2022/7/16 + */ +public interface HttpRouter extends Router { + +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouterType.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouterType.java new file mode 100644 index 00000000..5bff31a7 --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/HttpRouterType.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.router; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * http路由类型 + * @author: aoshiguchen + * @date: 2022/7/16 + */ +@Getter +@AllArgsConstructor +public enum HttpRouterType { + METHOD(1, "方法"), + PAGE(2, "页面"); + + private Integer type; + private String desc; +} diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/Router.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/Router.java new file mode 100644 index 00000000..fe60438a --- /dev/null +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/web/router/Router.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.core.web.router; + +/** + * 路由器 + * @author: aoshiguchen + * @date: 2022/7/16 + */ +public interface Router { + /** + * 路由 + * @param p + * @return + */ + R route(P p); +}