/**
   * Helper method that sets up the contexts and creates and sets an expression context into the
   * environment context.
   *
   * @return the MarinerPageContext
   */
  protected TestMarinerPageContext createContexts() throws Exception {
    TestMarinerPageContext pageContext = new TestMarinerPageContext();
    pageContext.setVolantis(volantis);
    TestEnvironmentContext envContext = new TestEnvironmentContext();

    DefaultDevice dev = new DefaultDevice(null, null, null);
    dev.setName("myDevice");
    dev.setPolicyValue("protocol", "XHTMLBasic");
    MarinerSessionContext session = envContext.getSessionContext();
    InternalDevice internalDevice = INTERNAL_DEVICE_FACTORY.createInternalDevice(dev);
    session.setDevice(internalDevice);
    pageContext.setDevice(session.getDevice());

    // Create an expression context for the environment context.
    final ExpressionFactory factory = ExpressionFactory.getDefaultInstance();
    final EnvironmentInteractionTracker simpleTracker = new SimpleEnvironmentInteractionTracker();
    final ExpressionContext exprContext =
        factory.createExpressionContext(simpleTracker, new DefaultNamespacePrefixTracker());

    // Associate the expression context with the environment context.
    envContext.setExpressionContext(exprContext);

    // Create the initial request context.
    MarinerRequestContext requestContext = createInitialRequestContext(envContext);

    ApplicationContext appContext = new ApplicationContext(requestContext);
    appContext.setEncodingManager(encodingManager);

    pageContext.pushRequestContext(requestContext);
    ContextInternals.setEnvironmentContext(requestContext, envContext);
    ContextInternals.setMarinerPageContext(requestContext, pageContext);
    ContextInternals.setApplicationContext(requestContext, appContext);

    return pageContext;
  }
  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    ApplicationContext applicationContext = ApplicationContext.getInstance();

    try {
      HttpContext httpContext = this.read(req);
      httpContext =
          this.filter.process(
              httpContext, applicationContext.getModel(), applicationContext.getConfiguration());
      this.write(resp, httpContext);

    } catch (FilterException e) {
      this.error(e, resp);
    }
  }
