Č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)
richunger's blog (feed)
APIDesign - Blogs (feed)
pandaconstantin's blog (feed)
hansmuller's blog (feed)
pkeegan's blog (feed)
tball's blog (feed)
ludo's blog (feed)
timboudreau's blog (feed)
Carsten Zerbst's Weblog (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)
Bernhard's Weblog (feed)
Michel Graciano's Weblog (feed)
Ramon.Ramos (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 04, 2015 10:06 PM
All times are UTC

Sponsored by
sponsored by Oracle

visit NetBeans website
Michael's blog » NetBeans - July 04, 2015 10:04 PM
NetBeans and Java EE: code navigation

NetBeans offers some shortcuts for code navigation. Click the mouse pointer onto a method name (or focus the name by keyboard) and press Alt-F7. This finds all usages of this method. Focus the usage of any method and press Ctrl-B … Weiterlesen

NetBeans Zone - The social network for developers - July 03, 2015 08:32 AM
Rahul Saha: 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 Rahul Saha. -- NetBeans team.

Geertjan's Blog - July 03, 2015 07:00 AM
Quo Vadis Enterprise JavaScript?

In this shaky new world of JavaScript, here are the libraries I find to be very interesting:

When creating enterprise JavaScript applications, i.e., applications that are scalable and that need to be flexible and responsive, a combination of the above solutions could result in a maintainable application based on solid principles.

Here's an application I've been working on that combines some of the above, though I'm adding more of them over time:

https://github.com/GeertjanWielenga/SolidKnockout/

The alternative to the above stack is AngularJS, which I think is a great solution if you buy into the entire philosophy of AngularJS. It's the "put all your eggs in one basket" approach vs. the "hey, let me build my own stack for my own needs" approach. It's also the "library vs. framework" debate. These debates have been going on forever. But, I think, in the JavaScript ecosystem, right now, this is pretty much where things stand.

Adam Bien - July 03, 2015 02:58 AM
More Questions Than Ever: The 16th Airhacks Live Questions And Answers

Questions for the 16th airhacks.tv at July, 6th 2015 at 6.PM. CET: http://www.ustream.tv/channel/adambien (no reqistrations, no obligations, just ask questions and watch :-)):

  1. Do you see JavaScript frameworks in your work yet? Do you see MVVM becoming popular? [Michael K.]

  2. You mentioned in an earlier video the BCE package structure. For business-cases, this is really straight forward and a good structure.

    But there are many concerns, which does not really fit in this structure (sort of cross-concern), and because of this I have the question: Where to put the following concerns/classes:

    ResourceLocator (für REST-SubResources) bzw. AbstractResources

    (for functionality, which every resource needs (like @Context definitions))

    DateUtil? / MailService?

    AbstractEntity

    ApplicationConfiguration/JaxRSConfig

    REST-Adapter/Interceptoren/Filter/Mapper

    Tracing mit LoggerExposer?

    ValidationController / Validation-Annotations (which do not belong

    to a concrete domain-object, but is rather used for any validation) [Ulrich C.]

  3. Is it ok to use DTO in a REST-method for request/response-payload?

    I would argue, that the DTO for the REST-method would separate the domain from a technical interface (REST). In addition, there is the possibility to version the interface (DTO) independently from the domain objects. Furthermore, there are some properties, which needs to be send via REST-interface, which are not needed in the domain objects. [Ulrich C.]

  4. I’m 21 years old , and i’m at 3rd year studying Computer Science. At the moment i’m creating some apps in Java and more specially in Android , i like the server side applications too.

    What i have seen so far is that Java is very powerful but we must always look at future.

    By that i mean C# with mono-project.com you can write the truly write once run everywhere that Java tried to offer.

    So i’m asking the Java guru if i should change to C# ?

    Also one more question , for next month’s Q&A : How annotations are useful ? Explain few of them.

    Thanks in advance and sorry for your time. [Giorgos]

  5. I have long been a fan of JDO and welcomed JPA. Using annotations it is very easy to persist objects. However, there are very few examples to be found about how to persist third-party objects (assuming said objects provide getters and setters that will not change). I am thinking that using a wrapper around the objects would be one way to go, but I would like to hear how you would approach this. An example would be great, too. [Eddy]

  6. Which cdi annotations are available in jsp? I want to use conversations coped to design wizard form. TY @8indaas

  7. Where would you put interceptors ?

    By definition they are “cross-cutting”.

    In the project I am currently doing I have the boundary, control and entity packages for each business “component”. Because of the cross-cutting nature of interceptors I created a fourth package currently named “interceptors”. I know ! That’s technical like “ejb” and “jsf” ! I thought about putting it in a control package. But the control package of which business component ? Just choosing at random a component seems contrary to the “cross-cutting” nature of interceptors. It would also introduce unwanted dependencies at the component
    level. Your insight on this would be much appreciated.

    Ronald

  8. could you please show how to Unit-test a boundary utilizing other @Stateless and @Inject (CDI) objects? What exactly do i need to test it fastly without having Arquillian in place?A simple example would be very helpful. Karsten

  9. Is there a way to have dynamic finders in JPA like Grails or Rails? Any plans to include this feature on the new MVC framework? Antonio

  10. What’s your reaction to this post from Juergen Hoeller: http://spring.io/blog/2015/06/04/happy-second-birthday-java-ee–7-how-is-it-going-in-production Remko

  11. This one might be a little off topic but I figured its worth a try asking. How do you go about setting up a datasource in wildfly that talks to a mysql server via ssl. I have the mysql server’s cert as well as a client key/cert combo. Brett

  12. I have question related to cooperation with JavaScript in one war. I would like to make a simple app using AngularJS but the structure of this project not directly match to the maven project so I found that I can use yeoman-maven-plugin and everything started work fine but then maven build takes too much time. I think that my approach is a little bit too much complicated :) So can you tell me how you do this, I will be grateful. Sebastian

  13. I have one more question. How to test two microservices where one communicates with the second.via REST. Exactly I wonder which interfaces should I mocked. Right now (we don’t have exactly microesrvices :)) I test both applications separately. Is it enough? Someone can for example change interface - I know that this is a strange reason but can happen :) Sebastian

  14. Question 1 : is it possible build web application MVC1 ( ozark ) with JAVAEE7 ? is it enough matured currently for large scale web application ?

    Question 2 : in JPA based app. I am facing some problem in

    em.mergeI().—————— transaction related problem.

    to overcome this problem i am use em.createNativeQuery (“update into”).

    please give comments : is it recommend write way ?

    Question 3 : what is the best practice primary key generation for large scale financial application ? (for jpa)

    a) auto-increment / not auto-increment ?

    b) table / sequence strategy ?

    Question 4 : how to do audit in JPA ? masumcse1

  15. Could you suggest how to organize CI process with jenkins and docker. I have a set of the java ee apps and for each of them I configured docker. So, I want to use jenkins to run integration tests and then rebuild image and rerun container for each application.

    As I understood the most straightforward way is to use separate VM for CI with preinstalled docker and jenkins on localhost. So, Jenkins tracks changes, updates source, then runs IT via maven and then reruns containers on localhost.

    But docker has official image for jenkins and I remember that you use it. If you run jenkins in docker container, how do you organize access to parent host for running IT, rerunning containers with apps? Or do you use docker in docker approach? Here is an example https://github.com/jpetazzo/dind Or maybe another way …. I’m really confused :) Andrii

  16. Can you provide an example of how to send text to cell phone from web application? Some sites provide an authorization code to cell phone as part of authentication. Patrick

  17. When using bce and jsf where do you place your backing beans? team4rk

