01: package org.ow2.easybeans.deployment.annotations.helper;
02:
03: import java.util.List;
04:
05: import org.ow2.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata;
06: import org.ow2.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata;
07: import org.ow2.easybeans.deployment.annotations.metadata.LibrariesAnnotationMetadata;
08:
09: /**
10: * Complete existing metadata by libraries metadata.
11: * @author Florent BENOIT
12: */
13: public final class ExtraMetadataHelper {
14:
15: /**
16: * Utility class.
17: */
18: private ExtraMetadataHelper() {
19: }
20:
21: /**
22: * Complete the given EJB metadata by the metadata found in the libraries.
23: * @param ejbMetadata the medata to complete
24: * @param libAnnotationMetadata the given data of the libraries.
25: */
26: public static void complete(
27: final EjbJarAnnotationMetadata ejbMetadata,
28: final LibrariesAnnotationMetadata libAnnotationMetadata) {
29:
30: // Nothing to complete
31: if (libAnnotationMetadata == null) {
32: return;
33: }
34:
35: // List ?
36: List<EjbJarAnnotationMetadata> extraMetaDataList = libAnnotationMetadata
37: .getEjbJarAnnotationMetadataList();
38:
39: // Nothing to do
40: if (extraMetaDataList == null) {
41: return;
42: }
43:
44: for (EjbJarAnnotationMetadata extraEjbJarAnnotationMetadata : extraMetaDataList) {
45: for (ClassAnnotationMetadata classAnnotationMetadata : extraEjbJarAnnotationMetadata
46: .getClassAnnotationMetadataCollection()) {
47: // Data exist for the EJB ?
48: ClassAnnotationMetadata foundClassAnnotationMetadata = ejbMetadata
49: .getClassAnnotationMetadata(classAnnotationMetadata
50: .getClassName());
51:
52: // Found something, continue
53: if (foundClassAnnotationMetadata != null) {
54: continue;
55: }
56:
57: // Not found, then complete
58: ejbMetadata
59: .addClassAnnotationMetadata(classAnnotationMetadata);
60:
61: }
62: }
63: }
64:
65: }
|