Č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
NetBeans Zone - The social network for developers (feed)
ludo's blog (feed)
APIDesign - Blogs (feed)
pandaconstantin's blog (feed)
hansmuller's blog (feed)
pkeegan's blog (feed)
richunger's blog (feed)
tball's blog (feed)
timboudreau's blog (feed)
David R. Heffelfinger (feed)
Winston Prakash's Weblog (feed)
Need to find a title (feed)
Roger Searjeant's blog (feed)
Optonline Webmail (feed)
Michael's blog » NetBeans (feed)
DukeScript (feed)
ProNetBeans (feed)
Tim Boudreau (feed)
Paulo Canedo » NetBeans English (feed)
Bistro! 2.0 (feed)
Anchialas' Java Blog (feed)
markiewb's blog (feed)
Anuradha (feed)
Netbeans6/6.5 my best practices (feed)
Java Evangelist John Yeary (feed)
Java, business and... NetBeans ! [[ Jonathan Lermitage ]] - NetBeans IDE (feed)
Neil's Dev Stuff (feed)
Category: NetBeans | Software and Science (feed)
Computer says null; (feed)
NetBeans Adventures, Java and more (feed)
Inspiration and Expression » Netbeans (feed)
John O'Conner » NetBeans (feed)
Adam Bien (feed)
Ignacio Sánchez Ginés » NetBeans (feed)
Ozone and Programming » netbeans (feed)
NetBeans Ruminations » NetBeans (feed)
Tiplite » netbeans (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)
My First Blog - Satyajit Tripathi (feed)
The Aquarium (feed)
Tinuola Awopetu (feed)
Insert Witty Irony Here (feed)
Gualtiero Testa » Netbeans (feed)
James Selvakumar's Blog » netbeans (feed)
nB gUru » NetBeans (feed)
Newsintegrator Blog » netbeans (feed)
Praxis LIVE » NetBeans (feed)
TechAshram » NetBeans (feed)
There's no place like 127.0.0.1 » Netbeans (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)
Oliver Wahlen's Blog (feed)
Shuttle between Galaxies (feed)
Welcome to my live... (feed)
Netbeans IDE Blog by Tushar Joshi, Nagpur (feed)
Devel Blog (feed)
diamond-powder (feed)
Manikantan's Netbeans (feed)
Antonio's blog (feed)
Where's my Blog?!

Powered by:    Planet

Last updated:
July 01, 2015 06:05 AM
All times are UTC

Sponsored by
sponsored by Oracle

visit NetBeans website
DukeScript - July 01, 2015 09:53 AM
How to develop DukeScript applications with Eclipse

I’ve been asked a couple of times, if you can develop DukeScript applications with Eclipse. And while we encourage people to try NetBeans, we don’t want to exclude Eclipse users. So I decided to give it a try. I have an Eclipse installation on my machine from writing a book on JavaFX, so I launched it, checked for updates and created a new project.

Prerequisites: Eclipse Luna (or better) with m2eclipse

Here are the steps I took:

1.) In the Java perspective select File -> New -> Project…

2.) A dialog pops up, select Maven -> Maven project, click “Next”:

3.) “Create a simple project (skip archetype selection)” should obviously not be ticked on the next screen, click “Next”

4.) On the next screen you’ll be asked to select an archetype. Type “dukescript” in the filter text field. This should give you a list of publicly available archetypes. Choose “knockout4j-archetype” (that’s the simple one).

4.a) If you don’t have anyting in the list, chances are that you don’t have the Maven Central Index. In that case click the “add archetype” button and register “https://repo1.maven.org/maven2/archetype-catalog.xml”, then try step 4 again.

5.) On the next screen, choose a group id and archetype id (e.g. “com.mycompany” and “demo”). Also in the properties section remove the “target/” prefix on the values of “iospath”, “androidpath”, and webpath. This will create subprojects for ios, android and browser. You can leave nbpath untouched unless you really want to develop a NetBeans plugin :-). Click “finish”:

6.) The project opens. In Package Explorer right-click the “demo-pom” project and select “Run as” -> “Maven install”. The build should succeed, as you can see from the console output:

7.) Now go to the project named like the archetype id in step 5 (“demo” in my case). Right-click and choose “Run as” -> “Maven build”.

8.) This should open a dialog. In the field “Goals” enter “process-classes exec:exec” and confirm. The project should be launched now.

OK, now that we’ve finished the most basic integration, being able to build and run, let’s go for some closer integration. DukeScript makes use of AnnotationProcessors to create the ViewModel. I’ve talked to a lot of Eclipse users about this topic and with their approval I dare to say here that Eclipse support for AnnotationProcessors really sucks. As a result when you open the DataModel.java Eclipse will complain that it doesn’t know the “Data” class. Fortunately there is a plugin (on the good side: in Eclipse there always is a plugin ;-)). called m2eapt which aims at providing automatic Annotation Processing configuration in Eclipse based on your pom.

1.) Install it via Window > Preferences > Maven > Discovery > Open Catalog.

2.) Go to Window > Preferences > Maven > Annotation Processing and select “Experimental: Delegate Annotation Processing to maven plugin”

