• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UpgradeResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jetty.websocket.api.UpgradeResponse的典型用法代码示例。如果您正苦于以下问题:Java UpgradeResponse类的具体用法?Java UpgradeResponse怎么用?Java UpgradeResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UpgradeResponse类属于org.eclipse.jetty.websocket.api包,在下文中一共展示了UpgradeResponse类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getPrincipalFromNativeSession

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Test
public void getPrincipalFromNativeSession() {

	TestPrincipal user = new TestPrincipal("joe");

	UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
	given(request.getUserPrincipal()).willReturn(user);

	UpgradeResponse response = Mockito.mock(UpgradeResponse.class);
	given(response.getAcceptedSubProtocol()).willReturn(null);

	Session nativeSession = Mockito.mock(Session.class);
	given(nativeSession.getUpgradeRequest()).willReturn(request);
	given(nativeSession.getUpgradeResponse()).willReturn(response);

	JettyWebSocketSession session = new JettyWebSocketSession(attributes);
	session.initializeNativeSession(nativeSession);

	reset(nativeSession);

	assertSame(user, session.getPrincipal());
	verifyNoMoreInteractions(nativeSession);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:JettyWebSocketSessionTests.java


示例2: getPrincipalNotAvailable

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Test
public void getPrincipalNotAvailable() {

	UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
	given(request.getUserPrincipal()).willReturn(null);

	UpgradeResponse response = Mockito.mock(UpgradeResponse.class);
	given(response.getAcceptedSubProtocol()).willReturn(null);

	Session nativeSession = Mockito.mock(Session.class);
	given(nativeSession.getUpgradeRequest()).willReturn(request);
	given(nativeSession.getUpgradeResponse()).willReturn(response);

	JettyWebSocketSession session = new JettyWebSocketSession(attributes);
	session.initializeNativeSession(nativeSession);

	reset(nativeSession);

	assertNull(session.getPrincipal());
	verifyNoMoreInteractions(nativeSession);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JettyWebSocketSessionTests.java


示例3: getAcceptedProtocol

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Test
public void getAcceptedProtocol() {

	String protocol = "foo";

	UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
	given(request.getUserPrincipal()).willReturn(null);

	UpgradeResponse response = Mockito.mock(UpgradeResponse.class);
	given(response.getAcceptedSubProtocol()).willReturn(protocol);

	Session nativeSession = Mockito.mock(Session.class);
	given(nativeSession.getUpgradeRequest()).willReturn(request);
	given(nativeSession.getUpgradeResponse()).willReturn(response);

	JettyWebSocketSession session = new JettyWebSocketSession(attributes);
	session.initializeNativeSession(nativeSession);

	reset(nativeSession);

	assertSame(protocol, session.getAcceptedProtocol());
	verifyNoMoreInteractions(nativeSession);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:JettyWebSocketSessionTests.java


示例4: createWebSocket

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Override
public Object createWebSocket(UpgradeRequest request, UpgradeResponse response) {

    // Validate and use "guacamole" subprotocol
    for (String subprotocol : request.getSubProtocols()) {

        if ("guacamole".equals(subprotocol)) {
            response.setAcceptedSubProtocol(subprotocol);
            return new RestrictedGuacamoleWebSocketTunnelListener(tunnelRequestService);
        }

    }

    // Invalid protocol
    return null;

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:18,代码来源:RestrictedGuacamoleWebSocketCreator.java


示例5: setup

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Before
public void setup() {
	this.session = mock(Session.class);
	given(this.session.getUpgradeRequest()).willReturn(Mockito.mock(UpgradeRequest.class));
	given(this.session.getUpgradeResponse()).willReturn(Mockito.mock(UpgradeResponse.class));

	this.webSocketHandler = mock(WebSocketHandler.class);
	this.webSocketSession = new JettyWebSocketSession(null, null);
	this.adapter = new JettyWebSocketHandlerAdapter(this.webSocketHandler, this.webSocketSession);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:JettyWebSocketHandlerAdapterTests.java


示例6: configure

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Override
public void configure(WebSocketServletFactory factory) {
  // Most implementations of this method simply invoke factory.register(DispatchSocket.class);
  // however, that requires DispatchSocket to have a no-arg constructor. That does not work for
  // us because we would like all WebSockets created by this factory to have a reference to this
  // parent class. This is why we override the default WebSocketCreator for the factory.
  WebSocketCreator wrapperCreator = new WebSocketCreator() {
    @Override
    public Object createWebSocket(UpgradeRequest req, UpgradeResponse resp) {
      return new MyWebSocket();
    }
  };
  factory.setCreator(wrapperCreator);
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:15,代码来源:StreamingWebSocketServlet.java


示例7: createWebSocket

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Override
  public Object createWebSocket(UpgradeRequest req, UpgradeResponse resp) {  
  	System.out.println(".. "+req.getRequestURI().getPath());
  	String path = req.getRequestURI().getPath(),
  		   name = path.substring(path.lastIndexOf('/')+1); 

try {

	Class<?> clazz = Class.forName("jforex.jetty."+name.substring(0, 1).toUpperCase() + name.substring(1)+"Strategy");
	
	Object strat = null;
	for (Entry<Long, IStrategy> e : WebServer.pids.entrySet()){
  			if (clazz.equals(e.getValue().getClass())){
  				strat = e.getValue();
  			}
	}
	// if not started, start it now
	if (strat ==null){
		Constructor<?> ctor = clazz.getConstructor();
		strat = ctor.newInstance();
    	long pid = ClientFactory.getDefaultInstance().startStrategy((IStrategy) strat);
    	WebServer.pids.put(pid, (IStrategy) strat);
	}
	return strat;

} catch (ClassNotFoundException | SecurityException | IllegalArgumentException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e1) {
	e1.printStackTrace();
}

      return null;
  }
 
开发者ID:caub,项目名称:JForexJetty,代码行数:32,代码来源:WsServlet.java


示例8: configure

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Override
public void configure(WebSocketServletFactory factory) {
    factory.getPolicy().setIdleTimeout(10000);
    factory.setCreator(new WebSocketCreator() {
            @Override
            public Object createWebSocket(UpgradeRequest req, UpgradeResponse resp) {
                return new DrogonLoggerSocket( getWebLoggerModule( ) );
            }
        });
}
 
开发者ID:joemonti,项目名称:drogon-master,代码行数:11,代码来源:DrogonLoggerServlet.java


示例9: getUpgradeResponse

import org.eclipse.jetty.websocket.api.UpgradeResponse; //导入依赖的package包/类
@Override
public UpgradeResponse getUpgradeResponse() {
  return null;
}
 
开发者ID:facebook,项目名称:buck,代码行数:5,代码来源:MockSession.java



注:本文中的org.eclipse.jetty.websocket.api.UpgradeResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FreeMarkerConfigurationFactory类代码示例发布时间:2022-05-22
下一篇:
Java Instruction10t类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap