Č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.
Feeds
[RSS 1.0 Feed] [RSS 2.0 Feed]
[FOAF Subscriptions] [OPML Subscriptions]
Do you blog about NetBeans ? Add your blog to PlanetNetBeans.
Feed Subscriptions
APIDesign - Blogs (feed)
David R. Heffelfinger (feed)
Carsten Zerbst's Weblog (feed)
Winston Prakash's Weblog (feed)
NetBeans – Michael's blog (feed)
ProNetBeans (feed)
Paulo Canedo » NetBeans English (feed)
NetBeans – NetBeans Ruminations (feed)
Anchialas' Java Blog (feed)
Need to find a title (feed)
Category: NetBeans | Software and Science (feed)
Roger Searjeant's blog (feed)
Adam Bien (feed)
Inspiration and Expression » Netbeans (feed)
DukeScript (feed)
NetBeans – Enrico Scantamburlo (feed)
Bernhard's Weblog (feed)
Michel Graciano's Weblog (feed)
Ramon.Ramos (feed)
Ozone and Programming » netbeans (feed)
netbeans – markiewb's blog (feed)
Arun Gupta, Miles to go ... (feed)
Geertjan's Blog (feed)
.JARa's Bilingual Weblog (feed)
JavaFX Composer (feed)
The Java Jungle (feed)
Jesse Glick (feed)
Martin Grebac (feed)
The NetBeans Community Podcast (feed)
NetBeans Profiler (feed)
NetBeans for PHP (feed)
NetBeans Web Client (feed)
Rechtacek's (feed)
Virtual Steve (feed)
The Aquarium (feed)
Tinuola Awopetu (feed)
Insert Witty Irony Here (feed)
Netbeans – Gualtiero Testa (feed)
netbeans – James Selvakumar’s Blog (feed)
NetBeans – nB gUru (feed)
netbeans – Newsintegrator Blog (feed)
NetBeans – Praxis LIVE (feed)
NetBeans – TechAshram (feed)
Netbeans – There's no place like 127.0.0.1 (feed)
Anuradha (feed)
Netbeans6/6.5 my best practices (feed)
Java Evangelist John Yeary (feed)
Neil's Dev Stuff (feed)
Computer says null; (feed)
NetBeans Adventures, Java and more (feed)
NetBeans – John O'Conner (feed)
NetBeans Community Docs Blog (feed)
The Netbeans Experience (feed)
NbPython/ jpydbg / pymvs (feed)
Shanbag's Blog (ರಜತ ಲೋಕ) (feed)
Wade Chandler's Programming Blog (feed)
Devlin's Lab (feed)
Big Al's Blog (feed)
Code Snakes (feed)
In perfect (spherical) shape (feed)
Van Couvering Is Not a Verb (feed)
Diego Torres Milano's blog (feed)
Vroom Framework (feed)
Messages from mrhaki (feed)
Jeff's Blog (feed)
Manikantan's Netbeans (feed)
Oliver Wahlen's Blog (feed)
Shuttle between Galaxies (feed)
Welcome to my live... (feed)
Devel Blog (feed)
diamond-powder (feed)
Antonio's blog (feed)
Where's my Blog?!

Powered by:    Planet

Last updated:
March 28, 2017 12:05 AM
All times are UTC

Sponsored by
sponsored by Oracle

visit NetBeans website
Adam Bien - March 27, 2017 03:49 AM
firehose v0.0.1 released --the prometheus gateway for Java EE (micro) service monitoring

firehose v0.0.1 (ignition) the MIT-licensed, "prometheus metrics gateway" is available as docker image, Thin WAR.

firehose connects to (micro) services (Thin WARs), gathers monitoring data and provides it in prometheus-compliant format. Lacking metadata can be provided via environment variables at docker start or via HTTP / JSON at runtime. New endpoints can be re-configured on-the-fly. One firehose instance can handle multiple endpoints. Firehose is a 16 kB Java EE 7, zero dependency, Thin WAR.

Firehose and prometheus are going to be covered in Java EE Microservices / javaeemicro.services and Java EE Monitoring, Performance and Troubleshooting workshops.
Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - March 26, 2017 08:41 PM
Running NetBeans IDE 9 Development Build on JDK 9 EA Build 162

For the adventurous, interesting times ahead since you're able to try out the NetBeans IDE 9 development build on top of JDK 9 EA, in my case, Build 162.

When you configure that in your 'etc/netbeans.conf' file, the first thing you see on start up is this error, which appears to be related to the Darcula plugin that I'm using. Of course, since it's awesome despite this aspect for the moment, I'm using the Darcula plugin, which you can download and install from here, i.e., simply use the latest release of the plugin for 8.2, works fine in 9 development builds, except for this error.

After seeing the above, simply click Cancel, and, so far, despite the above, things are pretty good!

There are two big advantages to running the NetBeans IDE 9 Development Build on top of JDK 9.

The first is that the fonts are automatically a lot better, at least, on Windows and, at the very least, on my system (click to enlarge the below, where you see NetBeans IDE 9 Development Build on JDK 9 on the left versus on JDK 8 Update 121 on the right):

The second advantage is that you automatically have JShell integration (choose Tools | Open Java Platform Shell), as shown below. Excellent enhancement here is that, since the last time I used it, there's now a code fold for the text at the top of the JShell.

Until further notice, this is the environment I'll be using. 

Geertjan's Blog - March 24, 2017 04:43 PM
New: JDK 9 Jigsaw Modular Projects in NetBeans IDE

The NetBeans IDE 9 development builds now enable you to create Java Modular Projects, i.e., Jigsaw projects that can contain multiple Jigsaw modules, which can be compiled together as a unit:



They're visualized as follows, for example, in this case, for the Jigsawified Anagram Game (discussed here):

Details: 

Adam Bien - March 22, 2017 07:53 AM
polymer 2.0 with browsersync: a minimal installation / hot reloading

For a minimal polymer (2.0) with browsersync (hot reloading) installation perform the following steps:

  1. Install www.npmjs.com
  2. Install bower.io with: sudo npm install -g bower
  3. Install browsersync.io with: sudo npm install -g browser-sync

Create bower.json with minimal dependencies:


{
  "name": "(...)",
  "main": "(...).html",
  "dependencies": {
    "polymer": "Polymer/polymer#^2.0.0-rc.2"
  },
  "devDependencies": {
    "webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0-rc.5"
  },
  "resolutions": {
    "polymer": "^2.0.0-rc.2"
  }
}
    

Execute: bower install

Maintain your code in src folder

Launch browsersync with with: browser-sync start --server src -f "**/*" --serveStatic ./bower_components -b "google chrome" --no-notify

Browsersync will open chrome, serve static files (polymer libs) from bower_components folder and watch src folder. Any changes are going to be automatically pushed to the browser without reloading. Skip the bower_components folder in all imports:

	
<link rel="import" href="polymer/polymer-element.html">
(...)
<script src="webcomponentsjs/webcomponents-lite.js"></script>
	
    

Also see sample project: github.com/AdamBien/polymer-essential

Interested in lean apps? See you at Java EE Workshops at Munich Airport, Terminal 2 and particularly at Building HTML 5 Applications with WebStandards only
Real World Java EE Workshops [Airport Munich]>

DukeScript - March 20, 2017 08:23 AM
DukeScript with Node.js backend

In one of our latest projects the customer has decided to use Node.js as a backend. So we decided to share a minimal demo how simple it is using DukeScript APIs.

You’ll need node installed and in addition the websocket module. Here’s the server, we’re using a websocket to make it a little fancier.

var ipaddress = 'localhost';
var port = 8085;

const WebSocket = require('ws');

var WebSocketServer = WebSocket.Server
  , wss = new WebSocketServer({host:ipaddress, port:port});

wss.broadcast = function(data) {
  wss.clients.forEach(function each(client) {
    if (client.readyState === WebSocket.OPEN) {
        console.log('send response');
      client.send(data);
    }
  });
};

wss.on('connection', function (ws) {
    ws.on('message', function (message) {
        console.log('received message ' + message);
        wss.broadcast("{message: 'message from server'}");
        setInterval(function () {
            wss.broadcast("{message: 'message "+i+" from server'}");
            i++;
        }, 5000);
    });
});

The websocket server sends a simple JSON message every 5 seconds after we connected. Don’t worry too much about the server code. This is just for demo purposes. Now we need a Java model to read the message:

@Model(className = "Data", targetId = "", instance = true, properties = {
    @Property(name = "message", type = String.class)
})
final class DataModel {
}

DukeScript has the extremely convenient @OnReceive annotation, that takes care of serializing messages to and deserializing messages from the server. So we extend our class with:

@OnReceive(url = "ws://localhost:8085", data = Data.class, method = "WebSocket")
public static void receive(Data data, Data message) {
    if (message != null) {
        ui.setMessage(message.getMessage());
    } else { // null means: connection established
        System.out.println("conection established");
    }
}

This will generate a method in our Model class with all the boilerplate code. To establish the connection you once call the method with a null argument.

private static Data ui;
static void onPageLoad() throws Exception {
    ui = new Data("Hallo");
    ui.applyBindings();
    ui.receive(null); //connect
}

After that you can call the receive method with data to send and receive messages via the websocket. The websocket can also push back messages to you. Let’s add a @Function, so we can send a message from the UI:

@Function
public static void send(Data data) {
    data.receive(data);
}

Now we only need a UI to start the connection, so we add this to our View:

<input type="text" data-bind="textInput: message">
<button data-bind="click: send">Send Message</button>

The full code to play with is available on Github.

And if you want to code the Node based server in Java as well, have a look at this project: Node4J.

That’s it. Easy, isn’t it? Have fun coding DukeScript!

Adam Bien - March 19, 2017 04:59 AM
Voxxed Days At Cern: Java EE -- As Cool As The LHC

After watching the keynote at Voxxed Day CERN I decided to add the "almost" to the title: "Java EE -- (Almost) As Cool As The LHC":

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 - March 18, 2017 10:12 AM
Yes/NO User Input in Jenkinsfile

The method input within the Jenkinsfile suspends the build and waits infinitely for the user input with configurable options.

A Yes / No dialog waits for user input and returns true / false with the following code snippet:


def doesJavaRock = input(message: 'Do you like Java?', ok: 'Yes', 
                        parameters: [booleanParam(defaultValue: true, 
                        description: 'If you like Java, just push the button',name: 'Yes?')])

echo "Java rocks?:" + doesJavaRock

See you at Java EE Workshops at MUC Airport, particularly at the Java EE CI/CD, Testing and Quality workshop
Real World Java EE Workshops [Airport Munich]>

Adam Bien - March 17, 2017 12:14 PM
JMS Redelivery, HA Singletons, Message Ordering, Test Coverage, JSON-P vs. JSON-B, UI Strategies or 36th airhacks.tv Episode Is Available

The 36th airhacks.tv, or 3 years anniversary live question and answers show with 96 live viewers and 20+ topics is available:

Past episodes are available at: airhacks.tv playlist.

Any questions left? Ask now https://gist.github.com/AdamBien/beae7dd8966a6d57b7225ba310b18abe and see you at April, 3rd, 6pm CET.

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 - March 15, 2017 05:27 AM
Advanced Injection in Jersey

I've just learned a new trick: proper way to do JerseyInjection. Maybe somebody finds it useful...

--JaroslavTulach 05:27, 15 March 2017 (UTC)

DukeScript - March 07, 2017 08:23 AM
How to display a "Loading" Indicator

When deploying a DukeScript Application to the Browser, it takes a bit until the Java libraries are loaded. During that time the HTML is already displayed.

Since the Bindings aren’t applied yet, the application will look “broken” for a few moments. Let’s take my little match 3 game as an example. Here’s what it’s supposed to look like:

And here’s how it looks before the bindings are applied:

Obviously that’s not very nice. It’s not a big issue for desktop applications where the view typically only takes a few milliseconds to load. But it’s clearly visible when you deploy it in the browser, because the Java Libraries are still loaded via the internet while the game is already displayed.

It would be much nicer if there was a splash screen while the game is loading.

Let’s fix this. Fortunately I have a nice image that I can display as a loading screen:

To show the image we add a div to the html of the page:

<div id="title" ></div>

We now make the image visible at the beginning via CSS:

#title {
    background-color: black;
    background-image: url("../assets/title.png");
    padding-top: 0;
    position: absolute;
    background-size: 100%;
    background-repeat: no-repeat;
    width: 100vh;
    height:100vh;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 0;
    z-index: 10;
}

Now the only thing left to do is to make the image vanish, when the page is loaded. We can do so via a boolean Property in our Model:

@Model(className = "Level", properties = {
    @Property(name="loading", type=boolean.class),
    //  other Properties omitted
}, targetId = "")
class LevelVM { 
    //...
}

The property will only take effect when the Application is loaded, so we can safely use it in our DIV:

<div id="title" data-bind="visible: loading"></div>

In our “onPageLoad”-method we set the property to “false” and the startup page vanishes. And now this is what users see while the application is loading:

Click here to see it in action.

That’s it. Simple isn’t it? Have fun coding DukeScript!

Adam Bien - March 07, 2017 06:10 AM
Java 8: An Endless Stream Of Random Numbers

The method Math#random is a Supplier<double> and can be used to generate an endless Stream or random numbers:


import java.util.stream.Stream;
import org.junit.Test;

public class RandomNumbersTest {

    @Test
    public void streamNumbers() {
        randomStream(10).
                limit(10).
                forEach(System.out::println);
    }


    public Stream<Long> randomStream(int range) {
        return Stream.generate(Math::random).
                map(n -> n * range).
                map(Math::round);
    }
}

The unit test above generates:

5 4 2 9 8 9 9 0 9 8

(...hopefully a different sequence on your machine :-))

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]>

DukeScript - March 06, 2017 08:23 AM
Alternative to RoboVM for iOS

A while ago RoboVM, our solution for running DukeScript applications on iPads and iPhones, was first commercialized and later abandonded. Our current workflow is based on the last Open Source version which still works fine.

In the meantime a fork of the original project exists, which is under active development. In order to use this fork, you can simply change the dependencies in your pom to this:

<dependency>
    <groupId>com.mobidevelop.robovm</groupId>
    <artifactId>robovm-cocoatouch</artifactId>
    <version>2.3.0</version>
    <type>jar</type>
</dependency>
<dependency>
    <groupId>com.mobidevelop.robovm</groupId>
    <artifactId>robovm-rt</artifactId>
    <version>2.3.0</version>
    <type>jar</type>
</dependency>

Note that we haven’t tested this heavily yet. So we’re happy to hear your feedback in case you find any issues. If we find it stable enough we’ll either switch to this fork in our archetypes, or add it as an alternative.

Have fun coding DukeScript!

NetBeans – Enrico Scantamburlo - March 05, 2017 09:33 PM
Custom Exception Reporting in a NetBeans RCP application

