Č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
ludo's blog (feed)
hansmuller's blog (feed)
pkeegan's blog (feed)
richunger's blog (feed)
tball's blog (feed)
timboudreau's blog (feed)
NetBeans Zone - The social network for developers (feed)
NetBeans RSS Feed Filter (feed)
APIDesign - Blogs (feed)
blogtrader - Blog (feed)
Carsten Zerbst's Weblog (feed)
Milan's blog (feed)
Winston Prakash's Weblog (feed)
Anchialas' Java Blog (feed)
Michael Bien's Weblog (feed)
open source. open mind. (feed)
Allan Lykke Christensen » NetBeans (feed)
Inspiration and Expression » Netbeans (feed)
Crazy java hacking (feed)
J. O'Conner » NetBeans (feed)
ProNetBeans (feed)
Adam Bien (feed)
Comments on: About (feed)
Ignacio Sánchez Ginés » NetBeans (feed)
Michel Graciano's Weblog (feed)
Ramon.Ramos (feed)
Ozone and Programming » netbeans (feed)
Paulo Canedo » NetBeans English (feed)
NetBeans Ruminations » NetBeans (feed)
Arun Gupta, Miles to go ... (feed)
Geertjan's Blog (feed)
.JARa's Bilingual Weblog (feed)
JavaFX Composer (feed)
Jesse Glick (feed)
Inside NetBeans Mobility (feed)
Martin Grebac (feed)
The NetBeans Community Podcast (feed)
NetBeans Profiler (feed)
NetBeans for PHP (feed)
Rechtacek's (feed)
Virtual Steve (feed)
My First Blog - Satyajit Tripathi (feed)
Insert Witty Irony Here (feed)
mkleint (feed)
Michel Graciano's Blog (feed)
Roger Searjeant's blog (feed)
Optonline Webmail (feed)
Bistro! 2.0 (feed)
James Selvakumar's Blog » netbeans (feed)
nB gUru » NetBeans (feed)
Newsintegrator Blog » netbeans (feed)
praxis » NetBeans (feed)
There's no place like 127.0.0.1 » Netbeans (feed)
Bernhard's Weblog (feed)
TechAshram » NetBeans (feed)
Anuradha (feed)
Netbeans6/6.5 my best practices (feed)
Need to find a title (feed)
Manikantan's Netbeans (feed)
Neil's Dev Stuff (feed)
Computer says null; (feed)
NetBeans Adventures, Java and more (feed)
NetBeans Community Docs Blog (feed)
Antonio's blog (feed)
Van Couvering Is Not a Verb (feed)
Diego Torres Milano's blog (feed)
Messages from mrhaki (feed)
The Netbeans Experience (feed)
An Open Source Fascicule (feed)
NbPython/ jpydbg / pymvs (feed)
Shanbag's Blog (ರಜ&#3236 &#3250&#3275&#3221) (feed)
Netbeans IDE Blog by Tushar Joshi, Nagpur (feed)
Wade Chandler's Programming Blog (feed)
Devlin's Lab (feed)
In perfect (spherical) shape (feed)
Alex Kotchnev's Blog (feed)
Big Al's Blog (feed)
Code Snakes (feed)
Oliver Wahlen's Blog (feed)
Vroom Framework (feed)
Jeff's Blog (feed)
Shuttle between Galaxies (feed)
Welcome to my live... (feed)
ryandelaplante.com (feed)
Devel Blog (feed)
diamond-powder (feed)
Where's my Blog?!

Powered by:    Planet

Last updated:
May 17, 2012 08:11 AM
All times are UTC

Sponsored by
sponsored by Oracle

visit NetBeans website
Geertjan's Blog - May 16, 2012 11:42 PM
Syntax Coloring for FreeMarker

Without fail, each JavaCC file (and ANTLR file) I have ever found (e.g., for Clojure and Ceylon) has been beaten into submission via this tutorial, which includes a YouTube movie explaining everything:

http://platform.netbeans.org/tutorials/nbm-javacc-lexer.html

Here's FreeMarker in NetBeans IDE, after applying the above tutorial to this file, which I found on-line after googling for about 5 minutes:

https://raw.github.com/freemarker/freemarker/master/src/main/javacc/FTL.jj

Not as pretty nor as complete as it could be, but I've clearly gone some way to getting things to work together.

However, note that in line 6 and 7, I have selected the "p" tag across two lines, meaning that I can change related text across multiple lines, because the block selection feature is a standard part of all editors, including any new editor you create, such as the FreeMarker editor above.

