ruper2/src/java/core/org/krysalis/ruper/impl ReferenceManager.java,1.4,1.5

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/impl
In directory sc8-pr-cvs1:/tmp/cvs-serv30114/src/java/core/org/krysalis/ruper/impl

Modified Files:
	ReferenceManager.java 
Log Message:
simple ruper.xml working

Index: ReferenceManager.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/impl/ReferenceManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ReferenceManager.java	9 Sep 2003 21:49:06 -0000	1.4
--- ReferenceManager.java	10 Sep 2003 16:09:39 -0000	1.5
***************
*** 4,10 ****
--- 4,12 ----
  package org.krysalis.ruper.impl;
  
+ import java.lang.reflect.Constructor;
  import java.util.HashMap;
  import java.util.Map;
  
+ import org.krysalis.ruper.log.Logger;
  import org.krysalis.ruper.util.identity.GenericIdentifier;
  import org.krysalis.ruper.util.identity.GenericNamespace;
***************
*** 12,15 ****
--- 14,18 ----
  import org.krysalis.ruper.util.reference.ReferenceTable;
  import org.krysalis.ruper.util.reference.Referenceable;
+ import org.krysalis.ruper.util.text.Messages;
  import org.krysalis.version.util.debug.DebugUtils;
  
***************
*** 17,21 ****
   * @author ajack
   */
! public final class ReferenceManager {
  
  	private static Map l_tables = new HashMap();
--- 20,25 ----
   * @author ajack
   */
! public final class ReferenceManager
! {
  
  	private static Map l_tables = new HashMap();
***************
*** 24,42 ****
  	//:TODO: If so, add one to ResourceUpdaterContext & keep a global 
  
! 	private ReferenceManager() {
  	}
  
! 	public static boolean hasReference(GenericIdentifier identifier) {
  		boolean hasReference = false;
  
  		GenericNamespace ns = identifier.getNamespace();
  
! 		synchronized (l_tables) {
  			ReferenceTable table = (ReferenceTable) l_tables.get(ns);
! 			if (null == table) {
  
  				hasReference = false;
  			}
! 			else {
  
  				hasReference = table.hasReference(identifier);
--- 28,51 ----
  	//:TODO: If so, add one to ResourceUpdaterContext & keep a global 
  
! 	private ReferenceManager()
! 	{
  	}
  
! 	public static boolean hasReference(GenericIdentifier identifier)
! 	{
  		boolean hasReference = false;
  
  		GenericNamespace ns = identifier.getNamespace();
  
! 		synchronized (l_tables)
! 		{
  			ReferenceTable table = (ReferenceTable) l_tables.get(ns);
! 			if (null == table)
! 			{
  
  				hasReference = false;
  			}
! 			else
! 			{
  
  				hasReference = table.hasReference(identifier);
***************
*** 48,57 ****
  
  	public static Object getReference(GenericIdentifier identifier)
! 		throws NoSuchReferenceException {
  		Object reference = null;
  
  		GenericNamespace ns = identifier.getNamespace();
  
! 		synchronized (l_tables) {
  			ReferenceTable table = (ReferenceTable) l_tables.get(ns);
  			if (null == table)
--- 57,68 ----
  
  	public static Object getReference(GenericIdentifier identifier)
! 		throws NoSuchReferenceException
! 	{
  		Object reference = null;
  
  		GenericNamespace ns = identifier.getNamespace();
  
! 		synchronized (l_tables)
! 		{
  			ReferenceTable table = (ReferenceTable) l_tables.get(ns);
  			if (null == table)
***************
*** 67,79 ****
  	}
  
! 	public static Object createReference(Referenceable referenceable) {
! 		Object reference = null;
! 
  		GenericIdentifier identifier = referenceable.getIdentifier();
  		GenericNamespace ns = identifier.getNamespace();
  
! 		synchronized (l_tables) {
  			ReferenceTable table = (ReferenceTable) l_tables.get(ns);
! 			if (null == table) {
  
  				table = new ReferenceTable(ns);
--- 78,91 ----
  	}
  
! 	public static void createReference(Referenceable referenceable)
! 	{
  		GenericIdentifier identifier = referenceable.getIdentifier();
  		GenericNamespace ns = identifier.getNamespace();
  
! 		synchronized (l_tables)
! 		{
  			ReferenceTable table = (ReferenceTable) l_tables.get(ns);
! 			if (null == table)
! 			{
  
  				table = new ReferenceTable(ns);
***************
*** 84,91 ****
  		}
  
- 		return reference;
  	}
  
! 	public static void dump() {
  		DebugUtils.dump(l_tables);
  	}
--- 96,135 ----
  		}
  
  	}
  
! 	public static Object createReference(
! 		Class clazz,
! 		String tagId,
! 		String refId)
! 	{
! 		Object reference = null;
! 		try
! 		{
! 			if(refId == null)
! 			{
! 				Class[] argumentTypes = { java.lang.String.class };
! 				Constructor idArgumentConstructor = clazz.getDeclaredConstructor(argumentTypes);
! 				idArgumentConstructor.setAccessible(true);
! 				reference = idArgumentConstructor.newInstance(new Object[] { tagId });
! 				
! 				//add the object to the reference table
! 				createReference((Referenceable)reference);
! 			}
! 			else
! 			{
! 				//TODO clone the object
! 			}
! 		}
! 		catch (Exception exp)
! 		{
! 			Logger.getLog().error(
! 				Messages.getString("CREATE_REFERENCE_ERROR"),
! 				exp);
! 		}
! 
! 		return reference;
! 	}
! 	public static void dump()
! 	{
  		DebugUtils.dump(l_tables);
  	}




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.