3.) Now go back to your DataModel class and check if the complaints have go away. You should now be able to e.g. add a new Property to the @Model like this:

@Model(className = "Data", targetId="", properties = {
    @Property(name = "message", type = String.class),
    @Property(name = "rotating", type = boolean.class),
    @Property(name= "test", type = String.class)
})
final class DataModel {
// more code...

Eclipse will allow the AnnotationProcessor to do its work and code completion will show you setters and getters for this property:

That’s it for now. You should now be able to run and develop DukeScript applications using Eclipse.

This blog post is work in progress, and I’d lik eto add it to our getting started guide, once Eclipse users report they’re happy with it (or don’t complain anymore). If you run into problems let me know. I’ll also ask some Eclipse users to give me their input. There’s an active discussion of bugs and problems when running with Eclipse on stackoverfow. It also has some hints when you run into problems.

Adam Bien - July 01, 2015 12:59 AM
Trouble-Free Shopping with youstice.com And Java EE 7

Interview with Matyas Bene, an airhacks.com alumni and developer at youstice.com:

What is youstice.com?

Youstice is a company and cloud-solution that helps resolve customer complaints and make shopping trouble-free. With Youstice , companies can seamlessly communicate and handle customer complaints within a matter of minutes. Similarly, disgruntled customers can get prompt assistance with their issues and save valuable time with the possibility to escalate their complaints to a neutral 3rd party for an independent decision.

Which technologies is youstice.com using on the backend?

The solution consists of 3 pillars:

  • the application itself - developed in a proprietary JVM-based, full-stack development and runtime platform, running on Tomcat,
  • the integration gateway (API) - facilitating the communication between 3rd party SW and the application, developed in J2EE,
  • plugins into various e-shop platforms and other points of entry - utilizing various technologies including PHP, Java, C# and others - as needed

You decided to use JAX-RS 2.0 / Java EE to implement the API, why?

First, we needed to be platform-independent, hence JAVA and the JVM. Choosing J2EE as our framework was a no-brainer for several reason:

  • all the components are already integrated (no wasted time by fiddling with the integration of 3rd party libraries),
  • is well-established and has a solution to the most pressing issues that a developer would encounter in an enterprise or even in the wild-wild world of cloud solutions, and
  • is open, versatile and future-proof,
  • is lean to run and quick to develop.
To give credit where credit is due, Adam Bien (and his videosvideos about "Lean J2EE" on youtube) played a big role in changing my opinion on J2EE a couple of years ago.

How many developers are working on the API?

It was a one-man project since the beginning.

What about the performance?

Development performance is remarkable. We estimated it to 5MD (net effort) to get on feature-parity with the old-version, which we delivered (excluding translations, bug-fixing and tuning). Runtime performance has also improved. Rewriting the API to J2EE helped us to increase the number of requests handled per second three-fold on the same hardware, and, at the same time, eliminate the occasional drop-outs. This migration also opened up possibilities and functionalities that were not available before, or would have required a considerable amount of extra-code.

What is your experience with Java EE so far?

Still learning it, of course. The more I learn about and work with Java EE 7, the more I realize the level of development (and also runtime) efficiency it offers. That said, I guess it&aposs still too easy and tempting not to follow the rules (TM) and end up with >X (=your time here) minutes of compilation times, sending development efficiency to the rock-bottom. So it either requires a really stubborn adamancy in sticking to the rules (TM) or considerable level of expertise.

I&aposd also like to note, that the number of quality materials specific for Java EE 6/7 is very limited. There are plenty of gems in the platform (especially in conjunction with JDK8) that are either well-hidden or difficult to understand/combine properly at first, yet are huge time-savers for the knowledgeable. A big thank you goes to you, Adam for doing your best to fill this gap. The blogs, Q&A sessions and the trainings are worth gold. So far every session I attended resulted in hundreds of lines deleted, dependencies dropped, features increased, builds simplified.

Which tools, servers, IDEs, external libraries are you using?

IDE is NetBeans. Previously it was Eclipse, but I haven&apost seen it since my first airhacks session in Munich. As a matter of fact, it was easy to convince my colleagues to switch as well. We utilize Jenkins, SonarQube and Jacoco for the quality cycle. The application server we use is Payara. Important 3rd party libs include querydsl, jersey and jackson. Lately, we introduced porcupine to fight back-pressure and swagger to document our API. However, the overall trend is to shrink the .war size. Currently it&aposs half the size it was 6 months ago. It&aposs partly Payara&aposs advantage (ships many commonly used jars, like jackson) and partly our internal effort to get rid of external dependencies. We even consider dropping jackson in spite of the performance advantages.

You attended the airhacks.com workshops in Munich. Do you had the opportunity to chat with other attendees? What was the most interesting project?

Knowledge sharing between participants is something I especially enjoyed during the last &aposmicro-services&apos sessions. The attendants were all seasoned professionals who&aposve brought their lessons learned from past projects. It was very interesting to see how certain challenges pop up in almost every organization (and the different solutions or attempts) as well as learn about the rare cases. Out of the projects I&aposve learned about, the most interesting one for me was tipi.camp - AFAIK they were running glassfish on an embedded raspberry.pi device to monitor showers in camps.

Any resources, links (shameless plugs) you would like to share with us?

Partly mentioned above: Payara, QueryDSL, Orient DB, Swagger, AuthenticRoast and of course Youstice. Just because I think they&aposre great.

Matyas, thank you for the interview!
Real World Java EE Workshops [Airport Munich]>

DukeScript - June 30, 2015 09:53 AM
How to write an API for PouchDB

In our forum someone has asked how he can use PouchDB in DukeScript. In case you don’t know PouchDB this is the description from their website:

“PouchDB is an in-browser database that allows applications to save data locally, so that users can enjoy all the features of an app even when they’re offline. Plus, the data is synchronized between clients, so users can stay up-to-date wherever they go.”

Maybe this is a nice chance for a blog post on writing a Java API for a JavaScript library. I’ve started by creating a little application “pouchdbdemo” based on the Knockout4j Archetype. Don’t bother doing this now, I’ve published the sources on Github for your convenience. The App does nothing fancy except creating a DB, storing one item and logging a message on success, but it might help you to see the ideas behind creating a simple API.

To create a Java API you only need to know two annotations: @JavaScriptBody and @JavaScriptRessource. The API Doc has some further info how to use them.

@JavaScriptRessource

The purpose of @JavaScriptRessource is simple. It allows you to load a JavaSript Library. Why is there an Annotation for this? You could also simply put a reference to it in your HTML-Page…

The reason is that it gives you a way to version the library. Others can then reference it via a Maven Dependency. And you can bundle it with your Java API. I’ve downloaded the latest version of PouchDB and put it into the “pouchdbdemo JavaScript Libraries” module. Now I create a class with this annotation:

import net.java.html.js.JavaScriptResource;

@JavaScriptResource(value = "pouchdb-3.6.0.min.js")
public class PouchDB {
    
}

NetBeans will complain that there needs to be at least one method with a @JavaScriptBody Annotation. We’ll fix that now:

@JavaScriptBody

Methods annotated with @JavaScriptBody can be used to execute JavaScript code from Java. In addition it makes it really easy to pass arguments to the JavaScriptCode. This is the code to create a pouchdb instance in JavaScript:

var db = new PouchDB('todos');

In order to wrap this call I can do this:

@JavaScriptBody(args = { "name" },body = "return new PouchDB(name)")
public static native Object createImpl(String name);

So instead of needing to construct the JavaScript String via some String operations, I can simply pass the name as an argument. In addition we’ve also made the method call type save. You can only pass in Strings.

Still the method isn’t very nice, because it would return some odd JavaScript Object to the user of your API. Java Developers don’t want to deal with that. The best strategy to make a nice API is to wrap this object and keep it out of sight. It’s enough that you as an API developer has to deal with ugly JavaScript:

@JavaScriptResource(value = "pouchdb-3.6.0.min.js")
public class PouchDB {


