View Javadoc

1   /*
2    * $Id: InboundEndpointFactoryBean.java 22566 2011-07-27 22:52:53Z julien.eluard $
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.config.ConfigurationException;
14  import org.mule.api.endpoint.EndpointException;
15  import org.mule.api.endpoint.EndpointFactory;
16  import org.mule.api.endpoint.ImmutableEndpoint;
17  import org.mule.api.endpoint.InboundEndpoint;
18  import org.mule.config.i18n.MessageFactory;
19  import org.mule.endpoint.AbstractEndpoint;
20  import org.mule.endpoint.EndpointURIEndpointBuilder;
21  
22  /**
23   * Spring FactoryBean used to create concrete instances of inbound endpoints
24   */
25  public class InboundEndpointFactoryBean extends AbstractEndpointFactoryBean
26  {
27  
28      public InboundEndpointFactoryBean(EndpointURIEndpointBuilder global) throws EndpointException
29      {
30          super(global);
31      }
32  
33      public InboundEndpointFactoryBean()
34      {
35          super();
36      }
37  
38      public Class<?> getObjectType()
39      {
40          return InboundEndpoint.class;
41      }
42  
43      @Override
44      public Object doGetObject() throws Exception
45      {
46          EndpointFactory ef = muleContext.getEndpointFactory();
47          if (ef != null)
48          {
49              InboundEndpoint inboundEndpoint = ef.getInboundEndpoint(this);
50              if (inboundEndpoint instanceof AbstractEndpoint)
51              {
52                  AbstractEndpoint.class.cast(inboundEndpoint).setAnnotations(getAnnotations());
53              }
54              return inboundEndpoint;
55          }
56          else
57          {
58              throw new ConfigurationException(MessageFactory.createStaticMessage("EndpointFactory not found in Registry"));
59          }
60      }
61  
62  }