Česky   |  Deutsch   |  English   |  Español   |  Français   |  Indonesia   |  日本語   |  한글   |  Polski   |  Português (BR)   |  Türkçe   |  中文   |  正體中文   |  Your Language  
PlanetNetbeans
Planet NetBeans is an aggregation of NetBeans related musings from all over the Blogosphere.
DukeScript - June 19, 2018 10:17 PM
Kotlin (and MVVM) Everywhere!

We Love Kotlin and JVM!

Our January post about the importance of proper MVVM for Kotlin explained why the Kotlin language is important.

Now it is time to stress the cross-platform nature of the sample project. With kt-mvvm-demo you write your application once and deploy it to desktop, Android, iOS and browser with the help of portable DukeScript presenters.

Android

The sample project comes with classical Android Gradle installDebug task to package your application as an Android .apk file and deploy it to your device or simulator:

$ ANDROID_HOME=/android-sdk/ ./gradlew installDebug
$ ls app/build/outputs/apk/
app-debug.apk

Kt-Mvvm-Demo on Android

iOS

One can package the same code as an iOS .ipa file with the help of Intel’s Multi OS Engine when running on Mac OS X. First of all list your simulators and then use one of them to launch your application:

$ ./gradlew moeListSimulators
...
- DD9904B6-76CD-4F2D-9153-EC7182878897 - iOS 11.4 - iPhone X
...
$ ./gradlew moeLaunch -Pmoe.launcher.simulators=DD9904B6-76CD-4F2D-9153-EC7182878897

Kt-Mvvm-Demo on iOS

Browser

The same application can also be transpiled to JavaScript and executed in the browser. The bck2brwsrShow tasks generates necessary .js files and launches a browser with the application

$ ./gradlew bck2brwsrShow
...
Showing http://localhost:53241/index.html
...
$ ls -l web/build/web/
bck2brwsr.js
index.css
index.html
lib
main.js

The files in web/build/web directory contain everything needed to execute your application and as such they can be deployed to any HTTP server as a static content. Read more.

Kt-Mvvm-Demo in the browser

With Kotlin MVVM API you can write your code once, deploy and display it everywhere (desktop - gradlew run, Android - gradlew installDebug, iOS - gradlew moeLaunch, browser - gradlew bck2brwsrShow) while using the power of Kotlin, its libraries and any other JVM libraries on every target platform.

The JVM Portability

The fact that one can execute the same Kotlin application on all the above platforms is not like the traditional Kotlin.js and Kotlin.native portability. With Kotlin.xxx one only gets the portability of the Kotlin language, but not the libraries.

With the kt-mvvm-demo project you may bring with yourself JVM libraries - e.g. JARs - from your previous life (e.g. written in Java & other JVM languages) that otherwise can’t go with you to the Kotlin js and native worlds.

We love Kotlin on the JVM!

Adam Bien - June 15, 2018 05:41 AM
Private Fields Serialization with JSON-B and JAX-RS 2.1 / Java EE 8

JSON-B from Java EE 8 serializes public fields or properties as default. For private field serialization:


public class Workshop {

    private String name;
    private int duration;

    public Workshop(String name, int duration) {
        this.name = name;
        this.duration = duration;
    }

}    

you will have to implement a PropertyVisibilityStrategy (checkout Java EE 8: Serializing POJOs with JSON-B):


    public class PrivateVisibilityStrategy implements PropertyVisibilityStrategy {
    
        @Override
        public boolean isVisible(Field field) {
            return true;
        }
    
        @Override
        public boolean isVisible(Method method) {
            return false;
        }
    
    }

...pass your custom configuration to the JsonbBuilder and return the instance with a ContextResolver:


    import javax.json.bind.Jsonb;
    import javax.json.bind.JsonbBuilder;
    import javax.json.bind.JsonbConfig;
    import javax.ws.rs.ext.ContextResolver;
    import javax.ws.rs.ext.Provider;
    
    @Provider
    public class JSONConfigurator implements ContextResolver {
    
        @Override
        public Jsonb getContext(Class type) {
            JsonbConfig config = new JsonbConfig().
                    withPropertyVisibilityStrategy(new PrivateVisibilityStrategy());
            return JsonbBuilder.newBuilder().
                    withConfig(config).
                    build();
        }
    }

Now your POJO's private fields are going to be used for JSON-mapping:


@Path("workshops")
public class WorkshopsResource {