Any questions left? Write a comment, edit: https://gist.github.com/AdamBien/ee8565840092cc7f39ab or ask live: https://twitter.com/AdamBien.

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 - July 02, 2015 08:59 PM
NetBeans and Java EE

NetBeans [1] is a free IDE, which originally focused on Java. Thinking of web development, the developer also needs to deal at least with CSS, HTML and JavaScript. Thinking of the JVM, there are Clojure, Groovy, Scala and others. NetBeans … Weiterlesen

Adam Bien - July 02, 2015 10:24 AM
From javax.json.JsonObject To byte[] And Back

Enjoy self-explanatory, Java EE 7 code :-):


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.JsonWriter;

//...
   JsonObject deserialize(byte[] content) throws IOException {
        try (ByteArrayInputStream bais = new ByteArrayInputStream(content);
             JsonReader reader = Json.createReader(bais)) {
            return reader.readObject();
        }
    }

  byte[] serialize(JsonObject object) throws IOException {
        try (ByteArrayOutputStream oos = new ByteArrayOutputStream(); 
		     JsonWriter writer = Json.createWriter(oos)) {
            writer.writeObject(object);
            writer.close();
            oos.flush();
            return oos.toByteArray();
        }
    }


//...

    @Test
    public void reserialize() throws IOException {
        JsonObject expected = Json.createObjectBuilder().
                add("name", "duke").
                build();
        byte[] serialized = serialize(expected);
        JsonObject actual = deserialize(serialized);
        assertNotSame(actual, expected);
        assertThat(actual, is(expected));
    }

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 - July 02, 2015 10:00 AM
Five Reasons to Apply for the NASA Java Opportunity

