Revision: 1134
Author: lstreepy
Date: 2006-05-10 13:39:19 -0700 (Wed, 10 May 2006)
ViewCVS: http://svn.sourceforge.net/spring-rich-c/?rev=1134&view=rev
Log Message:
-----------
Major refactoring of the application services handling to decouple it from
Application
and to get rid of the reliance on magic bean names.
Modified Paths:
--------------
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/PetClinicLifecycleAdvisor.java
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/pom.xml
trunk/spring-richclient/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/ContactView.java
trunk/spring-richclient/samples/simple/src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleListBinding.java
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/table/support/GlazedTableModel.java
trunk/spring-richclient/tiger/src/main/java/org/springframework/richclient/exception/I18nUncaughtExceptionHandler.java
Modified:
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/PetClinicLifecycleAdvisor.java
===================================================================
---
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/PetClinicLifecycleAdvisor.java
2006-05-10 20:35:43 UTC (rev 1133)
+++
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/PetClinicLifecycleAdvisor.java
2006-05-10 20:39:19 UTC (rev 1134)
@@ -30,8 +30,8 @@
public class PetClinicLifecycleAdvisor extends
DefaultApplicationLifecycleAdvisor {
public void onPreWindowOpen(ApplicationWindowConfigurer configurer) {
super.onPreWindowOpen(configurer);
- if (getApplicationServices().containsBean("setupWizard")) {
- SetupWizard setupWizard =
(SetupWizard)getApplicationServices().getBean("setupWizard", SetupWizard.class);
+ if
(getApplication().getApplicationContext().containsBean("setupWizard")) {
+ SetupWizard setupWizard =
(SetupWizard)getApplication().getApplicationContext().getBean("setupWizard",
SetupWizard.class);
setupWizard.execute();
}
// comment out to hide the menubar, toolbar, or reduce window size...
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-10 20:35:43 UTC (rev 1133)
+++
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
2006-05-10 20:39:19 UTC (rev 1134)
@@ -34,32 +34,45 @@
</property>
</bean>
- <bean id="applicationObjectConfigurer"
+ <!--
+ Bean: serviceLocator
+ Usage: Platform required
+ Description: This defines the singleton application service locator
instance.
+ This is a trivial singleton object providing access to the
configured
+ services, as specified on the applicationServices property.
+ -->
+ <bean id="serviceLocator"
class="org.springframework.richclient.application.ApplicationServicesLocator">
+ <property name="applicationServices" ref="applicationServices"/>
+ </bean>
+
+ <!--
+ Bean: applicationServices
+ 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).
+ -->
+ <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>
+ </bean>
+
+ <bean id="applicationObjectConfigurer" depends-on="serviceLocator"
class="org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer">
- <constructor-arg index="0">
- <ref bean="messageSource"/>
- </constructor-arg>
- <constructor-arg index="1">
- <ref bean="imageSource"/>
- </constructor-arg>
- <constructor-arg index="2">
- <ref bean="iconSource"/>
- </constructor-arg>
</bean>
<bean id="applicationEventMulticaster"
class="org.springframework.context.event.SimpleApplicationEventMulticaster"/>
- <bean id="componentFactory"
-
class="org.springframework.richclient.factory.DefaultComponentFactory">
- <property name="iconSource">
- <ref bean="iconSource"/>
- </property>
- <property name="messageSource">
- <ref bean="messageSource"/>
- </property>
- </bean>
-
<bean id="binderSelectionStrategy"
class="org.springframework.richclient.form.binding.swing.SwingBinderSelectionStrategy">
<property name="bindersForPropertyTypes">
@@ -128,13 +141,6 @@
</property>
</bean>
- <bean id="iconSource"
- class="org.springframework.richclient.image.DefaultIconSource">
- <constructor-arg index="0">
- <ref bean="imageSource"/>
- </constructor-arg>
- </bean>
-
<bean id="formComponentInterceptorFactory"
class="org.springframework.richclient.form.builder.support.ChainedInterceptorFactory">
<property name="interceptorFactories">
@@ -154,9 +160,6 @@
<bean id="rulesSource"
class="org.springframework.richclient.samples.petclinic.domain.PetClinicValidationRulesSource"/>
- <bean id="formPropertyFaceDescriptorSource"
-
class="org.springframework.binding.form.support.MessageSourceFormPropertyFaceDescriptorSource"/>
-
<bean id="ownerManagerView"
class="org.springframework.richclient.application.support.DefaultViewDescriptor">
<property name="viewClass">
Modified: trunk/spring-richclient/samples/simple/pom.xml
===================================================================
--- trunk/spring-richclient/samples/simple/pom.xml 2006-05-10 20:35:43 UTC
(rev 1133)
+++ trunk/spring-richclient/samples/simple/pom.xml 2006-05-10 20:39:19 UTC
(rev 1134)
@@ -17,7 +17,25 @@
This application provides a very simple example of how to use the
basic features of the Spring Rich Client platform.
</description>
-
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+
<mainClass>org.springframework.richclient.samples.simple.app.SimpleApp</mainClass>
+ <addClasspath>true</addClasspath>
+ <addExtensions/>
+ <classpathPrefix>../../lib</classpathPrefix>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<!-- Internal -->
Modified:
trunk/spring-richclient/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/ContactView.java
===================================================================
---
trunk/spring-richclient/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/ContactView.java
2006-05-10 20:35:43 UTC (rev 1133)
+++
trunk/spring-richclient/samples/simple/src/main/java/org/springframework/richclient/samples/simple/ui/ContactView.java
2006-05-10 20:39:19 UTC (rev 1134)
@@ -284,9 +284,6 @@
* state.
*/
private class DeleteExecutor extends AbstractActionCommandExecutor {
- public DeleteExecutor() {
- getApplicationServices().configure(this, "delete");
- }
/**
* Execute this command.
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-10 20:35:43 UTC (rev 1133)
+++
trunk/spring-richclient/samples/simple/src/main/resources/org/springframework/richclient/samples/simple/ctx/richclient-application-context.xml
2006-05-10 20:39:19 UTC (rev 1134)
@@ -6,11 +6,16 @@
<!--
The application context is used to configure components and services
within
- the platform. The platform defines a number of "magic" bean names
that it
- uses to locate specific components, so they must be named exactly as
shown.
- These magic beans are identified in the documentation below and they
are
- marked as required or optional.
+ the platform. The platform utilizes a number of services at runtime,
and
+ these must be configured here. The two key beans for this are the
serviceLocator
+ and applicationServices. Many of the services have reasonable default
+ implementations, meaning that you probably won't need to define them
here
+ unless you have specific needs not addressed in the default
implementation.
+ Beyond the services, you will define the various components that make
up
+ your application, like the application descriptor, views, lifecycle
advisor,
+ validation rules, etc.
+
This may look a little daunting at first, but hang in there. The good
news
is that you don't have to change many of the bean configurations
provided
here when you are setting up your application.
@@ -28,8 +33,7 @@
<!--
Bean: application
- Type: magic
- Usage: required
+ Usage: Platform required
Description: This defines the singleton application instance to be
used.
Note that, currently, this object is not pluggable. You must use
the
class specified below and configure it as needed.
@@ -42,8 +46,7 @@
<!--
Bean: lifecycleAdvisor
- Type: user named
- Usage: required
+ Usage: Platform required
Description: This defines the LifecycleAdvisor instance to be used by
the
Application. Note the reference to this bean in the constructor
args in the application bean. If you don't need any special
handling
@@ -71,6 +74,37 @@
</bean>
<!--
+ Bean: serviceLocator
+ Usage: Platform required
+ Description: This defines the singleton application service locator
instance.
+ This is a trivial singleton object providing access to the
configured
+ services, as specified on the applicationServices property.
+ -->
+ <bean id="serviceLocator"
class="org.springframework.richclient.application.ApplicationServicesLocator">
+ <property name="applicationServices" ref="applicationServices"/>
+ </bean>
+
+ <!--
+ Bean: applicationServices
+ 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).
+ -->
+ <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>
+ </bean>
+
+ <!--
Bean: applicationEventMulticaster
Type: magic
Usage: platform required
@@ -82,7 +116,6 @@
<!--
Bean: applicationDescriptor
- Type: user named
Usage: platform required
Description: This defines the Application metadata to be used by the
Application. Note the reference to this bean in the constructor
@@ -95,43 +128,17 @@
</bean>
<!--
- Bean: applicationDescriptor
- Type: magic
- Usage: platform required (because it requires configuration)
+ Bean: applicationObjectConfigurer
+ Usage: platform required (because it is a bean post processor)
Description: This defines the object responsible for configuring other
objects
constructed via the platform. This is a critical part of the I18N
support.
- Unless you have very special needs, you should use the default
implementation,
- as is done here. The implementation is configured with three other
- components responsible for providing I18N messages, images, and
icons.
-->
- <bean id="applicationObjectConfigurer"
+ <bean id="applicationObjectConfigurer" depends-on="serviceLocator"
class="org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer">
- <constructor-arg index="0" ref="messageSource"/>
- <constructor-arg index="1" ref="imageSource"/>
- <constructor-arg index="2" ref="iconSource"/>
</bean>
<!--
- Bean: componentFactory
- Type: magic
- Usage: platform required (because it requires configuration)
- Description: This defines the factory responsible for constructing UI
- components that are configured according to the platform standards.
- This is a critical part of the I18N support.
- If you have special needs when constructing UI controls, then you
- may need to override the default implementation.
- The imlpementation is configured with two other
- components responsible for providing I18N messages and icons.
- -->
- <bean id="componentFactory"
-
class="org.springframework.richclient.factory.DefaultComponentFactory">
- <property name="iconSource" ref="iconSource"/>
- <property name="messageSource" ref="messageSource"/>
- </bean>
-
- <!--
Bean: lookAndFeelConfigurer
- Type: magic
Usage: platform optional
Description: The platform doesn't specifically make direct use of this
object (other than instantiating it). It is expected that the
object
@@ -149,7 +156,6 @@
<!--
Bean: messageSource
- Type: user named
Usage: platform required (not really, but you can't do much without it)
Description: This specifies the component that is responsible for
providing
messages (all kinds of text) to the platform. This is a critical
piece
@@ -172,7 +178,6 @@
<!--
Bean: imageResourcesFactory
- Type: user named
Usage: platform required (if you are using the DefaultImageSource, see
below)
Description: This specifies the component that is responsible for
providing
image resources locations. This factory uses the specified
properties
@@ -206,21 +211,7 @@
</bean>
<!--
- Bean: iconSource
- Type: user named
- Usage: platform required (because it requires configuration)
- Description: This specifies the component that is responsible for
providing
- icons to the platform. It makes use of an image source to locate
the
- image resources for the named icons.
- -->
- <bean id="iconSource"
- class="org.springframework.richclient.image.DefaultIconSource">
- <constructor-arg index="0" ref="imageSource"/>
- </bean>
-
- <!--
Bean: formComponentInterceptorFactory
- Type: magic
Usage: platform optional
Description: This specifies the list of interceptors to attach to
controls
constructed by the platform. This allows for a declarative model
for
@@ -245,7 +236,6 @@
<!--
Bean: rulesSource
- Type: magic
Usage: platform optional
Description: This specifies the component that will supply validation
rules
for properties bound into forms. This allows validation rules to
be
@@ -256,7 +246,6 @@
<!--
Bean: conversionService
- Type: user named
Usage: platform optional
Description: This specifies the component that will supply converters
for property values. Since we are going to add a special converter
@@ -288,7 +277,6 @@
<!--
Bean: applicationEventRedispatcher
- Type: user named
Usage: application
Description: An object to redispatch application events. See it's
class
documentation for why this is needed.
@@ -299,7 +287,6 @@
<!--
Bean: contactDataStore
- Type: user named
Usage: application
Description: Defines the data store holding all the contacts.
-->
Modified:
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleListBinding.java
===================================================================
---
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleListBinding.java
2006-05-10 20:35:43 UTC (rev 1133)
+++
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/components/ShuttleListBinding.java
2006-05-10 20:39:19 UTC (rev 1134)
@@ -21,9 +21,10 @@
import org.springframework.binding.value.ValueModel;
import org.springframework.binding.value.support.BufferedCollectionValueModel;
import org.springframework.binding.value.support.ListListModel;
-import org.springframework.richclient.application.Application;
-import org.springframework.richclient.application.ApplicationServices;
+import org.springframework.context.MessageSource;
+import org.springframework.richclient.application.ApplicationServicesLocator;
import org.springframework.richclient.form.binding.support.AbstractBinding;
+import org.springframework.richclient.image.IconSource;
import org.springframework.richclient.list.DynamicListModel;
/**
@@ -134,15 +135,15 @@
}
private String getMsgText( String key, String defaultMsg ) {
- final ApplicationServices services = Application.services();
+ final MessageSource messageSource =
(MessageSource)ApplicationServicesLocator.services().getService(MessageSource.class);
String text = null;
if( getFormId() != null ) {
- text = services.getMessage(getFormId() + "." + key, null, null,
null);
+ text = messageSource.getMessage(getFormId() + "." + key, null,
null, null);
}
if( text == null ) {
- text = services.getMessage(key, null, defaultMsg, null);
+ text = messageSource.getMessage(key, null, defaultMsg, null);
}
return text;
@@ -155,16 +156,16 @@
* @return an Icon
*/
private Icon getEditIcon() {
- final ApplicationServices services = Application.services();
+ final IconSource iconSource =
(IconSource)ApplicationServicesLocator.services().getService(IconSource.class);
// @TODO find the form Id.
Icon icon = null;
if( getFormId() != null ) {
- icon = services.getIcon(getFormId() + ".shuttleList.edit");
+ icon = iconSource.getIcon(getFormId() + ".shuttleList.edit");
}
if( icon == null ) {
- icon = services.getIcon("shuttleList.edit");
+ icon = iconSource.getIcon("shuttleList.edit");
}
return icon;
}
Modified:
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/table/support/GlazedTableModel.java
===================================================================
---
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/table/support/GlazedTableModel.java
2006-05-10 20:35:43 UTC (rev 1133)
+++
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/table/support/GlazedTableModel.java
2006-05-10 20:39:19 UTC (rev 1134)
@@ -23,7 +23,7 @@
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.support.MessageSourceAccessor;
-import org.springframework.richclient.application.Application;
+import org.springframework.richclient.application.ApplicationServicesLocator;
import org.springframework.richclient.factory.LabelInfoFactory;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -142,7 +142,7 @@
protected MessageSourceAccessor getMessages() {
if (messages == null) {
- messages = Application.services().getMessages();
+ messages =
(MessageSourceAccessor)ApplicationServicesLocator.services().getService(MessageSourceAccessor.class);
}
return messages;
}
Modified:
trunk/spring-richclient/tiger/src/main/java/org/springframework/richclient/exception/I18nUncaughtExceptionHandler.java
===================================================================
---
trunk/spring-richclient/tiger/src/main/java/org/springframework/richclient/exception/I18nUncaughtExceptionHandler.java
2006-05-10 20:35:43 UTC (rev 1133)
+++
trunk/spring-richclient/tiger/src/main/java/org/springframework/richclient/exception/I18nUncaughtExceptionHandler.java
2006-05-10 20:39:19 UTC (rev 1134)
@@ -8,6 +8,7 @@
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.richclient.application.Application;
+import org.springframework.richclient.application.ApplicationServicesLocator;
import javax.swing.JOptionPane;
import java.util.ArrayList;
@@ -75,7 +76,7 @@
public void afterPropertiesSet() {
if (messageSourceAccessor == null) {
- messageSourceAccessor = Application.services().getMessages();
+ messageSourceAccessor = (MessageSourceAccessor)
ApplicationServicesLocator.services().getService(MessageSourceAccessor.class);
}
if (registerAsDefaultOnInitialization) {
Thread.setDefaultUncaughtExceptionHandler(this);
@@ -89,7 +90,7 @@
public static class ExceptionHandlerAdapterHack {
public void handle(Throwable e) {
Thread.UncaughtExceptionHandler uncaughtExceptionHandler
- = (Thread.UncaughtExceptionHandler)
Application.instance().getServices()
+ = (Thread.UncaughtExceptionHandler)
Application.instance().getApplicationContext()
.getBean(REQUIRED_BEAN_NAME);
if (uncaughtExceptionHandler == null) {
throw new RuntimeException("No bean found with name " +
REQUIRED_BEAN_NAME);
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