    private final Object pouch;

    private PouchDB(Object wrapped) {
        pouch = wrapped;
    }

    public static PouchDB create(String name) {
        return new PouchDB(createImpl(name));
    }

    @JavaScriptBody(args = { "name" },body = "return new PouchDB(name)")
    private static native Object createImpl(String name);
}

Much nicer. The user of your API can now create a new PouchDB and will receive a beautiful type safe Java Object:

PouchDB db = PouchDB.create("todos");

Not only are we able to use the JavaScript Library, we’ve also made it better. The user of the API immediately knows what he will get back from the call, a PouchDB. And also the IDE knows what it will get, and can offer methods you can call on this Object (we’ll create some soon). And also the compiler knows what this is.

All that JavaScript users get is a “var” with no further clues on how to use it. It could be anything from an int to a function.

So let’s see what else the PouchDB API has… The tutorial stores a message like this:

function addTodo(text) {
  var todo = {
    _id: new Date().toISOString(),
    title: text,
    completed: false
  };
  db.put(todo, function callback(err, result) {
    if (!err) {
      console.log('Successfully posted a todo!');
    }
  });
}

Let’s convert it to a Java API:

public void addTodo(String todo) {   
        addTodoImpl(pouch, todo);
    }

    @JavaScriptBody(args = {"pouch", "text"}, body = "console.log('Posting a todo '+text);\n"
            + "console.log(pouch.adapter);\n"
            + "var todo = {\n"
            + "    _id: new Date().toISOString(),\n"
            + "    title: text,\n"
            + "    completed: false\n"
            + "  };\n"
            + "  pouch.put(todo, function callback(err, result) {\n"
            + "    if (!err) {\n"
            + "      console.log('Successfully posted a todo!');\n"
            + "    }\n"
            + "    if (err) {\n"
            + "      console.log('Error '+err);\n"
            + "    }\n"
         
            + "  });")
    public static native void addTodoImpl(Object pouch, String text);

I mainly left the JS code unchanged, but added some logging. Notice how the public API method only requires you to pass the string. We then get the wrapped JavaScript “pouch” and pass it to the implementation. I usually follow this pattern in all my APIs.

You can now call the API like this:

PouchDB pouchDB = PouchDB.create("todos");
pouchDB.addTodo("Buy milk!");

So instead of a bunch of letters in a bag (aka JavaScript) you have a nice and type save API. Let’s stop here for now, as this should be the most important concepts you need for writing an API.

If you’re interested in having such an API or helping, let us know. This is a great chance to get some in depth knowledge about DukeScript. And in case you need this right now, but have no time, be a sponsor and bribe us to put it on top of our todo list ;-).