NetBeans Zone - The social network for developers - May 16, 2012 12:34 PM
NetBeans Weekly News (Issue #537 - May 16, 2012)

Project News Summer Internship for NetBeans Development A summer internship for NetBeans projects is being set up by NetBeans Dream Team member Emilian Bold's company. Read all about it here and gain some NetBeans API experience this summer!

open source. open mind. - May 16, 2012 05:35 AM
Free Workshop: Extending VisualVM BYOL

VisualVM is great for monitoring and profiling your application, and it has been created with extension points that you can use to add more functionality. Under the hood VisualVM uses the NetBeans Platform. In this workshop we’ll have a look at VisualVM and how to extend it with additional functionality.

Location: Eppleton IT Consulting, Bergmannstr. 66, 80339 Munich

Time: 23 May 2012, 18:30-21:00

This workshop is free for Java User Group members.

Bring your own Laptop (BYOL) with NetBeans 7.1.2 and JDK 7 preinstalled.

Update: No more seats available, due to many requests we’ll repeat the workshop in June or July (drop us a mail to register).

NetBeans Zone - The social network for developers - May 16, 2012 04:44 AM
Specifying Appropriate NetBeans JDK Source Release

NetBeans uses its projects' settings for javac.source (and javac.target) in more ways than simply enforcing javac's use of the -source and -target. Preview Text:  NetBeans uses its projects' settings for javac.source (and javac.target) in more ways than simply enforcing javac's use of the -source and -target. In this post, I look at some...

Adam Bien - May 16, 2012 04:39 AM
Java EE and How to Specify The Unconventional With Convention Over Configuration [Free Article]

The free (registration is required) Java Magazine article Convention Over Configuration in Java EE 6 focuses on the implementation of project and stage dependent configuration with JSF, EJB, JMX, JAX-RS and CDI.

Executable Maven 3 project is included and checked-in. Feedback is, as always, highly appreciated!


Real World Java EE Bootstrap and Effective Java EE Bootstrap Workshops [Airport Munich] Books: Real World Java EE Night Hacks - Dissecting Best Practices ...and the bestseller Real World Java EE - Rethinking Best Practices

Geertjan's Blog - May 15, 2012 07:42 PM
Gaea+

Gaea+ is a powerful geospatial application offering stunning 3D visualization, manipulation and analysis of spatial data. The data is pulled from the web using standard Open Geospatial Consortium protocols.

The terrain visualization is based on the NASA WorldWind Java SDK, while the user interface was first created in plain Swing, and then ported to the NetBeans Platform in 2009:

Gaea+ is being used by the Association of Municipalities and Towns of Slovenia for public display of urban plans, by the members of the Alpine Association of Slovenia to plan hiking trips, by the Slovene Administration for Civil Protection and Disaster Relief to visualize disasters and plan rescue actions, among others.

Arun Gupta, Miles to go ... - May 15, 2012 12:11 PM
JSON-P: Java API for JSON Processing (TOTD #178)


JSR 353 is Java API for JSON Processing (JSON-P) and will define an API to process (e.g. parse, generate, transform, and query) JSON. This JSR will be delivered as part of Java EE 7. The API will allow to produce and consume JSON in a streaming fashion (StAX equivalent in XML world) and build a Java object model for JSON (DOM equivalent in XML world). Note, binding JSON to Java objects and vice versa is not part of the scope of this JSR.

json-processing-spec.java.net is where all the specification work is happening and jsonp.java.net is the project for the  Reference Implementation. Its still early days but this Tip Of The Day (TOTD) will explain how to get started. The workspace can be checked out as

git clone git://java.net/jsonp~git
Cloning into jsonp~git...
remote: Counting objects: 313, done.
remote: Compressing objects: 100% (218/218), done.
remote: Total 313 (delta 110), reused 0 (delta 0)
Receiving objects: 100% (313/313), 64.13 KiB, done.
Resolving deltas: 100% (110/110), done.

Building the workspace require JAVA_HOME to be set (/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home or /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home). Once set, the workspace can be built as
mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] RI for JSON-P JSR
[INFO] Java API for Processing JSON (JSON-P)
[INFO] jsonp-tests
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building RI for JSON-P JSR 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------

. . .

Tests run: 22, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ jsonp-tests ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/arungup/code/workspaces/jsonp~git/tests/target/jsonp-tests-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ jsonp-tests ---
[INFO] Installing /Users/arungup/code/workspaces/jsonp~git/tests/target/jsonp-tests-1.0-SNAPSHOT.jar to /Users/arungup/.m2/repository/org/glassfish/jsonp-tests/1.0-SNAPSHOT/jsonp-tests-1.0-SNAPSHOT.jar
[INFO] Installing /Users/arungup/code/workspaces/jsonp~git/tests/pom.xml to /Users/arungup/.m2/repository/org/glassfish/jsonp-tests/1.0-SNAPSHOT/jsonp-tests-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] RI for JSON-P JSR ................................. SUCCESS [0.528s]
[INFO] Java API for Processing JSON (JSON-P) ............. SUCCESS [12.214s]
[INFO] jsonp-tests ....................................... SUCCESS [1.695s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

The API .jar file is in api/target/jsonp-ri-1.0-SNAPSHOT.jar and javadocs are in api/target/jsonp-ri-1.0-SNAPSHOT-javadoc.jar. There are several tests in the tests directory that shows the API usage. The RI JARs are not pushed to a public maven repo yet but are installed in the local repo with the above command. These can be included in your "pom.xml" with the following coordinates:

<dependency>
<groupId>javax.json</groupId>
<artifactId>jsonp-ri</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

The key APIs are
  • DOM-based APIs (javax.json package)
    • JsonBuilder - Builds a JSON object or JSON array
    • JsonReader - Reads a JSON object or array from the stream
    • JsonWriter - Writes a JSON object or array to the stream
  • Streaming APIs (javax.json.stream package)
    • JsonGenerator - Streaming JSON generator
    • JsonParser - Allows forward, read-only access to JSON

Here is an sample usage of JsonBuilder:
JsonObject value = new JsonBuilder()
   .beginObject()
     .add("firstName", "John")
     .add("lastName", "Smith")
     .add("age", 25)
        .beginObject("address")
           .add("streetAddress", "21 2nd Street")
           .add("city", "New York")
           .add("state", "NY")
           .add("postalCode", "10021")
        .endObject()
        .beginArray("phoneNumber")
           .beginObject()
              .add("type", "home")
              .add("number", "212 555-1234")
           .endObject()
           .beginObject()
              .add("type", "home")
              .add("number", "646 555-4567")
           .endObject()
        .endArray()
   .endObject()
.build();

Here is a sample usage of JsonReader:

String json = "...";
JsonReader reader = new JsonReader(new StringReader(json));
JsonValue value = reader.readObject();
reader.close();

A sample usage of JsonWriter:

JsonWriter jsonWriter = new JsonWriter(new FileWriter(...));
JsonObject jsonObject = new JsonBuilder()
.beginObject()
. . .
.endObject()
.build()
; jsonWriter.writeObject(jsonObject); jsonWriter.close();
Here is a sample usage of JsonGenerator:

JsonGenerator generator = new JsonGenerator(new FileWriter(...));
generator
.beginObject()
. . .
.beginArray()
. . .
.endArray()
.endObject()
.build();
generator.close();

And finally a sample usage of JsonParser:
String json = "...";
JsonParser parser = new JsonParser(new StringReader(json));
Iterator<Event> it = reader.iterator();
Event event = it.next();
The event  can be of the following types:
  • START_OBJECT
  • END_OBJECT
  • START_ARRAY
  • END_ARRAY
  • KEY_NAME
  • VALUE_STRING
  • VALUE_NUMBER
  • VALUE_FALSE
  • VALUE_TRUE
  • VALUE_NULL
Here are some references to track the progress and provide feedback:
This JSR will be delivered as part of Java EE 7. Here are some other early work that has been explained:

Have fun!

open source. open mind. - May 15, 2012 10:45 AM
Last Chance for Early Birds – Become Proficient in Java Performance Tuning with Kirk Pepperdine

Nur noch 6 Tage (bis einschl. 20.05.2012) haben Sie die Möglichkeit auf 10% Early Bird Rabatt bei Buchung des Kurses:

Become Proficient in Java Performance Tuning with Kirk Pepperdine

In diesem umfassenden viertägigen Workshop erlernen Sie praxiserprobte Techniken um Performance-Engpässe zu entdecken und zu beheben. Was Sie nicht finden werden sind Tipps und Tricks, die mit der nächsten Version von Java veraltet sein werden. Stattdessen konzentriert sich der Kurs darauf eine Methodik zu vermitteln, die aus jahrelanger Erfahrung bei der Lösung von Performanceproblemen für eine Vielzahl unterschiedlicher Programmiersprachen und Plattformen entwickelt wurden. Im Laufe des Seminars untersuchen wir, wie Java funktioniert und zeigen eine Methodik, um zu entscheiden welche Tools für das vorliegende Problem geeignet sind. Der Workshop fordert Sie mit mehr als einem Dutzend Übungsproblemen heraus, die aus realen Projekten stammen.

Während der 4 Tage lernen Sie:

  • schnell und zuverlässig die Hauptursachen für schlechte Performance in Ihren Applikationen zu identifizieren,
  • wie man Randbedingungen eliminiert, die das Auffinden von Bottlenecks verhindern,
  • die notwendigen unterstützenden Beweise vor einer Entscheidung über eine möglicherweise teure Vorgehensweise zu finden
  • und Performance-Probleme zu entdecken, bevor sie ihren Weg in Ihre Produktionsumgebung finden.

Kursleiter Kirk Pepperdine – ein anerkannter Experte für Java Performance Tuning, Sun Java Champion, internationaler Referent und Trainer und Co-Author des erfolgreichen Java Performance Tuning Newsletters – lehrt Sie in vier Tagen, was sonst Jahre des Selbsstudiums erfordert. Kirk hat zahlreiche kritische Performance-Probleme behoben und seinen Kunden Millionen in entgangenen Einnahmen und Ausfallzeiten eingespart. Dieser Kurs wird Ihnen helfen das gleiche zu tun.

Weitere Info unter: www.java-performance-tuning.de

NetBeans Zone - The social network for developers - May 15, 2012 07:48 AM
Paid Summer Internship: Our Own NetBeans Summer Of Code!

My company, Joseki Bold, is having a Summer of Code for students

Arun Gupta, Miles to go ... - May 14, 2012 06:27 PM
Java Day, Istanbul, May 2012 Trip Report




About 120+ 150 attendees at Java Day, Istanbul learned about Java EE 6/7 earlier today. The Java track had about 100 110 attendees during most of the day. I gave 4 sessions:

  • Developing Modern and Lightweight Java EE 6 Applications using WebLogic 12c (keynote to all the attendees)
  • What's coming in Java EE 7
  • Java EE 6 Hands-on Lab using NetBeans/WebLogic
  • RESTful Web services using JAX-RS

The attendees were generally quiet but the hands-on session had some interesting conversations around Java EE 6 usage. TOTD #177 showcase the WebLogic Maven plugin usage TOTD #176 shows how to run Conference Planner application on WebLogic 12c. I also had the opportunity to meet the Istanbul JUG leader and local GTUG leader. Show your passion about Java by participating at the local JUG, all the more better to volunteer as a speaker :-)

The slides presented are available below.






The self-paced instructions for Java EE 6 hands-on lab using NetBeans and WebLogic is available here.

Some pictures from the event and around the city ...














Here are a couple of more pictures from the local events team:





And the complete album:


Next stop Geecon, Poland ...

Geertjan's Blog - May 14, 2012 03:53 PM
Synchronize Javadoc Changes While Refactoring

Let's say here's a method you've defined:

Now you decide that "idx" should be "index". So you type "index" instead of "idx":


However, if you're smart, you'll first press Ctrl-R on "idx". When you then change "idx" to "index", the javadoc will ALSO be changed, automatically, as you type:

Geertjan's Blog - May 13, 2012 02:19 PM
"Extract Method" Functionality in NetBeans?

Why does NetBeans IDE not have "extract method" functionality?

Well, as Ralph from the NetBeans Team points out, it's as simple as using Alt-Shift-M. For example, here's a big chunk of code in the constructor of the Anagram Game (which is one of the samples in NetBeans IDE):

That big chunk of code deserves its own separate method. So, as you can see, I select it all with my mouse and then I press Alt-Shift-M (or Refactor | Introduce Method), which causes the "Introduce Method" dialog to be displayed, as shown below, where I type "postInitializeGUI", as you can see below:

I click OK in the dialog above. And now the constructor contains a new reference to a method...

...which is defined elsewhere in the code:

Hurray, again, for NetBeans IDE!

open source. open mind. - May 13, 2012 07:11 AM
JavaFX MotionBlur

In my little Pinball Machine project, I’m using JBox2D to position the nodes, specifically the ball. In every KeyFrame JBox2D gives me the current position and I simply set the layout of the Node representing the ball. Sometimes the motion looks a bit snatchy. Since I’ve got the current position and the new position I thought I could maybe use that info to create a nice MotionBlur to make the motion look a bit smoother and more realistic. The previous and new position can be used to calculate the angle and radius of the blur. I removed all custom Renderers to only show the rendering of the Ball (the pinball machine actually already looks a lot nicer, more about this later)

Here’s how it looks without (watch in fullscreen in case you want to see the difference :-) ):

