├── 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 |
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
12 | * @SQL("....where name like :1") 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
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
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 | * 如果原来是这样的
17 | * 现在改为:
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 "@
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
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给另外的控制器方法解析.
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
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开始)
27 | * 如果一个类A标注了{@link AsSuperController},但是他的一个子类B没有标注
28 | * {@link AsSuperController} ,如果这个子类的子类C是一个控制器,刚才标注了
29 | * {@link AsSuperController}的类A的方法仍旧不能作为action方法暴露出来。
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
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
27 | * Get参数:
31 | * example: UserController下有一个方法xyz
27 | * Put参数:
31 | * example: UserController下有一个方法xyz
27 | * Head参数:
31 | * example: UserController下有一个方法xyz
27 | * Post参数:
31 | * example: UserController下有一个方法xyz
27 | * Trace参数:
31 | * example: UserController下有一个方法xyz
27 | * Delete参数:
31 | * example: UserController下有一个方法xyz
27 | * Options参数:
31 | * example: UserController下有一个方法xyz
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
28 | *
29 | *
30 | *
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 | *
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的一个映射。
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中,使得控制器能够被该拦截器拦截。
30 | * 如果拦截器的实现是公有的(特别是已经打包成jar的拦截器)或者其他package的拦截器,则需要先把它配置在/WEB-INF/
31 | * *.xml或者某个jar包下applicationContext*.xml中,这样则能够拦截到所有模块的Controller。
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
13 | * public List
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 |
13 | * @ShardParam(name = "page_id", value=":2")
14 | * @SQL("....where name like :1")
15 | * public void find(String likeValue, String pageId);
16 | *
18 | * @SQL("....where name like :1")
19 | * public void find(String likeValue, @ShardBy String pageId);
20 | *
28 | * 2)开发者想要有更自由的解析以及时间点控制(对于后者可以,开发者可以在方法中声明 MultipartResolver 获取到解析器)
29 | *
41 | * 如果DAO方法中的参数设置了@SQLParam(name)
42 | * 注解,您还可以从parameters.get(name)取得该参数。
43 | *
44 | * @return
45 | */
46 | public Object execute(Map
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 | *
29 | * 如果返回类型是String[]或String的,RowMapper用来将结果集的每一行转化为一个字符串对象。
30 | * 。。。
31 | *
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的GET请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的GET请求。
30 | *
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 | *
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的PUT请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的PUT请求。
30 | *
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 | *
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的HEAD请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的HEAD请求。
30 | *
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 | *
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的POST请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的POST请求。
30 | *
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 | *
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的TRACE请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的TRACE请求。
30 | *
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 | *
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的DELETE请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的DELETE请求。
30 | *
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 | *
28 | * 没有没有设置值,表示所注解的方法用于处理对控制器资源的OPTIONS请求;
29 | * 如果设置值(可多个),表示所注解的方法用于处理所设定地址资源的OPTIONS请求。
30 | *
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
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 | @SQL("SELECT id, account, name FROM user WHERE id=:userId")
31 | *
33 | *
32 | * public User getUser(@SQLParam("userId") String id);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 |
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 | *
27 | * 同时因为某种原因,想暂时禁止掉这个module中的某个拦截器又不想删除它或者去除implements
28 | * ControllerInterceptor, 此时把类标注成@Ignored即可
29 | *
32 | * 如果不想让拦截器拦截到某些控制器,配置控制器@Intercepted的allow和deny属性, 或者通过使拦截器实现{
33 | * {@link #getAnnotationClasses()}
34 | * 明确要求只有标注了指定的该annotation的控制器或方法才可以被该拦截器拦截到
35 | *