本文整理汇总了Java中io.undertow.util.AttachmentKey类的典型用法代码示例。如果您正苦于以下问题:Java AttachmentKey类的具体用法?Java AttachmentKey怎么用?Java AttachmentKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttachmentKey类属于io.undertow.util包,在下文中一共展示了AttachmentKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToAttachmentList
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> void addToAttachmentList(AttachmentKey<AttachmentList<T>> key, T value) {
if (key == null) {
throw UndertowMessages.MESSAGES.argumentCannotBeNull("key");
}
final Map<AttachmentKey<?>, Object> attachments = this.attachments;
synchronized (attachments) {
final List<T> list = key.cast(attachments.get(key));
if (list == null) {
final AttachmentList<T> newList = new AttachmentList<T>((Class<T>) Object.class);
attachments.put(key, newList);
newList.add(value);
} else {
list.add(value);
}
}
}
示例2: testNotOverride
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Test
public void testNotOverride() throws Exception {
HttpServerExchange exchange = new MockUp<HttpServerExchange>() {
@Mock
public HeaderMap getRequestHeaders() {
throw new AssertionError();
}
@Mock
public <T> T getAttachment(final AttachmentKey<T> key) {
throw new AssertionError();
}
}.getMockInstance();
exchange.setRequestMethod(Methods.GET);
this.target.handleRequest(exchange);
}
示例3: getAttachment
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> T getAttachment(AttachmentKey<T> key) {
if (key == null) {
throw UndertowMessages.MESSAGES.argumentCannotBeNull("key");
}
return (T) attachments.get(key);
}
示例4: getAttachmentList
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> List<T> getAttachmentList(AttachmentKey<? extends List<T>> key) {
if (key == null) {
throw UndertowMessages.MESSAGES.argumentCannotBeNull("key");
}
Object o = attachments.get(key);
if(o == null) {
return Collections.emptyList();
}
return (List)o;
}
示例5: putAttachment
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> T putAttachment(AttachmentKey<T> key, T value) {
if (key == null) {
throw UndertowMessages.MESSAGES.argumentCannotBeNull("key");
}
return key.cast(attachments.put(key, key.cast(value)));
}
示例6: ChunkReader
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
public ChunkReader(final Attachable attachable, final AttachmentKey<HeaderMap> trailerAttachmentKey, ConduitListener<? super T> finishListener, T conduit) {
this.attachable = attachable;
this.trailerAttachmentKey = trailerAttachmentKey;
this.finishListener = finishListener;
this.conduit = conduit;
this.state = FLAG_READING_LENGTH;
}
示例7: putAttachment
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> void putAttachment(final AttachmentKey<T> key, final T value) {
exchange.putAttachment(key, value);
}
示例8: getAttachment
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> T getAttachment(final AttachmentKey<T> key) {
return exchange.getAttachment(key);
}
示例9: removeAttachment
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> T removeAttachment(AttachmentKey<T> key) {
return key.cast(attachments.remove(key));
}
示例10: addToAttachmentList
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> void addToAttachmentList(AttachmentKey<AttachmentList<T>> key, T value) {
channel.addToAttachmentList(key, value);
}
示例11: removeAttachment
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> T removeAttachment(AttachmentKey<T> key) {
return channel.removeAttachment(key);
}
示例12: putAttachment
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> T putAttachment(AttachmentKey<T> key, T value) {
return channel.putAttachment(key, value);
}
示例13: getAttachmentList
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> List<T> getAttachmentList(AttachmentKey<? extends List<T>> key) {
return channel.getAttachmentList(key);
}
示例14: getAttachment
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
@Override
public <T> T getAttachment(AttachmentKey<T> key) {
return channel.getAttachment(key);
}
示例15: AttachmentHandler
import io.undertow.util.AttachmentKey; //导入依赖的package包/类
public AttachmentHandler(final AttachmentKey<T> key, final HttpHandler next, final T instance) {
this.next = next;
this.key = key;
this.instance = instance;
}