Package com.packtpub.java7.concurrency.chapter1.recipe7.event

Examples of com.packtpub.java7.concurrency.chapter1.recipe7.event.Event


  logger.warning(message);
  display.bell(-50);
    }

    private void readAndDispatchEvent() {
  Event firstEvent = null;
  try {
      firstEvent = display.next_event();
  } catch (Exception e) {
      // We may get an exception at this point if the XS server goes
      // away. Just ignore it and exit the window manager.
View Full Code Here


   * @throws ConfigException
   *             DOCUMENT ME!
   */
  public EventProxy getEventProxy(String eventName) throws ConfigException {
    EventDef eventDef = this.events.get(eventName);
    Event event = null;

    if (eventDef == null) {
      throw new ConfigException("Invalid Event Name: " + eventName); //$NON-NLS-1$
    }

    try {
      String type = eventDef.getType();

      if (type != null) {
        // event = (Event) getClass().forName(type).newInstance();
        event = (Event) Class.forName(type).newInstance();
        event.setEventName(eventName);
      }
    } catch (Exception e) {
      throw new ConfigException("Invalid Event ", e); //$NON-NLS-1$
    }

View Full Code Here

     * @return The event that is associated with the request in the
     *         configuration.
     */
    public Event getEvent() throws ConfigException {
        String eventName = getEventName(this.request.getServletPath());
        Event event = getConfig().getEventProxy(eventName).getEvent();
        if (event != null) {
            event.setEventName(eventName);
        }
        return event;

    }
View Full Code Here

        //String view = null;
        //ForwardProxy result = null;
        ViewProxy proxy = null;
        try {
            String eventName = getEventName(this.request.getServletPath());
            Event event = getEvent();

            if (this.requestParams == null) {
                Frame2Exception e = null;
                if (this.fileUploadException != null) {
                    e = new Frame2Exception(this.fileUploadException);
View Full Code Here

    private ViewProxy callAndMapHandlers(ForwardProxy proxy) throws Exception {
      boolean valid = true;
      ForwardProxy result = proxy;
        while (result.isEventType()) {
          // Map URI params into event, then callHandlers again
          Event next = getConfig().getEventProxy(result.getPath()).getEvent();
          if (getContextWrapper().hasResponseURIAttributes()) {
            valid = mapAttributesToEvent(getContextWrapper().getResponseURIAttributes(), next, getConfig().validateFor(next.getEventName()));
          }
          if (valid) {
            result = callHandlers(result.getPath(), next, ViewType.HTML);
          } else {
            return new ViewProxy(result, getValidationFailedView(next, next.getEventName()).getPath());
          }
        }
      getContextWrapper().clearResponseURIAttributes();
      return new ViewProxy(result, result.getPath());
    }
View Full Code Here

      new Configuration("org/megatome/frame2/front/test-config.xml"); //$NON-NLS-1$
  }

  @Test
  public void testEventBinding() {
    Event event = null;
    try {
      event = this.config.getEventProxy("event1").getEvent(); //$NON-NLS-1$
    } catch (ConfigException e) {
      fail("Unexpected ConfigException: " + e.getMessage()); //$NON-NLS-1$
    }
View Full Code Here

    setServletPath("/event1"); //$NON-NLS-1$

    HttpRequestProcessor request = createHelper(config);

    Event event = request.getEvent();

    assertNotNull(event);
    assertTrue(event instanceof Event1);
  }
View Full Code Here

    request.processRequest();

    verifyForwardPath("/view1.jsp"); //$NON-NLS-1$

    Event evt1 = (Event) request.getContextWrapper().getRequestAttribute(
        "eventChain1"); //$NON-NLS-1$
    assertNotNull(evt1);

    String eventChainName = (String) request.getContextWrapper()
        .getRequestAttribute("eventChainName"); //$NON-NLS-1$
View Full Code Here

      setServletPath("/" + EVENT_NAME + ".f2"); //$NON-NLS-1$ //$NON-NLS-2$
      HttpRequestProcessor requestProc = createHelper(config);

      requestProc.processRequest();
      HttpServletRequest request = getRequest();
      Event event = (Event) request.getAttribute(EVENT_NAME);

      assertEquals(EVENT_NAME, event.getEventName());
    } catch (Throwable e) {
      fail();
    }

  }
View Full Code Here

      }
    };
   
    brokerInstance.subscribeNonPersistantly(subscription, dispatcher);
   
    brokerInstance.publishEvent(new Event(new Object(), topic));
   
    Thread.sleep(10000);
  }
View Full Code Here

TOP

Related Classes of com.packtpub.java7.concurrency.chapter1.recipe7.event.Event

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.