And here how it looks with MotionBlur:

I hope the MotionBlur is visible in the Videos… By the way, my “Angry Duke- physics based games with JavaFX” Session has been accepted for W-Jax. Hope to see you there.

APIDesign - Blogs - May 12, 2012 07:56 PM
An API Proximity. Are You Close Friend with Your API?

How close are you to the API that you use? Are you friends? Do you hate each other? Have you memorize the API? Can you debug it? Is your API a clueless blackbox for you? Are you a calling client? Do you implement and provide some of the API concepts? Do you think I am asking silly questions?

It seems that proximity is one of the best ways to classify libraries into categories. So far I managed to recognize Zero to Many, One to Many, Few to Many and Many to Many proximity categories. They seem to directly influence the APIDesignPatterns one should use when designing such libraries. As such, when you are about to design your library, think a bit about the proximity you want to have with your clients and providers.

Btw. Most of NetBeans libraries is using the Many to Many proximity. I'll be more than glad if you decide to stick with our most favourite proximity style as well.

--JaroslavTulach 19:56, 12 May 2012 (UTC)

NetBeans Zone - The social network for developers - May 11, 2012 05:19 PM
Rants On The Daily Grind of Building Software

Language, Tools, Chickens, Eggs, Java and Python Too much of programming is intimately tied up with the tools to support the development of the software. Example 1. I was told -- with absolute and fierce conviction -- that VB may suck as a language, but Visual Studio more than makes up for the obvious problems. For some people, Tools Trump Language. Sadly, I've also had customers...

