我正在使用spring-websocket和spring-messaging(版本4.2.2.RELEASE)通过功能齐全的代理(Apache ActiveMQ 5.10.0)在websockets上实现STOMP.
我的客户只想订阅目的地 - 也就是说他们不应该发送消息.此外,我想对客户可以订阅的目的地实施更严格的控制.在任何一种情况下(即客户端尝试发送消息或订阅无效目的地)我希望能够
请注意,我的所有目的地都转发给ActiveMQ.我认为我可以在入站通道上实现ChannelInterceptor,但是看看API我无法弄清楚如何实现我想要的.这是可能的,验证客户端请求的最佳方法是什么?我的websocket配置如下:
<websocket:message-broker
application-destination-prefix="/app">
<websocket:stomp-endpoint path="/pushchannel"/>
<websocket:stomp-broker-relay relay-host="localhost"
relay-port="61613" prefix="/topic"
heartbeat-receive-interval="300000" heartbeat-send-interval="300000" />
<websocket:client-inbound-channel>
<websocket:interceptors>
<bean class="MyClientMessageInterceptor"/>
</websocket:interceptors>
</websocket:client-inbound-channel>
</websocket:message-broker>
Run Code Online (Sandbox Code Playgroud) 我正在编写一个复合组件,用于包装输入元素,并在其下方添加一个“可选字段”名称和 h:message 元素。这是组件(在 input.xhtml 文件中):
<composite:interface/>
<composite:implementation>
<div>
#{component.children[1].setStyleClass(component.children[1].valid ? '' : 'inputError')}
<composite:insertChildren/>
</div>
<h:panelGroup styleClass="optional"
rendered="#{!component.parent.children[1].required}"
layout="block" >
#{msgs['common.optional.field']}
</h:panelGroup>
<h:message id="msgId"
for="#{component.parent.children[1].id}" errorClass="error"/>
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)
同样,该组件的预期用途是包装一个 h:input* 元素,该元素应该是它在 using 页面中的第一个和直接子元素。
在使用页面中,我会写:
<h:form id="f1">
<h:panelGrid border="0" columns="2" style="width: 80%">
<f:facet name="header">
<col width="40%" />
<col width="60%" />
</f:facet>
<h:outputLabel styleClass="sectionBody" for="i1"
value="Input 1"></h:outputLabel>
<my:input id="ii1">
<h:inputText id="i1" size="20" maxlength="20" tabindex="0"
required="true" label="Input 1">
</h:inputText>
</my:input>
<h:outputLabel styleClass="sectionBody" for="i2"
value="Input 2"></h:outputLabel>
<my:input id="ii2">
<h:inputText id="i2" size="20" maxlength="20" tabindex="0"
label="Input 2"> …Run Code Online (Sandbox Code Playgroud)