Recently, on the NetBeans mailing list, it was asked how to implement a custom exception reporter on an application based on the NetBeans platform. Some years ago I had to do the same thing and I want to share my experience.

I made a sample project on GitHub for reference, but the process itself is very easy.

In my sample project, I created a suite with two modules, one that generates an exception and one that registers itself as the Error Manager and handles the exceptions of the application.

I called the former module Exception Reporter and it just contains one class called MyErrorManager. To implement it quickly I just copied the original one, made it compile, replaced the old one and added the code to handle the exceptions in my own way.

The original NetBeans implementation is org.netbeans.core.NbErrorManager and it is located in o.n.core/src/org/netbeans/core/NbErrorManager.java inside the NetBeans sources, when I copied it I renamed MyErrorManager;
if you reuse it as well please keep the license in account please.

Then I added some dependencies to make it compile:

  • Lookup API: org.openide.util.lookup
  • Startup: org.netbeans.core.startup
  • Utilities API: org.openide.util.ui

The Startup module requires more attentions, I needed to access to some classes that are not public and when I tried to compile, it complained that my module is not a friend of the Startup module. To make it work I selected the Startup module, pressed Edit…, checked Implementation Version and pressed OK. This made almost compile my module compile.

Then I scrolled to about line 97 and replaced this line:

NotifyExcPanel.notify(ex);

with my custom code

EventQueue.invokeLater(() -&amp;gt; {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.t.printStackTrace(pw);
pw.flush();

String message = "Your Exception:\n" + sw.toString();
JOptionPane.showMessageDialog(null, message);
});

This just shows a popup with the Exception stack trace, but it can be customized to make something more useful like connecting to the company bug tracker or asking the user what he was doing.

Finally, I needed to remove the default NetBeans Error Manager, I could do this by setting the supersedes property to the annotation that registers the error manager.

@org.openide.util.lookup.ServiceProvider(service = java.util.logging.Handler.class, supersedes = {"org.netbeans.core.NbErrorManager"})

Now when I have an Exception my custom Exception Manager will be called.

The image was taken from here.

 

Adam Bien - March 05, 2017 03:50 PM
HA Singletons, Clouds vs. On-Prem, Messaging and Message Ordering, UI-Stack Options, Swagger, Code Coverage or 36th airhacks.tv

Questions for the 36th airhacks.tv, March 6th, exceptionally 0.5h earlier, at 5.30pm. CET:

  1. Java EE 8 News
  2. HA Singletons and Java EE
  3. JMS-redelivery in the case of a rollback or system failure
  4. Decisions for hosting Java EE projects on premise or in the cloud
  5. Messaging systems and message ordering
  6. Where to put cross-cutting classes in the Boundary-Control-Entity structure?
  7. Deploying a single WAR into separated subfolders
  8. How to deal with "useful" libraries in Thin WAR environments?
  9. Test coverage of system tests.
  10. JSON-P vs JSON-B
  11. How to separate environments in Java EE?
  12. UI-stack options in modern Java EE applications
  13. How to manage database connections with TomEE and Docker?
  14. What is @javax.inject.Singleton?
  15. Swagger integration and Jersey or: how to document REST
  16. Field validation in JavaFX and FXML
  17. Do we have to override: getClasses/getSingletons of the javax.ws.rs.core.Application class?

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]>

NetBeans – Michael's blog - March 02, 2017 10:48 PM
Using WebSockets with Java EE, part 2.2

This post is part of my short series about WebSockets with Java EE. Technical aspects of the WebSocket protocol WebSockets in a Java EE 7 application JSF 2.3 and WebSockets As I mentioned before, there are personal reasons which reduce my current time. Thus I divided part 2 into smaller sections. This is the second […]

DukeScript - February 28, 2017 08:23 AM
Better Retina Support for Canvas API

The DukeScript Canvas API is great, if you need to draw something directly in a DukeScript Application, but up until now there was one drawback. On Retina displays the output would look a little blurred. With version 0.10, we’ve fixed that problem, so now your graphics look as crisp as you’d expect it.

Here’s your before and after picture:

If you have an existing application using canvas simply change the dependency to:

<!-- https://mvnrepository.com/artifact/com.dukescript.canvas/canvas-api -->
<dependency>
    <groupId>com.dukescript.canvas</groupId>
    <artifactId>canvas-api</artifactId>
    <version>0.10</version>
</dependency>

Without further changes the application will look much better on devides with retina displays.

Have fun coding DukeScript!

NetBeans – Michael's blog - February 26, 2017 01:54 PM
Using WebSockets with Java EE, part 2.1

Before my holidays I started this short series about WebSockets and announced more articles during February. The day I started working on this matter, my godson died. So I did (and will do) other things than writing. I broke down my next article into two smaller pieces. One of them is the following writing. The […]

Geertjan's Blog - February 26, 2017 12:21 PM
Software at Delta Air Lines

A few days ago, not long after flying with Delta to Atlanta for DevNexus, and benefiting from a Delta upgrade and bathing in the luxury of Delta business class, I spent some time at Delta's Operational Control Center (OCC).

