1 17 package org.alfresco.repo.webservice.axis; 18 19 import org.alfresco.repo.webservice.Utils; 20 import org.apache.axis.AxisFault; 21 import org.apache.axis.MessageContext; 22 import org.apache.axis.handlers.soap.SOAPService; 23 import org.apache.axis.providers.java.RPCProvider; 24 import org.springframework.web.context.WebApplicationContext; 25 26 31 public class SpringBeanRPCProvider extends RPCProvider 32 { 33 private static final long serialVersionUID = 2173234269124176995L; 34 private static final String OPTION_NAME = "springBean"; 35 private WebApplicationContext webAppCtx; 36 37 42 @Override 43 protected Class getServiceClass(String beanName, SOAPService service, MessageContext msgCtx) throws AxisFault 44 { 45 Class clazz = null; 46 47 Object bean = getBean(msgCtx, beanName); 48 if (bean != null) 49 { 50 clazz = bean.getClass(); 51 } 52 53 return clazz; 54 } 55 56 59 @Override 60 protected String getServiceClassNameOptionName() 61 { 62 return OPTION_NAME; 63 } 64 65 70 @Override 71 protected Object makeNewServiceObject(MessageContext msgCtx, String beanName) throws Exception 72 { 73 return getBean(msgCtx, beanName); 74 } 75 76 83 private Object getBean(MessageContext msgCtx, String beanName) throws AxisFault 84 { 85 return getWebAppContext(msgCtx).getBean(beanName); 86 } 87 88 94 private WebApplicationContext getWebAppContext(MessageContext msgCtx) throws AxisFault 95 { 96 if (this.webAppCtx == null && msgCtx != null) 97 { 98 this.webAppCtx = Utils.getSpringContext(msgCtx); 99 } 100 101 if (this.webAppCtx == null) 102 { 103 throw new AxisFault("Failed to retrieve the Spring web application context"); 104 } 105 106 return this.webAppCtx; 107 } 108 } 109 | Popular Tags |