If you just want to play with it, do so here.

Adam Bien - June 30, 2015 06:23 AM
Java WebSockets Client

JSR-356 comprises both: client and server endpoints.

This screencast demonstrates how to connect to a (Java EE 7) server from a plain Java client using the RI (tyrus):

Also checkout: hellsockets.

See also other screencasts at: http://tv.adam-bien.com or subscribe tohttp://www.youtube.com/user/bienadam.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Michael's blog » NetBeans - June 29, 2015 09:26 PM
JSF LoopProblem

I inserted a chapter called Intermezzo into my book, which tackles some common aspects of JSF. Unlike the other chapters it is not specific to one of the discussed web applications. Today I described a problem with repetitive structures. A … Weiterlesen

NetBeans Zone - The social network for developers - June 29, 2015 08:53 PM
Interview: Ikroop Dhillon on Oracle Solaris Studio

For developers coding in C/C++, NetBeans IDE provides a C/C++ bundle of its set of tools.However, the NetBeans C/C++ toolset is the application platform for Oracle Studio IDE, which provides a set of features that extend the NetBeans C/C++ toolset. Preview Text:  Meet Ikroop Dhillon, the Oracle Principal Product Manager responsible for Oracle...

NetBeans Zone - The social network for developers - June 29, 2015 07:18 AM
Announcing jadice AFPviewer on the NetBeans Platform

The jadice AFPviewer by levigo solutions is a tool built on the NetBeans Platform for analyzing and displaying print data streams. Being a viewer for AFP data streams it displays these streams in their original appearance and shows meta data in a structured way. Preview Text:  The jadice AFPviewer by levigo solutions is a tool built on...

Geertjan's Blog - June 26, 2015 07:00 AM
International Synergy for Kendo UI Core in NetBeans

During JavaOne Brasil, quite a bit of work was done on the Kendo UI Core plugin for NetBeans! Opposite me at a restaurant (where we had endless heaps of great Brazilian meat and beer and so on) were sitting Mauricio Leal, Leonardo Zanivan, and All Pereira. I kind of mentioned to them that I was having problems with regular expressions for some pretty complex parsing of Kendo UI Core documents, the output of which is passed into the NetBeans code completion box.

It turned out that the three of them are a lot more experienced in regular expressions than I am. In fact, they'd been doing quite a bit of work with regular expressions recently and so the logic was still fresh in their minds. Right there in the middle of the food and plates and so on Mauricio, in particular, started hacking at the code. Leonardo and All also joined in. Then later I met with Leonardo and All at the Hackergarten, thanks to Heather van Cura:

And so it was that an international bond was forged between Heather (from the US), me (from the Netherlands), and Leonardo, All, and Mauricio (all from Brazil). Without Heather, we'd probably not have met up and without the Brazil guys we'd not now have a much better parsing. Compare the before with the after to see the difference, i.e., the same document is parsed, but now the information returned to the code completion box is far more complete:

Before:


After:


The above is thanks to the pull that Leonardo made available:

There's still quite a bit more work to be done to get the parsing even more complete, plus we want to add caching to speed up the parsing.

Some people have encountered problems installing the plugin, which is because an implementation dependency is used, rather than public APIs. It should, in theory, work in NetBeans IDE 8.0.2, though not everyone has got it to work, i.e., installation fails because of conflicts between the implementation dependency and the already installed JavaScript2 Editor module. I have a workaround for this and will make a screencast about it soon.

The sources of the plugin is here: https://github.com/GeertjanWielenga/KendoNetBeans

And the binary is here: http://plugins.netbeans.org/plugin/58791/kendo-ui-core-editor

Adam Bien - June 26, 2015 04:56 AM
Mapping CSV Files To POJOs With Enhydrator

Enhydrator is slim, Apache licensed, Java 8 ETL (Extract, Transform, Load) library. In the 3rd episode I'm going to explain how to map rows from any source into POJOs (4 mins, 30 secs):

Also checkout Enhydrator in Action (Part 1), Type Conversions and Filtering With Nashorn (Part 2) and: https://github.com/AdamBien/enhydrator.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 25, 2015 07:00 AM
Trip Report: NetBeans Day Brasil

The first NetBeans Day Brasil ever (or, possibly, in a long long time) was held on Monday 22 June 2015 in the Oracle office in Sao Paolo, food sponsored by the Oracle Technology Network, and goodies provided by a variety of NetBeans partners, such as a copy of JavaFX Rich Client Programming on the NetBeans Platform, by Paul and Gail Anderson of the Anderson Software Group.

A key aspect to this event is that it is awesome that we now have a location for this in Brazil, i.e., the Oracle office sponsored this event with a very nice auditorium. Many thanks to Bruno Borges from Oracle for arranging this.

The content delivered at the event was really great. Except for myself, all the speakers were local and everything was in the local language, i.e., Brazilian Portuguese. That makes a big difference at these kinds of local events.

