00001 /* 00002 * 00003 * JOnAS: Java(TM) Open Application Server 00004 * Copyright (C) 1999 Bull S.A. 00005 * Contact: jonas-team@objectweb.org 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 * 00022 * -------------------------------------------------------------------------- 00023 * $Id: javaURLContextFactory.java,v 1.5 2003/06/13 11:19:49 benoitf Exp $ 00024 * -------------------------------------------------------------------------- 00025 */ 00026 00027 package org.objectweb.jonas.naming.java; 00028 00029 import java.util.Hashtable; 00030 import javax.naming.Context; 00031 import javax.naming.Name; 00032 import javax.naming.spi.ObjectFactory; 00033 import org.objectweb.util.monolog.api.Logger; 00034 import org.objectweb.util.monolog.api.BasicLevel; 00035 00045 public class javaURLContextFactory implements ObjectFactory { 00046 00050 private static Logger logger = null; 00051 00065 public Object getObjectInstance(Object url, Name name, Context ctx, Hashtable env) throws Exception { 00066 if (url == null) { 00067 // All naming operations with "java:..." comes here 00068 // Users are encouraged to used intermediate contexts: 00069 // ctx = ic.lookup("java:comp/env") called only once (perfs) 00070 return new javaURLContext(env); 00071 } 00072 if (url instanceof String) { 00073 // Don't know what to do here 00074 logger.log(BasicLevel.WARN, "javaURLContextFactory.getObjectInstance(" + url + ")"); 00075 return null; 00076 } else if (url instanceof String[]) { 00077 // Don't know what to do here 00078 logger.log(BasicLevel.WARN, "javaURLContextFactory.getObjectInstance(String[])"); 00079 return null; 00080 } else { 00081 // invalid argument 00082 throw (new IllegalArgumentException("javaURLContextFactory")); 00083 } 00084 } 00085 }