Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one
    * or more contributor license agreements.  See the NOTICE file
    * distributed with this work for additional information
    * regarding copyright ownership.  The ASF licenses this file
    * to you under the Apache License, Version 2.0 (the
    * "License"); you may not use this file except in compliance
    * with the License.  You may obtain a copy of the License at
    * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing,
   * software distributed under the License is distributed on an
   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   * KIND, either express or implied.  See the License for the
   * specific language governing permissions and limitations
   * under the License.    
   */
  
  package org.apache.tuscany.sca.binding.jms;
  
  import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
  import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
  
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  
A processor to read the XML that describes the JMS binding... <binding.jms correlationScheme="string"? initialContextFactory="xs:anyURI"? jndiURL="xs:anyURI"? requestConnection="QName"? responseConnection="QName"? operationProperties="QName"? ...> <headers type="string"? deliveryMode="string"? timeToLive="int"? priority="string"?> <property name="NMTOKEN" type="NMTOKEN">* </headers>? <destination jndiName="xs:anyURI" type="string"? create="string"?> <property name="NMTOKEN" type="NMTOKEN">* </destination>? <connectionFactory jndiName="xs:anyURI" create="string"?> <property name="NMTOKEN" type="NMTOKEN">* </connectionFactory>? <activationSpec name="xs:anyURI" create="string"?> <property name="NMTOKEN" type="NMTOKEN">* </activationSpec>? <response> <destination jndiName="xs:anyURI" type="string"? create="string"?> <property name="NMTOKEN" type="NMTOKEN">* </destination>? <connectionFactory jndiName="xs:anyURI" create="string"?> <property name="NMTOKEN" type="NMTOKEN">* </connectionFactory>? <activationSpec name="xs:anyURI" create="string"?> <property name="NMTOKEN" type="NMTOKEN">* </activationSpec>? <wireFormat.someWireFormat/>? </response>? <complexType name="SubscriptionHeaders"> <attribute name="JMSSelector" type="string"/> </complexType> <resourceAdapter name="NMTOKEN">? <property name="NMTOKEN" type="NMTOKEN">* </resourceAdapter>? <operationProperties name="string" selectedOperation="string"?> <property name="NMTOKEN" type="NMTOKEN">* <headers type="string"? deliveryMode="string"? timeToLive="int"? priority="string"?> <property name="NMTOKEN" type="NMTOKEN">* </headers>? </operationProperties>* <wireFormat.someWireFormat/>? </binding.jms> Parsing error messages are recorded locally and reported as validation exceptions. Parsing warnings do not cause validation exceptions.

Version:
$Rev: 1025750 $ $Date: 2010-10-20 22:08:56 +0100 (Wed, 20 Oct 2010) $
 
 
     private PolicyFactory policyFactory;
 
     public JMSBindingProcessor(FactoryExtensionPoint modelFactoriesStAXArtifactProcessor<ObjectextensionProcessor) {
         this. = modelFactories.getFactory(PolicyFactory.class);
         this. = new PolicySubjectProcessor();
 
         this. = 
             new ConfiguredOperationProcessor(modelFactories);
         this. = extensionProcessor;
     }
    
    
Report a error.

Parameters:
problems
message
model
 
     private void warning(Monitor monitorString messageObject modelObject... messageParameters) {
         if (monitor != null) {
             Problem problem = monitor.createProblem(this.getClass().getName(), "binding-jms-validation-messages".modelmessage, (Object[])messageParameters);
     	    monitor.problem(problem);
         }        
     }
     
    
Report an error. One side effect is that error messages are saved for future validation calls.