Topics included JavaScript/HTML5 with NetBeans, Nashorn, IoT, and an overview of NetBeans IDE itself. The full agenda is here. Speakers were Bruno Souza, Bruno Borges, Vinicius Senger, and Leonardo Zanivan.

A definite highlight was an overview of new features in the upcoming NetBeans IDE 8.1 by a great new active member of the NetBeans community -- Leonardo Zanivan.

Node.js, HTML5, JBoss Forge, and Other Awesome New NetBeans Features

Drinks and snacks were great, thanks OTN:

Everyone thought it was unfortunate that only about 1/3 of those who registered showed up, but those who were there were very enthusiastic at the end of the day and want to help promote this next time and they suggest that we use the local Brazilian media, e.g., message boards, etc, to promote NetBeans Day. However, since this was the first event of its kind in Brazil (or, in fact, in Latin America in general), it was really a "getting to know you" and "let's see what this is" kind of event, i.e., we're really just getting our feet wet here and now we have a base to start getting things going more seriously in terms of attendance at the next NetBeans Day in Brazil. We're also thinking of new strategies to ensure there's a closer correlation between registrations and attendance, e.g., maybe charging a few dollars for registration, for example, i.e., to make the commitment stronger to the event, though there are downsides to this approach, i.e., harder to get students to sign up then, etc.

All in all, a nice start, definitely worth repeating at a larger scale. Many thanks to the speakers and attendees for participation in this event!

APIDesign - Blogs - June 24, 2015 04:04 PM
Design with Truffle. Get Debugger for Free!

Truffle - a modern way to write AST interpreters - gives you not only speed, but also debugger for free:

Image:TruffleDebugger.png

The picture shows NetBeans debugger stopped in middle of simple language (an artificial language used for demo purposes) method. NetBeans knows nothing about simple language (that is why syntax coloring is missing), but as NetBeans understands the Truffle AST, it can still provide enough valuable information in the debugger.

Please note that the name of the method is properly recognized and shown on top of the stack. Variables a and b and their values are properly shown as well.

Designing your own language? Do you want to spend time writing a debugger? If not, use Truffle and you'll get your debugger for free!

--JaroslavTulach 16:04, 24 June 2015 (UTC)

Adam Bien - June 24, 2015 03:17 PM
JAX-RS Client Rulz v0.0.2 released

The JAX-RS client rulz project was released with a single feature--the URI can be resolved using the Java's system properties:


JAXRSClientProvider.buildWithURI([SYSTEM-PROPERTY-KEY], [DEFAULT-IF-NOT-FOUND]);

Use:

<dependency>
	<groupId>com.airhacks.rulz</groupId>
	<artifactId>jaxrsclient</artifactId>
	<version>[RECENT_VERSION]</version>
	<scope>test</scope>
</dependency>

to setup rulz for your integration tests.

Usage example:


    @Rule
    public JAXRSClientProvider provider = JAXRSClientProvider.buildWithURI("java-site","http://www.java.com");

    @Test
    public void pingJava() {
        Client client = provider.client();
        assertNotNull(client);
        WebTarget target = provider.target();
        assertNotNull(target);
    }


See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 24, 2015 02:39 PM
Take Early JDK 9 For A Spin In Early NetBeans 9

Here's a super cool new development for the true adventurer, the wild side walker, and the most cutting edge of cutting edge Java developers.

Could this be you?

From today, there's a brand new build of NetBeans IDE focused very specifically on giving you the tools you need for taking the early access build of JDK 9 for a spin:

Spread the word and get involved in the process. Once you have downloaded the early access JDK and early build of NetBeans IDE, register the former in the latter, which will expose the JDK to your Java SE projects:

For all the details, including how to give feedback: http://wiki.netbeans.org/JDK9Support

Adam Bien - June 23, 2015 08:42 AM
One-liner: Extracting Long Statistics From A Collection of POJOs

From a collection of objects representing method calls:


public class MethodCall {

    private String methodName;
    private int duration;

    public MethodCall(String methodName, int duration) {
        this.methodName = methodName;
        this.duration = duration;
    }

    public String getMethodName() {
        return methodName;
    }

    public int getDuration() {
        return duration;
    }
}

useful statistics data can be extracted with Collectors.summarizingLong:


import java.util.ArrayList;
import java.util.LongSummaryStatistics;
import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.Test;

public class LongSummaryStatisticsTest {

    private ArrayList<MethodCall> calls;

    @Before
    public void provideTestData() {
        this.calls = new ArrayList<>();
        calls.add(new MethodCall("save", 90));
        calls.add(new MethodCall("find", 10));
        calls.add(new MethodCall("delete", 2));

    }

    @Test
    public void computeStatistics() {

        LongSummaryStatistics statistics = this.calls.stream().
                collect(Collectors.summarizingLong(MethodCall::getDuration));

        assertThat(statistics.getCount(), is(3l));
        assertThat(statistics.getMin(), is(2l));
        assertThat(statistics.getMax(), is(90l));
        assertThat(statistics.getAverage(), is(34d));
        assertThat(statistics.getSum(), is(102l));
    }

}