    @GET
    public Workshop workshop() {
        return new Workshop("Java EE 8", 42);
    }

}

Result: {"duration":42,"name":"Java EE 8"}

Tested with Payara 5.

See you at Java EE Workshops at MUC Airport, particularly at the Effective Java EE 8 workshop


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 12, 2018 03:04 PM
Consuming MicroProfile Metrics with Prometheus

In this (free) screencast I created a MicroProfile project with microprofile-essentials-archetype and exposed method runtime statistics and configured prometheus.io (from docklands) to consume the metrics directly:

Also checkout Exposing Business Metrics with MicroProfile.

See you at Java EE Microservices. Is Munich's airport too far? Learn from home: javaeemicro.services.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 07, 2018 09:40 AM
From Versioning, Automation and CI to File Upload, MVC, Scopes and Centralized Logging -- 51st airhacks.tv

"Versioning, tagging, branching, automation, CI/CD, autodeployment in production, JAX-RS and file upload, MVC 1.0 vs. servlets and JSPs, Primefaces as module, @Singleton vs. @ApplicationScoped vs. @RequestScoped and JAX-RS, centralized logging, logging vs. metrics and the future of webassembly":

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

Audio-only version is also available from: airhacks.fm podcast via: RSS iTunes

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.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 06, 2018 06:53 AM
Exposing Business Metrics with MicroProfile 1.3

In this (free) screencast I created a MicroProfile project with microprofile-essentials-archetype and exposed method runtime statistics as well as "business" metrics.

See you at Java EE Microservices. Is Munich's airport too far? Learn from home: javaeemicro.services.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 05, 2018 05:42 AM
Building Java EE 8 Applications For Fun -- Interview With LottoRitter

Ulrich, please introduce yourself

I am a passionated software architect and developer with more than 17 years of experiences in different industries and in implementation of mission critical software, that is reliable, performant and highly available.
Currently, I change from employed to self-employed as Java Freelancer and start the first project in June.
You can find me on my Personal website, XING, LinkedIn and GitHub.

I developed the project http://www.lottoritter.de with Christopher Schmidt. He is born in Hamburg/Germany and he is very fascinated by software development. He started with PHP/HTML/CSS in his early years, but later on he focused on JavaSE and JavaEE. He has many years of experience in software development, especially in Java projects.
Christoper can be found on XING, Twitter and GitHub.

What are you building with Java EE?

Christopher and me were building an OpenSource-JavaEE 8 project http://www.lottoritter.de. On this platform, you can "play German Lotto" for fun. You don't spend any money (and unfortunately you cannot win any money :-)). You register via eMail or OAuth (Google, Facebook, Instagram) and then you can 'buy' tickets with a dummy credit card for Lotto 6aus49, EuroJackpot, Gl&uumlcksSpirale and Keno. The drawings of the lottery are fetched via background processes.
You can found the source code here: https://github.com/Lottoritter/lottoritter-platform/

Why you started the project?

We started the project to prove, that you can build cool projects with JavaEE. For the frontend, we use JSF and JavaScript for the ticket-engine. We were developing for 4 month in spare time for the complete platform. So everyone can see, that JavaEE is highly productive. And it was a lot of fun, because we could focus mainly on the business features. Infrastructure like Application Server (we use Payara) and Database (MongoDB Atlas) just works and don't need much administration. The productive environment runs on a small private server in a docker container.

Can you share with us some geeky numbers like e.g. TX per seconds, heap sizes, thinnest WARs etc -- whatever Java EE devs might find interesting.

We did not make marketing, because this has more of a fun project without any profit thinking (we do not have any advertising or web-trackers or whatever). The project is straightforward, so we have no "Microservice"-architecture, but a simple WAR for deploying on the application server. That's it. So we don't have high load or many concurrent transaction with which we can 'boast' about.
For us, it was more interesting to share the code, so that others can reference to it and see, how easy it is to structure the code (thanks to your BCE-package pattern ;-)) and get a project up and running.

How big is your WAR?

It is 26MB all inclusive (Java, additional libraries, HTML, images and so on). But 80% of the size are consumed by third-party-libraries such as OAuth, Primefaces, Database-Driver and their transitive dependencies. The size of the written Java code is around 1 MB (15k real lines of code).

Are you happy with Java EE so far? Is Java EE productive?

