Adam Bien's Weblog

MVC, MVP, IoC, DI or A Deeper Dive Into afterburner.fx

What is the difference between MVC and MVP? How does the Dependency Injection work? Is it possible to UI-designers in production? How to implement an extension mechanism with plain Java SE? In this late night session I answered most of the questions with code as well as explained the inner workings of afterburner.fx.

Thanks to Silicon Valley JavaFX User Group for hosting this event.

Any questions left? Then join the conversation at each first Monday of the month at 6 P.M. live. No registration or any other commitment required. Checkout also past shows.

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.


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

afterburner.fx v1.7.0 "Branch Terminator" Released

afterburner.fx is an opinionated MVP framework with built-in, conventional Dependency Injection implemented by a single class.

The v1.7.0 release comes with swappable DI mechanism. An extensible DI enables the contributors to implement project-specific conventions and will so eliminate many open pull request. The release v1.7.0 also deprecates the "Top Gun" branch.

To create your own Injector:

  1. Implement the functional interface: com.airhacks.afterburner.injection.PresenterFactory
  2. Specify the fully qualified name of the implementation in the file: META-INF/services/com.airhacks.afterburner.injection.PresenterFactory

A no-op injector already ships with afterburner.fx as a part of the unit test:


public class DebuggingInjector implements PresenterFactory {

    @Override
    public <T> T instantiatePresenter(Class<T> clazz, Function<String, Object> injectionContext) {
        System.out.println("--- clazz " + clazz + " context " + injectionContext);
        return Injector.instantiatePresenter(clazz, injectionContext);
    }

}

Checkout github.com/AdamBien/afterburner.fx. The v1.7.0 is already available in maven central:

<dependency>
  <groupId>com.airhacks</groupId>
  <artifactId>afterburner.fx</artifactId>
  <version>1.7.0</version>
</dependency>

Also take a look at: github.com/Naoghuman/NetBeansIDE-AfterburnerFX-Plugin

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.


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

@Stateless As JAX-RS Resource?

@Stateless EJBs are an interesting component to be used as JAX-RS resource. They come with out-of-the-box method monitoring:

Are you interested in monitoring and microservices? Checkout javaeemicro.services

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


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

Memory Footprint: Tomcat vs. TomEE WebProfile vs. TomEE Plus

How much memory can you save with plain servlet container, like Tomcat comparing to full-blown application server tomee.apache.org (Plus)? (it is a popular FAQ). In this screencast I launched Tomcat, TomEE WebProfile and TomEE Plus and measured the total footprint (docker image + Java + server):

All images used in this screencast are available from: docklands.

Note: a 16 GB Server ECC RAM is currently available for 100 USD

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.


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

JavaScript Fatique and Java EE -- An Interview At JAX 2016

@gabriela_motroc asked me some interesting questions at the the JAX conference in Frankfurt after my talk "Java EE 7 and Java 8 -- Feedback From Projects":

Still interested in JavaScript? :-) See you at JavaScript Bootstrap in MUC. Otherwise attend Java EE 7 Boostrap, or enjoy Java EE from home: airhacks.io.


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

Converting Exceptions Into HTTP Status Codes

An exception thrown in an "exceptional" resource:


@Path("exceptions")
public class ExceptionalResource {

    @GET
    public String dontCallMe() {
        throw new IllegalStateException("Do NOT call me");
    }

}


can be easily converted into a HTTP Status code using the ExceptionMapper:


import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;


@Provider
public class IllegalStateExceptionMapper 
implements ExceptionMapper<IllegalStateException> {

    @Override
    public Response toResponse(IllegalStateException exception) {
        return Response.status(Response.Status.NOT_IMPLEMENTED).
                header("reason", exception.getMessage()).
                build();
    }

}


A curl -i http://localhost:8080/jaxrs-exceptionmapper/resources/exceptions outputs:


reason: Do NOT call me
Content-Language: 
Content-Type: text/html
Date: Wed, 20 Apr 2016 08:22:00 GMT
Connection: close
Content-Length: 1119

JPA OptimisticLockExceptions can be converted with the same mechanism.

Any questions left? See you at Java EE Workshops at Munich Airport, Terminal 2, particularly at: Effective Java EE 7 or at airhacks.io!


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

Is It Your Special Jar?

A nice video about JARs:

Too many JARs? Take a look at Java EE :-)

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.


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

How To Replace Classes With Java EE--After The Fact

With Java EE you can replace all injected classes without using an interface, factory or any other creational pattern.

The class Greeter:


public class Greeter {

    public String getGreetings(){
        return "Hey duke";
    }
}


...is directly injected into the Index:


import javax.enterprise.inject.Model;
import javax.inject.Inject;

public class Index {
    
    @Inject
    Greeter greeter;
    
    
    public String getMessage() {
        return content;
    }

}


PoliteGreeter replaces the Greeter using inheritance and applying the annotation @Specializes


import javax.enterprise.inject.Specializes;

@Specializes
public class PoliteGreeter extends Greeter{

    @Override
    public String getGreetings() {
        return "Dear " + super.getGreetings();
    }
}


The @Specializes mechanism is used to provide custom behavior / configuration for the porcupine and breakr utils. This post is motivated by the following porcupine issue.

Any questions left? See you at Java EE Workshops at Munich Airport, Terminal 2 and particularly at Bootstrap Java EE 7 or airhacks.io.

[See also an in-depth discussion in the "Real World Java EE Patterns--Rethinking Best Practices" book (Second Iteration, "Green Book"), page 235 in, chapter "Plugins"]. Sample is based on the template flavor of the plugin pattern.


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

New Docker Images For Java EE

github.com/AdamBien/docklands comes with Dockerfiles for the following servers:

  • WebLogic
  • WebSphere
  • TomEE
  • Payara Server
  • WildFly
  • nano (JDK HTTP server as reference)
  • Tomcat
  • DerbyDB
  • PostgreSQL

Docklands is used during the javaeemicro.services online workshop, sometimes during the airhacks.

I also used Docklands to measure the application server's overhead in the following screencasts: Memory Footprint Of Java EE Servers and Java EE 7 Application Servers vs. Plain "Hello World" screencasts.


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

PHP, Java EE Structure, Concurrency, Long Running Tasks, Microservices, IDEs, Correlation, Angular 2 or 2 Years of airhacks.tv

The 2 years of airhacks.tv show. In 1h and 10 minutes about 30 questions were discussed (hopefully answered) during this show:

Any questions left? Ask now: https://gist.github.com/ and join the conversation at each first Monday of the month at 6 P.M. live. No registration or any other commitment required.

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.


Java EE 7 Workshops: Bootstrap, Effective, Architectures, June, 13th-15th, Munich's Airport
On demand workshops: Java EE 7 Bootstrap, Effective Java EE 7, Java EE 7 Testing and NEW: Java EE 7 Microservices are available for streaming

Newsletter: airhacksnews.com

A book about rethinking Java EE Patterns

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