├── paoding-rose-hello ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── rose.properties │ │ ├── webapp │ │ ├── views │ │ │ └── hello │ │ │ │ ├── world-show.vm │ │ │ │ └── world-list.vm │ │ └── WEB-INF │ │ │ ├── toolbox.xml │ │ │ ├── log4j.properties │ │ │ └── web.xml │ │ └── java │ │ └── net │ │ └── paoding │ │ └── rose │ │ └── samples │ │ └── hellorose │ │ └── controllers │ │ ├── MainController.java │ │ └── hello │ │ └── WorldController.java ├── build.gradle └── README ├── paoding-rose-pipe ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ ├── rose.properties │ │ │ └── rosepipe.tld │ │ └── java │ │ └── net │ │ └── paoding │ │ └── rose │ │ └── web │ │ └── portal │ │ ├── controllers │ │ └── demo │ │ │ ├── rose.properties │ │ │ └── PortalController.java │ │ ├── WindowCallback.java │ │ ├── Portal.java │ │ ├── WindowRender.java │ │ ├── impl │ │ ├── SimpleWindowRender.java │ │ ├── MergeWindowAttributesToModelInterceptor.java │ │ ├── WindowResolver.java │ │ ├── PortalImpl.java │ │ ├── ThreadPoolExcutorServiceFactoryBean.java │ │ ├── PipeResolver.java │ │ └── PortalResolver.java │ │ ├── PortalFactory.java │ │ ├── WindowListenerAdapter.java │ │ ├── Pipe.java │ │ ├── PortalSetting.java │ │ ├── PortalUtils.java │ │ └── WindowListener.java └── pom.xml ├── paoding-rose-web ├── src │ └── main │ │ ├── resources │ │ ├── META-INF │ │ │ ├── MANIFEST.MF │ │ │ ├── rose.properties │ │ │ ├── rose.tld │ │ │ └── paoding-rose.tld │ │ ├── net │ │ │ └── paoding │ │ │ │ └── rose │ │ │ │ └── web │ │ │ │ └── impl │ │ │ │ └── view │ │ │ │ └── velocity │ │ │ │ └── rose.vm │ │ └── applicationContext-rose.xml │ │ └── java │ │ └── net │ │ └── paoding │ │ └── rose │ │ ├── controllers │ │ ├── rose.properties │ │ ├── Utils.java │ │ └── RoseToolsInterceptor.java │ │ ├── web │ │ ├── impl │ │ │ ├── mapping │ │ │ │ ├── ignored │ │ │ │ │ ├── IgnoredPath.java │ │ │ │ │ ├── IgnoredPathEnds.java │ │ │ │ │ ├── IgnoredPathStarts.java │ │ │ │ │ ├── IgnoredPathEquals.java │ │ │ │ │ └── IgnoredPathRegexMatch.java │ │ │ │ ├── MappingPattern.java │ │ │ │ ├── MatchResult.java │ │ │ │ └── MatchResultImpl.java │ │ │ ├── thread │ │ │ │ ├── EngineChain.java │ │ │ │ ├── AfterCompletion.java │ │ │ │ ├── Engine.java │ │ │ │ ├── BeforeActionInterceptor.java │ │ │ │ ├── AfterActionInterceptor.java │ │ │ │ └── BeforeInterceptorsInterceptor.java │ │ │ ├── view │ │ │ │ ├── ViewDispatcher.java │ │ │ │ ├── ViewPathCache.java │ │ │ │ └── DyContentTypeViewResolver.java │ │ │ ├── module │ │ │ │ ├── ModulesBuilder.java │ │ │ │ ├── ParentErrorHandlerImpl.java │ │ │ │ └── MethodRef.java │ │ │ └── validation │ │ │ │ └── ParameterBindingResult.java │ │ ├── Dispatcher.java │ │ ├── instruction │ │ │ ├── InstructionHelper.java │ │ │ ├── InstructionExecutor.java │ │ │ ├── Instruction.java │ │ │ ├── Text.java │ │ │ ├── HttpError.java │ │ │ ├── Forward.java │ │ │ ├── Redirect.java │ │ │ └── AbstractInstruction.java │ │ ├── InvocationLocal.java │ │ ├── ControllerErrorHandler.java │ │ ├── advancedinterceptor │ │ │ ├── Ordered.java │ │ │ ├── Named.java │ │ │ ├── DispatcherSelector.java │ │ │ └── ActionSelector.java │ │ ├── paramresolver │ │ │ ├── ResolverFactory.java │ │ │ └── ParamResolver.java │ │ ├── ParentErrorHandler.java │ │ ├── InvocationChain.java │ │ ├── BeforeAction.java │ │ ├── BeforeInterceptors.java │ │ ├── ErrorHandlerAdapter.java │ │ ├── AfterAction.java │ │ ├── AfterInterceptors.java │ │ ├── annotation │ │ │ ├── Return.java │ │ │ ├── HttpFeatures.java │ │ │ ├── MultipartCleanup.java │ │ │ ├── FlashParam.java │ │ │ ├── Pattern.java │ │ │ ├── DefValue.java │ │ │ ├── SuppressMultipartResolver.java │ │ │ ├── NotForSubModules.java │ │ │ ├── AsSuperController.java │ │ │ ├── Interceptor.java │ │ │ ├── Path.java │ │ │ ├── Create.java │ │ │ ├── rest │ │ │ │ ├── Get.java │ │ │ │ ├── Put.java │ │ │ │ ├── Head.java │ │ │ │ ├── Post.java │ │ │ │ ├── Trace.java │ │ │ │ ├── Delete.java │ │ │ │ └── Options.java │ │ │ ├── Ignored.java │ │ │ └── Param.java │ │ ├── ParamValidator.java │ │ └── ControllerInterceptor.java │ │ ├── util │ │ ├── Empty.java │ │ └── RoseBeanUtils.java │ │ ├── scanner │ │ └── ModuleResourceProvider.java │ │ └── RoseVersion.java └── build.gradle ├── paoding-rose-jade └── src │ ├── main │ ├── resources │ │ ├── META-INF │ │ │ └── rose.properties │ │ └── applicationContext-jade.xml │ └── java │ │ └── net │ │ └── paoding │ │ └── rose │ │ └── jade │ │ ├── annotation │ │ ├── UseMaster.java │ │ ├── KeyColumnOfMap.java │ │ ├── ShardBy.java │ │ ├── StatementAware.java │ │ ├── AfterInvocation.java │ │ ├── SQLType.java │ │ ├── ShardParam.java │ │ ├── CacheDelete.java │ │ ├── Cache.java │ │ └── SQLParam.java │ │ ├── statement │ │ ├── expression │ │ │ ├── ExqlUnit.java │ │ │ ├── impl │ │ │ │ ├── EmptyUnit.java │ │ │ │ ├── TextUnit.java │ │ │ │ ├── OptionUnit.java │ │ │ │ ├── ExprUnit.java │ │ │ │ ├── BunchUnit.java │ │ │ │ └── JoinExprUnit.java │ │ │ ├── ExprResolver.java │ │ │ ├── ExqlPattern.java │ │ │ └── ExqlContext.java │ │ ├── StatementWrapperProvider.java │ │ ├── InterpreterFactory.java │ │ ├── Querier.java │ │ ├── AfterInvocationCallback.java │ │ ├── StatementWrapper.java │ │ ├── cached │ │ │ ├── CacheProvider.java │ │ │ ├── CacheInterface.java │ │ │ └── MockCacheProvider.java │ │ ├── Interpreter.java │ │ ├── InterpreterComparator.java │ │ ├── Statement.java │ │ └── DynamicReturnGeneratedKeys.java │ │ ├── rowmapper │ │ ├── TypeUtils.java │ │ ├── SetRowMapper.java │ │ ├── ListRowMapper.java │ │ ├── RowMapperFactory.java │ │ └── ArrayRowMapper.java │ │ ├── dataaccess │ │ └── DataAccessFactory.java │ │ └── context │ │ └── spring │ │ └── SpringDataSourceFactoryDelegate.java │ └── test │ └── java │ ├── net │ └── paoding │ │ └── rose │ │ └── jade │ │ ├── ShardAttributes.java │ │ ├── provider │ │ └── DefinitionTests.java │ │ ├── exql │ │ └── ExqlContextTests.java │ │ ├── DataSources.java │ │ └── DataSourcesTest.java │ └── log4j.properties ├── .gitignore └── paoding-rose-load ├── src ├── main │ └── java │ │ └── net │ │ └── paoding │ │ └── rose │ │ └── load │ │ └── vfs │ │ ├── FileContent.java │ │ ├── FileName.java │ │ └── FileNameImpl.java └── test │ └── java │ └── net │ └── paoding │ └── rose │ └── load │ └── vfs │ └── LoadScopeTest.java └── pom.xml /paoding-rose-hello/src/main/resources/META-INF/rose.properties: -------------------------------------------------------------------------------- 1 | rose=* 2 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/resources/META-INF/rose.properties: -------------------------------------------------------------------------------- 1 | rose=applicationContext -------------------------------------------------------------------------------- /paoding-rose-web/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/resources/META-INF/rose.properties: -------------------------------------------------------------------------------- 1 | rose=controllers, applicationContext, messages -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/controllers/demo/rose.properties: -------------------------------------------------------------------------------- 1 | module.ignored=true -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/resources/META-INF/rose.properties: -------------------------------------------------------------------------------- 1 | # set rose=applicationContext to enable rose to scan the applicationContext-jade.xml from this jar 2 | rose=applicationContext -------------------------------------------------------------------------------- /paoding-rose-web/build.gradle: -------------------------------------------------------------------------------- 1 | sourceSets { 2 | main { 3 | resources { 4 | srcDir 'src/main/resources' 5 | srcDir 'src/main/java' 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /paoding-rose-hello/src/main/webapp/views/hello/world-show.vm: -------------------------------------------------------------------------------- 1 | Welcome to $name. 2 |

3 | Here is its index $index. 4 | 5 |

6 | Back
7 | Home 8 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/controllers/rose.properties: -------------------------------------------------------------------------------- 1 | #module.path\u7528\u6765\u6539\u53d8url\u5730\u5740\u8def\u5f84\u7684,\u4f60\u4e5f\u53ef\u4ee5\u7528 2 | module.path=/rose-info 3 | intercepted.allow=rose* -------------------------------------------------------------------------------- /paoding-rose-hello/src/main/webapp/views/hello/world-list.vm: -------------------------------------------------------------------------------- 1 | #foreach($name in $worlds) 2 | $velocityCount:  3 | Here is $name. 4 |
5 | #end 6 | 7 |