I was able to do that thanks to Graeme Ingleby, a senior developer at Delta who has been exploring the benefits of the NetBeans Platform for quite some time and has attended JavaOne over the past years, including related events such as NetBeans Day and other NetBeans social events at JavaOne.

Delta, of course, is one of the key international organizations based in Atlanta, as well as Coca Cola and CNN. The terrain of the OCC is large and diverse and includes a museum being built within a Delta plane, shown below:

I was given an inspiring tour throughout the OCC, by Ben Shermer, General Manager, Flight Control. The OCC handles absolutely everything you can think of in relation to Delta operations. Everything, absolutely everything, in relation to aircraft, crew, and passengers is managed from the OCC, a very small part of which is shown below:

For example, the OCC handles aircraft maintenance, hotel bookings for aircraft crew, emergencies such as death or illness of passengers on planes, boarding procedures, and more. Much more. Everything, in fact, all over the world, connected to anything to do with Delta is handled in the OCC in Atlanta. 

Each computer in the OCC has a light on top of it which, when switched on, indicates that the operator is on the phone. I was told during the tour that the head of the OCC is happiest when all the lights are switched off and when all the operators have their feet up on their desks while reading their newspaperssince that means that there isn't an emergency of some kind being handled.

For me, as a developer, the most interesting part of the day was seeing the application below: 

What you see above is, yes, a Java Swing application. The dominant elements are a JTable and, along the bottom, some JFreeCharts. All the data of all planes, crews, and passengers are received and monitored in this application. Someone sick on a plane? Flight delays? Snow storms? Crew hotel bookings? Current percentage of boarded passengers? Everything is displayed in one of the columns of this highly customized JTable.

The application above is named "Bridge Desktop". It is one of dozens of applications in use at the OCC. And that's precisely the problem of the OCC. The software across the OCC handles multiple different use cases and the applications have multiple different histories, coming from a variety of different organizations historically over time. Some duplicate the functionality of other software. Cut/paste and drag/drop between these applications is difficult to impossible, while multiple monitor support is an essential requirement, since as you can imagine, each operator is looking at about six different screens all at the same time.

How to integrate these different applications is the big problem of Delta. Some of the applications are Java, some C/C++, some web-based, etc. Each has different requirements and demands. Bridge Desktop, for example, has as its central component a highly customized JTable, which has taken years to develop to the point where it is now, both in terms of content and functionality. For example, multi-select across rows in tables has been built in, with a rules engine underneath it all, and features for comparing disparate data sets. There's no point in moving this application to JavaFX, since that JTable would need to be rewritten and the benefit of JavaFX in this context is severely limited, especially when weighed against the cost of the rewrite.

And a web-based solution would also not bring anything of benefit versus the cost of moving the application into the browser. One could imagine an interactive dashboard of some kind, to replace the JTable. In principle that sounds like a cool thing, while in reality that isn't a requirement for this piece of software. The operators using the JTable-based solution know how it works and understand it. The slick look and feel that a web-based dashboard would provide sounds completely valid in principle, as would purchasing an off-the-shelf solution sound like a logical thing to do. However, off-the-shelf solutions don't work in these highly customized contexts and, though attempts are always being made along those lines, they inevitably fail. Of course, there's continual pressure for a web-based solution, not from users or developers, but from managers. Not a new story at all, though interesting to see replicated again at Delta.

After discussing all these kinds of interesting challenges, I was given a tour of the flight simulators, see below: 

It was a brilliant time and I learned a lot and came out of it affirmed in several opinions I've had for many years. Of course, the NetBeans Platform is being evaluated as a mechanism for integrating the variety of software solutions throughout Delta. It's simply the right tool for the job in this context. 

Thanks again Graeme Ingleby as well as Ben Shermer for the inspiring and enthusiastic tour around the OCC.

DukeScript - February 24, 2017 08:23 AM
Storage and other Services for each Platform

Ever wanted to access the most appropriate persistent storage for browser, desktop, Android or iOS platform? Ever was in a need to access any other platform dependent service? With new version 0.17 of our Maven archetypes this task has become more than easy.

Setting the Project Up

Let’s get started. Follow the IDE based tutorial or use shell commands to create the project from a command line. In the wizard, choose Knockout for Java Example; from the command line select the knockout4j-archetype.

Make sure you include the example code. Preferably choose as much of supported platforms as possible: browser, Android, NetBeans Platform and iOS. The rest of this tutorial assumes all these platforms are enabled and used.

Structure of the Code

Now take a look at js/src/main/java/**/js/PlatformServices.java file. It contains generic methods for accessing storage:

public class PlatformServices {
    /**
     * Reads a value from a persistent storage.
     * @param key the identification for the value
     * @return the value or <code>null</code> if not found
     */
    public String getPreferences(String key) {
        return getPreferencesImpl(key);
    }

    /**
     * Puts a value into the persitent storage.
     * @param key the identification for the value
     * @param value the value to store
     */
    public void setPreferences(String key, String value) {
        setPreferencesImpl(key, value);
    }
}

and also their default (which in DukeScript means ready for standalone HTML browser) implementation:

