Č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)
APIDesign - Blogs (feed)
Pandaconstantin (feed)
blogtrader - Blog (feed)
Carsten Zerbst's Weblog (feed)
Winston Prakash's Weblog (feed)
Anchialas' Java Blog (feed)
markiewb's blog (feed)
Michael's blog » NetBeans (feed)
Gualtiero Testa » Netbeans (feed)
James Selvakumar's Blog » netbeans (feed)
nB gUru » NetBeans (feed)
Newsintegrator Blog » netbeans (feed)
Praxis LIVE » NetBeans (feed)
ProNetBeans (feed)
TechAshram » NetBeans (feed)
There's no place like 127.0.0.1 » Netbeans (feed)
Paulo Canedo » NetBeans English (feed)
Need to find a title (feed)
Category: NetBeans | Software and Science (feed)
Roger Searjeant's blog (feed)
Optonline Webmail (feed)
Allan Lykke Christensen » NetBeans (feed)
Inspiration and Expression » Netbeans (feed)
John O'Conner » NetBeans (feed)
Adam Bien (feed)
Ignacio Sánchez Ginés » NetBeans (feed)
Michel Graciano's Weblog (feed)
Ramon.Ramos (feed)
Ozone and Programming » netbeans (feed)
NetBeans Ruminations » NetBeans (feed)
Tiplite » netbeans (feed)
Bistro! 2.0 (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)
mkleint (feed)
Anuradha (feed)
Netbeans6/6.5 my best practices (feed)
Java Evangelist John Yeary's Blog (feed)
Neil's Dev Stuff (feed)
Computer says null; (feed)
NetBeans Adventures, Java and more (feed)
Bernhard's Weblog (feed)
NetBeans Community Docs Blog (feed)
The Netbeans Experience (feed)
NbPython/ jpydbg / pymvs (feed)
Wade Chandler's Programming Blog (feed)
Big Al's Blog (feed)
Code Snakes (feed)
In perfect (spherical) shape (feed)
Van Couvering Is Not a Verb (feed)
Diego Torres Milano's blog (feed)
Vroom Framework (feed)
Messages from mrhaki (feed)
Jeff's Blog (feed)
Manikantan's Netbeans (feed)
Oliver Wahlen's Blog (feed)
Shuttle between Galaxies (feed)
Shanbag's Blog (ರಜತ ಲೋಕ) (feed)
Welcome to my live... (feed)
Netbeans IDE Blog by Tushar Joshi, Nagpur (feed)
Devel Blog (feed)
diamond-powder (feed)
Antonio's blog (feed)
Where's my Blog?!

Powered by:    Planet

Last updated:
September 01, 2014 10:06 PM
All times are UTC

Sponsored by
sponsored by Oracle

visit NetBeans website
Geertjan's Blog - September 01, 2014 09:13 PM
New Toshiba Tecra Laptop

Weird how as soon as you have a new laptop, the old faithful one that stood by you throughout the past 5 years looks and feels like a brick that could only ever have been useful as a doorstop. (Then again, how faithful was it, breaking down in the middle of important presentations and constantly making its presence felt with loud whining chunky noises not unlike your broken washing machine.) But here it is, my new laptop, a Toshiba Tecra. Ultra light, definitely smaller than the previous one, which is what I thought when I got the previous one, so in 5 years time I'm sure the new ones at that point will be weightless or probably negative weight.

Here's NetBeans IDE on my new latop, click to enlarge it to get the full impression. 

Aside from a bunch of usual suspects (e.g., Thunderbird, Pidgin, FireFox) that the Oracle preinstallation environment automatically installed, I added the following within the first few hours of setting up my new laptop:

  • The PHP/HTML Distribution of NetBeans IDE Dev (see it above).
  • Camtasia
  • SnagIt
  • Chrome
  • Git
  • Node
  • Bower

Now. the aim is to keep this particular laptop as free of garbage and junk as possible so that screencasts and demos can be super fast and not hindered by weird stuff installed by accident or heaps of photos or something like that.

I'm also not going to do what I did with previous laptops, i.e., immediately uninstall Windows and then install the latest Ubuntu distro. Ubuntu is on my old laptop and I'll use it there. On this particular laptop, things are going to be as simplistic and as uniform and as minimal as can possibly be imagined. No dual boot either.

Here's to good intentions.

NetBeans Zone - The social network for developers - September 01, 2014 06:23 AM
Abhideep Chakravarty: 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 Abhideep Chakravarty. -- NetBeans team.My name is Abhideep Chakravarty, I work for MindTree, and I have been using NetBeans since its 4.5 release, many years ago. I even have an original NetBeans 5.5 CD. Preview Text:  ...

Adam Bien - August 31, 2014 04:21 PM
Opinionated JavaFX 8--virtualJUG Session

Opinionated Java FX applications, behind the scenes of afterburner.fx and walk through the floyd at virtualjug.

Thanks http://virtualjug.com for the invitation!

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


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - August 30, 2014 08:28 PM
Lazybones Meets NetBeans (Part 1)

