You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/11/15 17:05:18 UTC
cvs commit: jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake IntakeServiceImpl.java
epugh 2003/11/15 08:05:18
Modified: intake project.xml
intake/src/test/org/apache/fulcrum/intake IntakeTest.java
IntakeServiceTest.java
intake/xdocs changes.xml
intake/src/java/org/apache/fulcrum/intake
IntakeServiceImpl.java
Added: intake maven.xml
intake/conf config.xml block.xml
Removed: intake/src/test TestRoleConfig.xml TestComponentConfig.xml
Log:
Merlinized component.
Revision Changes Path
1.3 +31 -24 jakarta-turbine-fulcrum/intake/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/project.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- project.xml 16 Oct 2003 12:26:55 -0000 1.2
+++ project.xml 15 Nov 2003 16:05:18 -0000 1.3
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<project>
- <extend>${basedir}/../project.xml</extend>
+ <extend>${basedir}/../merlin-project.xml</extend>
<id>fulcrum-intake</id>
<name>Fulcrum Intake Component</name>
- <currentVersion>1.0-alpha-1</currentVersion>
+ <currentVersion>1.0-alpha-2</currentVersion>
<dependencies>
<dependency>
@@ -14,12 +14,12 @@
<dependency>
<groupId>fulcrum</groupId>
- <artifactId>fulcrum-localization</artifactId>
- <version>1.0-alpha-3</version>
+ <artifactId>fulcrum-localization-api</artifactId>
+ <version>1.0-alpha-4</version>
</dependency>
<dependency>
<groupId>fulcrum</groupId>
- <artifactId>fulcrum-factory</artifactId>
+ <artifactId>fulcrum-factory-api</artifactId>
<version>1.0-alpha-1</version>
</dependency>
@@ -43,25 +43,19 @@
<artifactId>oro</artifactId>
<version>2.0.7</version>
</dependency>
+ <dependency>
+ <id>commons-lang</id>
+ <version>2.0</version>
+ </dependency>
<!-- Needed only for testing -->
- <dependency>
- <groupId>fulcrum</groupId>
- <artifactId>fulcrum-testcontainer</artifactId>
- <version>1.0-alpha-1</version>
- </dependency>
<dependency>
- <id>xerces:xercesImpl</id>
- <version>2.0.2</version>
- <url>http://xml.apache.org/xerces2-j/</url>
+ <groupId>merlin</groupId>
+ <artifactId>merlin-unit</artifactId>
+ <version>3.2.2-dev</version>
</dependency>
- <dependency>
- <id>xerces:xmlParserAPIs</id>
- <version>2.0.2</version>
- <url>http://xml.apache.org/xerces2-j/</url>
- </dependency>
<!-- Needed for compilation -->
<dependency>
<id>servletapi</id>
@@ -70,17 +64,30 @@
</dependencies>
-<build>
+ <build>
<resources>
+ <resource>
+ <directory>src/dtd</directory>
+ <includes>
+ <include>intake.dtd</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${basedir}/conf</directory>
+ <targetPath>BLOCK-INF</targetPath>
+ <includes>
+ <include>block.xml</include>
+ </includes>
+ </resource>
<resource>
- <directory>src/dtd</directory>
- <targetPath>/</targetPath>
+ <directory>${basedir}/src/java</directory>
<includes>
- <include>intake.dtd</include>
+ <include>**/*.x*</include>
</includes>
- </resource>
+ </resource>
</resources>
- <jars></jars>
</build>
+
+
</project>
1.1 jakarta-turbine-fulcrum/intake/maven.xml
Index: maven.xml
===================================================================
<project default="jar:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util">
<preGoal name="java:compile">
<attainGoal name="avalon:meta"/>
</preGoal>
</project>
1.1 jakarta-turbine-fulcrum/intake/conf/config.xml
Index: config.xml
===================================================================
<targets>
<target path="/test/intake">
<categories priority="INFO"/>
</target>
</targets>
1.1 jakarta-turbine-fulcrum/intake/conf/block.xml
Index: block.xml
===================================================================
<container name="test">
<classloader>
<classpath>
<repository>
<resource id="fulcrum:fulcrum-localization-api" version="1.0-alpha-3"/>
<resource id="fulcrum:fulcrum-localization-impl" version="1.0-alpha-3"/>
<resource id="fulcrum:fulcrum-factory-api" version="1.0-alpha-1"/>
<resource id="fulcrum:fulcrum-factory-impl" version="1.0-alpha-1"/>
<resource id="servletapi:servletapi" version="2.3"/>
<resource id="commons-lang:commons-lang" version="2.0"/>
<resource id="commons-logging:commons-logging" version="1.0.3"/>
</repository>
</classpath>
</classloader>
<component name="localization"
class="org.apache.fulcrum.localization.DefaultLocalizationService">
<configuration>
<bundles>
<bundle>org.apache.fulcrum.localization.BarBundle</bundle>
<bundle>org.apache.fulcrum.localization.FooBundle</bundle>
</bundles>
</configuration>
</component>
<component name="factory"
class="org.apache.fulcrum.factory.DefaultFactoryService"/>
<component name="intake"
class="org.apache.fulcrum.intake.IntakeServiceImpl"
activation="lazy">
<configuration>
<serialDataPath>../../target/appData.ser</serialDataPath>
<xmlPaths>
<xmlPath>../../src/test/intake1.xml</xmlPath>
<xmlPath>../../src/test/intake2.xml</xmlPath>
</xmlPaths>
</configuration>
</component>
</container>
1.2 +4 -4 jakarta-turbine-fulcrum/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
Index: IntakeTest.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IntakeTest.java 14 Oct 2003 09:03:28 -0000 1.1
+++ IntakeTest.java 15 Nov 2003 16:05:18 -0000 1.2
@@ -59,14 +59,14 @@
import junit.framework.TestSuite;
import org.apache.fulcrum.intake.model.Group;
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.avalon.merlin.unit.AbstractMerlinTestCase;
/**
* Test the facade class for the service
*
* @author <a href="epugh@upstate.com">Eric Pugh</a>
* @version $Id$
*/
-public class IntakeTest extends BaseUnitTest
+public class IntakeTest extends AbstractMerlinTestCase
{
/**
* Defines the testcase name for JUnit.
@@ -114,7 +114,7 @@
public void testFacadeConfigured() throws Exception
{
// this.lookup causes the workflow service to be configured.
- this.lookup(IntakeService.ROLE);
+ this.resolve( "intake" );
assertTrue(Intake.isInitialized());
Group group = Intake.getGroup("LoginGroup");
assertNotNull(group);
1.3 +50 -42 jakarta-turbine-fulcrum/intake/src/test/org/apache/fulcrum/intake/IntakeServiceTest.java
Index: IntakeServiceTest.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/test/org/apache/fulcrum/intake/IntakeServiceTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IntakeServiceTest.java 12 Nov 2003 11:29:12 -0000 1.2
+++ IntakeServiceTest.java 15 Nov 2003 16:05:18 -0000 1.3
@@ -7,57 +7,65 @@
package org.apache.fulcrum.intake;
import java.io.File;
-import org.apache.avalon.framework.component.ComponentException;
import org.apache.fulcrum.intake.model.Group;
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.avalon.merlin.unit.AbstractMerlinTestCase;
+
/**
* @author Eric Pugh
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
-public class IntakeServiceTest extends BaseUnitTest {
- private IntakeService intakeService = null;
- /**
- * Defines the testcase name for JUnit.
- *
- * @param name the testcase's name.
- */
- public IntakeServiceTest(String name) {
- super(name);
- }
- public static void main(String[] args) {
- junit.textui.TestRunner.run(IntakeServiceTest.class);
- }
- protected void setUp() throws Exception{
- super.setUp();
- File appData = new File("target/appData.ser");
- if(appData.exists()){
- appData.delete();
+public class IntakeServiceTest extends AbstractMerlinTestCase
+{
+ private static final File BASEDIR = new File( System.getProperty( "basedir" ));
+
+ private IntakeService intakeService = null;
+
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public IntakeServiceTest(String name) {
+ super(name);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(IntakeServiceTest.class);
}
- try {
- intakeService = (IntakeService) this.lookup(IntakeService.ROLE);
- } catch (ComponentException e) {
- e.printStackTrace();
- fail(e.getMessage());
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ File appData = new File( BASEDIR, "target/appData.ser");
+ if(appData.exists()){
+ appData.delete();
+ }
+ try {
+ intakeService = (IntakeService) this.resolve( "intake" );
+ } catch (Throwable e) {
+ getLogger().error( "Setup failure.", e );
+ fail(e.getMessage());
+ }
}
- }
- public void testBasicConfigLoads() throws Exception {
- assertNotNull(intakeService);
- File file = new File("target/appData.ser");
- assertTrue(
- "Make sure serialized data file exists:" + file,
- file.exists());
- Group group = intakeService.getGroup("LoginGroup");
- assertNotNull(group);
- assertEquals("loginGroupKey", group.getGID());
- assertEquals("LoginGroup", group.getIntakeGroupName());
-
- Group group2 = intakeService.getGroup("AnotherGroup");
- assertNotNull(group2);
- assertEquals("anotherGroupKey", group2.getGID());
- assertEquals("AnotherGroup", group2.getIntakeGroupName());
- }
+ public void testBasicConfigLoads() throws Exception {
+ assertNotNull(intakeService);
+ File file = new File( BASEDIR, "target/appData.ser");
+ assertTrue(
+ "Make sure serialized data file exists:" + file,
+ file.exists());
+ Group group = intakeService.getGroup("LoginGroup");
+ assertNotNull(group);
+ assertEquals("loginGroupKey", group.getGID());
+ assertEquals("LoginGroup", group.getIntakeGroupName());
+
+ Group group2 = intakeService.getGroup("AnotherGroup");
+ assertNotNull(group2);
+ assertEquals("anotherGroupKey", group2.getGID());
+ assertEquals("AnotherGroup", group2.getIntakeGroupName());
+ getLogger().info( "OK" );
+ }
}
1.7 +6 -1 jakarta-turbine-fulcrum/intake/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/xdocs/changes.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- changes.xml 10 Nov 2003 04:26:00 -0000 1.6
+++ changes.xml 15 Nov 2003 16:05:18 -0000 1.7
@@ -7,7 +7,12 @@
</properties>
<body>
- <release version="Not applicable" date="">
+ <release version="1.0-alpha-2" date="">
+ <action dev="epugh" type="update">
+ Merlinized component
+ </action>
+ </release>
+ <release version="1.0-alpha-1" date="11-15-2003">
<action dev="epugh" type="remove">
Remove Intake Pull Tool. It should I think be part of Turbine as it is
very Turbine specific right now. I am trying to remove all Turbine requirements
1.3 +688 -692 jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
Index: IntakeServiceImpl.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IntakeServiceImpl.java 14 Oct 2003 09:03:28 -0000 1.2
+++ IntakeServiceImpl.java 15 Nov 2003 16:05:18 -0000 1.3
@@ -74,10 +74,9 @@
import java.util.Vector;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.component.Composable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -103,694 +102,691 @@
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
* @version $Id$
+ *
+ * @avalon.component name="intake"
+ * @avalon.service type="org.apache.fulcrum.intake.IntakeService"
*/
public class IntakeServiceImpl
- extends AbstractLogEnabled
- implements
- IntakeService,
- Configurable,
- Initializable,
- Component,
- Contextualizable,
- Composable {
- /** Map of groupNames -> appData elements */
- private Map groupNames;
-
- /** The cache of group names. */
- private Map groupNameMap;
-
- /** The cache of group keys. */
- private Map groupKeyMap;
-
- /** The cache of property getters. */
- private Map getterMap;
-
- /** The cache of property setters. */
- private Map setterMap;
-
- /** AppData -> keyed Pools Map */
- private Map keyedPools;
-
- /** Used for logging */
- private static Log log = LogFactory.getLog(IntakeServiceImpl.class);
-
- /** The Avalon Context */
- private Context context = null;
- /** The Avalon ComponentManager */
- private ComponentManager manager = null;
-
- 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";
-
- /**
- * Registers a given group name in the system
- *
- * @param groupName The name to register the group under
- * @param group The XML Group to register in
- * @param appData The app Data object where the group can be found
- * @param checkKey Whether to check if the key also exists.
- *
- * @return true if successful, false if not
- */
- private boolean registerGroup(
- String groupName,
- XmlGroup group,
- AppData appData,
- boolean checkKey) {
- if (groupNames.keySet().contains(groupName)) {
- // This name already exists.
- return false;
- }
-
- boolean keyExists = groupNameMap.keySet().contains(group.getKey());
-
- if (checkKey && keyExists) {
- // The key for this package is already registered for another group
- return false;
- }
-
- groupNames.put(groupName, appData);
-
- groupKeyMap.put(groupName, group.getKey());
-
- if (!keyExists) {
- // This key does not exist. Add it to the hash.
- groupNameMap.put(group.getKey(), groupName);
- }
-
- List classNames = group.getMapToObjects();
- for (Iterator iter2 = classNames.iterator(); iter2.hasNext();) {
- String className = (String) iter2.next();
- if (!getterMap.containsKey(className)) {
- getterMap.put(className, new HashMap());
- setterMap.put(className, new HashMap());
- }
- }
- return true;
- }
-
- /**
- * Tries to load a serialized Intake Group file. This
- * can reduce the startup time of Turbine.
- *
- * @param serialDataPath The path of the File to load.
- *
- * @return A map with appData objects loaded from the file
- * or null if the map could not be loaded.
- */
- private Map loadSerialized(String serialDataPath, long timeStamp) {
- log.debug(
- "Entered loadSerialized("
- + serialDataPath
- + ", "
- + timeStamp
- + ")");
-
- if (serialDataPath == null) {
- return null;
- }
-
- File serialDataFile = new File(serialDataPath);
-
- if (!serialDataFile.exists()) {
- log.info("No serialized file found, parsing XML");
- return null;
- }
-
- if (serialDataFile.lastModified() <= timeStamp) {
- log.info("serialized file too old, parsing XML");
- return null;
- }
-
- InputStream in = null;
- Map serialData = null;
-
- try {
- in = new FileInputStream(serialDataFile);
- ObjectInputStream p = new ObjectInputStream(in);
- Object o = p.readObject();
-
- if (o instanceof Map) {
- serialData = (Map) o;
- } else {
- // Maybe an old file from intake. Ignore it and try to delete
- log.info("serialized object is not an intake map, ignoring");
- in.close();
- in = null;
- serialDataFile.delete(); // Try to delete the file lying around
- }
- } catch (Exception e) {
- log.error("Serialized File could not be read.", e);
-
- // We got a corrupt file for some reason.
- // Null out serialData to be sure
- serialData = null;
- } finally {
- // Could be null if we opened a file, didn't find it to be a
- // Map object and then nuked it away.
- try {
- if (in != null) {
- in.close();
- }
- } catch (Exception e) {
- log.error("Exception while closing file", e);
- }
- }
-
- log.info("Loaded serialized map object, ignoring XML");
- return serialData;
- }
-
- /**
- * Writes a parsed XML map with all the appData groups into a
- * file. This will speed up loading time when you restart the
- * Intake Service because it will only unserialize this file instead
- * of reloading all of the XML files
- *
- * @param serialDataPath The path of the file to write to
- * @param appDataElements A Map containing all of the XML parsed appdata elements
- */
- private void saveSerialized(String serialDataPath, Map appDataElements) {
-
- log.debug(
- "Entered saveSerialized(" + serialDataPath + ", appDataElements)");
-
- if (serialDataPath == null) {
- return;
- }
-
- File serialData = new File(serialDataPath);
-
- try {
- serialData.createNewFile();
- serialData.delete();
- } catch (Exception e) {
- log.info(
- "Could not create serialized file "
- + serialDataPath
- + ", not serializing the XML data");
- return;
- }
-
- OutputStream out = null;
- InputStream in = null;
-
- try {
- // write the appData file out
- out = new FileOutputStream(serialDataPath);
- ObjectOutputStream pout = new ObjectOutputStream(out);
- pout.writeObject(appDataElements);
- pout.flush();
-
- // read the file back in. for some reason on OSX 10.1
- // this is necessary.
- in = new FileInputStream(serialDataPath);
- ObjectInputStream pin = new ObjectInputStream(in);
- Map dummy = (Map) pin.readObject();
-
- log.debug("Serializing successful");
- } catch (Exception e) {
- log.info(
- "Could not write serialized file to "
- + serialDataPath
- + ", not serializing the XML data");
- } finally {
- try {
- if (out != null) {
- out.close();
- }
- if (in != null) {
- in.close();
- }
- } catch (Exception e) {
- log.error("Exception while closing file", e);
- }
- }
- }
-
- /**
- * Gets an instance of a named group either from the pool
- * or by calling the Factory Service if the pool is empty.
- *
- * @param groupName the name of the group.
- * @return a Group instance.
- * @throws IntakeException if recycling fails.
- */
- public Group getGroup(String groupName) throws IntakeException {
- Group group = null;
-
- AppData appData = (AppData) groupNames.get(groupName);
-
- if (groupName == null) {
- throw new IntakeException("Intake IntakeServiceImpl.getGroup(groupName) is null");
- }
- if (appData == null) {
- throw new IntakeException(
- "Intake IntakeServiceImpl.getGroup(groupName): No XML definition for Group "
- + groupName
- + " found");
- }
- try {
- group =
- (Group)
- ((KeyedObjectPool) keyedPools.get(appData)).borrowObject(
- groupName);
- } catch (Exception e) {
- throw new IntakeException("Could not get group " + groupName, e);
- }
- return group;
- }
-
- /**
- * Puts a Group back to the pool.
- *
- * @param instance the object instance to recycle.
- *
- * @throws IntakeException The passed group name does not exist.
- */
- public void releaseGroup(Group instance) throws IntakeException {
- if (instance != null) {
- String groupName = instance.getIntakeGroupName();
- AppData appData = (AppData) groupNames.get(groupName);
-
- if (appData == null) {
- throw new IntakeException(
- "Intake IntakeServiceImpl.releaseGroup(groupName): "
- + "No XML definition for Group "
- + groupName
- + " found");
- }
-
- try {
- ((KeyedObjectPool) keyedPools.get(appData)).returnObject(
- groupName,
- instance);
- } catch (Exception e) {
- new IntakeException("Could not get group " + groupName, e);
- }
- }
- }
-
- /**
- * Gets the current size of the pool for a group.
- *
- * @param groupName the name of the group.
- *
- * @throws IntakeException The passed group name does not exist.
- */
- public int getSize(String groupName) throws IntakeException {
- AppData appData = (AppData) groupNames.get(groupName);
- if (appData == null) {
- throw new IntakeException(
- "Intake IntakeServiceImpl.Size(groupName): No XML definition for Group "
- + groupName
- + " found");
- }
-
- KeyedObjectPool kop = (KeyedObjectPool) keyedPools.get(groupName);
-
- return kop.getNumActive(groupName) + kop.getNumIdle(groupName);
- }
-
- /**
- * Names of all the defined groups.
- *
- * @return array of names.
- */
- public String[] getGroupNames() {
- return (String[]) groupNames.keySet().toArray(new String[0]);
- }
-
- /**
- * Gets the key (usually a short identifier) for a group.
- *
- * @param groupName the name of the group.
- * @return the the key.
- */
- public String getGroupKey(String groupName) {
- return (String) groupKeyMap.get(groupName);
- }
-
- /**
- * Gets the group name given its key.
- *
- * @param groupKey the key.
- * @return groupName the name of the group.
- */
- public String getGroupName(String groupKey) {
- return (String) groupNameMap.get(groupKey);
- }
-
- /**
- * Gets the Method that can be used to set a property.
- *
- * @param className the name of the object.
- * @param propName the name of the property.
- * @return the setter.
- * @throws ClassNotFoundException
- * @throws IntrospectionException
- */
- public Method getFieldSetter(String className, String propName)
- throws ClassNotFoundException, IntrospectionException {
- Map settersForClassName = (Map) setterMap.get(className);
-
- if (settersForClassName == null) {
- throw new IntrospectionException(
- "No setter Map for " + className + " available!");
- }
-
- Method setter = (Method) settersForClassName.get(propName);
-
- if (setter == null) {
- PropertyDescriptor pd =
- new PropertyDescriptor(propName, Class.forName(className));
- synchronized (setterMap) {
- setter = pd.getWriteMethod();
- settersForClassName.put(propName, setter);
- if (setter == null) {
- log.error(
- "Intake: setter for '"
- + propName
- + "' in class '"
- + className
- + "' could not be found.");
- }
- }
- // we have already completed the reflection on the getter, so
- // save it so we do not have to repeat
- synchronized (getterMap) {
- Map gettersForClassName = (Map) getterMap.get(className);
-
- if (gettersForClassName != null) {
- try {
- Method getter = pd.getReadMethod();
- if (getter != null) {
- gettersForClassName.put(propName, getter);
- }
- } catch (Exception e) {
- // Do nothing
- }
- }
- }
- }
- return setter;
- }
-
- /**
- * Gets the Method that can be used to get a property value.
- *
- * @param className the name of the object.
- * @param propName the name of the property.
- * @return the getter.
- * @throws ClassNotFoundException
- * @throws IntrospectionException
- */
- public Method getFieldGetter(String className, String propName)
- throws ClassNotFoundException, IntrospectionException {
- Map gettersForClassName = (Map) getterMap.get(className);
-
- if (gettersForClassName == null) {
- throw new IntrospectionException(
- "No getter Map for " + className + " available!");
- }
-
- Method getter = (Method) gettersForClassName.get(propName);
-
- if (getter == null) {
- PropertyDescriptor pd = null;
- synchronized (getterMap) {
- pd = new PropertyDescriptor(propName, Class.forName(className));
- getter = pd.getReadMethod();
- gettersForClassName.put(propName, getter);
- if (getter == null) {
- log.error(
- "Intake: getter for '"
- + propName
- + "' in class '"
- + className
- + "' could not be found.");
- }
- }
- // we have already completed the reflection on the setter, so
- // save it so we do not have to repeat
- synchronized (setterMap) {
- Map settersForClassName = (Map) getterMap.get(className);
-
- if (settersForClassName != null) {
- try {
- Method setter = pd.getWriteMethod();
- if (setter != null) {
- settersForClassName.put(propName, setter);
- }
- } catch (Exception e) {
- // Do nothing
- }
- }
- }
- }
- return getter;
- }
-
- // ---------------- Avalon Lifecycle Methods ---------------------
- /**
- * Avalon component lifecycle method
- */
- public void configure(Configuration conf) throws ConfigurationException {
-
- try {
- applicationRoot =
- (context == null)
- ? null
- : (String) context.get("componentAppRoot");
- } catch (ContextException ce) {
- getLogger().error("Could not load Application Root from Context");
- }
-
- Vector defaultXmlPathes = new Vector();
- defaultXmlPathes.add(XML_PATH_DEFAULT);
-
- final Configuration xmlPaths = conf.getChild(XML_PATHS, false);
- List xmlPathes = new ArrayList();
- if (xmlPaths == null) {
- xmlPathes.add(XML_PATH_DEFAULT);
- } else {
- Configuration[] nameVal = xmlPaths.getChildren();
- for (int i = 0; i < nameVal.length; i++) {
- String key = nameVal[i].getName();
- String val = nameVal[i].getValue();
- // getLogger.debug("Registered " + val
- // + " for Crypto Algorithm " + key);
- xmlPathes.add(val);
- }
- }
-
- Map appDataElements = null;
-
- String serialDataPath =
- conf.getChild(SERIAL_XML, false).getValue(SERIAL_XML_DEFAULT);
-
- if (!serialDataPath.equalsIgnoreCase("none")) {
- serialDataPath =
- new File(applicationRoot, serialDataPath).getAbsolutePath();
- } else {
- serialDataPath = null;
- }
-
- log.debug("Path for serializing: " + serialDataPath);
-
- groupNames = new HashMap();
- groupKeyMap = new HashMap();
- groupNameMap = new HashMap();
- getterMap = new HashMap();
- setterMap = new HashMap();
- keyedPools = new HashMap();
-
- if (xmlPathes == null) {
- String LOAD_ERROR =
- "No pathes for XML files were specified. "
- + "Check that the property exists in "
- + "TurbineResources.props and were loaded.";
-
- log.error(LOAD_ERROR);
- throw new ConfigurationException(LOAD_ERROR);
- }
-
- Set xmlFiles = new HashSet();
-
- long timeStamp = 0;
-
- for (Iterator it = xmlPathes.iterator(); it.hasNext();) {
- // Files are webapp.root relative
- String xmlPath = (String) it.next();
- File xmlFile = new File(applicationRoot, xmlPath);
-
- log.debug("Path for XML File: " + xmlFile);
-
- if (!xmlFile.canRead()) {
- String READ_ERR = "Could not read input file " + xmlPath;
-
- log.error(READ_ERR);
- throw new ConfigurationException(READ_ERR);
- }
-
- xmlFiles.add(xmlPath);
-
- log.debug("Added " + xmlPath + " as File to parse");
-
- // Get the timestamp of the youngest file to be compared with
- // a serialized file. If it is younger than the serialized file,
- // then we have to parse the XML anyway.
- timeStamp =
- (xmlFile.lastModified() > timeStamp)
- ? xmlFile.lastModified()
- : timeStamp;
- }
-
- Map serializedMap = loadSerialized(serialDataPath, timeStamp);
-
- if (serializedMap != null) {
- // Use the serialized data as XML groups. Don't parse.
- appDataElements = serializedMap;
- log.debug("Using the serialized map");
- } else {
- // Parse all the given XML files
- appDataElements = new HashMap();
-
- for (Iterator it = xmlFiles.iterator(); it.hasNext();) {
- String xmlPath = (String) it.next();
- AppData appData = null;
-
- log.debug("Now parsing: " + xmlPath);
- try {
- XmlToAppData xmlApp = new XmlToAppData();
- appData = xmlApp.parseFile(xmlPath);
- } catch (Exception e) {
- log.error("Could not parse XML file " + xmlPath, e);
-
- throw new ConfigurationException(
- "Could not parse XML file " + xmlPath,
- e);
- }
-
- appDataElements.put(appData, xmlPath);
- log.debug("Saving appData for " + xmlPath);
- }
-
- saveSerialized(serialDataPath, appDataElements);
- }
-
- try {
- for (Iterator it = appDataElements.keySet().iterator();
- it.hasNext();
- ) {
- AppData appData = (AppData) it.next();
-
- int maxPooledGroups = 0;
- List glist = appData.getGroups();
-
- String groupPrefix = appData.getGroupPrefix();
-
- 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);
-
- if (!registerUnqualified) {
- log.info(
- "Ignored redefinition of Group "
- + groupName
- + " or Key "
- + g.getKey()
- + " from "
- + appDataElements.get(appData));
- }
-
- 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)) {
- log.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));
- }
-
- } 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 InitializationException if initialization fails.
- */
- public void initialize() throws Exception {
- Intake.setIntakeService(this);
- if (log.isInfoEnabled())
- {
- log.info("Intake Service is Initialized now..");
- }
- }
-
- public void contextualize(Context context) throws ContextException {
- this.context = context;
- }
-
- /**
- * Avalon component lifecycle method
- */
- public void compose(ComponentManager manager) throws ComponentException {
- this.manager = manager;
-
- IntakeServiceFacade.setIntakeService(this);
- LocalizationService localizationService = (LocalizationService)manager.lookup(LocalizationService.ROLE);
- IntakeServiceFacade.setLocalizationService(localizationService);
- }
-
- /**
- * Avalon component lifecycle method
- */
- public void dispose() {
+ extends AbstractLogEnabled
+ implements
+ IntakeService,
+ Configurable,
+ Initializable,
+ Contextualizable,
+ Serviceable {
+ /** Map of groupNames -> appData elements */
+ private Map groupNames;
+
+ /** The cache of group names. */
+ private Map groupNameMap;
+
+ /** The cache of group keys. */
+ private Map groupKeyMap;
+
+ /** The cache of property getters. */
+ private Map getterMap;
+
+ /** The cache of property setters. */
+ private Map setterMap;
+
+ /** AppData -> keyed Pools Map */
+ private Map keyedPools;
+
+ /** Used for logging */
+ private static Log log = LogFactory.getLog(IntakeServiceImpl.class);
+
+ /** The Avalon Context */
+ private Context context = null;
+
+ /** The Avalon ComponentManager */
+ private ServiceManager manager = null;
+
+ 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";
+
+ /**
+ * Registers a given group name in the system
+ *
+ * @param groupName The name to register the group under
+ * @param group The XML Group to register in
+ * @param appData The app Data object where the group can be found
+ * @param checkKey Whether to check if the key also exists.
+ *
+ * @return true if successful, false if not
+ */
+ private boolean registerGroup(
+ String groupName,
+ XmlGroup group,
+ AppData appData,
+ boolean checkKey) {
+ if (groupNames.keySet().contains(groupName)) {
+ // This name already exists.
+ return false;
+ }
+
+ boolean keyExists = groupNameMap.keySet().contains(group.getKey());
+
+ if (checkKey && keyExists) {
+ // The key for this package is already registered for another group
+ return false;
+ }
+
+ groupNames.put(groupName, appData);
+
+ groupKeyMap.put(groupName, group.getKey());
+
+ if (!keyExists) {
+ // This key does not exist. Add it to the hash.
+ groupNameMap.put(group.getKey(), groupName);
+ }
+
+ List classNames = group.getMapToObjects();
+ for (Iterator iter2 = classNames.iterator(); iter2.hasNext();) {
+ String className = (String) iter2.next();
+ if (!getterMap.containsKey(className)) {
+ getterMap.put(className, new HashMap());
+ setterMap.put(className, new HashMap());
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Tries to load a serialized Intake Group file. This
+ * can reduce the startup time of Turbine.
+ *
+ * @param serialDataPath The path of the File to load.
+ *
+ * @return A map with appData objects loaded from the file
+ * or null if the map could not be loaded.
+ */
+ private Map loadSerialized(String serialDataPath, long timeStamp) {
+ log.debug(
+ "Entered loadSerialized("
+ + serialDataPath
+ + ", "
+ + timeStamp
+ + ")");
+
+ if (serialDataPath == null) {
+ return null;
+ }
+
+ File serialDataFile = new File(serialDataPath);
+
+ if (!serialDataFile.exists()) {
+ log.info("No serialized file found, parsing XML");
+ return null;
+ }
+
+ if (serialDataFile.lastModified() <= timeStamp) {
+ log.info("serialized file too old, parsing XML");
+ return null;
+ }
+
+ InputStream in = null;
+ Map serialData = null;
+
+ try {
+ in = new FileInputStream(serialDataFile);
+ ObjectInputStream p = new ObjectInputStream(in);
+ Object o = p.readObject();
+
+ if (o instanceof Map) {
+ serialData = (Map) o;
+ } else {
+ // Maybe an old file from intake. Ignore it and try to delete
+ log.info("serialized object is not an intake map, ignoring");
+ in.close();
+ in = null;
+ serialDataFile.delete(); // Try to delete the file lying around
+ }
+ } catch (Exception e) {
+ log.error("Serialized File could not be read.", e);
+
+ // We got a corrupt file for some reason.
+ // Null out serialData to be sure
+ serialData = null;
+ } finally {
+ // Could be null if we opened a file, didn't find it to be a
+ // Map object and then nuked it away.
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (Exception e) {
+ log.error("Exception while closing file", e);
+ }
+ }
+
+ log.info("Loaded serialized map object, ignoring XML");
+ return serialData;
+ }
+
+ /**
+ * Writes a parsed XML map with all the appData groups into a
+ * file. This will speed up loading time when you restart the
+ * Intake Service because it will only unserialize this file instead
+ * of reloading all of the XML files
+ *
+ * @param serialDataPath The path of the file to write to
+ * @param appDataElements A Map containing all of the XML parsed appdata elements
+ */
+ private void saveSerialized(String serialDataPath, Map appDataElements) {
+
+ log.debug(
+ "Entered saveSerialized(" + serialDataPath + ", appDataElements)");
+
+ if (serialDataPath == null) {
+ return;
+ }
+
+ File serialData = new File(serialDataPath);
+
+ try {
+ serialData.createNewFile();
+ serialData.delete();
+ } catch (Exception e) {
+ log.info(
+ "Could not create serialized file "
+ + serialDataPath
+ + ", not serializing the XML data");
+ return;
+ }
+
+ OutputStream out = null;
+ InputStream in = null;
+
+ try {
+ // write the appData file out
+ out = new FileOutputStream(serialDataPath);
+ ObjectOutputStream pout = new ObjectOutputStream(out);
+ pout.writeObject(appDataElements);
+ pout.flush();
+
+ // read the file back in. for some reason on OSX 10.1
+ // this is necessary.
+ in = new FileInputStream(serialDataPath);
+ ObjectInputStream pin = new ObjectInputStream(in);
+ Map dummy = (Map) pin.readObject();
+
+ log.debug("Serializing successful");
+ } catch (Exception e) {
+ log.info(
+ "Could not write serialized file to "
+ + serialDataPath
+ + ", not serializing the XML data");
+ } finally {
+ try {
+ if (out != null) {
+ out.close();
+ }
+ if (in != null) {
+ in.close();
+ }
+ } catch (Exception e) {
+ log.error("Exception while closing file", e);
+ }
+ }
+ }
+
+ /**
+ * Gets an instance of a named group either from the pool
+ * or by calling the Factory Service if the pool is empty.
+ *
+ * @param groupName the name of the group.
+ * @return a Group instance.
+ * @throws IntakeException if recycling fails.
+ */
+ public Group getGroup(String groupName) throws IntakeException {
+ Group group = null;
+
+ AppData appData = (AppData) groupNames.get(groupName);
+
+ if (groupName == null) {
+ throw new IntakeException("Intake IntakeServiceImpl.getGroup(groupName) is null");
+ }
+ if (appData == null) {
+ throw new IntakeException(
+ "Intake IntakeServiceImpl.getGroup(groupName): No XML definition for Group "
+ + groupName
+ + " found");
+ }
+ try {
+ group =
+ (Group)
+ ((KeyedObjectPool) keyedPools.get(appData)).borrowObject(
+ groupName);
+ } catch (Exception e) {
+ throw new IntakeException("Could not get group " + groupName, e);
+ }
+ return group;
+ }
+
+ /**
+ * Puts a Group back to the pool.
+ *
+ * @param instance the object instance to recycle.
+ *
+ * @throws IntakeException The passed group name does not exist.
+ */
+ public void releaseGroup(Group instance) throws IntakeException {
+ if (instance != null) {
+ String groupName = instance.getIntakeGroupName();
+ AppData appData = (AppData) groupNames.get(groupName);
+
+ if (appData == null) {
+ throw new IntakeException(
+ "Intake IntakeServiceImpl.releaseGroup(groupName): "
+ + "No XML definition for Group "
+ + groupName
+ + " found");
+ }
+
+ try {
+ ((KeyedObjectPool) keyedPools.get(appData)).returnObject(
+ groupName,
+ instance);
+ } catch (Exception e) {
+ new IntakeException("Could not get group " + groupName, e);
+ }
+ }
+ }
+
+ /**
+ * Gets the current size of the pool for a group.
+ *
+ * @param groupName the name of the group.
+ *
+ * @throws IntakeException The passed group name does not exist.
+ */
+ public int getSize(String groupName) throws IntakeException {
+ AppData appData = (AppData) groupNames.get(groupName);
+ if (appData == null) {
+ throw new IntakeException(
+ "Intake IntakeServiceImpl.Size(groupName): No XML definition for Group "
+ + groupName
+ + " found");
+ }
+
+ KeyedObjectPool kop = (KeyedObjectPool) keyedPools.get(groupName);
+
+ return kop.getNumActive(groupName) + kop.getNumIdle(groupName);
+ }
+
+ /**
+ * Names of all the defined groups.
+ *
+ * @return array of names.
+ */
+ public String[] getGroupNames() {
+ return (String[]) groupNames.keySet().toArray(new String[0]);
+ }
+
+ /**
+ * Gets the key (usually a short identifier) for a group.
+ *
+ * @param groupName the name of the group.
+ * @return the the key.
+ */
+ public String getGroupKey(String groupName) {
+ return (String) groupKeyMap.get(groupName);
+ }
+
+ /**
+ * Gets the group name given its key.
+ *
+ * @param groupKey the key.
+ * @return groupName the name of the group.
+ */
+ public String getGroupName(String groupKey) {
+ return (String) groupNameMap.get(groupKey);
+ }
+
+ /**
+ * Gets the Method that can be used to set a property.
+ *
+ * @param className the name of the object.
+ * @param propName the name of the property.
+ * @return the setter.
+ * @throws ClassNotFoundException
+ * @throws IntrospectionException
+ */
+ public Method getFieldSetter(String className, String propName)
+ throws ClassNotFoundException, IntrospectionException {
+ Map settersForClassName = (Map) setterMap.get(className);
+
+ if (settersForClassName == null) {
+ throw new IntrospectionException(
+ "No setter Map for " + className + " available!");
+ }
+
+ Method setter = (Method) settersForClassName.get(propName);
+
+ if (setter == null) {
+ PropertyDescriptor pd =
+ new PropertyDescriptor(propName, Class.forName(className));
+ synchronized (setterMap) {
+ setter = pd.getWriteMethod();
+ settersForClassName.put(propName, setter);
+ if (setter == null) {
+ log.error(
+ "Intake: setter for '"
+ + propName
+ + "' in class '"
+ + className
+ + "' could not be found.");
+ }
+ }
+ // we have already completed the reflection on the getter, so
+ // save it so we do not have to repeat
+ synchronized (getterMap) {
+ Map gettersForClassName = (Map) getterMap.get(className);
+
+ if (gettersForClassName != null) {
+ try {
+ Method getter = pd.getReadMethod();
+ if (getter != null) {
+ gettersForClassName.put(propName, getter);
+ }
+ } catch (Exception e) {
+ // Do nothing
+ }
+ }
+ }
+ }
+ return setter;
+ }
+
+ /**
+ * Gets the Method that can be used to get a property value.
+ *
+ * @param className the name of the object.
+ * @param propName the name of the property.
+ * @return the getter.
+ * @throws ClassNotFoundException
+ * @throws IntrospectionException
+ */
+ public Method getFieldGetter(String className, String propName)
+ throws ClassNotFoundException, IntrospectionException {
+ Map gettersForClassName = (Map) getterMap.get(className);
+
+ if (gettersForClassName == null) {
+ throw new IntrospectionException(
+ "No getter Map for " + className + " available!");
+ }
+
+ Method getter = (Method) gettersForClassName.get(propName);
+
+ if (getter == null) {
+ PropertyDescriptor pd = null;
+ synchronized (getterMap) {
+ pd = new PropertyDescriptor(propName, Class.forName(className));
+ getter = pd.getReadMethod();
+ gettersForClassName.put(propName, getter);
+ if (getter == null) {
+ log.error(
+ "Intake: getter for '"
+ + propName
+ + "' in class '"
+ + className
+ + "' could not be found.");
+ }
+ }
+ // we have already completed the reflection on the setter, so
+ // save it so we do not have to repeat
+ synchronized (setterMap) {
+ Map settersForClassName = (Map) getterMap.get(className);
+
+ if (settersForClassName != null) {
+ try {
+ Method setter = pd.getWriteMethod();
+ if (setter != null) {
+ settersForClassName.put(propName, setter);
+ }
+ } catch (Exception e) {
+ // Do nothing
+ }
+ }
+ }
+ }
+ return getter;
+ }
+
+ // ---------------- Avalon Lifecycle Methods ---------------------
+ /**
+ * Avalon component lifecycle method
+ */
+ public void configure(Configuration conf) throws ConfigurationException {
+
+ Vector defaultXmlPathes = new Vector();
+ defaultXmlPathes.add(XML_PATH_DEFAULT);
+
+ final Configuration xmlPaths = conf.getChild(XML_PATHS, false);
+ List xmlPathes = new ArrayList();
+ if (xmlPaths == null) {
+ xmlPathes.add(XML_PATH_DEFAULT);
+ } else {
+ Configuration[] nameVal = xmlPaths.getChildren();
+ for (int i = 0; i < nameVal.length; i++) {
+ String key = nameVal[i].getName();
+ String val = nameVal[i].getValue();
+ // getLogger.debug("Registered " + val
+ // + " for Crypto Algorithm " + key);
+ xmlPathes.add(val);
+ }
+ }
+
+ Map appDataElements = null;
+
+ String serialDataPath =
+ conf.getChild(SERIAL_XML, false).getValue(SERIAL_XML_DEFAULT);
+
+ if (!serialDataPath.equalsIgnoreCase("none")) {
+ serialDataPath =
+ new File(applicationRoot, serialDataPath).getAbsolutePath();
+ } else {
+ serialDataPath = null;
+ }
+
+ log.debug("Path for serializing: " + serialDataPath);
+
+ groupNames = new HashMap();
+ groupKeyMap = new HashMap();
+ groupNameMap = new HashMap();
+ getterMap = new HashMap();
+ setterMap = new HashMap();
+ keyedPools = new HashMap();
+
+ if (xmlPathes == null) {
+ String LOAD_ERROR =
+ "No pathes for XML files were specified. "
+ + "Check that the property exists in "
+ + "TurbineResources.props and were loaded.";
+
+ log.error(LOAD_ERROR);
+ throw new ConfigurationException(LOAD_ERROR);
+ }
+
+ Set xmlFiles = new HashSet();
+
+ long timeStamp = 0;
+
+ for (Iterator it = xmlPathes.iterator(); it.hasNext();) {
+ // Files are webapp.root relative
+ String xmlPath = (String) it.next();
+ File xmlFile = new File( applicationRoot, xmlPath);
+
+ log.debug("Path for XML File: " + xmlFile);
+
+ if (!xmlFile.canRead()) {
+ String READ_ERR = "Could not read input file " + xmlPath;
+
+ log.error(READ_ERR);
+ throw new ConfigurationException(READ_ERR);
+ }
+
+ xmlFiles.add(xmlFile.toString());
+
+ log.debug("Added " + xmlPath + " as File to parse");
+
+ // Get the timestamp of the youngest file to be compared with
+ // a serialized file. If it is younger than the serialized file,
+ // then we have to parse the XML anyway.
+ timeStamp =
+ (xmlFile.lastModified() > timeStamp)
+ ? xmlFile.lastModified()
+ : timeStamp;
+ }
+
+ Map serializedMap = loadSerialized(serialDataPath, timeStamp);
+
+ if (serializedMap != null) {
+ // Use the serialized data as XML groups. Don't parse.
+ appDataElements = serializedMap;
+ log.debug("Using the serialized map");
+ } else {
+ // Parse all the given XML files
+ appDataElements = new HashMap();
+
+ for (Iterator it = xmlFiles.iterator(); it.hasNext();) {
+ String xmlPath = (String) it.next();
+ AppData appData = null;
+
+ log.debug("Now parsing: " + xmlPath);
+ try {
+ XmlToAppData xmlApp = new XmlToAppData();
+ appData = xmlApp.parseFile(xmlPath);
+ } catch (Exception e) {
+ log.error("Could not parse XML file " + xmlPath, e);
+
+ throw new ConfigurationException(
+ "Could not parse XML file " + xmlPath,
+ e);
+ }
+
+ appDataElements.put(appData, xmlPath);
+ log.debug("Saving appData for " + xmlPath);
+ }
+
+ saveSerialized(serialDataPath, appDataElements);
+ }
+
+ try {
+ for (Iterator it = appDataElements.keySet().iterator();
+ it.hasNext();
+ ) {
+ AppData appData = (AppData) it.next();
+
+ int maxPooledGroups = 0;
+ List glist = appData.getGroups();
+
+ String groupPrefix = appData.getGroupPrefix();
+
+ 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);
+
+ if (!registerUnqualified) {
+ log.info(
+ "Ignored redefinition of Group "
+ + groupName
+ + " or Key "
+ + g.getKey()
+ + " from "
+ + appDataElements.get(appData));
+ }
+
+ 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)) {
+ log.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));
+ }
+
+ } 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 InitializationException if initialization fails.
+ */
+ public void initialize() throws Exception {
+ Intake.setIntakeService(this);
+ if (log.isInfoEnabled())
+ {
+ log.info("Intake Service is Initialized now..");
+ }
+ }
+
+ public void contextualize(Context context) throws ContextException {
+ this.context = context;
+ this.applicationRoot = context.get( "urn:avalon:home" ).toString();
+ }
+
+ /**
+ * Avalon component lifecycle method
+ * @avalon.dependency type="org.apache.fulcrum.localization.LocalizationService"
+ */
+ public void service( ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+
+ IntakeServiceFacade.setIntakeService(this);
+ LocalizationService localizationService =
+ (LocalizationService)manager.lookup(LocalizationService.ROLE);
+ IntakeServiceFacade.setLocalizationService(localizationService);
+ }
+
+ /**
+ * Avalon component lifecycle method
+ */
+ public void dispose() {
- manager = null;
- }
+ manager = null;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org