You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by aj...@apache.org on 2004/07/20 20:59:39 UTC
svn commit: rev 23096 - in incubator/depot/trunk/update/src/java/org/apache/depot/update: config impl sample util/xml
Author: ajack
Date: Tue Jul 20 13:59:39 2004
New Revision: 23096
Removed:
incubator/depot/trunk/update/src/java/org/apache/depot/update/sample/
Modified:
incubator/depot/trunk/update/src/java/org/apache/depot/update/config/UpdaterConfig.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ReferenceManager.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/util/xml/XMLHandler.java
Log:
Whittle
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/config/UpdaterConfig.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/config/UpdaterConfig.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/config/UpdaterConfig.java Tue Jul 20 13:59:39 2004
@@ -31,9 +31,7 @@
/**
* Provides the configuration of the depot-updater application. Basically reads the configuration
- * xml-file.
- *
- * :TODO: Right now this class is pretty useless, is it?????????
+ * xml-file and populates the ReferenceManager's tables w/ configured objects.
*
* @author <a href="http://incubator.apache.org/depot">The Apache Incubator Depot Project</a>
*/
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ReferenceManager.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ReferenceManager.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/impl/ReferenceManager.java Tue Jul 20 13:59:39 2004
@@ -22,6 +22,7 @@
import org.apache.depot.common.log.Logger;
import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.update.config.UpdaterConfig;
import org.apache.depot.update.util.identity.GenericIdentifier;
import org.apache.depot.update.util.identity.GenericNamespace;
import org.apache.depot.update.util.reference.IReferenceable;
@@ -33,33 +34,34 @@
/**
* @author arb_jack
*/
-public final class ReferenceManager
-{
+public final class ReferenceManager {
+
private static Map l_tables = new HashMap();
//:TODO: Make chainable to support scoping?
- //:TODO: If so, add one to ResourceUpdaterContext & keep a global
+ //:TODO: If so, add one to ResourceUpdaterContext & keep a global
- private ReferenceManager()
- {
+ private ReferenceManager() {
+ UpdaterConfig.configure();
}
- public static boolean hasReference(GenericIdentifier identifier)
- {
+ /**
+ * Does this ReferenceManager have an entry for this identifier?
+ *
+ * @param identifier
+ * @return true = yes
+ */
+ public static boolean hasReference(GenericIdentifier identifier) {
boolean hasReference = false;
GenericNamespace ns = identifier.getNamespace();
- synchronized (l_tables)
- {
+ synchronized (l_tables) {
ReferenceTable table = (ReferenceTable) l_tables.get(ns);
- if (null == table)
- {
+ if (null == table) {
hasReference = false;
- }
- else
- {
+ } else {
hasReference = table.hasReference(identifier);
}
}
@@ -67,15 +69,20 @@
return hasReference;
}
+ /**
+ * Get the referenced object.
+ *
+ * @param identifier
+ * @return
+ * @throws NoSuchReferenceException
+ */
public static Object getReference(GenericIdentifier identifier)
- throws NoSuchReferenceException
- {
+ throws NoSuchReferenceException {
Object reference = null;
GenericNamespace ns = identifier.getNamespace();
- synchronized (l_tables)
- {
+ synchronized (l_tables) {
ReferenceTable table = (ReferenceTable) l_tables.get(ns);
if (null == table)
throw new NoSuchReferenceException(identifier);
@@ -89,16 +96,13 @@
return reference;
}
- public static void createReference(IReferenceable referenceable)
- {
+ public static void createReference(IReferenceable referenceable) {
GenericIdentifier identifier = referenceable.getIdentifier();
GenericNamespace ns = identifier.getNamespace();
- synchronized (l_tables)
- {
+ synchronized (l_tables) {
ReferenceTable table = (ReferenceTable) l_tables.get(ns);
- if (null == table)
- {
+ if (null == table) {
table = new ReferenceTable(ns);
l_tables.put(ns, table);
@@ -109,48 +113,35 @@
}
- public static Object createObject(
- Class clazz,
- String tagId,
- String refId)
- {
+ public static Object createObject(Class clazz, String tagId, String refId) {
Object reference = null;
- try
- {
- if(refId == null)
- {
- Class[] argumentTypes = { java.lang.String.class };
+ try {
+ if (refId == null) {
+ Class[] argumentTypes = {java.lang.String.class};
Constructor idArgumentConstructor = clazz.getDeclaredConstructor(argumentTypes);
idArgumentConstructor.setAccessible(true);
- reference = idArgumentConstructor.newInstance(new Object[] { tagId });
- }
- else
- {
+ reference = idArgumentConstructor.newInstance(new Object[]{tagId});
+ } else {
//TODO clone the object
}
- }
- catch (Exception exp)
- {
+ } catch (Exception exp) {
Logger.getLogger().error(
- Messages.getString(MessageConstants.CREATE_OBJECT_ERROR),
- exp);
+ Messages.getString(MessageConstants.CREATE_OBJECT_ERROR),
+ exp);
}
return reference;
}
- public static Object createReferenceObject(
- Class clazz,
- String tagId,
- String refId)
- {
+ public static Object createReferenceObject(Class clazz, String tagId,
+ String refId) {
Object reference = createObject(clazz, tagId, refId);
//add the object to the reference table
- createReference((IReferenceable)reference);
+ createReference((IReferenceable) reference);
return reference;
}
public static void dump() {
DebugUtils.dump("References...", l_tables);
}
-}
+}
\ No newline at end of file
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/util/xml/XMLHandler.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/util/xml/XMLHandler.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/util/xml/XMLHandler.java Tue Jul 20 13:59:39 2004
@@ -167,6 +167,7 @@
}
catch (Exception exception) {
Logger.getLogger().error("XML_BEAN_ERROR", exception);
+
throw new SAXParseException(
exception.getLocalizedMessage(),
m_context.getLocator(),