[jboss-cvs] JBossAS SVN: r89006 - branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 18 08:16:06 EDT 2009
Author: emuckenhuber
Date: 2009-05-18 08:16:06 -0400 (Mon, 18 May 2009)
New Revision: 89006
Modified:
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java
Log:
extract the component mapper information from the persisted information.
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java 2009-05-18 12:07:17 UTC (rev 89005)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java 2009-05-18 12:16:06 UTC (rev 89006)
@@ -94,7 +94,7 @@
try
{
// Restore the components
- ComponentMapper mapper = getComponentMapper(parentAttachment.getClass().getName());
+ ComponentMapper mapper = getComponentMapper(root);
for(PersistedComponent component : root.getComponents())
{
mapper.restoreComponent(parentAttachment, component);
@@ -235,34 +235,55 @@
*/
protected ComponentMapper getComponentMapper(ManagedObject parent)
{
- String type = parent.getAttachmentName();
- if(type == null && parent.getAttachment() != null)
- type = parent.getAttachment().getClass().getName();
+ ComponentMapper mapper = null;
+ if(parent.getAttachmentName() != null)
+ mapper = getComponentMapper(parent.getAttachmentName());
+ if(mapper == null && parent.getAttachment() != null)
+ mapper = getComponentMapper(parent.getAttachment().getClass().getName());
+
+ if(mapper == null)
+ throw new IllegalStateException("no mapper registered for type: " + parent.getAttachmentName());
- return getComponentMapper(type);
+ return mapper;
}
/**
- * Get the component mapper for a given type.
+ * Get the component mapper for a persistence root.
*
- * @param type the type
+ * @param root the persistence root
* @return the component mapper
- * @throw IllegalArgumentException for a null type
* @throws IllegalStateException if no mapper is registered for this type
*/
- protected ComponentMapper getComponentMapper(String type)
+ protected ComponentMapper getComponentMapper(PersistenceRoot root)
{
- if(type == null)
- throw new IllegalArgumentException("null type");
+ ComponentMapper mapper = null;
+ if(root.getName() != null)
+ mapper = getComponentMapper(root.getName());
+ if(root.getClassName() != null)
+ mapper = getComponentMapper(root.getClassName());
- ComponentMapper mapper = componentMapper.getMapper(type);
if(mapper == null)
- throw new IllegalStateException("no mapper registered for type: " + type);
+ throw new IllegalStateException("no mapper registered for type: " + root);
return mapper;
}
/**
+ * Get the component mapper for a given type.
+ *
+ * @param type the type
+ * @return the component mapper, null if not registered
+ * @throw IllegalArgumentException for a null type
+ */
+ protected ComponentMapper getComponentMapper(String type)
+ {
+ if(type == null)
+ throw new IllegalArgumentException("null type");
+
+ return componentMapper.getMapper(type);
+ }
+
+ /**
* Map the components based on their names.
*
* @param root the persistence root
More information about the jboss-cvs-commits
mailing list