The code above was extracted from "Effective Java EE" online course (coming soon), the second part of the Java EE Bootstrap at parleys.com.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 23, 2015 07:00 AM
Released: Kendo UI Core Plugin for NetBeans IDE

The first release of the Kendo UI Core plugin for NetBeans IDE is available:

http://plugins.netbeans.org/plugin/58791

It provides two features. The first feature exposes the Kendo UI Core components to the code completion box:

The second feature gives the code completion box access to the attributes of the current Kendo UI Core component, i.e., here you see the attributes of the KendoCalendar component are available in the code completion box because the KendoCalendar is the currently used component:

In both cases, you can see documentation is included. Everything in the code completion box, provided by this plugin, comes from documentation by the Kendo UI Core team, such as this one:

https://github.com/telerik/kendo-ui-core/blob/master/docs/api/javascript/ui/calendar.md

More features are being worked on, including more information in the code completion box and any feedback is welcome.

Adam Bien - June 22, 2015 11:41 AM
Writing POJOs To XML--Without Annotations

With the utility classes introduced in JDK 1.4 XMLEncoder and XMLDecoder you can serialize and deserialize POJOs with property accessors (aka JavaBeans) with some caveats:

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 21, 2015 07:00 AM
Handy Parsing Utilities for Markdown

Kendo UI comes with Markdown documents that I'm working with to provide content for the code completion box:

Initially I was using some kind of Markdown parsing library, but then I realized hey why not simply use pattern matching instead: 

public class DataLoader {

    private static final Set<DemoDataItem> items = new HashSet<DemoDataItem>();

    public static Set<DemoDataItem> getData(List<File> files) {
        items.clear();
        for (File file : files) {
            try {
                String asText = FileUtil.toFileObject(file).asText();
                String pattern = "title: [A-Za-z]+";
                Pattern p = Pattern.compile(pattern);
                Matcher matcher = p.matcher(asText);
                if (matcher.find()) {
                    String formattedText = matcher.group().replace("title: ", "kendo");
                    items.add(new DemoDataItem(formattedText, null, escapeHTML(asText), null));
                }
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
        return items;
    }

    //http://stackoverflow.com/questions/9580684/how-to-retrieve-title-of-a-html-with-the-help-of-htmleditorkit
    public static String escapeHTML(String s) {
        StringBuilder out = new StringBuilder(Math.max(16, s.length()));
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
                out.append("&#");
                out.append((int) c);
                out.append(';');
            } else {
                out.append(c);
            }
        }
        String addBreak = out.toString().replace("\n", "<br />\n");;
        return addBreak;
    }

}

Adam Bien - June 21, 2015 05:18 AM
The Difference Between SOA and Microservices Architectures

SOA was not about SOAP and microservices are not about REST.

In theory there is no difference. The SOA definition could be also applied to microservices architecture as well:

"Services are unassociated, loosely coupled units of functionality that are self-contained. Each service implements at least one action, such as submitting an online application for an account, retrieving an online bank statement or modifying an online booking or airline ticket order." [SOA definition from wikipedia]

Also a microservice architecture could be challenged (often killed) with the same questions as a SOA.

In practice SOA was applied to expose, reuse and expose business services at enterprise level. Microservice architectures are used to structure individual applications. Because it is easier to control a single application than a whole enterprise, microservices are less ambitious and more pragmatic.

See you at Java EE Workshops at MUC Airport, particularly at the Java EE Architectures workshop!


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 20, 2015 09:48 PM
Code Completion Context for JavaScript Editors

You don't want the items in your code completion box extension to appear regardless of context. For example, Kendo UI components should only appear in the code completion box after the dot in this kind of structure:

For that reason, the org.netbeans.modules.javascript2.editor.spi.CompletionContext class exists.

It provides String constants that you can use to limit the appearance of your items to the context to which they apply.

Usage is simple. For example, look at the code in bold below. That's all I needed to do to cause the Kendo UI components that you see above to appear only in the place in the statement that you see above.

@Override
public List<CompletionProposal> complete(
        CodeCompletionContext ccContext,
        CompletionContext jsCompletionContext,
        String string) {
    if (jsCompletionContext != CompletionContext.OBJECT_PROPERTY) {
        return Collections.EMPTY_LIST;
    }
    List<CompletionProposal> result = new ArrayList<CompletionProposal>();
    Set<DemoDataItem> data = getData();
    for (DemoDataItem item : data) {
        result.add(DemoCompletionProposal.createDemoItem(item, 0));
    }
    return result;
}

In the next example, I want the Kendo UI options to appear for the related Kendo UI component and only within the braces of the statement, as shown below. Getting directly into the braces is a bit more work, but changing the code above to CompletionContext.OBJECT_PROPERTY_NAME is the starting point for getting the items within the code completion box only within the parentheses.

For a good example, take a look at the switch statement in this piece of code by Tim Boudreau.

The richness of these APIs holds the tremendous promise for NetBeans to be the meeting point of all imaginable JavaScript frameworks and libraries.

Geertjan's Blog - June 19, 2015 08:34 PM
How To Make Your Own JavaScript Editor

Code completion is the key feature you need when adding support for your own JavaScript framework to NetBeans IDE.