Yes, I am extremely happy. The "component" model with EJB and CDI in combination with the Boundary-Control-Entity (BCE) package structure let you write clear business code. Ok, there are framework-classes like a Webfilter and the identity stores for the Java security API (Soteria) and something else like that, but 90% of the code is business related. So it is really productive. As I said before, we implemented this within 4 month in spare time.
Furthermore, it es very easy to introduce CI and to integrate everything to Amazon AWS Elastic Container Service or other platforms.
Perhaps JavaEE is not fancy, but the most business cases in general don't need fancy things. The goal is "make the project run". And it is not a good idea to make things unnecessary complicated. Java and the JavaEE APIs provide you with 90% of what you need to build the features of any general project. I like the smooth integration of the JavaEE-APIs, which is even better in Java EE 8 (see Soteria which is an incredible step forward in making Java security much easier to implement).

Which application servers, tools or IDEs are you using?

I use IntelliJ IDEA for sure ;-). The application runs on Payara 5, because it 'extends' from Glassfish, which is the reference implementation of JavaEE, but Payara is updated frequently and so, it has always the current working versions of the JavaEE-API implementation libraries.
MongoDB as database, because the document centric approach fits much better to the domain-driven-design/model and it makes implementation much simpler. In addition with MongoDB-Morphia as object-document-mapper, it is so easy to write clean code.
It is a standard Maven project, so the project can be build with the 'build pipeline' like mvn clean install && docker build ... && docker run ....

You are using the Boundary Control Entity pattern to structure your applications. What were your experiences, challenges and findings so far?

Yes, I heard of this pattern for the first time in one of your screencasts about 5 years ago. It was so stupid simple, and that's why I really like this pattern. I can structure the code for business aspects, so it is easy to get along with the code. Furthermore, you can design your code exactly like the real world. Lottoritter for example has tickets, shoppingcart, drawings, players and so on, and these business entities are exactly modelled/structured in the code and you find exactly these named packages
The only 'challenge' is, where to put classes with cross-cutting functionality. But with a bit of clear thinking, you always find a proper solution (in my opinion ;-)).

How important are standards for you? Does your application depend on application server specific APIs?

Standards are extremely important for me. They are clearly defined and you can trust on them. It is well documented, you can read the official specification-documents and the documentation for the corresponding implementation. I don't like surprises in software-projects and I want to be sure, that 'technical' things work as described. So standards let me sleep a bit better ;-).
There are no dependencies on application specific APIs. So, as soon as other application servers fully support JavaEE 8 in the future, then this project could be run on other servers as well without changes.
I don't want to waste time dealing with technical problems, but I want to implement valuable business features, for customers and as well as for my personal projects.

Did you had the chance to chat with other attendees during the airhacks.com? If yes, what was the most interesting project / problem / situation in the workshops?

I attended the JavaEE Bootstrap and Effective JavaEE days in March 2013. These two days were really cool. It was interesting to listen to others, who have the same problems at work. Mainly, the acceptance for JavaEE was a main topic. Most managers/decision makers have the J2EE-patterns in mind, with local- and remote-interfaces and all the XML-stuff. But these days are over for years. It is interesting, that even in 2018 (for example, if you talk to Spring developers), they also think of JavaEE as how it was to the J2EE epoch. Many people don't know, that JavaEE has evolved to a real lightweight enterprise application platform.

Which Java EE APIs are you using in your products?

EJB (@Stateless) and CDI are the JavaEE APIs, which I cannot miss. They are the building blocks of the whole application. You recorded a Youtube-Video some years ago about the metrics, which are exposed by every application server since years. So I get these information for free when using EJBs.
In addition, I use JAXB (for JSON to JavaObject conversion between backend and the Javascript-Ticket-engine), JAX-RS for sure ;-), Java Security API (Soteria), which is so smart and useful now (in earlier days, Java Application server security was always very difficult and proprietary to setup).

Ulrich, thank you for the interview!


Real World Java EE Workshops [Airport Munich]>

Adam Bien - June 04, 2018 07:57 AM
Versioning, Tagging, Automation, CI, Logging, MVC 1.0, or 51st airhacks.tv

Topics and questions: https://gist.github.com/AdamBien/dc00f6b83c2430c91533486e72fb4d54 for the 51st airhacks.tv

  • Versioning (internal, production, etc.)
  • Tagging automation
  • To branch or not to branch
  • Using autodeploy for production?
  • Uploading a file with JAX-RS
  • MVC 1.0 thoughts
  • Primefaces as WildFly module or WildFly swarm
  • @Singleton vs. @Stateless
  • Java EE and centralized logging
  • Are separate stacks for logging and monitoring a best practce?
  • Automatically emitting metrics via JAX-RS

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

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.
Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - June 01, 2018 04:02 AM
Bck2Brwsr 0.23: Get Started via Gradle!