Parameters:
problems
message
model
 
     private void error(Monitor monitorString messageObject modelObject... messageParameters) {
         if (monitor != null) {
             Problem problem = monitor.createProblem(this.getClass().getName(), "binding-jms-validation-messages".modelmessage, (Object[])messageParameters);
      	    monitor.problem(problem);
         }        
     }
 
     public QName getArtifactType() {
         return .;
     }
 
     public Class<JMSBindinggetModelType() {
         return JMSBinding.class;
     }
 
         Monitor monitor = context.getMonitor();
         JMSBinding jmsBinding = new JMSBinding();
         // Reset validation message to keep track of validation issues.
 
         // Read policies
         .readPolicies(jmsBindingreader);
 
         // Read binding name
         String name = reader.getAttributeValue(null"name");
         if (name != null) {
             jmsBinding.setName(name);
         }
 
         // Read binding URI
         String uri = reader.getAttributeValue(null"uri");
         if (uri != null && uri.length() > 0) {
             parseURI(urijmsBindingmonitor);
         }
 
         // Read correlation scheme
         QName correlationScheme = StAXHelper.getAttributeAsQName(reader"correlationScheme");
         if (correlationScheme != null) {
             if (..equals(correlationScheme.getNamespaceURI()) && ..contains(correlationScheme.getLocalPart())) {
                 jmsBinding.setCorrelationScheme(correlationScheme.getLocalPart());
             } else {
             	error(monitor"InvalidCorrelationScheme"readercorrelationScheme);
             }
         }
 
         // Read initial context factory
         String initialContextFactory = getURIString(reader"initialContextFactory");
         if (initialContextFactory != null && initialContextFactory.length() > 0) {
             jmsBinding.setInitialContextFactoryName(initialContextFactory);
         }
 
         // Read JNDI URL
         String jndiURL = getURIString(reader"jndiURL");
         if (jndiURL != null && jndiURL.length() > 0) {
             jmsBinding.setJndiURL(jndiURL);
         }
 
         // Read message processor class name
         // TODO - maintain this for the time being but move over to 
         //        configuring wire formats instead of message processors
         String messageProcessorName = reader.getAttributeValue(null"messageProcessor");
         if (messageProcessorName != null && messageProcessorName.length() > 0) {
             if ("XMLTextMessage".equalsIgnoreCase(messageProcessorName)) {
                 // may be overwritten be real wire format later
                 jmsBinding.setRequestWireFormat(new WireFormatJMSTextXML());
                 jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
             } else if ("TextMessage".equalsIgnoreCase(messageProcessorName)) {
                 // may be overwritten be real wire format later
                 jmsBinding.setRequestWireFormat(new WireFormatJMSText());
                 jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
             } else if ("ObjectMessage".equalsIgnoreCase(messageProcessorName)) {
                 // may be overwritten be real wire format later
                 jmsBinding.setRequestWireFormat(new WireFormatJMSObject());
                 jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
             } else {
                 jmsBinding.setRequestMessageProcessorName(messageProcessorName);
                 jmsBinding.setResponseMessageProcessorName(messageProcessorName);
                 // exploit the text wire format code to drive the user selected 
                 // message processor
                 jmsBinding.setRequestWireFormat(new WireFormatJMSText());
                 jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
             }
         }
 
         String requestConnectionName = reader.getAttributeValue(null"requestConnection");
         if (requestConnectionName != null && requestConnectionName.length() > 0) {
             jmsBinding.setRequestConnectionName(getQNameValue(readerrequestConnectionName));
         }
         String responseConnectionName = reader.getAttributeValue(null"responseConnection");
         if (responseConnectionName != null && responseConnectionName.length() > 0) {
             jmsBinding.setResponseConnectionName(getQNameValue(readerresponseConnectionName));
         }
 
         String operationPropertiesName = reader.getAttributeValue(null"operationProperties");
         if (operationPropertiesName != null && operationPropertiesName.length() > 0) {
             jmsBinding.setOperationPropertiesName(getQNameValue(readeroperationPropertiesName));
         }
 
         // Read sub-elements of binding.jms
         boolean endFound = false;
         while (!endFound) {
             int fg = reader.next();
             switch (fg) {
                 case :
                     String elementName = reader.getName().getLocalPart();
                     if ("destination".equals(elementName)) {
                         parseDestination(readerjmsBindingmonitor);
                     } else if ("connectionFactory".equals(elementName)) {
                         parseConnectionFactory(readerjmsBindingmonitor);
                     } else if ("activationSpec".equals(elementName)) {
                         parseActivationSpec(readerjmsBindingmonitor);
                     } else if ("response".equals(elementName)) {
                         parseResponse(readerjmsBindingcontext);
                     } else if ("resourceAdapter".equals(elementName)) {
                         parseResourceAdapter(readerjmsBindingmonitor);
                     } else if ("headers".equals(elementName)) {
                         parseHeaders(readerjmsBindingmonitor);
                     } else if ("operationProperties".equals(elementName)) {
                         parseOperationProperties(readerjmsBindingmonitor);
                     } else if ("messageSelection".equals(elementName)) {
                         parseSubscriptionHeaders(readerjmsBinding);
                     } else if (..equals(reader.getName())) {
                         ConfiguredOperation confOp = .read(readercontext);
                         if (confOp != null) {
                             ((OperationsConfigurator)jmsBinding).getConfiguredOperations().add(confOp);
                         }
                     } else {
                         Object extension = .read(readercontext);
                         if (extension != null) {
                             if (extension instanceof WireFormat) {
                                 if (jmsBinding.getRequestWireFormat() == null) {
                                     jmsBinding.setRequestWireFormat((WireFormatextension);
                                 } else {
                                     error(monitor"WireFormatAlreadyDefined"readerextension.toString());
                                 }
                             } else if (extension instanceof OperationSelector) {
                                 if (jmsBinding.getOperationSelector() == null) {
                                     jmsBinding.setOperationSelector((OperationSelectorextension);
                                 } else {
                                     error(monitor"OpSelectorAlreadyDefined"readerextension.toString());
                                 }
 
                             } else {
                                 error(monitor"UnexpectedElement"readerextension.toString());
                             }
                         }
                     }
                     //reader.next();
                     break;
                 case :
                     QName x = reader.getName();
                     if (..equals(x.getLocalPart())) break;
                     // This assumption is not captured in schema, which isn't good, but will probably be fine for now.
                     // A better solution might be to require each processor to advance to its own END_ELEMENT.
                     if (x.getLocalPart().startsWith("wireFormat.") || x.getLocalPart().startsWith("operationSelector.")) {                         
                         break;
                     }
                     if (x.equals(.)) {
                         endFound = true;
                     } else {
                     	error(monitor"UnexpectedElement: expected " + . + ", found " + x.toString(), 
                     	      readerx.toString());
                     }
             }
         }
         
         // if no operation selector is specified then assume the default
         if (jmsBinding.getOperationSelector() == null){
             jmsBinding.setOperationSelector(new OperationSelectorJMSDefault());
         }
         
         // if no request wire format specified then assume the default
         if (jmsBinding.getRequestWireFormat() == null){
             jmsBinding.setRequestWireFormat(new WireFormatJMSDefault());
         }
         
         // if no response wire format specific then assume the same as the request
         if (jmsBinding.getResponseWireFormat() == null){
             jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat());
          }
 
         validatejmsBindingmonitor );
 
         return jmsBinding;
     }
 
     protected void parseURI(String uriJMSBinding jmsBindingMonitor monitor) {
         if (!(uri.startsWith("jms:jndi:") || uri.startsWith("jms:queue:") || uri.startsWith("jms:topic:"))) {
             error(monitor"MustStartWithSchema"jmsBindinguri);
             return;
         }
         int i = uri.indexOf('?');            
         if (i >= 0) {
         	StringTokenizer st = new StringTokenizer(uri.substring(i+1),"&");
         	while (st.hasMoreTokens()) {
         	    String s = st.nextToken();
         	    if (s.startsWith("jndiConnectionFactoryName=")) {
         	        jmsBinding.setConnectionFactoryName(s.substring(26));
                     } else if (s.startsWith("deliveryMode=")) {
                         jmsBinding.setURIJMSDeliveryMode("persistent".equals(s.substring(13)));
                     } else if (s.startsWith("priority=")) {
                         jmsBinding.setURIJMSPriority(Integer.parseInt(s.substring(9)));
                     } else if (s.startsWith("timeToLive=")) {
                         jmsBinding.setURIJMSTimeToLive(Long.parseLong(s.substring(11)));
                     } else if (s.startsWith("selector='")) {
                         String selector = s.substring(10);
                         if (selector.startsWith("\"") || selector.startsWith("'")) {
                             selector = selector.substring(1, selector.length());
                         }
                         if (selector.endsWith("\"") || selector.endsWith("'")) {
                             selector = selector.substring(0, selector.length() - 1);
                         }
                         jmsBinding.setURIJMSSelector(selector);
                     } else if (s.startsWith("type")) {
                     	String type = s.substring(5);
                     	jmsBinding.setJMSURIType(type);                    	
                     } else {
                     	error(monitor"UnknownTokenInURI"jmsBindingsuri);
                     	return;
                     }
         		}
         	int j=uri.indexOf(':', 4);
         	jmsBinding.setDestinationName(uri.substring(j+1, i));
         	jmsBinding.setDestinationType(uri.substring(4, j));
         } else {
            int j=uri.indexOf(':', 4);
            jmsBinding.setDestinationName(uri.substring(j+1));
            jmsBinding.setDestinationType(uri.substring(4, j));
         }
         jmsBinding.setJMSURI(uri);
     }
 
     public void resolve(JMSBinding modelModelResolver resolverProcessorContext contextthrows ContributionResolveException {
         if (model.getRequestConnectionName() != null) {
             model.setRequestConnectionBinding(getConnectionBinding(model"requestConnection"model.getRequestConnectionName(), resolvercontext));
         }
         if (model.getResponseConnectionName() != null) {
             model.setResponseConnectionBinding(getConnectionBinding(model"responseConnection"model.getResponseConnectionName(), resolvercontext));
         }
         if (model.getOperationPropertiesName() != null) {
             model.setOperationPropertiesBinding(getConnectionBinding(model"operationProperties"model.getOperationPropertiesName(), resolvercontext));
         }
     }
 
     private JMSBinding getConnectionBinding(JMSBinding modelString attrNameQName bindingNameModelResolver resolverProcessorContext context) {
         JMSBinding binding = new JMSBinding();
         binding.setTargetNamespace(bindingName.getNamespaceURI());
         binding.setName(bindingName.getLocalPart());
         binding.setUnresolved(true);
         binding = resolver.resolveModel(JMSBinding.classbindingcontext);
         if (binding.isUnresolved())
             error(context.getMonitor(), "BindingNotFound"modelattrNamebindingName);
         return binding;
     }
 
     private void parseDestination(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
     	jmsBinding.setIsDestinationSpecified(true);
         String name = getURIString(reader"jndiName");
         if (name != null && name.length() > 0) {
             jmsBinding.setDestinationName(name);
         }
 
         String type = reader.getAttributeValue(null"type");                
         if (type != null && type.length() > 0) {
             if (..equalsIgnoreCase(type)) {
                 jmsBinding.setDestinationType(.);
             } else if (..equalsIgnoreCase(type)) {
                 jmsBinding.setDestinationType(.);
             } else {
             	error(monitor"InvalidDestinationType"readertype);
             }            
         }
 
         String create = reader.getAttributeValue(null"create");
         if (create != null && create.length() > 0) {
         	validateCreate(createreadermonitor);
             jmsBinding.setDestinationCreate(create);
         }
 
         jmsBinding.getDestinationProperties().putAll(parseBindingProperties(readermonitor));
         
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_IF_NOT_EXIST"reader);
             }
         }
         if (jmsBinding.getDestinationCreate().equals(.)) {
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_NEVER"reader);
             }
         }
     }
 
     private void parseConnectionFactory(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
         String name = getURIString(reader"jndiName");
         if (name != null && name.length() > 0) {
             jmsBinding.setConnectionFactoryName(name);
         } else {
             error(monitor"MissingConnectionFactoryName"reader);
         }
 
         String create = reader.getAttributeValue(null"create");
         if (create != null && create.length() > 0) {
         	validateCreate(createreadermonitor);
             jmsBinding.setConnectionFactoryCreate(create);
         }
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_IF_NOT_EXIST"reader);
             }
         }
         if (jmsBinding.getConnectionFactoryCreate().equals(.)) {
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_NEVER"reader);
             }
         }
         
         jmsBinding.getConnectionFactoryProperties().putAll(parseBindingProperties(readermonitor));
     }
 
     private void parseActivationSpec(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
         String name = reader.getAttributeValue(null"jndiName");        
         if (name != null && name.length() > 0) {
             jmsBinding.setActivationSpecName(name);            
         }
 
         String create = reader.getAttributeValue(null"create");
         if (create != null && create.length() > 0) {
         	validateCreate(createreadermonitor);
             jmsBinding.setActivationSpecCreate(create);
         }
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_IF_NOT_EXIST"reader);
             }
         }
         if (jmsBinding.getActivationSpecCreate().equals(.)) {
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_NEVER"reader);
             }
         }
 
         jmsBinding.getActivationSpecProperties().putAll(parseBindingProperties(readermonitor));
     }
 
     private void parseResponseDestination(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
         String name = getURIString(reader"jndiName");
         if (name != null && name.length() > 0) {
             jmsBinding.setResponseDestinationName(name);
         }
 
         String type = reader.getAttributeValue(null"type");        
         if (type != null && type.length() > 0) {
             warning(monitor"DoesntProcessResponseDestinationType"jmsBinding);
             if (..equalsIgnoreCase(type)) {
                 jmsBinding.setResponseDestinationType(.);
             } else if (..equalsIgnoreCase(type)) {
                 jmsBinding.setResponseDestinationType(.);
             } else {
                 error(monitor"InvalidResponseDestinationType"readertype);
             }
         }
 
         String create = reader.getAttributeValue(null"create");
         if (create != null && create.length() > 0) {
         	validateCreate(createreadermonitor);
             jmsBinding.setResponseDestinationCreate(create);
         }
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_IF_NOT_EXIST"reader);
             }
         }
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_NEVER"reader);
             }
         }
 
         jmsBinding.getResponseDestinationProperties().putAll(parseBindingProperties(readermonitor));
     }
 
 	private void parseResponseConnectionFactory(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
         String name = getURIString(reader"jndiName");
         if (name != null && name.length() > 0) {
             jmsBinding.setResponseConnectionFactoryName(name);            
         } else {
             warning(monitor"MissingResponseConnectionFactory"reader);
         }
         String create = reader.getAttributeValue(null"create");
         if (create != null && create.length() > 0) {
         	validateCreate(createreadermonitor);
             jmsBinding.setResponseConnectionFactoryCreate(create);
         }
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_IF_NOT_EXIST"reader);
             }
         }
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_NEVER"reader);
             }
         }
         jmsBinding.getResponseConnectionFactoryProperties().putAll(parseBindingProperties(readermonitor));
     }
 
     private void parseResponseActivationSpec(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
         String name = reader.getAttributeValue(null"jndiName");
         if (name != null && name.length() > 0) {
             jmsBinding.setResponseActivationSpecName(name);            
         }
         String create = reader.getAttributeValue(null"create");
         if (create != null && create.length() > 0) {
         	validateCreate(createreadermonitor);
             jmsBinding.setResponseActivationSpecCreate(create);
         }
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_IF_NOT_EXIST"reader);
             }
         }
             if (name == null || name.length() < 1) {
                 error(monitor"MissingNameForCREATE_NEVER"reader);
             }
         }
         jmsBinding.getResponseActivationSpecProperties().putAll(parseBindingProperties(readermonitor));
     }
 
     private void validateCreate(String createXMLStreamReader readerMonitor monitor) {
     	if (..equals(create)) {
     		return;
     	}
     	if (..equals(create)) {
     		return;
     	}
     		return;
     	}
     	error(monitor"InvalidCreate"readercreate);
 	}
 
     private void parseResponse(XMLStreamReader readerJMSBinding jmsBindingProcessorContext contextthrows ContributionReadExceptionXMLStreamException {
         // Read sub-elements of response
         Monitor monitor = context.getMonitor();
         while (true) {
             switch (reader.next()) {
                 case :
                     String elementName = reader.getName().getLocalPart();
                     if ("destination".equals(elementName)) {
                         parseResponseDestination(readerjmsBindingcontext.getMonitor());
                     } else if ("connectionFactory".equals(elementName)) {
                         parseResponseConnectionFactory(readerjmsBindingmonitor);
                     } else if ("activationSpec".equals(elementName)) {
                         parseResponseActivationSpec(readerjmsBindingmonitor);
                     } else {
                         Object extension = .read(readercontext);
                         if (extension != null) {
                             if (extension instanceof WireFormat) {
                                 if (jmsBinding.getResponseWireFormat() == null) {
                                     jmsBinding.setResponseWireFormat((WireFormat)extension);
                                 } else {
                                     error(context.getMonitor(), "ResponseWireformatAlreadyDefined"readerextension.toString());
                                 }
                             } else {
                                 error(context.getMonitor(), "UnexpectedElement"readerextension.toString());
                             }
                         }
                         reader.next();
                     }
                     //reader.next();
                     break;
                 case :
                     QName x = reader.getName();
                     if (x.getLocalPart().equals("response")) {
                         return;
                     } else {
                     	error(context.getMonitor(), "UnexpectedResponseElement"readerx.toString());
                     }
             }
         }
     }
 
     private void parseResourceAdapter(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
         String name = reader.getAttributeValue(null"name");        
         if (name != null && name.length() > 0) {
             jmsBinding.setResourceAdapterName(name);            
         } else {
             error(monitor"MissingResourceAdapterName"reader);
         }
         jmsBinding.getResourceAdapterProperties().putAll(parseBindingProperties(readermonitor));
     }

    
<headers JMSType="string"? JMSCorrelationID="string"? JMSDeliveryMode="PERSISTENT or NON_PERSISTENT"? timeToLive="long"? JMSPriority="0 .. 9"?> <property name="NMTOKEN" type="NMTOKEN"?>* </headers>?
 
     private void parseHeaders(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
         String jmsType = reader.getAttributeValue(null"type");
         if (jmsType != null && jmsType.length() > 0) {
             jmsBinding.setJMSHeaderType(jmsType);
         }
 
         String jmsDeliveryMode = reader.getAttributeValue(null"deliveryMode");
         if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) {
             if ("persistent".equalsIgnoreCase(jmsDeliveryMode)) {
                 jmsBinding.setJMSHeaderDeliveryMode(true);
             } else if ("nonpersistent".equalsIgnoreCase(jmsDeliveryMode)) {
                 jmsBinding.setJMSHeaderDeliveryMode(false);
             } else {
                 error(monitor"InvalidJMSDeliveryMode"jmsBindingjmsDeliveryMode);
             }
         }
 
         String jmsTimeToLive = reader.getAttributeValue(null"timeToLive");
         if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) {
             jmsBinding.setJMSHeaderTimeToLive(Long.parseLong(jmsTimeToLive));
         }
 
         String jmsPriority = reader.getAttributeValue(null"priority");
         if (jmsPriority != null && jmsPriority.length() > 0) {
             try {
                 int p = Integer.parseInt(jmsPriority);
                 if (p >= 0 && p <= 9) {
                     jmsBinding.setJMSHeaderPriority(p);
                 } else {
                     warning(monitor"InvalidJMSPriority"jmsBindingjmsPriority);
                 }
             } catch (NumberFormatException ex) {
                 error(monitor"InvalidJMSPriority"jmsBindingjmsPriority);
             }
         }
 
         while (true) {
             switch (reader.next()) {
                 case :
                     if (reader.getName().getLocalPart().equals("property")) {
                         parseProperty(readerjmsBinding);
                     }
                     break;
                 case :
                     QName x = reader.getName();
                     if (x.getLocalPart().equals("headers")) {
                         return;
                     } else {
                         error(monitor"UnexpectedResponseElement"readerx.toString());
                     }
             }
         }
     }
     
     private void parseProperty(XMLStreamReader readerJMSBinding jmsBindingthrows XMLStreamException {
         jmsBinding.setHeaderstrue );
         String name = reader.getAttributeValue(null"name");
         QName typeName = StAXHelper.getAttributeAsQName(reader"type");
         String type = typeName == null ? null : typeName.getLocalPart(); 
         
         if (name != null && name.length() > 0) {
             Object value = reader.getElementText();
            
             if ("boolean".equalsIgnoreCase(type)) {
                 value = Boolean.parseBoolean((String)value);
             } else if ("byte".equalsIgnoreCase(type)) {
                 value = Byte.parseByte(((String)value));
             } else if ("short".equalsIgnoreCase(type)) {
                 value = Short.parseShort((String)value);
             } else if ("int".equalsIgnoreCase(type)) {
                 value = Integer.parseInt((String)value);
             } else if ("long".equalsIgnoreCase(type)) {
                 value = Long.parseLong((String)value);
             } else if ("float".equalsIgnoreCase(type)) {
                 value = Float.parseFloat((String)value);
             } else if ("double".equalsIgnoreCase(type)) {
                 value = Double.parseDouble((String)value);
             } else if ("String".equalsIgnoreCase(type)) {
                 // its already a string
             }
             jmsBinding.setProperty(namevalue);
         }
     }

    
