本文整理汇总了Java中org.glassfish.tyrus.core.TyrusWebSocketEngine类的典型用法代码示例。如果您正苦于以下问题:Java TyrusWebSocketEngine类的具体用法?Java TyrusWebSocketEngine怎么用?Java TyrusWebSocketEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TyrusWebSocketEngine类属于org.glassfish.tyrus.core包,在下文中一共展示了TyrusWebSocketEngine类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createdEndpoint
import org.glassfish.tyrus.core.TyrusWebSocketEngine; //导入依赖的package包/类
@Override
public Object createdEndpoint(ServerEndpointRegistration registration, ComponentProviderService provider,
WebSocketContainer container, TyrusWebSocketEngine engine) throws DeploymentException {
DirectFieldAccessor accessor = new DirectFieldAccessor(engine);
Object sessionListener = accessor.getPropertyValue("sessionListener");
Object clusterContext = accessor.getPropertyValue("clusterContext");
try {
if (constructorWithBooleanArgument) {
// Tyrus 1.11+
return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
"/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE);
}
else {
return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
"/", registration.getConfigurator(), sessionListener, clusterContext, null);
}
}
catch (Exception ex) {
throw new HandshakeFailureException("Failed to register " + registration, ex);
}
}
示例2: createTyrusEndpoint
import org.glassfish.tyrus.core.TyrusWebSocketEngine; //导入依赖的package包/类
private Object createTyrusEndpoint(Endpoint endpoint, String endpointPath, String protocol,
List<Extension> extensions, WebSocketContainer container, TyrusWebSocketEngine engine)
throws DeploymentException {
ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(endpointPath, endpoint);
endpointConfig.setSubprotocols(Collections.singletonList(protocol));
endpointConfig.setExtensions(extensions);
return getEndpointHelper().createdEndpoint(endpointConfig, this.componentProvider, container, engine);
}
示例3: unregisterTyrusEndpoint
import org.glassfish.tyrus.core.TyrusWebSocketEngine; //导入依赖的package包/类
private void unregisterTyrusEndpoint(TyrusWebSocketEngine engine, Object tyrusEndpoint) {
if (tyrusEndpoint != null) {
try {
getEndpointHelper().unregister(engine, tyrusEndpoint);
}
catch (Throwable ex) {
// ignore
}
}
}
示例4: register
import org.glassfish.tyrus.core.TyrusWebSocketEngine; //导入依赖的package包/类
@Override
public void register(TyrusWebSocketEngine engine, Object endpoint) {
try {
registerMethod.invoke(engine, endpoint);
}
catch (Exception ex) {
throw new HandshakeFailureException("Failed to register " + endpoint, ex);
}
}
示例5: unregister
import org.glassfish.tyrus.core.TyrusWebSocketEngine; //导入依赖的package包/类
@Override
public void unregister(TyrusWebSocketEngine engine, Object endpoint) {
try {
unRegisterMethod.invoke(engine, endpoint);
}
catch (Exception ex) {
throw new HandshakeFailureException("Failed to unregister " + endpoint, ex);
}
}
示例6: buildEngine
import org.glassfish.tyrus.core.TyrusWebSocketEngine; //导入依赖的package包/类
private void buildEngine() {
engine = TyrusWebSocketEngine.builder(this)
.incomingBufferSize(incomingBufferSize)
.clusterContext(clusterContext)
.applicationEventListener(applicationEventListener)
.maxSessionsPerApp(maxSessionsPerApp)
.maxSessionsPerRemoteAddr(maxSessionsPerRemoteAddr)
.parallelBroadcastEnabled(BooleanUtils.isTrue(parallelBroadcastEnabled))
.tracingType(tracingType)
.tracingThreshold(tracingThreshold)
.build();
}
示例7: upgradeInternal
import org.glassfish.tyrus.core.TyrusWebSocketEngine; //导入依赖的package包/类
@Override
public void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response,
String selectedProtocol, List<Extension> extensions, Endpoint endpoint)
throws HandshakeFailureException {
HttpServletRequest servletRequest = getHttpServletRequest(request);
HttpServletResponse servletResponse = getHttpServletResponse(response);
TyrusServerContainer serverContainer = (TyrusServerContainer) getContainer(servletRequest);
TyrusWebSocketEngine engine = (TyrusWebSocketEngine) serverContainer.getWebSocketEngine();
Object tyrusEndpoint = null;
boolean success;
try {
// Shouldn't matter for processing but must be unique
String path = "/" + random.nextLong();
tyrusEndpoint = createTyrusEndpoint(endpoint, path, selectedProtocol, extensions, serverContainer, engine);
getEndpointHelper().register(engine, tyrusEndpoint);
HttpHeaders headers = request.getHeaders();
RequestContext requestContext = createRequestContext(servletRequest, path, headers);
TyrusUpgradeResponse upgradeResponse = new TyrusUpgradeResponse();
UpgradeInfo upgradeInfo = engine.upgrade(requestContext, upgradeResponse);
success = SUCCESS.equals(upgradeInfo.getStatus());
if (success) {
if (logger.isTraceEnabled()) {
logger.trace("Successful request upgrade: " + upgradeResponse.getHeaders());
}
handleSuccess(servletRequest, servletResponse, upgradeInfo, upgradeResponse);
}
}
catch (Exception ex) {
unregisterTyrusEndpoint(engine, tyrusEndpoint);
throw new HandshakeFailureException("Error during handshake: " + request.getURI(), ex);
}
unregisterTyrusEndpoint(engine, tyrusEndpoint);
if (!success) {
throw new HandshakeFailureException("Unexpected handshake failure: " + request.getURI());
}
}
示例8: ServerInstance
import org.glassfish.tyrus.core.TyrusWebSocketEngine; //导入依赖的package包/类
ServerInstance() {
serverProperties.put( TyrusWebSocketEngine.WSADL_SUPPORT, "true" );
Runtime.getRuntime().addShutdownHook( createShutdownHookThread() );
reset();
}