Showing posts with label Java EE 7. Show all posts
Showing posts with label Java EE 7. Show all posts

29 November 2018

Websocket examples

Websocket examples using

5 May 2016

Callable ManagedTaskListener

  class Japavapa implements Callable, ManagedTask, ManagedTaskListener {

    String word;
    LocalTime submit;

    public Japavapa(String word) {
      this.word = word;
    }

    public String toString() {
      return ":P " + word;
    }

    @Override
    public String call() throws Exception {
      Random rand = new Random();
      Thread.currentThread().sleep(rand.nextInt(1000));
      Matcher match = Pattern.compile("([AEIOUYaeiouy]+)").matcher(word);
      return match.find() ? match.replaceAll(match.group(1) + "p" + match.group(1)) : word;
    }

    @Override
    public ManagedTaskListener getManagedTaskListener() {
      return this;
    }

    @Override
    public Map<String, String> getExecutionProperties() {
      return null;
    }

    @Override
    public void taskSubmitted(Future<?> future, ManagedExecutorService executor, Object task) {
      submit = LocalTime.now();
      logger.info("SUBMIT " + task
        + " AT " + submit 
        + " ON " + executor);
    }

    @Override
    public void taskAborted(Future<?> future, ManagedExecutorService executor, Object task, Throwable exception) {
      logger.info("ABORTED " + task
        + " AFTER " + Duration.between(submit, LocalTime.now()).toMillis()
        + "ms ON " + Thread.currentThread().getName());
    }

    @Override
    public void taskDone(Future<?> future, ManagedExecutorService executor, Object task, Throwable exception) {
      logger.info("DONE " + task
        + " AFTER " + Duration.between(submit, LocalTime.now()).toMillis() + "ms");
    }

    @Override
    public void taskStarting(Future<?> future, ManagedExecutorService executor, Object task) {
      logger.info("STARTING " + task
        + " AFTER " + Duration.between(submit, LocalTime.now()).toMillis()
        + "ms ON " + Thread.currentThread().getName());
    }

  }

7 September 2012

Oracle drops Java EE7 out of the cloud

Cloud support (PaaS) was Oracle's main focus for Java EE7.
Oracle has now proposed to the expert group to remove cloud support from Java EE7 in order to keep the planned release schedule.
Expert group members react positively.
I just don't know: dropping your main feature to reach your deadline?
We delivered your car on time, Sir (but the engine's missing).

21 June 2012

Expression Language 3.0 is in public review

The Expression Language (EL) is widely used in JSP and JSF. With version 3 the EL now becomes an independent specification. The EL v3 (JSR 314) is in public review until the end of July. It will be released in sync with Java EE 7 (Update: EL 3.0 was released in may 2013). New features include:

  •  As an independent specification, EL now comes with a standalone API, allowing usage outside a web container.
    • You can write your own ELProcessor. The source code is available, but I wish they had put the javadoc for  browsing at the project site as well.
  • Java 8 stuff
    • Lambda expressions
    • Collection literals follow proposed Java 8 syntax
      • List: [1, "two", 3.0]
      • Set: {1, 2, 3}
      • Map: {"one":1, "two":2, "three":3}
    • Collection streaming
  • Assignment operator (=) for changing values:
    • ${customer.name = 'Jan'}
  • String concatenation: + or cat operator
    • ${‘Welcome ‘ += customer.name += ‘ to our site’}.
  • Support for static references using the T construct (Type). 
    • By default only java.* and javax.* packages are available, but you can modify this using the EL API.
      • ${T(java.util.Calendar).APRIL}
      • ${T(java.util.Calendar).getInstance()}
    •  You can call constructors as a static method without a name. To call the default Calendar constructor:
      • ${T(java.util.Calendar).()}
    • For java.lang you can use the class without using the T construct
      • ${Boolean.TRUE}