@JavaScriptBody(args = { "key" }, body =
    "if (!window.localStorage) return null;\n" +
    "return window.localStorage.getItem(key);\n"
)
private static native String getPreferencesImpl(String key);

@JavaScriptBody(args = { "key", "value" }, body =
    "if (!window.localStorage) return;\n" +
    "window.localStorage.setItem(key, value);\n"
)
private static native void setPreferencesImpl(String key, String value);

The default implementation uses browser’s localStorage object via our interface with JavaScript - the @JavaScriptBody annotation (more about that annotation in HTML/Java documentation),

Using the Services Class

Let’s now explore the way to use this PlatformServices class. Take a look at your client/src/main/java/**/DataModel.java - the model class defining the UI model of your application. It’s header looks like:

@Model(className = "Data", targetId="", instance=true, properties = {
    @Property(name = "message", type = String.class),
    @Property(name = "rotating", type = boolean.class)
})
final class DataModel {
    private PlatformServices services;
    // ...
}

As you can see, the model of your UI has a reference to implementation of PlatformServices which is injected to it when starting the application and constructing the model. Various methods of the DataModel class are using this services field to read and store data into the persistent storage. A form of dependency injection. Now we just need to inject the most appropriate implementation of the services for each supported platform.

Desktop Services

There is a Main.java file next to the DataModel.java and if you inspect it you can see it provides a DesktopServices implementation that is using standard Java way to access (Windows) registry - e.g. preferences API;

public static void onPageLoad() throws Exception {
    DataModel.onPageLoad(new DesktopServices());
}

private static final class DesktopServices extends PlatformServices {
    @Override
    public String getPreferences(String key) {
        return Preferences.userNodeForPackage(Main.class).get(key, null);
    }

    @Override
    public void setPreferences(String key, String value) {
        Preferences.userNodeForPackage(Main.class).put(key, value);
    }
}

NetBeans Platform

The NetBeans Platform boot mechanism - located in client-netbeans/src/main/java/**/NbMain.java file - is similar. Just instead of Java preferences it uses NbPreferences class tailored for NetBeans needs.

iOS

The way to deal with user preferences on iOS system is to use NSUserDefaults as provided by Apple. Of course, their documentation is tailored for Objective-C and we aren’t coding in such language! Luckily there is a 1:1 wrapper API available in org.robovm.apple.foundation.NSUserDefaults class and we can thus easily write:

public static void onPageLoad() throws Exception {
    DataModel.onPageLoad(new iOSServices());
}

private static final class iOSServices extends PlatformServices {
    @Override
    public String getPreferences(String key) {
        return NSUserDefaults.getStandardUserDefaults().getString(key);
    }

    @Override
    public void setPreferences(String key, String value) {
        NSUserDefaults.getStandardUserDefaults().put(key, value);
    }
}

Android

The Android API for storage is associated with application context. Luckily the most recent version of DukeScript Presenters gives us an easy access to the application context. Just declare the Context as a single parameter of the main method:

import android.app.Activity;
import android.content.SharedPreferences;

public class AndroidMain extends Activity {
    public static void main(android.content.Context context) throws Exception {
        SharedPreferences prefs = context.getApplicationContext().getSharedPreferences(AndroidMain.class.getPackage().getName(), 0);
        DataModel.onPageLoad(new AndroidServices(prefs));
    }

    private static final class AndroidServices extends PlatformServices {
        private final SharedPreferences prefs;

        AndroidServices(SharedPreferences prefs) {
            this.prefs = prefs;
        }
        @Override
        public String getPreferences(String key) {
            return prefs.getString(key, null);
        }

        @Override
        public void setPreferences(String key, String value) {
            prefs.edit().putString(key, value).apply();
        }
    }
}

Browser

The simplest work is with the browser environment. As our default implementation of PlatformServices deals with localStorage object available in any browser, we can just use the class without any special tricks. This is exactly what the client-web/src/main/java/**/BrowserMain.java file does.

Trying it Out!

The sample application allows you to edit an input line with a message. With every change it stores the current value of the text into appropriate storage as provided by our registered PlatformServices implementation.

To try it out, run the application once, modify the message, shut the application down and launch it again. You should see the modified text being used and the behavior shall be consistent on desktop, Android, iOS or inside of a NetBeans Platform application. The behavior works in a browser as well - just open new tab with the same URL as the previous one and you can see the text is properly propagated through localStorage object.

DukeScript gives you platform independent UI. PlatformServices concept (as introduced in archetypes version 0.17) gives you simple, standardized and flexible way to access proprietary platform services.

Enjoy DukeScript’s portability and flexibility!

NetBeans – Michael's blog - February 20, 2017 08:33 PM
JUGC: Java Web Development with TomEE and Vaadin – slides and more

In addition to my impressions of the JUGC evening about TomEE, Vaadin, Linkki and Arquillian, some of the speakers provided me slides and other documentation or links to it. Andy Gumbrecht This demo revolves around the MyBatis JPetStore 6 on Apache TomEE. It includes several examples on how to add EE technoligies to an existing […]