One of the things I learned about at JCrete is Lazybones, which is a command-line tool, similar to what Grails, Gradle, and Play provide, for bootstrapping new projects.

In particular, Andres Almiray (@aalmiray) is interested in seeing a NetBeans plugin for Lazybones. The starting point for creating such a plugin is to install Lazybones and run it from the command-line, to make sure everything is set up correctly. Once you've done that, the next step is to call the Lazybones command from within NetBeans IDE, i.e., using NetBeans APIs to do so.

Here's how.

import java.io.File;
import org.netbeans.api.extexecution.ExecutionDescriptor;
import org.netbeans.api.extexecution.ExecutionService;
import org.netbeans.api.extexecution.ExternalProcessBuilder;

public class LNBUtils {

    public static void command(String name) {
        ExecutionDescriptor executionDescriptor = new ExecutionDescriptor().
                frontWindow(true).
                controllable(true).
                showProgress(true);
        File userdir = new File(System.getProperty("netbeans.user"));
        ExternalProcessBuilder externalProcessBuilder = new ExternalProcessBuilder("lazybones").
                workingDirectory(userdir).
                addArgument("create").
                addArgument("ratpack-lite").
                addArgument(name);
        ExecutionService service = ExecutionService.newService(
                externalProcessBuilder,
                executionDescriptor,
                "lazybones create ratpack-lite" + name
        );
        service.run();
    }

}

The above has all the commands hard coded. That's a starting point. Later we'll create a wizard so the user can fill in the values and start the process of creating the selected template.

For starters, here's an ActionListener, registered to appear in the File menu, for invoking the above code:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;

@ActionID(
        category = "File",
        id = "org.netbeans.lnb.RunLazybones"
)
@ActionRegistration(
        asynchronous = true,
        displayName = "#CTL_RunLazybones"
)
@ActionReference(path = "Menu/File", position = 0)
@Messages("CTL_RunLazybones=Run Lazybones")
public final class RunLazybones implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        String name = "my-rat-app-1";
        LNBUtils.command(name);
    }

}

The result is shown in the Output window:


In the next blog entry in this series, we'll hook the above code into a wizard so the user can fill in the values and start the process of creating new Lazybones projects from a more complex GUI than the menu item defined above.

Want to contribute or follow the project as it develops? Go here:

https://java.net/projects/nb-api-samples/sources/api-samples/show/versions/8.0/LazyNetBeansBones

Adam Bien - August 30, 2014 04:57 AM
My JavaOne 2014 Sessions: JavaFX, Nashorn and Unorthodox Practices

  1. Session ID: UGF8872 Session Title: Free Java Tools for Maven and Java EE Venue / Room: Moscone South - 200 Date and Time: 9/28/14, 11:00 - 11:45
  2. Session ID: CON2265 Session Title: Productive JavaFX 8 Venue / Room: Hilton - Plaza A Date and Time: 9/30/14, 16:00 - 17:00
  3. Session ID: CON2301 Session Title: Unorthodox Enterprise Practices Venue / Room: Parc 55 - Cyril Magnin II/III Date and Time: 10/1/14, 10:00 - 11:00
  4. Session ID: CON2131 Session Title: Java EE 8 Community Update and Panel Venue / Room: Parc 55 - Cyril Magnin II/III Date and Time: 10/2/14, 11:30 - 12:30
  5. Session ID: CON2266 Session Title: Enterprise Nashorn Venue / Room: Parc 55 - Cyril Magnin II/III Date and Time: 10/2/14, 14:30 - 15:30

See you at JavaOne in San Francisco, Munich: http://airhacks.com, or each first Monday of the month at 6 P.M CET live: http://airhacks.io


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - August 29, 2014 09:46 PM
JCrete 2014

When you go to any kind of conference, specifically a software programming conference, even more specifically a Java conference, you hold certain truths to be self-evident. For example, there'll be a program, there'll be organizers, there'll be rooms, there'll be chairs. There'll be a ceiling.

