@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:META-INF/spring/applicationContext.xml" }) public class ServiceThatNeedsServiceInterfaceTest { @Autowired ServiceThatNeedsServiceInterface serviceThatNeedsServiceInterface; @Test public void testUseService() { //As we are not running from a web container //so we set the context directly to the service RequestContext context = new RequestContext(); context.setQualifier("ProductAService"); serviceThatNeedsServiceInterface.context = context; serviceThatNeedsServiceInterface.useService(); context.setQualifier("ProductBService"); serviceThatNeedsServiceInterface.context = context; serviceThatNeedsServiceInterface.useService(); } }
@Override public void tryToCloseChannel( Channel channel ) { IdleChannelReaper.Request request = unmapSlave( channel ); if ( request == null ) { return; } tryToFinishOffChannel( channel, request.getRequestContext()); }
@Override public void accept( Response.Handler handler ) throws Exception { transactions.accept( handler.transactions() ); }
public void serializeRequest( Channel channel, ChannelBuffer buffer, RequestType type, RequestContext ctx, Serializer payload ) throws IOException { buffer.clear(); ChunkingChannelBuffer chunkingBuffer = new ChunkingChannelBuffer( buffer, channel, chunkSize, internalProtocolVersion, applicationProtocolVersion ); chunkingBuffer.writeByte( type.id() ); writeContext( ctx, chunkingBuffer ); payload.write( chunkingBuffer ); chunkingBuffer.done(); }
public class RequestContextBuilder implements Callable { @Override public Object onCall(MuleEventContext eventContext) throws Exception { MuleMessage message = eventcontext.getMessage(); RequestContext requestContext = new RequestContext(); requestContext.setMethod(RESTMethod.get((String) message.getInboundProperty("http.method"))); requestContext.setAPI((String) message.getInboundProperty("http.request.path")); requestContext.setQueryParams((String) message.getInboundProperty("http.query.string")); return requestContext; } }
public static RequestContext anonymous( long lastAppliedTransaction ) { return new RequestContext( EMPTY.epoch, EMPTY.machineId, EMPTY.eventIdentifier, lastAppliedTransaction, EMPTY.checksum ); } }
@Override public void setByte( int index, int value ) { throw unsupportedOperation(); }
protected Protocol createProtocol( int chunkSize, byte applicationProtocolVersion ) { return new Protocol320( chunkSize, applicationProtocolVersion, getInternalProtocolVersion() ); }
public BlockLogReader( ChannelBuffer source ) { this.source = source; readNextBlock(); }
public BlockLogBuffer( ChannelBuffer target, ByteCounterMonitor monitor ) { this.target = target; this.monitor = monitor; clearInternalBuffer(); }
private ComExceptionHandler getNoOpComExceptionHandler() { return exception -> { if ( ComException.TRACE_HA_CONNECTIVITY ) { String noOpComExceptionHandler = "NoOpComExceptionHandler"; //noinspection ThrowableResultOfMethodCallIgnored traceComException( exception, noOpComExceptionHandler ); } }; }
import play.api.Play; import play.mvc.*; import play.mvc.Http.Request; public abstract class GenericController extends Controller { protected static RequestContext getContext() { return new RequestContext(getAPIVersion()); } protected static double getAPIVersion() { return (double) Http.Context.current().args .get(VersioningController.API_VERSION); } }
@Override public void setMedium( int index, int value ) { throw unsupportedOperation(); }
/** * Reads everything that can be read from the channel. Stops when a chunk * starting with a non zero byte is met. */ private void readToTheEnd() { while ( moreBlocks ) { readNextBlock(); } } }
@Override public void setChar( int index, int value ) { throw unsupportedOperation(); }
@Override public void setBytes( int index, byte[] src ) { throw unsupportedOperation(); }
@Override public void setBytes( int index, byte[] src, int srcIndex, int length ) { throw unsupportedOperation(); }
@Override public void writeBytes( ByteBuffer src ) { throw unsupportedOperation(); }
@Override public int bytesBefore( int index, int length, ChannelBufferIndexFinder indexFinder ) { throw unsupportedOperation(); }
@Override public int arrayOffset() { throw unsupportedOperation(); }