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


Java Attribute.set方法代码示例

本文整理汇总了Java中io.netty.util.Attribute.set方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.set方法的具体用法?Java Attribute.set怎么用?Java Attribute.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.util.Attribute的用法示例。


在下文中一共展示了Attribute.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: channelRead0

import io.netty.util.Attribute; //导入方法依赖的package包/类
@Override
protected void channelRead0(final ChannelHandlerContext channelHandlerContext, final ResponseMessage response) throws Exception {
    // We are only interested in AUTHENTICATE responses here. Everything else can
    // get passed down the pipeline
    if (response.getStatus().getCode() == ResponseStatusCode.AUTHENTICATE) {
        final Attribute<SaslClient> saslClient = channelHandlerContext.attr(saslClientKey);
        final Attribute<Subject> subject = channelHandlerContext.attr(subjectKey);
        RequestMessage.Builder messageBuilder = RequestMessage.build(Tokens.OPS_AUTHENTICATION);
        // First time through we don't have a sasl client
        if (saslClient.get() == null) {
            subject.set(login());
            saslClient.set(saslClient(getHostName(channelHandlerContext)));
            messageBuilder.addArg(Tokens.ARGS_SASL_MECHANISM, getMechanism());
            messageBuilder.addArg(Tokens.ARGS_SASL, saslClient.get().hasInitialResponse() ?
                                                        evaluateChallenge(subject, saslClient, NULL_CHALLENGE) : null);
        } else {
            messageBuilder.addArg(Tokens.ARGS_SASL, evaluateChallenge(subject, saslClient, (byte[])response.getResult().getData()));
        }
        channelHandlerContext.writeAndFlush(messageBuilder.create());
    } else {
        channelHandlerContext.fireChannelRead(response);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:24,代码来源:Handler.java

示例2: clientToProxyRequest

import io.netty.util.Attribute; //导入方法依赖的package包/类
@Override
public HttpResponse clientToProxyRequest(HttpObject httpObject) {
    if (httpObject instanceof HttpRequest) {
        HttpRequest httpRequest = (HttpRequest) httpObject;

        if (ProxyUtils.isCONNECT(httpRequest)) {
            Attribute<String> hostname = ctx.attr(AttributeKey.<String>valueOf(HttpsAwareFiltersAdapter.HOST_ATTRIBUTE_NAME));
            String hostAndPort = httpRequest.getUri();

            // CONNECT requests contain the port, even when using the default port. a sensible default is to remove the
            // default port, since in most cases it is not explicitly specified and its presence (in a HAR file, for example)
            // would be unexpected.
            String hostNoDefaultPort = BrowserMobHttpUtil.removeMatchingPort(hostAndPort, 443);
            hostname.set(hostNoDefaultPort);
        }
    }

    return null;
}
 
开发者ID:misakuo,项目名称:Dream-Catcher,代码行数:20,代码来源:HttpsHostCaptureFilter.java

示例3: bind

import io.netty.util.Attribute; //导入方法依赖的package包/类
public static boolean bind(Channel channel, NettyClient nettyClient){
	
	Attribute<NettyClient> attribute = channel.attr(KEY_CLIENT);
	if(attribute != null){
		return false;
	}
	
	synchronized (channel) {
		attribute = channel.attr(KEY_CLIENT);
		if(attribute == null){
			return false;
		}
		attribute.set(nettyClient);
	}
	return true;
}
 
开发者ID:ctripcorp,项目名称:x-pipe,代码行数:17,代码来源:NettyClientHandler.java

示例4: initChannel

import io.netty.util.Attribute; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
  final ChannelPipeline p = ch.pipeline();

  final UUID uuid = UUID.randomUUID();

  LOG.debug("KaaTcpServerInitializer Initializing Channel {} connection from {}:{}",
          uuid, ch.remoteAddress().getAddress().toString(), ch.remoteAddress().getPort());

  Attribute<UUID> uuidAttr = ch.attr(AbstractNettyServer.UUID_KEY);
  uuidAttr.set(uuid);

  p.addLast("binaryDecoder", new ByteArrayDecoder());
  p.addLast("kaaTcpDecoder", getDecoder());
  p.addLast("binaryEncoder", new ByteArrayEncoder());
  p.addLast("kaaTcpEncoder", new KaaTcpEncoder());
  p.addLast("mainHandler", getMainHandler(uuid));
  p.addLast("kaaTcpExceptionHandler", new KaaTcpExceptionHandler());
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:20,代码来源:AbstractKaaTcpServerInitializer.java

示例5: initChannel

import io.netty.util.Attribute; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
  final ChannelPipeline p = ch.pipeline();

  final UUID uuid = UUID.randomUUID();

  LOG.info("DefaultServerInitializer Initializing Channel {} connection from {}:{}", uuid,
      ch.remoteAddress().getAddress().toString(), ch.remoteAddress().getPort());

  Attribute<UUID> uuidAttr = ch.attr(AbstractNettyServer.UUID_KEY);
  uuidAttr.set(uuid);

  p.addLast("httpDecoder", new HttpRequestDecoder());
  p.addLast("httpAggregator", new HttpObjectAggregator(getClientMaxBodySize()));
  p.addLast("httpDecoderAux", getRequestDecoder());
  p.addLast("httpEncoder", new HttpResponseEncoder());
  p.addLast("httpEncoderAux", new ResponseEncoder());
  p.addLast("handler", getMainHandler(uuid));
  p.addLast("httpExceptionHandler", new DefaultExceptionHandler());
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:21,代码来源:DefaultHttpServerInitializer.java

示例6: setActive

import io.netty.util.Attribute; //导入方法依赖的package包/类
/**
 * Marks a {@link Channel} as active.
 * 
 * @param channel
 *            the Channel to mark active
 * @throws IllegalArgumentException
 *             if the Channel was not added to this manager
 */
public void setActive(final Channel channel) {
	synchronized (channels) {
		if (!channels.contains(channel)) {
			throw new IllegalArgumentException("channel " + channel + " was not added to this manager");
		}

		final ModuleID remoteID = getRemoteID(channel);
		final boolean informListeners = (remoteID != null && getActiveChannels(remoteID).isEmpty());

		final Attribute<Boolean> activeAttribute = channel.attr(ACTIVE_KEY);
		LOGGER.debug("setting active attribute on {}", channel);
		activeAttribute.set(true);

		if (informListeners) {
			delegatingConnectionListener.connectionEstablished(remoteID);
		}
	}
}
 
开发者ID:DesignAndDeploy,项目名称:dnd,代码行数:27,代码来源:ClientChannelManager.java

示例7: bindKey

import io.netty.util.Attribute; //导入方法依赖的package包/类
@Override
public void bindKey(Channel ctx, String key) {
    Attribute<String> attr = ctx.attr(attributeKey);
    if(attr!=null){
        attr.set(key);
        //put delivery
        deliveryClient.putKey(getModelName(),getUniqueKey(ctx),key);
    }
}
 
开发者ID:1991wangliang,项目名称:sds,代码行数:10,代码来源:SocketControlImpl.java

示例8: issueDebugRequest

import io.netty.util.Attribute; //导入方法依赖的package包/类
/**
 * Issue a debug request when debugging is enabled.
 *
 * @param httpObject      Http request of client
 * @param m_ctx           Netty context
 * @param fromDebugFilter Indicator shows if the request require to be forwarded
 * @return An indicator showing if debug manager consumes the request. If true, the caller needs to stop handling request.
 */
public void issueDebugRequest(FullHttpRequest httpObject, final ChannelHandlerContext m_ctx, boolean fromDebugFilter) {
	if (debugEnabled()) {
		final FullHttpRequest request = httpObject.copy();
		if (fromDebugFilter) {
			try {
				if (ssl(request)) {
					Field field = ClientToProxyConnection.class.getDeclaredField("mitming");
					field.setAccessible(true);
					field.set(m_ctx.handler(), true);
				}
			} catch (Exception e) {
				LOGGER.error(e.getMessage());
			}
			String key = m_policyManager.generateCacheKey(request);
			FullHttpResponse cacheResponse = m_policyManager.getCacheManager().get(key);
			CacheResultVerifier verifier = new CacheResultVerifier(key, request, cacheResponse);
			Attribute<CacheResultVerifier> debugging = m_ctx.attr(DEBUG_RESULT);
			debugging.set(verifier);
		} else {
			executor.execute(new Runnable() {
				@Override
				public void run() {
					forwardDebugRequest(request);
				}
			});
		}
	}
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:37,代码来源:DebugManager.java

示例9: getOrCreateProxyRouterProcessingState

import io.netty.util.Attribute; //导入方法依赖的package包/类
protected ProxyRouterProcessingState getOrCreateProxyRouterProcessingState(ChannelHandlerContext ctx) {
    Attribute<ProxyRouterProcessingState> proxyRouterStateAttribute =
        ChannelAttributes.getProxyRouterProcessingStateForChannel(ctx);

    ProxyRouterProcessingState proxyRouterState = proxyRouterStateAttribute.get();
    if (proxyRouterState == null) {
        proxyRouterState = new ProxyRouterProcessingState();
        proxyRouterStateAttribute.set(proxyRouterState);
    }

    return proxyRouterState;
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:13,代码来源:ProxyRouterEndpointExecutionHandler.java

示例10: channelActive

import io.netty.util.Attribute; //导入方法依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    Attribute<MessageMetrics> attr = ctx.attr(ATTR_KEY_METRICS);
    attr.set(new MessageMetrics());

    super.channelActive(ctx);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:8,代码来源:MessageMetricsHandler.java

示例11: channelActive

import io.netty.util.Attribute; //导入方法依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    Attribute<BytesMetrics> attr = ctx.attr(ATTR_KEY_METRICS);
    attr.set(new BytesMetrics());

    super.channelActive(ctx);
}
 
开发者ID:sn3009,项目名称:EasyMessage,代码行数:8,代码来源:BytesMetricsHandler.java

示例12: handlerRemoved

import io.netty.util.Attribute; //导入方法依赖的package包/类
@Override
public void handlerRemoved(ChannelHandlerContext ctx) {
	Attribute<ByteBuf> bytebufAttr = ctx.channel().attr(BUFFER_IN);
	ByteBuf buffer = bytebufAttr.get();
	Util.safeRelease(buffer);
	bytebufAttr.set(null);
}
 
开发者ID:GHzGangster,项目名称:Nomad,代码行数:8,代码来源:PacketDecoder.java

示例13: HttpsOriginalHostCaptureFilter

import io.netty.util.Attribute; //导入方法依赖的package包/类
public HttpsOriginalHostCaptureFilter(HttpRequest originalRequest, ChannelHandlerContext ctx) {
    super(originalRequest, ctx);

    // if this is an HTTP CONNECT, set the isHttps attribute on the ChannelHandlerConect and capture the hostname from the original request.
    // capturing the original host (and the remapped/modified host in clientToProxyRequest() below) guarantees that we will
    // have the "true" host, rather than relying on the Host header in subsequent requests (which may be absent or spoofed by malicious clients).
    if (ProxyUtils.isCONNECT(originalRequest)) {
        Attribute<String> originalHostAttr = ctx.attr(AttributeKey.<String>valueOf(HttpsAwareFiltersAdapter.ORIGINAL_HOST_ATTRIBUTE_NAME));
        String hostAndPort = originalRequest.getUri();
        originalHostAttr.set(hostAndPort);

        Attribute<Boolean> isHttpsAttr = ctx.attr(AttributeKey.<Boolean>valueOf(HttpsAwareFiltersAdapter.IS_HTTPS_ATTRIBUTE_NAME));
        isHttpsAttr.set(true);
    }
}
 
开发者ID:misakuo,项目名称:Dream-Catcher,代码行数:16,代码来源:HttpsOriginalHostCaptureFilter.java

示例14: attachSession

import io.netty.util.Attribute; //导入方法依赖的package包/类
private Session attachSession(ChannelHandlerContext ctx){
	Session sess = new NettySession(ctx);
	Attribute<String> attr = ctx.channel().attr(sessionKey); 
	attr.set(sess.id()); 
	sessionMap.put(sess.id(), sess);
	return sess;
}
 
开发者ID:rushmore,项目名称:zbus,代码行数:8,代码来源:NettyAdaptor.java

示例15: ensurePlay

import io.netty.util.Attribute; //导入方法依赖的package包/类
private static void ensurePlay(Channel channel) {
    Attribute<EnumConnectionState> attr = channel.attr(NetworkManager.attrKeyConnectionState);
    EnumConnectionState enumConnectionState = attr.get();
    if (enumConnectionState == null) {
        Core.logSevere("Changing ConnectionState from null to PLAY: " + channel);
        attr.set(EnumConnectionState.PLAY);
    }
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:9,代码来源:PacketJunction.java


注:本文中的io.netty.util.Attribute.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。