10 May 2016

JPA links (updated)

Reference implementation.

Official documentation:

Others:
Providers often have good JPA documentation as well. Might include extensions (and JDO stuff) though:

Specific topics:
Background:

    5 May 2016

    Callable ManagedTaskListener

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
      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());
        }
     
      }