org/objectweb/joram/client/jms/admin/ObjectFactory.java

00001 /*
00002  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
00003  * Copyright (C) 2007 ScalAgent Distributed Technologies
00004  * Copyright (C) 2007 France Telecom R&D
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): ScalAgent Distributed Technologies
00022  * Contributor(s): 
00023  */
00024 package org.objectweb.joram.client.jms.admin;
00025 
00026 import javax.naming.*;
00027 
00028 import org.objectweb.joram.shared.JoramTracing;
00029 import org.objectweb.util.monolog.api.BasicLevel;
00030 
00035 public class ObjectFactory implements javax.naming.spi.ObjectFactory {
00036 
00038   public Object getObjectInstance(Object obj,
00039                                   Name name,
00040                                   Context ctx,
00041                                   java.util.Hashtable env) throws Exception {
00042     if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG))
00043       JoramTracing.dbgClient.log(BasicLevel.DEBUG,
00044                                  "ObjectFactory.getObjectInstance(" +
00045                                  obj + ',' + name + ',' +
00046                                  ctx + ',' + env + ')');
00047 
00048     Reference ref = (Reference) obj;
00049     AdministeredObject ao = null;
00050     try {
00051       Class clazz = Class.forName(ref.getClassName());
00052       ao = (AdministeredObject) clazz.newInstance();
00053       ao.fromReference(ref);
00054     } catch (Exception exc) {
00055       if (JoramTracing.dbgClient.isLoggable(BasicLevel.ERROR))
00056         JoramTracing.dbgClient.log(BasicLevel.ERROR, "", exc);
00057     }
00058     return ao;
00059   }
00060 }

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