com/scalagent/kjoram/admin/AdministeredObject.java

00001 /*
00002  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
00003  * Copyright (C) 2001 - ScalAgent Distributed Technologies
00004  * Copyright (C) 1996 - Dyade
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA.
00020  *
00021  * Initial developer(s): Frederic Maistre (INRIA)
00022  * Contributor(s): Nicolas Tachker (ScalAgent)
00023  */
00024 package com.scalagent.kjoram.admin;
00025 
00026 import java.util.Hashtable;
00027 import java.util.Vector;
00028 
00033 public abstract class AdministeredObject
00034 {
00041   protected static Hashtable instancesTable = new Hashtable();
00042 
00044   protected String id;
00045 
00046 
00052   protected AdministeredObject(String id)
00053   {
00054     this.id = this.getClass().getName() + ":" + id;
00055 
00056     // Registering this instance in the table:
00057     instancesTable.put(this.id, this);
00058   }
00059 
00063   protected AdministeredObject()
00064   {}
00065 
00067   public static Object getInstance(String name)
00068   {
00069     if (name == null)
00070       return null;
00071     return instancesTable.get(name);
00072   }
00073 
00074   public void setId(String id) {
00075     this.id = id;
00076   }
00077 
00078   public String getId() {
00079     return id;
00080   }
00081 
00082   public void addInstanceTable(String key, Object value) {
00083     instancesTable.put(key,value);
00084   }
00085 
00090   public Hashtable code() {
00091     Hashtable h = new Hashtable();
00092     String className = this.getClass().getName();
00093     String end = className.substring(
00094       className.lastIndexOf((int)'.'),
00095       className.length());
00096 
00097     if (className.startsWith("com.scalagent.kjoram.admin")) {
00098       className = "org.objectweb.joram.client.jms.admin";
00099     } else if (className.startsWith("com.scalagent.kjoram.excepts")) {
00100       className = "org.objectweb.joram.shared.excepts";
00101     } else if (className.startsWith("com.scalagent.kjoram.jms")) {
00102       className = "org.objectweb.joram.shared.client";
00103     } else if (className.startsWith("com.scalagent.kjoram.ksoap")) {
00104       className = "org.objectweb.joram.client.jms.ksoap";
00105     } else if (className.startsWith("com.scalagent.kjoram.messages")) {
00106       className = "org.objectweb.joram.shared.messages";
00107     } else if (className.startsWith("com.scalagent.kjoram")) {
00108       className = "org.objectweb.joram.client.jms";
00109     }
00110     className = className + end;
00111     h.put("className",className);
00112     return h;
00113   }
00114 }

Generated on Tue Sep 16 16:14:23 2008 for joram by  doxygen 1.5.0