Well, no such thing, necessarily, at JCrete, an invitation-only annual conference, held for the 4th time, during this week, that strives to invite around 70 people in total. (Nice and small and intimate, and if it were any larger, the process described in the next paragraphs wouldn't work.) It's the best conference I have attended in, like, well, ever. On the day the conference starts, everyone gets a stack of empty yellow post-its and a pen. Then everyone thinks about two or three topics they'd like to hear or talk about and they all write those topics on their post-its, e.g., "Talking about lambdas: patterns and anti-patterns" or "Docker, Vagrant, Packer" or "What's your documentation process like?" or "Which tools do you use?" or "Programming is hard". And then everyone gets up one by one and introduces their topics to the group, enabling everyone to quickly jot down the name of topics that sound interesting, and then sticks the post-its on the "launch pad", i.e., a big piece of paper on the wall.

After everyone has introduced their topics, the process of moving the post-its into a schedule starts. First, some clusters are created, e.g., some topics are similar to other topics. The organizers, i.e., the 'disorganizers', lead this process of clustering and arranging topics in a schedule, though everyone is in full control over where in the schedule their topics will be convened.

The schedule consists of three sessions per day, in the morning, in four different tracks. (Each track is more like a slot, since sessions within a track don't necessarily have anything to do with each other, i.e., there's no Java EE track, instead, there's simply track 1, 2, 3, and 4.) That way, everyone can spend the afternoon at the beach, which is a big plus of Crete. Each session is convened by whoever submitted the post-it bearing the topic. But the convener sits in the session just like any other attendee. For example, just because you submitted "Docker, Vagrant, Packer" doesn't mean that you know anything about those technologies. It just means you might have some half-formed ideas about what they are and how they relate. The main thing is that you're interested in finding out about them and would like others to share their bits of knowledge with you and the rest. The blind leading the blind? Maybe. But remember that JCrete is invitation-only, meaning that many of the attendees have been invited precisely because they're experts in areas that are likely to be interesting, plus that in any of the sessions you'll find that when you combine everyone's half-sightedness you end up with more insight than you would have gained by sitting in a traditional session, no matter how good that traditional session is. Of all the sessions, even the most awesome ones, I've ever attended at other conferences, there's nothing (as in Really, Not One Thing) I remember at this stage, though I'm sure I'll remember the key points attained as a group within the JCrete sessions because I didn't sit passively in any of them. I was engaged and involved and any knowledge acquired wasn't handed to me but was built up throughout the session from the collective knowledge of whoever the people were that were in the session with me. The best sessions turn out to be those where the group is small (while in traditional sessions low attendance means you or your topic must suck somehow, OK sure it's a niche topic and you're really special and it's for smart people and everyone is at the Scala session and so on, and from the very beginning of your talk a grim sense of gloom and dejection hangs over you and everyone else who made the mistake to attend, scattered in odd clumps of one here, another there, and someone else way off in the back edging his way out, and it is more or less impossible to leave because then the speaker, with frail timid voice echoing in large sparsely populated room, might well start crying, hey I'm not mocking anyone, I've been that guy), so everyone gets to talk and the most knowledgeable attendees don't dominate things.

You know how the best part of any conference is the time you spend in the conference corridors, bumping into new and old friends? And how the worst part is when you're sitting in a session, realizing that for any number of different reasons you'd rather be in the corridor? Well, imagine you're in the corridor from start to end and you'll understand how cool JCrete is. Forget about being disappointed about the speaker's (lack of) knowledge or (in)ability to express their thoughts, and then being stuck with them for an excruciating hour, since in JCrete sessions everyone is the speaker, everyone participates, everyone simply chats and no one feels intimidated or stupid. Any question can be stated in as half-baked a form as you like, and is taken seriously by everyone and then mulled over, since questions arise naturally throughout the session no one needs to ask at the end whether there are any questions, nor look awkward when clearly no one cares enough to engage, while every moment is as valuable as you the attendee/speaker enables it to be. 

All separation and division falls away, including the day/night separation, as you find yourself hacking with random people late at night, while others discuss stuff in spontaneous groups, everyone with drinks and very informal. 

But the best sessions of all are the ones in the car on the way to the beach (some beaches are an hour away, so you're in a car with 4 others, and so you're chatting for an hour, i.e., hey that's another session), the ones spent in the sea, and the ones that take place at the dinner table over wine and raki. (For regular traditional conference attendees, consider the thought that every dinner is 'speakers dinner', i.e., no exclusion and no separation between speakers/attendees because everyone is there to speak and everyone is there to attend.) And that is exactly why there are only three sessions (in 4 tracks, i.e., each session you make a choice out of 4 different topics) per day, mostly before lunch, except when an excursion is so interesting it trumps the sessions. The rest of the day springs forth from car-based, sea-based, and dinner-based sessions. These sessions arise spontaneously, such as about the qualities and purpose of olive oil, the main export product of Crete, which, though such topics might have nothing to do with programming, initially, always somehow end up being about programming by the end of it, yes, certainly aided by wine and raki. 


And you know the feeling you have at the end of traditional sessions, when you walk out of a room full of people who must have the same interest as you, otherwise why would they be at the same session as you, but none of whom you had the opportunity to actually talk with? That empty feeling of "wow, a room full of people who are also interested in Java performance, some of them must be experts, all of them must have experiences to share, yet I've spent the past hour listening to one selfinflated illinformed slidebased dude drone on and on about very basic stuff that surely most attendees must have known already when they walked into the room an hour ago"? Or how about that feeling of "wow, within 5 minutes the dude went from uselessly simplistic 'hello world' to massively complex rocket science and I have no idea whatsoever how he did that and I've lost the plot completely within 10 minutes, I must really be a complete idiot because everyone else around me appears to be following along fine with their eyes wide open but that could be because they're proactive and surreptitiously taped up their eyelids which I'd do too if I'd brought tape, which makes me even more of an idiot for not thinking to bring tape". No chance of that when you're at JCrete! 

One of the dozens of takeaways I am left with at the end of JCrete is that next year's NetBeans Day should definitely be an unconference too. (And maybe JUGs could experiment with this format too? And maybe large conferences could attempt this format per topic, e.g., an unconference on IoT within a larger conference that deals with other things too?) Now need to figure out how to relocate NetBeans Day and JavaOne as a whole to Crete for the weather, great food, warm sea, friendly people, and everything else that defines Crete. Yes, the olive oil, for example.

Note: All images shown above were grabbed from Twitter, after doing a search on #jcrete. If you want a long list of enthusiasm about programming in general, that's the hash tag to keep track of.

Adam Bien - August 29, 2014 04:01 AM
New Pattern, Play, Broken EJB Proxies, Network Files, Huge Apps--Or The 6th Airhacks Q & A

  1. What do you think about play framework as compared to JavaEE ? I often heard that JavaEE is heavyweight in development and therefore internet-startups uses other framework stacks like play, rails, meteor etc
  2. What would be the proper approach to read a network file in a J2E environment?
  3. “Open Extended Persistence Context In View” - a new pattern?
  4. ID generation in a cluster.
  5. State computation (daily limits) and scalability vs. consistency.
  6. Is JSF compatible with Bootstrap?
  7. The JSP / HTML 5 drama: The Return Of JSPs in HTML 5
  8. “How are you going to structure your application if application is going to be really huge. Are you still going to keep it in one big war?” blog comment by Thomas
  9. Commercial vs. free tools: gist discussion
  10. Is “Mixing storage/transfer concerns an antipattern”? Rafael Chaves, @abstratt
  11. Broken EJB proxies? Brad Davies, @bradsdavis

See also https://gist.github.com/AdamBien/8735518ee671d7edb778

The questions above are going to be answered during the next "Airhacks Q & A" http://airhacks.io live. You can subscribe to the channel and / or for the next event: http://www.ustream.tv/channel/adambien.

If you miss a question, write a comment on this post, tweet your question with the hashtag "#airhacks" or mention me https://twitter.com/AdamBien.

The best of all: you can ask the questions live, during the show using the chat: http://www.ustream.tv/channel/adambien, twitter (hashtag "#airhacks") or (the best option): using channel ##airhacks on http://freenode.net.

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!


Real World Java EE Workshops [Airport Munich]>

Adam Bien - August 28, 2014 03:33 AM
DTO: The Exceptions From The Rule

Most JavaEE applications do not need a Data Transfer Object at all. Built-in support for JSON and XML does the transport job already. However, DTOs are still useful for special case handling like:

  1. Transferring a custom subset, superset (multiple entities) of entity data at once
  2. Dedicated optimizations like sophisticated JAXB mapping, customization of binary transfer e.g. hooks in http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html
  3. Role-dependent dataset: specific roles are only allowed to see specific data attributes. However, a http://docs.oracle.com/javaee/7/api/javax/json/JsonObject.html would solve such a job perfectly as well.
  4. Client-dependent view: native clients may request a different view to data as it can be provided by stock entities. Client may require a DTO per view independently of the organization on the server.
  5. Client technology may expect different contents e.g. a JavaFX client may expect a http://docs.oracle.com/javafx/2/api/javafx/beans/property/StringProperty.html instead of a plain String.

DTOs do not have to be justified in all the use cases above. The reason for introduction is obvious: a DTO is significantly different to the persistent domain object, or the technology forces you to introduce a DTO.

[See also an in-depth discussion in the "Real World Java EE Patterns--Rethinking Best Practices" book (Second Iteration, "Green Book"), page 273 in, chapter "Data Transfer Object", particularly the strategies "Generic DTO", "Client-specific DTO"]

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!


Real World Java EE Workshops [Airport Munich]>

NetBeans Zone - The social network for developers - August 26, 2014 08:10 AM
Thomas Stütz: Why NetBeans IDE is Great for Teaching Java

We've now met several teachers using NetBeans IDE in the classroom: Michiel Noback (Netherlands), Zoran Sevarac (Serbia), Pieter van den Hombergh (Netherlands)

Adam Bien - August 25, 2014 08:38 AM
JavaEE 7 Retired The DTO

The classic DTO solves the following problem:

"You want to transfer multiple data elements over a tier."

Back in the days a DTO was implemented as a Serializable anemic Java class only equipped with field accessors.

In Java EE the https://jax-rs-spec.java.net became a de-facto standard for remoting, so the implementation of Serializable interface is no more required. To transfer data between tiers in Java EE 7 you get the following options for free:

  1. JAXB: the popular application servers offer JSON, XML serialization for "free".
    
    @Entity
    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    @NamedQuery(name = Registration.findAll, query = "SELECT r FROM Registration r")
    public class Registration {
    
        private static final String PREFIX = "com.airhacks.workshops.business.registrations.entity.Registration.";
        public static final String findAll = PREFIX + "all";
    
    
        @Id
        @GeneratedValue
        @XmlTransient
        private long id;
    
        @XmlTransient
        @Transient
        private BiFunction<Boolean, Integer, Integer> taxCalculator;
    
        private int numberOfDays;
        private int numberOfAttendees;
        private boolean vatIdAvailable;
        
        //...
    
    }
    
    
    [Registration.java from https://github.com/AdamBien/javaee-bce-archetype]
  2. With the introduction of Java API for JSON Processing, you can also directly serialize parts of your objects into JSON:
    
    @Path("health")
    @Produces(MediaType.APPLICATION_JSON)
    public class HealthResource {
    
        @Inject
        ServerWatch watch;
    
    
        @GET
        @Path("/current-memory")
        public JsonObject availableHeap() {
     JsonObjectBuilder builder = Json.createObjectBuilder();
    	builder.add("Available memory in mb", this.watch.availableMemoryInMB()).
    	add("Used memory in mb", this.watch.usedMemoryInMb());
    	return builder.build();
        }
        
        //...
    }
    
    
    [HealthResource.java from project ping]

Both approaches transport the data without any binary coupling to the origin object. The decoupling is even higher, as it was the case with the "traditional" (=code duplication) DTO implementation.

[See also an in-depth discussion in the "Real World Java EE Night Hacks--Dissecting the Business Tier" book, page 273 in, chapter "Data Transfer Object"]

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!


Real World Java EE Workshops [Airport Munich]>

NetBeans Zone - The social network for developers - August 23, 2014 07:34 AM
Tim Boudreau: Frequently Undiscovered Features in NetBeans

Tim Boudreau is a noted technology consultant, evangelist and author. Most broadly known for his leadership in the NetBeans project while it was part of Sun Microsystems, those who’ve worked with him remark most on his technical chops, passion for a challenge, and rare gift of great communication. And, as a former troubadour, he’s pretty tough when it comes to bad 70s rock lyrics too. A real...

Adam Bien - August 23, 2014 05:56 AM
NetBeans Rocks: Installation and Setup

NetBeans installation is fast and easy: no plugins, no configuration:

Enjoy Java hacking!


Real World Java EE Workshops [Airport Munich]>

NetBeans Zone - The social network for developers - August 22, 2014 08:57 AM
Eirik Bakke: 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 Eirik Bakke from MIT. -- NetBeans team. Preview Text:  Eirik Bakke from MIT in Boston considers the Java editor, Maven support, and the clean NetBeans user interface to be among his favorite NetBeans features. ...

Adam Bien - August 22, 2014 07:40 AM
Mocking JPA EntityManager with Query

EntityManager is an interface and can be easily mocked out with https://code.google.com/p/mockito/.

At the same time the EntityManager is also a factory, which creates Query instance, which in turn creates results. Mocking a query involves therefore a three step (=three lines process):


public class RegistrationsTest {

    Registrations cut;

    @Before
    public void init() {
        this.cut = new Registrations();
        this.cut.priceCalculator = mock(VatCalculator.class);

        this.cut.em = mock(EntityManager.class);

		//...
    }

    void mockQuery(String name, List<Registration> results) {

        Query mockedQuery = mock(Query.class);
        when(mockedQuery.getResultList()).thenReturn(results);
        when(this.cut.em.createNamedQuery(name)).thenReturn(mockedQuery);

    }

After this step you can easily return whatever results you like:


    @Test
    public void convertEmptyListToJson() {

        mockQuery(Registration.findAll, Collections.EMPTY_LIST);

        final JsonArray result = this.cut.allAsJson();
        assertNotNull(result);
        assertTrue(result.isEmpty());
    }

If you would like to ignore the parameters, or react to specific query parameters, the method Query::setParameter needs to be mocked as well:


  when(mockedQuery.setParameter(Matchers.anyString(), Matchers.anyObject())).thenReturn(mockedQuery);

See the entire unit test: RegistrationsTest.java. The whole example is available as maven archetype.

Usually complex queries are going to be encapsulated in dedicated controls, so it is easier to mock out the whole control instead.

Interested in Java EE Code Quality and Testing? See you at http://workshops.adam-bien.com/about-testing.htm or regular http://airhacks.com
Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - August 22, 2014 07:00 AM
Over 300 "NetBeans Platform for Beginners" Sold

I've noticed that the authors of "NetBeans Platform for Beginners" have started exposing the number of sales they have achieved. Below, notice the '304' (which will probably change quite quickly) at the lower left end of this screenshot:

That's pretty good since the book has only existed for a few months and developers tend to share books they buy in PDF format. That probably means there are 300 teams of software developers around the world who are using the book, which is pretty awesome. (Though it would help the authors significantly, I'm sure, if individual developers on teams would buy the book, rather than sharing one between them. Come on, let's support these great authors so that they'll write more books like this.)

Also note that there is a set of reviewer comments on the page above:

Plus, the book is updated at the end of each month, so it continues to grow and improve from month to month, for free for everyone who has bought it.

If you've read the book and want to contribute a review like the above, contact walternyland @ yahoo dot com.

Great work, guys!

For anyone out there who hasn't got it yet: https://leanpub.com/nbp4beginners

APIDesign - Blogs - August 21, 2014 03:29 PM
Develop in NetBeans and Deploy to AppStore

Minesweeper for iOS has been published. First iBrwsr powered DukeScript application has been deployed to AppStore. If you own an iPad or iPhone, give it a try: https://itunes.apple.com/us/app/fair-minesweeper/id903688146

And don't forget you can use NetBeans to develop such applications yourself! Install DukeScript NetBeans support.

--JaroslavTulach 15:29, 21 August 2014 (UTC)

Geertjan's Blog - August 21, 2014 01:43 PM
RequireJS: JavaScript for the Enterprise

I made a small introduction to RequireJS via some of the many cool new RequireJS features in NetBeans IDE. I believe RequireJS, and the modularity and encapsulation and loading solutions that it brings, provides the tools needed for creating large JavaScript applications, i.e., enterprise JavaScript applications.

&amp;amp;amp;lt;span id=&amp;amp;amp;quot;XinhaEditingPostion&amp;amp;amp;quot;&amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;

(Sorry for the wobbly sound in the above.)

An interesting comment by my colleague John Brock on the above:

One other advantage that RequireJS brings, is called lazy loading of resources. In your first example, everyone one of those .js files is loaded when the first file is loaded in the browser. By using the require() call in your modules, your application will only load the javascript modules when they are actually needed. It makes for faster startup in large applications. You could show this by showing the libraries that are loaded in the Network Monitor window.

So I did as suggested:

Click the screenshot to enlarge it and notice how the Network Monitor is helpful in the context of RequireJS troubleshooting.

Adam Bien - August 21, 2014 08:23 AM
How To Deal With J2EE and Design Patterns

Patterns are clearly defined as:

"In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design."
[http://en.wikipedia.org/wiki/Software_design_pattern].

If you encounter a design challenge, you are supposed to search in a catalog for the description, compare the Motivation (Forces) or Applicability. If they match, you can apply the ideas from the pattern to solve your problem. Patterns are not a genius solution to a problem, rather than a standardized compromise. Usually you are going to implement flavors of the design patterns without even knowing it.

In Java Enterprise community patterns seem to have their own live. They are going to be applied regardless their problem definition or context. The most misused pattern in the Java Enterprise community is the DTO. DTO was clearly defined as a solution for a distribution problem. DTO was meant to be a coarse-grained data container which efficiently transports data between processes (tiers). In J2EE DTO was absolutely necessary, CMP Entity Beans were not serializable. Martin Fowler also defines defines DTO as:

"An object that carries data between processes in order to reduce the number of method calls."
According to the definitions DTOs were never meant to carry data within a JVM...

Even more suspicious is the popularity of the DAO pattern. The solution statement starts as:

"The DAO implements the access mechanism required to work with the data source. The data source could be a persistent store like an RDBMS, an external service like a B2B exchange, a repository like an LDAP database, or a business service accessed via CORBA Internet Inter-ORB Protocol (IIOP) or low-level sockets."

DAO was always meant as a procedural encapsulation of inconvenient or not standardized data sources. An object oriented flavor, the Domain Store pattern uses DAO to access JDBC and provides an object oriented access to the store. Interestingly the Domain Store looks like a slightly modified version of the ...JPA Entity Manager.

Some projects are wrapping Entity Manager with an empty delegate and call it "DAO". Such an approach is actually the opposite of the origin intention...

Java EE 5 killed the majority of the J2EE Patterns. Their "Problem" and "Forces" descriptions do not apply any more. Java EE 6 and 7 killed the remaining patterns, only the Application Service is still useful.

If you take the pattern definitions seriously and look at some "enterprise" projects you are not going to understand the design. Patterns are going to be applied without having a problem and are considered as future "insurance": "...in case JPA disappears, I only have to change the implementation of the DAO..."

How to deal with patterns? Apply them if you encounter a problem. Java EE design is "bottom-up" rather than "top-down", as it was the case in the old J2EE world.

[See also an in-depth discussion in the "Real World Java EE Night Hacks--Dissecting the Business Tier" book, page 259 in, chapter "Data Access Object"]

We spend some time to eliminate J2EE and GoF patterns one by one with Java EE 7 and Java 8 during the Java EE Architectures "airhacks" workshops at MUC airport.
Real World Java EE Workshops [Airport Munich]>

NetBeans Zone - The social network for developers - August 21, 2014 06:41 AM
Weekly NetBeans News in Chinese

Liang Ding is a programmer and a blogger from China. He has worked for Alibaba doing online payments related development and now works at EPICPaaS on architecting and implementing a PaaS software platform. Preview Text:  Meet NetBeans Dream Team member Liang Ding, who leads the team that translates the NetBeans Weekly Newsletter! ...

Geertjan's Blog - August 20, 2014 04:05 PM
Asciidoctor / NetBeans

With Jason Lee's NetBake plugin (https://bitbucket.org/jdlee/netbake), when you've installed JRuby and then the Asciidoctor gem, you're good to go to use Asciidoctor with NetBeans IDE.

New Asciidoc files can be created, which have a Source view...

...and a Visual view. The current content of the text editor is parsed by the Asciidoctor gem and the resulting HTML is displayed in a JEditorPane:

Awestruct support is also part of the NetBake plugin, with a new project type and other related features. An Options window is included for configuring the plugin:

I've been in touch with Jason and we're discussing separating the Asciidoctor parts from the Awestruct parts and then putting them seperately as plugins on the NetBeans Plugin Portal.

NetBeans Zone - The social network for developers - August 20, 2014 11:32 AM
Web Development with Java and JSF: Author Interview with Michael Müller

Software developer, blogger and active NetBeans user Michael Müller has been a frequent reviewer of technical books. Now he has taken the leap from book reviewer to book author. Preview Text:  Software developer and blogger Michael Müller discusses his new book “Web Development with Java and JSF ”, a practical guide for Java developers to...

NetBeans Zone - The social network for developers - August 20, 2014 08:36 AM
NASA Conjunction Assessment with JavaFX and the NetBeans Platform

The Tracking and Orbit Determination Quality (TODQ) Viewer is a collection of prototype 2D and 3D interactive visualizations for analysis software updates by NASA Robotic Conjunction Assessment Risk Analysis (CARA) using Java and JavaFX 8.   Preview Text:  The Tracking and Orbit Determination Quality (TODQ) Viewer is a collection of...

Adam Bien - August 20, 2014 02:40 AM
igniter.fx 1.9.2 released--The Java 8 Edition

A new version of igniter.fx -- the maven "wizard" which creates a sample Java FX MVP application is released.

The 1.9.2 edition demonstrates afterburner's 1.6.0 capabilities like asynchronous FXML loading and view-dependent object injection.


@FXML
Pane lightsBox;
//...
LightView view = new LightView((f) -> red);
view.getViewAsync(lightsBox.getChildren()::add);


A passed constructor parameter (an int in the example below) can be conveniently injected into the presenter. Each presenter instance receives its own value:

public class LightPresenter{

    @FXML
    Circle light;

    @Inject
    int red;


See the full code: DashboardPresenter.java

igniter.fx is open source: https://github.com/AdamBien/igniter.fx

To create a an igniter.fx 1.9.2 maven project execute the following command from the CLI:


mvn archetype:generate -Dfilter=com.airhacks:igniter

You can also clone the sample source code directly from: https://github.com/AdamBien/followme.fx.

followme screenshot

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!


Real World Java EE Workshops [Airport Munich]>

Michael's blog » NetBeans - August 19, 2014 09:06 PM
Copy Static Resources on Save

Have you heard about the series “My top 5 NetBeans features”? NetBeans users report their favorite features. I just want to point out only one small (and almost hidden), but valuable feature, which is included in the upcoming version NetBeans … Continue reading

NetBeans Zone - The social network for developers - August 19, 2014 06:21 PM
NetBeans Weekly News (Issue #653 - Aug 19, 2014)

Project News NetBeans in the Enterprise: Boeing What's Boeing doing with NetBeans? And what are some daily development tips that you might find useful in your own coding tasks? Join Michelle Chamberlin and Bruce Shimel as they share their favorite NetBeans features. Preview Text:  In this issue: James Gosling and others share why they use...

NetBeans Zone - The social network for developers - August 19, 2014 03:06 PM
Michelle Chamberlin and Bruce Shimel: 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 Michelle Chamberlin and Bruce Shimel at Boeing, whose history with NetBeans IDE goes back many years. -- NetBeans team. Preview Text:  What do engineers at Boeing like about NetBeans IDE? Michelle Chamberlin and Bruce...

Java Evangelist John Yeary's Blog - August 19, 2014 02:16 PM
JSF 2.1 Tip of the Day: Clearing the @ViewScope

Introduction

I was trying to solve an issue in our code where the @ViewScope beans were not being garbage collected. I spoke a number of times with Manfred Riem at Oracle about the weirdness of this issue. The issue simply put was that we were facing a memory leak where the instances of @ViewScope objects were not being removed from the view map. As a result, the pages were being kept in memory. The view map is limited to 32 views which helped to hide the issue. In most cases, it would not appear to normal users of our application. The issue was suddenly evident when the view contained tens of thousands of objects. 32 x 10k is REALLY BIG! It really never made it to 32, the system would stall and crash at about 6 instances.

The Culprit

We had implemented our own custom NavigationHandler. This was working quite well on JSF 2.0.x, but a couple of things happened. The JSF implementation was changed to handle another view scope issue, and our implementation of the NavigationHandler was changed from my original code. The new handler did not handle cleaning up the @ViewScope object view map which is stored in the session. Oh, yeah, the view map in the session was the change to the API too.

The Solution

The solution turned out to be something simple, re-implement the same mechanism in the default NavigationHandler to clear the @ViewScope objects from the view map in the session.

Interesting Observations

I was trying to come up with a mechanism to clear the view map data from the session, and came up with a SystemEventListener to test out some ideas. I thought I would share the code for people to see how the map is cleared. This is an approach to the issue, but as I noted, it was actually something missed in our NavigationHandler. I thought I should post the code for anyone who was looking for ideas on how to manipulate the map, or clear data in it. So without further hesitation. Here is the code.

ViewMapSystemEventListener.java


To implement the listener, you need to add an entry to the faces-config.xml file as shown below.

faces-config.xml


Geertjan's Blog - August 19, 2014 12:37 PM
Gesture Based NetBeans Tip Infrastructure

All/most/many gestures you make in NetBeans IDE are recorded in an XML file in your user directory, "var/log/uigestures", which is what makes the Key Promoter I outlined yesterday possible. The idea behind it is for analysis to be made possible, when you periodically pass the gestures data back to the NetBeans team. See http://statistics.netbeans.org for details.

Since the gestures in the 'uigestures' file are identifiable by distinct loggers and other parameters, there's no end to the interesting things that one is able to do with it. While the NetBeans team can see which gestures are done most frequently, e.g., which kinds of projects are created most often, thus helping in prioritizing new features and bugs, etc, you as the user can, depending on who and how the initiative is taken, directly benefit from your collected data, too.

Tim Boudreau, in a recent article, mentioned the usefulness of hippie completion. So, imagine that whenever you use code completion, a tip were to appear reminding you about hippie completion. And then you'd be able to choose whether you'd like to see the tip again or not, etc, i.e., customize the frequency of tips and the types of tips you'd like to be shown.

And then, it could be taken a step further. The tip plugin could be set up in such a way that anyone would be able to register new tips per gesture. For example, maybe you have something very interesting to share about code completion in NetBeans. So, you'd create your own plugin in which there'd be an HTML file containing the text you'd like to have displayed whenever you (or your team members, or your students, maybe?) use code completion. Then you'd register that HTML file in plugin's layer file, in a subfolder dedicated to the specific gesture that you're interested in commenting on.

The same is true, not just for NetBeans IDE, but for anyone creating their applications on top of the NetBeans Platform, of course.

Geertjan's Blog - August 18, 2014 03:17 PM
Key Promoter for NetBeans

Whenever a menu item or toolbar button is clicked, it would be handy if NetBeans were to tell you 'hey, did you know, you can actually do this via the following keyboard shortcut', if a keyboard shortcut exists for the invoked action.

After all, ultimately, a lot of developers would like to do everything with the keyboard and a key promoter feature of this kind is a helpful tool in learning the keyboard shortcuts related to the menu items and toolbar buttons you're clicking with your mouse.

Above, you see the balloon message that appears for each menu item and toolbar button that you click and, below, you can see a list of all the actions that have been logged in the Notifications window. That happens automatically when an action is invoked (assuming the plugin described in this blog entry is installed), showing the display name of the action, together with the keyboard shortcut, which is presented as a hyperlink which, when clicked, re-invokes the action (which might not always be relevant, especially for context-sensitive actions, though for others it is quite useful, e.g., reopen the New Project wizard).


And here's all the code. Notice that I'm hooking into the 'uigestures' functionality, which was suggested by Tim Boudreau, and I have added my own handler, which was suggested by Jaroslav Tulach, which gets a specific parameter from each new log entry handled by the 'org.netbeans.ui.actions' logger, makes sure that the parameter actually is an action, and then gets the relevant info from the action, if the relevant info exists:

@OnShowing
public class Startable implements Runnable {
    @Override
    public void run() {
        Logger logger = Logger.getLogger("org.netbeans.ui.actions");
        logger.addHandler(new StreamHandler() {
            @Override
            public void publish(LogRecord record) {
                Object[] parameters = record.getParameters();
                if (parameters[2] instanceof Action) {
                    Action a = (Action) parameters[2];
                    JMenuItem menu = new JMenuItem();
                    Mnemonics.setLocalizedText(
                            menu,
                            a.getValue(Action.NAME).toString());
                    String name = menu.getText();
                    if (a.getValue(Action.ACCELERATOR_KEY) != null) {
                        String accelerator = a.getValue(Action.ACCELERATOR_KEY).toString();
                        NotificationDisplayer.getDefault().notify(
                                name,
                                new ImageIcon("/org/nb/kp/car.png"),
                                accelerator,
                                new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                a.actionPerformed(e);
                            }
                        });
                    }
                }
            }
        });
    }
}

Indeed, inspired by the Key Promoter in IntelliJ IDEA.

Interested in trying it out? If there's interest in it, I'll put it in the NetBeans Plugin Portal.

Update 08/19/14: OK, here it is -- http://plugins.netbeans.org/plugin/55751

NetBeans Zone - The social network for developers - August 18, 2014 06:24 AM
Universal Maven for Teaching Java Desktop Applications

Ken Fogel is the Program Coordinator and Chairperson of the Computer Science Technology program at Dawson College in Montreal, Canada. He is also a Program Consultant to and part-time instructor in the Computer Institute of Concordia University's School of Extended Learning. Preview Text:  Regular NetBeans education columnist Ken Fogel, the Program...