當前位置: 首頁>>代碼示例>>Java>>正文


Java ActivationConfigProperty類代碼示例

本文整理匯總了Java中javax.ejb.ActivationConfigProperty的典型用法代碼示例。如果您正苦於以下問題:Java ActivationConfigProperty類的具體用法?Java ActivationConfigProperty怎麽用?Java ActivationConfigProperty使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ActivationConfigProperty類屬於javax.ejb包,在下文中一共展示了ActivationConfigProperty類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: messageDrivenBean

import javax.ejb.ActivationConfigProperty; //導入依賴的package包/類
private static <T> JMSContextMock messageDrivenBean(T bean, Class<? extends T> beanType) {
    if (MessageListener.class.isAssignableFrom(beanType)) {
        MessageDriven md = beanType.getAnnotation(MessageDriven.class);
        Collection<ActivationConfigProperty> properties = asList(md.activationConfig());
        ActiveMQDestination destination = lookupDestination(properties);
        CTX.startBrokerIfAbsent();
        try {
            JMSContextMock ctx = new JMSContextMock(CTX.getConnectionFactory(),
                    lookupClientId(properties, destination.getPhysicalName()),
                    false,
                    lookupAcknowledgeMode(properties));
            createConsumer(properties, ctx.getSession(), destination)
                    .setMessageListener(new JMS20MessageListenerDecorator<>((MessageListener) bean));
            return ctx;
        } catch (JMSException e) {
            throw new EJBException(e.getLocalizedMessage(), e);
        }
    } else {
        throw new EJBException("The message driven bean \""
                + beanType.getName()
                + "\" must implement the appropriate message listener interface \""
                + MessageDriven.class.getName()
                + "\".");
    }
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:26,代碼來源:MessageDrivenContext.java

示例2: lookupDestination

import javax.ejb.ActivationConfigProperty; //導入依賴的package包/類
private static ActiveMQDestination lookupDestination(Collection<ActivationConfigProperty> properties) {
    Optional<ActivationConfigProperty> destinationType =
            properties.stream()
                    .filter(p -> "destinationType".equals(p.propertyName()))
                    .findFirst();

    String type = destinationType.orElseThrow(InvalidDestinationTypeException::new)
            .propertyValue();

    Optional<ActivationConfigProperty> destinationLookup =
            properties.stream()
                    .filter(p -> "destinationLookup".equals(p.propertyName()))
                    .findFirst();

    String jndi = destinationLookup.orElseThrow(InvalidDestinationLookupException::new)
            .propertyValue();

    return of(type)
            .map(destType -> toDestination(destType, jndi))
            .orElseThrow(InvalidDestinationTypeException::new);
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:22,代碼來源:MessageDrivenContext.java

示例3: createConsumer

import javax.ejb.ActivationConfigProperty; //導入依賴的package包/類
private static MessageConsumer createConsumer(Collection<ActivationConfigProperty> properties,
                                              Session session, Destination destination) throws JMSException {
    if (destination instanceof Topic) {
        boolean isDurable = hasTopicSubscriptionDurability(properties);
        if (isDurable) {
            String subscriptionName = lookupDurableTopicSubscriptionName(properties);
            // yet ActiveMQ 5.13.2 is JMS 1.1
            return session.createDurableSubscriber((Topic) destination, subscriptionName);
        }
    }
    return session.createConsumer(destination);
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:13,代碼來源:MessageDrivenContext.java

示例4: lookupClientId

import javax.ejb.ActivationConfigProperty; //導入依賴的package包/類
private static String lookupClientId(Collection<ActivationConfigProperty> properties, String fallback) {
    Optional<String> clientId =
            properties.stream()
                    .filter(p -> "clientId".equals(p.propertyName()))
                    .findFirst()
                    .map(ActivationConfigProperty::propertyValue);
    return clientId.orElse(fallback);
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:9,代碼來源:MessageDrivenContext.java

示例5: lookupAcknowledgeMode

import javax.ejb.ActivationConfigProperty; //導入依賴的package包/類
private static int lookupAcknowledgeMode(Collection<ActivationConfigProperty> properties) {
    Optional<Integer> acknowledgeMode =
            properties.stream()
                    .filter(p -> "acknowledgeMode".equals(p.propertyName()))
                    .findFirst()
                    .map(p -> p.propertyValue().equals("Dups_ok_acknowledge") ? DUPS_OK_ACKNOWLEDGE : AUTO_ACKNOWLEDGE);
    return acknowledgeMode.orElse(AUTO_ACKNOWLEDGE);
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:9,代碼來源:MessageDrivenContext.java

示例6: hasTopicSubscriptionDurability

import javax.ejb.ActivationConfigProperty; //導入依賴的package包/類
private static boolean hasTopicSubscriptionDurability(Collection<ActivationConfigProperty> properties) {
    Optional<ActivationConfigProperty> property = properties.stream()
            .filter(p -> "subscriptionDurability".equals(p.propertyName()))
            .findFirst();

    if (!property.isPresent()) {
        return false;
    }

    return property.map(ActivationConfigProperty::propertyValue)
            .map(v -> "Durable".equals(v) ? TRUE : ("NonDurable".equals(v) ? FALSE : null))
            .orElseThrow(InvalidDestinationLookupException::new);
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:14,代碼來源:MessageDrivenContext.java

示例7: lookupDurableTopicSubscriptionName

import javax.ejb.ActivationConfigProperty; //導入依賴的package包/類
private static String lookupDurableTopicSubscriptionName(Collection<ActivationConfigProperty> properties) {
    return properties.stream()
            .filter(p -> "subscriptionName".equals(p.propertyName()))
            .findFirst()
            .map(ActivationConfigProperty::propertyValue)
            .orElseThrow(InvalidDestinationLookupException::new);
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:8,代碼來源:MessageDrivenContext.java


注:本文中的javax.ejb.ActivationConfigProperty類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。