@Test
 public void getParameterSummaryParameterWithEmptyComment() throws Exception {
   when(elements.getDocComment(executableElement))
       .thenReturn(
           "\n"
               + "     Bla bla bla\n"
               + "     \n"
               + "     @param name the name\n"
               + "     @param content");
   JavaDocUtils javaDocUtils = new JavaDocUtils(elements);
   assertTrue(StringUtils.isBlank(javaDocUtils.getParameterSummary("content", executableElement)));
 }
  public void setScope(String scope) {
    if (StringUtils.isBlank(scope)) {
      // ignore and use defaults
      return;
    }

    PropertyScope ps = PropertyScope.get(scope.toLowerCase().trim());
    if (ps == null) {
      throw new IllegalArgumentException(
          String.format("'%s' is not a valid property scope.", scope));
    }
    this.scope = ps;
  }
示例#3
0
  public String getStatement(ImmutableEndpoint endpoint) {
    String writeStmt = endpoint.getEndpointURI().getAddress();
    String str;
    if ((str = getQuery(endpoint, writeStmt)) != null) {
      writeStmt = str;
    }
    writeStmt = StringUtils.trimToEmpty(writeStmt);
    if (StringUtils.isBlank(writeStmt)) {
      throw new IllegalArgumentException("Missing statement");
    }

    return writeStmt;
  }
示例#4
0
  /** {@inheritDoc} */
  public String getDomainName() {
    // TODO add some config options to the JmxAgent
    String domain = DEFAULT_JMX_DOMAIN_PREFIX;
    String instanceId =
        StringUtils.defaultIfEmpty(MuleManager.getInstance().getId(), StringUtils.EMPTY);
    if (instanceId.length() > 0) {
      domain += "." + instanceId;
    }

    JmxRegistrationContext ctx = JmxRegistrationContext.getCurrent();

    String resolvedDomain = ctx.getResolvedDomain();
    if (StringUtils.isBlank(resolvedDomain)) {
      domain = resolveDomainClash(domain);
      ctx.setResolvedDomain(domain);
    }

    return domain;
  }
示例#5
0
  @Override
  public void processReplyTo(MuleEvent event, MuleMessage returnMessage, Object replyTo)
      throws MuleException {
    Destination replyToDestination = null;
    MessageProducer replyToProducer = null;
    Session session = null;
    try {
      // now we need to send the response
      if (replyTo instanceof Destination) {
        replyToDestination = (Destination) replyTo;
      }
      if (replyToDestination == null) {
        super.processReplyTo(event, returnMessage, replyTo);
        return;
      }

      // This is a work around for JmsTransformers where the current endpoint needs
      // to be set on the transformer so that a JMSMessage can be created correctly (the transformer
      // needs a Session)
      Class srcType = returnMessage.getPayload().getClass();
      for (Iterator iterator = getTransformers().iterator(); iterator.hasNext(); ) {
        Transformer t = (Transformer) iterator.next();
        if (t.isSourceDataTypeSupported(DataTypeFactory.create(srcType))) {
          if (t.getEndpoint() == null) {
            t.setEndpoint(getEndpoint(event, "jms://temporary"));
            break;
          }
        }
      }
      returnMessage.applyTransformers(getTransformers());
      Object payload = returnMessage.getPayload();

      if (replyToDestination instanceof Topic
          && replyToDestination instanceof Queue
          && connector.getJmsSupport() instanceof Jms102bSupport) {
        logger.error(
            StringMessageUtils.getBoilerPlate(
                "ReplyTo destination implements both Queue and Topic "
                    + "while complying with JMS 1.0.2b specification. "
                    + "Please report your application server or JMS vendor name and version "
                    + "to dev<_at_>mule.codehaus.org or http://mule.mulesource.org/jira"));
      }

      final boolean topic = connector.getTopicResolver().isTopic(replyToDestination);
      session = connector.getSession(false, topic);
      Message replyToMessage = JmsMessageUtils.toMessage(payload, session);

      processMessage(replyToMessage, event);
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Sending jms reply to: "
                + replyToDestination
                + "("
                + replyToDestination.getClass().getName()
                + ")");
      }
      replyToProducer =
          connector.getJmsSupport().createProducer(session, replyToDestination, topic);

      // QoS support
      MuleMessage eventMsg = event.getMessage();
      String ttlString = (String) eventMsg.removeProperty(JmsConstants.TIME_TO_LIVE_PROPERTY);
      String priorityString = (String) eventMsg.removeProperty(JmsConstants.PRIORITY_PROPERTY);
      String persistentDeliveryString =
          (String) eventMsg.removeProperty(JmsConstants.PERSISTENT_DELIVERY_PROPERTY);

      String correlationIDString = replyToMessage.getJMSCorrelationID();
      if (StringUtils.isBlank(correlationIDString)) {
        correlationIDString = (String) eventMsg.getProperty(JmsConstants.JMS_MESSAGE_ID);
        replyToMessage.setJMSCorrelationID(correlationIDString);
      }

      event.getService().getStatistics().incSentReplyToEvent();

      final ImmutableEndpoint endpoint = event.getEndpoint();
      if (ttlString == null && priorityString == null && persistentDeliveryString == null) {
        connector.getJmsSupport().send(replyToProducer, replyToMessage, topic, endpoint);
      } else {
        long ttl = Message.DEFAULT_TIME_TO_LIVE;
        int priority = Message.DEFAULT_PRIORITY;

        if (ttlString != null) {
          ttl = Long.parseLong(ttlString);
        }
        if (priorityString != null) {
          priority = Integer.parseInt(priorityString);
        }
        boolean persistent =
            StringUtils.isNotBlank(persistentDeliveryString)
                ? Boolean.valueOf(persistentDeliveryString)
                : connector.isPersistentDelivery();

        connector
            .getJmsSupport()
            .send(replyToProducer, replyToMessage, persistent, priority, ttl, topic, endpoint);
      }

      logger.info(
          "Reply Message sent to: "
              + replyToDestination
              + " with correlationID:"
              + correlationIDString);
    } catch (Exception e) {
      throw new DispatchException(
          JmsMessages.failedToCreateAndDispatchResponse(replyToDestination),
          returnMessage,
          null,
          e);
    } finally {
      connector.closeQuietly(replyToProducer);

      final Transaction transaction = TransactionCoordination.getInstance().getTransaction();
      if (transaction == null) {
        if (logger.isDebugEnabled()) {
          logger.debug("Closing non-TX replyTo session: " + session);
        }
        connector.closeQuietly(session);
      } else if (logger.isDebugEnabled()) {
        logger.debug("Not closing TX replyTo session: " + session);
      }
    }
  }