List of usage examples for org.apache.http.util Args notNull
public static <T> T notNull(T t, String str)
From source file:pl.allegro.tech.hermes.consumers.consumer.sender.http.ByteBufferEntity.java
@Override public void writeTo(OutputStream outstream) throws IOException { Args.notNull(outstream, "Output stream"); WritableByteChannel channel = Channels.newChannel(outstream); channel.write(buffer);// www .j a v a 2 s . c o m outstream.flush(); }
From source file:nl.nn.adapterframework.http.mime.MultipartForm.java
/** * Creates an instance with the specified settings. * * @param charset the character set to use. May be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. US-ASCII - is used. * @param boundary to use - must not be {@code null} * @throws IllegalArgumentException if charset is null or boundary is null *///w w w .j a v a2 s .c om public MultipartForm(final Charset charset, final String boundary, final List<FormBodyPart> parts) { Args.notNull(boundary, "Multipart boundary"); this.charset = charset != null ? charset : MIME.DEFAULT_CHARSET; this.boundary = boundary; this.parts = parts; }
From source file:org.apache.synapse.transport.nhttp.NhttpSharedOutputBuffer.java
public NhttpSharedOutputBuffer(final int buffersize, final IOControl ioctrl, final ByteBufferAllocator allocator, int timeout) { super(buffersize, allocator); Args.notNull(ioctrl, "I/O content control"); this.ioctrl = ioctrl; this.lock = new ReentrantLock(); this.condition = this.lock.newCondition(); this.timeout = timeout; }
From source file:com.ok2c.lightmtp.impl.pool.MailIOSessionManager.java
public void releaseSession(final LeasedSession managedSession) { Args.notNull(managedSession, "Managed session"); synchronized (managedSession) { final IOSession iosession = managedSession.getConnection(); try {/*from w w w . ja v a2s . co m*/ if (!iosession.isClosed()) { managedSession.updateExpiry(30, TimeUnit.SECONDS); if (this.log.isDebugEnabled()) { this.log.debug( "Connection " + format(managedSession) + " can be kept alive for 30 seconds"); } } } finally { this.pool.release(managedSession, !iosession.isClosed()); if (this.log.isDebugEnabled()) { this.log.debug( "Session released: " + format(managedSession) + formatStats(managedSession.getRoute())); } } } }
From source file:com.ok2c.lightmtp.impl.protocol.SendDataCodec.java
@Override public void reset(final IOSession iosession, final ClientState sessionState) throws IOException, SMTPProtocolException { Args.notNull(iosession, "IO session"); Args.notNull(sessionState, "Session state"); if (sessionState.getRequest() == null) { throw new IllegalArgumentException("Delivery request may not be null"); }/* www . ja v a2s .c o m*/ DeliveryRequest request = sessionState.getRequest(); this.parser.reset(); this.contentBuf.clear(); this.lineBuf.clear(); this.recipients.clear(); if (this.mode.equals(DataAckMode.PER_RECIPIENT)) { this.recipients.addAll(request.getRecipients()); } this.content = request.getContent(); this.contentChannel = this.content.channel(); this.contentSent = false; this.codecState = CodecState.CONTENT_READY; iosession.setEvent(SelectionKey.OP_WRITE); }
From source file:com.wudaosoft.net.httpclient.HostConfigBuilder.java
/** * @param httpHost the httpHost to set/*from www. j av a2 s .c om*/ */ public HostConfigBuilder setHttpHost(HttpHost httpHost) { Args.notNull(httpHost, "httpHost"); this.httpHost = httpHost; if (this.hostUrl == null) { this.hostUrl = httpHost.toURI(); } return this; }
From source file:com.app.precared.utils.MultipartEntityBuilder.java
public MultipartEntityBuilder addPart(final String name, final ContentBody contentBody) { Args.notNull(name, "Name"); Args.notNull(contentBody, "Content body"); return addPart(new FormBodyPart(name, contentBody)); }
From source file:com.ok2c.lightmtp.impl.protocol.PipeliningReceiveEnvelopCodec.java
@Override public void produceData(final IOSession iosession, final ServerState sessionState) throws IOException, SMTPProtocolException { Args.notNull(iosession, "IO session"); Args.notNull(sessionState, "Session state"); SessionOutputBuffer buf = this.iobuffers.getOutbuf(); synchronized (sessionState) { if (this.actionFuture != null) { SMTPReply reply = getReply(this.actionFuture); this.actionFuture = null; this.writer.write(reply, buf); }//from www .j a v a 2s. c o m if (this.actionFuture == null) { while (!this.pendingActions.isEmpty()) { Action<ServerState> action = this.pendingActions.remove(); Future<SMTPReply> future = action.execute(sessionState, new OutputTrigger<SMTPReply>(sessionState, iosession)); if (future.isDone()) { SMTPReply reply = getReply(future); this.writer.write(reply, buf); } else { this.actionFuture = future; break; } } } if (buf.hasData()) { buf.flush(iosession.channel()); } if (!buf.hasData()) { if (sessionState.getDataType() != null) { this.completed = true; } if (sessionState.isTerminated()) { iosession.close(); } else { iosession.clearEvent(SelectionKey.OP_WRITE); } } } }
From source file:com.ok2c.lightmtp.impl.protocol.SendLocalHeloCodec.java
@Override public void consumeData(final IOSession iosession, final ClientState sessionState) throws IOException, SMTPProtocolException { Args.notNull(iosession, "IO session"); Args.notNull(sessionState, "Session state"); SessionInputBuffer buf = this.iobuffers.getInbuf(); int bytesRead = buf.fill(iosession.channel()); SMTPReply reply = this.parser.parse(buf, bytesRead == -1); if (reply != null) { switch (this.codecState) { case SERVICE_READY_EXPECTED: if (reply.getCode() == SMTPCodes.SERVICE_READY) { this.codecState = CodecState.LHLO_READY; iosession.setEvent(SelectionKey.OP_WRITE); } else { this.codecState = CodecState.COMPLETED; sessionState.setReply(reply); }/*from w ww .j av a 2 s . c o m*/ break; case LHLO_RESPONSE_EXPECTED: if (reply.getCode() == SMTPCodes.OK) { Set<String> extensions = sessionState.getExtensions(); List<String> lines = reply.getLines(); if (lines.size() > 1) { for (int i = 1; i < lines.size(); i++) { String line = lines.get(i); extensions.add(line.toUpperCase(Locale.US)); } } } this.codecState = CodecState.COMPLETED; sessionState.setReply(reply); break; default: if (reply.getCode() == SMTPCodes.ERR_TRANS_SERVICE_NOT_AVAILABLE) { sessionState.setReply(reply); this.codecState = CodecState.COMPLETED; } else { throw new SMTPProtocolException("Unexpected reply: " + reply); } } } else { if (bytesRead == -1 && !sessionState.isTerminated()) { throw new UnexpectedEndOfStreamException(); } } }
From source file:de.vanita5.twittnuker.util.net.ssl.HostResolvedSSLConnectionSocketFactory.java
public HostResolvedSSLConnectionSocketFactory(final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier) { this(Args.notNull(sslContext, "SSL context").getSocketFactory(), null, null, hostnameVerifier); }