1 /*
2 * $Id: AnnotationsConfigurationBuilder.java 19191 2010-08-25 21:05:23Z tcarlson $
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 package org.mule.config;
11
12 import org.mule.api.MuleContext;
13 import org.mule.config.builders.AbstractConfigurationBuilder;
14 import org.mule.config.endpoint.RegistryBackedAnnotationsParserFactory;
15
16 /**
17 * Enables Mule annotation processing so that annotated objects registered with the Mule registry will automatically
18 * be configured. This helper also enables JSR-330 injection annotations {@link javax.inject.Inject} and {@link javax.inject.Named}.
19 * <p/>
20 * Internal Implementation note: We could have used a 'registry-bootstrap.properties' file to load the objects necessary
21 * to enable annotations however, that method would not allow the annotation processors to be easily overridden when using
22 * other platforms such as Google App Engine.
23 *
24 * @since 3.0
25 */
26 public class AnnotationsConfigurationBuilder extends AbstractConfigurationBuilder
27 {
28 @Override
29 protected void doConfigure(MuleContext muleContext) throws Exception
30 {
31 //Make the annotation parsers available
32 AnnotationsParserFactory factory = createAnnotationsParserFactory();
33 muleContext.getRegistry().registerObject("_" + factory.getClass().getSimpleName(), factory);
34 }
35
36 protected AnnotationsParserFactory createAnnotationsParserFactory()
37 {
38 return new RegistryBackedAnnotationsParserFactory();
39 }
40 }