Beispiel #3
0
  @Test
  public void test() {
    final TestSvc test = (TestSvc) context.getBean("testSvc");

    // *AssignCache assignments are not very dynamic by their very nature.
    // Take care to invalidate the caches before each of the *AssignCache tests
    test.invalidateL2AssignIndia(System.currentTimeMillis());

    // Set the first cached datum
    final String orig = test.getL2AssignGolf(999L, RandomStringUtils.randomAlphabetic(4) + "-");

    // Make sure the value is definitely in there
    for (int ix = 0; ix < 3; ix++) {
      assertEquals(
          orig,
          test.getL2AssignGolf(1000L + ix, RandomStringUtils.randomAlphanumeric(4 + ix) + "-"));
    }

    // Force the update to happen.
    final String renew =
        test.getL2AssignHotel(
            System.currentTimeMillis(), RandomStringUtils.randomAlphanumeric(8) + "-");
    assertFalse(orig.equals(renew));

    // Make sure the NEW value is definitely in there
    for (int ix = 0; ix < 3; ix++) {
      assertEquals(
          renew,
          test.getL2AssignGolf(1000L + ix, RandomStringUtils.randomAlphanumeric(8 + ix) + "-"));
    }
  }
  /**
   * Inicializa la comunicación con el servidor.
   *
   * @throws RequestException es lanzada cuando no se puede establecer la comunicación el servidor
   */
  protected void activeCommunication() throws RequestException {
    try {
      OutputMonitor.printLine("Initialize communication", OutputMonitor.INFORMATION_MESSAGE);

      // iniciar el entorno de ejecución de ICE
      if (communication.isInitialize()) {
        communication.reset();
      } else {
        communication.initialize(this.args);
      }
      SettingProperties.loadSettingProperies();
      ApplicationContext.initContext();
      String host = cnxServer.getServerHost();
      int serverPort = cnxServer.getServerPort();
      int clientPort = clientSetting.getPortNumber();
      OutputMonitor.printLine("Server host: " + host, OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine("Server port: " + serverPort, OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine(
          "Server name: " + cnxServer.getServerName(), OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine(
          "Container name: " + cnxServer.getContainerName(), OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine(
          "Session name: " + cnxServer.getSessionName(), OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine(
          "File store name: " + cnxServer.getFileStoreName(), OutputMonitor.INFORMATION_MESSAGE);

      if (clientPort <= 0) {
        clientPort = (clientPort <= 0) ? Utilities.getAvailablePort() : clientPort;
        clientSetting.setPortNumber(clientPort);
      }

      this.appManager = new ApplicationManager(communication, netController, clientPort);
      this.appManager.activate();
      this.server =
          new DelegateServerManager(communication, cnxServer.getServerName(), host, serverPort);
      this.server.create(); // se establece la comunicación con el proxy del servidor
      this.container = server.getDlgSessionContainer(cnxServer.getContainerName());
      this.session =
          container.getNoPersistentSessionByName(
              cnxServer.getSessionName(), Invocation.SYNCHRONOUS_METHOD_INVOCATION);
      this.session.setCommunication(container.getCommunication());
      this.fileStore =
          new DelegateFileStore(communication, cnxServer.getFileStoreName(), host, serverPort);
      this.fileStore.create();
      this.startedCommunication = true;

      OutputMonitor.printLine("Initialized communication", OutputMonitor.INFORMATION_MESSAGE);
    } catch (Exception ex) {
      throw new RequestException(ex.getMessage());
    }
  }
Beispiel #5
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {

    boolean result = super.onKeyDown(keyCode, event);

    // limit the maximum volume to 0.9 [echo prevention]
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
      AudioManager audioManager =
          (AudioManager)
              ApplicationContext.getInstance().getContext().getSystemService(Context.AUDIO_SERVICE);
      int curVol = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
      int maxVol = (int) (audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL) * 0.9);
      Log.d("RedPhone", "volume up key press detected: " + curVol + " / " + maxVol);
      if (curVol > maxVol) {
        audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, maxVol, 0);
      }
    }
    return result;
  }
Beispiel #6
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);

    setContentView(R.layout.main);
    tv_sender_nickname = (TextView) findViewById(R.id.sender_nickname);
    tv_recipients_nickname = (TextView) findViewById(R.id.recipients_nickname);
    tv_message = (TextView) findViewById(R.id.message);
    btn_read_more_button = (Button) findViewById(R.id.read_more_button);

    final String regId = GCMRegistrar.getRegistrationId(this);
    Log.i(debugAppTag, "registration id ==  " + regId);

    if (regId.equals("")) {
      GCMRegistrar.register(this, ApplicationContext.getSenderID());
    } else {
      Log.v(debugAppTag, "Already registered");
    }
  }
  @SuppressWarnings("unchecked")
  public D build() {
    try {
      T object = type.newInstance();
      for (String name : parameters.keySet()) {
        Field field = type.getDeclaredField(name);
        field.setAccessible(true);
        field.set(object, parameters.get(name));
      }

      for (String dependency : dependencies.keySet()) {
        Field field = type.getDeclaredField(dependency);
        field.setAccessible(true);
        field.set(object, ApplicationContext.getInstance().getObject(dependencies.get(dependency)));
      }
      return (D) object;
    } catch (InstantiationException e) {
      throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
  }
 public boolean isSingleton(String arg0) throws NoSuchBeanDefinitionException {
   return applicationContext.isSingleton(arg0);
 }
 public boolean isTypeMatch(String arg0, Class<?> arg1) throws NoSuchBeanDefinitionException {
   return applicationContext.isTypeMatch(arg0, arg1);
 }
 public Environment getEnvironment() {
   return applicationContext.getEnvironment();
 }
 public boolean isPrototype(String arg0) throws NoSuchBeanDefinitionException {
   return applicationContext.isPrototype(arg0);
 }
Beispiel #12
0
 private void initializeApplicationContext() {
   ApplicationContext context = ApplicationContext.getInstance();
   context.setContext(this);
   context.setCallStateListener(this);
 }
 public NumberFormat getDistanceFormat() {
   UserSettings.SpeedUnit speedUnit =
       ApplicationContext.getInstance().getUserSettings().getSpeedUnit();
   return new DistanceNumberFormat(speedUnit.getDistanceUnit());
 }
 public BeanFactory getParentBeanFactory() {
   return applicationContext.getParentBeanFactory();
 }
 public boolean containsBeanDefinition(String arg0) {
   return applicationContext.containsBeanDefinition(arg0);
 }
 public String getMessage(String arg0, Object[] arg1, String arg2, Locale arg3) {
   return applicationContext.getMessage(arg0, arg1, arg2, arg3);
 }
 public ApplicationContext getParent() {
   return applicationContext.getParent();
 }
 public String getMessage(String arg0, Object[] arg1, Locale arg2) throws NoSuchMessageException {
   return applicationContext.getMessage(arg0, arg1, arg2);
 }
 public String getMessage(MessageSourceResolvable arg0, Locale arg1)
     throws NoSuchMessageException {
   return applicationContext.getMessage(arg0, arg1);
 }
 public String getId() {
   return applicationContext.getId();
 }
 public void publishEvent(ApplicationEvent arg0) {
   applicationContext.publishEvent(arg0);
 }
 public ClassLoader getClassLoader() {
   return applicationContext.getClassLoader();
 }
 /**
  * 鏍规嵁key 鏉ユ煡鎵�鍊�
  *
  * @param key
  * @return
  */
 public static String getMsgByKey(String key) {
   if (key == null | key.trim().length() <= 0) {
     return null;
   }
   return applicationContext.getMessage(key, null, Locale.getDefault());
 }
 public Resource[] getResources(String arg0) throws IOException {
   return applicationContext.getResources(arg0);
 }
 public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> arg0)
     throws BeansException {
   return applicationContext.getBeansWithAnnotation(arg0);
 }
 public long getStartupDate() {
   return applicationContext.getStartupDate();
 }
 public NumberFormat getSpeedFormat() {
   return new SpeedNumberFormat(ApplicationContext.getInstance().getUserSettings().getSpeedUnit());
 }
 public Class<?> getType(String arg0) throws NoSuchBeanDefinitionException {
   return applicationContext.getType(arg0);
 }
 public Resource getResource(String arg0) {
   return applicationContext.getResource(arg0);
 }
 public String getDisplayName() {
   return applicationContext.getDisplayName();
 }