Web Components in Unsupported Browsers

What happens to Web Components (Custom Elements and Shadow DOM) in unsupported browsers? In this screencast I'm creating a Custom Element with Shadow DOM from scratch and run the sample in Firefox, Safari and Chrome. Patching (aka polyfill) included:

See you at Structuring Single Page Applications (SPA)s / Progressive Web Applications (PWA)s with WebComponents -- the "no frameworks, no migrations" approach, at Munich Airport, Terminal 2 or webcomponents.training (online).


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Metrics, ServerSockets, SSE, WebSockets, Smelling DAOs, JPA Historization, SLSB scalability, Killing EJBs, Logging, ELK, Docker, Kubernetes, Openshift, Licensing, Obfuscation -- or 46th airhacks.tv

This time "Metrics, ServerSockets, SSE, WebSockets, Homework / Code Review of a basic CRUD, Smelling DAOs, JPA Historisation, SLSB design for scalability, Killing EJBs, Logging, ELK, Docker, Kubernetes, Openshift, Licensing, Obfuscation" were discussed.

Any questions left? Ask now: https://gist.github.com/AdamBien/dce90e8d7162c06ca3395f9a9ceb7bf1 and get the answers at the next airhacks.tv.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Web Components On-Demand Workshops

After covering the "basics" in WebStandards igniter, now 50+ episodes of continuous Web Components (Custom Elements, Shadow DOM, CSS 3 styling, Templates, ES 6 imports) coding workshop is available: webcomponents.training. No installation, no dependencies, no builds: only vanilla web (browser) standards, without any external frameworks or dependencies, were used.

Are you already building, or still migrating? Learn once, apply anywhere :-):

Web Components from AdamBien on Vimeo.

See you also at: PWAs / SPAs with Web Components Workshop at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting.


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Pipeline-specific timeouts with CompletableFuture#orTimeout and JAX-RS 2.1

CompletableFuture#orTimeout (>= Java 9) method

"...exceptionally completes this CompletableFuture with a TimeoutException if not otherwise completed before the given timeout. ..."
and is therefore well suited to set a pipeline-specific timeout.

The method AsyncResponse#setTimeout sets the max timeout per request:


import static java.util.concurrent.CompletableFuture.supplyAsync;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Response;

@Path("ping")
public class PingResource {

    @GET
    public void ping(@Suspended AsyncResponse response) {
        response.setTimeout(1, TimeUnit.SECONDS); //global timeout
        supplyAsync(this::answer).
                thenAccept(response::resume).
                orTimeout(100, TimeUnit.MILLISECONDS). //pipeline specific timeout
                exceptionally((t) -> handleTimeout(response::resume, t));
    }

    Void handleTimeout(Consumer<Response> consumer, Throwable t) {
        consumer.accept(Response.status(503).
                header("cause", "timeout in the pipeline").
                header("exception", t.toString()).
                build());
        return null;
    }

    public String answer() {
        try {
            Thread.sleep(200);
            return "42 + " + System.currentTimeMillis();
        } catch (InterruptedException ex) {
            throw new IllegalStateException("cannot sleep");
        }
    }
}

The request: curl -i http://localhost:8080/completable-timeout/resources/ping returns:


HTTP/1.1 503 Service Unavailable
X-Powered-By: Servlet/4.0
cause: timeout in the pipeline
exception: java.util.concurrent.TimeoutException
(...)

See you at Java EE 8 / Java 9 / Web Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Java 9's StackWalker

The Java 9's StackWalker class allows stack walking without instantiating an Exception.

The following unit test:


package com.airhacks;

import java.lang.StackWalker.StackFrame;
import org.junit.Before;
import org.junit.Test;

public class StackWalkerBasicsTest {

    private StackWalker walker;

    @Before
    public void init() {
        this.walker = StackWalker.getInstance();
    }

    @Test
    public void walkTheStack() {
        this.walker.forEach(this::print);
    }

    void print(StackFrame frame) {
        String className = frame.getClassName();
        String methodName = frame.getMethodName();
        int lineNumber = frame.getLineNumber();
        System.out.println(className + "." + methodName + ":" + lineNumber);
    }
}