<operationProperties name="string" selectedOperation="string"?> <property name="NMTOKEN" type="NMTOKEN"?>* <headers JMSType="string"? JMSCorrelationID="string"? JMSDeliveryMode="PERSISTENT or NON_PERSISTENT"? timeToLive="long"? JMSPriority="0 .. 9"?> <property name="NMTOKEN" type="NMTOKEN"?>* </headers>? </operationProperties>*
 
     private void parseOperationProperties(XMLStreamReader readerJMSBinding jmsBindingMonitor monitorthrows XMLStreamException {
         
         if (jmsBinding.getOperationPropertiesName() != null) {
             error(monitor"DuplicateOperationProperties"jmsBinding);
         }
         
         String opName = reader.getAttributeValue(null"name");
         if (opName == null || opName.length() < 1) {
             error(monitor"MissingJMSOperationPropertyName"jmsBinding);
             return;
         }
         // Since nativeOpName, headers, and property elements are optional, must add opName.
         jmsBinding.addOperationName(opName);
         String nativeOpName = reader.getAttributeValue(null"selectedOperation"); // optional
         if (nativeOpName != null && nativeOpName.length() > 0) {
             jmsBinding.setNativeOperationName(opNamenativeOpName);
         }
 
         Map<StringBindingPropertyprops = new HashMap<StringBindingProperty>();
         while (true) {
             switch (reader.next()) {
                 case :
                     if (reader.getName().getLocalPart().equals("headers")) { // optional
                         parseOperationHeaders(readerjmsBindingopNamemonitor);
                     } else if (reader.getName().getLocalPart().equals("property")) { // optional
                     	processProperty(readerpropsmonitor);
                     }
                 break;
                 case :
                     if (reader.isEndElement()) {
                         QName x = reader.getName();
                         if (x.getLocalPart().equals("headers")) {
                             break;
                         }
                         if (x.getLocalPart().equals("property")) {
                             break;
                         }
                         if (x.getLocalPart().equals("operationProperties")) {
                         	jmsBinding.getOperationPropertiesProperties(opName).putAll(props);
                             return;
                         } else {
                             error(monitor"UnexpectedResponseElement"readerx.toString());
                         }
                     }
             }
         }
     }
 
     private void parseOperationHeaders(XMLStreamReader readerJMSBinding jmsBindingString opNameMonitor monitorthrows XMLStreamException {
         String jmsType = reader.getAttributeValue(null"type");
         if (jmsType != null && jmsType.length() > 0) {
             jmsBinding.setOperationJMSType(opNamejmsType);
         }
 
         String jmsDeliveryMode = reader.getAttributeValue(null"deliveryMode");
         if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) {
             if ("persistent".equalsIgnoreCase(jmsDeliveryMode)) {
                 jmsBinding.setOperationJMSDeliveryMode(opNametrue);
             } else if ("nonpersistent".equalsIgnoreCase(jmsDeliveryMode)) {
                 jmsBinding.setOperationJMSDeliveryMode(opNamefalse);
             } else {
                 error(monitor"InvalidOPJMSDeliveryMode"jmsBindingjmsDeliveryMode);
             }
         }
 
         String jmsTimeToLive = reader.getAttributeValue(null"timeToLive");
         if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) {
             jmsBinding.setOperationJMSTimeToLive(opName, Long.parseLong(jmsTimeToLive));
         }
 
         String jmsPriority = reader.getAttributeValue(null"priority");
         if (jmsPriority != null && jmsPriority.length() > 0) {
             try {
                 int p = Integer.parseInt(jmsPriority);
                 if (p >= 0 && p <= 9) {
                     jmsBinding.setOperationJMSPriority(opNamep);
                 } else {
                     warning(monitor"InvalidOPJMSPriority"jmsBindingjmsPriority);
                 }
             } catch (NumberFormatException ex) {
                 error(monitor"InvalidOPJMSPriority"jmsBindingjmsPriority);
             }
         }
 
         while (true) {
             switch (reader.next()) {
                 case :
                     if (reader.getName().getLocalPart().equals("property")) {
                         parseOperationPropertyProperties(readerjmsBindingopName);
                     }
                     break;
                 case :
                     QName x = reader.getName();
                     if (x.getLocalPart().equals("headers")) {
                         return;
                     } else {
                         error(monitor"UnexpectedResponseElement"readerx.toString());
                     }
             }
         }
     }
 
     private void parseOperationPropertyProperties(XMLStreamReader readerJMSBinding jmsBindingString opNamethrows XMLStreamException {
         String propName = reader.getAttributeValue(null"name");
         QName typeName = StAXHelper.getAttributeAsQName(reader"type");
         String type = typeName == null ? null : typeName.getLocalPart(); 
         if (propName != null && propName.length() > 0) {
             Object value = reader.getElementText();
             if ("boolean".equalsIgnoreCase(type)) {
                 value = Boolean.parseBoolean((String)value);
             } else if ("byte".equalsIgnoreCase(type)) {
                 value = Byte.parseByte(((String)value));
             } else if ("short".equalsIgnoreCase(type)) {
                 value = Short.parseShort((String)value);
             } else if ("int".equalsIgnoreCase(type)) {
                 value = Integer.parseInt((String)value);
             } else if ("long".equalsIgnoreCase(type)) {
                 value = Long.parseLong((String)value);
             } else if ("float".equalsIgnoreCase(type)) {
                 value = Float.parseFloat((String)value);
             } else if ("double".equalsIgnoreCase(type)) {
                 value = Double.parseDouble((String)value);
             } else if ("String".equalsIgnoreCase(type)) {
                 // its already a string
             }
             jmsBinding.setOperationProperty(opNamepropNamevalue);
         }
     }
 
     private void parseSubscriptionHeaders(XMLStreamReader readerJMSBinding jmsBindingthrows XMLStreamException {
         String jmsSelector = reader.getAttributeValue(null"selector");
         if (jmsSelector != null && jmsSelector.length() > 0 && jmsBinding.getJMSSelector() == null) {
             jmsBinding.setJMSSelector(jmsSelector);
         }
         
         // Skip to end element
         while (reader.hasNext()) {
             if (reader.next() ==  && "messageSelection".equals(reader.getName().getLocalPart())) {
                 break;
             }
         } // end while
     }
 
     private Map<StringBindingPropertyparseBindingProperties(XMLStreamReader readerMonitor monitorthrows XMLStreamException {
     	Map<StringBindingPropertyprops = new HashMap<StringBindingProperty>();
     	String parentName = reader.getName().getLocalPart();        
         // Parse for all the properties within this element, until the end of
         // the element is reached.
     	boolean completed = false;
         while (!completed) {
             switch (reader.next()) {
                 case :
                     String elementName = reader.getName().getLocalPart();
                     if ("property".equals(elementName)) {
                     	processProperty(readerpropsmonitor);
                     }
                     break;
                 case :
                 	String endName = reader.getName().getLocalPart();
                 	if (parentName.equals(endName)) {
                 		completed = true;
                         break;
                 	}
             }
         }        
         return props;
     }
 
     private void processProperty(XMLStreamReader readerMap<StringBindingPropertypropsMonitor monitorthrows XMLStreamException {
         String name = reader.getAttributeValue(null"name");
         if (name == null || name.length() < 1) {
             error(monitor"InvalidPropertyElement"reader);
         }
         String type = reader.getAttributeValue(null"type");
         String value = reader.getElementText();
         props.put(namenew BindingProperty(nametypevalue));
     }

    
Preserve an existing public method. The method validate() is a legacy method that was called from reading am XML stream via the read(XMLStreamReader) method above. However read(XMLStreamReader) now calls validate(JMSBinding jmsBinding) and passes in the jmsBinding model. The older validate() now calls validate(JMSBinding jmsBinding) with a null model.
 
     public void validate() {
         validatenullnull );
     }
    
    
Validates JMS parsing and JMSBinding model. Validation rules are taken from the binding schema and the OSOA and OASIS specs: http://www.oasis-open.org/committees/documents.php?wg_abbrev=sca-bindings (sca-binding-jms-1.1-spec-cd01-rev4.pdf) http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications (SCA JMS Binding V1.00 )

Parameters:
jmsBinding an optional JMS binding model to check for validity.
Since:
1.4
 
     protected void validateJMSBinding jmsBindingMonitor monitor ) {        
         // If no JMSBinding model is provided, that is all the validation we can do.
         if ( jmsBinding == null ) {
             return;
         }
 
         // Connection factory should not contradict destination type.
         String connectionFactoryName = jmsBinding.getConnectionFactoryName();
         if (( connectionFactoryName != null ) && ( connectionFactoryName.length() > 0 )) {
             if (. == jmsBinding.getDestinationType()) {
                 if ( connectionFactoryName.contains"topic" )) {
                     error(monitor"DestinationQueueContradiction"jmsBindingconnectionFactoryName );
                 }
             }
             if (. == jmsBinding.getDestinationType()) {
                 if ( connectionFactoryName.contains"queue" )) {
                     error(monitor"DestinationTopicContradiction"jmsBindingconnectionFactoryName );
                 }
             }
         }
         
         // Connection factory and activation Specification are mutually exclusive.
         if (( connectionFactoryName != null ) && ( connectionFactoryName.length() > 0 )) {
             String activationSpecName = jmsBinding.getActivationSpecName();
             if ((activationSpecName != null) && (activationSpecName.length() > 0 )) {
                 error(monitor"ConnectionFactoryActivationSpecContradiction"jmsBindingconnectionFactoryNameactivationSpecName );                
             }
        }
        
        // If URI is specified, destination should not be present
        if ( ( jmsBinding.getJMSURI() != null ) && ( jmsBinding.getJMSURI().length() > 0) &&
        		(jmsBinding.isDestinationSpecified())) {
        	error(monitor"DestinationURIContradiction"jmsBindingjmsBinding.getJMSURI(), jmsBinding.getDestinationName());
        }
        
        // If activation spec and destination are both specified, they have to match
        if ( ( jmsBinding.getActivationSpecName() != null ) && (jmsBinding.getActivationSpecName().length() > 0 ) &&
        		(jmsBinding.getDestinationName() != null) && (jmsBinding.getDestinationName().length() > 0 ) ) {
        	if ( !jmsBinding.getActivationSpecName().equals(jmsBinding.getDestinationName())) {
        		error(monitor"ActivationSpecAndDestinationMismatch"jmsBindingjmsBinding.getActivationSpecName(), jmsBinding.getDestinationName());
        	}
        }
        if ( ( jmsBinding.getResponseActivationSpecName() != null ) && (jmsBinding.getResponseActivationSpecName().length() > 0 ) &&
        		(jmsBinding.getResponseDestinationName() != null ) && (jmsBinding.getResponseDestinationName().length() > 0 ) ) {
        	if ( !jmsBinding.getResponseActivationSpecName().equals(jmsBinding.getResponseDestinationName())) {
        		error(monitor"ActivationSpecAndDestinationMismatch"jmsBindingjmsBinding.getResponseActivationSpecName(), jmsBinding.getResponseDestinationName());
        	}
        }
        // If activation spec exists with create=always, a jndiName must be specified
        		(jmsBinding.getActivationSpecName() == null)) {
        	error(monitor"ActivationSpecNameRequiredForCreateAlways"jmsBinding);