NetBeans – Michael's blog - February 19, 2017 09:14 PM
Impressions from JUGC: Java Web Development with TomEE and Vaadin

On Friday, 17th we had another event at the Java User Group Cologne. An evening about Java web development with Apache TomEE and Vaadin. More than 40 Java enthusiasts participated that evening. The event was hosted by Faktor Zehn, the company which hosted the first NetBeans Evening Colonge, too. The evening was scheduled from 6:30 […]

Geertjan's Blog - February 19, 2017 01:36 PM
From AngularJS to Oracle JET at DevNexus

I'm going to DevNexus this week. There'll be a NetBeans booth and several NetBeans community members in attendance, drop by and come and chat about NetBeans, Apache, etc!

Also, I'll be talking about Oracle JET:

https://devnexus.com/s/devnexus2017/presentations/17974

I'll take an AngularJS/Ionic application Matt Raible created and talked about recently at Jfokus and I'll show how that application looks and how it is structured when created via Oracle JET. I'll discuss the similarities/differences and advantages/disadvantages. Here's the repo where I am working on this:

https://github.com/GeertjanWielenga/jet-hello-world

So, if you're exploring alternatives to AngularJS/Ionic, come to the session and see the approach you can take with JET to create web or mobile applications. The pic on the left is Matt's AngularJS/Ionic app, on the right is my JET app:

Geertjan's Blog - February 16, 2017 03:37 PM
Oracle JET at Transfer Solutions (Part 2)

I attended an excellent session about Oracle JET by Lai Ho Yueng and Maresa Bunschoten, from Transfer Solutions in Leerdam in the Netherlands. Transfer Solutions, an Oracle partner, regularly hosts free knowledge sharing sessions. Some time ago, I was invited to talk about Oracle JET (as described here in part 1) and in the meantime developers at Transfer Solutions are using Oracle JET to create mobile and web products for their customers.

Before the break, Maresa did a thorough overview of Oracle JET and all that it provides:

She started by talking about the difference between web, mobile, and hybrid development and then discussed how Oracle JET covers all of these paradigms from the same codebase. 

After the break, Lai showed an application that makes use of offline features in Oracle JET, based on a real application in production at a client site.

And it was clear that NetBeans IDE was a handy tool to use for JavaScript development, especially the integration with the Chrome browser, demonstrated by Lai.

It was a good event, with around 30 attendees. Clearly the message of Oracle JET as a toolkit for mobile and web development is spreading!

APIDesign - Blogs - February 16, 2017 10:40 AM
Codesnippet Doclet 0.20 Release

Enhance your Javadoc with Codesnippet4Javadoc version 0.20 which now supports special "coloring" for strings and comments.

--JaroslavTulach 10:40, 16 February 2017 (UTC)

Geertjan's Blog - February 14, 2017 11:37 AM
NetBeans and Apache (Part 2)

Since the various announcements about NetBeans transitioning to Apache, what's been going on and what's the current status?

Before reading on, take a look at the following:

Well, if you're asking "what's been going on?" it simply means you're not part of the discussion, which is a simple step-by-step process to be part of:

https://cwiki.apache.org/confluence/display/NETBEANS/How+to+Participate

After following the above, you'll be on the NetBeans Apache developer mailing list and be able to follow the process as it happens. Right now, weekly updates are provided on the process.

In short, Oracle is going through the process of making sure that the NetBeans repositories that are targeted at being donated to Apache do not contain anything that should not be donated. For example, Oracle cannot donate files that are not Oracle's to donate. The repositories contain code going back 20 years, since NetBeans has existed since 1995/96, and are therefore full of potential accidental reusages of code that may or may not belong to Oracle, e.g., that could be forks of the JDK, for example. All files are being examined for such instances, including missing copyright notices, and similar potentially problematic areas.

Which repositories are we talking about? How long will all this take? Scroll to the end of the page here for details:

https://cwiki.apache.org/confluence/display/NETBEANS/Apache+Transition

The aim is for NetBeans 9 to be released as a top level Apache project together with the release of JDK 9. Prior to that, i.e., in order to move out of the Apache Incubator, there needs to be at least one release of NetBeans done from within the Apache incubator, i.e., NetBeans IDE 8.2.1 or NetBeans IDE 8.3.

So, those are tight deadlines we're aiming for, though all sides are clear about what we're targeting and focused on meeting those deadlines. Things are looking good and, speaking for myself, I'm happy that we're going through such a thorough process, since the end result will be clear and comprehensive to everyone involved.

And, guess what, the Apache NetBeans community already has a new website in place, clearly a work in process though it's awesome we have it at this stage already, with thanks especially to Chris Lenz from Leipzig who is leading this project:

netbeans.apache.org

If you're out there and interested in joining in and keeping in touch with the process, go here to get started:

https://cwiki.apache.org/confluence/display/NETBEANS/How+to+Participate

Adam Bien - February 14, 2017 09:41 AM
Pushing Full Profile Java EE Applications To Amazon EC2 Container Service

In this screencast I created from scratch with Maven, built (CentOS, JDK, Payara, Thin WAR, taken from docklands) and pushed a Full Profile Java EE 7 (Payara Full) application to Amazon EC2 Container Service cluster.