After few months the newest version of Bck2Brwsr VM is here. It contains:

It was quite a fun to write Gradle tasks together with Maven and build them by Maven.

Get started with README. Enjoy.

--JaroslavTulach 04:02, 1 June 2018 (UTC)

DukeScript - May 30, 2018 11:51 AM
New High Quality Presenter for Swing and JavaFX

Run your DukeScript application in our new “JXBrowser Presenter” for optimal performance and the latest HTML5 features including WebGL. The evaluation version is now available from our Maven Repository. For details on installing and using the JXBrowser Presenter please check our documentation.

When you build a new DukeScript application, the default presenter for Desktop applications is based on the JavaFX WebView. This presenter is nice for debugging and visual design, but it lacks a lot of modern HTML & CSS features. For example it doesn’t support WebGL or input type=”date”.

For that reason, we’ve supported Webkit and Browser based solutions on different platforms. But this solution doesn’t work for everyone, as the components depend on the OS platform, and they aren’t embeddable in Swing or JavaFX applications, something a lot of our customers rely one.

Now we’ve developed a new presenter that we’ve been using in customer projects for some time. This presenter is based on a current version of Chromium and supports all its latest and greatest features. For the Chromium Integration we’re using the commercial JXBrowser Component, hence the name “JXBrowser Presenter”. It has much better performance than the JavaFX WebView, but is still embeddable in Swing and JavaFX applications.

Checkout the documentation and test our latest and greatest presenter.

Adam Bien - May 26, 2018 05:21 AM
WildFly and JBoss -- A Conversation with Jason Greene, Chief Architect, JBoss EAP

A conversation with Jason Greene @jtgreene about HotJava on Sparc, increasing productivity, Tomcat, OrionServer, JBoss, Jigsaw W3C's Server, JavaServer Web Development Kit, flat network assumptions, SOAP and XML vs. IIOP, grpc, thrift, DTO bloat, Infinispan, Marc Fleury, POJO Cache, JBoss Cache, caching and concurrency, clustering, JBoss/WildFly clustering under the hood, using Infinispan as JMS provider, WildFly 13 provisioning infrastructure, WildFly as a platform, pruning CORBA, the danger of profiles, dying SOAP, WildFly 12 and Java EE 8, Hibernate 6 query optimization, quarterly WildFly releases, EAP release cadence, community enterprise and supported WildFly, EAP for developers, Java EE productivity and the declarative model, Java EE concurrency model, WildFly's killer features, undertow and wildfly.

Subscribe to airhacks.fm podcast via: RSS iTunes

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.
Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - May 22, 2018 07:50 AM
Git on Steroids: Fire Your Integration Guy!

Stefan asked who shall be responsible for integration in the MultiGitRepository setup? Should there be an integration guy? No, its 21st century and we know how to use Git, right? The right tool is called pull request!

As such fire your integration guy!

--JaroslavTulach 07:50, 22 May 2018 (UTC)

NetBeans – Praxis LIVE - May 16, 2018 12:09 PM
Moving 4-ward

The first full release of PraxisLIVE v4 happened earlier this week, and while you might immediately notice some UI improvements (bezier curves in the graph editor caused some excitement!), the primary focus of this release is on the restructuring and … Continue reading

Adam Bien - May 16, 2018 08:44 AM
Simplistic Router With WebStandards

In this screencast I'm using the standard onhashchange event listener to replace a section with content loaded from an external file. It is a simplistic router:

This screencast is bonus material from: webstandards.training. You might also like: webcomponents.training.

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.
Real World Java EE Workshops [Airport Munich]>

Adam Bien - May 15, 2018 06:57 AM
From Jakarta EE Profiles over Exception Handling To Swing Migrations -- 50th airhacks.tv

"Jakarta EE Profiles and News, Exception Handling, TransactionSynchronizationRegistry, UUID progation and XA, equals, hashcode and JPA, remote CDI, websockets testing, Code Coverage, Swing Migration and Thin WARs with Hibernate" or 50th airhacks.tv is available:

