4545 */
4646class WebSocketNamespaceUtils {
4747
48-
4948 public static RuntimeBeanReference registerHandshakeHandler (Element element , ParserContext context , Object source ) {
5049 RuntimeBeanReference handlerRef ;
5150 Element handlerElem = DomUtils .getChildElementByTagName (element , "handshake-handler" );
@@ -62,7 +61,7 @@ public static RuntimeBeanReference registerHandshakeHandler(Element element, Par
6261 return handlerRef ;
6362 }
6463
65- public static RuntimeBeanReference registerSockJsService (Element element , String sockJsSchedulerName ,
64+ public static RuntimeBeanReference registerSockJsService (Element element , String schedulerName ,
6665 ParserContext context , Object source ) {
6766
6867 Element sockJsElement = DomUtils .getChildElementByTagName (element , "sockjs" );
@@ -79,7 +78,7 @@ public static RuntimeBeanReference registerSockJsService(Element element, String
7978 scheduler = new RuntimeBeanReference (customTaskSchedulerName );
8079 }
8180 else {
82- scheduler = registerSockJsScheduler ( sockJsSchedulerName , context , source );
81+ scheduler = registerScheduler ( schedulerName , context , source );
8382 }
8483 sockJsServiceDef .getConstructorArgumentValues ().addIndexedArgumentValue (0 , scheduler );
8584
@@ -94,7 +93,6 @@ public static RuntimeBeanReference registerSockJsService(Element element, String
9493 }
9594 else if (handshakeHandler != null ) {
9695 RuntimeBeanReference handshakeHandlerRef = new RuntimeBeanReference (handshakeHandler .getAttribute ("ref" ));
97-
9896 RootBeanDefinition transportHandler = new RootBeanDefinition (WebSocketTransportHandler .class );
9997 transportHandler .setSource (source );
10098 transportHandler .getConstructorArgumentValues ().addIndexedArgumentValue (0 , handshakeHandlerRef );
@@ -106,7 +104,9 @@ else if (handshakeHandler != null) {
106104 String allowedOriginsAttribute = element .getAttribute ("allowed-origins" );
107105 List <String > allowedOrigins = Arrays .asList (StringUtils .tokenizeToStringArray (allowedOriginsAttribute , "," ));
108106 sockJsServiceDef .getPropertyValues ().add ("allowedOrigins" , allowedOrigins );
109- interceptors .add (new OriginHandshakeInterceptor (allowedOrigins ));
107+ RootBeanDefinition originHandshakeInterceptor = new RootBeanDefinition (OriginHandshakeInterceptor .class );
108+ originHandshakeInterceptor .getPropertyValues ().add ("allowedOrigins" , allowedOrigins );
109+ interceptors .add (originHandshakeInterceptor );
110110 sockJsServiceDef .getPropertyValues ().add ("handshakeInterceptors" , interceptors );
111111
112112 String attrValue = sockJsElement .getAttribute ("name" );
@@ -156,7 +156,7 @@ else if (handshakeHandler != null) {
156156 return null ;
157157 }
158158
159- private static RuntimeBeanReference registerSockJsScheduler (String schedulerName , ParserContext context , Object source ) {
159+ public static RuntimeBeanReference registerScheduler (String schedulerName , ParserContext context , Object source ) {
160160 if (!context .getRegistry ().containsBeanDefinition (schedulerName )) {
161161 RootBeanDefinition taskSchedulerDef = new RootBeanDefinition (ThreadPoolTaskScheduler .class );
162162 taskSchedulerDef .setSource (source );
@@ -174,7 +174,7 @@ public static ManagedList<? super Object> parseBeanSubElements(Element parentEle
174174 ManagedList <? super Object > beans = new ManagedList <Object >();
175175 if (parentElement != null ) {
176176 beans .setSource (context .extractSource (parentElement ));
177- for (Element beanElement : DomUtils .getChildElementsByTagName (parentElement , new String [] { "bean" , "ref" } )) {
177+ for (Element beanElement : DomUtils .getChildElementsByTagName (parentElement , "bean" , "ref" )) {
178178 beans .add (context .getDelegate ().parsePropertySubElement (beanElement , null ));
179179 }
180180 }
0 commit comments