1 16 17 package org.apache.axis.server; 18 19 import org.apache.axis.AxisEngine; 20 import org.apache.axis.AxisFault; 21 import org.apache.axis.utils.Messages; 22 23 import javax.naming.InitialContext ; 24 import javax.naming.NamingException ; 25 import javax.servlet.ServletContext ; 26 import java.util.Map ; 27 28 36 37 public class JNDIAxisServerFactory extends DefaultAxisServerFactory { 38 39 53 public AxisServer getServer(Map environment) 54 throws AxisFault 55 { 56 log.debug("Enter: JNDIAxisServerFactory::getServer"); 57 58 InitialContext context = null; 59 60 try { 63 context = new InitialContext (); 64 } catch (NamingException e) { 65 log.warn(Messages.getMessage("jndiNotFound00"), e); 66 } 67 68 ServletContext servletContext = null; 69 try { 70 servletContext = 71 (ServletContext )environment.get(AxisEngine.ENV_SERVLET_CONTEXT); 72 } catch (ClassCastException e) { 73 log.warn(Messages.getMessage("servletContextWrongClass00"), e); 74 } 76 77 AxisServer server = null; 78 if (context != null && servletContext != null) { 79 81 86 87 90 String name = servletContext.getRealPath("/WEB-INF/Server"); 92 93 111 if (name != null) { 114 try { 115 server = (AxisServer)context.lookup(name); 116 } catch (NamingException e) { 117 server = super.getServer(environment); 119 try { 120 context.bind(name, server); 121 } catch (NamingException e1) { 122 } 124 } 125 } 126 } 127 128 if (server == null) { 129 server = super.getServer(environment); 130 } 131 132 log.debug("Exit: JNDIAxisServerFactory::getServer"); 133 134 return server; 135 } 136 } 137 | Popular Tags |