Arun Gupta, Miles to go ... - May 11, 2012 04:41 PM
wls-maven-plugin: WebLogic 12c Maven Plugin Usage (TOTD #177)


Oracle WebLogic Server 12c provides full Java EE 6 platform support. The screencast #39 shows how to build a complete application using NetBeans. The self-paced hands-on lab provides detailed instructions on the same as well. The Maven support in WebLogic 12c is much more improved. Steve Button and Markus Eisele wrote detailed blogs on how/what/why of Maven support in WebLogic. This Tip Of The Day (TOTD) will provide a quick overview of how to get started with using the maven plugin for deploying a Java EE 6 web application.

  1. Download and install WebLogic 12c using the zip installer as explained in TOTD #174.
  2. The Maven plugin can be installed using "$MW_HOME/wlserver/server/lib/wls-maven-plugin.jar". Change the directory to "$MW_HOME/wlserver/server/lib" and give the following commands:
    mvn install
    mvn install:install-file –Dfile=wls-maven-plugin.jar -DpomFile=pom.xml
  3. The maven plugin usage can be seen by giving the following command:
    mvn com.oracle.weblogic:wls-maven-plugin:help
    Or add the following to "~/.m2/settings.xml":
    <pluginGroups>     
    <pluginGroup>com.oracle.weblogic</pluginGroup>
    </pluginGroups>
    And then give the following command:
    mvn wls:help
    to see the output as:
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building wls-maven-sample 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- wls-maven-plugin:12.1.1.0:help (default-cli) @ wls-maven-sample ---
    [INFO]
    WebLogic Server Maven Plugin
    The following goals are supported by wls-maven-plugin:

    appc:
    The appc compiler generates and compiles the classes needed to deploy
    EJBs and JSPs to WebLogic Server. It also validates the deployment
    descriptors for compliance with the current specifications at both the
    individual module level and the application level.

    deploy:
    To deploy a weblogic server application (supports all formats WAR,JAR
    etc..)

    create-domain:
    Create a domain for WebLogic Server using the default domain template.
    For more complex domain creation use the WLST goal.

    help:
    Provides a list of all the goals supported by the wls-maven-plugin

    install:
    Install WebLogic Server

    list-apps:
    Lists the deployment names for applications and stand-alone modules
    deployed distributed, or installed to the domain

    redeploy:
    Redeploys a running application or part of a running application

    start-app:
    Starts an application deployed on weblogic server.

    start-server:
    Start WebLogic Server

    stop-app:
    Stops an application

    stop-server:
    Stop Weblogic Server

    undeploy:
    Undeploys the application from weblogic server. Stops the deployment unit
    and removes staged files from target servers

    update-app:
    Updates an application's deployment plan by redistributing the plan files
    and reconfiguring the application based on the new plan contents.

    wlst:
    WLST wrapper for Maven


    For detailed help on a goal, use -Dgoal=<goal-name> -Ddetail=true options.
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.794s
    [INFO] Finished at: Thu May 03 06:38:23 IST 2012
    [INFO] Final Memory: 8M/125M
    [INFO] ------------------------------------------------------------------------
    More details about each goal can be found using the following command:
    mvn wls:help -Dgoal=<GOAL> -Ddetail=true
    For example:
    mvn wls:help -Dgoal=install -Ddetail=true
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Maven Stub Project (No POM) 1
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- wls-maven-plugin:12.1.1.0:help (default-cli) @ standalone-pom ---
    [INFO]
    WebLogic Server Maven Plugin
    The following goals are supported by wls-maven-plugin:

    install:
    Install WebLogic Server

    Available Parameters:

    installCommand:
    The command to use to install the product when using an
    'executable' installer. The following macros are supported -
    @INSTALLER_FILE@ - the path to the installer file, @JAVA_HOME@ -
    path to the java home. eg: @JAVA_HOME@ -Xms512m -Xmx1024m -jar
    @INSTALLER_FILE@ one two

    artifactLocation:
    The address of the artifact. This can be one of the following -
    1) A ':' separated maven coordinates of the form (groupId:artifac-
    tId:packaging:classifier:version) 2) A file on the local system
    (/home/prash/myapps/helloworld.war)3) A remote http url
    (http://foo/a/b.zip)

    middlewareHome:
    The home directory for Oracle WebLogic Server or Fusion
    Middleware installation. Required unless WLS was installed in the
    default location selected by the WLS Maven Plugin's install goal.

    domainHome:
    Location of WLS domain

    localRepository:
    The absolute path of a local maven repository.

    artifactFactory:
    The artifactFactory is used to locate an artifact with a
    groupId:artifactId:artifactName:version in the remote Repository
    as provided by the remoteRepsitories parameter.

    artifactResolver:
    Artifactresolver resolves the artifact from the remote
    repository. Downloads an updated version of the artifact if
    present in the remote repo.



    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.889s
    [INFO] Finished at: Wed May 02 17:35:46 PDT 2012
    [INFO] Final Memory: 6M/89M
    [INFO] ------------------------------------------------------------------------

  4. Build a Java EE 6 application
    1. Create a Java EE 6 Maven web application as:
      mvn archetype:generate
      -DarchetypeGroupId=org.codehaus.mojo.archetypes
      -DarchetypeArtifactId=webapp-javaee6 -DgroupId=example
      -DartifactId=wls-maven-sample -DarchetypeVersion=1.5
      -DinteractiveMode=false
    2. Add a trivial servlet to the sample project by following the screencast #39. The complete source code for the project can be downloaded here.
  5. Add the following code fragment to the generated "pom.xml":
    <plugin>                
    <groupId>com.oracle.weblogic</groupId>
    <artifactId>wls-maven-plugin</artifactId>
    <version>12.1.1.0</version>
    </plugin>
  6. Try some Maven commands in the "wls-maven-sample" directory
    1. The server can be started as:

      mvn wls:start-server
      -DmiddlewareHome=/Users/arungup/tools/weblogic/12c
      -DdomainHome=/Users/arungup/tools/weblogic/mydomain

      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building wls-maven-sample 1.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- wls-maven-plugin:12.1.1.0:start-server (default-cli) @ wls-maven-sample ---
      [INFO] ++====================================================================++
      [INFO] ++ wls-maven-plugin: start-server ++
      [INFO] ++====================================================================++
      .[INFO] Starting server in domain: /Users/arungup/tools/weblogic/mydomain
      [INFO] Check stdout file for details: /Users/arungup/tools/weblogic/mydomain/server-922019421247284651.out
      [INFO] Process being executed, waiting for completion.
      ................
      [INFO] Server started successful
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 16.919s
      [INFO] Finished at: Wed May 02 18:06:22 PDT 2012
      [INFO] Final Memory: 5M/88M
      [INFO] ------------------------------------------------------------------------
    2. Build and deploy the application as:

      mvn wls:deploy
      -DmiddlewareHome=/Users/arungup/tools/weblogic/12c
      -DdomainHome=/Users/arungup/tools/weblogic/mydomain
      -Duser=admin
      -Dpassword=admin007
      -Dsource=/Users/arungup/code/samples/weblogic/wls-maven-sample/target/wls-maven-sample-1.0-SNAPSHOT.war

      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building wls-maven-sample 1.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- wls-maven-plugin:12.1.1.0:deploy (default-cli) @ wls-maven-sample ---
      [INFO] ++====================================================================++
      [INFO] ++ wls-maven-plugin: deploy ++
      [INFO] ++====================================================================++
      weblogic.Deployer invoked with options: -noexit -user admin -deploy -source /Users/arungup/code/samples/weblogic/wls-maven-sample/target/wls-maven-sample-1.0-SNAPSHOT.war
      <May 3, 2012 8:24:17 AM IST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, wls-maven-sample-1.0-SNAPSHOT [archive: /Users/arungup/code/samples/weblogic/wls-maven-sample/target/wls-maven-sample-1.0-SNAPSHOT.war], to configured targets.>
      Task 0 initiated: [Deployer:149026]deploy application wls-maven-sample-1.0-SNAPSHOT on myserver.
      Task 0 completed: [Deployer:149026]deploy application wls-maven-sample-1.0-SNAPSHOT on myserver.
      Target state: deploy completed on Server myserver

      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 7.745s
      [INFO] Finished at: Thu May 03 08:24:18 IST 2012
      [INFO] Final Memory: 11M/130M
      [INFO] ------------------------------------------------------------------------
    3. The application is accessible at localhost:7001/wls-maven-sample-1.0-SNAPSHOT/TestServlet.
    4. Stop the server as:

      mvn wls:stop-server
      -DmiddlewareHome=/Users/arungup/tools/weblogic/12c
      -DdomainHome=/Users/arungup/tools/weblogic/mydomain
      -Duser=admin
      -Dpassword=admin007

      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building wls-maven-sample 1.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- wls-maven-plugin:12.1.1.0:stop-server (default-cli) @ wls-maven-sample ---
      [INFO] ++====================================================================++
      [INFO] ++ wls-maven-plugin: stop-server ++
      [INFO] ++====================================================================++
      [INFO] Stop server in domain: /Users/arungup/tools/weblogic/mydomain
      [INFO] Process being executed, waiting for completion.
      [INFO] [exec] Stopping Weblogic Server...
      [INFO] [exec]
      [INFO] [exec] Initializing WebLogic Scripting Tool (WLST) ...
      [INFO] [exec]
      [INFO] [exec] Welcome to WebLogic Server Administration Scripting Shell
      [INFO] [exec]
      [INFO] [exec] Type help() for help on available commands
      [INFO] [exec]
      [INFO] [exec] Connecting to t3://localhost:7001 with userid admin ...
      [INFO] [exec] Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'.
      [INFO] [exec]
      [INFO] [exec] Warning: An insecure protocol was used to connect to the
      [INFO] [exec] server. To ensure on-the-wire security, the SSL port or
      [INFO] [exec] Admin port should be used instead.
      [INFO] [exec]
      [INFO] [exec] Shutting down the server myserver with force=false while connected to myserver ...
      [INFO] [exec] WLST lost connection to the WebLogic Server that you were
      [INFO] [exec] connected to, this may happen if the server was shutdown or
      [INFO] [exec] partitioned. You will have to re-connect to the server once the
      [INFO] [exec] server is available.
      [INFO] [exec] Disconnected from weblogic server: myserver
      [INFO] [exec] Disconnected from weblogic server:
      [INFO] [exec]
      [INFO] [exec]
      [INFO] [exec] Exiting WebLogic Scripting Tool.
      [INFO] [exec]
      [INFO] [exec] Done
      [INFO] [exec] Stopping Derby Server...
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 10.847s
      [INFO] Finished at: Thu May 03 06:37:48 IST 2012
      [INFO] Final Memory: 9M/125M
      [INFO] ------------------------------------------------------------------------

Simple, quick, and easy!

Are you building Java EE 6 applications on WebLogic ? With Maven ? Now you can fully integrate the WebLogic lifecycle with your "pom.xml".

The WebLogic Application Development Guide provide detailed documentation on the maven plugin.


Geertjan's Blog - May 11, 2012 10:59 AM
Mass Format in NetBeans IDE 7.2

Prior to the upcoming 7.2 release, the Source | Format menu item would be disabled, unless the currently selected window was an editor document.

In 7.2, you can select any of these:

  • project node
  • Source Packages node
  • package node
  • folder node

And you can also select multiple nodes, from various kinds, of the above. You'll then see that Source | Format is enabled and functions as you might expect:

When the action is invoked everything within the selected nodes is formatted as defined by the rules defined in the Options window.

Related issue: https://www.netbeans.org/bugzilla/show_bug.cgi?id=67397

NetBeans Zone - The social network for developers - May 11, 2012 07:31 AM
NetBeans Platform

oirpThumb.JPG

NetBeans Ruminations » NetBeans - May 11, 2012 06:24 AM
Migrating my Mind to Maven (Part 4) – Building an Update Center

The ability to easily build an update center that users of your application can use to update their software, is a very useful feature of the NetBeans Platform. And being able to build this from the command line means that it can be useful on a build server.

For an Ant-based application, you can call the nbms target in the build script of the suite. The nbms and update.xml file will be built to <suite folder>/build/updates. This can also be executed from the NetBeans IDE by right-clicking on the suite project > Package As > NBMs.

With a Maven-based project, you can use the following command in the parent project folder:

mvn nbm:autoupdate

The nbms and update.xml file will be placed in the parent project folder, under target/netbeans_site.

NetBeans Zone - The social network for developers - May 10, 2012 07:11 PM
Customize NetBeans Platform Installer to Copy External Files During Installation

Installer software helps to copy application files to their expected locations. Well, not only to the application folder, but to any place on the system it is run on.The NetBeans Platform installer infrastructure helps to package and distribute software to any supported machine. The job is routine but it gets a bit tricky when it comes to customization.For instance, consider the situation that an...

Adam Bien - May 10, 2012 04:39 PM
Summer Java EE Workshops

  1. 23.05, Amsterdam Airport Java EE Hacking, Without Airport. The dutch version of Airport Hacking. Seems like sold out.
  2. 26.06-27.06, Munich Java EE Summit. I will give sessions about testing, patterns, anti-patterns and a "Productivity with Joy" workshop. Last year it was sold out.
  3. 09.07-10.07, Airport Munich Java EE Bootstrap and Effective Java EE workshops. At the first day I will focus on principles and essentials needed to bootstrap a Java EE project. The second day is all about tools, approaches and tricks for effective Java EE Development. The first edition of this workshop was sold out weeks before. After scaling the venue, there are still some seats available.

Conclusion: Everything Java EE related is sold out :-)
Real World Java EE Bootstrap and Effective Java EE Bootstrap Workshops [Airport Munich] Books: Real World Java EE Night Hacks - Dissecting Best Practices ...and the bestseller Real World Java EE - Rethinking Best Practices

