1 55 56 package org.jboss.axis.server; 57 58 import org.jboss.axis.AxisEngine; 59 import org.jboss.axis.AxisFault; 60 import org.jboss.axis.utils.Messages; 61 import org.jboss.logging.Logger; 62 63 import javax.naming.InitialContext ; 64 import javax.naming.NamingException ; 65 import javax.servlet.ServletContext ; 66 import java.util.Map ; 67 68 76 77 public class JNDIAxisServerFactory extends DefaultAxisServerFactory 78 { 79 80 private static Logger log = Logger.getLogger(JNDIAxisServerFactory.class.getName()); 81 82 96 public AxisServer getServer(Map environment) 97 throws AxisFault 98 { 99 log.debug("Enter: JNDIAxisServerFactory::getServer"); 100 101 InitialContext context = null; 102 103 try 106 { 107 context = new InitialContext (); 108 } 109 catch (NamingException e) 110 { 111 log.warn(Messages.getMessage("jndiNotFound00"), e); 112 } 113 114 ServletContext servletContext = null; 115 try 116 { 117 servletContext = 118 (ServletContext )environment.get(AxisEngine.ENV_SERVLET_CONTEXT); 119 } 120 catch (ClassCastException e) 121 { 122 log.warn(Messages.getMessage("servletContextWrongClass00"), e); 123 } 125 126 AxisServer server = null; 127 if (context != null && servletContext != null) 128 { 129 131 136 137 140 String name = servletContext.getRealPath("/WEB-INF/Server"); 142 143 161 if (name != null) 164 { 165 try 166 { 167 server = (AxisServer)context.lookup(name); 168 } 169 catch (NamingException e) 170 { 171 server = super.getServer(environment); 173 try 174 { 175 context.bind(name, server); 176 } 177 catch (NamingException e1) 178 { 179 } 181 } 182 } 183 } 184 185 if (server == null) 186 { 187 server = super.getServer(environment); 188 } 189 190 log.debug("Exit: JNDIAxisServerFactory::getServer"); 191 192 return server; 193 } 194 } 195 | Popular Tags |