Revision: 1174
Author: lstreepy
Date: 2006-05-19 07:42:36 -0700 (Fri, 19 May 2006)
ViewCVS: http://svn.sourceforge.net/spring-rich-c/?rev=1174&view=rev
Log Message:
-----------
Change to using bean ids for registering services in the applicaiton context.
All
existing setXXX methods now have a setXXXId counterpart.
Modified Paths:
--------------
trunk/spring-richclient/archetype/src/main/resources/archetype-resources/src/main/resources/ctx/richclient-application-context.xml
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
trunk/spring-richclient/samples/simple/src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java
Modified:
trunk/spring-richclient/archetype/src/main/resources/archetype-resources/src/main/resources/ctx/richclient-application-context.xml
===================================================================
---
trunk/spring-richclient/archetype/src/main/resources/archetype-resources/src/main/resources/ctx/richclient-application-context.xml
2006-05-19 07:29:26 UTC (rev 1173)
+++
trunk/spring-richclient/archetype/src/main/resources/archetype-resources/src/main/resources/ctx/richclient-application-context.xml
2006-05-19 14:42:36 UTC (rev 1174)
@@ -88,18 +88,15 @@
Usage: Platform required (unless you set this up programmatically)
Description: This configures the application services available to the
platform.
There are specific setter methods for all the standard services,
see the
- javadoc on teh DefaultApplicationServices class for more details.
- NOTE: The use of applicationObjectConfigurerBeanId instead of a
direct bean
- reference is required in order to break a circular dependency with
the
- ApplicationObjectConfigurer (which is a BeanPostProcessor).
+ javadoc on the DefaultApplicationServices class for more details.
+ NOTE: The use of bean ids (idref) is preferred over using direct
bean
+ references to avoid startup problems with circular references.
-->
<bean id="applicationServices"
class="org.springframework.richclient.application.support.DefaultApplicationServices">
- <property name="imageSource" ref="imageSource" />
- <property name="formComponentInterceptorFactory"
ref="formComponentInterceptorFactory" />
- <property name="applicationObjectConfigurerBeanId">
- <idref bean="applicationObjectConfigurer" />
- </property>
+ <property name="imageSourceId"><idref bean="imageSource"/></property>
+ <property name="formComponentInterceptorFactoryId"><idref
bean="formComponentInterceptorFactory"/></property>
+ <property name="applicationObjectConfigurerId"><idref
bean="applicationObjectConfigurer" /></property>
</bean>
<!--
Modified:
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
===================================================================
---
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
2006-05-19 07:29:26 UTC (rev 1173)
+++
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
2006-05-19 14:42:36 UTC (rev 1174)
@@ -50,20 +50,17 @@
Usage: Platform required (unless you set this up programmatically)
Description: This configures the application services available to the
platform.
There are specific setter methods for all the standard services,
see the
- javadoc on teh DefaultApplicationServices class for more details.
- NOTE: The use of applicationObjectConfigurerBeanId instead of a
direct bean
- reference is required in order to break a circular dependency with
the
- ApplicationObjectConfigurer (which is a BeanPostProcessor).
+ javadoc on the DefaultApplicationServices class for more details.
+ NOTE: The use of bean ids (idref) is preferred over using direct
bean
+ references to avoid startup problems with circular references.
-->
<bean id="applicationServices"
class="org.springframework.richclient.application.support.DefaultApplicationServices">
- <property name="imageSource" ref="imageSource" />
- <property name="rulesSource" ref="rulesSource" />
- <property name="binderSelectionStrategy"
ref="binderSelectionStrategy"/>
- <property name="formComponentInterceptorFactory"
ref="formComponentInterceptorFactory" />
- <property name="applicationObjectConfigurerBeanId">
- <idref bean="applicationObjectConfigurer" />
- </property>
+ <property name="imageSourceId"><idref bean="imageSource"/></property>
+ <property name="rulesSourceId"><idref bean="rulesSource"/></property>
+ <property name="binderSelectionStrategyId"><idref
bean="binderSelectionStrategy"/></property>
+ <property name="formComponentInterceptorFactoryId"><idref
bean="formComponentInterceptorFactory"/></property>
+ <property name="applicationObjectConfigurerId"><idref
bean="applicationObjectConfigurer" /></property>
</bean>
<bean id="applicationObjectConfigurer" depends-on="serviceLocator"
Modified:
trunk/spring-richclient/samples/simple/src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml
===================================================================
---
trunk/spring-richclient/samples/simple/src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml
2006-05-19 07:29:26 UTC (rev 1173)
+++
trunk/spring-richclient/samples/simple/src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml
2006-05-19 14:42:36 UTC (rev 1174)
@@ -89,19 +89,17 @@
Usage: Platform required (unless you set this up programmatically)
Description: This configures the application services available to the
platform.
There are specific setter methods for all the standard services,
see the
- javadoc on teh DefaultApplicationServices class for more details.
- NOTE: The use of applicationObjectConfigurerBeanId instead of a
direct bean
- reference is required in order to break a circular dependency with
the
- ApplicationObjectConfigurer (which is a BeanPostProcessor).
+ javadoc on the DefaultApplicationServices class for more details.
+ NOTE: The use of bean ids (idref) is preferred over using direct
bean
+ references to avoid startup problems with circular references.
-->
<bean id="applicationServices"
class="org.springframework.richclient.application.support.DefaultApplicationServices">
- <property name="imageSource" ref="imageSource" />
- <property name="rulesSource" ref="rulesSource" />
- <property name="formComponentInterceptorFactory"
ref="formComponentInterceptorFactory" />
- <property name="applicationObjectConfigurerBeanId">
- <idref bean="applicationObjectConfigurer" />
- </property>
+ <property name="imageSourceId"><idref bean="imageSource"/></property>
+ <property name="rulesSourceId"><idref bean="rulesSource"/></property>
+ <property name="conversionServiceId"><idref
bean="conversionService"/></property>
+ <property name="formComponentInterceptorFactoryId"><idref
bean="formComponentInterceptorFactory"/></property>
+ <property name="applicationObjectConfigurerId"><idref
bean="applicationObjectConfigurer" /></property>
</bean>
<!--
Modified:
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java
===================================================================
---
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java
2006-05-19 07:29:26 UTC (rev 1173)
+++
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java
2006-05-19 14:42:36 UTC (rev 1174)
@@ -24,8 +24,8 @@
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.binding.convert.ConversionService;
+import org.springframework.binding.form.FieldFaceSource;
import org.springframework.binding.form.FormModel;
-import org.springframework.binding.form.FieldFaceSource;
import org.springframework.binding.form.support.MessageSourceFieldFaceSource;
import org.springframework.binding.value.ValueChangeDetector;
import org.springframework.binding.value.support.DefaultValueChangeDetector;
@@ -64,10 +64,38 @@
/**
* A default implementation of the ApplicationServices (service locator)
interface. This
- * implementation uses information from the application context in order to
locate
- * services using "magic" bean names. If requested beans are not defined in
the context,
- * then a suitable default service will be created.
+ * implementation allows for the direct registration of service
implementations by using
+ * various setter methods (like [EMAIL PROTECTED]
#setImageSource(ImageSource)}). Service registry
+ * entries can also be added in bulk using the [EMAIL PROTECTED]
#setRegistryEntries(Map)} method.
+ * <p>
+ * Except in testing environments, this class will typically be instantiated
in the
+ * application context and the various service implementations will be set
<b>BY ID</b>.
+ * The use of service bean ids instead of direct bean references is to avoid
numerous
+ * problems with cyclic dependencies and other order dependent operations. So,
a typical
+ * incarnation might look like this:
*
+ * <pre>
+ * <bean id="applicationServices"
+ *
class="org.springframework.richclient.application.support.DefaultApplicationServices">
+ * <property
name="applicationObjectConfigurerId"><idref
bean="applicationObjectConfigurer" /></property>
+ * <property name="imageSourceId"><idref
bean="imageSource"/></property>
+ * <property name="rulesSourceId"><idref
bean="rulesSource"/></property>
+ * <property name="conversionServiceId"><idref
bean="conversionService"/></property>
+ * <property
name="formComponentInterceptorFactoryId"><idref
bean="formComponentInterceptorFactory"/></property>
+ * </bean>
+ * </pre>
+ * Note the use of the <code>refid</code> form instead of just using a string
value. This
+ * is the preferred syntax in order to avoid having misspelled bean names go
unreported.
+ * <p>
+ * When a service is requested, via [EMAIL PROTECTED] #getService(Class)}, the
current registry of
+ * service implementations is consulted. If a registry entry was made using a
bean id, this
+ * is the point at which it will be dereferenced into the actual bean
implementation. So,
+ * the bean impementation will not be referenced until it is requested.
+ * <p>
+ * If a service is requested that has not been registered and a default
implementation
+ * can be provided, it will be constructed at that time. Default
implementations are
+ * provided for essentially all services referenced by the platform.
+ *
* @author Larry Streepy
*/
public class DefaultApplicationServices implements ApplicationServices,
ApplicationContextAware {
@@ -138,7 +166,8 @@
} else {
// Runtime derefence of refid's
if( service instanceof String ) {
- service = getApplicationContext().getBean((String)service,
serviceType);
+ service = getApplicationContext().getBean((String) service,
serviceType);
+ services.put(serviceType, service);
}
}
@@ -159,8 +188,8 @@
* Add entries to the service registry. This is typically called from a
bean
* definition in the application context. The entryMap parameter must be a
map with
* keys that are either class instances (the serviceType) or the String
name of the
- * class and values that are the implementation to use for that service or
an idref
- * to a bean that is the implementation (passed as a String).
+ * class and values that are the implementation to use for that service or
an idref to
+ * a bean that is the implementation (passed as a String).
*
* @param entryMap Map of entries
*/
@@ -193,24 +222,21 @@
}
/**
- * Set the Id of the context bean that holds the
ApplicationObjectConfigurer instance
- * to use as the service. This mechanism is used to break a chicken/egg
problem in
- * providing a reference to the AOC to the application services when the
AOC needs to
- * ensure that the application services locator is constructed before the
AOC.
+ * Set the application object configurer service implementation.
*
- * @param aocBeanId Id of the ApplicationObjectConfigurer bean
+ * @param applicationObjectConfigurer
*/
- public void setApplicationObjectConfigurerBeanId( String aocBeanId ) {
- applicationObjectConfigurerBeanId = aocBeanId;
+ public void setApplicationObjectConfigurer( ApplicationObjectConfigurer
applicationObjectConfigurer ) {
+ services.put(ApplicationObjectConfigurer.class,
applicationObjectConfigurer);
}
/**
- * Set the application object configurer service implementation.
+ * Set the application object configurer service implementation bean id
*
- * @param applicationObjectConfigurer
+ * @param applicationObjectConfigurerId bean id
*/
- public void setApplicationObjectConfigurer( ApplicationObjectConfigurer
applicationObjectConfigurer ) {
- services.put(ApplicationObjectConfigurer.class,
applicationObjectConfigurer);
+ public void setApplicationObjectConfigurerId( String
applicationObjectConfigurerId ) {
+ services.put(ApplicationObjectConfigurer.class,
applicationObjectConfigurerId);
}
/**
@@ -223,6 +249,15 @@
}
/**
+ * Set the application security manager service implementation bean id
+ *
+ * @param applicationSecurityManagerId bean id
+ */
+ public void setApplicationSecurityManagerId( String
applicationSecurityManagerId ) {
+ services.put(ApplicationSecurityManager.class,
applicationSecurityManagerId);
+ }
+
+ /**
* Set the binder selection strategy service implementation
*
* @param binderSelectionStrategy
@@ -232,6 +267,15 @@
}
/**
+ * Set the binder selection strategy service implementation bean id
+ *
+ * @param binderSelectionStrategyId bean id
+ */
+ public void setBinderSelectionStrategyId( String binderSelectionStrategyId
) {
+ services.put(BinderSelectionStrategy.class, binderSelectionStrategyId);
+ }
+
+ /**
* Set the binding factory provider service implementation
*
* @param bindingFactoryProvider
@@ -241,6 +285,15 @@
}
/**
+ * Set the binding factory provider service implementation bean id
+ *
+ * @param bindingFactoryProviderId bean id
+ */
+ public void setBindingFactoryProviderId( String bindingFactoryProviderId )
{
+ services.put(BindingFactoryProvider.class, bindingFactoryProviderId);
+ }
+
+ /**
* Set the command configurer service implementation
*
* @param commandConfigurer
@@ -250,6 +303,15 @@
}
/**
+ * Set the command configurer service implementation bean id
+ *
+ * @param commandConfigurerId bean id
+ */
+ public void setCommandConfigurerId( String commandConfigurerId ) {
+ services.put(CommandConfigurer.class, commandConfigurerId);
+ }
+
+ /**
* Set the component factory service implementation
*
* @param componentFactory
@@ -259,6 +321,15 @@
}
/**
+ * Set the component factory service implementation bean id
+ *
+ * @param componentFactoryId bean id
+ */
+ public void setComponentFactoryId( String componentFactoryId ) {
+ services.put(ComponentFactory.class, componentFactoryId);
+ }
+
+ /**
* Set the conversion service service implementation
*
* @param conversionService
@@ -268,6 +339,15 @@
}
/**
+ * Set the conversion service service implementation bean id
+ *
+ * @param conversionServiceId bean id
+ */
+ public void setConversionServiceId( String conversionServiceId ) {
+ services.put(ConversionService.class, conversionServiceId);
+ }
+
+ /**
* Set the form component interceptor factory service implementation
*
* @param formComponentInterceptorFactory
@@ -277,8 +357,17 @@
}
/**
- * Set the form property face descriptor source service implementation
+ * Set the form component interceptor factory service implementation bean
id
*
+ * @param formComponentInterceptorFactoryId bean id
+ */
+ public void setFormComponentInterceptorFactoryId( String
formComponentInterceptorFactoryId ) {
+ services.put(FormComponentInterceptorFactory.class,
formComponentInterceptorFactoryId);
+ }
+
+ /**
+ * Set the field face descriptor source service implementation
+ *
* @param fieldFaceSource
*/
public void setFieldFaceSource( FieldFaceSource fieldFaceSource ) {
@@ -286,6 +375,15 @@
}
/**
+ * Set the field face descriptor source service implementation bean id
+ *
+ * @param fieldFaceSourceId bean id
+ */
+ public void setFieldFaceSourceId( String fieldFaceSourceId ) {
+ services.put(FieldFaceSource.class, fieldFaceSourceId);
+ }
+
+ /**
* Set the icon source service implementation
*
* @param iconSource
@@ -295,6 +393,15 @@
}
/**
+ * Set the icon source service implementation bean id
+ *
+ * @param iconSourceId bean id
+ */
+ public void setIconSourceId( String iconSourceId ) {
+ services.put(IconSource.class, iconSourceId);
+ }
+
+ /**
* Set the image source service implementation
*
* @param imageSource
@@ -304,6 +411,15 @@
}
/**
+ * Set the image source service implementation bean id
+ *
+ * @param imageSourceId bean id
+ */
+ public void setImageSourceId( String imageSourceId ) {
+ services.put(ImageSource.class, imageSourceId);
+ }
+
+ /**
* Set the labeled enum resolver service implementation
*
* @param labeledEnumResolver
@@ -313,6 +429,15 @@
}
/**
+ * Set the labeled enum resolver service implementation bean id
+ *
+ * @param labeledEnumResolverId bean id
+ */
+ public void setLabeledEnumResolverId( String labeledEnumResolverId ) {
+ services.put(LabeledEnumResolver.class, labeledEnumResolverId);
+ }
+
+ /**
* Set the message source service implementation
*
* @param messageSource
@@ -322,6 +447,15 @@
}
/**
+ * Set the message source service implementation bean id
+ *
+ * @param messageSourceId bean id
+ */
+ public void setMessageSourceId( String messageSourceId ) {
+ services.put(MessageSource.class, messageSourceId);
+ }
+
+ /**
* Set the message source accessor service implementation
*
* @param messageSourceAccessor
@@ -331,6 +465,15 @@
}
/**
+ * Set the message source accessor service implementation bean id
+ *
+ * @param messageSourceAccessorId bean id
+ */
+ public void setMessageSourceAccesorId( String messageSourceAccessorId ) {
+ services.put(MessageSourceAccessor.class, messageSourceAccessorId);
+ }
+
+ /**
* Set the rules source service implementation
*
* @param rulesSource
@@ -340,6 +483,15 @@
}
/**
+ * Set the rules source service implementation bean id
+ *
+ * @param rulesSourceId bean id
+ */
+ public void setRulesSourceId( String rulesSourceId ) {
+ services.put(RulesSource.class, rulesSourceId);
+ }
+
+ /**
* Set the security controller manager service implementation
*
* @param securityControllerManager instance to use
@@ -349,6 +501,15 @@
}
/**
+ * Set the security controller manager service implementation bean id
+ *
+ * @param securityControllerManagerId bean id
+ */
+ public void setSecurityControllerManagerId( String
securityControllerManagerId ) {
+ services.put(SecurityControllerManager.class,
securityControllerManagerId);
+ }
+
+ /**
* Set the value change detector service imlpementation.
*
* @param valueChangeDetector instance to use
@@ -358,6 +519,15 @@
}
/**
+ * Set the value change detector service imlpementation bean id
+ *
+ * @param valueChangeDetectorId bean id
+ */
+ public void setValueChangeDetectorId( String valueChangeDetectorId ) {
+ services.put(ValueChangeDetector.class, valueChangeDetectorId);
+ }
+
+ /**
* Set the view descriptor registry service implementation
*
* @param viewDescriptorRegistry
@@ -367,6 +537,15 @@
}
/**
+ * Set the view descriptor registry service implementation bean id
+ *
+ * @param viewDescriptorRegistryId bean id
+ */
+ public void setViewDescriptorRegistryId( String viewDescriptorRegistryId )
{
+ services.put(ViewDescriptorRegistry.class, viewDescriptorRegistryId);
+ }
+
+ /**
* Get the default implementation of a service according to the service
type. If no
* default implementation is available, then a null is returned.
*
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs