1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
package org.mule.module.ibeans.config; |
11 | |
|
12 | |
import org.mule.api.MuleContext; |
13 | |
import org.mule.api.config.ConfigurationException; |
14 | |
import org.mule.util.scan.ClasspathScanner; |
15 | |
|
16 | |
import java.io.IOException; |
17 | |
import java.util.HashSet; |
18 | |
import java.util.Set; |
19 | |
|
20 | |
import org.ibeans.annotation.Call; |
21 | |
import org.ibeans.annotation.IBeanGroup; |
22 | |
import org.ibeans.annotation.Template; |
23 | |
import org.ibeans.impl.IBeansNotationHelper; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
public class IBeanHolderConfigurationBuilder extends AbstractAnnotationConfigurationBuilder |
31 | |
{ |
32 | |
public static final String IBEAN_HOLDER_PREFIX = "_ibeanHolder."; |
33 | |
|
34 | |
public IBeanHolderConfigurationBuilder() |
35 | 0 | { |
36 | 0 | } |
37 | |
|
38 | |
public IBeanHolderConfigurationBuilder(String... basepackages) |
39 | |
{ |
40 | 0 | super(basepackages); |
41 | 0 | } |
42 | |
|
43 | |
public IBeanHolderConfigurationBuilder(ClassLoader classLoader) |
44 | |
{ |
45 | 0 | super(classLoader); |
46 | 0 | } |
47 | |
|
48 | |
public IBeanHolderConfigurationBuilder(ClassLoader classLoader, String... basepackages) |
49 | |
{ |
50 | 0 | super(classLoader, basepackages); |
51 | 0 | } |
52 | |
|
53 | |
protected String getScanPackagesProperty() |
54 | |
{ |
55 | 0 | return "ibeans.scan.packages"; |
56 | |
} |
57 | |
|
58 | |
protected void doConfigure(MuleContext muleContext) throws Exception |
59 | |
{ |
60 | 0 | Set<Class> ibeanClasses = new HashSet<Class>(); |
61 | 0 | ClasspathScanner scanner = createClasspathScanner(); |
62 | |
|
63 | |
try |
64 | |
{ |
65 | |
|
66 | 0 | ibeanClasses.addAll(scanner.scanFor(Call.class, ClasspathScanner.INCLUDE_INTERFACE)); |
67 | 0 | ibeanClasses.addAll(scanner.scanFor(Template.class, ClasspathScanner.INCLUDE_INTERFACE)); |
68 | |
|
69 | 0 | ibeanClasses.addAll(scanner.scanFor(IBeanGroup.class, ClasspathScanner.INCLUDE_INTERFACE)); |
70 | |
} |
71 | 0 | catch (IOException e) |
72 | |
{ |
73 | 0 | throw new ConfigurationException(e); |
74 | 0 | } |
75 | |
|
76 | 0 | for (Class ibeanClass : ibeanClasses) |
77 | |
{ |
78 | |
|
79 | 0 | muleContext.getRegistry().registerObject(IBeansNotationHelper.getIBeanShortID(ibeanClass), new IBeanHolder(ibeanClass)); |
80 | |
} |
81 | 0 | } |
82 | |
} |