1717
1818import org .fireflyframework .ecm .adapter .AdapterRegistry ;
1919import org .fireflyframework .ecm .adapter .AdapterSelector ;
20+ import org .fireflyframework .ecm .adapter .local .LocalDocumentSearchAdapter ;
21+ import org .fireflyframework .ecm .adapter .local .LocalPermissionAdapter ;
2022import org .fireflyframework .ecm .adapter .noop .NoOpAdapterFactory ;
2123import org .fireflyframework .ecm .port .document .*;
2224import org .fireflyframework .ecm .port .folder .*;
2729import org .fireflyframework .ecm .service .EcmPortProvider ;
2830import lombok .extern .slf4j .Slf4j ;
2931import org .springframework .boot .autoconfigure .AutoConfiguration ;
32+ import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
3033import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
3134import org .springframework .boot .context .properties .EnableConfigurationProperties ;
35+ import org .springframework .context .ApplicationContext ;
3236import org .springframework .context .annotation .Bean ;
33- import org .springframework .context .annotation .ComponentScan ;
3437
3538/**
3639 * Spring Boot auto-configuration for the Firefly ECM (Enterprise Content Management) system.
4144 * <li>Adapter discovery and registration</li>
4245 * <li>Port provider configuration</li>
4346 * <li>Conditional bean creation based on feature flags</li>
44- * <li>Component scanning for ECM-related beans </li>
47+ * <li>Explicit bean registration for ECM infrastructure components </li>
4548 * </ul>
4649 *
4750 * <p>The auto-configuration is activated when the property {@code firefly.ecm.enabled}
7275@ Slf4j
7376@ AutoConfiguration
7477@ EnableConfigurationProperties (EcmProperties .class )
75- @ ComponentScan (basePackages = "org.fireflyframework.ecm" )
7678@ ConditionalOnProperty (prefix = "firefly.ecm" , name = "enabled" , havingValue = "true" , matchIfMissing = true )
7779public class EcmAutoConfiguration {
7880
81+ /**
82+ * Configures the adapter registry for discovering and managing ECM adapters.
83+ *
84+ * <p>The adapter registry automatically discovers all ECM adapters in the Spring
85+ * application context and provides efficient access to them based on type or
86+ * interface requirements.</p>
87+ *
88+ * @param applicationContext the Spring application context for bean discovery
89+ * @return a configured AdapterRegistry instance
90+ * @see AdapterRegistry
91+ */
92+ @ Bean
93+ @ ConditionalOnMissingBean
94+ public AdapterRegistry adapterRegistry (ApplicationContext applicationContext ) {
95+ return new AdapterRegistry (applicationContext );
96+ }
97+
98+ /**
99+ * Configures the adapter selector for choosing appropriate ECM adapters.
100+ *
101+ * <p>The adapter selector implements the adapter selection logic, providing
102+ * intelligent fallback mechanisms and validation capabilities.</p>
103+ *
104+ * @param adapterRegistry the registry containing available adapters
105+ * @return a configured AdapterSelector instance
106+ * @see AdapterSelector
107+ */
108+ @ Bean
109+ @ ConditionalOnMissingBean
110+ public AdapterSelector adapterSelector (AdapterRegistry adapterRegistry ) {
111+ return new AdapterSelector (adapterRegistry );
112+ }
113+
114+ /**
115+ * Configures the no-op adapter factory for creating fallback adapter implementations.
116+ *
117+ * <p>The no-op adapter factory provides a centralized way to create no-op adapters
118+ * that serve as fallbacks when no real adapter implementations are available.</p>
119+ *
120+ * @return a configured NoOpAdapterFactory instance
121+ * @see NoOpAdapterFactory
122+ */
123+ @ Bean
124+ @ ConditionalOnMissingBean
125+ public NoOpAdapterFactory noOpAdapterFactory () {
126+ return new NoOpAdapterFactory ();
127+ }
128+
79129 /**
80130 * Configures the central ECM port provider that manages adapter selection and port provisioning.
81131 *
@@ -90,11 +140,46 @@ public class EcmAutoConfiguration {
90140 * @see AdapterSelector
91141 */
92142 @ Bean
143+ @ ConditionalOnMissingBean
93144 public EcmPortProvider ecmPortProvider (AdapterSelector adapterSelector , EcmProperties ecmProperties ) {
94145 log .info ("Configuring ECM Port Provider with adapter type: {}" , ecmProperties .getAdapterType ());
95146 return new EcmPortProvider (adapterSelector , ecmProperties );
96147 }
97148
149+ /**
150+ * Configures the local in-memory document search adapter.
151+ *
152+ * <p>This bean is only created when the {@code firefly.ecm.search.enabled} property
153+ * is set to {@code true}. It provides an in-memory search implementation for
154+ * development and testing purposes.</p>
155+ *
156+ * @return a configured LocalDocumentSearchAdapter instance
157+ * @see LocalDocumentSearchAdapter
158+ */
159+ @ Bean
160+ @ ConditionalOnMissingBean
161+ @ ConditionalOnProperty (name = "firefly.ecm.search.enabled" , havingValue = "true" , matchIfMissing = false )
162+ public LocalDocumentSearchAdapter localDocumentSearchAdapter () {
163+ return new LocalDocumentSearchAdapter ();
164+ }
165+
166+ /**
167+ * Configures the local in-memory permission adapter.
168+ *
169+ * <p>This bean is only created when the {@code firefly.ecm.permissions.enabled} property
170+ * is set to {@code true}. It provides an in-memory permission management implementation
171+ * for development and testing purposes.</p>
172+ *
173+ * @return a configured LocalPermissionAdapter instance
174+ * @see LocalPermissionAdapter
175+ */
176+ @ Bean
177+ @ ConditionalOnMissingBean
178+ @ ConditionalOnProperty (name = "firefly.ecm.permissions.enabled" , havingValue = "true" , matchIfMissing = false )
179+ public LocalPermissionAdapter localPermissionAdapter () {
180+ return new LocalPermissionAdapter ();
181+ }
182+
98183 /**
99184 * Configures the document port for basic document CRUD operations.
100185 *
0 commit comments