Geertjan's Blog - May 10, 2012 07:00 AM
Geotk & NetBeans Platform

An alternative to OpenMap is Geotk. (Read here about the relationship between Geotk and GeoTools.) I recently wrote about how to get started setting up OpenMap in a NetBeans Platform application.

Now it's Geotk's turn. 

Here's some code to get a first impression of how it works:

public class Map extends JFrame {

    public Map() {
        initComponents();
        setLayout(new BorderLayout());
        MapContext mapContext = MapBuilder.createContext(DefaultGeographicCRS.WGS84);
        addShpData(mapContext);
        JMap2D map = new JMap2D();
        map.getContainer().setContext(mapContext);
        map.setBackground(new Color(0, 150, 150));
        JNavigationBar navBar = new JNavigationBar(map);
        add(navBar, BorderLayout.NORTH);
        add(map, BorderLayout.CENTER);
    }

    public static void addShpData(MapContext context) {
        
        try {
            
            DataStore store = DataStoreFinder.
                    getDataStore("url", Map.class.getResource("/some/path/Countries.shp"));
            
            Name name = store.getNames().iterator().next();
            
            FeatureCollection fs = 
                    store.createSession(true).getFeatureCollection(QueryBuilder.all(name));
            
            MapLayer layer = MapBuilder.createFeatureLayer(fs,
                    RandomStyleFactory.createRandomVectorStyle(fs));
            
            layer.setVisible(true);
            
            context.layers().add(layer);
        
        } catch (DataStoreException e) {
        }

    }

