Package org.stringtree.mojasef.model

Examples of org.stringtree.mojasef.model.CommonContext


import org.stringtree.tract.ByteTract;

public class CommonContextFallbackTest extends TestCase {
   
    public void testGetFromContext() throws IOException {
        CommonContext context = new RemoteSpecCommonContext("src/test/files/fb/fa.spec");
        Fetcher tpls = (Fetcher)context.getObject(MojasefConstants.TEMPLATE_SOURCE);
        assertEquals("I am aa: ${*hello}", tpls.getObject("home"));
        assertEquals("Hello, ${value}!", tpls.getObject("hello"));
    }
View Full Code Here


            server = (Server)servletContext.getAttribute(id);
            if (null == server) {
                String spec = getSpec(config);
                try {
                    server = new Server(spec, false);
                    CommonContext commonContext = server.getCommonContext();
                    if (null != overrides) {
                        commonContext.putAll(overrides);
                    }
                    if (!commonContext.contains(MojasefConstants.MOJASEF_SERVER_NAME)) {
                        commonContext.put(MojasefConstants.MOJASEF_SERVER_NAME, servletName);
                    }
                    servletContext.setAttribute(id, server);

                    Integer obj = (Integer)servletContext.getAttribute(MOJASEF_SERVLET_INSTANCE_COUNT);
                    int icount = (obj != null) ? obj.intValue() + 1 : 1;
                    servletContext.setAttribute(MOJASEF_SERVLET_INSTANCE_COUNT, new Integer(icount));

                @SuppressWarnings("unchecked")
                    Enumeration<String> at = servletContext.getAttributeNames();
                    while (at.hasMoreElements()) {
                        String name = at.nextElement();
                        Object value = servletContext.getAttribute(name);
                        commonContext.put(name, value);
                    }
                   
                @SuppressWarnings("unchecked")
                    Enumeration<String> pn = config.getInitParameterNames();
                    while (pn.hasMoreElements()) {
                        String name = pn.nextElement();
                        Object value = config.getInitParameter(name);
                        commonContext.put(name, value);
                    }
                } catch (IOException e) {
                    throw new ServletException(e);
                }
            }
View Full Code Here

TOP

Related Classes of org.stringtree.mojasef.model.CommonContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.