@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(); } }
private void writeContext( RequestContext context, ChannelBuffer targetBuffer ) { targetBuffer.writeLong( context.getEpoch() ); targetBuffer.writeInt( context.machineId() ); targetBuffer.writeInt( context.getEventIdentifier() ); long tx = context.lastAppliedTransaction(); targetBuffer.writeLong( tx ); targetBuffer.writeLong( context.getChecksum() ); }
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 Response<Void> fullBackup( StoreWriter writer, boolean forensics ) { String backupIdentifier = getBackupIdentifier(); try ( StoreWriter storeWriter = writer ) { logger.log( "%s: Full backup started...", backupIdentifier ); RequestContext copyStartContext = storeCopyServer.flushStoresAndStreamStoreFiles( FULL_BACKUP_CHECKPOINT_TRIGGER, storeWriter, forensics ); ResponsePacker responsePacker = new StoreCopyResponsePacker( logicalTransactionStore, transactionIdStore, logFileInformation, storeId, copyStartContext.lastAppliedTransaction() + 1, storeCopyServer.monitor() ); long optionalTransactionId = copyStartContext.lastAppliedTransaction(); return responsePacker.packTransactionStreamResponse( anonymous( optionalTransactionId ), null/*no response object*/ ); } finally { logger.log( "%s: Full backup finished.", backupIdentifier ); } }
private RequestContext slaveContextOf( GraphDatabaseAPI graphDb ) { TransactionIdStore transactionIdStore = graphDb.getDependencyResolver().resolveDependency( TransactionIdStore.class ); return anonymous( transactionIdStore.getLastCommittedTransactionId() ); }
public <T> Response<T> packTransactionStreamResponse( RequestContext context, T response ) { final long toStartFrom = context.lastAppliedTransaction() + 1; final long toEndAt = transactionIdStore.getLastCommittedTransactionId(); TransactionStream transactions = visitor -> { // Check so that it's even worth thinking about extracting any transactions at all if ( toStartFrom > BASE_TX_ID && toStartFrom <= toEndAt ) { extractTransactions( toStartFrom, filterVisitor( visitor, toEndAt ) ); } }; return new TransactionStreamResponse<>( response, storeId.get(), transactions, ResourceReleaser.NO_OP ); }
protected ChannelBuffer mapSlave( Channel channel, RequestContext slave ) { // Checking for machineId -1 excludes the "empty" slave contexts // which some communication points pass in as context. if ( slave != null && slave.machineId() != RequestContext.EMPTY.machineId() ) { connectedSlaveChannels.add( channel, slave ); } return ChannelBuffers.dynamicBuffer(); }
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); } }
return anonymous( lastAppliedTransaction );
using (var requestContext = new RequestContext(requestContextSettings)) using (var browser = new ChromiumWebBrowser(url, browserSettings, requestContext))
List<FileItem> result = up.parseRequest(new RequestContext() {
protected RequestContext readContext( ChannelBuffer buffer ) { long sessionId = buffer.readLong(); int machineId = buffer.readInt(); int eventIdentifier = buffer.readInt(); long neoTx = buffer.readLong(); long checksum = buffer.readLong(); RequestContext readRequestContext = new RequestContext( sessionId, machineId, eventIdentifier, neoTx, checksum ); // verify checksum only if there are transactions committed in the store if ( neoTx > TransactionIdStore.BASE_TX_ID ) { txVerifier.assertMatch( neoTx, checksum ); } return readRequestContext; }