View Javadoc

1   /*
2    * $Id: AbstractEndpointBuilder.java 12269 2008-07-10 04:19:03Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.endpoint;
12  
13  import org.mule.RegistryContext;
14  import org.mule.api.DefaultMuleException;
15  import org.mule.api.MuleContext;
16  import org.mule.api.MuleRuntimeException;
17  import org.mule.api.config.MuleProperties;
18  import org.mule.api.endpoint.EndpointBuilder;
19  import org.mule.api.endpoint.EndpointException;
20  import org.mule.api.endpoint.EndpointURI;
21  import org.mule.api.endpoint.ImmutableEndpoint;
22  import org.mule.api.endpoint.InboundEndpoint;
23  import org.mule.api.endpoint.OutboundEndpoint;
24  import org.mule.api.lifecycle.InitialisationException;
25  import org.mule.api.registry.ServiceDescriptorFactory;
26  import org.mule.api.registry.ServiceException;
27  import org.mule.api.routing.filter.Filter;
28  import org.mule.api.security.EndpointSecurityFilter;
29  import org.mule.api.transaction.TransactionConfig;
30  import org.mule.api.transformer.Transformer;
31  import org.mule.api.transport.ConnectionStrategy;
32  import org.mule.api.transport.Connector;
33  import org.mule.config.i18n.CoreMessages;
34  import org.mule.config.i18n.Message;
35  import org.mule.transaction.MuleTransactionConfig;
36  import org.mule.transformer.TransformerUtils;
37  import org.mule.transport.AbstractConnector;
38  import org.mule.transport.service.TransportFactory;
39  import org.mule.transport.service.TransportFactoryException;
40  import org.mule.transport.service.TransportServiceDescriptor;
41  import org.mule.util.CharSetUtils;
42  import org.mule.util.ClassUtils;
43  import org.mule.util.MapCombiner;
44  import org.mule.util.ObjectNameHelper;
45  
46  import java.util.Collections;
47  import java.util.HashMap;
48  import java.util.LinkedList;
49  import java.util.List;
50  import java.util.Map;
51  import java.util.Properties;
52  
53  /**
54   * Abstract endpoint builder used for externalizing the complex creation logic of
55   * endpoints out of the endpoint instance itself. <br/> The use of a builder allows
56   * i) Endpoints to be configured once and created in a repeatable fashion (global
57   * endpoints), ii) Allow for much more extensibility in endpoint creation for
58   * transport specific endpoints, streaming endpoints etc.<br/>
59   */
60  public abstract class AbstractEndpointBuilder implements EndpointBuilder
61  {
62  
63      public static final String PROPERTY_REMOTE_SYNC = "remoteSync";
64      public static final String PROPERTY_REMOTE_SYNC_TIMEOUT = "remoteSyncTimeout";
65  
66      protected URIBuilder uriBuilder;
67      protected Connector connector;
68      protected List transformers;
69      protected List responseTransformers;
70      protected String name;
71      protected Map properties = new HashMap();
72      protected TransactionConfig transactionConfig;
73      protected Filter filter;
74      protected Boolean deleteUnacceptedMessages;
75      protected EndpointSecurityFilter securityFilter;
76      protected Boolean synchronous;
77      protected Boolean remoteSync;
78      protected Integer remoteSyncTimeout;
79      protected String initialState = ImmutableEndpoint.INITIAL_STATE_STARTED;
80      protected String encoding;
81      protected Integer createConnector;
82      protected ConnectionStrategy connectionStrategy;
83  
84      // not included in equality/hash
85      protected String registryId = null;
86      protected MuleContext muleContext;
87  
88      public InboundEndpoint buildInboundEndpoint() throws EndpointException, InitialisationException
89      {
90          return doBuildInboundEndpoint();
91      }
92  
93      public OutboundEndpoint buildOutboundEndpoint() throws EndpointException, InitialisationException
94      {
95          return doBuildOutboundEndpoint();
96      }
97  
98      protected void setPropertiesFromProperties(Map properties)
99      {
100         synchronous = getBooleanProperty(properties, MuleProperties.SYNCHRONOUS_PROPERTY, synchronous);
101         remoteSync = getBooleanProperty(properties, PROPERTY_REMOTE_SYNC, remoteSync);
102         remoteSyncTimeout = getIntegerProperty(properties, PROPERTY_REMOTE_SYNC_TIMEOUT, remoteSyncTimeout);
103     }
104 
105     public static Boolean getBooleanProperty(Map properties, String name, Boolean dflt)
106     {
107         if (properties.containsKey(name))
108         {
109             return Boolean.valueOf((String) properties.get(name));
110         }
111         else
112         {
113             return dflt;
114         }
115     }
116 
117     public static Integer getIntegerProperty(Map properties, String name, Integer dflt)
118     {
119         if (properties.containsKey(name))
120         {
121             return Integer.decode((String) properties.get(name));
122         }
123         else
124         {
125             return dflt;
126         }
127     }
128 
129     protected InboundEndpoint doBuildInboundEndpoint() throws InitialisationException, EndpointException
130     {
131         // use an explicit value here to avoid caching
132         Map properties = getProperties();
133         // this sets values used below, if they appear as properties
134         setPropertiesFromProperties(properties);
135 
136         if (uriBuilder == null)
137         {
138             throw new MuleRuntimeException(CoreMessages.objectIsNull("uriBuilder"));
139         }
140 
141         EndpointURI endpointURI = uriBuilder.getEndpoint();
142         endpointURI.initialise();
143 
144         Connector connector = getConnector();
145 
146         if (connector != null && endpointURI != null && !connector.supportsProtocol(endpointURI.getFullScheme()))
147         {
148             throw new IllegalArgumentException(CoreMessages.connectorSchemeIncompatibleWithEndpointScheme(
149                 connector.getProtocol(), endpointURI).getMessage());
150         }
151 
152         List transformers = getInboundTransformers(connector, endpointURI);
153         List responseTransformers = getInboundEndpointResponseTransformers(connector, endpointURI);
154 
155         boolean remoteSync = getRemoteSync(connector);
156         boolean synchronous;
157         if (remoteSync)
158         {
159             synchronous = true;
160         }
161         else
162         {
163             synchronous = getSynchronous(connector, endpointURI);
164         }
165 
166         return new DefaultInboundEndpoint(connector, endpointURI, transformers, responseTransformers,
167             getName(endpointURI), getProperties(), getTransactionConfig(), getFilter(connector),
168             getDefaultDeleteUnacceptedMessages(connector), getSecurityFilter(), synchronous, remoteSync,
169             getRemoteSyncTimeout(connector), getInitialState(connector), getEndpointEncoding(connector), muleContext,
170             getConnectionStrategy(connector));
171     }
172 
173     protected OutboundEndpoint doBuildOutboundEndpoint() throws InitialisationException, EndpointException
174     {
175         // use an explicit value here to avoid caching
176         Map properties = getProperties();
177         // this sets values used below, if they appear as properties
178         setPropertiesFromProperties(properties);
179 
180         if (uriBuilder == null)
181         {
182             throw new MuleRuntimeException(CoreMessages.objectIsNull("uriBuilder"));
183         }
184 
185         EndpointURI endpointURI = uriBuilder.getEndpoint();
186         endpointURI.initialise();
187 
188         Connector connector = getConnector();
189 
190         if (connector != null && endpointURI != null && !connector.supportsProtocol(endpointURI.getFullScheme()))
191         {
192             throw new IllegalArgumentException(CoreMessages.connectorSchemeIncompatibleWithEndpointScheme(
193                 connector.getProtocol(), endpointURI).getMessage());
194         }
195 
196         List transformers = getOutboundTransformers(connector, endpointURI);
197         List responseTransformers = getOutboundEndpointResponseTransformers(connector, endpointURI);
198 
199         boolean remoteSync = getRemoteSync(connector);
200         boolean synchronous;
201         if (remoteSync)
202         {
203             synchronous = true;
204         }
205         else
206         {
207             synchronous = getSynchronous(connector, endpointURI);
208         }
209 
210         return new DefaultOutboundEndpoint(connector, endpointURI, transformers, responseTransformers,
211             getName(endpointURI), getProperties(), getTransactionConfig(), getFilter(connector),
212             getDefaultDeleteUnacceptedMessages(connector), getSecurityFilter(), synchronous, remoteSync,
213             getRemoteSyncTimeout(connector), getInitialState(connector), getEndpointEncoding(connector), muleContext,
214             getConnectionStrategy(connector));
215 
216     }
217 
218     protected boolean getSynchronous(Connector connector, EndpointURI endpointURI)
219     {
220         return synchronous != null ? synchronous.booleanValue() : getDefaultSynchronous(connector,
221             endpointURI.getScheme());
222     }
223 
224     protected boolean getDefaultSynchronous(Connector connector, String protocol)
225     {
226         if (connector != null && connector.isSyncEnabled(protocol))
227         {
228             return true;
229         }
230         else
231         {
232             return muleContext.getConfiguration().isDefaultSynchronousEndpoints();
233         }
234     }
235 
236     protected ConnectionStrategy getConnectionStrategy(Connector connector)
237     {
238         return connectionStrategy != null ? connectionStrategy : getDefaultConnectionStrategy(connector);
239     }
240 
241     protected ConnectionStrategy getDefaultConnectionStrategy(Connector connector)
242     {
243         return muleContext.getDefaultConnectionStrategy();
244     }
245 
246     protected TransactionConfig getTransactionConfig()
247     {
248         return transactionConfig != null ? transactionConfig : getDefaultTransactionConfig();
249     }
250 
251     protected TransactionConfig getDefaultTransactionConfig()
252     {
253         // TODO Do we need a new instance per endpoint, or can a single instance be
254         // shared?
255         return new MuleTransactionConfig();
256     }
257 
258     protected EndpointSecurityFilter getSecurityFilter()
259     {
260         return securityFilter != null ? securityFilter : getDefaultSecurityFilter();
261     }
262 
263     protected EndpointSecurityFilter getDefaultSecurityFilter()
264     {
265         return null;
266     }
267 
268     protected Connector getConnector() throws EndpointException
269     {
270         return connector != null ? connector : getDefaultConnector();
271     }
272 
273     protected Connector getDefaultConnector() throws EndpointException
274     {
275         return getConnector(uriBuilder.getEndpoint(), muleContext);
276     }
277 
278     protected String getName(EndpointURI endpointURI)
279     {
280         return name != null ? name : ObjectNameHelper.getEndpointName(endpointURI);
281     }
282 
283     protected Map getProperties()
284     {
285         // Add properties from builder, endpointURI and then seal (make unmodifiable)
286         LinkedList maps = new LinkedList();
287         // properties from url come first
288         if (null != uriBuilder)
289         {
290             // properties from the URI itself
291             maps.addLast(uriBuilder.getEndpoint().getParams());
292         }
293         // properties on builder may override url
294         if (properties != null)
295         {
296             maps.addLast(properties);
297         }
298         MapCombiner combiner = new MapCombiner();
299         combiner.setList(maps);
300         return Collections.unmodifiableMap(combiner);
301     }
302 
303     protected boolean getRemoteSync(Connector connector)
304     {
305         return remoteSync != null ? remoteSync.booleanValue() : getDefaultRemoteSync(connector);
306     }
307 
308     protected boolean getDefaultRemoteSync(Connector connector)
309     {
310         return muleContext.getConfiguration().isDefaultRemoteSync();
311     }
312 
313     protected boolean getDeleteUnacceptedMessages(Connector connector)
314     {
315         return deleteUnacceptedMessages != null
316                                                ? deleteUnacceptedMessages.booleanValue()
317                                                : getDefaultDeleteUnacceptedMessages(connector);
318 
319     }
320 
321     protected boolean getDefaultDeleteUnacceptedMessages(Connector connector)
322     {
323         return false;
324     }
325 
326     protected String getEndpointEncoding(Connector connector)
327     {
328         return encoding != null ? encoding : getDefaultEndpointEncoding(connector);
329     }
330 
331     protected String getDefaultEndpointEncoding(Connector connector)
332     {
333         if (muleContext != null)
334         {
335             return muleContext.getConfiguration().getDefaultEncoding();
336         }
337         else
338         {
339             return CharSetUtils.defaultCharsetName();
340         }
341     }
342 
343     protected Filter getFilter(Connector connector)
344     {
345         return filter != null ? filter : getDefaultFilter(connector);
346 
347     }
348 
349     protected Filter getDefaultFilter(Connector connector)
350     {
351         return null;
352     }
353 
354     protected String getInitialState(Connector connector)
355     {
356         return initialState != null ? initialState : getDefaultInitialState(connector);
357 
358     }
359 
360     protected String getDefaultInitialState(Connector connector)
361     {
362         return ImmutableEndpoint.INITIAL_STATE_STARTED;
363     }
364 
365     protected int getRemoteSyncTimeout(Connector connector)
366     {
367         return remoteSyncTimeout != null ? remoteSyncTimeout.intValue() : getDefaultRemoteSyncTimeout(connector);
368 
369     }
370 
371     protected int getDefaultRemoteSyncTimeout(Connector connector)
372     {
373         return muleContext.getConfiguration().getDefaultSynchronousEventTimeout();
374     }
375 
376     protected List getInboundTransformers(Connector connector, EndpointURI endpointURI)
377         throws TransportFactoryException
378     {
379         // #1 Transformers set on builder
380         if (transformers != null)
381         {
382             return transformers;
383         }
384 
385         // #2 Transformer specified on uri
386         List transformers = getTransformersFromString(endpointURI.getTransformers());
387         if (transformers != null)
388         {
389             return transformers;
390         }
391 
392         // #3 Default Transformer
393         return getDefaultInboundTransformers(connector);
394     }
395 
396     protected List getDefaultInboundTransformers(Connector connector) throws TransportFactoryException
397     {
398         try
399         {
400             return TransformerUtils.getDefaultInboundTransformers(getNonNullServiceDescriptor(uriBuilder.getEndpoint()
401                 .getSchemeMetaInfo(), getOverrides(connector)));
402         }
403         catch (Exception e)
404         {
405             throw new TransportFactoryException(e);
406         }
407     }
408 
409     protected List getOutboundTransformers(Connector connector, EndpointURI endpointURI)
410         throws TransportFactoryException
411     {
412         // #1 Transformers set on builder
413         if (transformers != null)
414         {
415             return transformers;
416         }
417 
418         // #2 Transformer specified on uri
419         List transformers = getTransformersFromString(endpointURI.getTransformers());
420         if (transformers != null)
421         {
422             return transformers;
423         }
424 
425         // #3 Default Transformer
426         return getDefaultOutboundTransformers(connector);
427     }
428 
429     protected List getDefaultOutboundTransformers(Connector connector) throws TransportFactoryException
430     {
431         try
432         {
433             return TransformerUtils.getDefaultOutboundTransformers(getNonNullServiceDescriptor(uriBuilder.getEndpoint()
434                 .getSchemeMetaInfo(), getOverrides(connector)));
435         }
436         catch (Exception e)
437         {
438             throw new TransportFactoryException(e);
439         }
440     }
441 
442     protected List getInboundEndpointResponseTransformers(Connector connector, EndpointURI endpointURI)
443         throws TransportFactoryException
444     {
445         // #1 Transformers set on builder
446         if (responseTransformers != null)
447         {
448             return responseTransformers;
449         }
450 
451         // #2 Transformer specified on uri
452         List transformers = getTransformersFromString(endpointURI.getResponseTransformers());
453         if (transformers != null)
454         {
455             return transformers;
456         }
457 
458         // #3 Default Connector Response Transformer
459         return getDefaultResponseTransformers(connector);
460     }
461 
462     protected List getOutboundEndpointResponseTransformers(Connector connector, EndpointURI endpointURI)
463         throws TransportFactoryException
464     {
465         // #1 Transformers set on builder
466         if (responseTransformers != null)
467         {
468             return responseTransformers;
469         }
470 
471         // #2 Transformer specified on uri
472         List transformers = getTransformersFromString(endpointURI.getResponseTransformers());
473         if (transformers != null)
474         {
475             return transformers;
476         }
477         return Collections.EMPTY_LIST;
478     }
479 
480     protected List getDefaultResponseTransformers(Connector connector) throws TransportFactoryException
481     {
482         try
483         {
484             return TransformerUtils.getDefaultResponseTransformers(getNonNullServiceDescriptor(uriBuilder.getEndpoint()
485                 .getSchemeMetaInfo(), getOverrides(connector)));
486         }
487         catch (Exception e)
488         {
489             throw new TransportFactoryException(e);
490         }
491     }
492 
493     private List getTransformersFromString(String transformers) throws TransportFactoryException
494     {
495         try
496         {
497             return TransformerUtils.getTransformers(transformers);
498         }
499         catch (DefaultMuleException e)
500         {
501             throw new TransportFactoryException(e);
502         }
503     }
504 
505     private Properties getOverrides(Connector connector)
506     {
507         // Get connector specific overrides to set on the descriptor
508         Properties overrides = new Properties();
509         if (connector instanceof AbstractConnector)
510         {
511             Map so = ((AbstractConnector) connector).getServiceOverrides();
512             if (so != null)
513             {
514                 overrides.putAll(so);
515             }
516         }
517         return overrides;
518     }
519 
520     private TransportServiceDescriptor getNonNullServiceDescriptor(String scheme, Properties overrides)
521         throws ServiceException
522     {
523         TransportServiceDescriptor sd = (TransportServiceDescriptor) RegistryContext.getRegistry()
524             .lookupServiceDescriptor(ServiceDescriptorFactory.PROVIDER_SERVICE_TYPE, scheme, overrides);
525         if (null != sd)
526         {
527             return sd;
528         }
529         else
530         {
531             throw new ServiceException(CoreMessages.noServiceTransportDescriptor(scheme));
532         }
533     }
534 
535     private Connector getConnector(EndpointURI endpointURI, MuleContext muleContext) throws EndpointException
536     {
537         String scheme = uriBuilder.getEndpoint().getFullScheme();
538         Connector connector;
539         try
540         {
541             if (uriBuilder.getEndpoint().getConnectorName() != null)
542             {
543                 connector = muleContext.getRegistry().lookupConnector(uriBuilder.getEndpoint().getConnectorName());
544                 if (connector == null)
545                 {
546                     throw new TransportFactoryException(CoreMessages.objectNotRegistered("Connector",
547                         uriBuilder.getEndpoint().getConnectorName()));
548                 }
549             }
550             else
551             {
552                 connector = TransportFactory.getConnectorByProtocol(scheme);
553                 if (connector == null)
554                 {
555                     connector = TransportFactory.createConnector(endpointURI, muleContext);
556                     muleContext.getRegistry().registerConnector(connector);
557                 }
558             }
559         }
560         catch (Exception e)
561         {
562             throw new TransportFactoryException(e);
563         }
564 
565         if (connector == null)
566         {
567             Message m = CoreMessages.failedToCreateObjectWith("Endpoint", "endpointURI: " + endpointURI);
568             m.setNextMessage(CoreMessages.objectIsNull("connector"));
569             throw new TransportFactoryException(m);
570 
571         }
572         return connector;
573     }
574 
575     // Builder setters
576 
577     public void setConnector(Connector connector)
578     {
579         this.connector = connector;
580 
581     }
582 
583     public void addTransformer(Transformer transformer)
584     {
585         if (transformers == null)
586         {
587             transformers = new LinkedList();
588         }
589         transformers.add(transformer);
590     }
591 
592     public void setTransformers(List transformers)
593     {
594         this.transformers = transformers;
595     }
596 
597     public void setResponseTransformers(List responseTransformers)
598     {
599         this.responseTransformers = responseTransformers;
600     }
601 
602     public void setName(String name)
603     {
604         this.name = name;
605     }
606 
607     /**
608      * NOTE - this appends properties.
609      */
610     public void setProperties(Map properties)
611     {
612         if (null == this.properties)
613         {
614             this.properties = new HashMap();
615         }
616         this.properties.putAll(properties);
617     }
618 
619     /**
620      * Sets a property on the endpoint
621      * 
622      * @param key the property key
623      * @param value the value of the property
624      */
625     public void setProperty(Object key, Object value)
626     {
627         properties.put(key, value);
628     }
629 
630     public void setTransactionConfig(TransactionConfig transactionConfig)
631     {
632         this.transactionConfig = transactionConfig;
633 
634     }
635 
636     public void setFilter(Filter filter)
637     {
638         this.filter = filter;
639 
640     }
641 
642     public void setDeleteUnacceptedMessages(boolean deleteUnacceptedMessages)
643     {
644         this.deleteUnacceptedMessages = Boolean.valueOf(deleteUnacceptedMessages);
645 
646     }
647 
648     public void setSecurityFilter(EndpointSecurityFilter securityFilter)
649     {
650         this.securityFilter = securityFilter;
651 
652     }
653 
654     public void setSynchronous(boolean synchronous)
655     {
656         this.synchronous = Boolean.valueOf(synchronous);
657 
658     }
659 
660     public void setRemoteSync(boolean remoteSync)
661     {
662         this.remoteSync = Boolean.valueOf(remoteSync);
663 
664     }
665 
666     public void setRemoteSyncTimeout(int remoteSyncTimeout)
667     {
668         this.remoteSyncTimeout = new Integer(remoteSyncTimeout);
669 
670     }
671 
672     public void setInitialState(String initialState)
673     {
674         this.initialState = initialState;
675 
676     }
677 
678     public void setEncoding(String encoding)
679     {
680         this.encoding = encoding;
681 
682     }
683 
684     public void setCreateConnector(int createConnector)
685     {
686         this.createConnector = new Integer(createConnector);
687     }
688 
689     public void setRegistryId(String registryId)
690     {
691         this.registryId = registryId;
692 
693     }
694 
695     public void setMuleContext(MuleContext muleContext)
696     {
697         this.muleContext = muleContext;
698 
699     }
700 
701     public void setConnectionStrategy(ConnectionStrategy connectionStrategy)
702     {
703         this.connectionStrategy = connectionStrategy;
704 
705     }
706 
707     public URIBuilder getEndpointBuilder()
708     {
709         return uriBuilder;
710     }
711 
712     public void setURIBuilder(URIBuilder URIBuilder)
713     {
714         this.uriBuilder = URIBuilder;
715 
716     }
717 
718     // TODO Equals() and hashCode() only needed for tests, move to tests
719     public int hashCode()
720     {
721         return ClassUtils.hash(new Object[]{connectionStrategy, connector, createConnector, deleteUnacceptedMessages,
722             encoding, uriBuilder, filter, initialState, name, properties, remoteSync, remoteSyncTimeout,
723             responseTransformers, securityFilter, synchronous, transactionConfig, transformers});
724     }
725 
726     // TODO Equals() and hashCode() only needed for tests, move to tests
727     public boolean equals(Object obj)
728     {
729         if (this == obj) return true;
730         if (obj == null || getClass() != obj.getClass()) return false;
731 
732         final AbstractEndpointBuilder other = (AbstractEndpointBuilder) obj;
733         return equal(connectionStrategy, other.connectionStrategy) && equal(connector, other.connector)
734                && equal(createConnector, other.createConnector)
735                && equal(deleteUnacceptedMessages, other.deleteUnacceptedMessages) && equal(encoding, other.encoding)
736                && equal(uriBuilder, other.uriBuilder) && equal(filter, other.filter)
737                && equal(initialState, other.initialState) && equal(name, other.name)
738                && equal(properties, other.properties) && equal(remoteSync, other.remoteSync)
739                && equal(remoteSyncTimeout, other.remoteSyncTimeout)
740                && equal(responseTransformers, other.responseTransformers)
741                && equal(securityFilter, other.securityFilter) && equal(synchronous, other.synchronous)
742                && equal(transactionConfig, other.transactionConfig) && equal(transformers, other.transformers);
743     }
744 
745     protected static boolean equal(Object a, Object b)
746     {
747         return ClassUtils.equal(a, b);
748     }
749 
750     public Object clone() throws CloneNotSupportedException
751     {
752         EndpointBuilder builder = (EndpointBuilder) super.clone();
753         builder.setConnector(connector);
754         builder.setURIBuilder(uriBuilder);
755         builder.setTransformers(transformers);
756         builder.setResponseTransformers(responseTransformers);
757         builder.setName(name);
758         builder.setProperties(properties);
759         builder.setTransactionConfig(transactionConfig);
760         builder.setFilter(filter);
761         builder.setSecurityFilter(securityFilter);
762         builder.setInitialState(initialState);
763         builder.setEncoding(encoding);
764         builder.setRegistryId(registryId);
765         builder.setMuleContext(muleContext);
766         builder.setConnectionStrategy(connectionStrategy);
767 
768         if (deleteUnacceptedMessages != null)
769         {
770             builder.setDeleteUnacceptedMessages(deleteUnacceptedMessages.booleanValue());
771         }
772         if (synchronous != null)
773         {
774             builder.setSynchronous(synchronous.booleanValue());
775         }
776         if (remoteSync != null)
777         {
778             builder.setRemoteSync(remoteSync.booleanValue());
779         }
780         if (remoteSyncTimeout != null)
781         {
782             builder.setRemoteSyncTimeout(remoteSyncTimeout.intValue());
783         }
784 
785         return builder;
786     }
787 
788 }