Examples of ServletContext


Examples of javax.servlet.ServletContext

    ActionMapping mapping = createMock(ActionMapping.class);
    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpSession session = createMock(HttpSession.class);
    ModuleConfig moduleConfig = createMock(ModuleConfig.class);
    ActionServlet servlet = createMock(ActionServlet.class);
    ServletContext context = createMock(ServletContext.class);
    MessageResources messageResources = createMock(MessageResources.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);

    action.setServlet(servlet);

    actionBean.preBind();
    form.bindInwards(actionBean);
    expect(request.getAttribute(Globals.CANCEL_KEY)).andReturn(null);
    expect(mapping.getParameter()).andReturn("method");
    expect(request.getParameter("method")).andReturn("Insert Stuff Here");
    expect(request.getSession(false)).andReturn(session);
    expect(session.getAttribute(Globals.LOCALE_KEY)).andReturn(Locale.getDefault());
    expect(request.getAttribute(Globals.MODULE_KEY)).andReturn(moduleConfig);
    expect(moduleConfig.findMessageResourcesConfigs()).andReturn(new MessageResourcesConfig[]
    {
      new MessageResourcesConfig()
    });
    expect(servlet.getServletContext()).andReturn(context);
    expect(request.getAttribute(Globals.MODULE_KEY)).andReturn(moduleConfig);
    expect(moduleConfig.getPrefix()).andReturn("");
    expect(context.getAttribute(Globals.MESSAGES_KEY)).andReturn(messageResources);
    expect(messageResources.getMessage(Locale.getDefault(), "insert.key")).andReturn("Insert Stuff Here");
    actionBean.insert();
    expect(actionBean.getNavigationResult()).andReturn("inserted");
    expect(mapping.findForward("inserted")).andReturn(actionForward);
View Full Code Here

Examples of javax.servlet.ServletContext

    ActionMapping mapping = createMock(ActionMapping.class);
    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpSession session = createMock(HttpSession.class);
    ModuleConfig moduleConfig = createMock(ModuleConfig.class);
    ActionServlet servlet = createMock(ActionServlet.class);
    ServletContext context = createMock(ServletContext.class);
    MessageResources messageResources = createMock(MessageResources.class);

    action.setServlet(servlet);

    expect(request.getAttribute(Globals.CANCEL_KEY)).andReturn(null);
    expect(mapping.getParameter()).andReturn("method");
    expect(request.getParameter("method")).andReturn("Insert Stuff Here");
    expect(request.getSession(false)).andReturn(session);
    expect(session.getAttribute(Globals.LOCALE_KEY)).andReturn(Locale.getDefault());
    expect(request.getAttribute(Globals.MODULE_KEY)).andReturn(moduleConfig);
    expect(moduleConfig.findMessageResourcesConfigs()).andReturn(new MessageResourcesConfig[]
    {
      new MessageResourcesConfig()
    });
    expect(servlet.getServletContext()).andReturn(context);
    expect(request.getAttribute(Globals.MODULE_KEY)).andReturn(moduleConfig);
    expect(moduleConfig.getPrefix()).andReturn("");
    expect(context.getAttribute(Globals.MESSAGES_KEY)).andReturn(messageResources);

    expect(mapping.getPath()).andReturn("appPath");

    replay(actionBean);
    replay(mapping);
View Full Code Here

Examples of javax.servlet.ServletContext

  }
 
  protected HttpContext getHttpContext(final ActionMapping mapping,
      final ActionForm form, final HttpServletRequest request,
      final HttpServletResponse response) {
    final ServletContext context = super.context();
    return new HttpContext() {
      public HttpServletRequest getRequest() {
        return request;
      }
View Full Code Here

Examples of javax.servlet.ServletContext

        try {

            // loop through all initialization parameter pairs
            HashMap map = new HashMap();
            Enumeration pnum = servlet.getInitParameterNames();
            ServletContext serv = servlet.getServletContext();
            while (pnum.hasMoreElements()) {

                // parameter name is path and value is service definition file
                path = (String) pnum.nextElement();
                file = "/WEB-INF/" + servlet.getInitParameter(path);
                InputStream is = null;
                try {
                    is = serv.getResourceAsStream(file);
                    if (is == null) {
                        logger.error("Service definition not found for service " + path + " at " + file);
                        throw new UnavailableException("Service definition not found for service " + path + " at "
                            + file + ". Check configuration of servlet " + servlet.getServletName()
                            + " in WEB-INF/web.xml.");
View Full Code Here

Examples of javax.servlet.ServletContext

  }

  public Object getValue(ActionContext injectionContext)
  {

    ServletContext context = injectionContext.getContext();

    Object attribute = context.getAttribute(attributeName);

    if (attribute == null && autoCreateClass != null)
    {
      attribute = AnnotationFactoryUtils.maybeAutoCreate(autoCreateClass);
      context.setAttribute(attributeName, attribute);
    }
    return attribute;
  }
View Full Code Here

Examples of javax.servlet.ServletContext

      HttpSession session = request.getSession();
      attribute = session.getAttribute(attributeName);
    }
    if (attribute == null)
    {
      ServletContext context = injectionContext.getContext();
      attribute = context.getAttribute(attributeName);
    }
    return attribute;
  }
View Full Code Here

Examples of javax.servlet.ServletContext

  private static final String LINE_PRICE_ATTR = "invoice.linePrice";

  public void initiatePriceCalculation(CustomerInfo customerInfo,
      PurchaseOrder purchaseOrder) {
    MessageContext messageContext = serviceContext.getMessageContext();
    ServletContext servletContext =
        (ServletContext) messageContext.get(MessageContext.SERVLET_CONTEXT);
    servletContext.setAttribute(ORDER_ID_ATTR, purchaseOrder.getOrderId());
    // In our system the part number is also the unit price!
    servletContext.setAttribute(LINE_PRICE_ATTR,
        (float) purchaseOrder.getQuantity() * purchaseOrder.getPartNumber());
  }
 
View Full Code Here

Examples of javax.servlet.ServletContext

    }
  }

  protected void sendInvoiceMessage(float shippingPrice) throws JMSException {
    MessageContext messageContext = serviceContext.getMessageContext();
    ServletContext servletContext =
        (ServletContext) messageContext.get(MessageContext.SERVLET_CONTEXT);
    Integer orderId = (Integer) servletContext.getAttribute(ORDER_ID_ATTR);
    Float linePrice = (Float) servletContext.getAttribute(LINE_PRICE_ATTR);
    float amount = linePrice + shippingPrice;

    // create a connection
    Connection connection = connectionFactory.createConnection();
    try {
View Full Code Here

Examples of javax.servlet.ServletContext

    return beanName;
  }

  public Object getValue(ActionContext injectionContext)
  {
    ServletContext servletContext = injectionContext.getContext();
    return SpringUtils.getSpringBean(servletContext, beanName);
  }
View Full Code Here

Examples of javax.servlet.ServletContext

  protected MessageResources getMessageResources(ActionContext injectionContext)
  {
    HttpServletRequest request = injectionContext.getRequest();

    ServletContext context = injectionContext.getContext();
    ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, context);

    // Return the requested message resources instance
    return (MessageResources) context.getAttribute(bundle + moduleConfig.getPrefix());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.