    ...
    ...
    ...

When the application above is run, the following is shown, depending on the selected Shape file:

Next, of course, I want to do the above within a NetBeans Platform application.

Here's the code I used, in a TopComponent, i.e., a copy/paste of the code above:

public final class MapTopComponent extends TopComponent {

    public MapTopComponent() {
        initComponents();
        setName(Bundle.CTL_MapTopComponent());
        setToolTipText(Bundle.HINT_MapTopComponent());
        setLayout(new BorderLayout());
        MapContext mapContext = MapBuilder.createContext(DefaultGeographicCRS.SPHERE);
        addShpData(mapContext);
        JMap2D map = new JMap2D();
        map.getContainer().setContext(mapContext);
        map.setBackground(new Color(0, 150, 150));
        JNavigationBar navBar = new JNavigationBar(map);
        add(navBar, BorderLayout.NORTH);
        add(map, BorderLayout.CENTER);
    }

    public void addShpData(MapContext context) {

        try {

            DataStore store = DataStoreFinder.getDataStore("url", 
                    MapTopComponent.class.getResource("Countries.shp"));

            Name name = store.getNames().iterator().next();

            Session session = store.createSession(true);

            FeatureCollection fs = session.getFeatureCollection(QueryBuilder.all(name));

            MapLayer layer = MapBuilder.createFeatureLayer(fs,
                    RandomStyleFactory.createDefaultVectorStyle(fs));

            layer.setVisible(true);

            context.layers().add(layer);

        } catch (DataStoreException e) {
        }

    }
    ...
    ...
    ...

However, when I run the above, I see the following:

The message in the error dialog above is:

"The ShapeFileDatastore does not support sortby query."

I wonder why this problem occurs, since the code works fine in a standard Java Swing application, but not in the NetBeans Platform. I have a feeling that the DataStore class is resolved to a different implementation in standard Java Swing to when used within the NetBeans Platform.

I asked Johann Sorel from the Geotk project for advice, and he told me: "Shapefile are flat files with few indexes, a sort by would cause the datastore to read the full file and potentialy take much memory." I tried various solutions based on what Johann sent, but so far without any luck. Hope to get this working!

Arun Gupta, Miles to go ... - May 10, 2012 04:45 AM
OTN Developer Days in Turkey and Johannesburg, Geecon in Poland, JEEConf in Ukraine


Several Java EE sessions around the world over next few days ...


Where: Ceylan Intercontinental Istanbul, Turkey
When: May 14, 9am
Sessions: Several Java EE 6/7 sessions
Agenda, Register



Where: Poznan, Poland
When: May 16-18
Sessions:
    Java EE 6 = Less Code + More Power (May 16, 9am)
    Java EE 7: Developing for the Cloud (May 16, 11:10am)
    JAX-RS 2.0: RESTful Java on Steroids (May 18, 11:20am)
    PaaSing a Java EE 6 Application (May 18, 2:30pm)



Where: International Exhibition Center, Kiev, Ukraine
When: May 19, 10am
Session: Java EE 7: Developing for the Cloud
Register



When: May 21
Where: The Forum, Johannesburg, South Africa
Session: Several
Agenda, Register


Where will I see or run with you ?

Geertjan's Blog - May 09, 2012 03:14 PM
JavaFX Charts for Kirk Pepperdine's VisualVM Plugin

Kirk Pepperdine wrote a VisualVM plugin sometime ago for displaying Java's memory pool statistics:

Sources are here: http://java.net/projects/memorypoolview 

Let's replace those charts with some of the cool charts provided by JavaFX. In real life, of course, the charts below are all squiggly and moving like a stock chart:

The data displayed above isn't real. The blog entry you're currently reading only deals with embedding JavaFX charts into Kirk's VisualVM plugin. It does not deal with the question about how to update those charts when the memory pool changes. That is a different discussion for another time. So, to get started, from the above, as you can see, I like this NetBeans IDE sample for JavaFX, which, as you can see from the above, would be a cool replacement for those blue lines in Kirk's plugin:

Of course, the above is an image; in real life it is an animated stock line like you might expect in stock applications. The above is one of the standard JavaFX samples that comes with NetBeans IDE, named "ChartAdvancedStockLine".

Let's start by transforming Kirk's plugin so that it is embedded in a nice comfy JavaFX environment. That entails two steps:

  1. Wrap the jfxrt.jar (the JavaFX Runtime JAR) into the module. Though a preferable approach in a modular application, such as VisualVM, would be to create a separate module for the JAR, it is quite convenient to stick it into the module where the JavaFX functionality is going to be found. That way we'll only have one NBM to distribute, instead of two. So, right-click the module, choose Properties, go to Libraries | Wrapped JARs, click Add JAR, and browse to the "jfxrt.jar" in your JavaFX distribution.

  2. Next, we need to include the JavaFX native libraries in our module. At some stage, maybe already in JDK 7 Update 4, those native libraries will at least be in the JDK. And, hopefully, ultimately, they'll be in the JRE (or in some additional JRE) so that the user will already have the native libraries available. Of course, since VisualVM is a JDK tool, having the JavaFX native libraries in the JDK will be exactly what is needed. However, in my case, I am on JDK 7 Update 2, so I am going to include the native libraries (for Windows only, since I'm on Windows right now as I make this plugin) for Windows only, just to prove that it works. Switch to the Files window in NetBeans IDE and copy all the DLL's into "release/modules/bin", which should be a directory you create for the first time. (In "release/modules/ext" you'll find the JAR you wrapped in the previous step.) Again, note that this is a temporary step, since the DLL's will ultimately be in the JDK already.

