JmsDestinationLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element jmsDestinationEle = getSingleChildElement(getSingleChildElement(element, RESOURCE), JMS_DESTINATION); final String id = jmsDestinationEle.getAttribute(ATTRIBUTE_ID); final Element jmsDestinationDetailEle = getSingleChildElement(jmsDestinationEle, JMS_DESTINATION_DETAIL); final String name = getSingleChildElementTextContent(jmsDestinationDetailEle, NAME); final boolean isInbound = toBoolean(getSingleChildElementTextContent(jmsDestinationDetailEle, INBOUND)); final boolean isTemplate = toBoolean(getSingleChildElementTextContent(jmsDestinationDetailEle, TEMPLATE)); final Map<String, Object> jmsDestinationDetailProps = mapPropertiesElements(getSingleChildElement(jmsDestinationDetailEle, PROPERTIES, false), PROPERTIES); final Element jmsConnectionEle = getSingleChildElement(jmsDestinationEle, JMS_CONNECTION); final String providerType = getSingleChildElementTextContent(jmsConnectionEle, JMS_PROVIDER_TYPE); final Map<String, Object> jmsConnectionProps = mapPropertiesElements(getSingleChildElement(jmsConnectionEle, PROPERTIES, false), PROPERTIES); final String initialContextFactoryClassName = (String) jmsConnectionProps.remove(JNDI_INITIAL_CONTEXT_FACTORY_CLASSNAME); final String jndiUrl = (String) jmsConnectionProps.remove(JNDI_PROVIDER_URL); final Map<String, Object> contextPropertiesTemplateProps = mapPropertiesElements(getSingleChildElement(jmsConnectionEle, CONTEXT_PROPERTIES_TEMPLATE, false), CONTEXT_PROPERTIES_TEMPLATE); final String jndiUsername = (String) contextPropertiesTemplateProps.remove(JNDI_USERNAME); final String jndiPassword = (String) contextPropertiesTemplateProps.remove(JNDI_PASSWORD); final Map<String, Object> jndiProperties = contextPropertiesTemplateProps.entrySet().stream() .filter(map -> !map.getKey().startsWith(JMS_PROPS_PREFIX) && !map.getKey().startsWith(TIBCO_JMS_PREFIX) && !SOAP_ACTION_MSG_PROP_NAME.equals(map.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); contextPropertiesTemplateProps.keySet().removeAll(jndiProperties.keySet()); final String destinationType = (String) jmsDestinationDetailProps.remove(DESTINATION_TYPE); final String connectionFactoryName = (String) jmsConnectionProps.remove(CONNECTION_FACTORY_NAME); final String destinationName = getSingleChildElementTextContent(jmsDestinationDetailEle, JMS_DESTINATION_NAME); final String destinationUsername = (String) jmsDestinationDetailProps.remove(PROPERTY_USERNAME); final String destinationPassword = (String) jmsDestinationDetailProps.remove(PROPERTY_PASSWORD); Builder builder = new Builder() .id(id) .name(name) .providerType(providerType) .initialContextFactoryClassName(initialContextFactoryClassName) .jndiUrl(jndiUrl) .jndiUsername(jndiUsername) .jndiPassword(jndiPassword) .destinationType(JmsDestination.DestinationType.fromType(destinationType)) .connectionFactoryName(connectionFactoryName) .destinationName(destinationName) .destinationUsername(destinationUsername) .destinationPassword(destinationPassword); if (!jndiProperties.isEmpty()) { builder.jndiProperties(jndiProperties); } if (isInbound) { builder.inboundDetail(this.loadInboundDetail(jmsDestinationDetailProps, contextPropertiesTemplateProps)); } else { builder.outboundDetail(this.loadOutboundDetail(isTemplate, jmsDestinationDetailProps, contextPropertiesTemplateProps)); } this.removeKeystoreGoidRefs(providerType, contextPropertiesTemplateProps); if (!contextPropertiesTemplateProps.isEmpty()) { builder.additionalProperties(contextPropertiesTemplateProps); } JmsDestination jmsDestination = builder.build(); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(jmsDestination.getId()); annotations.add(bundleEntity); jmsDestination.setAnnotations(annotations); bundle.getJmsDestinations().put(name, jmsDestination); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType();  }
@Test void testLoadInbound() { JmsDestinationLoader loader = new JmsDestinationLoader(); Bundle bundle = new Bundle(); loader.load(bundle, createJmsDestinationXml( DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), true, PROVIDER_TYPE_GENERIC) ); assertFalse(bundle.getJmsDestinations().isEmpty()); assertEquals(1, bundle.getJmsDestinations().size()); JmsDestination jmsDestination = bundle.getJmsDestinations().get("my-jms-endpoint"); verifyCommonSettings(jmsDestination); verifyGenericProviderSettings(jmsDestination); verifyInboundSettings(jmsDestination); }
@Test void testLoadOutbound() { JmsDestinationLoader loader = new JmsDestinationLoader(); Bundle bundle = new Bundle(); loader.load(bundle, createJmsDestinationXml( DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), false, PROVIDER_TYPE_GENERIC) ); assertFalse(bundle.getJmsDestinations().isEmpty()); assertEquals(1, bundle.getJmsDestinations().size()); JmsDestination jmsDestination = bundle.getJmsDestinations().get("my-jms-endpoint"); verifyCommonSettings(jmsDestination); verifyGenericProviderSettings(jmsDestination); verifyOutboundSettings(jmsDestination); }
@Test void testLoadTibcoEmsProvider() { JmsDestinationLoader loader = new JmsDestinationLoader(); Bundle bundle = new Bundle(); loader.load(bundle, createJmsDestinationXml( DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), true, PROVIDER_TYPE_TIBCO_EMS) ); assertFalse(bundle.getJmsDestinations().isEmpty()); assertEquals(1, bundle.getJmsDestinations().size()); JmsDestination jmsDestination = bundle.getJmsDestinations().get("my-jms-endpoint"); verifyCommonSettings(jmsDestination); verifyInboundSettings(jmsDestination); verifyTibcoEmsProviderSettings(jmsDestination); }
@Test void testLoadWebShpereMqOverLdapProvider() { JmsDestinationLoader loader = new JmsDestinationLoader(); Bundle bundle = new Bundle(); loader.load(bundle, createJmsDestinationXml( DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), true, PROVIDER_TYPE_WEBSPHERE_MQ_OVER_LDAP) ); assertFalse(bundle.getJmsDestinations().isEmpty()); assertEquals(1, bundle.getJmsDestinations().size()); JmsDestination jmsDestination = bundle.getJmsDestinations().get("my-jms-endpoint"); verifyCommonSettings(jmsDestination); verifyInboundSettings(jmsDestination); verifyWebShpereMqOverLdapProviderSettings(jmsDestination); }