View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config.spring.factories;
8   
9   import org.mule.api.endpoint.EndpointBuilder;
10  import org.mule.api.endpoint.EndpointException;
11  import org.mule.api.endpoint.OutboundEndpoint;
12  import org.mule.api.registry.ServiceType;
13  import org.mule.endpoint.EndpointURIEndpointBuilder;
14  import org.mule.transport.service.TransportServiceDescriptor;
15  
16  /**
17   * Spring FactoryBean used to create concrete instances of outbound endpoints
18   */
19  public class OutboundEndpointFactoryBean extends AbstractEndpointFactoryBean
20  {
21  
22      public OutboundEndpointFactoryBean(EndpointURIEndpointBuilder global) throws EndpointException
23      {
24          super(global);
25      }
26  
27      public OutboundEndpointFactoryBean()
28      {
29          super();
30      }
31      
32      public Class getObjectType()
33      {
34          return OutboundEndpoint.class;
35      }
36  
37      public Object doGetObject() throws Exception
38      {
39          // If this is a meta endpoint, then we can wrap it using the meta endpoint builder from the TransportServiceDescriptor
40          String scheme = getEndpointBuilder().getEndpoint().getFullScheme();
41          TransportServiceDescriptor tsd = (TransportServiceDescriptor) muleContext.getRegistry().lookupServiceDescriptor(ServiceType.TRANSPORT, scheme, null);
42          EndpointBuilder endpointBuilder = tsd.createEndpointBuilder(this);
43          
44          return muleContext.getEndpointFactory().getOutboundEndpoint(endpointBuilder);
45      }
46  
47  }