当前位置: 首页>>代码示例>>Java>>正文


Java UpgradeResponse类代码示例

本文整理汇总了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;未经允许,请勿转载。