Any questions left? Ask now: https://gist.github.com/AdamBien/dc00f6b83c2430c91533486e72fb4d54 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.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - May 11, 2018 10:36 AM
Simplest Possible MicroProfile Maven Kickstarter

Execution of the microprofile-essentials-archetype (see also Simplest Possible Java EE 8 Kickstarter):

mvn archetype:generate -DarchetypeGroupId=com.airhacks -DarchetypeArtifactId=microprofile-essentials-archetype -DarchetypeVersion=0.0.1 -DgroupId=com.airhacks -DartifactId=[YOUR_PROJECT_NAME] -Dversion=0.0.1 -Darchetype.interactive=false --batch-mode

creates a ready to use 3.5kB Thin WAR project with configured JAX-RS runtime, a resource with a GET endpoint ("/ping"), 25 lines of pom.xml with a single microprofile dependency:

 <dependency>
    <groupId>org.eclipse.microprofile</groupId>
    <artifactId>microprofile</artifactId>
    <version>1.3</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>
and a shell script which executes the the maven and Docker build and starts the image. The build-and-run cycle takes about ...5 seconds.

Payara 5 Full server is not only Java EE 8 compliant, it also comes with MicroProfile 1.2 APIs -- so you don't have to use any esoteric runtimes.

Payara 5 Dockerfile is also available from: docklands. The Maven Archetype is available in: https://github.com/AdamBien/microprofile-essentials-archetype.

See you at Java EE Microservices. Is Munich's airport too far? Learn from home: javaeemicro.services.
Real World Java EE Workshops [Airport Munich]>

Adam Bien - May 07, 2018 10:49 AM
Jakarta EE Profiles and News, Exception Handling, UUID progation, equals, hashcode and JPA, remote CDI, websockets testing, or 50th airhacks.tv

