/** * <p>This is a convenience method to call {@link * #createSourceSession(SourceSessionParams)} with default values for the * {@link SourceSessionParams} object.</p> * * @param handler The reply handler to receive the replies for the session. * @return The created session. */ public SourceSession createSourceSession(ReplyHandler handler) { return createSourceSession(new SourceSessionParams().setReplyHandler(handler)); }
/** * <p>The default constructor requires values for all final member variables * of this. It expects all arguments but the {@link SourceSessionParams} to * be proper, so no checks are performed. The constructor is declared * package private since only {@link MessageBus} is supposed to instantiate * it.</p> * * @param mbus The message bus that created this instance. * @param params A parameter object that holds configuration parameters. */ SourceSession(MessageBus mbus, SourceSessionParams params) { this.mbus = mbus; sequencer = new Sequencer(mbus); if (!params.hasReplyHandler()) { throw new NullPointerException("Reply handler is null."); } replyHandler = params.getReplyHandler(); throttlePolicy = params.getThrottlePolicy(); timeout = params.getTimeout(); mbus.register(this); }
private SourceSessionParams createSourceSessionParams(VisitorParameters visitorParameters) { SourceSessionParams sourceParams = new SourceSessionParams(); if (visitorParameters.getThrottlePolicy() != null) { sourceParams.setThrottlePolicy(visitorParameters.getThrottlePolicy()); } else { sourceParams.setThrottlePolicy(new DynamicThrottlePolicy()); } return sourceParams; }
private SourceSessionParams sourceSessionParams(HttpRequest request) { SourceSessionParams params = new SourceSessionParams(); String timeout = request.getHeader(Headers.TIMEOUT); if (timeout != null) { try { params.setTimeout(Double.parseDouble(timeout)); } catch (NumberFormatException e) { // NOP } } return params; }
private RemoteClient(Slobrok slobrok, String slobrokId, Protocol protocol) { this.slobrok = slobrok; this.slobrokId = slobrok != null ? slobrok.configId() : slobrokId; mbus = new MessageBus(new RPCNetwork(new RPCNetworkParams().setSlobrokConfigId(this.slobrokId)), new MessageBusParams().addProtocol(protocol)); session = mbus.createSourceSession(new SourceSessionParams().setThrottlePolicy(null).setReplyHandler(queue)); }
/** * Sets the extended source session params. * * @param params The params object. * @return This object for chaining. */ public MessageBusParams setSourceSessionParams(SourceSessionParams params) { sourceSessionParams = new SourceSessionParams(params); return this; } }
public SharedSourceSession(SharedMessageBus mbus, SourceSessionParams params) { if (params.getReplyHandler() != null) { throw new IllegalArgumentException("Reply handler must be null."); } this.mbus = mbus; this.session = mbus.messageBus().createSourceSession(params.setReplyHandler(this)); this.mbusReference = mbus.refer(); }
/** * Creates a new async session running on message bus logic with a specified reply handler. * * @param asyncParams Common asyncsession parameters, not used. * @param bus The message bus on which to run. * @param mbusParams Parameters concerning message bus configuration. * @param handler The external reply handler. */ MessageBusAsyncSession(AsyncParameters asyncParams, MessageBus bus, MessageBusParams mbusParams, ReplyHandler handler) { route = mbusParams.getRoute(); routeForGet = mbusParams.getRouteForGet(); traceLevel = mbusParams.getTraceLevel(); throttlePolicy = mbusParams.getSourceSessionParams().getThrottlePolicy(); if (handler == null) { handler = new MyReplyHandler(asyncParams.getResponseHandler(), responses); } session = bus.createSourceSession(handler, mbusParams.getSourceSessionParams()); }
private ClientTestDriver(RemoteServer server, Protocol protocol) { this.server = server; MessageBusParams mbusParams = new MessageBusParams().addProtocol(protocol); RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(server.slobrokId()); SharedMessageBus mbus = SharedMessageBus.newInstance(mbusParams, netParams); session = mbus.newSourceSession(new SourceSessionParams()); client = new MbusClient(session); client.start(); mbus.release(); driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.clientBindings().bind("mbus://*/*", client); driver.activateContainer(builder); }
/** * <p>This is a convenience method to call {@link * #createSourceSession(SourceSessionParams)} by first assigning the reply * handler to the parameter object.</p> * * @param handler The reply handler to receive the replies for the session. * @param params The parameters to control the session. * @return The created session. */ public SourceSession createSourceSession(ReplyHandler handler, SourceSessionParams params) { return createSourceSession(new SourceSessionParams(params).setReplyHandler(handler)); }