Writes the following output:


com.airhacks.StackWalkerBasicsTest.walkTheStack:24
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall:50
org.junit.internal.runners.model.ReflectiveCallable.run:12
org.junit.runners.model.FrameworkMethod.invokeExplosively:47
org.junit.internal.runners.statements.InvokeMethod.evaluate:17
org.junit.internal.runners.statements.RunBefores.evaluate:26
org.junit.runners.ParentRunner.runLeaf:325
org.junit.runners.BlockJUnit4ClassRunner.runChild:78
org.junit.runners.BlockJUnit4ClassRunner.runChild:57
org.junit.runners.ParentRunner$3.run:290
org.junit.runners.ParentRunner$1.schedule:71
org.junit.runners.ParentRunner.runChildren:288
org.junit.runners.ParentRunner.access$000:58
org.junit.runners.ParentRunner$2.evaluate:268
org.junit.runners.ParentRunner.run:363
org.apache.maven.surefire.junit4.JUnit4Provider.execute:252
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet:141
org.apache.maven.surefire.junit4.JUnit4Provider.invoke:112
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray:189
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke:165
org.apache.maven.surefire.booter.ProviderFactory.invokeProvider:85
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess:115
org.apache.maven.surefire.booter.ForkedBooter.main:75    

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Building a Web Component with Java EE 8 Backend

In this screencast I created a Java EE 8 application with JAX-RS endpoint and JSON-B serialization from scratch, then developed a Custom Element (part of the Web Components specification) which talks to the Java EE 8 backend in 6 mins. No external dependencies were used in frontend and backend.


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Homework Review, JPA history, Business Metrics, Sanity, WebSockets, SSE, XMPP, Logging, Licensing or Questions for the 46th airhacks.tv

Questions for the 46th airhacks.tv:

  1. Surprise
  2. Interactive review of a CRUD homework assignment
  3. JPA history
  4. Testing and embedded integration tests
  5. Getting rid of EJBs
  6. Business metrics with Java EE
  7. THE DAOs smell and Deltaspike Data
  8. Asynchronous JAX-RS resource
  9. Docker swarm vs. kubernetes vs. openshift
  10. SLSB command pattern vs. one bean with multiple methods
  11. How to stay sane (sanity is subjective :-)
  12. Server Push: WebSockets vs. SSE
  13. ServerSocket handling with Java EE -- or how to XMPP with Java EE
  14. Logging with java.util.logging and what about ELK?
  15. Java EE and obfuscation
  16. Licensing Java EE applications
  17. The Pair class and Apache Commons

Any questions left? Ask now: or wait a month.

Ask questions during the show via twitter mentioning me: http://twitter.com/AdamBien (@AdamBien) or using the hashtag: #airhacks. You can join the Q&A session live each first Monday of month, 6 P.M at airhacks.tv or http://www.ustream.tv/channel/adambien


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Reactive JAX-RS 2.1 Client Combined with Asynchronous Resource and CompletableFuture

The reactive JAX-RS 2.1 client integrates seamlessly with asynchronous JAX-RS resources and Java 8+CompletableFuture:

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

4th airhacks.fm Episode: "Micro Java EE"

4th episode "Micro Java EE" of airhacks.fm podcast with special guest, Payara CEO, Steve Millidge is available. We discussed Microservices, Cloud Native Java EE, Microprofile, EE4J, Thin WARs, Ueber JARS and Fat JARs.

Subscribe to airhacks.fm podcast via: RSS iTunes


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

From BeanShell and Kotlin over Deadlocked Conversations to AWS, Authentication and Java PWAs -- 45th airhacks.tv is available

From BeanShell over deadlocked conversations to AWS and authentication. The 45th airhacks.tv is available:

Any questions left? Ask now: https://gist.github.com/AdamBien/725f0e529bda54e2a35cf35c88f49c26 and get the answers at the next airhacks.tv.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


NEW online workshop: Web Components training (online)

Airport MUC workshops: Java EE 8, Java 9: Bootstrap, Effective, Architectures, Single Page Apps, Progressive Web Apps, HTML 5, ES 6, CSS 3 and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License