Above you see a new item I added by means of a simple starting point, which starts like this:

package org.demo;

import java.util.ArrayList;
import java.util.List;
import org.netbeans.modules.csl.api.CodeCompletionContext;
import org.netbeans.modules.csl.api.CompletionProposal;
import org.netbeans.modules.csl.api.ElementHandle;
import org.netbeans.modules.csl.spi.ParserResult;
import org.netbeans.modules.javascript2.editor.spi.CompletionContext;
import org.netbeans.modules.javascript2.editor.spi.CompletionProvider;

@CompletionProvider.Registration(priority = 20)
public class DemoCompletionProvider implements CompletionProvider {

    @Override
    public List<CompletionProposal> complete(
            CodeCompletionContext ccc, 
            CompletionContext cc, 
            String string) {
        List<CompletionProposal> result = 
                new ArrayList<CompletionProposal>();
        DemoDataItem ddi = new DemoDataItem("a", "b", "c", "d");
        result.add(DemoCompletionProposal.createDemoItem(ddi, 0));
        return result;
    }

    @Override
    public String getHelpDocumentation(
            ParserResult pr, 
            ElementHandle eh) {
        return "help documentation";
    }
        
}

Here is where the full code sample, i.e., a basis for your own new extension to code completion in the JavaScript editor in NetBeans, can be found:

https://github.com/GeertjanWielenga/DemoJSEditorExtension

Geertjan's Blog - June 18, 2015 12:25 PM
Kendo UI in NetBeans IDE

Johan Borchers, from KPMG Crimsonwing in the Netherlands, was one of the people at the Blue4IT event where I talked about the JavaScript landscape. He mentioned that the only tools he's found for Kendo UI Core, his favorite JavaScript toolkit, is Visual Studio:

Here you can see there's code completion in Visual Studio for Kendo UI components, together with documentation showing you the options you can add to the argument object.

Displaying the classes in code completion (i.e., IntelliSense) in NetBeans is already supported, if you check out the sources of Kendo UI from its Git repository and put them into your HTML5 project in NetBeans. NetBeans will then detect the sources that you have added, which you can of course exclude from your Git commits, and then display relevant proposals in the code completion box:


However, I'm also working on a plugin that shows, context sensitively, the options available for the current Kendo UI component. Here you see what happens when I call up code completion for KendoCalendar:

And here, to show you that each Kendo UI component is supported via its own set of options in code completion, is what you'll see for KendoAutoComplete:


How it works is that the plugin will contain all the documents from the Kendo site, such as this one:

https://github.com/telerik/kendo-ui-core/blob/master/docs/api/javascript/ui/calendar.md

These are then parsed and integrated into the code completion box in NetBeans. In other words, all the code completion and related documentation will come from the Kendo UI site, i.e., they will be copied into the NetBeans module and used from there. Indeed, if they change on-line, there'll be no way of knowing that, plus the authors of those documents possibly don't treat them completely as an API, which is how I am treating them. Unfortunately, I don't see a better way of doing this.

I'm not parsing completely correctly yet, hence some of the options are clearly missing from the two screenshots above. Once  everything is working as it should, the documents will be read from the layer.xml file, meaning that anyone will be able to add new ones to their user directory and NetBeans will automatically pick it up, e.g., when a new Kendo UI component is made available, together with its documentation.

Soon the first draft of the plugin should be available and it will be developed on GitHub, so anyone out there is free to join in:

https://github.com/GeertjanWielenga/KendoNetBeans

Adam Bien - June 18, 2015 12:23 PM
With POJOs To XML And Back With JAXB

JAXB comes out-of-the-box with JDK and makes it trivial to write and read POJOs from XML:

The entire enhydrator configuration (Pipeline) is persisted with JAXB.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 17, 2015 07:15 AM
"Everything a Java developer should know about the JavaScript landscape"

For a few months I've been working on a presentation aimed at Java developers, to introduce them to the brave new world of JavaScript, not JavaScript the language, but JavaScript the constantly changing ecosystem.Why? Because this topic is something of relevance to the Java community and it's an interesting area to look at. It makes sense to examine the JavaScript ecosystem and to evaluate the extent to which its current popularity is a trend or a hype and what Java developers can do with it and maybe benefit from it in the context of their existing Java applications, too.

The story starts by looking at new enhancements in HTML (thanks to HTML5) and CSS (thanks to CSS3) and then in more detail at all the different kinds of JavaScript solutions (core libraries, build tools, application frameworks, testing frameworks, and component suites) that a Java developer should be aware of when beginning to get their toes wet with JavaScript. After that, a brief look at various kinds of transpilers, e.g., CoffeeScript, TypeScript, Dart, GWT, Vaadin, and DukeScript. Yesterday I presented that story for the first time, at a session organized in Bodegraven in the Netherlands by Blue4IT, a great organization (always on the lookout for new local developers to hire) which recently hosted Adam Bien and will be hosting Martijn Verburg in October.

