Compare commits
13 Commits
2.0.0.beta
...
2.0.0.beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c37b0e8cb5 | ||
|
|
a20570a6eb | ||
|
|
5e3edb7e1d | ||
|
|
ad8f1d2da6 | ||
|
|
24b23c894f | ||
|
|
c551d5fb81 | ||
|
|
fba43894c1 | ||
|
|
22cc7e086c | ||
|
|
1791008729 | ||
|
|
90e15dd253 | ||
|
|
7db73c076c | ||
|
|
95ad6e99d9 | ||
|
|
0b2a5d0f61 |
@@ -43,7 +43,7 @@ public class BsonWriter extends Writer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected BsonWriter(byte[] bs) {
|
protected BsonWriter(byte[] bs) {
|
||||||
this.content = bs;
|
this.content = bs == null ? new byte[0] : bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BsonWriter() {
|
public BsonWriter() {
|
||||||
@@ -102,7 +102,7 @@ public class BsonWriter extends Writer {
|
|||||||
super.recycle();
|
super.recycle();
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
this.specify = null;
|
this.specify = null;
|
||||||
if (this.content.length > defaultSize) {
|
if (this.content != null && this.content.length > defaultSize) {
|
||||||
this.content = new byte[defaultSize];
|
this.content = new byte[defaultSize];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import org.redkale.convert.*;
|
|||||||
*/
|
*/
|
||||||
public class FileSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, File> {
|
public class FileSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, File> {
|
||||||
|
|
||||||
public static final PatternSimpledCoder instance = new PatternSimpledCoder();
|
public static final FileSimpledCoder instance = new FileSimpledCoder();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void convertTo(W out, File value) {
|
public void convertTo(W out, File value) {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class JsonWriter extends Writer {
|
|||||||
super.recycle();
|
super.recycle();
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
this.specify = null;
|
this.specify = null;
|
||||||
if (this.content.length > defaultSize) {
|
if (this.content != null && this.content.length > defaultSize) {
|
||||||
this.content = new char[defaultSize];
|
this.content = new char[defaultSize];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -390,7 +390,9 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
|||||||
this.header.addValue("retcode", String.valueOf(ret.getRetcode()));
|
this.header.addValue("retcode", String.valueOf(ret.getRetcode()));
|
||||||
this.header.addValue("retinfo", ret.getRetinfo());
|
this.header.addValue("retinfo", ret.getRetinfo());
|
||||||
}
|
}
|
||||||
finish(request.getJsonConvert().convertTo(getBodyBufferSupplier(), ret));
|
Convert convert = ret == null ? null : ret.convert();
|
||||||
|
if (convert == null || !(convert instanceof TextConvert)) convert = request.getJsonConvert();
|
||||||
|
finish(convert.convertTo(getBodyBufferSupplier(), ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -497,6 +499,8 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
|||||||
context.getLogger().log(Level.WARNING, "HttpServlet finish File occur, force to close channel. request = " + getRequest(), e);
|
context.getLogger().log(Level.WARNING, "HttpServlet finish File occur, force to close channel. request = " + getRequest(), e);
|
||||||
finish(500, null);
|
finish(500, null);
|
||||||
}
|
}
|
||||||
|
} else if (obj instanceof org.redkale.service.RetResult) {
|
||||||
|
finishJson((org.redkale.service.RetResult) obj);
|
||||||
} else if (obj instanceof HttpResult) {
|
} else if (obj instanceof HttpResult) {
|
||||||
HttpResult result = (HttpResult) obj;
|
HttpResult result = (HttpResult) obj;
|
||||||
if (result.getContentType() != null) setContentType(result.getContentType());
|
if (result.getContentType() != null) setContentType(result.getContentType());
|
||||||
@@ -506,7 +510,9 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
|||||||
} else if (result.getResult() instanceof CharSequence) {
|
} else if (result.getResult() instanceof CharSequence) {
|
||||||
finish(result.getResult().toString());
|
finish(result.getResult().toString());
|
||||||
} else {
|
} else {
|
||||||
finish(result.getConvert() == null ? convert : result.getConvert(), result.getResult());
|
Convert cc = result.convert();
|
||||||
|
if (cc == null || !(cc instanceof TextConvert)) cc = convert;
|
||||||
|
finish(cc, result.getResult());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasRender) {
|
if (hasRender) {
|
||||||
|
|||||||
@@ -90,12 +90,11 @@ public class HttpResult<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConvertDisabled
|
public Convert convert() {
|
||||||
public Convert getConvert() {
|
|
||||||
return convert;
|
return convert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConvert(Convert convert) {
|
public void convert(Convert convert) {
|
||||||
this.convert = convert;
|
this.convert = convert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -860,7 +860,7 @@ public final class Rest {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (defmodulename.isEmpty() || (!pound && entrys.size() <= 6)) {
|
if (defmodulename.isEmpty() || (!pound && entrys.size() <= 2)) {
|
||||||
for (MappingEntry entry : entrys) {
|
for (MappingEntry entry : entrys) {
|
||||||
String suburl = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + (defmodulename.isEmpty() ? "" : (defmodulename + "/")) + entry.name;
|
String suburl = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + (defmodulename.isEmpty() ? "" : (defmodulename + "/")) + entry.name;
|
||||||
urlpath += "," + suburl;
|
urlpath += "," + suburl;
|
||||||
|
|||||||
@@ -562,7 +562,7 @@ public abstract class WebSocketNode {
|
|||||||
protected CompletableFuture<Integer> sendOneUserMessage(final Object message, final boolean last, final Serializable userid) {
|
protected CompletableFuture<Integer> sendOneUserMessage(final Object message, final boolean last, final Serializable userid) {
|
||||||
if (message instanceof CompletableFuture) return ((CompletableFuture) message).thenApply(msg -> sendOneUserMessage(msg, last, userid));
|
if (message instanceof CompletableFuture) return ((CompletableFuture) message).thenApply(msg -> sendOneUserMessage(msg, last, userid));
|
||||||
if (logger.isLoggable(Level.FINEST)) {
|
if (logger.isLoggable(Level.FINEST)) {
|
||||||
logger.finest("websocket want send message {userid:" + userid + ", content:'" + (message instanceof WebSocketPacket ? ((WebSocketPacket) message).toSimpleString() : JsonConvert.root().convertTo(message)) + "'} from locale node to " + ((this.localEngine != null) ? "locale" : "remote") + " engine");
|
logger.finest("websocket want send message {userid:" + userid + ", content:" + (message instanceof WebSocketPacket ? ((WebSocketPacket) message).toSimpleString() : (message instanceof CharSequence ? message : JsonConvert.root().convertTo(message))) + "} from locale node to " + ((this.localEngine != null) ? "locale" : "remote") + " engine");
|
||||||
}
|
}
|
||||||
CompletableFuture<Integer> localFuture = null;
|
CompletableFuture<Integer> localFuture = null;
|
||||||
if (this.localEngine != null) localFuture = localEngine.sendLocalMessage(message, last, userid);
|
if (this.localEngine != null) localFuture = localEngine.sendLocalMessage(message, last, userid);
|
||||||
@@ -596,7 +596,7 @@ public abstract class WebSocketNode {
|
|||||||
protected CompletableFuture<Integer> sendOneAddrMessage(final InetSocketAddress sncpAddr, final Object message, final boolean last, final Serializable... userids) {
|
protected CompletableFuture<Integer> sendOneAddrMessage(final InetSocketAddress sncpAddr, final Object message, final boolean last, final Serializable... userids) {
|
||||||
if (message instanceof CompletableFuture) return ((CompletableFuture) message).thenApply(msg -> sendOneAddrMessage(sncpAddr, msg, last, userids));
|
if (message instanceof CompletableFuture) return ((CompletableFuture) message).thenApply(msg -> sendOneAddrMessage(sncpAddr, msg, last, userids));
|
||||||
if (logger.isLoggable(Level.FINEST)) {
|
if (logger.isLoggable(Level.FINEST)) {
|
||||||
logger.finest("websocket want send message {userids:" + JsonConvert.root().convertTo(userids) + ", sncpaddr:" + sncpAddr + ", content:'" + (message instanceof WebSocketPacket ? ((WebSocketPacket) message).toSimpleString() : JsonConvert.root().convertTo(message)) + "'} from locale node to " + ((this.localEngine != null) ? "locale" : "remote") + " engine");
|
logger.finest("websocket want send message {userids:" + JsonConvert.root().convertTo(userids) + ", sncpaddr:" + sncpAddr + ", content:" + (message instanceof WebSocketPacket ? ((WebSocketPacket) message).toSimpleString() : (message instanceof CharSequence ? message : JsonConvert.root().convertTo(message))) + "} from locale node to " + ((this.localEngine != null) ? "locale" : "remote") + " engine");
|
||||||
}
|
}
|
||||||
if (Objects.equals(sncpAddr, this.localSncpAddress)) {
|
if (Objects.equals(sncpAddr, this.localSncpAddress)) {
|
||||||
return this.localEngine == null ? CompletableFuture.completedFuture(RETCODE_GROUP_EMPTY) : localEngine.sendLocalMessage(message, last, userids);
|
return this.localEngine == null ? CompletableFuture.completedFuture(RETCODE_GROUP_EMPTY) : localEngine.sendLocalMessage(message, last, userids);
|
||||||
|
|||||||
@@ -349,7 +349,12 @@ public final class SncpClient {
|
|||||||
final BsonWriter writer = bsonConvert.pollBsonWriter(transport.getBufferSupplier()); // 将head写入
|
final BsonWriter writer = bsonConvert.pollBsonWriter(transport.getBufferSupplier()); // 将head写入
|
||||||
writer.writeTo(DEFAULT_HEADER);
|
writer.writeTo(DEFAULT_HEADER);
|
||||||
for (int i = 0; i < params.length; i++) { //params 可能包含: 3 个 boolean
|
for (int i = 0; i < params.length; i++) { //params 可能包含: 3 个 boolean
|
||||||
bsonConvert.convertTo(writer, CompletionHandler.class.isAssignableFrom(myparamclass[i]) ? CompletionHandler.class : myparamtypes[i], params[i]);
|
BsonConvert bcc = bsonConvert;
|
||||||
|
if (params[i] instanceof org.redkale.service.RetResult) {
|
||||||
|
org.redkale.convert.Convert cc = ((org.redkale.service.RetResult) params[i]).convert();
|
||||||
|
if (cc instanceof BsonConvert) bcc = (BsonConvert) cc;
|
||||||
|
}
|
||||||
|
bcc.convertTo(writer, CompletionHandler.class.isAssignableFrom(myparamclass[i]) ? CompletionHandler.class : myparamtypes[i], params[i]);
|
||||||
}
|
}
|
||||||
final int reqBodyLength = writer.count() - HEADER_SIZE; //body总长度
|
final int reqBodyLength = writer.count() - HEADER_SIZE; //body总长度
|
||||||
final long seqid = System.nanoTime();
|
final long seqid = System.nanoTime();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package org.redkale.service;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import org.redkale.convert.Convert;
|
||||||
import org.redkale.convert.json.*;
|
import org.redkale.convert.json.*;
|
||||||
import org.redkale.util.Utility;
|
import org.redkale.util.Utility;
|
||||||
|
|
||||||
@@ -33,6 +34,8 @@ public class RetResult<T> {
|
|||||||
|
|
||||||
protected Map<String, String> attach;
|
protected Map<String, String> attach;
|
||||||
|
|
||||||
|
protected Convert convert;
|
||||||
|
|
||||||
public RetResult() {
|
public RetResult() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +43,11 @@ public class RetResult<T> {
|
|||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RetResult(Convert convert, T result) {
|
||||||
|
this.convert = convert;
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
public RetResult(int retcode) {
|
public RetResult(int retcode) {
|
||||||
this.retcode = retcode;
|
this.retcode = retcode;
|
||||||
}
|
}
|
||||||
@@ -55,6 +63,14 @@ public class RetResult<T> {
|
|||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Convert convert() {
|
||||||
|
return convert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void convert(Convert convert) {
|
||||||
|
this.convert = convert;
|
||||||
|
}
|
||||||
|
|
||||||
public static RetResult success() {
|
public static RetResult success() {
|
||||||
return new RetResult();
|
return new RetResult();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public final class Redkale {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getDotedVersion() {
|
public static String getDotedVersion() {
|
||||||
return "2.0.0-beta4";
|
return "2.0.0-beta5";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMajorVersion() {
|
public static int getMajorVersion() {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.redkale.util;
|
package org.redkale.util;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -42,12 +43,22 @@ public final class ResourceFactory {
|
|||||||
|
|
||||||
private final List<WeakReference<ResourceFactory>> chidren = new CopyOnWriteArrayList<>();
|
private final List<WeakReference<ResourceFactory>> chidren = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
private final ConcurrentHashMap<Type, ResourceLoader> loadermap = new ConcurrentHashMap();
|
private final ConcurrentHashMap<Type, ResourceInjectLoader> injectLoaderMap = new ConcurrentHashMap();
|
||||||
|
|
||||||
|
private final ConcurrentHashMap<Type, ResourceLoader> resLoaderMap = new ConcurrentHashMap();
|
||||||
|
|
||||||
private final ConcurrentHashMap<Type, ConcurrentHashMap<String, ResourceEntry>> store = new ConcurrentHashMap();
|
private final ConcurrentHashMap<Type, ConcurrentHashMap<String, ResourceEntry>> store = new ConcurrentHashMap();
|
||||||
|
|
||||||
private ResourceFactory(ResourceFactory parent) {
|
private ResourceFactory(ResourceFactory parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
if (parent == null) {
|
||||||
|
ServiceLoader<ResourceInjectLoader> loaders = ServiceLoader.load(ResourceInjectLoader.class);
|
||||||
|
Iterator<ResourceInjectLoader> it = loaders.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ResourceInjectLoader ril = it.next();
|
||||||
|
this.injectLoaderMap.put(ril.annotationType(), ril);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -565,6 +576,7 @@ public final class ResourceFactory {
|
|||||||
try {
|
try {
|
||||||
list.add(src);
|
list.add(src);
|
||||||
Class clazz = src.getClass();
|
Class clazz = src.getClass();
|
||||||
|
final boolean diyloaderflag = !instance.injectLoaderMap.isEmpty();
|
||||||
do {
|
do {
|
||||||
if (java.lang.Enum.class.isAssignableFrom(clazz)) break;
|
if (java.lang.Enum.class.isAssignableFrom(clazz)) break;
|
||||||
final String cname = clazz.getName();
|
final String cname = clazz.getName();
|
||||||
@@ -586,6 +598,13 @@ public final class ResourceFactory {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (flag && diyloaderflag) {
|
||||||
|
instance.injectLoaderMap.values().stream().forEach(iloader -> {
|
||||||
|
Annotation ann = field.getAnnotation(iloader.annotationType());
|
||||||
|
if (ann == null) return;
|
||||||
|
iloader.load(this, src, ann, field, attachment);
|
||||||
|
});
|
||||||
|
}
|
||||||
if (ns == null) continue;
|
if (ns == null) continue;
|
||||||
final String nsname = ns.getClass().getName();
|
final String nsname = ns.getClass().getName();
|
||||||
if (ns.getClass().isPrimitive() || ns.getClass().isArray()
|
if (ns.getClass().isPrimitive() || ns.getClass().isArray()
|
||||||
@@ -685,16 +704,21 @@ public final class ResourceFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends Annotation> void register(final ResourceInjectLoader<T> loader) {
|
||||||
|
if (loader == null) return;
|
||||||
|
instance.injectLoaderMap.put(loader.annotationType(), loader);
|
||||||
|
}
|
||||||
|
|
||||||
public void register(final ResourceLoader rs, final Type... clazzs) {
|
public void register(final ResourceLoader rs, final Type... clazzs) {
|
||||||
if (clazzs == null || rs == null) return;
|
if (clazzs == null || rs == null) return;
|
||||||
for (Type clazz : clazzs) {
|
for (Type clazz : clazzs) {
|
||||||
loadermap.put(clazz, rs);
|
resLoaderMap.put(clazz, rs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceLoader findMatchLoader(Type ft, Field field) {
|
private ResourceLoader findMatchLoader(Type ft, Field field) {
|
||||||
ResourceLoader it = this.loadermap.get(ft);
|
ResourceLoader it = this.resLoaderMap.get(ft);
|
||||||
if (it == null && field != null) it = this.loadermap.get(field.getType());
|
if (it == null && field != null) it = this.resLoaderMap.get(field.getType());
|
||||||
if (it != null) return it;
|
if (it != null) return it;
|
||||||
return parent == null ? null : parent.findMatchLoader(ft, field);
|
return parent == null ? null : parent.findMatchLoader(ft, field);
|
||||||
}
|
}
|
||||||
@@ -702,7 +726,7 @@ public final class ResourceFactory {
|
|||||||
private ResourceLoader findRegxLoader(Type ft, Field field) {
|
private ResourceLoader findRegxLoader(Type ft, Field field) {
|
||||||
if (field == null) return null;
|
if (field == null) return null;
|
||||||
Class c = field.getType();
|
Class c = field.getType();
|
||||||
for (Map.Entry<Type, ResourceLoader> en : this.loadermap.entrySet()) {
|
for (Map.Entry<Type, ResourceLoader> en : this.resLoaderMap.entrySet()) {
|
||||||
Type t = en.getKey();
|
Type t = en.getKey();
|
||||||
if (t == ft) return en.getValue();
|
if (t == ft) return en.getValue();
|
||||||
if (t instanceof Class && (((Class) t)).isAssignableFrom(c)) return en.getValue();
|
if (t instanceof Class && (((Class) t)).isAssignableFrom(c)) return en.getValue();
|
||||||
|
|||||||
25
src/org/redkale/util/ResourceInjectLoader.java
Normal file
25
src/org/redkale/util/ResourceInjectLoader.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package org.redkale.util;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义注入加载器
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* 详情见: https://redkale.org
|
||||||
|
*
|
||||||
|
* @author zhangjx
|
||||||
|
* @param <T> Annotation
|
||||||
|
*/
|
||||||
|
public interface ResourceInjectLoader<T extends Annotation> {
|
||||||
|
|
||||||
|
public void load(ResourceFactory factory, Object src, T annotation, Field field, Object attachment);
|
||||||
|
|
||||||
|
public Class<T> annotationType();
|
||||||
|
}
|
||||||
67
test/org/redkale/test/util/ResourceInjectMain.java
Normal file
67
test/org/redkale/test/util/ResourceInjectMain.java
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package org.redkale.test.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
import static java.lang.annotation.ElementType.FIELD;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
import org.redkale.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author zhangjx
|
||||||
|
*/
|
||||||
|
public class ResourceInjectMain {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Throwable {
|
||||||
|
ResourceFactory factory = ResourceFactory.root();
|
||||||
|
factory.register(new CustomConfLoader());
|
||||||
|
InjectBean bean = new InjectBean();
|
||||||
|
factory.inject(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomConfLoader implements ResourceInjectLoader<CustomConf> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(ResourceFactory factory, Object src, CustomConf annotation, Field field, Object attachment) {
|
||||||
|
try {
|
||||||
|
field.set(src, new File(annotation.path()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println("对象是 src =" + src + ", path=" + annotation.path());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<CustomConf> annotationType() {
|
||||||
|
return CustomConf.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InjectBean {
|
||||||
|
|
||||||
|
@CustomConf(path = "conf/test.xml")
|
||||||
|
public File conf;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return JsonConvert.root().convertTo(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Documented
|
||||||
|
@Target({FIELD})
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
public static @interface CustomConf {
|
||||||
|
|
||||||
|
String path();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user