View Javadoc

1   /*
2    * $Id: OutboundEndpointFactoryBean.java 20385 2010-11-29 20:25:26Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.config.spring.factories;
12  
13  import org.mule.api.endpoint.EndpointBuilder;
14  import org.mule.api.endpoint.EndpointException;
15  import org.mule.api.endpoint.OutboundEndpoint;
16  import org.mule.api.registry.ServiceType;
17  import org.mule.endpoint.EndpointURIEndpointBuilder;
18  import org.mule.transport.service.TransportServiceDescriptor;
19  
20  /**
21   * Spring FactoryBean used to create concrete instances of outbound endpoints
22   */
23  public class OutboundEndpointFactoryBean extends AbstractEndpointFactoryBean
24  {
25  
26      public OutboundEndpointFactoryBean(EndpointURIEndpointBuilder global) throws EndpointException
27      {
28          super(global);
29      }
30  
31      public OutboundEndpointFactoryBean()
32      {
33          super();
34      }
35      
36      public Class getObjectType()
37      {
38          return OutboundEndpoint.class;
39      }
40  
41      public Object doGetObject() throws Exception
42      {
43          // If this is a meta endpoint, then we can wrap it using the meta endpoint builder from the TransportServiceDescriptor
44          String scheme = getEndpointBuilder().getEndpoint().getFullScheme();
45          TransportServiceDescriptor tsd = (TransportServiceDescriptor) muleContext.getRegistry().lookupServiceDescriptor(ServiceType.TRANSPORT, scheme, null);
46          EndpointBuilder endpointBuilder = tsd.createEndpointBuilder(this);
47          
48          return muleContext.getEndpointFactory().getOutboundEndpoint(endpointBuilder);
49      }
50  
51  }