Skip to content

Commit 7126c0d

Browse files
committed
mybatis source parse
1 parent 26003c2 commit 7126c0d

390 files changed

Lines changed: 39712 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright 2009-2024 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+
* https://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 org.apache.ibatis.annotations;
17+
18+
import java.lang.annotation.Documented;
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Repeatable;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import org.apache.ibatis.type.JdbcType;
26+
import org.apache.ibatis.type.TypeHandler;
27+
import org.apache.ibatis.type.UnknownTypeHandler;
28+
29+
/**
30+
* The annotation that specify a mapping definition for the constructor argument.
31+
*
32+
* @see ConstructorArgs
33+
*
34+
* @author Clinton Begin
35+
*/
36+
@Documented
37+
@Retention(RetentionPolicy.RUNTIME)
38+
@Target(ElementType.METHOD)
39+
@Repeatable(ConstructorArgs.class)
40+
public @interface Arg {
41+
42+
/**
43+
* Returns whether id column or not.
44+
*
45+
* @return {@code true} if id column; {@code false} if otherwise
46+
*/
47+
boolean id() default false;
48+
49+
/**
50+
* Return the column name(or column label) to map to this argument.
51+
*
52+
* @return the column name(or column label)
53+
*/
54+
String column() default "";
55+
56+
/**
57+
* Return the java type for this argument.
58+
*
59+
* @return the java type
60+
*/
61+
Class<?> javaType() default void.class;
62+
63+
/**
64+
* Return the jdbc type for column that map to this argument.
65+
*
66+
* @return the jdbc type
67+
*/
68+
JdbcType jdbcType() default JdbcType.UNDEFINED;
69+
70+
/**
71+
* Returns the {@link TypeHandler} type for retrieving a column value from result set.
72+
*
73+
* @return the {@link TypeHandler} type
74+
*/
75+
Class<? extends TypeHandler> typeHandler() default UnknownTypeHandler.class;
76+
77+
/**
78+
* Return the statement id for retrieving a object that map to this argument.
79+
*
80+
* @return the statement id
81+
*/
82+
String select() default "";
83+
84+
/**
85+
* Returns the result map id for mapping to a object that map to this argument.
86+
*
87+
* @return the result map id
88+
*/
89+
String resultMap() default "";
90+
91+
/**
92+
* Returns the parameter name for applying this mapping.
93+
*
94+
* @return the parameter name
95+
*
96+
* @since 3.4.3
97+
*/
98+
String name() default "";
99+
100+
/**
101+
* Returns the column prefix that use when applying {@link #resultMap()}.
102+
*
103+
* @return the column prefix
104+
*
105+
* @since 3.5.0
106+
*/
107+
String columnPrefix() default "";
108+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2009-2024 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+
* https://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 org.apache.ibatis.annotations;
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+
* The marker annotation that indicate a constructor for automatic mapping.
26+
* <p>
27+
* <b>How to use:</b>
28+
*
29+
* <pre>
30+
* public class User {
31+
*
32+
* private int id;
33+
* private String name;
34+
*
35+
* public User(int id) {
36+
* this.id = id;
37+
* }
38+
*
39+
* &#064;AutomapConstructor
40+
* public User(int id, String name) {
41+
* this.id = id;
42+
* this.name = name;
43+
* }
44+
* // ...
45+
* }
46+
* </pre>
47+
*
48+
* @author Tim Chen
49+
*
50+
* @since 3.4.3
51+
*/
52+
@Documented
53+
@Retention(RetentionPolicy.RUNTIME)
54+
@Target({ ElementType.CONSTRUCTOR })
55+
public @interface AutomapConstructor {
56+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright 2009-2024 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+
* https://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 org.apache.ibatis.annotations;
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 org.apache.ibatis.cache.Cache;
25+
import org.apache.ibatis.cache.decorators.LruCache;
26+
import org.apache.ibatis.cache.impl.PerpetualCache;
27+
28+
// @formatter:off
29+
/**
30+
* The annotation that specify to use cache on namespace(e.g. mapper interface).
31+
* <p>
32+
* <b>How to use:</b>
33+
*
34+
* <pre>
35+
* &#064;CacheNamespace(implementation = CustomCache.class, properties = {
36+
* &#064;Property(name = "host", value = "${mybatis.cache.host}"),
37+
* &#064;Property(name = "port", value = "${mybatis.cache.port}"),
38+
* &#064;Property(name = "name", value = "usersCache")
39+
* })
40+
* public interface UserMapper {
41+
* // ...
42+
* }
43+
* </pre>
44+
*
45+
* @author Clinton Begin
46+
* @author Kazuki Shimizu
47+
*/
48+
// @formatter:on
49+
@Documented
50+
@Retention(RetentionPolicy.RUNTIME)
51+
@Target(ElementType.TYPE)
52+
public @interface CacheNamespace {
53+
54+
/**
55+
* Returns the cache implementation type to use.
56+
*
57+
* @return the cache implementation type
58+
*/
59+
Class<? extends Cache> implementation() default PerpetualCache.class;
60+
61+
/**
62+
* Returns the cache evicting implementation type to use.
63+
*
64+
* @return the cache evicting implementation type
65+
*/
66+
Class<? extends Cache> eviction() default LruCache.class;
67+
68+
/**
69+
* Returns the flush interval.
70+
*
71+
* @return the flush interval
72+
*/
73+
long flushInterval() default 0;
74+
75+
/**
76+
* Return the cache size.
77+
*
78+
* @return the cache size
79+
*/
80+
int size() default 1024;
81+
82+
/**
83+
* Returns whether use read/write cache.
84+
*
85+
* @return {@code true} if use read/write cache; {@code false} if otherwise
86+
*/
87+
boolean readWrite() default true;
88+
89+
/**
90+
* Returns whether block the cache at request time or not.
91+
*
92+
* @return {@code true} if block the cache; {@code false} if otherwise
93+
*/
94+
boolean blocking() default false;
95+
96+
/**
97+
* Returns property values for a implementation object.
98+
*
99+
* @return property values
100+
*
101+
* @since 3.4.2
102+
*/
103+
Property[] properties() default {};
104+
105+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2009-2024 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+
* https://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 org.apache.ibatis.annotations;
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+
* The annotation that reference a cache.
26+
* <p>
27+
* If you use this annotation, should be specified either {@link #value()} or {@link #name()} attribute.
28+
* <p>
29+
* <b>How to use:</b>
30+
*
31+
* <pre>
32+
* &#064;CacheNamespaceRef(UserMapper.class)
33+
* public interface AdminUserMapper {
34+
* // ...
35+
* }
36+
* </pre>
37+
*
38+
* @author Clinton Begin
39+
* @author Kazuki Shimizu
40+
*/
41+
@Documented
42+
@Retention(RetentionPolicy.RUNTIME)
43+
@Target(ElementType.TYPE)
44+
public @interface CacheNamespaceRef {
45+
46+
/**
47+
* Returns the namespace type to reference a cache (the namespace name become a FQCN of specified type).
48+
*
49+
* @return the namespace type to reference a cache
50+
*/
51+
Class<?> value() default void.class;
52+
53+
/**
54+
* Returns the namespace name to reference a cache.
55+
*
56+
* @return the namespace name
57+
*
58+
* @since 3.4.2
59+
*/
60+
String name() default "";
61+
}

0 commit comments

Comments
 (0)