KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > jndi2 > scn > scnURLContextFactory


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2004 ScalAgent Distributed Technologies
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  *
20  * Initial developer(s): David Feliot
21  * Contributor(s):
22  */

23 package fr.dyade.aaa.jndi2.scn;
24
25 import java.util.Hashtable JavaDoc;
26 import javax.naming.Context JavaDoc;
27 import javax.naming.Name JavaDoc;
28 import javax.naming.spi.ObjectFactory JavaDoc;
29
30 import org.objectweb.util.monolog.api.BasicLevel;
31 import org.objectweb.util.monolog.api.Logger;
32
33 /**
34  * Context factory for scnURLContext objects.
35  * This factory will be used for all "scn:..." urls provided as Name objects
36  * for all JNDI operations.
37  */

38 public class scnURLContextFactory implements ObjectFactory JavaDoc {
39
40   public final static Logger logger;
41   
42   static {
43     logger = fr.dyade.aaa.util.Debug.getLogger("fr.dyade.aaa.jndi2.scn");
44   }
45
46   /**
47    * Returns an instance of scnURLContext for a java URL.
48    *
49    * If url is null, the result is a context for resolving java URLs.
50    * If url is a URL, the result is a context named by the URL.
51    *
52    * @param url String with a "scn:" prefix or null.
53    * @param name Name of context, relative to ctx, or null.
54    * @param ctx Context relative to which 'name' is named.
55    * @param env Environment to use when creating the context
56    */

57   public Object JavaDoc getObjectInstance(Object JavaDoc url,
58                                   Name JavaDoc name,
59                                   Context JavaDoc ctx,
60                   Hashtable JavaDoc env)
61     throws Exception JavaDoc {
62     if (logger.isLoggable(BasicLevel.DEBUG))
63       logger.log(BasicLevel.DEBUG,
64                  "scnURLContextFactory.getObjectInstance(" + url +
65                  ',' + name + ',' + ctx + ',' + env + ')');
66
67     if (url == null) {
68       return new scnURLContext(env);
69     } else if (url instanceof String JavaDoc) {
70       // Don't know what to do here
71
return null;
72     } else if (url instanceof String JavaDoc[]) {
73       // Don't know what to do here
74
return null;
75     } else {
76       // invalid argument
77
throw (new IllegalArgumentException JavaDoc(
78         "scnURLContextFactory"));
79     }
80   }
81 }
82
83
Popular Tags