I mentioned the new job at a.i. solutions here yesterday. Sean Phillips, the great guy and NetBeans Dream Team member and author and many other things, you'll be working with, gave me the following 5 reasons for taking up the gauntlet and applying for the job!

  1. a.i. solutions provides Flight Dynamics and Launch Service Support to a large cross-section NASA and USAF centers and missions.

  2. Engineers at a.i. solutions are presented with a variety of space flight missions including LEO and International Space Station operations, Debris detection and collision avoidance and even Deep Space mission design.

  3. Software Engineers are given a significant degree of creative freedom to architect overall software designs while working directly with the country's top Space Flight Dynamics experts.

  4. The James Webb Space Telescope Flight Dynamics Ground System (JWST FDGS) ConOps integrates a variety of high fidelity modeling and simulation tools.

  5. The JWST FDGS faces design challenges including Parallelization, Big Data and custom Data Visualization.  The software engineers will be depended on to identify and apply the best software technologies to meet these challenges.   

And, need I say more, you'll be working on awesome Duke's Choice Award winning NetBeans Platform based network satellite software like this:

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.

Geertjan's Blog - July 01, 2015 07:00 AM
Get Paid to Work for NASA with Java and NetBeans

Quite possibly the coolest job in the world for Java developers, with US citizenship, ideally with NetBeans Platform experience:

I love this bullet in particular up there: "Participate in inter-disciplinary teams to design and develop systems capable of supporting real-time satellite flight operations." That sounds amazing. :-) 

And if you're reading the above while thinking "Hmmm. I wonder what JWST means?" Then you should definitely take a look at this:

http://www.jwst.nasa.gov

All the job details are here: https://rew12.ultipro.com/AIS1000/JobBoard/JobDetails.aspx?__ID=*A8E0B5D35817721B

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 videos 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.

Geertjan's Blog - June 30, 2015 07:00 AM
YouTube: NetBeans at JavaOne Brazil

During JavaOne Brazil last week, I made two short screencasts and published them on YouTube. They're both interviews, both with someone saying nice things about NetBeans!

Here's more from Diego in a blog entry: http://www.diegomagalhaes.com/netbeans-experience-revisited/

Watch more NetBeans videos here: https://www.youtube.com/user/NetBeansVideos

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 29, 2015 07:00 AM
YouTube: New Praxis LIVE Screencasts

One of the great people I met at NetBeans Day UK was Neil C. Smith, who is the developer behind the brilliant Praxis LIVE (@PraxisLIVE) project, the hybrid visual IDE for live visual coding.

Here's two screencasts he made about Praxis LIVE, recently, based on the demos he did at NetBeans Day UK.

Pretty amazing what can be done with the NetBeans Platform...

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