Author: alexsmirnov
Date: 2011-03-21 15:11:35 -0400 (Mon, 21 Mar 2011)
New Revision: 22288
Added:
trunk/core/api/src/main/java/org/richfaces/application/Initializable.java
trunk/core/api/src/main/javadoc/
trunk/core/api/src/main/javadoc/org/
trunk/core/api/src/main/javadoc/org/richfaces/
trunk/core/api/src/main/javadoc/org/richfaces/application/
trunk/core/api/src/main/javadoc/org/richfaces/application/services.png
trunk/core/api/src/main/javadoc/org/richfaces/application/services.uxf
Removed:
trunk/core/impl/src/main/java/org/richfaces/application/Initializable.java
Modified:
trunk/core/api/src/main/java/org/richfaces/application/Module.java
trunk/core/api/src/main/java/org/richfaces/application/ServiceException.java
trunk/core/api/src/main/java/org/richfaces/application/ServiceTracker.java
trunk/core/api/src/main/java/org/richfaces/application/ServicesFactory.java
Log:
RESOLVED - issue RFPL-1316: Create architectural document for framework: services -
ServiceTracker review
https://issues.jboss.org/browse/RFPL-1316
Copied: trunk/core/api/src/main/java/org/richfaces/application/Initializable.java (from
rev 22287, trunk/core/impl/src/main/java/org/richfaces/application/Initializable.java)
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/application/Initializable.java
(rev 0)
+++ trunk/core/api/src/main/java/org/richfaces/application/Initializable.java 2011-03-21
19:11:35 UTC (rev 22288)
@@ -0,0 +1,15 @@
+package org.richfaces.application;
+
+
+/**
+ * <p class="changed_added_4_0">Classes that require initialization and
release methods should implement this interface</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface Initializable {
+
+ public void init();
+
+ public void release();
+
+}
\ No newline at end of file
Modified: trunk/core/api/src/main/java/org/richfaces/application/Module.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/application/Module.java 2011-03-21 11:22:45
UTC (rev 22287)
+++ trunk/core/api/src/main/java/org/richfaces/application/Module.java 2011-03-21 19:11:35
UTC (rev 22288)
@@ -2,12 +2,16 @@
/**
- * <p class="changed_added_4_0">User-provided configuration
module.</p>
+ * <p class="changed_added_4_0">{@link ServicesFactory} configuration
module.</p>
* @author asmirnov(a)exadel.com
*
*/
public interface Module {
+ /**
+ * <p class="changed_added_4_0">This method called from
Initialization event listener. User can register their services there to override/extend
base functionality.</p>
+ * @param factory
+ */
public void configure(ServicesFactory factory);
}
Modified: trunk/core/api/src/main/java/org/richfaces/application/ServiceException.java
===================================================================
---
trunk/core/api/src/main/java/org/richfaces/application/ServiceException.java 2011-03-21
11:22:45 UTC (rev 22287)
+++
trunk/core/api/src/main/java/org/richfaces/application/ServiceException.java 2011-03-21
19:11:35 UTC (rev 22288)
@@ -26,7 +26,7 @@
import javax.faces.FacesException;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">Exception fired by service tracker if it
cannot create requested service.</p>
* @author asmirnov(a)exadel.com
*
*/
Modified: trunk/core/api/src/main/java/org/richfaces/application/ServiceTracker.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/application/ServiceTracker.java 2011-03-21
11:22:45 UTC (rev 22287)
+++ trunk/core/api/src/main/java/org/richfaces/application/ServiceTracker.java 2011-03-21
19:11:35 UTC (rev 22288)
@@ -31,10 +31,11 @@
* <p>Tracker class to provide access to various framework implementation
services.
* Examples of such services are: {@link org.richfaces.skin.SkinFactory}, TBD.</p>
*
- * <p>Supports JSR-330 dependency injection.</p>
*
- * <p>This class represents application-scoped object that is stored in the map
with {@link Thread#currentThread()} Context classloader. Therefore, there is
- * only one instance perr JEE application in the current JVM.</p>
+ * <p>This class managess application-scoped service factories that are stored in
the map with {@link Thread#currentThread()} Context classloader as the key. Therefore,
there is
+ * only one instance per JEE application in the current JVM.</p>
+ * <p> actuall cal for the service instance delegated to the current
factory</p>
+ * <img src="services.png" alt="services tracking class
diagramm"/>
*
*
* <p><b>Note:</b> in initial state this class is not synchronized and
presumes that all
@@ -54,14 +55,31 @@
private static final Map<ClassLoader, ServicesFactory> INSTANCES =
new ConcurrentHashMap<ClassLoader, ServicesFactory>();
+ /**
+ * <p class="changed_added_4_0">This class supposed to use with
static methods only and cannot be instantiated.</p>
+ */
private ServiceTracker() {
}
+ /**
+ * <p class="changed_added_4_0">Get service instance for given type.
This is a wrapper method for {@link #getService(FacesContext, Class)} that
+ * gets faces context by {@link FacesContext#getCurrentInstance()} call, if
needed.</p>
+ * @param <T> The service type, usually interface.
+ * @param target Service type class.
+ * @return service implementation instance.
+ */
public static <T> T getService(Class<T> target) {
return getServicesFactory().getInstance(target);
}
+ /**
+ * <p class="changed_added_4_0">Get service instance for given
type.</p>
+ * @param <T> The service type, usually interface.
+ * @param context current {@link FacesContext}.
+ * @param target Service type class.
+ * @return service instance.
+ */
public static <T> T getService(FacesContext context, Class<T> target) {
return getServicesFactory().getInstance(target);
}
@@ -85,7 +103,7 @@
}
/**
- * <p class="changed_added_4_0">Set dependency injection service
implementation.</p>
+ * <p class="changed_added_4_0">Set service factory implementation
for the current context.</p>
* @param factory
*/
public static void setFactory(ServicesFactory factory) {
@@ -93,7 +111,7 @@
}
/**
- * <p class="changed_added_4_0">Remove dependency injection service
associated with current context.</p>
+ * <p class="changed_added_4_0">Release factory service associated
with current context.</p>
*/
public static void release() {
ServicesFactory servicesFactory = INSTANCES.remove(getCurrentLoader());
Modified: trunk/core/api/src/main/java/org/richfaces/application/ServicesFactory.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/application/ServicesFactory.java 2011-03-21
11:22:45 UTC (rev 22287)
+++ trunk/core/api/src/main/java/org/richfaces/application/ServicesFactory.java 2011-03-21
19:11:35 UTC (rev 22288)
@@ -30,10 +30,26 @@
*/
public interface ServicesFactory {
+ /**
+ * <p class="changed_added_4_0">Get service instance associated with
given type, usually service interface or base abstract class.</p>
+ * @param <T> service type.
+ * @param type Base class implemented by service.
+ * @return Current service implementation.
+ * @throws ServiceException if factory cannot create requested service.
+ */
public <T> T getInstance(Class<T> type) throws ServiceException;
+ /**
+ * <p class="changed_added_4_0">Associate concrete instance with
service.</p>
+ * @param <T> service type.
+ * @param type Base class implemented by service.
+ * @param instance service instance.
+ */
public <T> void setInstance(Class<T> type, T instance);
+ /**
+ * <p class="changed_added_4_0">Release all services. </p>
+ */
public void release();
}
Added: trunk/core/api/src/main/javadoc/org/richfaces/application/services.png
===================================================================
(Binary files differ)
Property changes on:
trunk/core/api/src/main/javadoc/org/richfaces/application/services.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/core/api/src/main/javadoc/org/richfaces/application/services.uxf
===================================================================
--- trunk/core/api/src/main/javadoc/org/richfaces/application/services.uxf
(rev 0)
+++ trunk/core/api/src/main/javadoc/org/richfaces/application/services.uxf 2011-03-21
19:11:35 UTC (rev 22288)
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<diagram program="umlet" version="11.1">
+ <zoom_level>10</zoom_level>
+ <element>
+ <type>com.umlet.element.Class</type>
+ <coordinates>
+ <x>80</x>
+ <y>50</y>
+ <w>210</w>
+ <h>190</h>
+ </coordinates>
+ <panel_attributes><<Factory>>
+ServiceTracker
+{static methods only}
+--
+-servicesFactory: ServicesFactory
+--
+#getService(t: Class<T>): T
+</panel_attributes>
+ <additional_attributes/>
+ </element>
+ <element>
+ <type>com.umlet.element.Class</type>
+ <coordinates>
+ <x>460</x>
+ <y>100</y>
+ <w>190</w>
+ <h>50</h>
+ </coordinates>
+ <panel_attributes>/ServicesFactory/
+--
+#getService(t: Class<T>): T</panel_attributes>
+ <additional_attributes/>
+ </element>
+ <element>
+ <type>com.umlet.element.Relation</type>
+ <coordinates>
+ <x>260</x>
+ <y>80</y>
+ <w>220</w>
+ <h>50</h>
+ </coordinates>
+ <panel_attributes>lt=<<<-</panel_attributes>
+ <additional_attributes>30;30;200;30</additional_attributes>
+ </element>
+ <element>
+ <type>com.umlet.element.Relation</type>
+ <coordinates>
+ <x>420</x>
+ <y>120</y>
+ <w>172</w>
+ <h>160</h>
+ </coordinates>
+ <panel_attributes>lt=<.
+<<instanceOf>></panel_attributes>
+ <additional_attributes>90;30;90;140</additional_attributes>
+ </element>
+ <element>
+ <type>com.umlet.element.Class</type>
+ <coordinates>
+ <x>410</x>
+ <y>260</y>
+ <w>340</w>
+ <h>70</h>
+ </coordinates>
+ <panel_attributes>_concreteFactory: ServicesFactoryImpl_
+--
+</panel_attributes>
+ <additional_attributes/>
+ </element>
+ <element>
+ <type>com.umlet.element.Class</type>
+ <coordinates>
+ <x>90</x>
+ <y>310</y>
+ <w>200</w>
+ <h>90</h>
+ </coordinates>
+ <panel_attributes><<InitializationListener>>
+FacesInitListener</panel_attributes>
+ <additional_attributes/>
+ </element>
+ <element>
+ <type>com.umlet.element.Class</type>
+ <coordinates>
+ <x>430</x>
+ <y>410</y>
+ <w>240</w>
+ <h>60</h>
+ </coordinates>
+ <panel_attributes>/Module/
+--
+#init(f:ServicesFactory)
+</panel_attributes>
+ <additional_attributes/>
+ </element>
+ <element>
+ <type>com.umlet.element.Class</type>
+ <coordinates>
+ <x>470</x>
+ <y>540</y>
+ <w>100</w>
+ <h>30</h>
+ </coordinates>
+ <panel_attributes>UserModule
+--</panel_attributes>
+ <additional_attributes/>
+ </element>
+ <element>
+ <type>com.umlet.element.Relation</type>
+ <coordinates>
+ <x>440</x>
+ <y>440</y>
+ <w>172</w>
+ <h>120</h>
+ </coordinates>
+ <panel_attributes>lt=<.
+<<instanceOf>></panel_attributes>
+ <additional_attributes>90;30;90;100</additional_attributes>
+ </element>
+ <element>
+ <type>com.umlet.element.Relation</type>
+ <coordinates>
+ <x>260</x>
+ <y>270</y>
+ <w>170</w>
+ <h>110</h>
+ </coordinates>
+ <panel_attributes>lt=<.
+creates</panel_attributes>
+ <additional_attributes>150;30;30;90</additional_attributes>
+ </element>
+ <element>
+ <type>com.umlet.element.Relation</type>
+ <coordinates>
+ <x>100</x>
+ <y>210</y>
+ <w>154</w>
+ <h>120</h>
+ </coordinates>
+ <panel_attributes>lt=<.
+setFactory
+releaseFacroty</panel_attributes>
+ <additional_attributes>80;30;90;100</additional_attributes>
+ </element>
+ <element>
+ <type>com.umlet.element.Relation</type>
+ <coordinates>
+ <x>260</x>
+ <y>330</y>
+ <w>190</w>
+ <h>130</h>
+ </coordinates>
+ <panel_attributes>lt=<.
+init</panel_attributes>
+ <additional_attributes>170;110;30;30</additional_attributes>
+ </element>
+</diagram>
Deleted: trunk/core/impl/src/main/java/org/richfaces/application/Initializable.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/application/Initializable.java 2011-03-21
11:22:45 UTC (rev 22287)
+++ trunk/core/impl/src/main/java/org/richfaces/application/Initializable.java 2011-03-21
19:11:35 UTC (rev 22288)
@@ -1,15 +0,0 @@
-package org.richfaces.application;
-
-
-/**
- * <p class="changed_added_4_0">Classes that require initialization
should implement this interface</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface Initializable {
-
- public void init();
-
- public void release();
-
-}
\ No newline at end of file