org.projectodd.wunderboss.Options.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(65)

本文整理了Java中org.projectodd.wunderboss.Options.<init>()方法的一些代码示例,展示了Options.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Options.<init>()方法的具体详情如下:
包路径:org.projectodd.wunderboss.Options
类名称:Options
方法名:<init>

Options.<init>介绍

暂无

代码示例

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-caching

protected Options<CreateOption> validate(Map<CreateOption,Object> options) {
  Options<CreateOption> result = new Options<CreateOption>(options);
  String mode = result.getString(CreateOption.MODE);
  if (mode != null && !"LOCAL".equalsIgnoreCase(mode)) {
    log.warn("Requested mode only available in a cluster, setting to LOCAL");
    result.put(CreateOption.MODE, "LOCAL");
  }
  return result;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

protected Options<MessageOpOption> replyOptions(Map<Destination.MessageOpOption, Object> options) throws Exception {
  Options<MessageOpOption> opts = new Options<>(options);
  Map<String, Object> properties = (Map<String, Object>)opts.get(Destination.PublishOption.PROPERTIES);
  Map<String, Object> newProperties = new HashMap<>();
  if (properties != null) {
    newProperties.putAll(properties);
  }
  newProperties.put(SYNC_RESPONSE_PROPERTY, true);
  newProperties.put(REQUEST_ID_PROPERTY, requestID());
  newProperties.put(REQUEST_NODE_ID_PROPERTY, requestNodeID());
  opts.put(Destination.PublishOption.PROPERTIES, newProperties);
  return opts;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-core

public static <T extends Component> T findOrCreateComponent(Class<T> clazz, String name, Map<Object, Object> options) {
  if (name == null) {
    name = "default";
  }
  T component = findComponent(clazz, name);
  String fullName = fullComponentName(clazz, name);
  if (component != null) {
    log.debug("Returning existing component for " + fullName + ", ignoring options.");
  } else {
    component = getComponentProvider(clazz, true).create(name, new Options<>(options));
    components.put(fullName, component);
  }
  return component;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-core

private static void init() {
  classLoader = new DynamicClassLoader(WunderBoss.class.getClassLoader());
  locator = new ClassPathLocator(classLoader);
  options = new Options<>();
  options.put("root", ".");
  configureLogback();
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-web-undertow

@Override
public boolean unregister(Map<RegisterOption, Object> opts) {
  final Options<RegisterOption> options = new Options<>(opts);
  return pathology.remove(options.getString(RegisterOption.PATH), options.getList(RegisterOption.VHOSTS));
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-wildfly-caching

protected Options<CreateOption> validate(Map<CreateOption,Object> options) {
  Options<CreateOption> result = new Options<CreateOption>(options);
  String mode = result.getString(CreateOption.MODE);
  // Default mode when in a cluster
  if (mode == null && ASUtils.inCluster()) {
    result.put(CreateOption.MODE, "DIST_SYNC");
  }
  return result;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public void unsubscribe(String id, Map<UnsubscribeOption, Object> options) throws Exception {
  final Options<UnsubscribeOption> opts = new Options<>(options);
  try (JMSSpecificContext context = (JMSSpecificContext)context(id, opts.get(UnsubscribeOption.CONTEXT))) {
    context.jmsSession().unsubscribe(id);
  }
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-scheduling

@Override
public synchronized boolean schedule(String name, Runnable fn, Map<ScheduleOption, Object> opts) throws Exception {
  Options<ScheduleOption> options = new Options<>(opts);
  validateOptions(options);
  start();
  final boolean replacedExisting = unschedule(name);
  final JobDataMap jobDataMap = new JobDataMap();
  final Map contextOptions = new HashMap();
  contextOptions.put(ExecutionContext.CreateOption.SINGLETON, options.getBoolean(SINGLETON));
  final ImmediateContext context = WunderBoss.findOrCreateComponent(ImmediateContext.class, name, contextOptions);
  context.setAction(fn);
  // TODO: Quartz says only serializable things should be in here
  jobDataMap.put(RunnableJob.RUN_FUNCTION_KEY, context);
  
  JobBuilder jobBuilder;
  if (options.getBoolean(ALLOW_CONCURRENT_EXEC)) {
    jobBuilder = JobBuilder.newJob(RunnableJob.class);
  } else {
    jobBuilder = JobBuilder.newJob(RunnableJob.NotConcurrentlyExecuting.class);
  }
  JobDetail job = jobBuilder.usingJobData(jobDataMap).build();
  this.scheduler.scheduleJob(job, initTrigger(name, options));
  this.currentJobs.put(name, job.getKey());
  return replacedExisting;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public Listener respond(final MessageHandler handler,
            final Codecs codecs,
            Map<ListenOption, Object> options) throws Exception {
  final Options<ListenOption> opts = new Options<>(options);
  String selector = JMSMessage.SYNC_PROPERTY + " = TRUE";
  if (opts.has(ListenOption.SELECTOR)) {
    selector += " AND " + opts.getString(ListenOption.SELECTOR);
  }
  opts.put(ListenOption.SELECTOR, selector);
  MessageHandler wrappedHandler = new MessageHandler() {
    @Override
    public Reply onMessage(Message msg, Context context) throws Exception {
      Reply result = handler.onMessage(msg, context);
      Options<MessageOpOption> replyOptions = new Options<>();
      replyOptions.put(PublishOption.TTL, opts.getInt(RespondOption.TTL));
      replyOptions.put(PublishOption.CONTEXT, context);
      replyOptions.put(PublishOption.PROPERTIES, result.properties());
      ((ReplyableMessage)msg).reply(result.content(), codecs.forContentType(msg.contentType()), replyOptions);
      return null;
    }
  };
  return listen(wrappedHandler, codecs, opts);
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-core

public Options<T> merge(Options<T> otherOptions) {
    Options mergedOptions = new Options();
    for (T key : this.keySet()) {
      mergedOptions.put(key, this.get(key));
    }
    for (T key : otherOptions.keySet()) {
      mergedOptions.put(key, otherOptions.get(key));
    }
    return mergedOptions;
  }
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public Response request(Object content, Codec codec,
            Codecs codecs,
            Map<MessageOpOption, Object> options) throws Exception {
  final Options<MessageOpOption> opts = new Options<>(options);
  final String id = UUID.randomUUID().toString();
  final JMSSpecificContext context = (JMSSpecificContext)opts.get(MessageOpOption.CONTEXT);
  final String nodeId = context != null ? context.id() : JMSMessagingSkeleton.BROKER_ID;
  final ConcreteResponse response = new ConcreteResponse();
  Options<ListenOption> routerOpts = new Options<>();
  routerOpts.put(ListenOption.CONCURRENCY, 1);
  routerOpts.put(ListenOption.SELECTOR,
          JMSMessage.REQUEST_NODE_ID_PROPERTY + " = '" + nodeId + "' AND " +
              JMSMessage.SYNC_RESPONSE_PROPERTY + " = TRUE");
  if (context != null &&
      context.isRemote()) {
    routerOpts.put(ListenOption.CONTEXT, context);
  }
  ResponseRouter.routerFor(this, codecs, routerOpts).registerResponse(id, response);
  publish(content, codec, options,
      new HashMap<String, Object>() {{
        put(JMSMessage.REQUEST_NODE_ID_PROPERTY, nodeId);
        put(JMSMessage.SYNC_PROPERTY, true);
        put(JMSMessage.REQUEST_ID_PROPERTY, id);
      }});
  return response;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public synchronized Topic findOrCreateTopic(String name,
                      Map<CreateTopicOption, Object> options) throws Exception {
  Options<CreateTopicOption> opts = new Options<>(options);
  javax.jms.Topic topic;
  JMSSpecificContext givenContext = (JMSSpecificContext)opts.get(CreateTopicOption.CONTEXT);

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public Listener listen(final MessageHandler handler, Codecs codecs, Map<ListenOption, Object> options) throws Exception {
  Options<ListenOption> opts = new Options<>(options);
  Context givenContext = (Context)opts.get(ListenOption.CONTEXT);
  if (givenContext != null &&
      !givenContext.isRemote()) {
    throw new IllegalArgumentException("Listening only accepts a remote context.");
  }
  MessageHandler wrappedHandler = new MessageHandler() {
    @Override
    public Reply onMessage(Message msg, Context ctx) throws Exception {
      ((JMSSpecificContext)ctx).setLatestMessage((JMSMessage)msg);
      return handler.onMessage(msg, ctx);
    }
  };
  final JMSSpecificContext context = context(givenContext);
  Listener listener = new JMSMessageHandlerGroup(context,
                          wrappedHandler,
                          codecs,
                          this,
                          opts).start();
  if (givenContext != null) {
    givenContext.addCloseable(listener);
  }
  this.broker.addCloseableForDestination(this, listener);
  this.broker.addCloseable(listener);
  return listener;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public synchronized Queue findOrCreateQueue(String name,
                      Map<CreateQueueOption, Object> options) throws Exception {
  Options<CreateQueueOption> opts = new Options<>(options);
  javax.jms.Queue queue;
  JMSSpecificContext givenContext = (JMSSpecificContext)opts.get(CreateQueueOption.CONTEXT);

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

throw new IllegalArgumentException("codec can't be null");
Options<MessageOpOption> opts = new Options<>(options);
JMSSpecificContext context = context(opts.get(MessageOpOption.CONTEXT));
Session session = context.jmsSession();

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-web-undertow

protected boolean registerHandler(HttpHandler httpHandler, Map<RegisterOption, Object> opts, Runnable cleanup) {
  final Options<RegisterOption> options = new Options<>(opts);
  final String context = options.getString(RegisterOption.PATH);
  httpHandler = wrapWithSessionHandler(httpHandler);
  if (options.has(RegisterOption.STATIC_DIR)) {
    httpHandler = wrapWithStaticHandler(httpHandler, options.getString(RegisterOption.STATIC_DIR));
  }
  if (options.getBoolean(RegisterOption.DISPATCH)) {
    httpHandler = wrapWithDispatcher(httpHandler);
  }
  final boolean replacement = pathology.add(context, options.getList(RegisterOption.VHOSTS), httpHandler);
  if (cleanup != null) {
    pathology.epilogue(httpHandler, cleanup);
  }
  if (autoStart) {
    start();
  }
  log.info("Registered web context {}", context);
  return replacement;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
  public Reply onMessage(Message msg, Context context) throws Exception {
    Reply result = handler.onMessage(msg, context);
    Options<MessageOpOption> replyOptions = new Options<>();
    replyOptions.put(PublishOption.TTL, opts.getInt(RespondOption.TTL));
    replyOptions.put(PublishOption.CONTEXT, context);
    replyOptions.put(PublishOption.PROPERTIES, result.properties());
    ((ReplyableMessage)msg).reply(result.content(), codecs.forContentType(msg.contentType()), replyOptions);
    return null;
  }
};

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public Message receive(Codecs codecs, Map<MessageOpOption, Object> options) throws Exception {
  Options<MessageOpOption> opts = new Options<>(options);
  int timeout = opts.getInt(ReceiveOption.TIMEOUT);
  JMSSpecificContext context = context(opts.get(MessageOpOption.CONTEXT));

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public Context createContext(Map<CreateContextOption, Object> options) throws Exception {
  final Options<CreateContextOption> opts = new Options<>(options);
  JMSSpecificContext context;
  boolean xa = opts.getBoolean(CreateContextOption.XA);
  ConnectionFactory cf;
  if (opts.has(CreateContextOption.HOST)) {
    cf = createRemoteConnectionFactory(opts);
  }  else {
    start();
    cf = (ConnectionFactory)lookupJNDI(xa ? JNDI_XA_CF_NAME : JNDI_CF_NAME);
  }
  if (xa) {
    context = createXAContext((XAConnectionFactory)cf, opts);
  } else {
    context = createContext(cf, opts);
  }
  if (opts.has(CreateContextOption.CLIENT_ID)) {
    context.jmsConnection().setClientID(opts.getString(CreateContextOption.CLIENT_ID));
  }
  return context;
}

代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging

@Override
public Listener subscribe(final String id, final MessageHandler handler,
             final Codecs codecs,
             final Map<SubscribeOption, Object> options) throws Exception {
  Options<SubscribeOption> opts = new Options<>(options);
  final JMSSpecificContext context = (JMSSpecificContext)context(id, opts.get(SubscribeOption.CONTEXT));
  final TopicSubscriber subscriber = context
      .jmsSession()
      .createDurableSubscriber((javax.jms.Topic) jmsDestination(),
                   id,
                   opts.getString(SubscribeOption.SELECTOR), false);
  final Listener listener = new JMSListener(handler,
                       codecs,
                       this,
                       context,
                       subscriber).start();
  Context parent = (Context)opts.get(SubscribeOption.CONTEXT);
  if (parent != null) {
    parent.addCloseable(listener);
  }
  broker().addCloseableForDestination(this, listener);
  return new Listener() {
    @Override
    public void close() throws Exception {
      listener.close();
      context.close();
    }
  };
}

相关文章