The demonstrations done during the session:

  • HTML5 as an 'application framework' via new elements and attributes, see the HTML5 Fun Pack.
  • Responsive CSS via media queries vs. Responsive JavaScript via Response.js and Foundation.js.
  • Monolithic vs Modular via Require.js, using these examples.
  • AngularJS, Knockout.js, and Backbone.js.
  • Java EE backend with JavaScript fronted, via RESTful Web Services.
  • Solid Knockout, a Knockout/Require.js template for JavaScript enterprise apps.
  • DukeScript, enabling UIs in HTML and business logic in Java instead of JavaScript.

The feedback was pretty positive. What surprised me the most was that Java developers, at least in this session, were not necessarily doing everything they could to avoid coding in JavaScript, i.e., even though it is loosely typed and has all kinds of problems, developers appeared to be quite excited about working with a new language and a new ecosystem. Several have already been crossing over to JavaScript and, sure, despite that there are problems with it, all ecosystems have problems of one kind or another, though everyone is always interested in using the technologies that are new and popular.

In particular, AngularJS is something everyone wants to start doing things with, to the extent that they haven't already, simply because there's so much buzz around it. I tried to make the case for a few alternative solutions, especially Knockout.js, since I do believe it allows for a more flexible architecture than that enforced by AngularJS. I presented DukeScript as a credible solution for those who want to continue coding in Java and it did feel like a lot of people were interested in the notion of JavaScript as an assembly language, i.e., something that the browser needs but that no developer should need/want to touch. Nevertheless, it feels to me that the new and cool technologies that run in the browser, i.e., all these various cool JavaScript frameworks, are going to win simply because there's so much energy around them and even the most hardcore Java developers don't have a problem at all in changing their toolbox, including their language, every few years or so. JavaScript is new and fun and there are not many hardcore dogmatic Java developers who would reject it out of some kind of principled objection to anything that isn't Java.

Of course, and this is the basic underlying principle to all of this, the tools and technologies you choose depend on the kinds of business requirements you have. If you're going to be creating an air traffic control system that should remain functional for the next 10 years and be operated by 6 users in a control tower, obviously you're not going to use JavaScript and the browser. However, if you're going to create a SPA primarily targeted at desktop browsers, tablets, and mobile devices, all at the same time, then the JavaScript ecosystem is the most obvious candidate for implementing your requirements. 

Anyway, let's see what happens in the coming years. There certainly is more than enough choice out there, that's for sure. 

Note: Happy to do this presentation again to any organization interested in getting a thorough overview of all the things going on in the JavaScript ecosystem.

Geertjan's Blog - June 16, 2015 07:00 AM
HTML Fun Pack on JAXEnter.de

Read all the new HTML5 component palette snippets for NetBeans IDE here in German:

Geertjan's Blog - June 15, 2015 01:43 PM
Angular vs Knockout...

Angular vs. Knockout according to this article:


Angular vs. Knockout according to this article:


Hmmm. The first says that Angular is "much better suited for large, complex enterprise applications", while the second says that it is "a great choice for small projects".

Awesome. Love it when evaluations are do diametrically opposed to each other.

Adam Bien - June 15, 2015 11:34 AM
Enhydrator--Type Conversions and Filtering With Nashorn

In the first, introductory, part of the enhydrator screencast I imported a raw CSV file and converted it into in-memory table structure.

This screencast explains how to convert datatypes of columns values and how to filter them with nashorn (JavaScript).

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.


Real World Java EE Workshops [Airport Munich]>

APIDesign - Blogs - June 15, 2015 09:21 AM
Enforcing Proper API Usage by Law

Enforcing proper usage of an API is hard. One needs to strive for clarity, one can invent engineering solutions to the problem, but at the end clever hacker always find a way around it. But there is a cure: Let's choose our licenses wisely and scare the hackers with legal actions!

At the end it could also solve the famous sun.misc.Unsafe issue...

--JaroslavTulach 09:21, 15 June 2015 (UTC)

NetBeans Zone - The social network for developers - June 14, 2015 11:39 AM
Agenda: NetBeans Day Brasil 2015

The agenda for NetBeans Day Brasil, to be held on June 22, has been completed and looks as follows. All the sessions, except those by Geertjan Wielenga, will be in Brazilian Portuguese! Preview Text:  The agenda for NetBeans Day Brasil, with great speakers and sessions is ready! Legacy Sponsored:  ...

NetBeans Zone - The social network for developers - June 13, 2015 09:41 AM
David Bolsover: My Five Favorite NetBeans IDE Features!

Continuing a series of articles focusing on NetBeans users and their five favorite NetBeans IDE features, here's the next part, by David Bolsover. -- NetBeans team. Preview Text:  David Bolsover from Manchester in the UK describes why he particularly likes the NetBeans tools for working with databases, as well as Java editor tools such...

Geertjan's Blog - June 12, 2015 07:00 AM
Learning Resources for Require.js

Here you see two web apps, the first is "ModularSales" and the second is "SimpleSales":

The first uses Require.js for modularity, while the other does not.

These are two handy samples to play with to get to understand the basics of RequireJS.

Get them here:

https://github.com/GeertjanWielenga/RequireJSSamples

And watch the YouTube screencast to understand the code and the reasons for using RequireJS:

https://www.youtube.com/watch?v=v4jnTWFihMU

A related blog entry:

https://blogs.oracle.com/geertjan/entry/requirejs_javascript_for_the_enterprise