Maybe this can give you some hint, I use a listener to get SCADomain
from Web Servlet Context:

package xxxx;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.apache.tuscany.sca.host.webapp.WebAppServletHost;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



public class ScaWebContextInitListener implements ServletContextListener {
        
        private static Logger logger =
LoggerFactory.getLogger(ScaWebContextInitListener.class);



    public void contextInitialized(ServletContextEvent event) {
        SCADomain scaDomain =
(SCADomain)event.getServletContext().getAttribute(WebAppServletHost.SCA_DOMAIN_ATTRIBUTE);
        if (scaDomain == null)
                logger.error("SCADomain has not found in context!");
        else
                logger.info("SCADomain has found.");

        //......
    }


}




2011/7/13 fzhong <[email protected]>:
> Hi all,
>     The spring provides ApplicationContextAware Interface to get
> ApplicationContext .Does Tuscany have similar mechanism to get SCADomain
> instance?
>
>    As the question I asked last time,maybe,I can develop a filter that
> implement javax.servlet.Filter interface. The filter get the SCADomain
> instance from the ServletContext in its init method  and save it to a static
> field. Then other class can get the scadomain anywhere. Any better
> suggestion?
> 2011-07-13
> ________________________________
> fzhong
> ________________________________
> 发件人: fzhong
> 发送时间: 2011-07-11  13:22:39
> 收件人: user
> 抄送:
> 主题: How can I get the SCADomain refererce in a polciy module?
> Hi all:
>   I'm trying to develop a policy module that need to visit database and rmi
> services, the database configuration and the rmi service has been
> initialized by the TuscanyContextListener .
>
>  I know that the developers can get a reference to the SCADomain in their
> JSP or HttpServlet just like the following code snippet:
>     SCADomain domain = (SCADomain)
> application.getAttribute("org.apache.tuscany.sca.SCADomain");
>
> My question is  how can I get the ServletContext in the policy?  The method
> of interceptor ' Message invoke(Message msg) ' has no information about
> that.
>
> Thanks.
> 2011-07-11
> ________________________________
> fzhong



-- 
Jet Knight

Reply via email to