Revision: 1460
          http://svn.sourceforge.net/spring-rich-c/?rev=1460&view=rev
Author:   jhoskens
Date:     2006-09-28 04:09:47 -0700 (Thu, 28 Sep 2006)

Log Message:
-----------
refactoring modules: ApplicationServicesLocator and ApplicationServices are 
used throughout the whole project

Added Paths:
-----------
    
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServices.java
    
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServicesLocator.java

Copied: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServices.java
 (from rev 1457, 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationServices.java)
===================================================================
--- 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServices.java
                              (rev 0)
+++ 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServices.java
      2006-09-28 11:09:47 UTC (rev 1460)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.richclient.application;
+
+/**
+ * Service locator
+ * 
+ * @author Larry Streepy
+ */
+public interface ApplicationServices {
+
+    /**
+     * Get a service of the requested type (class).
+     * <p>
+     * TODO change to use a more specific exception like 
NoServiceImplementationException
+     * 
+     * @param serviceType Type of service to locate
+     * @return service implementation
+     * @throws UnsupportedOperationException if there is no service known for 
the given
+     *         serviceType.
+     */
+    Object getService( Class serviceType );
+
+    /**
+     * Determine if a service of the requested type is available.
+     * 
+     * @param serviceType Type of service to locate
+     * @return true if service is available, false if not
+     */
+    boolean containsService( Class serviceType );
+}


Property changes on: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServices.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServicesLocator.java
 (from rev 1457, 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationServicesLocator.java)
===================================================================
--- 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServicesLocator.java
                               (rev 0)
+++ 
trunk/spring-richclient/core/src/main/java/org/springframework/richclient/application/ApplicationServicesLocator.java
       2006-09-28 11:09:47 UTC (rev 1460)
@@ -0,0 +1,90 @@
+package org.springframework.richclient.application;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.util.Assert;
+
+/**
+ * This class provides a singleton model for accessing the configured 
ApplicationServices
+ * object.
+ * 
+ * @author Larry Streepy
+ * 
+ */
+public class ApplicationServicesLocator {
+
+    private static final Log logger = 
LogFactory.getLog(ApplicationServicesLocator.class);
+
+    /** The singleton instance. */
+    private static ApplicationServicesLocator INSTANCE;
+
+    /** The configured ApplicationServices. */
+    private ApplicationServices applicationServices;
+
+    /**
+     * Default Constructor.
+     */
+    public ApplicationServicesLocator() {
+        load(this);
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param applicationServices instance to use
+     */
+    public ApplicationServicesLocator( ApplicationServices applicationServices 
) {
+        setApplicationServices(applicationServices);
+        load(this);
+    }
+
+    /**
+     * Return the single ApplicationServicesLocator instance.
+     * 
+     * @return The instance
+     */
+    public static ApplicationServicesLocator instance() {
+        Assert.state(INSTANCE != null, "The application services locator 
instance has not yet been initialized.");
+        return INSTANCE;
+    }
+
+    /**
+     * Load the single ApplicationServicesLocator instance.
+     * 
+     * @param instance The ApplicationServicesLocator
+     */
+    public static void load( ApplicationServicesLocator instance ) {
+        if( INSTANCE != null ) {
+            logger.info("Replacing existing ApplicationServicesLocator 
instance with: " + instance);
+        }
+        INSTANCE = instance;
+    }
+
+    /**
+     * Return a global service locator for application services.
+     * 
+     * @return The application services locator.
+     */
+    public static ApplicationServices services() {
+        return instance().getApplicationServices();
+    }
+
+    /**
+     * Set the ApplicationServices instance to use
+     * 
+     * @param applicationServices
+     */
+    public void setApplicationServices( ApplicationServices 
applicationServices ) {
+        this.applicationServices = applicationServices;
+    }
+
+    /**
+     * Get the ApplicationServices to use
+     * 
+     * @return ApplicationServices instance
+     */
+    public ApplicationServices getApplicationServices() {
+        return applicationServices;
+    }
+
+}


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to