8 | Home 9 | 10 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/test/java/net/paoding/rose/jade/ShardAttributes.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade; 2 | 3 | public interface ShardAttributes { 4 | 5 | String originTable = "_ShardAttributes.originTable"; 6 | 7 | String targetTable = "_ShardAttributes.targetTable"; 8 | } 9 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/mapping/ignored/IgnoredPath.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.web.impl.mapping.ignored; 2 | 3 | import net.paoding.rose.web.RequestPath; 4 | 5 | public interface IgnoredPath { 6 | 7 | public boolean hit(RequestPath requestPath); 8 | } 9 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/thread/EngineChain.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.web.impl.thread; 2 | 3 | public interface EngineChain { 4 | 5 | public Object doNext() throws Throwable; 6 | 7 | public void addAfterCompletion(AfterCompletion task); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /paoding-rose-hello/src/main/webapp/WEB-INF/toolbox.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | date 5 | application 6 | org.apache.velocity.tools.generic.DateTool 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/test/java/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 6 | 7 | log4j.logger.net.paoding.rose.jade.jadeinterface=DEBUG 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .DS_Store 3 | .classpath 4 | .project 5 | .settings 6 | *.class 7 | *.swp 8 | *.bak 9 | .idea 10 | *.iml 11 | bin 12 | build/ 13 | target/ 14 | pom.xml.tag 15 | pom.xml.releaseBackup 16 | pom.xml.versionsBackup 17 | pom.xml.next 18 | release.properties 19 | dependency-reduced-pom.xml 20 | buildNumber.properties 21 | -------------------------------------------------------------------------------- /paoding-rose-hello/src/main/java/net/paoding/rose/samples/hellorose/controllers/MainController.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.samples.hellorose.controllers; 2 | 3 | import net.paoding.rose.web.annotation.Path; 4 | import net.paoding.rose.web.annotation.rest.Get; 5 | 6 | @Path("") 7 | public class MainController { 8 | 9 | @Get("") 10 | public String main() { 11 | return "redirect:/hello/world"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /paoding-rose-hello/src/main/webapp/WEB-INF/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 6 | 7 | log4j.logger.org.springframework=INFO 8 | log4j.logger.net.paoding=DEBUG 9 | log4j.logger.net.paoding.rose.web.controllers.roseInfo=DEBUG 10 | -------------------------------------------------------------------------------- /paoding-rose-hello/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'eclipse' 3 | apply plugin: 'war' 4 | apply plugin: 'jetty' 5 | 6 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 7 | 8 | repositories { 9 | mavenLocal() 10 | mavenCentral() 11 | } 12 | dependencies { 13 | compile "net.paoding:rose:1.2-SNAPSHOT" 14 | compile "net.paoding:rose-jade:1.2-SNAPSHOT" 15 | compile "sslext:sslext:1.10-4" 16 | } 17 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/mapping/ignored/IgnoredPathEnds.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.web.impl.mapping.ignored; 2 | 3 | import net.paoding.rose.web.RequestPath; 4 | 5 | public class IgnoredPathEnds implements IgnoredPath { 6 | 7 | private String path; 8 | 9 | public IgnoredPathEnds(String path) { 10 | this.path = path; 11 | } 12 | 13 | @Override 14 | public boolean hit(RequestPath requestPath) { 15 | return requestPath.getRosePath().endsWith(path); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/mapping/ignored/IgnoredPathStarts.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.web.impl.mapping.ignored; 2 | 3 | import net.paoding.rose.web.RequestPath; 4 | 5 | public class IgnoredPathStarts implements IgnoredPath { 6 | 7 | private String path; 8 | 9 | public IgnoredPathStarts(String path) { 10 | this.path = path; 11 | } 12 | 13 | @Override 14 | public boolean hit(RequestPath requestPath) { 15 | return requestPath.getRosePath().startsWith(path); 16 | } 17 | } -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/mapping/ignored/IgnoredPathEquals.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.web.impl.mapping.ignored; 2 | 3 | import net.paoding.rose.web.RequestPath; 4 | 5 | 6 | public class IgnoredPathEquals implements IgnoredPath { 7 | 8 | private String path; 9 | 10 | public IgnoredPathEquals(String path) { 11 | this.path = path; 12 | } 13 | 14 | @Override 15 | public boolean hit(RequestPath requestPath) { 16 | return requestPath.getRosePath().equals(path); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/resources/META-INF/rosepipe.tld: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 1.2 8 | 1.1 9 | rosepipe 10 | http://paoding.net/rose/pipe 11 | 12 | 13 | write 14 | net.paoding.rose.web.portal.taglibs.PipeWriteTag 15 | 16 | JSP 17 | 18 | -------------------------------------------------------------------------------- /paoding-rose-hello/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelloRose 4 | 5 | rose 6 | net.paoding.rose.RoseFilter 7 | 8 | 9 | rose 10 | /* 11 | REQUEST 12 | FORWARD 13 | INCLUDE 14 | 15 | 16 | -------------------------------------------------------------------------------- /paoding-rose-hello/README: -------------------------------------------------------------------------------- 1 | 2 | HOW TO RUN THIS SAMPLE? 3 | 4 | * make sure 'gradle' is avaiable in your machine 5 | try 'gradle -version' 6 | otherwise install the 'gradle' from http://www.gradle.org/ 7 | 8 | * install paoding-rose's artifacts to your local repository 9 | cd to the paoding-rose 10 | run 'gradle install' 11 | 12 | NOTE: rose will install its artifacts to the Maven Local Repository, which is ~/.m2/repostory in default 13 | 14 | * start web service at 80 port 15 | cd to this sample's root directory 16 | run 'gradle jettyRun' 17 | 18 | * view http://localhost/HelloRose by your explorer 19 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/mapping/ignored/IgnoredPathRegexMatch.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.web.impl.mapping.ignored; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | import net.paoding.rose.web.RequestPath; 6 | 7 | public class IgnoredPathRegexMatch implements IgnoredPath { 8 | 9 | private Pattern path; 10 | 11 | public IgnoredPathRegexMatch(String path) { 12 | this.path = Pattern.compile(path); 13 | } 14 | 15 | @Override 16 | public boolean hit(RequestPath requestPath) { 17 | return path.matcher(requestPath.getRosePath()).matches(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/UseMaster.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 使用:{#link UseMaster} 标注需要强制查询 master 数据库的 DAO 接口方法。 11 | * 12 | * @author han.liao 13 | */ 14 | @Target({ ElementType.METHOD }) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Documented 17 | public @interface UseMaster { 18 | 19 | /** 20 | * 是否需要强制查询 master 数据库。 21 | * 22 | * @return 强制查询 master 数据库 23 | */ 24 | boolean value() default true; 25 | } 26 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/ExqlUnit.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression; 2 | 3 | 4 | /** 5 | * 定义一个语句输出单元, 可以进行组装。 6 | * 7 | * @author han.liao 8 | */ 9 | public interface ExqlUnit { 10 | 11 | /** 12 | * 检查单元的内容是否有效。 13 | * 14 | * @param exprResolver - 使用的引擎 15 | * 16 | * @return 内容是否有效 17 | * 18 | * @throws Exception 19 | */ 20 | boolean isValid(ExprResolver exprResolver); 21 | 22 | /** 23 | * 输出单元的语句内容。 24 | * 25 | * @param exqlContext - 输出上下文 26 | * @param exprResolver - 使用的引擎 27 | * 28 | * @throws Exception 29 | */ 30 | void fill(ExqlContext exqlContext, ExprResolver exprResolver) throws Exception; 31 | } 32 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/impl/EmptyUnit.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression.impl; 2 | 3 | import net.paoding.rose.jade.statement.expression.ExprResolver; 4 | import net.paoding.rose.jade.statement.expression.ExqlContext; 5 | import net.paoding.rose.jade.statement.expression.ExqlUnit; 6 | 7 | /** 8 | * 输出空白的语句单元, 代替空的表达式。 9 | * 10 | * @author han.liao 11 | */ 12 | public class EmptyUnit implements ExqlUnit { 13 | 14 | @Override 15 | public boolean isValid(ExprResolver exprResolver) { 16 | // Empty unit is always valid. 17 | return true; 18 | } 19 | 20 | @Override 21 | public void fill(ExqlContext exqlContext, ExprResolver exprResolver) throws Exception { 22 | // Do nothing. 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/KeyColumnOfMap.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Jade支持DAO方法返回Map形式的,默认情况下Jade选取第一列作为Map的key。 11 | *

12 | * 我们推荐您在写返回map的SQL时,把key放到第一列,但是如果真不想这样做,你可以通过本注解,即{@link KeyColumnOfMap} 13 | * 进行指定。 14 | * 15 | * @author 王志亮 [qieqie.wang@gmail.com] 16 | * @author 廖涵 [in355hz@gmail.com] 17 | */ 18 | @Target( { ElementType.METHOD }) 19 | @Retention(RetentionPolicy.RUNTIME) 20 | @Documented 21 | public @interface KeyColumnOfMap { 22 | 23 | /** 24 | * 指出要被当成map key的字段名称 25 | * 26 | * @return 27 | */ 28 | String value(); 29 | } 30 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/ExprResolver.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression; 2 | 3 | /** 4 | * 定义处理表达式的接口, 以兼容不同的表达式语法。 5 | * 6 | * @author han.liao 7 | */ 8 | public interface ExprResolver { 9 | 10 | /** 11 | * 返回变量的内容。 12 | * 13 | * @param variant - 变量的名称 14 | * 15 | * @return 变量的内容 16 | */ 17 | Object getVar(String variant); 18 | 19 | /** 20 | * 设置变量的内容。 21 | * 22 | * @param variant - 变量的名称 23 | * 24 | * @param value - 变量的内容 25 | */ 26 | void setVar(String variant, Object value); 27 | 28 | /** 29 | * 返回在语句输出的内容。 30 | * 31 | * @param expression - 解释的表达式 32 | * 33 | * @return 输出的内容 34 | * 35 | * @throws Exception 36 | */ 37 | Object executeExpr(String expression) throws Exception; 38 | } 39 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/ExqlPattern.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * 定义一个语句的执行接口。 7 | * 8 | * @author han.liao 9 | */ 10 | public interface ExqlPattern { 11 | 12 | /** 13 | * 输出全部的语句内容。 14 | * 15 | * @param context - 输出上下文 16 | * 17 | * @param map - 参数表 18 | * 19 | * @throws Exception 20 | */ 21 | void execute(ExqlContext context, Map map) throws Exception; 22 | 23 | /** 24 | * 输出全部的语句内容。 25 | * 26 | * @param context - 输出上下文 27 | * 28 | * @param mapVars - 参数表 29 | * @param mapConsts - 常量表 30 | * 31 | * @throws Exception 32 | */ 33 | void execute(ExqlContext context, Map mapVars, // NL 34 | Map mapConsts) throws Exception; 35 | } 36 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/rowmapper/TypeUtils.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.rowmapper; 2 | 3 | import java.math.BigDecimal; 4 | import java.sql.Blob; 5 | import java.sql.Clob; 6 | import java.util.Date; 7 | 8 | import org.springframework.util.ClassUtils; 9 | 10 | public class TypeUtils { 11 | 12 | public static boolean isColumnType(Class columnTypeCandidate) { 13 | return String.class == columnTypeCandidate // NL 14 | || ClassUtils.isPrimitiveOrWrapper(columnTypeCandidate)// NL 15 | || Date.class.isAssignableFrom(columnTypeCandidate) // NL 16 | || columnTypeCandidate == byte[].class // NL 17 | || columnTypeCandidate == BigDecimal.class // NL 18 | || columnTypeCandidate == Blob.class // NL 19 | || columnTypeCandidate == Clob.class; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/ShardBy.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 对于sql中没有含有散表参数的或散表参数名称和配置的散表名称不一致的,通过将 ShardBy 配置在这个参数上,表示使用该参数进行散表. 11 | *

12 | * @SQL("....where name like :1")
13 | * public List find(String likeValue, @ShardBy String pageId); 14 | * 15 | *

16 |  * 
17 | * 18 | * @author 王志亮 [qieqie.wang@gmail.com] 19 | */ 20 | @Target({ ElementType.PARAMETER }) 21 | @Retention(RetentionPolicy.RUNTIME) 22 | @Documented 23 | public @interface ShardBy { 24 | 25 | /** 26 | * bean参数情况下的属性名 27 | * 28 | * @return 29 | */ 30 | String value() default ""; 31 | } 32 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/ExqlContext.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression; 2 | 3 | /** 4 | * 定义输出的上下文接口。 5 | * 6 | * @author han.liao 7 | */ 8 | public interface ExqlContext { 9 | 10 | /** 11 | * 输出字符到语句内容。 12 | * 13 | * @param ch - 输出的字符 14 | */ 15 | void fillChar(char ch); 16 | 17 | /** 18 | * 输出字符串到语句内容, 字符串的内容是未经转义的。 19 | * 20 | * @param string - 输出的字符串 21 | */ 22 | void fillText(String string); 23 | 24 | /** 25 | * 输出对象到语句内容, 字符串的内容将被转义。 26 | * 27 | * @param obj - 输出的对象 28 | */ 29 | void fillValue(Object obj); 30 | 31 | /** 32 | * 返回所有参数的数组, 按参数出现的顺序。 33 | * 34 | * @return 所有参数的数组 35 | */ 36 | Object[] getArgs(); 37 | 38 | /** 39 | * 得到输出的语句内容。 40 | * 41 | * @return 语句内容 42 | */ 43 | String flushOut(); 44 | } 45 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/Dispatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public enum Dispatcher { 24 | 25 | REQUEST, FORWARD, INCLUDE; 26 | } 27 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/instruction/InstructionHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.instruction; 17 | 18 | /** 19 | * 只是一个标志,没有任何接口方法 20 | * 21 | * @author 王志亮 [qieqie.wang@gmail.com] 22 | * 23 | */ 24 | public interface InstructionHelper { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/resources/META-INF/rose.tld: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 1.2 8 | 1.1 9 | rose 10 | http://paoding.net/rose 11 | 12 | 13 | flash 14 | net.paoding.rose.web.taglibs.FlashTag 15 | 16 | JSP 17 | 18 | key 19 | true 20 | false 21 | 22 | 23 | prefix 24 | false 25 | false 26 | 27 | 28 | suffix 29 | false 30 | false 31 | 32 | 33 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/StatementWrapperProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public interface StatementWrapperProvider { 24 | 25 | Statement wrap(Statement statement); 26 | } 27 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/resources/net/paoding/rose/web/impl/view/velocity/rose.vm: -------------------------------------------------------------------------------- 1 | #** 2 | * msg 3 | * 4 | * Macro to translate a message code into a message. 5 | * 6 | * @see org/springframework/web/servlet/view/velocity/spring.vm 7 | * @see springMessage 8 | *# 9 | #macro(msg $code )$springMacroRequestContext.getMessage($code)#end 10 | #macro(msg $code $arg0)$springMacroRequestContext.getMessage($code, $arg0)#end 11 | #macro(msg $code $arg0 $arg1)$springMacroRequestContext.getMessage($code, $arg0, $arg1)#end 12 | #macro(msg $code $arg0 $arg1 $arg2)$springMacroRequestContext.getMessage($code, $arg0, $arg1, $arg2)#end 13 | #macro(msg $code $arg0 $arg1 $arg2 $arg3)$springMacroRequestContext.getMessage($code, $arg0, $arg1, $arg2, $arg3)#end 14 | #macro(msg $code $arg0 $arg1 $arg2 $arg3 $arg4)$springMacroRequestContext.getMessage($code, $arg0, $arg1, $arg2, $arg3, $arg4)#end 15 | 16 | #** 17 | * flash 18 | *# 19 | #macro(flash $key )$!{roseInvocation.flash.get($key)}#end 20 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/WindowCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public interface WindowCallback { 24 | 25 | public void beforeSubmit(Window window); 26 | } 27 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/resources/META-INF/paoding-rose.tld: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 1.2 8 | 1.1 9 | tags-core 10 | http://rose.paoding.net/tags-core 11 | 12 | 13 | flash 14 | net.paoding.rose.web.taglibs.FlashTag 15 | 16 | JSP 17 | 18 | key 19 | true 20 | false 21 | 22 | 23 | prefix 24 | false 25 | false 26 | 27 | 28 | suffix 29 | false 30 | false 31 | 32 | 33 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/InterpreterFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public interface InterpreterFactory { 24 | 25 | Interpreter[] getInterpreters(StatementMetaData metaData); 26 | } 27 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/util/Empty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.util; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public class Empty { 24 | 25 | /** 长度为零字符串 */ 26 | public final static String[] STRING_ARRAY = new String[0]; 27 | } 28 | -------------------------------------------------------------------------------- /paoding-rose-hello/src/main/java/net/paoding/rose/samples/hellorose/controllers/hello/WorldController.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.samples.hellorose.controllers.hello; 2 | 3 | import net.paoding.rose.web.Invocation; 4 | import net.paoding.rose.web.annotation.Param; 5 | import net.paoding.rose.web.annotation.rest.Get; 6 | 7 | public class WorldController { 8 | 9 | private String worlds = "heaven,earth,hell"; 10 | 11 | @Get("") 12 | public String index() { 13 | return "@Every Thing is OK.

list worlds"; 14 | } 15 | 16 | @Get("list") 17 | public String list(Invocation inv) { 18 | inv.addModel("worlds", worlds.split(",")); 19 | return "world-list"; // refer: views/hello/world-list.vm 20 | } 21 | 22 | @Get("prefix-{name}") 23 | public String show(Invocation inv, @Param("name") String name) { 24 | int index = worlds.indexOf(name); 25 | inv.addModel("index", index); 26 | inv.addModel("name", name); 27 | return "world-show";// refer: views/hello/world-show.vm 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/Querier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | import net.paoding.rose.jade.annotation.SQLType; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface Querier { 26 | 27 | Object execute(SQLType sqlType, StatementRuntime... runtimes); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/impl/TextUnit.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression.impl; 2 | 3 | import net.paoding.rose.jade.statement.expression.ExprResolver; 4 | import net.paoding.rose.jade.statement.expression.ExqlContext; 5 | import net.paoding.rose.jade.statement.expression.ExqlUnit; 6 | 7 | /** 8 | * 原样输出文本的语句单元, 通常是语句中不含表达式的部分。 9 | * 10 | * @author han.liao 11 | */ 12 | public class TextUnit implements ExqlUnit { 13 | 14 | private final String text; 15 | 16 | /** 17 | * 构造输出文本的语句单元。 18 | * 19 | * @param text - 输出的文本 20 | */ 21 | public TextUnit(String text) { 22 | this.text = text; 23 | } 24 | 25 | @Override 26 | public boolean isValid(ExprResolver exprResolver) { 27 | 28 | // 文本始终有效 29 | return true; 30 | } 31 | 32 | @Override 33 | public void fill(ExqlContext exqlContext, ExprResolver exprResolver) throws Exception { 34 | 35 | // 输出未经转义的文本 36 | exqlContext.fillText(text); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/InvocationLocal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public interface InvocationLocal extends Invocation { 24 | 25 | /** 26 | * 27 | * @return 28 | */ 29 | public Invocation getCurrent(boolean required); 30 | } 31 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/ControllerErrorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public interface ControllerErrorHandler { 24 | 25 | /** 26 | * 27 | * @param ex 28 | * @return 29 | */ 30 | public Object onError(Invocation inv, Throwable ex) throws Throwable; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/impl/OptionUnit.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression.impl; 2 | 3 | import net.paoding.rose.jade.statement.expression.ExprResolver; 4 | import net.paoding.rose.jade.statement.expression.ExqlContext; 5 | import net.paoding.rose.jade.statement.expression.ExqlUnit; 6 | 7 | /** 8 | * 条件输出子单元的语句单元, 例如一个: {...}? 语句段。 9 | * 10 | * @author han.liao 11 | */ 12 | public class OptionUnit implements ExqlUnit { 13 | 14 | private final ExqlUnit unit; 15 | 16 | public OptionUnit(ExqlUnit unit) { 17 | this.unit = unit; 18 | } 19 | 20 | @Override 21 | public boolean isValid(ExprResolver exprResolver) { 22 | 23 | // 条件单元始终有效, 因为若子单元无效 24 | // 它就不会产生输出。 25 | return true; 26 | } 27 | 28 | @Override 29 | public void fill(ExqlContext exqlContext, ExprResolver exprResolver) throws Exception { 30 | 31 | // 当且仅当子单元有效时输出 32 | if (unit.isValid(exprResolver)) { 33 | unit.fill(exqlContext, exprResolver); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-load/src/main/java/net/paoding/rose/load/vfs/FileContent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.paoding.rose.load.vfs; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | 22 | /** 23 | * 24 | * @author 王志亮 [qieqie.wang@gmail.com] 25 | * 26 | */ 27 | 28 | public interface FileContent { 29 | 30 | public InputStream getInputStream() throws IOException; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/Portal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | /** 19 | * {@link WindowContainer} 20 | * 两种类型的其中一种,用于在服务端为一个请求并发请求多个窗口时,并把窗口的页面合并后一并送给客户端。 21 | * 22 | *

23 | * 详细文档,请见 {@link WindowContainer} 24 | * 25 | * @author 王志亮 [qieqie.wang@gmail.com] 26 | * 27 | */ 28 | public interface Portal extends WindowContainer { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/advancedinterceptor/Ordered.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.advancedinterceptor; 17 | 18 | /** 19 | * 如果拦截器实现了此接口,代表这个拦截器关注其在所有拦截器中的顺序。 20 | * 21 | * @author Administrator 22 | * 23 | */ 24 | public interface Ordered { 25 | 26 | /** 27 | * 返回一个数字,值大的具有最高优先拦截权 28 | * 29 | * @return 30 | */ 31 | int getPriority(); 32 | } 33 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/instruction/InstructionExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.instruction; 17 | 18 | import net.paoding.rose.web.Invocation; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface InstructionExecutor { 26 | 27 | public Object render(Invocation inv, Object instruction) throws Exception; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/paramresolver/ResolverFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * Copyright 2007-2009 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package net.paoding.rose.web.paramresolver; 18 | 19 | 20 | /** 21 | * @author 王志亮 [qieqie.wang@gmail.com] 22 | */ 23 | public interface ResolverFactory { 24 | 25 | /** 26 | * 27 | * @param paramMetaData 28 | * @return 29 | */ 30 | public ParamResolver supports(ParamMetaData paramMetaData); 31 | } 32 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/advancedinterceptor/Named.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.advancedinterceptor; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public interface Named { 24 | 25 | /** 26 | * 27 | */ 28 | public void setName(String name); 29 | 30 | /** 31 | * 32 | * @return 33 | */ 34 | public String getName(); 35 | } 36 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/ParentErrorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 声明在 {@link ControllerErrorHandler}的实现类,引用上级的错误处理器 20 | * 21 | * @author zhiliang.wang 22 | * 23 | */ 24 | public interface ParentErrorHandler { 25 | 26 | /** 27 | * 28 | * @param ex 29 | * @return 30 | */ 31 | public Object onError(Invocation inv, Throwable ex) throws Throwable; 32 | } 33 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/InvocationChain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 开发者用于实现拦截器时,将控制流程交给下一个拦截器或最终的控制器方法 20 | * 21 | * @author 王志亮 [qieqie.wang@gmail.com] 22 | */ 23 | public interface InvocationChain { 24 | 25 | /** 26 | * 将控制流程交给下一个拦截器,并获取下一个拦截器或最终的控制器方法返回的指示 27 | * 28 | * @return 29 | * @throws Exception 30 | */ 31 | Object doNext() throws Exception; 32 | } 33 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/AfterInvocationCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public interface AfterInvocationCallback { 24 | 25 | /** 26 | * 27 | * @param runtime 运行时 28 | * @param returnValue DAO方法的返回值 29 | * @return 改变后的返回值 30 | */ 31 | public Object execute(StatementRuntime runtime, Object returnValue); 32 | } 33 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/StatementWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public interface StatementWrapper extends Statement { 24 | 25 | /** 26 | * 27 | * @param statement 28 | */ 29 | void setStatement(Statement statement); 30 | 31 | /** 32 | * 33 | * @return 34 | */ 35 | Statement getStatement(); 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/view/ViewDispatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.view; 17 | 18 | import java.util.Locale; 19 | 20 | import net.paoding.rose.web.Invocation; 21 | 22 | import org.springframework.web.servlet.View; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public interface ViewDispatcher { 30 | 31 | public View resolveViewName(Invocation inv, String viewPath, Locale locale) throws Exception; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/StatementAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.annotation; 17 | 18 | import net.paoding.rose.jade.statement.StatementMetaData; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | * @param 25 | */ 26 | public interface StatementAware { 27 | 28 | /** 29 | * 设置 {@link StatementMetaData},目的是告知有关的DAO信息 30 | * @param smd 31 | */ 32 | public void setStatementMetaData(StatementMetaData smd); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/advancedinterceptor/DispatcherSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.advancedinterceptor; 17 | 18 | import net.paoding.rose.web.Dispatcher; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface DispatcherSelector { 26 | 27 | /** 28 | * 当所分配请求是所给的类型时(普通请求、FORWARD请求、INCLUDE请求),是否执行此拦截器? 29 | * 30 | * @return 31 | */ 32 | boolean isForDispatcher(Dispatcher dispatcher); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/mapping/MappingPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.mapping; 17 | 18 | /** 19 | * {@link MappingPattern} 封装字符串的匹配规则,不同的 {@link MatchMode} 匹配规则不一样 20 | * 21 | * @see MatchMode 22 | * 23 | * @author 王志亮 [qieqie.wang@gmail.com] 24 | * 25 | */ 26 | public interface MappingPattern { 27 | 28 | /** 29 | * 返回匹配结果,返回空表示不能匹配 30 | * 31 | * @param path 32 | */ 33 | java.util.regex.MatchResult match(CharSequence path); 34 | } 35 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/cached/CacheProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement.cached; 17 | 18 | import net.paoding.rose.jade.statement.StatementMetaData; 19 | 20 | /** 21 | * 定义 CacheProvider 接口从缓存池名称获取实例。 22 | * 23 | * @author han.liao 24 | */ 25 | public interface CacheProvider { 26 | 27 | /** 28 | * 从缓存池的名称获取实例。 29 | * 30 | * @param poolName - 缓存池的名称 31 | * 32 | * @return 缓存池实例 33 | */ 34 | CacheInterface getCacheByPool(StatementMetaData metaData, String poolName); 35 | } 36 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/WindowRender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | import java.io.IOException; 19 | import java.io.Writer; 20 | 21 | /** 22 | * 23 | * @author 王志亮 [qieqie.wang@gmail.com] 24 | * 25 | */ 26 | public interface WindowRender { 27 | 28 | /** 29 | * 30 | * @param window 31 | * @param out 32 | * @throws IOException 33 | * @throws IOException 34 | */ 35 | public void render(Writer out,Window window) throws IOException; 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/BeforeAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 如果控制器action方法的参数对象实现了 {@link BeforeAction}接口,Rose将在调用所在action方法之前,调用 20 | * {@link #doBeforeAction(Invocation)}方法 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface BeforeAction { 26 | 27 | /** 28 | * 29 | * @param inc 30 | * @param instruction 31 | * @throws Exception 32 | */ 33 | public void doBeforeAction(Invocation inc) throws Exception; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/advancedinterceptor/ActionSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.advancedinterceptor; 17 | 18 | import java.lang.reflect.Method; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface ActionSelector { 26 | 27 | /** 28 | * 作为候选拦截器,这个拦截器是否应拦截所指的控制器及其方法? 29 | * 30 | * @param controllerClazz 31 | * @param actionMethod 32 | * @return 33 | */ 34 | boolean isForAction(Class controllerClazz, Method actionMethod); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/module/ModulesBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.module; 17 | 18 | import java.util.List; 19 | 20 | import net.paoding.rose.scanner.ModuleResource; 21 | 22 | import org.springframework.web.context.WebApplicationContext; 23 | 24 | /** 25 | * 根据输入的module类信息,构造出具体的Module结构出来 26 | * 27 | * @author 王志亮 [qieqie.wang@gmail.com] 28 | */ 29 | public interface ModulesBuilder { 30 | 31 | public List build(List moduleResources, 32 | WebApplicationContext rootContext) throws Exception; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/BeforeInterceptors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 如果控制器action方法的参数对象实现了 {@link BeforeInterceptors}接口,Rose将拦截所有拦截器之前,调用 20 | * {@link #doBeforeInterceptors(Invocation)}方法 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface BeforeInterceptors { 26 | 27 | /** 28 | * 29 | * @param inv 30 | * @param instruction 31 | * @throws Exception 32 | */ 33 | public void doBeforeInterceptors(Invocation inv) throws Exception; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/ErrorHandlerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public class ErrorHandlerAdapter implements ControllerErrorHandler { 26 | 27 | @Autowired 28 | protected ParentErrorHandler parentHandler; 29 | 30 | @Override 31 | public Object onError(Invocation inv, Throwable ex) throws Throwable { 32 | return parentHandler.onError(inv, ex); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/instruction/Instruction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.instruction; 17 | 18 | import java.io.IOException; 19 | 20 | import javax.servlet.ServletException; 21 | 22 | import net.paoding.rose.web.Invocation; 23 | 24 | /** 25 | * 26 | * @author zhiliang.wang 27 | * 28 | */ 29 | public interface Instruction { 30 | 31 | /** 32 | * 33 | * @param inv 34 | * @throws IOException 35 | * @throws ServletException 36 | * @throws Exception 37 | */ 38 | public void render(Invocation inv) throws IOException, ServletException, Exception; 39 | } 40 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/AfterAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 如果控制器action方法的参数对象实现了 {@link AfterAction}接口,Rose将在所在action方法返回之后,调用 20 | * {@link #doAfterAction(Invocation, Object)}方法 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface AfterAction { 26 | 27 | /** 28 | * 29 | * @param inc 30 | * @param instruction 31 | * @return null表示保留原来所返回的指示 32 | * @throws Exception 33 | */ 34 | public Object doAfterAction(Invocation inc, Object instruction) throws Exception; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/impl/SimpleWindowRender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal.impl; 17 | 18 | import java.io.IOException; 19 | import java.io.Writer; 20 | 21 | import net.paoding.rose.web.portal.Window; 22 | import net.paoding.rose.web.portal.WindowRender; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public class SimpleWindowRender implements WindowRender { 30 | 31 | @Override 32 | public void render(Writer out, Window window) throws IOException { 33 | out.write(window.getContent()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/scanner/ModuleResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.scanner; 17 | 18 | import java.io.IOException; 19 | import java.util.List; 20 | 21 | import net.paoding.rose.load.LoadScope; 22 | 23 | /** 24 | * 用于发现规定查找范围内的web模块资源。 25 | * 26 | * @see ModuleResource 27 | * 28 | * @author 王志亮 [qieqie.wang@gmail.com] 29 | * 30 | */ 31 | public interface ModuleResourceProvider { 32 | 33 | /** 34 | * 发现规定查找范围内的web模块资源。 35 | * 36 | * @return 37 | */ 38 | public List findModuleResources(LoadScope scope) throws IOException; 39 | } 40 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/AfterInterceptors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | /** 19 | * 如果控制器action方法的参数对象实现了 {@link AfterInterceptors}接口,Rose将在所在拦截器拦截之后,调用 20 | * {@link #doAfterInterceptors(Invocation, Object)}方法 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface AfterInterceptors { 26 | 27 | /** 28 | * 29 | * @param inv 30 | * @param instruction 31 | * @return null表示保留原来所返回的指示 32 | * @throws Exception 33 | */ 34 | public Object doAfterInterceptors(Invocation inv, Object instruction) throws Exception; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/AfterInvocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import net.paoding.rose.jade.statement.AfterInvocationCallback; 25 | 26 | @Target({ ElementType.METHOD }) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Documented 29 | public @interface AfterInvocation { 30 | 31 | /** 32 | * 33 | */ 34 | Classvalue(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/Return.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 使用 {@link Return} 26 | * 标注用于action方法为void类型时,模拟return语句,让Rose框架把它当成该action方法的返回值 27 | * 28 | * @author 王志亮 [qieqie.wang@gmail.com] 29 | * 30 | */ 31 | @Target( { ElementType.METHOD }) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Documented 34 | public @interface Return { 35 | 36 | String value(); 37 | } 38 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/HttpFeatures.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | @Target( { ElementType.TYPE, ElementType.METHOD }) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface HttpFeatures { 33 | 34 | String charset() default ""; 35 | 36 | String contentType() default ""; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/thread/AfterCompletion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.thread; 17 | 18 | import net.paoding.rose.web.Invocation; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface AfterCompletion { 26 | 27 | /** 28 | * 整个流程(包括页面render流程)结束时调用,不管是否发生过异常。如果发生了异常,则将传送一个非空的Throwable对象到该方法。 29 | *

30 | * 只有之前调用before时返回true时才会调用到它的afterRender方法 31 | * 32 | * @param inv 33 | * @param ex 34 | * @throws Exception 35 | */ 36 | void afterCompletion(Invocation inv, Throwable ex) throws Exception; 37 | } 38 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/impl/ExprUnit.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression.impl; 2 | 3 | import net.paoding.rose.jade.statement.expression.ExprResolver; 4 | import net.paoding.rose.jade.statement.expression.ExqlContext; 5 | import net.paoding.rose.jade.statement.expression.ExqlUnit; 6 | import net.paoding.rose.jade.statement.expression.util.ExqlUtils; 7 | 8 | /** 9 | * 输出表达式内容的语句单元, 例如: ':expr' 或者: '#(:expr)' 形式的表达式。 10 | * 11 | * @author han.liao 12 | */ 13 | public class ExprUnit implements ExqlUnit { 14 | 15 | private final String expr; 16 | 17 | /** 18 | * 构造输出表达式内容的语句单元。 19 | * 20 | * @param text - 输出的表达式 21 | */ 22 | public ExprUnit(String expr) { 23 | this.expr = expr; 24 | } 25 | 26 | @Override 27 | public boolean isValid(ExprResolver exprResolver) { 28 | 29 | // 解释表达式内容 30 | Object obj = ExqlUtils.execExpr(exprResolver, expr); 31 | 32 | // 表达式内容有效 33 | return ExqlUtils.isValid(obj); 34 | } 35 | 36 | @Override 37 | public void fill(ExqlContext exqlContext, ExprResolver exprResolver) throws Exception { 38 | 39 | // 解释表达式内容 40 | Object value = exprResolver.executeExpr(expr); 41 | 42 | // 输出转义的对象内容 43 | exqlContext.fillValue(value); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/impl/BunchUnit.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression.impl; 2 | 3 | import java.util.List; 4 | 5 | import net.paoding.rose.jade.statement.expression.ExprResolver; 6 | import net.paoding.rose.jade.statement.expression.ExqlContext; 7 | import net.paoding.rose.jade.statement.expression.ExqlUnit; 8 | 9 | /** 10 | * 顺序输出子单元的语句单元, 例如一个语句段。 11 | * 12 | * @author han.liao 13 | */ 14 | public class BunchUnit implements ExqlUnit { 15 | 16 | private final List units; 17 | 18 | /** 19 | * 构造顺序输出子单元的语句单元。 20 | * 21 | * @param units - 子单元列表 22 | */ 23 | public BunchUnit(List units) { 24 | this.units = units; 25 | } 26 | 27 | @Override 28 | public boolean isValid(ExprResolver exprResolver) { 29 | 30 | // 顺序检查子单元 31 | for (ExqlUnit unit : units) { 32 | 33 | if (!unit.isValid(exprResolver)) { 34 | return false; 35 | } 36 | } 37 | 38 | // 子单元全部有效 39 | return true; 40 | } 41 | 42 | @Override 43 | public void fill(ExqlContext exqlContext, ExprResolver exprResolver) throws Exception { 44 | 45 | // 顺序输出子单元 46 | for (ExqlUnit unit : units) { 47 | unit.fill(exqlContext, exprResolver); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/expression/impl/JoinExprUnit.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.statement.expression.impl; 2 | 3 | import net.paoding.rose.jade.statement.expression.ExprResolver; 4 | import net.paoding.rose.jade.statement.expression.ExqlContext; 5 | import net.paoding.rose.jade.statement.expression.ExqlUnit; 6 | import net.paoding.rose.jade.statement.expression.util.ExqlUtils; 7 | 8 | /** 9 | * 直接输出表达式内容的语句单元, 例如: '##(:expr)' 形式的表达式,内容不经转义输出。 10 | * 11 | * @author han.liao 12 | */ 13 | public class JoinExprUnit implements ExqlUnit { 14 | 15 | private final String expr; 16 | 17 | /** 18 | * 构造输出表达式内容的语句单元。 19 | * 20 | * @param text - 输出的表达式 21 | */ 22 | public JoinExprUnit(String expr) { 23 | this.expr = expr; 24 | } 25 | 26 | @Override 27 | public boolean isValid(ExprResolver exprResolver) { 28 | 29 | // 解释表达式内容 30 | Object obj = ExqlUtils.execExpr(exprResolver, expr); 31 | 32 | // 表达式内容有效 33 | return ExqlUtils.isValid(obj); 34 | } 35 | 36 | @Override 37 | public void fill(ExqlContext exqlContext, ExprResolver exprResolver) throws Exception { 38 | 39 | // 解释表达式内容 40 | Object obj = exprResolver.executeExpr(expr); 41 | 42 | // 直接输出未经转义的对象内容 43 | exqlContext.fillText(String.valueOf(obj)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/SQLType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.annotation; 17 | 18 | /** 19 | * SQL类型标识。 20 | *

21 | * 在使用{@link SQL} 22 | * 注解时,Jade将以SELECT开始的语句认为是查询类型SQL语句,其它的语句被认为是更新类型,开发者可以根据实际改变Jade的默认判断 23 | * ,比如SHOW语句实际应该是查询类型语句,而非更新类型语句。 24 | * 25 | * @author 王志亮 [qieqie.wang@gmail.com] 26 | * @author 廖涵 [in355hz@gmail.com] 27 | */ 28 | public enum SQLType { 29 | /** 30 | * 查询类型语句 31 | */ 32 | READ, 33 | 34 | /** 35 | * 更新类型语句 36 | */ 37 | WRITE, 38 | 39 | /** 40 | * 未知类型,将使用Jade的默认规则判断:所有以SELECT开始的语句是查询类型的,其他的是更新类型的 41 | */ 42 | AUTO_DETECT, 43 | 44 | } 45 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/ShardParam.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 请改为使用ShardBy放在具体的参数前。 11 | *

12 | * 如果原来是这样的
13 | * @ShardParam(name = "page_id", value=":2")
14 | * @SQL("....where name like :1")
15 | * public void find(String likeValue, String pageId); 16 | *

17 | * 现在改为:
18 | * @SQL("....where name like :1")
19 | * public void find(String likeValue, @ShardBy String pageId); 20 | *

21 | * 22 | * 把 {@link ShardParam} 标注在 SQL 查询的散表参数上,说明该参数值用于散库 / 散表。 23 | * 24 | * @author han.liao [in355hz@gmail.com] 25 | * @author 王志亮 [qieqie.wang@gmail.com] 26 | */ 27 | @Target( { ElementType.METHOD }) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | @Deprecated 31 | public @interface ShardParam { 32 | 33 | // 匹配所有列 34 | final String WIDECARD = "*"; 35 | 36 | /** 37 | * 指出这个参数作为 SQL 语句中哪个散表字段。 38 | * 39 | * @return 对应的散表字段 40 | */ 41 | String name() default WIDECARD; 42 | 43 | /** 44 | * 指出这个参数值如何计算。 45 | * 46 | * @return 计算参数值 47 | */ 48 | String value(); 49 | } 50 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/Interpreter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | import org.springframework.core.annotation.Order; 19 | 20 | /** 21 | * 可用 {@link Order}来调节优先级,根据 {@link Order} 语义,值越小越优先,值越大越后; 22 | *

23 | * 如果没有标注 {@link Order} 使用默认值0。 24 | * 25 | * 从实践看,jade插件的解析器一般应该设置为负数,以优先于系统解析器。 26 | * 27 | * @author 王志亮 [qieqie.wang@gmail.com] 28 | * @author 廖涵 [in355hz@gmail.com] 29 | * 30 | */ 31 | //按Spring语义规定,根据 {@link Order} 语义,值越小越优先,值越大越后; 32 | @Order(0) 33 | public interface Interpreter { 34 | 35 | /** 36 | * 37 | * @param runtime 38 | */ 39 | void interpret(StatementRuntime runtime); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/MultipartCleanup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | @Target( { ElementType.METHOD }) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface MultipartCleanup { 33 | 34 | public enum After { 35 | CONTROLLER_INVOCATION, REQUEST_COMPLETION 36 | }; 37 | 38 | After after() default After.CONTROLLER_INVOCATION; 39 | } 40 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/paramresolver/ParamResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * Copyright 2007-2009 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package net.paoding.rose.web.paramresolver; 18 | 19 | import net.paoding.rose.web.Invocation; 20 | 21 | /** 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | */ 24 | public interface ParamResolver { 25 | 26 | /** 27 | * 返回true表示是由本解析器负责解析这种类型的参数. 28 | * 29 | * @param metaData 30 | * @return 31 | */ 32 | public boolean supports(ParamMetaData metaData); 33 | 34 | /** 35 | * @param inv 36 | * @param metaData 37 | * @return 38 | * @throws Exception 39 | */ 40 | public Object resolve(Invocation inv, ParamMetaData metaData) throws Exception; 41 | } 42 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/mapping/MatchResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.mapping; 17 | 18 | /** 19 | * 控制器的action path参数映射结果,从这个结果中可以知道一个地址映射给哪个资源、资源的参数值是什么 20 | * 21 | * @author 王志亮 [qieqie.wang@gmail.com] 22 | * 23 | */ 24 | public interface MatchResult { 25 | 26 | /** 27 | * 28 | * 29 | */ 30 | public MappingNode getMappingNode(); 31 | 32 | /** 33 | * 返回匹配结果字符串 34 | * 35 | * 36 | */ 37 | public String getValue(); 38 | 39 | /** 40 | * 返回从结果字符串中得到的资源参数名(如果该资源使用了使用了参数化的映射地址) 41 | * 42 | * @param name 43 | * 44 | */ 45 | public String getParameterName(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/cached/CacheInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement.cached; 17 | 18 | /** 19 | * {@link CacheInterface} 抽象DAO方法所使用的缓存接口 20 | * 21 | * @author han.liao [in355hz@gmail.com] 22 | */ 23 | public interface CacheInterface { 24 | 25 | /** 26 | * 从缓存取出给定key对应的对象,如果没有则返回null 27 | * 28 | */ 29 | Object get(String key); 30 | 31 | /** 32 | * 将某个对象和给定的key绑定起来存储在缓存中 33 | * 34 | * @param expiryInSecond - 缓存过期时间,单位为秒 35 | * 36 | */ 37 | boolean set(String key, Object value, int expiryInSecond); 38 | 39 | /** 40 | * 从 Cache 缓存池删除对象。 41 | * 42 | * @param key - 缓存关键字 43 | */ 44 | boolean delete(String key); 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/FlashParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 将{@link FlashParam}标注在控制器方法的参数上,重定向之前的的信息. 26 | *

27 | * 28 | * @author 王志亮 [qieqie.wang@gmail.com] 29 | * 30 | */ 31 | @Target( { ElementType.PARAMETER }) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Documented 34 | public @interface FlashParam { 35 | 36 | /** 37 | * 声明要从Flash对象获取的参数的名字; 38 | *

39 | * 40 | * @return 41 | */ 42 | String value(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/controllers/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.controllers; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | import net.paoding.rose.RoseVersion; 24 | 25 | import org.springframework.core.SpringVersion; 26 | 27 | class Utils { 28 | 29 | public static String wrap(String msg) { 30 | String roseVersion = RoseVersion.getVersion(); 31 | String springVersion = SpringVersion.getVersion(); 32 | return "@Paoding Rose " + roseVersion + "@Spring-" + springVersion 33 | + "" + msg + "

" + roseVersion + "@Spring-" 34 | + springVersion + "
"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/Pattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 用 {@link Pattern} 标注在控制器的方法参数上,表示其解析模式。 26 | *

27 | * 如用于时间参数解析,可以使用 @Pattern("MM/dd/yyyy")来解析"03/12/2010"的字符串! 28 | * 29 | * 30 | * @author 王志亮 [qieqie.wang@gmail.com] 31 | * 32 | */ 33 | @Target( { ElementType.PARAMETER }) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Documented 36 | public @interface Pattern { 37 | 38 | /** 39 | * 40 | * @return 41 | */ 42 | String[] value(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/rowmapper/SetRowMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.rowmapper; 17 | 18 | import java.util.Collection; 19 | import java.util.HashSet; 20 | 21 | import net.paoding.rose.jade.statement.StatementMetaData; 22 | 23 | /** 24 | * 将SQL结果集的一行映射为Set 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * @author 廖涵 [in355hz@gmail.com] 28 | */ 29 | public class SetRowMapper extends AbstractCollectionRowMapper { 30 | 31 | public SetRowMapper(StatementMetaData modifier) { 32 | super(modifier); 33 | } 34 | 35 | @Override 36 | @SuppressWarnings("unchecked") 37 | protected Collection createCollection(int columnSize) { 38 | return new HashSet(columnSize * 2); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/ParamValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | import net.paoding.rose.web.paramresolver.ParamMetaData; 19 | 20 | import org.springframework.validation.Errors; 21 | 22 | /** 23 | * 24 | * @author 王志亮 [qieqie.wang@gmail.com] 25 | * 26 | */ 27 | public interface ParamValidator { 28 | 29 | /** 30 | * 返回true表示是由本解析器负责解析这种类型的参数. 31 | * 32 | * @param metaData 33 | * @return 34 | */ 35 | public boolean supports(ParamMetaData metaData); 36 | 37 | /** 38 | * 如果返回的instruction不是null、boolean或空串==>杯具:流程到此为止! 39 | * 返回null或true,false,空串没有本质区别 40 | */ 41 | Object validate(ParamMetaData metaData, Invocation inv, Object target, Errors errors); 42 | } 43 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/dataaccess/DataAccessFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.dataaccess; 17 | 18 | import java.util.Map; 19 | 20 | import net.paoding.rose.jade.statement.StatementMetaData; 21 | import net.paoding.rose.jade.statement.StatementRuntime; 22 | 23 | /** 24 | * 这是框架的内部接口,{@link DataAccess}的工厂类。 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * @author 廖涵 [in355hz@gmail.com] 28 | */ 29 | public interface DataAccessFactory { 30 | 31 | /** 32 | * 运行时为框架提供一个 {@link DataAccess} 实例 33 | * @param metaData 所执行的DAO方法 34 | * @param attributes {@link StatementRuntime#getAttributes()} 35 | */ 36 | DataAccess getDataAccess(StatementMetaData metaData, Map attributes); 37 | } 38 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/rowmapper/ListRowMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.rowmapper; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collection; 20 | 21 | import net.paoding.rose.jade.statement.StatementMetaData; 22 | 23 | /** 24 | * 将SQL结果集的一行映射为List 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * @author 廖涵 [in355hz@gmail.com] 28 | */ 29 | public class ListRowMapper extends AbstractCollectionRowMapper { 30 | 31 | public ListRowMapper(StatementMetaData modifier) { 32 | super(modifier); 33 | } 34 | 35 | @Override 36 | @SuppressWarnings("unchecked") 37 | protected Collection createCollection(int columnSize) { 38 | return new ArrayList(columnSize); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/instruction/Text.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.instruction; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public class Text implements InstructionHelper { 24 | 25 | public static TextInstruction text(Object value) { 26 | TextInstruction instruction = new TextInstruction(); 27 | String text = (value == null) ? "" : value.toString(); 28 | if (text.length() > 0) { 29 | if (!(value instanceof CharSequence)) { 30 | if (value.getClass().getName().equalsIgnoreCase("JSONObject")) { 31 | text = "json:" + text; 32 | } 33 | } 34 | } 35 | instruction.text(text); 36 | return instruction; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/controllers/demo/PortalController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal.controllers.demo; 17 | 18 | import net.paoding.rose.web.portal.Portal; 19 | import net.paoding.rose.web.portal.PortalSetting; 20 | 21 | /** 22 | * 23 | * @author 王志亮 [qieqie.wang@gmail.com] 24 | * 25 | */ 26 | public class PortalController { 27 | 28 | @PortalSetting(timeout = 100) 29 | public String home(Portal portal) throws Exception { 30 | portal.addWindow("content1", "/test/uri?abc=asd"); 31 | portal.addWindow("content2", "/test/uri?abc=asd"); 32 | portal.addWindow("content3", "/test/uri?abc=asd"); 33 | portal.addWindow("content4", "/test/uri?abc=asd"); 34 | return "portal-home"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/DefValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | @Target( { ElementType.PARAMETER }) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface DefValue { 33 | 34 | String NATIVE_DEFAULT = "$$paoding-rose.param.nativeDefualt"; 35 | 36 | /** 37 | * 设置该参数的默认值,如果请求中没有该参数的话,或者发生转化错误时 38 | *

39 | * 40 | * @return 41 | */ 42 | String value() default NATIVE_DEFAULT; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/SuppressMultipartResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 26 | * 标注 {@link SuppressMultipartResolver} 在方法上,能够压制rose自动进行上传解析。这用于两种情况: 27 | * 1)如有必要可forward给另外的控制器方法解析.
28 | * 2)开发者想要有更自由的解析以及时间点控制(对于后者可以,开发者可以在方法中声明 MultipartResolver 获取到解析器) 29 | *

30 | * 31 | * 32 | * @author 王志亮 [qieqie.wang@gmail.com] 33 | * 34 | */ 35 | @Target( { ElementType.METHOD }) 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Documented 38 | public @interface SuppressMultipartResolver { 39 | 40 | } 41 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/instruction/HttpError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.instruction; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | 24 | public class HttpError implements InstructionHelper { 25 | 26 | public static HttpErrorInstruction code(int code) { 27 | HttpErrorInstruction instruction = new HttpErrorInstruction(); 28 | instruction.setCode(code); 29 | return instruction; 30 | } 31 | 32 | public static HttpErrorInstruction code(int code, String message) { 33 | HttpErrorInstruction instruction = new HttpErrorInstruction(); 34 | instruction.setCode(code); 35 | instruction.setMessage(message); 36 | return instruction; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/NotForSubModules.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import net.paoding.rose.web.ControllerErrorHandler; 25 | import net.paoding.rose.web.paramresolver.ParamResolver; 26 | 27 | /** 28 | * 使用 {@link NotForSubModules} 标注在编写在模块目录中的拦截器、错误处理器 29 | * {@link ControllerErrorHandler}、 参数解析器 {@link ParamResolver} 上,表示不应用到子模块 30 | * 31 | * @author 王志亮 [qieqie.wang@gmail.com] 32 | */ 33 | @Target( { ElementType.TYPE }) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Documented 36 | public @interface NotForSubModules { 37 | 38 | } 39 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/InterpreterComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | import java.util.Comparator; 19 | 20 | import org.springframework.core.annotation.Order; 21 | 22 | /** 23 | * 24 | * @author 王志亮 [qieqie.wang@gmail.com] 25 | * 26 | */ 27 | public class InterpreterComparator implements Comparator { 28 | 29 | @Override 30 | public int compare(Interpreter thees, Interpreter that) { 31 | Order thessOrder = thees.getClass().getAnnotation(Order.class); 32 | Order thatOrder = that.getClass().getAnnotation(Order.class); 33 | int thessValue = thessOrder == null ? 0 : thessOrder.value(); 34 | int thatValue = thatOrder == null ? 0 : thatOrder.value(); 35 | return thessValue - thatValue; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/PortalFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | import java.io.IOException; 19 | 20 | import net.paoding.rose.web.Invocation; 21 | 22 | /** 23 | * {@link PortalFactory} 是 portal/pipe 框架的核心,它负责创建 {@link Portal} / 24 | * {@link Pipe} 对象. 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public interface PortalFactory { 30 | 31 | /** 32 | * 创建给定请求的 {@link Portal} 实例 33 | * 34 | * @param inv 35 | * @return 36 | */ 37 | public Portal createPortal(Invocation inv); 38 | 39 | /** 40 | * 创建给定请求的 {@link Pipe} 实例 41 | * 42 | * @return 43 | * @throws IOException 44 | */ 45 | public Pipe createPipe(Invocation inv, boolean create); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/CacheDelete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 使用:{#link CacheDelete} 标注需要在执行后清除缓存的 DAO 接口方法。 26 | * 27 | * @author han.liao 28 | */ 29 | @Target( { ElementType.METHOD }) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface CacheDelete { 33 | 34 | /** 35 | * 标注需要清除的缓存 Pool 36 | * 37 | * @return 缓存 Pool 38 | */ 39 | String pool() default "default"; 40 | 41 | /** 42 | * 标注需要清除的缓存 Key. 43 | * 44 | * @return 缓存 Key 45 | */ 46 | String[] key(); 47 | } 48 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/Statement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | import java.util.Map; 19 | 20 | /** 21 | * {@link Statement} 表示一个符合规范的DAO方法,代表一个对数据库进行检索或更新的语句。 22 | *

23 | * 24 | * 这是一个内部接口 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | */ 28 | public interface Statement { 29 | 30 | /** 31 | * 所属的DAO方法及其相关的信息 32 | * 33 | * @return 34 | */ 35 | public StatementMetaData getMetaData(); 36 | 37 | /** 38 | * 按照给定的方法参数值,执行一次数据库检索或更新 39 | *

40 | * 您可以通过parameters.get(":1")、parameters.get(":2")获得方法中的第1、第2个参数(从1开始)
41 | * 如果DAO方法中的参数设置了@SQLParam(name) 42 | * 注解,您还可以从parameters.get(name)取得该参数。 43 | * 44 | * @return 45 | */ 46 | public Object execute(Map parameters); 47 | } 48 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/test/java/net/paoding/rose/jade/provider/DefinitionTests.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.provider; 2 | 3 | import java.util.Map; 4 | 5 | import net.paoding.rose.jade.statement.DAOMetaData; 6 | 7 | import junit.framework.Assert; 8 | import junit.framework.TestCase; 9 | 10 | public class DefinitionTests extends TestCase { 11 | 12 | public void testDefinition() { 13 | 14 | DAOMetaData definition = new DAOMetaData(Character.class, null); 15 | Assert.assertEquals("java.lang.Character", definition.toString()); 16 | 17 | // 输出所有常量 18 | System.out.println("Class constants: "); 19 | Map consts = definition.getConstants(); 20 | for (Map.Entry entry : consts.entrySet()) { 21 | System.out.println(entry.getKey() + " = " + entry.getValue()); 22 | } 23 | 24 | // 效验一些常量 25 | Assert.assertEquals(Character.CONTROL, consts.get("CONTROL")); 26 | Assert.assertEquals(Character.DECIMAL_DIGIT_NUMBER, consts.get("DECIMAL_DIGIT_NUMBER")); 27 | Assert.assertEquals(Character.MIN_CODE_POINT, consts.get("MIN_CODE_POINT")); 28 | Assert.assertEquals(Character.MAX_CODE_POINT, consts.get("MAX_CODE_POINT")); 29 | Assert.assertEquals(Character.MIN_HIGH_SURROGATE, consts.get("MIN_HIGH_SURROGATE")); 30 | Assert.assertEquals(Character.MAX_LOW_SURROGATE, consts.get("MAX_LOW_SURROGATE")); 31 | Assert.assertEquals(Character.FORMAT, consts.get("FORMAT")); 32 | Assert.assertEquals(Character.SIZE, consts.get("SIZE")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/WindowListenerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public abstract class WindowListenerAdapter implements WindowListener { 24 | 25 | @Override 26 | public void onWindowAdded(Window window) { 27 | 28 | } 29 | 30 | @Override 31 | public void onWindowCanceled(Window window) { 32 | 33 | } 34 | 35 | @Override 36 | public void onWindowDone(Window window) { 37 | 38 | } 39 | 40 | @Override 41 | public void onWindowError(Window window) { 42 | 43 | } 44 | 45 | @Override 46 | public void onWindowStarted(Window window) { 47 | 48 | } 49 | 50 | @Override 51 | public void onWindowTimeout(Window window) { 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/impl/MergeWindowAttributesToModelInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal.impl; 17 | 18 | import net.paoding.rose.web.ControllerInterceptorAdapter; 19 | import net.paoding.rose.web.Invocation; 20 | import net.paoding.rose.web.portal.PortalUtils; 21 | import net.paoding.rose.web.portal.Window; 22 | 23 | /** 24 | * 25 | * @author 王志亮 [qieqie.wang@gmail.com] 26 | * 27 | */ 28 | public class MergeWindowAttributesToModelInterceptor extends ControllerInterceptorAdapter { 29 | 30 | @Override 31 | public Object after(Invocation inv, Object instruction) throws Exception { 32 | Window window = PortalUtils.getWindow(inv); 33 | if (window != null) { 34 | inv.getModel().merge(window.getAttributes()); 35 | } 36 | return instruction; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/AsSuperController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 标注成为{@link AsSuperController}的类,他的方法可以作为直接继承类(子类)控制器的action被使用。 26 | *

27 | * 如果一个类A标注了{@link AsSuperController},但是他的一个子类B没有标注 28 | * {@link AsSuperController} ,如果这个子类的子类C是一个控制器,刚才标注了 29 | * {@link AsSuperController}的类A的方法仍旧不能作为action方法暴露出来。
30 | * 但是如果类B标注了{@link AsSuperController},则类A和B的方法将暴露给类C作为action方法。 31 | * 32 | * @author 王志亮 [qieqie.wang@gmail.com] 33 | * 34 | */ 35 | @Target( { ElementType.TYPE }) 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Documented 38 | public @interface AsSuperController { 39 | 40 | } 41 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/Interceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 使用 {@link Interceptor} 标注一个控制器拦截器的名字以及其他设置 26 | * 27 | * @author 王志亮 [qieqie.wang@gmail.com] 28 | * 29 | */ 30 | @Target( { ElementType.TYPE, ElementType.FIELD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Documented 33 | public @interface Interceptor { 34 | 35 | // /** 36 | // * 明确标注拦截器的名字 37 | // * 38 | // * @return 39 | // */ 40 | // String name() default ""; 41 | 42 | /** 43 | * 对用户的每一个请求,只执行一次拦截? 44 | * 45 | * @return 46 | */ 47 | boolean oncePerRequest() default false; 48 | } 49 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/Path.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 标注 {@link Path}设置对控制器的自定义映射规则。 26 | * 27 | * @author 王志亮 [qieqie.wang@gmail.com] 28 | * 29 | */ 30 | @Target( { ElementType.TYPE }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Documented 33 | public @interface Path { 34 | 35 | /** 36 | * 设定哪些路径应由所在控制器处理,可以设置多个。 37 | *

38 | * 可以在设置中使用不限制个数的${xx},并结合 {@link Param}标注使用 。 路径是否以'/'开头不做区别。 39 | *

40 | * 41 | * 特别的,如果不想让一个控制器生效,除了使用@Ignored外(推荐),还可以使用@Path({}),即使用零长度数组来实现. 42 | * 43 | * @return 44 | */ 45 | String[] value(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/Pipe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | /** 19 | * {@link WindowContainer} 20 | * 两种类型的其中一种,用于在服务端为一个请求并发请求多个窗口,但主控制器返回的整体页面框架先输出给客户端,并保持连接不断开, 21 | * 当某个窗口的流程执行完毕,框架再将该窗口返回的页面数据通过那个没有断开的连接吐给客户端; 22 | * 23 | * 24 | *

25 | * 详细文档,请见 {@link WindowContainer} 26 | * 27 | * @author 王志亮 [qieqie.wang@gmail.com] 28 | * 29 | */ 30 | public interface Pipe extends WindowContainer { 31 | 32 | /** 33 | * 将一个css地址注册到window,使得客户端在渲染该Window时候能够先装载该css 34 | * 35 | * @param window 36 | * @param css 37 | */ 38 | public void addCssTo(String windowName, String css); 39 | 40 | /** 41 | * 将一个css地址注册到window,使得客户端得到Window时候能够执行该javascripte 42 | * 43 | * @param windowName 44 | * @param js 45 | */ 46 | public void addJsTo(String windowName, String js); 47 | } 48 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/impl/WindowResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal.impl; 17 | 18 | import net.paoding.rose.web.Invocation; 19 | import net.paoding.rose.web.paramresolver.ParamMetaData; 20 | import net.paoding.rose.web.paramresolver.ParamResolver; 21 | import net.paoding.rose.web.portal.PortalUtils; 22 | import net.paoding.rose.web.portal.Window; 23 | 24 | /** 25 | * 解析声明在窗口控制器中的Window参数 26 | * 27 | * @author 王志亮 [qieqie.wang@gmail.com] 28 | * 29 | */ 30 | public class WindowResolver implements ParamResolver { 31 | 32 | @Override 33 | public boolean supports(ParamMetaData paramMetaData) { 34 | return Window.class == paramMetaData.getParamType(); 35 | } 36 | 37 | @Override 38 | public Object resolve(Invocation inv, ParamMetaData paramMetaData) throws Exception { 39 | return PortalUtils.getWindow(inv); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/rowmapper/RowMapperFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.rowmapper; 17 | 18 | 19 | 20 | import net.paoding.rose.jade.statement.StatementMetaData; 21 | 22 | import org.springframework.jdbc.core.RowMapper; 23 | 24 | /** 25 | * {@link RowMapperFactory}可以为每一个查询类型DAO方法创建对应的行映射器{@link RowMapper} 26 | * 对象,用来把SQL结果集中的每一行转化为DAO方法定义的返回类型所要求的组件类型。 27 | *

28 | * 对于DAO方法返回类型是List或User的,RowMapper用来将结果集的每一行转化为User对象。
29 | * 如果返回类型是String[]或String的,RowMapper用来将结果集的每一行转化为一个字符串对象。
30 | * 。。。 31 | *

32 | * 33 | * @author 王志亮 [qieqie.wang@gmail.com] 34 | * @author 廖涵 [in355hz@gmail.com] 35 | */ 36 | public interface RowMapperFactory { 37 | 38 | /** 39 | * 根据DAO方法的返回类型定义,解析可能存在的泛型,创建对应的行映射器对象。 40 | * 41 | * @return 如果无法解析时可返回null 42 | */ 43 | public RowMapper getRowMapper(StatementMetaData metaData); 44 | } 45 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/Create.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import javax.servlet.http.HttpSession; 25 | 26 | import net.paoding.rose.web.paramresolver.ResolverFactoryImpl.HttpSessionResolver; 27 | 28 | /** 29 | * 将Create标注在控制器方法参数上,表示该参数必须或不必须创建,比如对 {@link HttpSession}参数,可通过配置 30 | * {@link Create} 为false,表示如果原先没有 HttpSession 时,保留为null,不用创建。 31 | * 32 | * @see HttpSessionResolver 33 | * @author 王志亮 [qieqie.wang@gmail.com] 34 | * 35 | */ 36 | @Target( { ElementType.PARAMETER }) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @Documented 39 | public @interface Create { 40 | 41 | /** 42 | * 43 | * @return 44 | */ 45 | boolean value() default true; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/test/java/net/paoding/rose/jade/exql/ExqlContextTests.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.exql; 2 | 3 | import java.util.Date; 4 | 5 | import junit.framework.Assert; 6 | import junit.framework.TestCase; 7 | import net.paoding.rose.jade.statement.expression.ExqlContext; 8 | import net.paoding.rose.jade.statement.expression.impl.ExqlContextImpl; 9 | 10 | public class ExqlContextTests extends TestCase { 11 | 12 | public void testExqlContext() { 13 | 14 | Date current = new Date(); 15 | 16 | ExqlContext context = new ExqlContextImpl(); 17 | 18 | context.fillText("WHERE uid = "); 19 | context.fillValue(102); 20 | context.fillText(" AND sid IN ("); 21 | context.fillValue(new int[] { 11, 12, 24, 25, 31, 32, 33 }); 22 | context.fillText(") AND (create_time > "); 23 | context.fillValue(current); 24 | context.fillText(" OR create_time <= "); 25 | context.fillValue(current); 26 | context.fillChar(')'); 27 | 28 | Assert.assertEquals( // NL 29 | "WHERE uid = ? AND sid IN (?,?,?,?,?,?,?) " 30 | + "AND (create_time > ? OR create_time <= ?)", // NL 31 | context.flushOut()); 32 | 33 | Object[] expectArray = new Object[] { 102, 11, 12, 24, 25, 31, 32, 33, // NL 34 | current, current }; 35 | Object[] paramArray = context.getArgs(); 36 | 37 | Assert.assertEquals(expectArray.length, paramArray.length); 38 | for (int i = 0; i < expectArray.length; i++) { 39 | Assert.assertEquals(expectArray[i], paramArray[i]); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /paoding-rose-load/src/test/java/net/paoding/rose/load/vfs/LoadScopeTest.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.load.vfs; 2 | 3 | import org.apache.commons.lang.ArrayUtils; 4 | 5 | import junit.framework.TestCase; 6 | import net.paoding.rose.load.LoadScope; 7 | 8 | public class LoadScopeTest extends TestCase { 9 | 10 | public void test1() { 11 | LoadScope scope = new LoadScope("controllers=com.xiaonei.game", "controllers"); 12 | assertNull(scope.getScope("applicationContext")); 13 | assertTrue(ArrayUtils.isEquals(new String[] { "com.xiaonei.game", "net.paoding.rose" }, 14 | scope.getScope("controllers"))); 15 | } 16 | 17 | public void test2() { 18 | LoadScope scope = new LoadScope("controllers=com.xiaonei.game,net.paoding.rose.web", 19 | "controllers"); 20 | assertNull(scope.getScope("applicationContext")); 21 | assertTrue(ArrayUtils.isEquals(new String[] { "com.xiaonei.game", "net.paoding.rose.web", 22 | "net.paoding.rose" }, scope.getScope("controllers"))); 23 | } 24 | 25 | public void test3() { 26 | LoadScope scope = new LoadScope( 27 | "com.xiaonei.game;applicationContext=com.xiaonei.abc", "controllers"); 28 | assertNotNull(scope.getScope("applicationContext")); 29 | assertTrue(ArrayUtils.isEquals(new String[] { "com.xiaonei.game", "net.paoding.rose" }, 30 | scope.getScope("controllers"))); 31 | assertTrue(ArrayUtils.isEquals(new String[] { "com.xiaonei.abc", "net.paoding.rose" }, 32 | scope.getScope("applicationContext"))); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /paoding-rose-load/src/main/java/net/paoding/rose/load/vfs/FileName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.load.vfs; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public interface FileName { 26 | 27 | /** 28 | * 返回所代表的文件或实体对象 29 | * 30 | * @return 31 | * @throws IOException 32 | */ 33 | public FileObject getFileObject() throws IOException; 34 | 35 | /** 36 | * 基础文件名,即使是目录也不以'/'开始或结尾 37 | * 38 | * @return 39 | * @throws IOException 40 | */ 41 | public String getBaseName() throws IOException; 42 | 43 | /** 44 | * 一个下级文件或实体相对于本文件或实体的路径,得到的返回字符串不以'/'开始,如果subFileName是一个子目录的话,返回的结果将以 45 | * '/'结尾 46 | * 47 | * @param subFileName 48 | * @return 49 | * @throws IOException 50 | */ 51 | public String getRelativeName(FileName subFileName) throws IOException; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/impl/PortalImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal.impl; 17 | 18 | import java.util.concurrent.ExecutorService; 19 | 20 | import net.paoding.rose.web.Invocation; 21 | import net.paoding.rose.web.portal.Portal; 22 | import net.paoding.rose.web.portal.WindowListener; 23 | 24 | /** 25 | * {@link Portal} 的实现类,Portal 框架的核心类。 26 | * 27 | * @author 王志亮 [qieqie.wang@gmail.com] 28 | * 29 | */ 30 | public class PortalImpl extends GenericWindowContainer implements Portal, WindowListener { 31 | 32 | public PortalImpl(Invocation inv, ExecutorService executorService, WindowListener portalListener) { 33 | super(inv, executorService, portalListener); 34 | } 35 | 36 | //-------------实现toString()--------------- 37 | 38 | @Override 39 | public String toString() { 40 | return "portal ['" + getInvocation().getRequestPath().getUri() + "']"; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/view/ViewPathCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.view; 17 | 18 | import java.util.HashMap; 19 | 20 | import net.paoding.rose.RoseConstants; 21 | 22 | /** 23 | * 24 | * @author 王志亮 [qieqie.wang@gmail.com] 25 | * 26 | */ 27 | public class ViewPathCache { 28 | 29 | private String directoryPath; 30 | 31 | private HashMap viewPathMap = new HashMap(); 32 | 33 | public ViewPathCache(String modulePath) { 34 | directoryPath = RoseConstants.VIEWS_PATH + modulePath; 35 | } 36 | 37 | public String getViewPath(String viewName) { 38 | return viewPathMap.get(viewName); 39 | } 40 | 41 | public void setViewPath(String viewName, String viewPath) { 42 | viewPathMap.put(viewName, viewPath); 43 | } 44 | 45 | public String getDirectoryPath() { 46 | return directoryPath; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/PortalSetting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | import java.util.concurrent.TimeUnit; 24 | 25 | /** 26 | * 在portal主控制器方法上标注 {@link PortalSetting}设置有关 {@link Portal}、 {@link Pipe} 的参数 27 | * 28 | * @author 王志亮 [qieqie.wang@gmail.com] 29 | * 30 | */ 31 | @Target( { ElementType.METHOD }) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Documented 34 | public @interface PortalSetting { 35 | 36 | /** 37 | * 设置超时等待时间。如果为0或负数表示无限期等待直至所有窗口完毕 38 | * 39 | * @return 40 | */ 41 | public long timeout() default -1; 42 | 43 | /** 44 | * 超时时间设置单位,默认为毫秒 45 | * 46 | * @return 47 | */ 48 | public TimeUnit timeUnit() default TimeUnit.MILLISECONDS; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/rest/Get.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation.rest; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 表明所注解的方法可用于处理HTTP GET请求。 26 | *

27 | * Get参数:
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的GET请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的GET请求。 30 | *

31 | * example: UserController下有一个方法xyz
32 | * 1、在没有配置任何注解的情况下,xyz方法代表的资源是/user/xyz,支持GET和POST两种访问
33 | * 2、如果对xyz标注了@Get()注解,xyz代表的资源是/user,并且仅支持GET访问
34 | * 3、如果对xyz标注了@Get("abc"),xyz代表的是资源/user/abc,并且仅支持GET访问
35 | * 36 | * 37 | * @author 王志亮 [qieqie.wang@gmail.com] 38 | */ 39 | @Target( { ElementType.METHOD }) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Documented 42 | public @interface Get { 43 | 44 | String[] value() default { "" }; 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/rest/Put.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation.rest; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 表明所注解的方法可用于处理HTTP PUT请求。 26 | *

27 | * Put参数:
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的PUT请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的PUT请求。 30 | *

31 | * example: UserController下有一个方法xyz
32 | * 1、在没有配置任何注解的情况下,xyz方法代表的资源是/user/xyz,支持GET和POST两种访问
33 | * 2、如果对xyz标注了@Put()注解,xyz代表的资源是/user,并且仅支持PUT访问
34 | * 3、如果对xyz标注了@Put("abc"),xyz代表的是资源/user/abc,并且仅支持PUT访问
35 | * 36 | * 37 | * @author 王志亮 [qieqie.wang@gmail.com] 38 | */ 39 | @Target( { ElementType.METHOD }) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Documented 42 | public @interface Put { 43 | 44 | String[] value() default { "" }; 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/rest/Head.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation.rest; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 表明所注解的方法可用于处理HTTP HEAD请求。 26 | *

27 | * Head参数:
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的HEAD请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的HEAD请求。 30 | *

31 | * example: UserController下有一个方法xyz
32 | * 1、在没有配置任何注解的情况下,xyz方法代表的资源是/user/xyz,支持GET和POST两种访问
33 | * 2、如果对xyz标注了@Head()注解,xyz代表的资源是/user,并且仅支持HEAD访问
34 | * 3、如果对xyz标注了@Head("abc"),xyz代表的是资源/user/abc,并且仅支持HEAD访问
35 | * 36 | * 37 | * @author 王志亮 [qieqie.wang@gmail.com] 38 | */ 39 | @Target( { ElementType.METHOD }) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Documented 42 | public @interface Head { 43 | 44 | String[] value() default { "" }; 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/rest/Post.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation.rest; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 表明所注解的方法可用于处理HTTP POST请求。 26 | *

27 | * Post参数:
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的POST请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的POST请求。 30 | *

31 | * example: UserController下有一个方法xyz
32 | * 1、在没有配置任何注解的情况下,xyz方法代表的资源是/user/xyz,支持GET和POST两种访问
33 | * 2、如果对xyz标注了@Post()注解,xyz代表的资源是/user,并且仅支持POST访问
34 | * 3、如果对xyz标注了@Post("abc"),xyz代表的是资源/user/abc,并且仅支持POST访问
35 | * 36 | * 37 | * @author 王志亮 [qieqie.wang@gmail.com] 38 | */ 39 | @Target( { ElementType.METHOD }) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Documented 42 | public @interface Post { 43 | 44 | String[] value() default { "" }; 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/util/RoseBeanUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.paoding.rose.util; 18 | 19 | import org.springframework.beans.BeanInstantiationException; 20 | import org.springframework.beans.BeanUtils; 21 | /** 22 | * 23 | * @author 王志亮 [qieqie.wang@gmail.com] 24 | * 25 | */ 26 | public class RoseBeanUtils extends BeanUtils { 27 | 28 | @SuppressWarnings("unchecked") 29 | public static Object instantiateClass(Class clazz) throws BeanInstantiationException { 30 | // spring's : Object mappedObject = BeanUtils.instantiateClass(this.mappedClass); 31 | // jade's : private Object instantiateClass(this.mappedClass); 32 | // why: 经过简单的笔记本测试,mappedClass.newInstrance性能比BeanUtils.instantiateClass(mappedClass)快1个数量级 33 | try { 34 | return clazz.newInstance(); 35 | } catch (Exception ex) { 36 | throw new BeanInstantiationException(clazz, ex.getMessage(), ex); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/rest/Trace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation.rest; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 表明所注解的方法可用于处理HTTP TRACE请求。 26 | *

27 | * Trace参数:
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的TRACE请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的TRACE请求。 30 | *

31 | * example: UserController下有一个方法xyz
32 | * 1、在没有配置任何注解的情况下,xyz方法代表的资源是/user/xyz,支持GET和TRACE两种访问
33 | * 2、如果对xyz标注了@Trace()注解,xyz代表的资源是/user,并且仅支持POST访问
34 | * 3、如果对xyz标注了@Trace("abc"),xyz代表的是资源/user/abc,并且仅支持TRACE访问
35 | * 36 | * 37 | * @author 王志亮 [qieqie.wang@gmail.com] 38 | */ 39 | @Target( { ElementType.METHOD }) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Documented 42 | public @interface Trace { 43 | 44 | String[] value() default { "" }; 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/rest/Delete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation.rest; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 表明所注解的方法可用于处理HTTP DELETE请求。 26 | *

27 | * Delete参数:
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的DELETE请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的DELETE请求。 30 | *

31 | * example: UserController下有一个方法xyz
32 | * 1、在没有配置任何注解的情况下,xyz方法代表的资源是/user/xyz,支持GET和POST两种访问
33 | * 2、如果对xyz标注了@Delete()注解,xyz代表的资源是/user,并且仅支持DELETE访问
34 | * 3、如果对xyz标注了@Delete("abc"),xyz代表的是资源/user/abc,并且仅支持DELETE访问
35 | * 36 | * 37 | * @author 王志亮 [qieqie.wang@gmail.com] 38 | */ 39 | @Target( { ElementType.METHOD }) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Documented 42 | public @interface Delete { 43 | 44 | String[] value() default { "" }; 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/rest/Options.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation.rest; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 表明所注解的方法可用于处理HTTP OPTIONS请求。 26 | *

27 | * Options参数:
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的OPTIONS请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的OPTIONS请求。 30 | *

31 | * example: UserController下有一个方法xyz
32 | * 1、在没有配置任何注解的情况下,xyz方法代表的资源是/user/xyz,支持GET和POST两种访问
33 | * 2、如果对xyz标注了@Options()注解,xyz代表的资源是/user,并且仅支持OPTIONS访问
34 | * 3、如果对xyz标注了@Options("abc"),xyz代表的是资源/user/abc,并且仅支持OPTIONS访问
35 | * 36 | * 37 | * @author 王志亮 [qieqie.wang@gmail.com] 38 | */ 39 | @Target( { ElementType.METHOD }) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Documented 42 | public @interface Options { 43 | 44 | String[] value() default { "" }; 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/context/spring/SpringDataSourceFactoryDelegate.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade.context.spring; 2 | 3 | import java.util.Map; 4 | 5 | import net.paoding.rose.jade.dataaccess.DataSourceFactory; 6 | import net.paoding.rose.jade.dataaccess.DataSourceHolder; 7 | import net.paoding.rose.jade.statement.StatementMetaData; 8 | 9 | import org.springframework.beans.factory.ListableBeanFactory; 10 | 11 | /** 12 | * 13 | * @author 王志亮 [qieqie.wang@gmail.com] 14 | * 15 | */ 16 | public class SpringDataSourceFactoryDelegate implements DataSourceFactory { 17 | 18 | private ListableBeanFactory beanFactory; 19 | 20 | private DataSourceFactory dataSourceFactory; 21 | 22 | public SpringDataSourceFactoryDelegate(ListableBeanFactory beanFactory) { 23 | this.beanFactory = beanFactory; 24 | } 25 | 26 | @Override 27 | public DataSourceHolder getHolder(StatementMetaData metaData, Map runtimeProperties) { 28 | if (dataSourceFactory == null) { 29 | ListableBeanFactory beanFactory = this.beanFactory; 30 | if (beanFactory != null) { 31 | if (beanFactory.containsBeanDefinition("jade.dataSourceFactory")) { 32 | dataSourceFactory = (DataSourceFactory) beanFactory.getBean( 33 | "jade.dataSourceFactory", DataSourceFactory.class); 34 | } else { 35 | dataSourceFactory = new SpringDataSourceFactory(beanFactory); 36 | } 37 | this.beanFactory = null; 38 | } 39 | } 40 | return dataSourceFactory.getHolder(metaData, runtimeProperties); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/cached/MockCacheProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement.cached; 17 | 18 | import java.util.concurrent.ConcurrentHashMap; 19 | 20 | import net.paoding.rose.jade.statement.StatementMetaData; 21 | 22 | /** 23 | * 提供 ConcurrentHashMap 缓存池的 {@link CacheProvider} 实现。 24 | * 25 | * @author han.liao 26 | */ 27 | public class MockCacheProvider implements CacheProvider { 28 | 29 | private ConcurrentHashMap caches = new ConcurrentHashMap(); 30 | 31 | @Override 32 | public CacheInterface getCacheByPool(StatementMetaData metaData, String poolName) { 33 | MockCache cache = caches.get(poolName); 34 | if (cache == null) { 35 | cache = new MockCache(poolName); 36 | 37 | MockCache cacheExist = caches.putIfAbsent(poolName, cache); 38 | if (cacheExist != null) { 39 | cache = cacheExist; 40 | } 41 | } 42 | 43 | return cache; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/Cache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 使用:{#link Cache} 标注需要缓存的 DAO 接口方法。默认的 expiry 为 0 表示没有过期限制。 26 | * 27 | * @author han.liao 28 | */ 29 | @Target( { ElementType.METHOD }) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Documented 32 | public @interface Cache { 33 | 34 | /** 35 | * 标注 DAO 方法的缓存 Pool 36 | * 37 | * @return 缓存 Pool 38 | */ 39 | String pool() default "default"; 40 | 41 | /** 42 | * 标注 DAO 方法的缓存 Key. 43 | * 44 | * @return 缓存 Key 45 | */ 46 | String key(); 47 | 48 | /** 49 | * 标注 DAO 缓存的过期时间。 50 | * 51 | * @return 缓存过期时间 52 | */ 53 | int expiry() default 0; 54 | 55 | 56 | Class cl() default Object.class; 57 | } 58 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/controllers/RoseToolsInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.controllers; 17 | 18 | import net.paoding.rose.RoseVersion; 19 | import net.paoding.rose.web.ControllerInterceptorAdapter; 20 | import net.paoding.rose.web.Invocation; 21 | 22 | import org.apache.commons.logging.LogFactory; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public class RoseToolsInterceptor extends ControllerInterceptorAdapter { 30 | 31 | @Override 32 | public Object before(Invocation inv) throws Exception { 33 | Class controllerClass = inv.getControllerClass(); 34 | if (!LogFactory.getLog(controllerClass).isDebugEnabled()) { 35 | String msg = String.format("warning: set logger.%s to debug level first. " 36 | + "
Rose-Version: %s", controllerClass.getName(), RoseVersion.getVersion()); 37 | return Utils.wrap(msg); 38 | } 39 | return true; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/module/ParentErrorHandlerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.module; 17 | 18 | import net.paoding.rose.web.ControllerErrorHandler; 19 | import net.paoding.rose.web.Invocation; 20 | import net.paoding.rose.web.ParentErrorHandler; 21 | import net.paoding.rose.web.impl.thread.InvocationBean; 22 | 23 | /** 24 | * 25 | * @author 王志亮 [qieqie.wang@gmail.com] 26 | * 27 | */ 28 | public class ParentErrorHandlerImpl implements ParentErrorHandler { 29 | 30 | @Override 31 | public Object onError(Invocation inv, Throwable ex) throws Throwable { 32 | InvocationBean invb = (InvocationBean) inv; 33 | Module module = invb.getModule(); 34 | while ((module = module.getParent()) != null) { 35 | ControllerErrorHandler handler; 36 | if ((handler = module.getErrorHandler()) != null) { 37 | return handler.onError(invb, ex); 38 | } 39 | } 40 | throw ex; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/resources/applicationContext-rose.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 24 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/Ignored.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import net.paoding.rose.web.ControllerErrorHandler; 25 | import net.paoding.rose.web.ControllerInterceptor; 26 | 27 | /** 28 | * 将{@link Ignored}标注在控制器或者它方法、拦截器( {@link ControllerInterceptor} 29 | * )、控制器异常处理类( {@link ControllerErrorHandler}、上,表示这个类不要被Rose识别。 30 | *

31 | * 对拦截器而言就是不加入对控制器的拦截;对控制器而言就是不暴露该控制器或某个具体的方法;对异常处理器而言就是"就像没有它一样"。 32 | *

33 | * 但是如果有其他类继承被标注为Ignored的类时,这个被Ignored的类的annotation仍然可能影响子类,具体请参考: 34 | * {@link Class#getAnnotation(Class)}的实现 35 | * 36 | * @author 王志亮 [qieqie.wang@gmail.com] 37 | * 38 | */ 39 | @Target( { ElementType.TYPE, ElementType.METHOD, ElementType.FIELD }) 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Documented 42 | public @interface Ignored { 43 | 44 | } 45 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/PortalUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | import net.paoding.rose.RoseConstants; 19 | import net.paoding.rose.web.Invocation; 20 | 21 | /** 22 | * 23 | * @author 王志亮 [qieqie.wang@gmail.com] 24 | * 25 | */ 26 | public class PortalUtils { 27 | 28 | public static Window getWindow(Invocation inv) { 29 | // get from window request attributes 30 | // @see WindowTask#run 31 | return (Window) inv.getRequest().getAttribute(RoseConstants.WINDOW_ATTR); 32 | } 33 | 34 | public static Portal getPortal(Invocation inv) { 35 | // get from invocation attributes 36 | // @see PortalResolver#resolve 37 | return (Portal) inv.getAttribute("$$paoding-rose-portal.portal"); 38 | } 39 | 40 | public static Pipe getPipe(Invocation inv) { 41 | // get from head invocation attributes 42 | return (Pipe) inv.getHeadInvocation().getAttribute("$$paoding-rose-portal.pipe"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/test/java/net/paoding/rose/jade/DataSources.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.Random; 6 | 7 | import javax.sql.DataSource; 8 | 9 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 10 | 11 | /** 12 | * 为可能的测试需要提供各种DataSource实现 13 | *

14 | * 15 | * 这些DataSource使用hsqldb实现,均为内存数据库 16 | * 17 | * @author 王志亮 [qieqie.wang@gmail.com] 18 | * 19 | */ 20 | public class DataSources { 21 | 22 | public static Map instances = new HashMap(); 23 | 24 | /** 25 | * 获取或创建给定名称的一个DataSource实例 26 | * 27 | * @param name 28 | * @return 29 | */ 30 | public static DataSource getDataSource(String name) { 31 | DataSource instance = instances.get(name); 32 | if (instance == null) { 33 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 34 | dataSource.setUrl("jdbc:hsqldb:mem:" + name); 35 | dataSource.setDriverClassName("org.hsqldb.jdbc.JDBCDriver"); 36 | instance = dataSource; 37 | instances.put(name, instance); 38 | } 39 | return instance; 40 | } 41 | 42 | /** 43 | * 创建一个新的、唯一的DataSource实例 44 | * 45 | * @return 46 | */ 47 | public static DataSource createUniqueDataSource() { 48 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 49 | int random = new Random(Integer.MAX_VALUE).nextInt(); 50 | dataSource.setUrl("jdbc:hsqldb:mem:" + System.currentTimeMillis() + "-" + random); 51 | dataSource.setDriverClassName("org.hsqldb.jdbc.JDBCDriver"); 52 | return dataSource; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/resources/applicationContext-jade.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /paoding-rose-pipe/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | net.paoding 6 | paoding-rose-pipe 7 | jar 8 | 2.0-SNAPSHOT 9 | paoding-rose-pipe 10 | 11 | 12 | net.paoding 13 | paoding-rose-parent 14 | 2.0-SNAPSHOT 15 | ../pom.xml 16 | 17 | 18 | 19 | 20 | 21 | 王志亮 22 | qieqie.wang@gmail.com 23 | 24 | 25 | 廖涵 26 | in355hz@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | net.paoding 33 | paoding-rose-web 34 | 35 | 36 | javax.servlet 37 | javax.servlet-api 38 | 39 | 40 | javax.servlet 41 | jsp-api 42 | 43 | 44 | com.metaparadigm 45 | json-rpc 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/annotation/SQLParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 用{@link SQLParam} 注解标注DAO方法的参数,指定参数的名称,使得可以在SQL中通过":参数名"的方式使用它。 26 | * Jade通过PreparedStatment动态地把参数值提交给数据库执行。 27 | *

28 | * 29 | * 30 | * @SQL("SELECT id, account, name FROM user WHERE id=:userId") 31 | *
32 | * public User getUser(@SQLParam("userId") String id);
33 | *

34 | * 35 | * @author 王志亮 [qieqie.wang@gmail.com] 36 | * @author 廖涵 [in355hz@gmail.com] 37 | */ 38 | @Target( { ElementType.PARAMETER }) 39 | @Retention(RetentionPolicy.RUNTIME) 40 | @Documented 41 | public @interface SQLParam { 42 | 43 | /** 44 | * 指出这个值是 SQL 语句中哪个参数的值 45 | * 46 | * @return 对应 SQL 语句中哪个参数 47 | */ 48 | String value(); 49 | } 50 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/RoseVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2006 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.paoding.rose; 18 | 19 | 20 | /** 21 | * Class that exposes the Spring version. Fetches the 22 | * "Implementation-Version" manifest attribute from the jar file. 23 | * 24 | *

25 | * Note that some ClassLoaders do not expose the package metadata, hence 26 | * this class might not be able to determine the Spring version in all 27 | * environments. Consider using a reflection-based check instead: For 28 | * example, checking for the presence of a specific Spring 2.0 method that 29 | * you intend to call. 30 | * 31 | * @author Juergen Hoeller 32 | * @since 1.1 33 | */ 34 | public class RoseVersion { 35 | 36 | /** 37 | * Return the full version string of the present Spring codebase, or 38 | * null if it cannot be determined. 39 | * 40 | * @see java.lang.Package#getImplementationVersion() 41 | */ 42 | public static String getVersion() { 43 | Package pkg = RoseVersion.class.getPackage(); 44 | return (pkg != null ? pkg.getImplementationVersion() : null); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/instruction/Forward.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.instruction; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public class Forward implements InstructionHelper { 24 | 25 | public static ForwardInstruction path(String path) { 26 | ForwardInstruction instruction = new ForwardInstruction(); 27 | instruction.path(path); 28 | return instruction; 29 | } 30 | 31 | public static ForwardInstruction module(String module) { 32 | ForwardInstruction instruction = new ForwardInstruction(); 33 | instruction.module(module); 34 | return instruction; 35 | } 36 | 37 | public static ForwardInstruction controller(String controller) { 38 | ForwardInstruction instruction = new ForwardInstruction(); 39 | instruction.controller(controller); 40 | return instruction; 41 | } 42 | 43 | public static ForwardInstruction action(String action) { 44 | ForwardInstruction instruction = new ForwardInstruction(); 45 | instruction.action(action); 46 | return instruction; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/instruction/Redirect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.instruction; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public class Redirect implements InstructionHelper { 24 | 25 | public static RedirectInstruction location(String path) { 26 | RedirectInstruction instruction = new RedirectInstruction(); 27 | instruction.location(path); 28 | return instruction; 29 | } 30 | 31 | public static RedirectInstruction module(String module) { 32 | RedirectInstruction instruction = new RedirectInstruction(); 33 | instruction.module(module); 34 | return instruction; 35 | } 36 | 37 | public static RedirectInstruction controller(String controller) { 38 | RedirectInstruction instruction = new RedirectInstruction(); 39 | instruction.controller(controller); 40 | return instruction; 41 | } 42 | 43 | public static RedirectInstruction action(String action) { 44 | RedirectInstruction instruction = new RedirectInstruction(); 45 | instruction.action(action); 46 | return instruction; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/test/java/net/paoding/rose/jade/DataSourcesTest.java: -------------------------------------------------------------------------------- 1 | package net.paoding.rose.jade; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import net.paoding.rose.jade.annotation.DAO; 6 | import net.paoding.rose.jade.annotation.SQL; 7 | import net.paoding.rose.jade.context.application.JadeFactory; 8 | 9 | import org.junit.Assert; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | 13 | /** 14 | * 通过集成DAO和JadeFactory,验证 {@link DataSources}的可用 15 | * 16 | * @author 王志亮 [qieqie.wang@gmail.com] 17 | * 18 | */ 19 | public class DataSourcesTest { 20 | 21 | @DAO 22 | interface UserDAO { 23 | 24 | @SQL("create table user (id int, name varchar(200));") 25 | void createTable(); 26 | 27 | @SQL("insert into user (id, name) values(:1, :2);") 28 | void insert(int id, String name); 29 | 30 | @SQL("select name from user where id=:1") 31 | String getName(int id); 32 | 33 | @SQL("select name from user order by id asc") 34 | String[] findNames(); 35 | } 36 | 37 | // init方法负责初始化dao 38 | private UserDAO dao; 39 | 40 | @Before 41 | public void init() { 42 | DataSource dataSource = DataSources.createUniqueDataSource(); 43 | JadeFactory factory = new JadeFactory(dataSource); 44 | dao = factory.create(UserDAO.class); 45 | dao.createTable(); 46 | dao.insert(1, "zhiliang1"); 47 | dao.insert(2, "zhiliang2"); 48 | } 49 | 50 | @Test 51 | public void testGetName() { 52 | Assert.assertEquals("zhiliang1", dao.getName(1)); 53 | } 54 | 55 | @Test 56 | public void testFindNames() { 57 | String[] names = dao.findNames(); 58 | Assert.assertEquals(2, names.length); 59 | Assert.assertEquals("zhiliang1", names[0]); 60 | Assert.assertEquals("zhiliang2", names[1]); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/view/DyContentTypeViewResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.view; 17 | 18 | import java.util.Locale; 19 | 20 | import org.springframework.web.servlet.View; 21 | import org.springframework.web.servlet.ViewResolver; 22 | import org.springframework.web.servlet.view.AbstractView; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public class DyContentTypeViewResolver implements ViewResolver { 30 | 31 | private ViewResolver viewResolver; 32 | 33 | private String contentType; 34 | 35 | public DyContentTypeViewResolver(ViewResolver viewResolver, String contentType) { 36 | this.viewResolver = viewResolver; 37 | this.contentType = contentType; 38 | } 39 | 40 | @Override 41 | public View resolveViewName(String viewName, Locale locale) throws Exception { 42 | View view = viewResolver.resolveViewName(viewName, locale); 43 | if (contentType != null && view instanceof AbstractView) { 44 | ((AbstractView) view).setContentType(contentType); 45 | } 46 | return view; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/instruction/AbstractInstruction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.instruction; 17 | 18 | import java.io.IOException; 19 | 20 | import javax.servlet.ServletException; 21 | 22 | import net.paoding.rose.util.PlaceHolderUtils; 23 | import net.paoding.rose.web.Invocation; 24 | 25 | /** 26 | * 27 | * @author 王志亮 [qieqie.wang@gmail.com] 28 | * 29 | */ 30 | public abstract class AbstractInstruction implements Instruction { 31 | 32 | protected Instruction preInstruction; 33 | 34 | protected String resolvePlaceHolder(String text, Invocation inv) { 35 | return PlaceHolderUtils.resolve(text, inv); 36 | } 37 | 38 | @Override 39 | public final void render(Invocation inv) throws IOException, ServletException, Exception { 40 | preRender(inv); 41 | if (preInstruction != null) { 42 | preInstruction.render(inv); 43 | } 44 | doRender(inv); 45 | } 46 | 47 | protected void preRender(Invocation inv) throws IOException, ServletException, Exception { 48 | } 49 | 50 | protected abstract void doRender(Invocation inv) throws IOException, ServletException, 51 | Exception; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/rowmapper/ArrayRowMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.rowmapper; 17 | 18 | import java.lang.reflect.Array; 19 | import java.sql.ResultSet; 20 | import java.sql.SQLException; 21 | 22 | import org.springframework.jdbc.core.RowMapper; 23 | import org.springframework.jdbc.support.JdbcUtils; 24 | 25 | /** 26 | * 将SQL结果集的一行映射为一个数组 27 | * 28 | * @author 王志亮 [qieqie.wang@gmail.com] 29 | * @author 廖涵 [in355hz@gmail.com] 30 | */ 31 | public class ArrayRowMapper implements RowMapper { 32 | 33 | private Class componentType; 34 | 35 | public ArrayRowMapper(Class returnType) { 36 | this.componentType = returnType.getComponentType(); 37 | } 38 | 39 | @Override 40 | public Object mapRow(ResultSet rs, int rowNum) throws SQLException { 41 | int columnSize = rs.getMetaData().getColumnCount(); 42 | Object array = Array.newInstance(componentType, columnSize); 43 | for (int i = 0; i < columnSize; i++) { 44 | Object value = JdbcUtils.getResultSetValue(rs, (i + 1), componentType); 45 | Array.set(array, i, value); 46 | } 47 | return array; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/WindowListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal; 17 | 18 | /** 19 | * 窗口的状态侦听器 20 | * 21 | * @author 王志亮 [qieqie.wang@gmail.com] 22 | * 23 | */ 24 | public interface WindowListener { 25 | 26 | /** 27 | * 当添加一个窗口到aggregate时被调用 28 | * 29 | * @param window 30 | */ 31 | public void onWindowAdded(Window window); 32 | 33 | /** 34 | * 当窗口开始被容器处理时被调用 35 | * 36 | * @param window 37 | */ 38 | public void onWindowStarted(Window window); 39 | 40 | /** 41 | * 当窗口被取消时候调用 42 | * 43 | * @param window 44 | */ 45 | public void onWindowCanceled(Window window); 46 | 47 | /** 48 | * 当窗口被成功执行后被调用(即:没有抛出异常时候) 49 | * 50 | * @param window 51 | */ 52 | public void onWindowDone(Window window); 53 | 54 | /** 55 | * 当窗口执行出现异常时被调用(异常对象可通过window.getThrowable()方法获取) 56 | * 57 | * @param window 58 | */ 59 | public void onWindowError(Window window); 60 | 61 | /** 62 | * 当aggregate等待窗口超时时被调用 63 | * 64 | * @param window 65 | */ 66 | public void onWindowTimeout(Window window); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /paoding-rose-load/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | net.paoding 6 | paoding-rose-load 7 | jar 8 | 2.0-SNAPSHOT 9 | paoding-rose-load 10 | 11 | 12 | net.paoding 13 | paoding-rose-parent 14 | 2.0-SNAPSHOT 15 | ../pom.xml 16 | 17 | 18 | 19 | 20 | 21 | 王志亮 22 | qieqie.wang@gmail.com 23 | 24 | 25 | 廖涵 26 | in355hz@gmail.com 27 | 28 | 29 | 30 | 31 | 32 | javax.servlet 33 | javax.servlet-api 34 | 35 | 36 | org.springframework 37 | spring-context 38 | 39 | 40 | org.springframework 41 | spring-web 42 | 43 | 44 | commons-lang 45 | commons-lang 46 | 47 | 48 | commons-collections 49 | commons-collections 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/thread/Engine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $ID$ 3 | */ 4 | /* 5 | * Copyright 2007-2009 the original author or authors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package net.paoding.rose.web.impl.thread; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | 23 | import net.paoding.rose.web.impl.mapping.Mapping; 24 | 25 | /** 26 | * 一个 {@link Engine} 封装了对某种符合要求的请求的某种处理。Rose 对一次WEB请求的处理最终落实为对一些列的 27 | * {@link Engine}的有序调用,每个 {@link Engine} 负责处理其中需要处理的逻辑,共同协作完成 Rose 的职责。 28 | *

29 | * 在一个Rose应用中,存在着“很多的、不同的” {@link Engine}实例,这些实例根据映射关系组成在一个树状的结构中。 30 | * 31 | * @see Rose 32 | * @see Mapping 33 | * @author 王志亮 [qieqie.wang@gmail.com] 34 | */ 35 | public interface Engine { 36 | 37 | /** 38 | * 除了地址匹配之外,哪些因素可能拒绝或同意由这个engine来处理? 39 | * 所有匹配地址的engine都会被询问,返回值0或负数表示不接受,大于等于1的表示可以,值越大越优先 40 | * 41 | * @param request 42 | * @return 43 | */ 44 | public int isAccepted(HttpServletRequest request); 45 | 46 | /** 47 | * 处理web请求 48 | * 49 | * @param rose 50 | * @param mr 51 | * @throws Throwable 52 | */ 53 | public Object execute(Rose rose) throws Throwable; 54 | 55 | /** 56 | * 销毁该引擎,在系统关闭或其他情况时 57 | * 58 | * @throws Throwable 59 | */ 60 | public void destroy(); 61 | } 62 | -------------------------------------------------------------------------------- /paoding-rose-jade/src/main/java/net/paoding/rose/jade/statement/DynamicReturnGeneratedKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License i distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.jade.statement; 17 | 18 | import org.springframework.dao.InvalidDataAccessApiUsageException; 19 | 20 | import net.paoding.rose.jade.annotation.ReturnGeneratedKeys; 21 | 22 | /** 23 | * 24 | * @see ReturnGeneratedKeys 25 | */ 26 | public abstract class DynamicReturnGeneratedKeys { 27 | 28 | /** 29 | * 是否要启动 return generated keys机制 30 | * @param runtime 31 | */ 32 | public abstract boolean shouldReturnGerneratedKeys(StatementRuntime runtime); 33 | 34 | /** 35 | * 检查DAO返回的类型是否合格 36 | * 37 | * @param returnType DAO方法的返回类型(如果方法声明的返回类型是泛型,框架会根据上下文信息解析为运行时实际应该返回的真正类型) 38 | * 39 | * @throws InvalidDataAccessApiUsageException DAO方法的返回类型不合格 40 | */ 41 | public void checkMethodReturnType(Class returnType, StatementMetaData metaData) { 42 | if (returnType != void.class && !Number.class.isAssignableFrom(returnType)) { 43 | throw new InvalidDataAccessApiUsageException( 44 | "error return type, only support int/long/double/float/void type for method with @ReturnGeneratedKeys:" 45 | + metaData.getMethod()); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/impl/ThreadPoolExcutorServiceFactoryBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal.impl; 17 | 18 | import java.util.concurrent.ExecutorService; 19 | import java.util.concurrent.ThreadPoolExecutor; 20 | 21 | import org.springframework.beans.factory.FactoryBean; 22 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 23 | 24 | /** 25 | * 此类用于配置在spring文件中,使获取Spring的 {@link ThreadPoolTaskExecutor} 的内部 {@link ExecutorService}对象 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public class ThreadPoolExcutorServiceFactoryBean implements FactoryBean { 30 | 31 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; 32 | 33 | public void setThreadPoolTaskExecutor(ThreadPoolTaskExecutor threadPoolTaskExecutor) { 34 | this.threadPoolTaskExecutor = threadPoolTaskExecutor; 35 | } 36 | 37 | @Override 38 | public Object getObject() throws Exception { 39 | return threadPoolTaskExecutor.getThreadPoolExecutor(); 40 | } 41 | 42 | @Override 43 | @SuppressWarnings("unchecked") 44 | public Class getObjectType() { 45 | return ThreadPoolExecutor.class; 46 | } 47 | 48 | @Override 49 | public boolean isSingleton() { 50 | return true; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/annotation/Param.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import net.paoding.rose.web.var.Model; 25 | 26 | /** 27 | * 将{@link Param}标注在控制器方法的参数上,可以获得在{@link Path} 28 | * 中的占位符的参数,或者request的请求参数。 29 | *

30 | * 如果{@link Param}标注的是bean,则表示这个bean放到model中应该使用配置的名称。 31 | *

32 | * 可以使用{@link Param}标注Map, List, Set, 33 | * String/int/Integer[]等参数,并从配置的名称中获取request参数绑定进来 34 | *

35 | * Map的规则是请求参数以名为"param_value:map_key"的形式出现,并和该参数的值作为map的一个映射。
36 | * 数组的规则是请求参数以名为param_value的所有request参数。如果只有一个参数,则将该参数按照逗号做切割分成数组
37 | * Map,List,Set均只支持String类型的;数组可以支持String类型以及一般的int/Integer等类型的。 38 | * 39 | * @author 王志亮 [qieqie.wang@gmail.com] 40 | * 41 | */ 42 | @Target( { ElementType.PARAMETER }) 43 | @Retention(RetentionPolicy.RUNTIME) 44 | @Documented 45 | public @interface Param { 46 | 47 | /** 48 | * 声明参数的名字,框架将把这个名字参数的值设置到所在的参数上; 49 | *

50 | * 如果该参数是一个bean,则将该bean绑定到 {@link Model}中的这个名字中 51 | * 52 | * @return 53 | */ 54 | String value(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/impl/PipeResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal.impl; 17 | 18 | import net.paoding.rose.web.Invocation; 19 | import net.paoding.rose.web.paramresolver.ParamMetaData; 20 | import net.paoding.rose.web.paramresolver.ParamResolver; 21 | import net.paoding.rose.web.portal.Pipe; 22 | import net.paoding.rose.web.portal.PortalFactory; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public class PipeResolver implements ParamResolver { 30 | 31 | private PortalFactory portalFactory; 32 | 33 | public void setPortalFactory(PortalFactory portalFactory) { 34 | this.portalFactory = portalFactory; 35 | } 36 | 37 | public PortalFactory getPortalFactory() { 38 | return portalFactory; 39 | } 40 | 41 | @Override 42 | public boolean supports(ParamMetaData paramMetaData) { 43 | if (portalFactory == null) { 44 | return false; 45 | } 46 | return paramMetaData.getParamType() == Pipe.class; 47 | } 48 | 49 | @Override 50 | public Pipe resolve(Invocation inv, ParamMetaData paramMetaData) throws Exception { 51 | return portalFactory.createPipe(inv, true); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /paoding-rose-pipe/src/main/java/net/paoding/rose/web/portal/impl/PortalResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.portal.impl; 17 | 18 | import net.paoding.rose.web.Invocation; 19 | import net.paoding.rose.web.paramresolver.ParamMetaData; 20 | import net.paoding.rose.web.paramresolver.ParamResolver; 21 | import net.paoding.rose.web.portal.Portal; 22 | import net.paoding.rose.web.portal.PortalFactory; 23 | 24 | /** 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public class PortalResolver implements ParamResolver { 30 | 31 | private PortalFactory portalFactory; 32 | 33 | public void setPortalFactory(PortalFactory portalFactory) { 34 | this.portalFactory = portalFactory; 35 | } 36 | 37 | public PortalFactory getPortalFactory() { 38 | return portalFactory; 39 | } 40 | 41 | @Override 42 | public boolean supports(ParamMetaData paramMetaData) { 43 | if (portalFactory == null) { 44 | return false; 45 | } 46 | return paramMetaData.getParamType() == Portal.class; 47 | } 48 | 49 | @Override 50 | public Portal resolve(Invocation inv, ParamMetaData paramMetaData) throws Exception { 51 | return portalFactory.createPortal(inv); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/thread/BeforeActionInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.thread; 17 | 18 | import java.lang.reflect.Method; 19 | 20 | import net.paoding.rose.web.BeforeAction; 21 | import net.paoding.rose.web.ControllerInterceptorAdapter; 22 | import net.paoding.rose.web.Invocation; 23 | 24 | /** 25 | * @author 王志亮 [qieqie.wang@gmail.com] 26 | */ 27 | public class BeforeActionInterceptor extends ControllerInterceptorAdapter { 28 | 29 | public BeforeActionInterceptor() { 30 | setPriority(Integer.MIN_VALUE); 31 | } 32 | 33 | @Override 34 | protected boolean isForAction(Method actionMethod, Class controllerClazz) { 35 | for (Class clazz :actionMethod.getParameterTypes()) { 36 | if (BeforeAction.class.isAssignableFrom(clazz)) { 37 | return true; 38 | } 39 | } 40 | return false; 41 | } 42 | 43 | @Override 44 | public Object before(Invocation inv) throws Exception { 45 | for (Object object : inv.getMethodParameters()) { 46 | if (object instanceof BeforeAction) { 47 | ((BeforeAction) object).doBeforeAction(inv); 48 | } 49 | } 50 | return true; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /paoding-rose-load/src/main/java/net/paoding/rose/load/vfs/FileNameImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2010 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.load.vfs; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * 22 | * @author 王志亮 [qieqie.wang@gmail.com] 23 | * 24 | */ 25 | public class FileNameImpl implements FileName { 26 | 27 | private final FileObject fileObject; 28 | 29 | private final String baseName; 30 | 31 | public FileNameImpl(FileObject fileObject, String baseName) { 32 | this.fileObject = fileObject; 33 | this.baseName = baseName; 34 | } 35 | 36 | @Override 37 | public String getBaseName() { 38 | return baseName; 39 | } 40 | 41 | @Override 42 | public FileObject getFileObject() { 43 | return fileObject; 44 | } 45 | 46 | @Override 47 | public String getRelativeName(FileName subFileName) throws IOException { 48 | String basePath = fileObject.getURL().getPath(); 49 | String subPath = subFileName.getFileObject().getURL().getPath(); 50 | if (!subPath.startsWith(basePath)) { 51 | throw new IllegalArgumentException("basePath='" + basePath + "'; subPath='" + subPath 52 | + "'"); 53 | } 54 | return subPath.substring(basePath.length()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/ControllerInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web; 17 | 18 | import net.paoding.rose.web.advancedinterceptor.Ordered; 19 | import net.paoding.rose.web.annotation.Intercepted; 20 | 21 | /** 22 | * 实现{@link ControllerInterceptor}用于拦截整个MVC流程。(通常则是实现 23 | * {@link ControllerInterceptorAdapter})。 24 | *

25 | * 如果你要实现的拦截器是模块特有的,可以直接在控制器所在package中实现它,并以Interceptor作为命名的结尾, 26 | * Rose会自动把它load到module中,使得控制器能够被该拦截器拦截。
27 | * 同时因为某种原因,想暂时禁止掉这个module中的某个拦截器又不想删除它或者去除implements 28 | * ControllerInterceptor, 此时把类标注成@Ignored即可 29 | *

30 | * 如果拦截器的实现是公有的(特别是已经打包成jar的拦截器)或者其他package的拦截器,则需要先把它配置在/WEB-INF/ 31 | * *.xml或者某个jar包下applicationContext*.xml中,这样则能够拦截到所有模块的Controller。
32 | * 如果不想让拦截器拦截到某些控制器,配置控制器@Intercepted的allow和deny属性, 或者通过使拦截器实现{ 33 | * {@link #getAnnotationClasses()} 34 | * 明确要求只有标注了指定的该annotation的控制器或方法才可以被该拦截器拦截到 35 | *

36 | * 37 | * @author 王志亮 [qieqie.wang@gmail.com] 38 | * 39 | * @see Intercepted 40 | * @see Ordered 41 | * @see ControllerInterceptorAdapter 42 | */ 43 | public interface ControllerInterceptor { 44 | 45 | /** 46 | * 47 | * @param inv 48 | * @param chain 49 | * @return 50 | * @throws Exception 51 | */ 52 | Object roundInvocation(Invocation inv, InvocationChain chain) throws Exception; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/thread/AfterActionInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.thread; 17 | 18 | import java.lang.reflect.Method; 19 | 20 | import net.paoding.rose.web.AfterAction; 21 | import net.paoding.rose.web.ControllerInterceptorAdapter; 22 | import net.paoding.rose.web.Invocation; 23 | 24 | /** 25 | * @author 王志亮 [qieqie.wang@gmail.com] 26 | */ 27 | public class AfterActionInterceptor extends ControllerInterceptorAdapter { 28 | 29 | public AfterActionInterceptor() { 30 | setPriority(Integer.MIN_VALUE); 31 | } 32 | 33 | @Override 34 | protected boolean isForAction(Method actionMethod, Class controllerClazz) { 35 | for (Class clazz :actionMethod.getParameterTypes()) { 36 | if (AfterAction.class.isAssignableFrom(clazz)) { 37 | return true; 38 | } 39 | } 40 | return false; 41 | } 42 | 43 | @Override 44 | public Object after(Invocation inv, Object instruction) throws Exception { 45 | for (Object object : inv.getMethodParameters()) { 46 | if (object instanceof AfterAction) { 47 | instruction = ((AfterAction) object).doAfterAction(inv, instruction); 48 | } 49 | } 50 | return instruction; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/thread/BeforeInterceptorsInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.thread; 17 | 18 | import java.lang.reflect.Method; 19 | 20 | import net.paoding.rose.web.BeforeInterceptors; 21 | import net.paoding.rose.web.ControllerInterceptorAdapter; 22 | import net.paoding.rose.web.Invocation; 23 | 24 | /** 25 | * @author 王志亮 [qieqie.wang@gmail.com] 26 | */ 27 | public class BeforeInterceptorsInterceptor extends ControllerInterceptorAdapter { 28 | 29 | public BeforeInterceptorsInterceptor() { 30 | setPriority(Integer.MAX_VALUE); 31 | } 32 | 33 | @Override 34 | protected boolean isForAction(Method actionMethod, Class controllerClazz) { 35 | for (Class clazz :actionMethod.getParameterTypes()) { 36 | if (BeforeInterceptors.class.isAssignableFrom(clazz)) { 37 | return true; 38 | } 39 | } 40 | return false; 41 | } 42 | 43 | @Override 44 | public Object before(Invocation inv) throws Exception { 45 | for (Object object : inv.getMethodParameters()) { 46 | if (object instanceof BeforeInterceptors) { 47 | ((BeforeInterceptors) object).doBeforeInterceptors(inv); 48 | } 49 | } 50 | return true; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/module/MethodRef.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.module; 17 | 18 | import java.lang.reflect.Method; 19 | import java.util.HashMap; 20 | import java.util.HashSet; 21 | import java.util.Map; 22 | import java.util.Set; 23 | 24 | import net.paoding.rose.web.annotation.ReqMethod; 25 | 26 | /** 27 | * 28 | * @author 王志亮 [qieqie.wang@gmail.com] 29 | * 30 | */ 31 | public class MethodRef { 32 | 33 | private Method method; 34 | 35 | private Map> mappings = new HashMap>(); 36 | 37 | public Method getMethod() { 38 | return method; 39 | } 40 | 41 | public void setMethod(Method method) { 42 | this.method = method; 43 | } 44 | 45 | public void addMapping(ReqMethod reqMethod, String[] mappingPaths) { 46 | for (String mappingPath : mappingPaths) { 47 | Set mapping = mappings.get(mappingPath); 48 | if (mapping == null) { 49 | mapping = new HashSet(); 50 | mappings.put(mappingPath, mapping); 51 | } 52 | mapping.add(reqMethod); 53 | } 54 | } 55 | 56 | public Map> getMappings() { 57 | return mappings; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/mapping/MatchResultImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.mapping; 17 | 18 | /** 19 | * 20 | * @author 王志亮 [qieqie.wang@gmail.com] 21 | * 22 | */ 23 | public class MatchResultImpl implements MatchResult { 24 | 25 | /** 结果字符串 */ 26 | private String value; 27 | 28 | private MappingNode mappingNode; 29 | 30 | /** 从结果字符串中得到的资源参数名(如果该资源使用了使用了参数化的映射地址) */ 31 | private String parameterName; 32 | 33 | /** 34 | * 创建新的匹配结果对象 35 | * 36 | * @param value 匹配结果字符串 37 | */ 38 | public MatchResultImpl(MappingNode mappingNode, String value) { 39 | this.mappingNode = mappingNode; 40 | this.value = value; 41 | } 42 | 43 | @Override 44 | public MappingNode getMappingNode() { 45 | return mappingNode; 46 | } 47 | 48 | @Override 49 | public String getValue() { 50 | return value; 51 | } 52 | 53 | public void setParameter(String name) { 54 | this.parameterName = name; 55 | } 56 | 57 | @Override 58 | public String getParameterName() { 59 | return parameterName; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return ((parameterName == null) ? getValue() : parameterName + "=" + getValue()); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /paoding-rose-web/src/main/java/net/paoding/rose/web/impl/validation/ParameterBindingResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2009 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.paoding.rose.web.impl.validation; 17 | 18 | import net.paoding.rose.web.Invocation; 19 | 20 | import org.springframework.util.Assert; 21 | import org.springframework.validation.AbstractBindingResult; 22 | 23 | /** 24 | * 控制器action方法普通参数绑定信息类, 25 | * 26 | * @author 王志亮 [qieqie.wang@gmail.com] 27 | * 28 | */ 29 | public class ParameterBindingResult extends AbstractBindingResult { 30 | 31 | public static final String OBJECT_NAME = "parameterBindingResult"; 32 | 33 | private static final long serialVersionUID = -592629554361073051L; 34 | 35 | private transient Invocation inv; 36 | 37 | /** 38 | * 39 | * @param inv 40 | */ 41 | public ParameterBindingResult(Invocation inv) { 42 | super(OBJECT_NAME); 43 | Assert.notNull(inv, "Target Invocation must not be null"); 44 | this.inv = inv; 45 | } 46 | 47 | @Override 48 | public Object getTarget() { 49 | return this.inv; 50 | } 51 | 52 | /** 53 | * 54 | * @throws IllegalStateException 在反序列化后调用 55 | */ 56 | @Override 57 | protected Object getActualFieldValue(String field) { 58 | if (inv == null) { 59 | throw new IllegalStateException(); 60 | } 61 | return inv.getParameter(field); 62 | } 63 | 64 | } 65 | --------------------------------------------------------------------------------