Author: tv
Date: Tue Mar 24 13:46:25 2009
New Revision: 757801
URL: http://svn.apache.org/viewvc?rev=757801&view=rev
Log:
Removed the Intake class. It was duplicating the IntakeServiceFacade.
Moved the initialization code of the service implementation to initialize()
Removed:
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/Intake.java
Modified:
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeService.java
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceFacade.java
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
turbine/fulcrum/trunk/intake/xdocs/changes.xml
Modified:
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeService.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeService.java?rev=757801&r1=757800&r2=757801&view=diff
==============================================================================
---
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeService.java
(original)
+++
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeService.java
Tue Mar 24 13:46:25 2009
@@ -48,11 +48,22 @@
String ROLE = IntakeService.class.getName();
/**
+ * The configuration property specifying the location of the xml
specification.
+ */
+ String XML_PATHS = "xmlPaths";
+
+ /**
* The default location of the xml specification.
*/
String XML_PATH_DEFAULT = "WEB-INF/conf/intake.xml";
/**
+ * The configuration property specifying the location where a serialized
version of the
+ * xml specification can be written for faster restarts..
+ */
+ String SERIAL_XML = "serialDataPath";
+
+ /**
* The default location where a serialized version of
* the xml specification can be written for faster restarts..
*/
Modified:
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceFacade.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceFacade.java?rev=757801&r1=757800&r2=757801&view=diff
==============================================================================
---
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceFacade.java
(original)
+++
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceFacade.java
Tue Mar 24 13:46:25 2009
@@ -45,6 +45,15 @@
private static IntakeService intakeService;
/**
+ * Return whether the intake service has been initialized.
+ * @return
+ */
+ public static boolean isInitialized()
+ {
+ return (!(intakeService == null));
+ }
+
+ /**
* Gets an instance of a named group either from the pool or by calling the
* Factory Service if the pool is empty.
*
Modified:
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java?rev=757801&r1=757800&r2=757801&view=diff
==============================================================================
---
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
(original)
+++
turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
Tue Mar 24 13:46:25 2009
@@ -36,7 +36,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Vector;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configurable;
@@ -94,17 +93,12 @@
/** The Avalon Container root directory */
private String applicationRoot;
- /**
- * The property specifying the location of the xml specification.
- */
- String XML_PATHS = "xmlPaths";
-
- /**
- * The property specifying the location where a serialized version of the
- * xml specification can be written for faster restarts..
- */
- String SERIAL_XML = "serialDataPath";
-
+ /** List of configured xml specification files */
+ private List xmlPathes = null;
+
+ /** Configured location of the serialization file */
+ private String serialDataPath = null;
+
/**
* Registers a given group name in the system
*
@@ -598,12 +592,10 @@
*/
public void configure(Configuration conf) throws ConfigurationException
{
+ final Configuration xmlPaths = conf.getChild(XML_PATHS, false);
- Vector defaultXmlPathes = new Vector();
- defaultXmlPathes.add(XML_PATH_DEFAULT);
+ xmlPathes = new ArrayList();
- final Configuration xmlPaths = conf.getChild(XML_PATHS, false);
- List xmlPathes = new ArrayList();
if (xmlPaths == null)
{
xmlPathes.add(XML_PATH_DEFAULT);
@@ -618,9 +610,7 @@
}
}
- Map appDataElements = null;
-
- String serialDataPath = conf.getChild(SERIAL_XML,
false).getValue(SERIAL_XML_DEFAULT);
+ serialDataPath = conf.getChild(SERIAL_XML,
false).getValue(SERIAL_XML_DEFAULT);
if (!serialDataPath.equalsIgnoreCase("none"))
{
@@ -632,6 +622,18 @@
}
getLogger().debug("Path for serializing: " + serialDataPath);
+ }
+
+ /**
+ * Avalon component lifecycle method Initializes the service by loading
+ * default class loaders and customized object factories.
+ *
+ * @throws Exception
+ * if initialization fails.
+ */
+ public void initialize() throws Exception
+ {
+ Map appDataElements = null;
groupNames = new HashMap();
groupKeyMap = new HashMap();
@@ -658,7 +660,7 @@
+ xmlPath + ". Looking for file " + xmlFile;
getLogger().error(READ_ERR);
- throw new ConfigurationException(READ_ERR);
+ throw new Exception(READ_ERR);
}
xmlFiles.add(xmlFile.toString());
@@ -691,17 +693,10 @@
AppData appData = null;
getLogger().debug("Now parsing: " + xmlPath);
- try
- {
- XmlToAppData xmlApp = new XmlToAppData();
- xmlApp.enableLogging(getLogger());
- appData = xmlApp.parseFile(xmlPath);
- }
- catch (Exception e)
- {
- throw new ConfigurationException(
- "Could not parse XML file " + xmlPath, e);
- }
+
+ XmlToAppData xmlApp = new XmlToAppData();
+ xmlApp.enableLogging(getLogger());
+ appData = xmlApp.parseFile(xmlPath);
appDataElements.put(appData, xmlPath);
getLogger().debug("Saving appData for " + xmlPath);
@@ -710,89 +705,67 @@
saveSerialized(serialDataPath, appDataElements);
}
- try
+ for (Iterator it = appDataElements.keySet().iterator(); it.hasNext();)
{
- for (Iterator it = appDataElements.keySet().iterator(); it
- .hasNext();)
- {
- AppData appData = (AppData) it.next();
+ AppData appData = (AppData) it.next();
- int maxPooledGroups = 0;
- List glist = appData.getGroups();
+ int maxPooledGroups = 0;
+ List glist = appData.getGroups();
- String groupPrefix = appData.getGroupPrefix();
+ String groupPrefix = appData.getGroupPrefix();
- for (int i = glist.size() - 1; i >= 0; i--)
- {
- XmlGroup g = (XmlGroup) glist.get(i);
- String groupName = g.getName();
+ for (int i = glist.size() - 1; i >= 0; i--)
+ {
+ XmlGroup g = (XmlGroup) glist.get(i);
+ String groupName = g.getName();
- boolean registerUnqualified = registerGroup(groupName, g,
- appData, true);
+ boolean registerUnqualified = registerGroup(groupName, g,
+ appData, true);
- if (!registerUnqualified)
- {
- getLogger().info(
- "Ignored redefinition of Group " + groupName
- + " or Key " + g.getKey() + " from "
- + appDataElements.get(appData));
- }
+ if (!registerUnqualified)
+ {
+ getLogger().info(
+ "Ignored redefinition of Group " + groupName
+ + " or Key " + g.getKey() + " from "
+ + appDataElements.get(appData));
+ }
- if (groupPrefix != null)
+ if (groupPrefix != null)
+ {
+ StringBuffer qualifiedName = new StringBuffer();
+ qualifiedName.append(groupPrefix).append(':').append(
+ groupName);
+
+ // Add the fully qualified group name. Do _not_ check
+ // for
+ // the existence of the key if the unqualified
+ // registration succeeded
+ // (because then it was added by the registerGroup
+ // above).
+ if (!registerGroup(qualifiedName.toString(), g,
+ appData, !registerUnqualified))
{
- StringBuffer qualifiedName = new StringBuffer();
- qualifiedName.append(groupPrefix).append(':').append(
- groupName);
-
- // Add the fully qualified group name. Do _not_ check
- // for
- // the existence of the key if the unqualified
- // registration succeeded
- // (because then it was added by the registerGroup
- // above).
- if (!registerGroup(qualifiedName.toString(), g,
- appData, !registerUnqualified))
- {
- getLogger()
- .error(
- "Could not register fully
qualified name "
- + qualifiedName
- + ", maybe two XML files
have the same prefix. Ignoring it.");
- }
+ getLogger().error(
+ "Could not register fully qualified name "
+ + qualifiedName
+ + ", maybe two XML files have the same
prefix. Ignoring it.");
}
-
- maxPooledGroups = Math.max(maxPooledGroups, Integer
- .parseInt(g.getPoolCapacity()));
-
}
- KeyedPoolableObjectFactory factory = new Group.GroupFactory(
- appData);
- keyedPools.put(appData, new StackKeyedObjectPool(factory,
- maxPooledGroups));
+ maxPooledGroups = Math.max(maxPooledGroups, Integer
+ .parseInt(g.getPoolCapacity()));
+
}
+ KeyedPoolableObjectFactory factory = new Group.GroupFactory(
+ appData);
+ keyedPools.put(appData, new StackKeyedObjectPool(factory,
+ maxPooledGroups));
}
- catch (Exception e)
- {
- throw new ConfigurationException(
- "IntakeServiceImpl failed to initialize", e);
- }
- }
- /**
- * Avalon component lifecycle method Initializes the service by loading
- * default class loaders and customized object factories.
- *
- * @throws Exception
- * if initialization fails.
- */
- public void initialize() throws Exception
- {
- Intake.setIntakeService(this);
if (getLogger().isInfoEnabled())
{
- getLogger().info("Intake Service is Initialized now..");
+ getLogger().info("Intake Service is initialized now.");
}
}
Modified:
turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java?rev=757801&r1=757800&r2=757801&view=diff
==============================================================================
---
turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
(original)
+++
turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
Tue Mar 24 13:46:25 2009
@@ -43,12 +43,16 @@
}
- public void testFacadeNotConfigured() throws Exception
+ /*
+ * This looks strange to me. A test should not bother with explicit
initialization.
+ * That's the task of the container.
+ */
+ public void OFFtestFacadeNotConfigured() throws Exception
{
- assertFalse(Intake.isInitialized());
+ assertFalse(IntakeServiceFacade.isInitialized());
try
{
- Intake.getGroup("test");
+ IntakeServiceFacade.getGroup("test");
}
catch (RuntimeException re)
{
@@ -62,8 +66,8 @@
IntakeService is = (IntakeService) this.resolve(
IntakeService.class.getName() );
Group group = is.getGroup("LoginGroup");
assertNotNull(group);
- assertTrue(Intake.isInitialized());
- group = Intake.getGroup("LoginGroup");
+ assertTrue(IntakeServiceFacade.isInitialized());
+ group = IntakeServiceFacade.getGroup("LoginGroup");
assertNotNull(group);
}
@@ -72,8 +76,8 @@
IntakeService is = (IntakeService) this.resolve(
IntakeService.class.getName() );
Group group = is.getGroup("BooleanTest");
assertNotNull(group);
- assertTrue(Intake.isInitialized());
- group = Intake.getGroup("BooleanTest");
+ assertTrue(IntakeServiceFacade.isInitialized());
+ group = IntakeServiceFacade.getGroup("BooleanTest");
Field booleanField = group.get("EmptyBooleanTestField");
assertTrue("The Default Validator of an intake Field type boolean
should be BooleanValidator", (booleanField.getValidator() instanceof
BooleanValidator));
assertFalse("An Empty intake Field type boolean should not be
required", booleanField.isRequired());
@@ -84,8 +88,8 @@
IntakeService is = (IntakeService) this.resolve(
IntakeService.class.getName() );
Group group = is.getGroup("BooleanTest");
assertNotNull(group);
- assertTrue(Intake.isInitialized());
- group = Intake.getGroup("BooleanTest");
+ assertTrue(IntakeServiceFacade.isInitialized());
+ group = IntakeServiceFacade.getGroup("BooleanTest");
Field booleanField = group.get("BooleanTestField");
assertTrue("The Default Validator of an intake Field type boolean
should be BooleanValidator", (booleanField.getValidator() instanceof
BooleanValidator));
assertFalse("An intake Field type boolean, which is not required,
should not be required", booleanField.isRequired());
@@ -96,8 +100,8 @@
IntakeService is = (IntakeService) this.resolve(
IntakeService.class.getName() );
Group group = is.getGroup("BooleanTest");
assertNotNull(group);
- assertTrue(Intake.isInitialized());
- group = Intake.getGroup("BooleanTest");
+ assertTrue(IntakeServiceFacade.isInitialized());
+ group = IntakeServiceFacade.getGroup("BooleanTest");
Field booleanField = group.get("RequiredBooleanTestField");
assertTrue("The Default Validator of an intake Field type boolean
should be BooleanValidator", (booleanField.getValidator() instanceof
BooleanValidator));
assertTrue("An intake Field type boolean, which is required, should be
required", booleanField.isRequired());
Modified: turbine/fulcrum/trunk/intake/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/xdocs/changes.xml?rev=757801&r1=757800&r2=757801&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/xdocs/changes.xml (original)
+++ turbine/fulcrum/trunk/intake/xdocs/changes.xml Tue Mar 24 13:46:25 2009
@@ -26,6 +26,12 @@
<body>
<release version="1.0.4-dev" date="in Subversion">
+ <action type="remove" dev="tv">
+ Removed the Intake class. It was duplicating the IntakeServiceFacade.
+ </action>
+ <action type="update" dev="tv">
+ Moved the initialization code of the service implementation to
initialize()
+ </action>
<action type="fix" dev="tv" issue="TRB-68" due-to="Ronny Voelker">
Intake did not correctly parse the message of a rule or
required-message from intake.xml
</action>