Now we're good to go. Let's start coding. In fact, not much coding, mostly refactoring, as you'll see.

  1. From the JavaFX example illustrated above, i.e., "ChartAdvancedStockLine", copy the variables at the top of the (only) class in the sample, i.e., "ChartAdvancedStockLine.java" to the top of Kirk's plugin's "MemoryPoolPanel.java" file:
    private XYChart.Series hourDataSeries;
    private XYChart.Series minuteDataSeries;
    private NumberAxis xAxis;
    private Timeline animation;
    
    private double hours = 0;
    private double minutes = 0;
    private double timeInHours = 0;
    private double prevY = 10;
    private double y = 10;
  2. Next copy the bulk of the code into the same class in Kirk's plugin, i.e., copy "createChart()", "nextTime()", "plotTime()", "play()", and "stop()", as shown below, i.e., the below is literally copied and pasted from the sample code:
    protected LineChart createChart() {
        xAxis = new NumberAxis(0, 24, 3);
        final NumberAxis yAxis = new NumberAxis(0, 100, 10);
        final LineChart lc = new LineChart(xAxis, yAxis);
        // setup chart
        lc.setId("lineStockDemo");
        lc.setCreateSymbols(false);
        lc.setAnimated(false);
        lc.setLegendVisible(false);
        lc.setTitle("ACME Company Stock");
        xAxis.setLabel("Time");
        xAxis.setForceZeroInRange(false);
        yAxis.setLabel("Share Price");
        yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis, "$", null));
        // add starting data
        hourDataSeries = new XYChart.Series();
        hourDataSeries.setName("Hourly Data");
        minuteDataSeries = new XYChart.Series();
        minuteDataSeries.setName("Minute Data");
        // create some starting data
        hourDataSeries.getData().add(new XYChart.Data(timeInHours, prevY));
        minuteDataSeries.getData().add(new XYChart.Data(timeInHours, prevY));
        for (double m = 0; m < (60); m++) {
            nextTime();
            plotTime();
        }
        lc.getData().add(minuteDataSeries);
        lc.getData().add(hourDataSeries);
        return lc;
    }
    
    private void nextTime() {
        if (minutes == 59) {
            hours++;
            minutes = 0;
        } else {
            minutes++;
        }
        timeInHours = hours + ((1d / 60d) * minutes);
    }
    
    private void plotTime() {
        if ((timeInHours % 1) == 0) {
            // change of hour
            double oldY = y;
            y = prevY - 10 + (Math.random() * 20);
            prevY = oldY;
            while (y < 10 || y > 90) {
                y = y - 10 + (Math.random() * 20);
            }
            hourDataSeries.getData().add(new XYChart.Data(timeInHours, prevY));
            // after 25hours delete old data
            if (timeInHours > 25) {
                hourDataSeries.getData().remove(0);
            }
            // every hour after 24 move range 1 hour
            if (timeInHours > 24) {
                xAxis.setLowerBound(xAxis.getLowerBound() + 1);
                xAxis.setUpperBound(xAxis.getUpperBound() + 1);
            }
        }
        double min = (timeInHours % 1);
        double randomPickVariance = Math.random();
        if (randomPickVariance < 0.3) {
            double minY = prevY + ((y - prevY) * min) - 4 + (Math.random() * 8);
            minuteDataSeries.getData().add(new XYChart.Data(timeInHours, minY));
        } else if (randomPickVariance < 0.7) {
            double minY = prevY + ((y - prevY) * min) - 6 + (Math.random() * 12);
            minuteDataSeries.getData().add(new XYChart.Data(timeInHours, minY));
        } else if (randomPickVariance < 0.95) {
            double minY = prevY + ((y - prevY) * min) - 10 + (Math.random() * 20);
            minuteDataSeries.getData().add(new XYChart.Data(timeInHours, minY));
        } else {
            double minY = prevY + ((y - prevY) * min) - 15 + (Math.random() * 30);
            minuteDataSeries.getData().add(new XYChart.Data(timeInHours, minY));
        }
        // after 25hours delete old data
        if (timeInHours > 25) {
            minuteDataSeries.getData().remove(0);
        }
    }
    
    public void play() {
        animation.play();
    }
    
    public void stop() {
        animation.pause();
    }
    
  3. Now we'll add our first bit of unique code to the class, though the body (i.e., the animation stuff) is directly copied from the JavaFX sample:
    private void initAndShowGUI() {
        final JFXPanel fxPanel = new JFXPanel();
        add(fxPanel, BorderLayout.CENTER);
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                fxPanel.setScene(new Scene(createChart()));
                animation = new Timeline();
                animation.getKeyFrames().add(new KeyFrame(Duration.millis(1000 / 60), new EventHandler() {
                    @Override
                    public void handle(ActionEvent actionEvent) {
                        // 6 minutes data per frame
                        for (int count = 0; count < 6; count++) {
                            nextTime();
                            plotTime();
                        }
                    }
                }));
                animation.setCycleCount(Animation.INDEFINITE);
                play();
            }
        });
    }

    So, we use the JFXPanel, since that's what it's for, i.e., it is a Swing container for embedding JavaFX code, in this case a Scene defined by our LineChart, which is returned by the "createChart()" method, which we moved into the class in the previous step. The initialization of the animation functionality is a direct copy/paste from the sample.


  4. At this stage, when you install the plugin, the JavaFX chart is running inside VisualVM! Now you need to customize the JavaFX chart to display the same info as in Kirk's original code. For example, use the "memoryPoolUpdated" method, which is an override from something Kirk created, to do something like this:
    @Override
    public void memoryPoolUpdated(MemoryPoolModel model) {
        long[] dataPoints = new long[2];
        dataPoints[0] = model.getCommitted();
        dataPoints[1] = model.getUsed();
    //        chart.addValues(System.currentTimeMillis(), dataPoints);
        animation.getKeyFrames().add(
             new KeyFrame(Duration.millis(System.currentTimeMillis()), 
             new EventHandler() {
        ...
        ...
        ...

    The point is, when the memory pool changes, you need to update the JavaFX chart. That synchronization is outside the scope of what I'm trying to do here, i.e., I want to show how the JavaFX charts can be embedded in VisualVM. If you're at this stage of the story, you're welcome to develop Kirk's plugin further, to show the JavaFX chart changing as the memory pool changes.

When I run it at this point in the proceedings, Kirk's plugin looks as follows in VisualVM:

Looking forward to what Kirk thinks of this and also to seeing this plugin come to a happy resolution in the JavaFX ecosystem!

NetBeans Zone - The social network for developers - May 09, 2012 12:42 PM
NetBeans Weekly News (Issue #536 - May 09, 2012)

Project News 10th Annual Duke's Choice Awards: Nominations Call The Duke's Choice Awards celebrate extreme innovation in the world of Java technology. NetBeans-based projects have been Duke winners in 2009 and 2011. Be a part of this distinguished group!

Geertjan's Blog - May 08, 2012 06:41 PM
Leveraging AgroSense, GeoViewer, and Maven

AgroSense is a Java open-source services platform for farm management. It looks like an extremely cool and well-designed app, on top of SwingX, GeoTools, the Flamingo Ribbon bar, the NetBeans Platform, and many other libraries. Click to enlarge the image to get a better view: 

As an open source project, the team is constantly looking for new developers to work with them, especially if you're interested in farm software. In fact, forget about creating your own farm software, just port your code to plugins for AgroSense. Come one, come all and join this truly useful Java project. (One simple way to join is to leave a message at the end of this blog entry and then you'll be contacted.)

The project is built via Maven. Here's the source structure in the IDE, from a Mercurial check out that I did today:

(Tushar Joshi from India should recognize part of the above project structure!) 

Artifacts from AgroSense are checked into Maven central, so parts of the above application can very easily be reused within your own Maven-based NetBeans Platform applications. For example, let's assume we want to reuse the mapping functionality from AgroSense, as provided by the "geoviewer" suite in the project structure above.

Here's what you need to do to achieve the above. 

1. Create a new Maven based NetBeans Platform application:

2. Give the application a name and other Maven properties:

3. Add these dependencies in the POM file of the NetBeans Platform application module:

<dependency>
    <groupId>nl.cloudfarming.client</groupId>
    <artifactId>geoviewer-api</artifactId>
    <version>1.0.24</version>
</dependency>
<dependency>
    <groupId>nl.cloudfarming.client</groupId>
    <artifactId>geoviewer-jxmap</artifactId>
    <version>1.0.24</version>
</dependency>

4. Build and run the application and you should see this:

Note: An example of AgroSense API usage for the GeoViewer is included in the "examples" folder in the Mercurial repository:

http://java.net/projects/agrosense/sources/core/show

I intend to discuss this example in an upcoming blog entry soon.

Geertjan's Blog - May 08, 2012 06:06 AM
OpenMap & NetBeans Platform

OpenMap is an open-source map technology. Integrated into the NetBeans Platform, you can click on a map (below one of the sample maps that comes with the OpenMap download is shown), and then use Lookup to publish items of interest for display in other windows, which can be undocked at startup (and the application can start in full screen mode) with tabs removed, creating the start of a typical mapping solution, such as used in air traffic control systems:

(My mouse isn't shown in the screenshot above, but it is on Ouagadougou in Burkina Faso. Hi Constantine and other NetBeans users in Ouagadougou!) 

Here's the code in the MapTopComponent, which is in the "editor" position above, with the tab removed, so that it covers the whole frame of the application: 

public final class MapTopComponent extends TopComponent {

    private final InstanceContent ic = new InstanceContent();

    public MapTopComponent() {

        initComponents();

        setName(Bundle.CTL_MapTopComponent());
        setToolTipText(Bundle.HINT_MapTopComponent());

        setLayout(new BorderLayout());

        try {

            //MapPanel:
            MapPanel mapPanel = new BasicMapPanel();

            //MapHandler:
            MapHandler mapHandler = mapPanel.getMapHandler();
            mapHandler.add(new LayerHandler());
            mapHandler.add(this);

            //MapBean:
            MapBean mapBean = mapPanel.getMapBean();
            mapBean.setScale(120000000f);

            //Selection:
            MouseDelegator mouseDelegator = new MouseDelegator();
            mapHandler.add(mouseDelegator);
            SelectMouseMode selectMouseMode = new SelectMouseMode();
            mapHandler.add(selectMouseMode);
            mouseDelegator.setActive(selectMouseMode);

            //MapMouseListener:
            final MyMapMouseListener myMapMouseListener = new MyMapMouseListener();

            //ShapeLayer: 
            ShapeLayer shapeLayer = new ShapeLayer() {
                @Override
                public synchronized MapMouseListener getMapMouseListener() {
                    return myMapMouseListener;
                }
            };

            //Properties:
            Properties shapeLayerProps = new Properties();
            shapeLayerProps.put("lineColor", "000000");
            shapeLayerProps.put("fillColor", "BDDE83");
            shapeLayerProps.put("shapeFile", "org/myatc/initializer/dcwpo-browse.shp");
            shapeLayerProps.put("spatialIndex", "org/myatc/initializer/dcwpo-browse.ssx");
            
            //Assign properties to ShapeLayer: 
            shapeLayer.setProperties(shapeLayerProps);
            shapeLayer.setVisible(true);

            //Assign ShapeLayer to MapHandler:
            mapHandler.add(shapeLayer);

            add(mapPanel.getMapBean(), BorderLayout.CENTER);

        } catch (MultipleSoloMapComponentException msmce) {
        }

        associateLookup(new AbstractLookup(ic));

    }

    public class MyMapMouseListener implements MapMouseListener {
        @Override
        public String[] getMouseModeServiceList() {
            return new String[]{SelectMouseMode.modeID};
        }
        @Override
        public boolean mouseClicked(MouseEvent e) {
            MapMouseEvent mme = (MapMouseEvent) e;
            //Optionally:
            //LatLonPoint latLonPoint = LatLonPoint.getFloat(mme.getLatLon());
            //UTMPoint utmPoint = UTMPoint.LLtoUTM(latLonPoint);
            //Publish something into Lookup:
            ic.set(Collections.singleton(mme.getLatLon()), null);
            return true;
        }
        @Override
        public boolean mousePressed(MouseEvent e) {return true;}
        @Override
        public boolean mouseReleased(MouseEvent e) {return true;}
        @Override
        public void mouseEntered(MouseEvent e) {}
        @Override
        public void mouseExited(MouseEvent e) {}
        @Override
        public boolean mouseDragged(MouseEvent e) {return true;}
        @Override
        public boolean mouseMoved(MouseEvent e) {return true;}
        @Override
        public void mouseMoved() {}
    }

    ...
    ...
    ...

NetBeans RSS Feed Filter - May 07, 2012 03:46 PM
JSF 2 Tip of the Day: Learning the JSF Lifecycle with a PhaseListener

I have to do some JSF training in the next couple of weeks for some of the staff at the company where I work. The learning curve for JSF has often been called a vertical wall. In part this is due to the JSF Lifecycle. The JSF Lifecycle has a number of phases, and before and after each phase there is an extension point where we can intervene in the process using a PhaseListener.

Since the PhaseListener intercepts the process, you can use it to learn the phases. The PhaseListener below is an example of one that reports on all PhaseEvents. You should modify it to learn what occurs during each phase.

PhaseListenerImpl.java

Here is the output:
INFO: Before Phase: RESTORE_VIEW 1 invoked.
INFO: After Phase: RESTORE_VIEW 1 invoked.
INFO: Before Phase: APPLY_REQUEST_VALUES 2 invoked.
INFO: After Phase: APPLY_REQUEST_VALUES 2 invoked.
INFO: Before Phase: PROCESS_VALIDATIONS 3 invoked.
INFO: After Phase: PROCESS_VALIDATIONS 3 invoked.
INFO: Before Phase: UPDATE_MODEL_VALUES 4 invoked.
INFO: After Phase: UPDATE_MODEL_VALUES 4 invoked.
INFO: Before Phase: INVOKE_APPLICATION 5 invoked.
INFO: After Phase: INVOKE_APPLICATION 5 invoked.
INFO: Before Phase: RENDER_RESPONSE 6 invoked.
INFO: After Phase: RENDER_RESPONSE 6 invoked.


NetBeans Zone - The social network for developers - May 07, 2012 05:03 AM
First Smoke Test: NetBeans IDE 7.1.2 & Oracle JDK 7u4 for Mac OS X

In case you didn't notice it, Oracle has released the first JDK 7 for Mac OS X made under its own responsibility. This is a historic milestone as in the past decade Apple did the whole job of porting, after some previous poor attempts by Sun. Unfortunately, Apple's work became unsatisfactory too, at least in some respects like constant delays or missing security patches such as those that shed...

NetBeans RSS Feed Filter - May 06, 2012 03:46 PM
JSF 2 Tip of the Day: JSF Page Redirection in PhaseListener

I needed to redirect a user to a login page the other day, and solved it using a PhaseListener. Subsequently, I had another need to do a page redirection based on a value in the HttpSession. I thought I would share the general idea of how to do it with you.

The PhaseListener allows us to take action at various integration points in the JSF lifecycle. The most likely place you will want to handle an internal redirection, is before the view is restored. We use the JSF NavigationHandler to do the work for us.

PageRedirectionPhaseListener.java