The ECS cluster is running on the smallest "free tier" available Amazon EC2 machine t2.micro (1 CPU and 1 GB RAM). t2.nano (512 MB max) would also work -- but is not eligible for free tier.

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 - February 09, 2017 08:55 AM
20+ Topics in 45 mins -- 35th airhacks.tv Questions and Answers

90 live attendees, 20+ topics in 45 mins ranging from Java EE 8 News over JPA relations in MSAs to cross-field validation. The 35th (2.2017) airhacks.tv is available:

Watch past episodes with: airhacks.tv playlist.

Any questions left? Ask now gist.github.com/AdamBien/4500d4f7e546ea7f242baaec2e2f6616 and see you at March, 6th, 6pm CET.

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]>

Geertjan's Blog - February 08, 2017 08:00 AM
NetBeans Day France 2017

The Laboratoire d'Informatique de Grenoble hosted NetBeans Day France yesterday.

The event was sponsored by Davidson in Paris, who provided the great lunch!

The program included the following topics:

  • Reactive Systems with Eclipse Vert.x and Red Hat Open Shift (Clement Escoffier, Red Hat)
  • Développement entreprise JavaScript avec Oracle JET (Geertjan Wielenga, Oracle)
  • Jouer avec Spring Boot et Docker (Nebrass Lamouchi, Davidson SI)
  • JBoss Forge, WildFly et Java EE (Emmanuel Hugonnet, Red Hat)

The day began with a session about the NetBeans project, its history, unique features, and transition to Apache.

Clement Escoffier demoed in a lot of detail Vert.x together with OpenShift and NetBeans IDE:

That was followed by me talking about Oracle's new JavaScript toolkit, Oracle JET:

I had to leave shortly after the above, though I heard Nebrass and Emmanuel did great sessions on Spring Boot and Docker (Nebrass) and JBoss Forge, WildFly, and Java EE (Emmanuel). Both Emmanuel and Nebrass are NetBeans Dream Team members, great to have worked with them to organize this event. And thanks again, Davidson in Paris, for sponsoring the lunch for this successful event.

Possibly we could have two NetBeans events in France each year. One in Grenoble and the other in Paris! 

Adam Bien - February 08, 2017 07:18 AM
JPA and Microservices, RxJava, CRUD and TX, Gradle, Cross Field Validation, Licensing, MDA or Topics For The 35th airhacks.tv

Questions (gist) for the 35th airhacks.tv, February 8th (exceptionally at Wednesday, not Monday), 6 pm CET:

  1. Java EE 8 News
  2. Java SDK for Oracle Bare Metal Cloud Services github.com/oracle/bmcs-java-sdk
  3. Handling JPA relationships in CRUD microservice scenarios
  4. The role of RxJava in typical enterprise applications
  5. JAX-RS: returning Response vs. objects and JSON vs. XML
  6. Useful Java EE 7 tools
  7. Cross-field entity validation
  8. GPL/LGPL, opensource and commercial projects
  9. What is www.pac4j.org?
  10. Transactions, CRUD-Services (BCE), EntityManager and connection sharing
  11. (SCM) Managing, Structuring and organizing microservices
  12. Gradle adoption, gradle vs. maven
  13. Dealing with (setup) scripts in Java EE environment
  14. Oracle JDK vs. openJDK and licensing
  15. Greatings from Panama: gitbook.com/book/avbravo/jmoordb
  16. The role of Model Driven Architecture in Java EE

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]>

Adam Bien - February 06, 2017 05:32 AM
JSON Is The New Data Transfer Object (DTO)

The JSON processing API comes with Java EE 7 and is already integrated with JAX-RS. JsonObject and JsonArray are serialized and deserialized by the JAX-RS runtime without any additional effort.

JsonObject is a Map<String, JsonValue> and so a generic and dynamic DTO.

Because the entities know their state and also have access to private data, the JSON-mapping happens directly within the domain objects:

    
public class Workshop {

    private String name;
    private int duration;

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


    public Workshop(JsonObject input) {
        this.name = input.getString("name");
        this.duration = input.
                getJsonNumber("duration").
                intValue();
    }


    public JsonObject toJson() {
        return Json.createObjectBuilder().
                add("name", this.name).
                add("duration", this.duration).
                build();
    }
}
    
    

Now the JAX-RS resource class only has to invoke the entities method to map from and to the JsonObject representation:

        
@Stateless
@Path("workshops")
public class WorkshopsResource {

    @Inject
    RegistrationStore store;

    @GET
    public JsonArray all() {
        JsonArrayBuilder list = Json.createArrayBuilder();
        List<Workshop> all = this.store.all();
        all.stream().map(Workshop::toJson).forEach(list::add);
        return list.build();
    }

    @POST
    public void save(JsonObject input) {
        this.store.save(new Workshop(input));
    }
}
        
    
See you at Java EE Microservices. Is Munich's airport too far? Learn from home: javaeemicro.services.
Real World Java EE Workshops [Airport Munich]>