本文整理汇总了Java中reactor.core.Environment类的典型用法代码示例。如果您正苦于以下问题:Java Environment类的具体用法?Java Environment怎么用?Java Environment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Environment类属于reactor.core包,在下文中一共展示了Environment类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeReactor
import reactor.core.Environment; //导入依赖的package包/类
private void initializeReactor() {
reactor = Reactors.reactor()
.env(env)
.dispatcher(Environment.RING_BUFFER)
.get();
decoderReactor = Reactors.reactor()
.env(env)
.dispatcher(Environment.RING_BUFFER)
.get();
decoderReactor.on(Selectors.$(DECODE_TOPIC), (Event<byte[]> m) -> {
try {
Envelope message = EnvelopeCodec.decode(m.getData());
message.setDecoded(false);
send(message);
} catch (IOException | MessageTypeException ex) {
LOG.error("Error decoding message.", ex);
}
});
}
示例2: main
import reactor.core.Environment; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Environment env = new Environment();
Reactor reactor = Reactors.reactor().env(env).dispatcher(Environment.THREAD_POOL).get();
// topic: parse
reactor.on($("parse"), App::handleEvent1);
reactor.on($("parse"), App::handleEvent2);
// Notify consumers of the 'parse' topic that data is ready
// by passing a Supplier<Event<T>> in the form of a lambda
for (long l = 0; true; l++) {
String obj = "Test-" + l;
reactor.notify("parse", Event.wrap(new ObjectEvent().setObject(obj)));
Thread.sleep(1000);
}
}
示例3: AsyncAnnotationAuditOutputStream
import reactor.core.Environment; //导入依赖的package包/类
/**
* Instantiates a new annotation audit output stream.
*
* @param outputStream the output stream
* @param transformer the transformer
*/
public AsyncAnnotationAuditOutputStream(final AuditOutputStream<AuditEvent> outputStream, final AnnotationTransformer transformer) {
ENV = new Environment();
this.outputStream = outputStream;
b = new Boundary();
annotationDeferred = Streams.<AnnotationAuditEvent> defer().env(ENV).dispatcher(Environment.RING_BUFFER).get();
Stream<AnnotationAuditEvent> annostream = annotationDeferred.compose();
annostream.consume(b.bind(new Consumer<AnnotationAuditEvent>() {
@Override
public void accept(AnnotationAuditEvent annotationEvent) {
AuditEvent event = transformer.transformToEvent(annotationEvent);
// event is null if annotation is not found
if (event != null) {
outputStream.write(event);
}
}
}));
}
示例4: AsyncAuditOutputStream
import reactor.core.Environment; //导入依赖的package包/类
/**
* Instantiates a new async audit output stream.
*
* @param outputStream the output stream
* @param annotationStream the annotation stream
*/
public AsyncAuditOutputStream(final AuditOutputStream<AuditEvent> outputStream, final AuditOutputStream<AnnotationAuditEvent> annotationStream) {
this.outputStream = outputStream;
this.annotationStream = annotationStream;
ENV = new Environment();
b = new Boundary();
deferred = Streams.<AuditEvent> defer().env(ENV).dispatcher(Environment.RING_BUFFER).get();
Stream<AuditEvent> stream = deferred.compose();
stream.consume(b.bind(new Consumer<AuditEvent>() {
@Override
public void accept(AuditEvent event) {
outputStream.write(event);
}
}));
batchBoundry = new Boundary();
batchDeferred = Streams.<EventBatch> defer().env(ENV).dispatcher(Environment.RING_BUFFER).get();
Stream<EventBatch> batchStream = batchDeferred.compose();
batchStream.consume(batchBoundry.bind(new Consumer<EventBatch>() {
@Override
public void accept(EventBatch batch) {
outputStream.writeBatch(batch);
}
}));
}
示例5: main
import reactor.core.Environment; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Environment env = new Environment();
final TradeServer server = new TradeServer();
// Use a Reactor to dispatch events using the default Dispatcher
Reactor reactor = Reactors.reactor()
.env(env)
.dispatcher("ringBuffer")
.get();
String topic = "trade.execute";
// For each Trade event, execute that on the server
reactor.on($(topic), new Consumer<Event<Trade>>() {
@Override
public void accept(Event<Trade> tradeEvent) {
server.execute(tradeEvent.getData());
// Since we're async, for this test, use a latch to tell when we're done
latch.countDown();
}
});
// Start a throughput timer
startTimer();
// Publish one event per trade
for (int i = 0; i < totalTrades; i++) {
// Pull next randomly-generated Trade from server
Trade t = server.nextTrade();
// Notify the Reactor the event is ready to be handled
reactor.notify(topic, Event.wrap(t));
}
// Stop throughput timer and output metrics
endTimer();
server.stop();
}
示例6: reactor
import reactor.core.Environment; //导入依赖的package包/类
@Bean
public Reactor reactor(Environment env, MailServer mailServer) {
Logger log = LoggerFactory.getLogger("mail.server");
Reactor r = Reactors.reactor(env);
// Wire an event handler to execute messages
r.on($("mail.execute"), (Event<MessageDescriptor> ev) -> {
mailServer.execute(ev.getData());
log.info("Executed message: {}", ev.getData());
});
return r;
}
示例7: ListenerRegistry
import reactor.core.Environment; //导入依赖的package包/类
/**
* Constructor.
*/
public ListenerRegistry() {
reactor = Reactors.reactor()
.env(environment)
.dispatcher(Environment.RING_BUFFER)
.get();
}
示例8: VisactorResourceConfig
import reactor.core.Environment; //导入依赖的package包/类
public VisactorResourceConfig() {
this.reactor = Reactors.reactor(new Environment(), Environment.RING_BUFFER);
this.store = new ListEventStore();
register(SseFeature.class);
registerInstances(new VisactorResource(reactor, store));
}
示例9: SingletonEnvironment
import reactor.core.Environment; //导入依赖的package包/类
private SingletonEnvironment() {
env = new Environment();
defaultReactor = Reactors.reactor(env);
}
示例10: rootReactor
import reactor.core.Environment; //导入依赖的package包/类
@Bean
public Reactor rootReactor(final Environment env) {
return Reactors.reactor().env(env).get();
}
示例11: getEnv
import reactor.core.Environment; //导入依赖的package包/类
/**
* Returns the
* @return the env
*/
public Environment getEnv() {
return env;
}