Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
开源群组
iotucy
Iot
Commits
498723ab
Commit
498723ab
authored
4 years ago
by
汪清城
Browse files
Options
Download
Email Patches
Plain Diff
1. 修改客户端请求的处理方式
parent
58e04c15
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
11 deletions
+88
-11
iot-server/src/main/java/com/iteaj/network/IotServeBootstrap.java
...er/src/main/java/com/iteaj/network/IotServeBootstrap.java
+1
-1
iot-server/src/main/java/com/iteaj/network/client/handle/ClientHandle.java
...in/java/com/iteaj/network/client/handle/ClientHandle.java
+23
-0
iot-server/src/main/java/com/iteaj/network/client/handle/ClientHandleBeanPostProcessor.java
.../network/client/handle/ClientHandleBeanPostProcessor.java
+45
-0
iot-server/src/main/java/com/iteaj/network/client/handle/IotMapping.java
...main/java/com/iteaj/network/client/handle/IotMapping.java
+19
-0
iot-server/src/main/java/com/iteaj/network/client/handle/Mapper.java
...src/main/java/com/iteaj/network/client/handle/Mapper.java
+0
-10
No files found.
iot-server/src/main/java/com/iteaj/network/IotServeBootstrap.java
View file @
498723ab
...
...
@@ -240,7 +240,7 @@ public class IotServeBootstrap implements InitializingBean,DisposableBean
}
@Bean
({
"deviceManager"
,
"devicePipelineManager"
})
@ConditionalOnMissingBean
(
name
=
"devicePipelineManager"
)
@ConditionalOnMissingBean
(
name
=
{
"devicePipelineManager"
,
"deviceManager"
}
)
public
DevicePipelineManager
devicePipelineManager
()
{
return
DevicePipelineManager
.
getInstance
();
}
...
...
This diff is collapsed.
Click to expand it.
iot-server/src/main/java/com/iteaj/network/client/handle/Handle.java
→
iot-server/src/main/java/com/iteaj/network/client/handle/
Client
Handle.java
View file @
498723ab
package
com.iteaj.network.client.handle
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* 声明目标类是一个客户端处理器
*/
@Target
(
ElementType
.
TYPE
)
public
@interface
Handle
{
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
ClientHandle
{
String
name
();
String
value
()
default
""
;
/**
* 序列化
*/
Class
<?>
deserializer
()
default
Void
.
class
;
}
This diff is collapsed.
Click to expand it.
iot-server/src/main/java/com/iteaj/network/client/handle/ClientHandleBeanPostProcessor.java
0 → 100644
View file @
498723ab
package
com.iteaj.network.client.handle
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.BeanInitializationException
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
public
class
ClientHandleBeanPostProcessor
implements
BeanPostProcessor
{
private
final
Map
<
String
,
Method
>
clientMapping
=
new
ConcurrentHashMap
();
@Override
public
Object
postProcessBeforeInitialization
(
Object
bean
,
String
beanName
)
throws
BeansException
{
final
ClientHandle
clientHandle
=
bean
.
getClass
().
getAnnotation
(
ClientHandle
.
class
);
if
(
clientHandle
!=
null
)
{
final
String
value
=
clientHandle
.
value
();
ReflectionUtils
.
doWithMethods
(
bean
.
getClass
(),
item
->
{
final
IotMapping
iotMapping
=
item
.
getAnnotation
(
IotMapping
.
class
);
String
tradeType
=
value
;
if
(
iotMapping
!=
null
||
iotMapping
.
value
()
!=
null
)
{
tradeType
+=
iotMapping
.
value
();
}
if
(
StringUtils
.
hasText
(
tradeType
))
{
final
Method
method
=
clientMapping
.
get
(
tradeType
);
if
(
method
==
null
)
{
clientMapping
.
put
(
tradeType
,
item
);
}
else
{
throw
new
BeanInitializationException
(
"错误的映射名称["
+
tradeType
+
"]"
+
", 和方法冲突["
+
method
.
getDeclaringClass
().
getName
()+
method
.
getName
()+
"]"
);
}
}
else
{
throw
new
BeanInitializationException
(
"错误的映射名称["
+
tradeType
+
"], 必须不能空"
);
}
});
}
return
bean
;
}
}
This diff is collapsed.
Click to expand it.
iot-server/src/main/java/com/iteaj/network/client/handle/IotMapping.java
0 → 100644
View file @
498723ab
package
com.iteaj.network.client.handle
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
value
=
{
ElementType
.
METHOD
,
ElementType
.
TYPE
})
public
@interface
IotMapping
{
String
value
();
/**
* 是否同步
* @return
*/
boolean
sync
()
default
false
;
}
This diff is collapsed.
Click to expand it.
iot-server/src/main/java/com/iteaj/network/client/handle/Mapper.java
deleted
100644 → 0
View file @
58e04c15
package
com.iteaj.network.client.handle
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Target
;
@Target
(
ElementType
.
METHOD
)
public
@interface
Mapper
{
// Class<>
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment