[jboss-cvs] JBossAS SVN: r78903 - projects/naming/trunk/jnpserver/src/main/java/org/jboss/naming.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 26 20:48:07 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-09-26 20:48:07 -0400 (Fri, 26 Sep 2008)
New Revision: 78903

Added:
   projects/naming/trunk/jnpserver/src/main/java/org/jboss/naming/InitialContextFactoryBean.java
Log:
JBNAME-11, an InitialContextFactoryBean that creates an InitialContext from the bean naming environment properties

Added: projects/naming/trunk/jnpserver/src/main/java/org/jboss/naming/InitialContextFactoryBean.java
===================================================================
--- projects/naming/trunk/jnpserver/src/main/java/org/jboss/naming/InitialContextFactoryBean.java	                        (rev 0)
+++ projects/naming/trunk/jnpserver/src/main/java/org/jboss/naming/InitialContextFactoryBean.java	2008-09-27 00:48:07 UTC (rev 78903)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.naming;
+
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * A bean that creates an InitialContext based on its env Properties
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class InitialContextFactoryBean
+{
+   private Properties env;
+   private InitialContext ctx;
+
+   public Properties getEnv()
+   {
+      return env;
+   }
+   public void setEnv(Properties env)
+   {
+      this.env = env;
+   }
+
+   public synchronized InitialContext getCtx()
+      throws NamingException
+   {
+      System.out.println(env);
+      if(ctx == null)
+         ctx = new InitialContext(env);
+      return ctx;
+   }
+}




More information about the jboss-cvs-commits mailing list