Topics and questions (https://gist.github.com/AdamBien/e96e52400c5582f86d5f4962a68470ac)

for the 50th airhacks.tv.
  1. Swing Migrations Workshop
  2. Jakarta EE News
  3. Exception handling strategies
  4. Transparent and remote UUI propagation
  5. Thin WARs and 3rd party JPA
  6. Equals and hashCode in JPA entities
  7. Remote CDI events
  8. WebSockets testing
  9. Jakarta EE's future
  10. Combining Primefaces with JAX-RS
  11. When Numbers Are More Important Than Quality

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

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.
Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - May 04, 2018 10:54 AM
Git on Steroids: Local Collaboration Area

Turns out that one gets very useful MultiGitRepository#Appendix_A:_Local_Collaboration_Area: the master branch in each slave repository of the MultiGitRepository setup is in fact the best place for team members to collaborate without publishing the changes to the final integration destination.

--JaroslavTulach 10:54, 4 May 2018 (UTC)

Adam Bien - May 03, 2018 05:26 AM
Live-Coding No-Ceremony Microservices with Thin WARs

In this screencast I implemented Thin WAR microservices, let them communicate and implemented microservice patterns from scratch. I started with Java EE full profile and ended with microprofile. No tricks, no frameworks, no magic:

See you at Java EE Microservices. Is Munich's airport too far? Learn from home: javaeemicro.services.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - April 27, 2018 03:09 PM
Java EE 8 / JSON-P 1.1: Convenient JsonArray to POJO conversion

With the JSON-P 1.1 / Java EE 8 method: getValueAs a JsonArray instance can be directly converted into a POJO-List. The POJO's constructor:


import javax.json.JsonObject;

public class Developer {

    private String name;
    private String language;

    public Developer(JsonObject input) {
        this.name = input.getString("name", null);
        this.language = input.getString("language", null);
    }

    @Override
    public String toString() {
        return "Developer{" + "name=" + name + ", language=" + language + '}';
    }
}

...can be used as the converter function / parameter of getValueAs:


import java.util.List;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;

public class MappingArrayValuesTest {

    @Test
    public void map() {
        JsonArray developerArray = getDevelopers();
        List<Developer> developers = developerArray.getValuesAs(Developer::new);
        assertThat(developers.size(), is(2));
        System.out.println("developers = " + developers);
    }

    JsonArray getDevelopers() {
        return Json.createArrayBuilder().
                add(create("brendan", "JavaScript")).
                add(create("james", "Java")).
                build();
    }

    JsonObject create(String name, String language) {
        return Json.createObjectBuilder().
                add("name", name).
                add("language", language).
                build();
    }
}

The successful test outputs: developers = [Developer{name=brendan, language=JavaScript}, Developer{name=james, language=Java}]

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.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - April 26, 2018 06:04 AM
From Xelphi, over Nashorn To JVM Compiler Innovation with GraalVM

8th episode of airhacks.fm, or a conversation with @JaroslavTulach about the beginnings of NetBeans, xelphi, JavaDoc, Glasgow, JavaBeans for the network, LimeTree, mounting jars, deals with Jonathan Schwartz, Bck2Brws (Back To Browser), Duke Script, Multi OS Engine, JavaFX, Java to JavaScript transpiler, Typescript, Frameworks, GraalVM, Project Maxwell , Maxine VM, C2 compiler, IGV, nashorn and performance, Graal and Twitter, JEP metropolis, Graal speedup, the most complex statement, speculative interpreters, talk to your compiler, Truffle, SubstrateVM, avatar.js, node.js on JVM, Graal Installation, language interop is available.

Subscribe to airhacks.fm podcast via: iTunes or RSS

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.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - April 25, 2018 07:30 AM
Binding WildFly To IP-Address

To bind WildFly to a particular address, launch it with the -b flag: ${WILDFLY_HOME}/bin/standalone.sh -b=0.0.0.0 (see e.g. Docklands Wildfly image).

Alternatively you can also change the defaults in the standalone-full.xml from 127.0.0.1 to 0.0.0.0 (0.0.0.0 means: all interfaces, what is useful for development):


<interfaces>
    
    <interface name="management">
        
        <inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
    
    </interface>
    
    <interface name="public">
        
        <inet-address value="${jboss.bind.address:0.0.0.0}"/>
    
    </interface>
    
    <interface name="unsecure">
        
        <inet-address value="${jboss.bind.address.unsecure:0.0.0.0}"/>
    
    </interface>

</interfaces>    
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.
Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - April 23, 2018 03:20 PM
Git on Steroids: Master Multiple Repositories

Let me introduces MultiGitRepository - aka Git on steroids to you. I have seen a lot of confusion when it comes to working with multiple repositories and keeping them in orchestration, but I believe it is not that complex. Everything we learned about distributed version controls applies. However this time it has to be applied on a completely new level!

Master your MultiGitRepository in few easy lessons!

--JaroslavTulach 15:20, 23 April 2018 (UTC)

Adam Bien - April 19, 2018 08:33 AM
JSON-B, Groovy and Jenkins, CQRS, 40k with JSF, EJB TX or 48th airhacks.tv is available

36mins: with JSON-B and hierarchical mapping, Groovy and Jenkins pipelines, CQRS, 40k with (deprecated) JSF, EJB TX, JSON-B, Java EE migrations and I'm performing live a code review / refactoring.

Also checkout past episodes: 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.


Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - April 19, 2018 06:49 AM
Shocking: Default Listener Methods ain't Dangerous!

Using Default Listener Methods is perfectly fine! Those who remember my recent arguments against using DefaultMethods in APIs maybe the surprised by this statement, but it has to be made. Looks like using Default Listener Methods doesn't violate any practices of good API Design.

Thanks Dušane, for pointing that out!

--JaroslavTulach 06:49, 19 April 2018 (UTC)

Adam Bien - April 11, 2018 07:26 AM
Local-Variable Type Inference Java 10 Example

Java 9 legacy code:


@Test
public void java9Legacy() {
    Map<String, String> devs = new HashMap();
    devs.put("duke", "java8");
    for (Map.Entry<String, String> dev : devs.entrySet()) {
        System.out.println(dev.getKey() + " " + dev.getValue());
    }
}

...can be streamlined with Java 10 and Local-Variable Type Inference (JEP-286):


import java.util.HashMap;
import java.util.Map;
import org.junit.Test;

public class VariableTypeInferenceTest {

    @Test
    public void inferTypeWithJava10() {
        var modernDevs = new HashMap<String, String>();
        modernDevs.put("duke", "java10");
        for (var dev : modernDevs.entrySet()) {
            System.out.println(dev.getKey() + " " + dev.getValue());
        }
    }
}

The code above runs on openJDK 10 GA JDK 10, was edited with Apache Netbeans 9 and built with Maven 3.5.0


        <project>
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.airhacks</groupId>
        <artifactId>variable-type-inference</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>10</maven.compiler.source>
            <maven.compiler.target>10</maven.compiler.target>
        </properties>
    </project>    

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.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - April 10, 2018 09:22 AM
Simplest Possible Microprofile Liveness Check

A health check can be exposed using the org.eclipse.microprofile.health.Health qualifier exposing a HealthCheckResponse:


import javax.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.health.Health;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;    
@Health
@ApplicationScoped
public class LivenessCheck implements HealthCheck {

    @Override
    public HealthCheckResponse call() {
        return HealthCheckResponse.
                named("ping").
                up().
                withData("duke", "lives").
                build();
    }

}

The health check is available from the "root" URL (not the WAR URI):

curl http://localhost:8080/health outputs:

{"outcome":"UP","checks":[{"name":"ping","state":"UP","data":{"duke":"lives"}}]}

The API is included in the microprofile BOM:


 <project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.airhacks</groupId>
<artifactId>microprofile</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<dependencies>
   <dependency>
       <groupId>org.eclipse.microprofile</groupId>
       <artifactId>microprofile</artifactId>
       <version>1.2</version>
       <type>pom</type>
       <scope>provided</scope>
   </dependency>
</dependencies>
<build>
   <finalName>microprofile</finalName>
</build>
<properties>
   <maven.compiler.source>1.8</maven.compiler.source>
   <maven.compiler.target>1.8</maven.compiler.target>
   <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>    

The above example comes with 4.2 kB WAR and runs on stock Payara Server 5. Payara 5 comes with Java EE 8 and microprofile 1.2 support.

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.


Real World Java EE Workshops [Airport Munich]>

Adam Bien - April 09, 2018 05:01 AM
Swing without WebStart, No Sessions, Performance Testing and JWT, JPA Query Result Caching, SAML, JavaScript Data Binding, Asynchronous Java EE or 49th airhacks.tv

Topics and questions (https://gist.github.com/AdamBien/d2bdc699f8f39948ff04126f3d09227d) for the 49th http://airhacks.tv.

  1. Swing without WebStart
  2. Preventing Web Sessions
  3. Performance Testing with JWT
  4. JPA query result caching
  5. SAML Java Frameworks
  6. JavaScript databinding with WebSockets
  7. Asynchronous Java EE
  8. Using embedded container testing with container resources blog comment
  9. When Numbers Are More Important Than Quality

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

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.


Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - April 06, 2018 10:27 AM
Where's your Frontend? On a desktop!?

What does term Frontend mean to you? Tell us!

--JaroslavTulach 10:27, 6 April 2018 (UTC)

APIDesign - Blogs - April 04, 2018 02:16 PM
Don't rely on Jenkins and co. They hurt your API design skills!

Recently I observed an incompatible API change and I received following explanation: Everything is OK, my ContinuousIntegration server is still green! In a shock I decided to write a philippic against ContinuousIntegration.

If you have to fix your tests in a significant way after making a change to your API, then you should think twice. Maybe such change isn't really compatible enough to become smoothly part of your framework. There is probably a lot of code similar to your tests out there and there is nobody to fix them as part of your refactoring. Better to learn and invest in keeping a bit of BackwardCompatibility.

In some sense: When designing APIs, relying only on ContinuousIntegration is bad!

--JaroslavTulach 14:16, 4 April 2018 (UTC)

DukeScript - April 04, 2018 11:51 AM
Welcome Info Footer in Archetypes Version 0.23

A very inspiring discussion about usability of DukeScript has happened on the development Apache NetBeans mailing list. As a result of the comments collected there, here comes an attempt to improve the first contact experience when somebody tries the archetypes or the IDE wizard out of curiosity without knowing anything about the APIs.

When the freshly created application starts, it now contains a footer with links to documentation, blogs, etc.

Removing the footer is a matter of deleting one script tag in the index.html file:

<!-- Remove this line to remove the button bar in the footer -->
<script async=true src="http://dukescript.com/presenters/welcome.js"></script>

The change can be tried out immediately as necessary updates to the archetypes are already hosted on the Apache Maven Central. Just try:

$ mvn archetype:generate \
	-DarchetypeGroupId=com.dukescript.archetype \
	-DarchetypeArtifactId=knockout4j-archetype \
	-DarchetypeVersion=0.23 \
        -DgroupId=your.company -DartifactId=test -Dversion=1.0-SNAPSHOT
$ cd test
$ mvn install
$ mvn -f client/pom.xml exec:exec

And you shall see the links! Is it now easier to get started with DukeScript?