Right, such algorithm may work only for predefined node types and custom
node types. And only if there is such node type to POJO mapping only
once (in mapping xml).
What about special property - JCR spec uses special properties for many
occasions (jcr:primaryType, jcr: mixinTypes, ...). We can use property
named e.g. 'jcrMapping:pojoClassName' and store there name of POJO class.
Christophe Lombart wrote:
If you have only the path, you can have some issues with nodes based
on nt:unstructured.
If I understand your algorithm is :
* Get the JCR node object matching to the path
* Get the NodeTypeDefintion for this JCR node
* Found the ClassDescriptor
What happens if the node type is nt:unstructured ? If we found a
solution we can review the getObject method like this :
PersistenceManager#getObject(String path)
Christophe
2005/9/7, Martin Koci <[EMAIL PROTECTED]>:
org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObject(Class
pojoClass, String path) requires knowledge of persistent class but in
some cases I know only path in repository.
Christophe Lombart wrote:
ok but in which context this method can be usefull ?
2005/9/7, Martin Koci <[EMAIL PROTECTED]>:
When I know path and therefore a JCR node and its note type I want to
know class mapped to note type. MappingDescriptor should have new method
'getClassNameForNodeType':
public class MappingDescriptor {
private HashMap classDescriptors = new HashMap();
private Map nodeTypeToClassMap = new HashMap();
public void addClassDescriptor(ClassDescriptor classDescriptor)
{
classDescriptors.put(classDescriptor.getClassName(), classDescriptor);
nodeTypeToClassMap.put(classDescriptor.getJcrNodeType(),
classDescriptor.getClassName());
}
public ClassDescriptor getClassDescriptor(String className)
{
return (ClassDescriptor) classDescriptors.get(className);
}
public String getClassNameForNodeType(String nodeType) {
return (String) nodeTypeToClassMap.get(nodeType);
}
}
and DigesterMapperImpl new method:
public Class getClassForNodeType(String nodeType) throws
JcrMappingException {
String classNameForNodeType = null;
try {
classNameForNodeType = mappingDescriptor.getClassNameForNodeType(nodeType);
return Class.forName(classNameForNodeType);
} catch (ClassNotFoundException e) {
throw new JcrMappingException("Class of name: " + classNameForNodeType +
" is not found" );
}
}
Christophe Lombart wrote:
Hi all,
I just commited some code refactoring.
Can you vote for the PersistenceManager API & the Mapper API ?
We can expect to see some modification on thoses components when we
will add new features.
See on :
* org.apache.portals.graffito.jcr.persistence.PersistenceManager
* org.apache.portals.graffito.jcr.mapper.Mapper.
You can also check the current impletation. Let me know what you want to do.
I'm currently reviewing (for the secon time :-) the collection management.
Christophe
--
Mgr. Martin Kočí
---------------------------------
AURA, s.r.o.
Úvoz 499/56; 602 00 Brno
ISO 9001 certifikovaná společnost
tel./fax: +420 5 43 24 51 11
e-mail: [EMAIL PROTECTED]
internet: http://www.aura.cz
http://www.j2ee.cz
---------------------------------
--
Mgr. Martin Kočí
---------------------------------
AURA, s.r.o.
Úvoz 499/56; 602 00 Brno
ISO 9001 certifikovaná společnost
tel./fax: +420 5 43 24 51 11
e-mail: [EMAIL PROTECTED]
internet: http://www.aura.cz
http://www.j2ee.cz
---------------------------------