Č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
arrow.JARa's Bilingual Weblogfeed subscription
arrowAPIDesign - Blogsfeed subscription
arrowAdam Bienfeed subscription
arrowAdam Myatt's Weblogfeed subscription
arrowAlex Kotchnev's blogfeed subscription
arrowAmateur's Codingfeed subscription
arrowAmit Kumar Saha's Blogfeed subscription
arrowAmit Kumar Saha's Blogfeed subscription
arrowAn Open Source Fasciculefeed subscription
arrowAnother Random Developer Blog » NetBeansfeed subscription
arrowAnuradha G Blogfeed subscription
arrowBernhard's Weblogfeed subscription
arrowBig Al's Blogfeed subscription
arrowBistro!feed subscription
arrowBrian Leonard's Blogfeed subscription
arrowCarsten Zerbst's Weblogfeed subscription
arrowCharlie Hunt's Weblogfeed subscription
arrowChris Webster's Weblogfeed subscription
arrowCode Snakesfeed subscription
arrowComputer says null;feed subscription
arrowCraig McClanahan's Weblogfeed subscription
arrowDavid Coldrick's Weblogfeed subscription
arrowDevel Blogfeed subscription
arrowDevlin's Labfeed subscription
arrowDiego Torres Milano's blogfeed subscription
arrowGeertjan's Blogfeed subscription
arrowGregg Sporar @Sunfeed subscription
arrowHans Muller's Blogfeed subscription
arrowHulles - NetBeansfeed subscription
arrowInsert Witty Irony Herefeed subscription
arrowInside of the NetBeans Mobilityfeed subscription
arrowInsider Scoop From the Tutorial Divasfeed subscription
arrowInspiration and Expression » Netbeansfeed subscription
arrowJames' Blogfeed subscription
arrowJan (Hanz) Jancura's Blogfeed subscription
arrowJanice Campbell's Weblogfeed subscription
arrowJean-Francois Denise : JMX, NetBeans and more!feed subscription
arrowJesse Glickfeed subscription
arrowJohn O'Connerfeed subscription
arrowJonathan H Fisher - Blog » Netbeansfeed subscription
arrowJun Qian (钱骏) 's Weblogfeed subscription
arrowKuldip Oberoi's Blog » NetBeansfeed subscription
arrowLudovic Champenois's Blogfeed subscription
arrowLukas Hasik's Weblogfeed subscription
arrowMartin Adamek's Blogfeed subscription
arrowMartin Grebacfeed subscription
arrowMasaki Katakai's Weblogfeed subscription
arrowMichel Graciano's Weblogfeed subscription
arrowMilan's blogfeed subscription
arrowMiles to go ...feed subscription
arrowMobility Everywherefeed subscription
arrowNETBEANS 6.1feed subscription
arrowNetBeans Adventures, Java and morefeed subscription
arrowNetBeans Community Docs Blogfeed subscription
arrowNetBeans Core QAfeed subscription
arrowNetBeans Profilerfeed subscription
arrowNetBeans Support Weblogfeed subscription
arrowNetBeans for PHPfeed subscription
arrowNetbeansfeed subscription
arrowNetbeans6/6.1beta my best practicesfeed subscription
arrowOctavian Tanase's Weblogfeed subscription
arrowOne Minute Distractionfeed subscription
arrowPatrick Keegan's Blogfeed subscription
arrowPavel Buzek's Weblogfeed subscription
arrowPetr Chytil's Weblogfeed subscription
arrowRamon.Ramosfeed subscription
arrowRechtacek'sfeed subscription
arrowRich Unger's Blogfeed subscription
arrowRoumen's Weblogfeed subscription
arrowSatya's Blogfeed subscription
arrowSeapegasus Blogfeed subscription
arrowShuttle between Galaxiesfeed subscription
arrowStan's Weblogfeed subscription
arrowThe Netbeans Experiencefeed subscription
arrowThe Next Wavefeed subscription
arrowThe Portal Postfeed subscription
arrowTim Boudreau's Blogfeed subscription
arrowTom Ball's Blogfeed subscription
arrowTomasz Slota's Weblogfeed subscription
arrowToni Epple » netbeansfeed subscription
arrowTor Norbye's Weblogfeed subscription
arrowVadiraj's Blogfeed subscription
arrowVincent Brabant's Blogfeed subscription
arrowVirtual Stevefeed subscription
arrowVivek's Weblogfeed subscription
arrowWeb Cornucopiafeed subscription
arrowWhisht Windfeed subscription
arrowWinston Prakash's Weblogfeed subscription
arrowXzajo's Weblogfeed subscription
arrow[digital:meditation]feed subscription
arrowcldfeed subscription
arrowdavidsalter.co.uk - NetBeansfeed subscription
arrowmkleintfeed subscription
arrowsandip chitale's blogfeed subscription
arrowtm's weblogfeed subscription
Where's my Blog?!

Powered by:    Planet

Last updated:
July 23, 2008 07:15 PM
All times are UTC

sponsored by Sun Microsystems

visit NetBeans website
Geertjan's Blog - July 23, 2008 04:33 PM
Groovy Makes Web Services Embarrassingly Easy

Meera pointed me to another very cool article she's written, RESTful Web Services in 60 Seconds, and (because I've been in an intensely groovy frame of mind for a few days now), I immediately associated it with my earlier experiments with Groovy and web services, in a blog entry entitled Groovy Web Service from the end of last year, based on some key learnings from the official Groovy web service site, (which has expanded a lot since then, I noticed today). At the time, I needed to hack things quite a bit to get web services to work with Groovy in NetBeans IDE (as honestly recorded in that blog entry).

So, I thought, how do things stand today in terms of Groovy and web services in NetBeans IDE? To be perfectly honest, the improvement couldn't have been much better, aside from the currently incomplete code completion (which is a work in progress still). In fact, I was able to mix and match Matisse with a Groovy web service, although you can't tell from the result:

This is the actionPerformed in the JButton in the Matisse form that you see above:

ShakesWSClient shakes = new ShakesWSClient();
    
private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {                                         
    String searchString = shakes.setSearchString(searchTextArea.getText());
    resultTextArea.setText(searchString);
}

And this is the ENTIRE web service client:

package org.me.hello

import groovyx.net.ws.WSClient

class ShakesWSClient {

    def proxy = new WSClient("http://www.xmlme.com/WSShakespeare.asmx?WSDL", ShakesWSClient.class.classLoader)
	
    String setSearchString(searchString) {
        def newQuote = proxy.GetSpeech(searchString)
        return newQuote
    }

}

Really, that's just a bit ridiculous. And I'm sure that the Groovy experts could cut the above code down a few lines and characters further. And I didn't need to hack anything in NetBeans. The Groovy class behaved seamlessly with the Java class.

NetBeans Core QA - July 23, 2008 02:04 PM
Why is 'Build' action grey on new project?

Create new project in NetBeans IDE. Right click the project. The Build and Clean action is always grey out.

When you open an old project then it is there. So what is the magic here? Go to project properties, in category Compiling you'll find Compile On Save check box. When checked then the saved file is always compiled when you save it.


Are you interested in more details? Try it in latest builds or read the specification.

Michel Graciano's Weblog - July 23, 2008 01:59 PM
NetBeans 6.5 - Database support refreshed...

The main NetBeans 6.5 feature I have been looking forward to is the new database support. For details about what is coming, look here for details.
For now, we already can use code completion, some features as editable queries result, quick column info on result table and another really cool features. You can see below an image about what is coming...


[Click to enlarge]

BTW, the execution plan will be implemented just for feature versions. If it is important to you, vote for it now here! :)

Happy coding!

Bistro! - July 23, 2008 12:46 PM
A visit to JUG Ukraine

Call me crazy or workaholic but I took a few hours out of my vacation in Kiev, Ukraine to visit the local JUG.

The meeting was hosted at GlobalLogic (somewhat of a geek's paradise) and was pretty well attended given the last-minute organization. The presentation slides (in English) are here and the full photo album there.

The presentation started with a bit of a challenge as no one was using GlassFish (mainly WebLogic, WebpShere, Tomcat and some JBoss). Given the presentation + Q&A session lasted almost 2 hours, I think it's fair to say that the interest was great. There were many questions during and after the presentation. Here's the refined Q&A:

OpenESB looks interesting (documentation, NetBeans graphical tooling, ...), but can I use BPEL4People with it?
Unfortunately IBM does not support JBI and to the best of my knowledge, there is no BPEL4People service engine. OpenESB and JavaCAPS do come with a WS-BPEL implementation though.

What is the Hibernate/TopLink split? (me asking)
- Hibernate: 60%
- TopLink: 40%

Is the 404 error in the admin console during your demo a bug or a feature ? ;)
It's certainly a bug. Fixed in GlassFish 2.1.

Can I deploy OSGi bundles on GlassFish v3?
Well, GlassFish v3 is running on top of Felix by default so it can host any OSGi bundle. The question is rather how it can extend the features of GFv3. This is a nice picture to explain the additional metadata required.

Can GlassFish run on the JRE (not the JDK)? This makes a difference for me in terms of re-distribution.
Provided you don't need to compile JSP's, GlassFish should run fine on top of the JRE, but this has not been extensively tested. Note that creating domains also requires the JDK (although that's not really runtime per say). I'll probably blog more on this, including the legal side to this (yes, you can redistribute the JDK).

How does GlassFish manage the ClassPath when using JSR 199 (Java Compiler API) to compile JSP's?
The default JavaDoc for this API isn't really helpful. In general, JavaCompiler.getTask(...) gives you the ability to pass a set of options, including a classpath. You may also find this testing API to he helpful in debugging compile issues. Finally, this link explains the performance benefits of using JDK 6's javac API in GlassFish. All is done dynamically now, all you need to do is use Java 6 to run GlassFish.

Does GlassFish support distributed transactions between multiple JVMs?
Well, if you're talking about WS-Coordination and WS-AtomicTransaction, these are both implemented as part of the Metro Web Services tack which itself is part of GlassFish v2 and above. This enables distributed transactions even with .Net services.

You claim that Grizzly has very good performance for serving both static and dynamic data. Do you have any benchmark results?
Yes. You probably want to start looking at this original post by Jean-François Arcand. It's a bit old but Grizzly and GlassFish only got better with time!

How do you move from one version of GlassFish to another? Other products make this pretty painful.
We take compatibility very seriously. It's a company thing (think Java 1.0). With every copy of GlassFish we provide bin/asupgrade which allows you to point to a source GlassFish domain, say GlassFish v1, and a target, say GlassFish v2. The tool will proceed to read the applications, resources, and configuration and recreate them in the target application server. You can achieve similar results with bin/asadmin backup-domain and bin/asadmin restore-domain within a single version of GlassFish.

Have people started using GlassFish in production? Any more you could share?
Some people (like Wotif.com) have started using GlassFish v1 in production. With the release of GlassFish v2 less than a year ago, we've seen a great level of deployments some (a fraction) is discussed by the users themselves on this blog: http://blogs.sun.com/stories.

Does GlassFish suffer from the same memory leaks as Tomcat on redeploys?
We've fixed a couple of bug in GlassFish v2 which should make the redeployment of artifacts painless, including on Windows which had a tendency to lock deployed files.

So there you are, this is all the questions I could remember. If you have more, please comment here, I'll add them to the entry.

Adam Bien - July 23, 2008 11:18 AM
"No XML" - Dependency Injection (EJB 3) For Absolute Beginners, or Is Possible To Inject With Less Code / XML?

If you already invested the three minutes working through the post "EJB 3 (@Session) For Absolute Beginners - 3 Minutes Bootstrap, 5 Steps", you can skip the requirements section.

Requirements:

  1. Installled JDK 1.5 (better 1.6) 
  2. An IDE of your choice e.g. vi, emacs, netbeans 6.1 (SE or EE), Eclipse Genymede (SE or EE)
  3. @Stateless, @Local, @Entity, @Id Annotations in classpath
  4. An Java EE 5 capable application server of your choice. It will work with Glassfish v1+ (better v2), JBoss 4.2+, WLS 10+ and probably Geronimo (not tried yed)

What is Dependency Injection (DI)?

DI is a fancy term for a simple thing: someone (in this case something -> the EJB 3 container) cares about managing the dependencies for you. You just have to declare the need for it.
EJB 3 is using annotations for this purpose, absolutely NO XML is needed.

Basically: everything which is stored in JNDI can be injected, instead of "looked up".

What is to do:

  1. To inject one Session Bean to another use the @EJB annotation:
    @Stateless
    public class BookServiceBean implements BookService {
        @EJB
        private SearchService search;


    Common error: you cannot inject classes in EJB 3.0, but only interfaces. This will change in EJB 3.1...

  2. To inject a DataSource, Queue, ConnectionFactory, Mail, SessionContext etc. you will need the @Resource annotation:
    @Stateless
    public class BookServiceBean implements BookService {
       
        @Resource(mappedName="jndi/sample")
        private DataSource ds;


  3. To use the persistence, just use the @PersistenceContext annotation:
@Stateless
public class BookServiceBean implements BookService {
    @PersistenceContext
    private EntityManager em;


How it works:

EJB 3 DI operates in "Convention over Configuration" mode. So in general: in case there is only one possibility - it will be injected.
If there are more than one, you will have to configure manifesting your choice...

The easiest possible start:

...is with Netbeans 6.1 (EE) -  download the first choice (139 MB - all included). It will not only install the IDE, but the application server (Reference Implementation: Glassfish RI), sample database etc. Eclipse's Ganymede is good as well, however you will need more projects (one for EJB 3, one for JPA), setup the application server etc. so it takes slightly more time if you are an absolute beginner :-).

Why is it good:

  1. No overhead - the code is as lean as it can be (any suggestions to make it simpler? :-)). The jar contains nothing else, but the interfaces and classes.
  2. It's simple - and sufficient for most use cases.
  3. Is easy to test: the reference can be set in JUnit directly (I will cover this in one of the next posts)
  4. Is configurable - all annotations can be overruled by XML. Even legacy POJOs can be integrated that way. See an extrem example - the deployment of a Swing Table Model as EJB 3 :-).
  5. No vendor lock in: EJB 3 is one and only component model I now, which is vendor neutral, with several available implementations (JBoss, Glassfish, Weblogic, Websphere, openEJB, SAP, Spring Pitchfork, Geronimo + forgotten ones). Google Guice is, however, promising as well. The dependency to EJB 3 spec itself is low - if it does not work for you, you can deploy this "pojos" to something else...
  6. The EJB 3 container is able to monitor (see e.g. Glassfish CallFlow) the whole invocation chain of EJBs. If you are developer: you probably don't care, but your operations :-)

Jun Qian (钱骏) 's Weblog - July 23, 2008 12:05 AM
XAM AutoGen: a tool to automate XAM model generation

XAM (Extensible Abstract Model) is an extensible framework for building domain-specific object model on top of any base models. Many NetBeans modules (such as WSDL Model, Schema Model, XSLT Model, BPEL Model) are built on top of XAM. A XAM-based model is best suited for an IDE like NetBeans because of its IDE-friendly features (unlimited undo/redo, automatic synchronization, document fidelity, etc.), but you are not tied to NetBeans by using XAM.

To create a XAM-based model, one typically starts from the schema describing the domain. It's a very tedious process to generate all the Java interfaces and implementation classes, along with the all plumbing classes (factories, visitors, etc.). 

To ease the pain of manual class creation, a tool is needed to auto generate a XAM-based model from a XML schema. This blog entry describes a tool that takes a domain schema as input, and uses Velocity templates to generate a XAM-based model.

This tool doesn't use any popular schema language (such as XML Schema (W3C), or Relax NG.)  There are a couple of reasons:

  1. A formal XML schema language is a little bit too heavy. I want to clearly define what is supported and what is not.
  2. In addition to domain typing, I also want to add extra semantics. For example, I want to express an element FOO has an attribute BAR of type URI or QName which refers to another element BAZ in this or even a foreign domain.
The following is the meta schema (the schema for your domain schema) used by this tool:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://xml.netbeans.org/schema/xamgen"
            xmlns:tns="http://xml.netbeans.org/schema/xamgen"
            elementFormDefault="qualified"> 
               
    <xsd:element name="Content">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Element"  minOccurs="0" maxOccurs="unbounded"/>
                <xsd:element name="EnumType" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>    

    <xsd:element name="Element">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Attribute" minOccurs="0" maxOccurs="unbounded"/>
                <xsd:element name="ChildElement" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="name" type="xsd:string" use="required"/>
            <xsd:attribute name="className" type="xsd:string"/>
            <xsd:attribute name="root" type="xsd:boolean" default="false"/>
            <xsd:attribute name="virtual" type="xsd:boolean" default="false"/>
            <xsd:attribute name="base" type="xsd:string"/>
            <xsd:attribute name="anyAttribute" type="xsd:boolean" default="false"/>
            <xsd:attribute name="anyElement" type="xsd:boolean" default="false"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Attribute">
        <xsd:complexType>
            <xsd:attribute name="name" type="xsd:string" use="required"/>
            <xsd:attribute name="type" type="xsd:string" use="required"/>
            <xsd:attribute name="reference" type="xsd:string"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="ChildElement">
        <xsd:complexType>
            <xsd:attribute name="name" type="xsd:string" use="required"/>
            <xsd:attribute name="multiplicity" type="xsd:string" default="n"/>
            <xsd:attribute name="ordered" type="xsd:boolean" default="false"/>
        </xsd:complexType>
    </xsd:element>    

    <xsd:element name="EnumType">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Enumeration" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="Enumeration">
        <xsd:complexType>
            <xsd:attribute name="value" type="xsd:string" use="required"/>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Most of it should be pretty straightforward. Here are a few notes:

  • Element.root: whether this element is a root element in an instance document in your domain. Multiple root elements in a domain are allowed.
  • Element.className: you can use this attribute to overwrite the default component class name derived from the element name.
  • Element.abstract: whether the corresponding component class is abstract.
  • Element.base: the name of the element whose corresponding domain component class serves as a base class.
  • Attribute.type: Java type, for example, "String", "boolean", "java.util.List<javax.xml.namespace.QName>".
  • Attribute.reference: use this if the attribute value references another component in the model.
    • If you want to reference a component that can be globally identified by QName, use "QName" for the corresponding Attribute.type;
    • For local reference, you can use "String" or "URI" as Attribute.type. Note that you can define the reference to be something like "elementA/elementB" for a multi-level reference.

Example:

Here is a schema instance describing an example domain:

<Content xmlns="http://xml.netbeans.org/schema/xamgen" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xml.netbeans.org/schema/xamgen xamgen.xsd">
    
    <Element name="composite" root="true">
        <Attribute name="name" type="String"/>
        <Attribute name="targetNamespace" type="java.net.URI"/>        
        <ChildElement name="component"/>
        <ChildElement name="connection"/>
    </Element>
    
    <Element name="component">
        <Attribute name="name" type="String"/>        
        <ChildElement name="provides"/>
        <ChildElement name="consumes"/>
        <ChildElement name="property"/>
    </Element>
    
    <Element name="endpoint" virtual="true">
        <Attribute name="name" type="String"/>        
        <ChildElement name="interface" multiplicity="1"/>
    </Element>
    
    <Element name="provides" base="endpoint"/>
    
    <Element name="consumes" base="endpoint"/>
    
    <Element name="property">
        <Attribute name="name" type="String"/>
        <Attribute name="value" type="String"/>
        <Attribute name="override" type="OverrideOptions"/>        
    </Element>
    
    <Element name="connection">
        <Attribute name="source" type="javax.xml.namespace.QName" reference="consumes"/>
        <Attribute name="target" type="javax.xml.namespace.QName" reference="provides"/>
    </Element>
              
    <Element name="interface" virtual="true"/>
    
    <Element name="interface.wsdl" className="InterfaceWSDL" base="interface">
        <Attribute name="interface" type="java.net.URI"/>
    </Element>
            
    <EnumType name="OverrideOptions">
        <Enumeration value="no"/>
        <Enumeration value="may"/>
        <Enumeration value="must"/>
    </EnumType>        
</Content>

Here is a little configuration file:

# XML file describing the domain data model.
domainDataModelFile=DemoDataModel.xml

# Namespace URI for the domain model
namespaceURI=http://www.yourorg.org/xmlns/foo/1.0

# Name of the domain model, such as "WSDL", "Schema", etc.
domainModelName=Foo

# Package name for the base model classes.
modelPackage=org.yourorg.foo.model

# Header file to be included in all the generated Java files.
headerFile=Header.txt

# Your name
author=jqian

The following shows the list of classes this XAM AutoGen Tool spits out when fed with the above domain schema and configuration file:


Usage:

Here is the steps you need to take to use this tool:

  1. Unzip this zip file
  2. Define your domain data model under the config directory.
  3. Configure a few properties in config/config.properties
  4. Run "java  -jar  XAMGenerator.jar  <output_dir>". (The output_dir could be your Java project or NetBeans module project's source directory.)
  5. In your project, add dependency to platform8/lib/org-openide-util.jar and ide9/modules/org-netbeans-modules-xml-xam.jar under your NetBeans directory.

That's it.

I am currently using this tool to auto generate the data model for SCA (Service Component Architecture). Here is the domain schema for the SCA Assembly Model. You can compare it with the original XSD Schemas. Based on my usage, I am going to keep improving this XAM AutoGen Tool . If you have any comments or suggestions, I am all ears.

P.S. I found this NetBeans Velocity plugin along the way. Very nice as a Velocity template viewer, but once you start editing the templates, it's getting a little crazy sometimes.

Geertjan's Blog - July 22, 2008 11:55 PM
Creating a Grails Plugin in NetBeans IDE

Let's create a plugin for Grails. Grails is, after all, modular and pluggable. Here's the ultimate simple Grails plugin, just to give an idea what is involved, from start to finish. The most useful references I have found so far are these:

Between those three, you should have enough to figure things out. I still found it hard, despite those instructions and so to avoid having to figure things out again some time in the future, I'll write absolutely everything here.

Creating the Plugin

  1. On the command line, run this:
    grails create-plugin SamplePlugin

    Now you have a Grails plugin. However, at the same time it is just another Grails application, which means you can simply open it in NetBeans IDE. (I.e., there is no import process and no NetBeans artifacts are added to the plugin in order to be able to open it in the IDE.)

  2. So open the plugin in the IDE. The Projects window isn't very interesting, it just shows you the same as you would normally see for Grails applications:

    The Files window (Ctrl-2) however, shows a lot more:

    Open the "SamplePluginGrailsPlugin.groovy" file and there you see the following:

    class SamplePluginGrailsPlugin {
        def version = 0.1
        def dependsOn = [:]
    	
        def doWithSpring = {
            // TODO Implement runtime spring config (optional)
        }
       
        def doWithApplicationContext = { applicationContext ->
            // TODO Implement post initialization spring config (optional)		
        }
    
        def doWithWebDescriptor = { xml ->
            // TODO Implement additions to web.xml (optional)
        }
    	                                      
        def doWithDynamicMethods = { ctx ->
            // TODO Implement registering dynamic methods to classes (optional)
        }
    	
        def onChange = { event ->
            // TODO Implement code that is executed when this class plugin class is changed  
            // the event contains: event.application and event.applicationContext objects
        }
                                                                                      
        def onApplicationChange = { event ->
            // TODO Implement code that is executed when any class in a GrailsApplication changes
            // the event contain: event.source, event.application and event.applicationContext objects
        }
    }

    I.e., you have hooks for integrating your code into meaningful places in the plugin.

  3. Now we'll create code that will let our plugin provide a new "constraint". (If you don't know what that is, you will know by the time you finish reading all this.) To do so, we will need to extend org.codehaus.groovy.grails.validation.AbstractConstraint, in a package within src/groovy:
    import org.codehaus.groovy.grails.validation.AbstractConstraint
    import org.springframework.validation.Errors
    
    class BestFrameworkConstraint extends AbstractConstraint {
    
        private static final String DEFAULT_MESSAGE_CODE = "default.answer.invalid.message";
        public static final String NAME = "oneCorrectResponse";
    
        private boolean validateConstraint
    
        //The parameter which the constraint is validated against:
        @Override
        public void setParameter(Object constraintParameter) {
            if (!(constraintParameter instanceof Boolean))
                throw new IllegalArgumentException("Parameter for constraint ["
                        + NAME + "] of property ["
                        + constraintPropertyName + "] of class ["
                        + constraintOwningClass + "] must be a boolean value");
            this.validateConstraint = ((Boolean) constraintParameter).booleanValue()
            super.setParameter(constraintParameter);
        }
    
        //Returns the default message for the given message code in the current locale:
        @Override
        protected void processValidate(Object target, Object propertyValue, Errors errors) {
            if (validateConstraint && !validate(target, propertyValue)) {
                def args = (Object[]) [constraintPropertyName, constraintOwningClass,
                        propertyValue]
                super.rejectValue(target, errors, DEFAULT_MESSAGE_CODE,
                        "not." + NAME, args);
            }
        }
    
        //Returns whether the constraint supports being applied against the specified type:
        @Override
        boolean supports(Class type) {
            return type != null && String.class.isAssignableFrom(type);
        }
    
        //The name of the constraint, which the user of the plugin will use
        //when working with your plugin.
        @Override
        String getName() {
            return NAME;
        }
    
        //Validate this constraint against a property value,
        //In this case, ONLY "Grails" is valid, everything else will cause an error:
        @Override
        boolean validate(target, propertyValue) {
            propertyValue ==~ /^Grails$/
        }
    
    }

  4. Next, back in the Groovy plugin class that we looked at earlier, hook the above class into the plugin, using the "doWithSpring" closure to do so:
    def doWithSpring = {
        ConstrainedProperty.registerNewConstraint(
            BestFrameworkConstraint.NAME,
            BestFrameworkConstraint.class);
    }

  5. Now, back on the command line, navigate to within the "SamplePlugin" folder. There, run the following:
    grails package-plugin

    Back in the IDE, examine the ZIP file that the above command created:

That ZIP file is your Grails plugin.

Installing the Plugin

Now we will install our plugin in a new application.

  1. First, create a new Grails application by going to the New Project wizard (Ctrl-Shift-N) and choosing Groovy | Grails Application. Click Next and type "SampleApplication" and then click Finish.

  2. After the IDE has finished running the "grails create-app" command for you, you will see the new application open in the IDE. Right-click it and choose "Plugins", as shown here:

  3. In the Grails Plugins dialog, notice that the list gets filled with many potential plugins that you might want to install, from the Grails plugins repository. Instead, we'll install our own. Click Browse and browse to the ZIP file that we created three steps ago and notice that it appears in the text field at the bottom of the dialog:

  4. Click "Install" and then a progress bar appears, ending with the plugin being installed. Notice that you can also uninstall it:

  5. Take a look at your application and notice (in the Files window) what's happened to the plugin. It's been unzipped, plus the ZIP file is still there. And all that's been done in the "plugins" folder. Nothing else has changed, which means that uninstallation is as simple as removing the folder from the "plugins" folder:

    Thanks to "convention over configuration", Grails knows exactly where everything is—so that, for example, the "plugin.xml" file that you see above, if found within the folder structure you see above, is the indicator to Grails that a plugin is available for use.

Using the Functionality Provided By the Plugin

  1. Let's now use our plugin. Create a domain class called "Quiz", after right-clicking the "Domain Classes" node and choosing "Create new Domain Class":

  2. Right-click the "Controllers" node and choose "Create new controller". Type "Quiz" and then click Finish. Use the Groovy editor to add one line for adding the scaffolding (and uncomment the other line):

  3. Back in the "Quiz" domain class, add your property and use the "oneCorrectResponse" constraint defined in your plugin, as shown here:

    Note: The "oneCorrectResponse" constraint that you see above is the name of the constraint defined in the plugin.

  4. And then add the message to the messages.properties file, which is within the "Messages Bundles" node:

  5. Run the application and you will see that your constraint will prevent anything other than "Grails" from being considered acceptable, when "Create" is clicked below:

Congratulations, you've created, installed, and used your first Grails plugin!

Another Random Developer Blog » NetBeans - July 22, 2008 08:45 PM
Using Spring and Facelets together with NetBeans 6.1


[Read more]

Technorati Tags:: Facelets, GlassFish, Java, MyFaces, NetBeans, Spring

tm's weblog - July 22, 2008 02:55 PM
Hudson as a tool for testing? Yes!

Lots of folks in NetBeans started to use Hudson as a tool for continuous integration, or just for building NetBeans from various clones, or to build test, whatever you can imagine. Just take a look at Deadlock machine and you will see a plenty of NetBeans related jobs. We (NetBeans QE) recently got an idea to utilize Hudson as our testing infrastructure. Yes, NetBeans have a lot of automated tests that are being ran daily and test results are evaluated for potential problems. So you have tests, you have machines, but you still need an infrastructure to connect this together. We chose Hudson, because it's a great tool, and what's really cool - is extensible by various plugins (available on Hudson's web, or you can write your own if you wish). The basic idea was to use Hudson as "master-slave" architecture, where you simply set up on master what do you want to run, and master distributes the work to the slaves, that execute the jobs. More detailed approach to this - configure on master which tests do you want to run on which platforms, and they will get executed on appropriate slaves. And getting one level lower - to achieve this, you have to have something we called generic Ant script, which will provide all the stuff needed to execute test:

  1. Download IDE - the IDE build which will be tested
  2. Download NetBeans Test Distribution - Test Distribution contains binaries of all tests from NetBeans repo.
  3. Run selected tests - Specify which tests from Test Distribution will run in tested IDE
So i wrote and Ant script with plenty of useful targets to provide this functionality (Yeah, by this I learned a lot how to write Ant scrips:-) ). This Ant script is generic, and all the stuff like where to take IDE build, where to take Test Distribution, which tests run, what to do with results etc. are controlled by passing corresponding properties. Once we have this working, the only thing we have to do, is to distribute the Ant script to machine we want to run tests on, and provide some better UI than command line for the main properties, which control the test execution. Therefore me and Max Sauer extended Hudson by Test Run Plugin (sources are not public right now), that enables Hudson to copy our generic Ant script on target slave machines and extends job configuration with our panel for setting properties for testrun. With all this stuff working, people can simply log in on master, select one or more slave machines on which will tests run, configure which build will be tested by which test (through nice GUI :-) ), run the job and take a nap while watching the progress of tests execution on target machines. When test run is finished, you get a nice overview of test results (yes, built-in feature of Hudson).
The main benefits we take from Hudson (aka features we really like):
  • Master-slave architecture - you can have various machine with various architectures/OS added into testing farm.
  • JUnit results processing - nice HTML, results trends, charts,...
  • Scheduler - triggering of testrun by another job (which can listen e.g. if new production build is available), or "cron-like" settings.
  • Email notification - send email if tests do not pass.
  • SCP plugin - we can send test results to remote machine that can parse them and store into DB.
  • Authentication - simply configure and point Hudson to your LDAP server, really out of box functionality.
  • Multiple JDK installations - specify location where are JDKs located and voila - you can run whole matrix of tests - one axis is JDKs, second is platform.
  • ...many many others:-)
And conclusion? Hudson is not only contentious integration tool, it can be almost whatever you like.

NetBeans for PHP - July 22, 2008 01:25 PM
Feature freeze was reached

Our team has reached the feature freeze for NetBeans 6.5. It means we will concentrate mainly on stabilization, bug fixing and improving performance. And this is where you can really help us. How? Try a development build or NetBeans 6.5 M1. NetBeans 6.5 M2 is planned to be published on Aug 11th, so it will be a good idea to switch to it then.

If you find any bug or you have feature and enhancement requests, enter them in Issuezilla (you have to be log in). We always appreciate it.  And don't forget to include additional information such as the build number, OS etc. This information can be easily copied from the About dialog.

Although we are in the stabilization phase, minor improvements are still possible. We are trying to create superb PHP IDE and you can help us enormously. Just let us know what you think. Also feel free to write your opinions, suggestions  here or discuss it on users@php.netbeans.org  mainling list. Subscribing is easy, just send an empty email to users-subscribe@php.netbeans.org.

cld - July 22, 2008 07:56 AM
StarOffice 9 Beta Available

StarOffice 9 Beta is available. More....

Bistro! - July 22, 2008 05:20 AM
Gartner sur l'open source Sun : "Strong Positive"

Si vous m'avez entendu présenter sur GlassFish, j'ai probablement mentionné les commentaires de Gartner en expliquant que vous (développeur, architecte) n'accordiez peut-être pas beaucoup d'intérêt à ce genre de commentaire, mais qu'il suffisait probablement de monter de un ou de deux crans dans la hiérarchie pour que ca devienne absolument capital.

Dans la série donc "J'ai besoin que mon patron me lâche la grappe", le dernier rapport du Gartner (en date de Juillet 2008) est particulièrement positif dans les catégories OpenSource (GlassFish, MySQL, ...), Java et SOA (OpenESB). En voici un extrait:

"Sun is a premier contributor of key technologies to the open-source movement. From OpenSolaris, to middleware (GlassFish), DBMS (MySQL) and Java, Sun has delivered innovative code into various communities."

Pour le reste, voici le lien pour le patron de votre patron:
http://mediaproducts.gartner.com/reprints/sunmicrosystems/article4/article4.html

An Open Source Fascicule - July 22, 2008 04:38 AM
How to commit suicide in an Interview!!!

Campus recruitment and Interviews!!!! Most important time of a student life! Here I will tell you how you can screw it up!

Well... The US based Informatica - The Data Integration Company, came to our campus yesterday! About 100 students were eligible to appear according to their eligibility criteria.

Stage 1: Technical Aptitude Test + Theory Paper!

Duration: 45 + 30 min.

Topics: Database (Major), Operating Systems, Unix, C language, General Aptitude.

Students Shortlisted: 13. (I was among them)

Stage 2: Technical Interview:

The interview lasted for almost an hour. Database questions were fired like anything. (I have only basic understanding of databases and queries). I could not answer the higher concepts.
Unix commands and architecture was asked - It was ok! I told them I won prizes in Sun MS blogging contests. He was very impressed!

Students Short listed -4. (I was again one of them).

Stage 3: Technical Interview + HR:

Now comes the most interesting part.... (The interview was conducted by John Sir)
In the beginning I was asked about the database I had designed long back (For storing student -teacher academic data). He was very impressed again.

Then he came to my field!!!! Programming....

I answered almost everything... We discussed some of the projects I had undertaken before (I keep on doing small projects and exploring new technologies.) He also asked base Software Engineering concepts and OS! Everything going so smoothly!!!

Next....

John Sir: So, you are good at programming.. not at database...

Me: Sir I know the basics. I am not an expert in it...

John Sir: See... We do not expected you to be an expert. If you are capable of learning new things we can train you as we like. Its every companies responsibility.. right?

Me: Right Sir!

John Sir: So what are you basically most interested in?

Me: (Without thinking anything) Programming!!!!!!!!!!!


.......... Now !! Here I am... In front of the HR from the Most reputed Data Integration and Solutions Company... I have cleared all the hurdles. He asks me what I am interested in...

I say - I am not interested in what the company is doing! I like programming!!!

Thats the end....

He explains me that it is very difficult to get anything related to code in their job! The core team is far away....


The Concluding remarks...

One guy - really good at databases finally got selected. I was handed a T- Shirt and a pen!!
Not just that - There was this concluding remark:

"You are very good at what you do and you will get selected in other companies. Its just that your interest and our interest don't match!!!!"

Question is - Was it a mistake or a boon in disguise?

I don't know the answer as of today. One thing is for sure.... I cant sit for years typing in same old mugged up SQL Queries - So I think I did the right thing!!!

Everybody around me thinks - I am wrong!! 5.6 Lakh per annum (Indian Rupees) is not a small amount right?

But what about job satisfaction? I would love to get less than that for doing what I love to do - To PROGRAM! To think about things - To try and innovate!

I hope I am not proved wrong in the long run..... But am I too inexperienced to keep preferences at this stage of my carrier?

Insider Scoop From the Tutorial Divas - July 22, 2008 12:55 AM
Martin talks about Rake Runner, Ruby Debugging, and Other 6.5 Enhancements

As I mentioned a couple of weeks ago, I am researching the new Ruby and Rails features in the upcoming NetBeans IDE 6.5. Last week, Martin Krauskopf and I talked about the work that he is doing. Some of you might know Martin from his earlier work with Jesse Glick on NetBeans Module Development (also known as APISupport) which was great experience for him. Before he joined Sun, Martin says that he "enjoyed a short experience working on the Vim plugin for Eclipse ;)".

One of his most noticeable pieces of work for 6.5 is the new Rake Runner dialog box, which I am finding to be a nice improvement. In addition, Martin has also done an overhaul on the Rake infrastructure, and he worked on providing a pre-generated Rakefile for new projects, which includes tasks such as clean, gem, packages, rdoc, spec, and test (Martin: thanks Dudley Flanders for tips).

On the debugging side, he has released new versions of the fast JRuby debugger and ruby-debug-ide gems, which the 6.5 IDE utilizes to bring support for conditional breakpoints and catchpoints (breakpoint on exception).

You will also see improvements in the Ruby Gems Manager. When you open up the manager, you can now easily switch the platform, without having to wait for the manager to finish fetching the data for the currently selected repository. Martin also added the -a (fetch all versions) and -d (fetch detailed gem description) options for tweaking gems fetching so that it goes a bit faster. If the manager finds that it doesn't have permissions on the repository directory for updating and installing gems, it will now invoke the underlying gem commands using gksu or kdesu, as appropriate (if it finds it).

Two other changes that Martin made were to (1) provide support for Rubinius, an addition to MRI Ruby and JRuby, and (2) Enable you to use the project's Properties dialog box to pass JVM options to JRuby, such as -Djruby.objectspace.enabled=true

. Martin is also looking for user situations where something might go wrong and is trying to either make sure that the user gets good messages to help resolve the problem, or have the IDE handle the situation better. His goal is to provide good problem detection capabilities and to provide users with more useful help and clues in such situations. He is focusing on the areas where there are multiple interpreters and multiple Gem Home and Gem Path settings, some with root-writable repositories, as well different VMs with different fast debugging support. He has made several enhancements in this area for 6.5 and will continue working on this for 6.5 and in the next release.

For 6.5, if time permits, he would also like to add support for the Rubinius fast debugger that is being developed by Adam Gardiner, and polish some problems and behaviors of all debuggers generally, since there are still a few remaining issues after the ruby-debug-ide overhaul.

I asked Martin what he does when he isn't working so hard. He likes to spend his free time doing sports such as skiing and biking. He usually spends his vacations with his girlfriend and their friends traveling in his own country (Czech Republic), or around the world, often in the mountains with backpacks. His best vacation was the trip to Himachal Pradesh in the north-west of India.

NetBeans Community Docs Blog - July 21, 2008 11:35 PM
Another Milestone | 175 Docs- Accomplished!

Hey,

Yesterday night, we got 2 contributions (Spanish) by Diego E. Siva L., cool :D Still,
10 days to go (end of July), I am sure we are headed for another milestone, as we cross another- yes, we wrote 175 docs. Awesome guys within few months we have come a long way. Its your community after all, come, innovate and take us to 200 and beyond within next few weeks ;)

Feel free to take part in these projects-

http://nb-community-docs.blogspot.com/2008/07/eclipsetonetbeans.html
http://nb-community-docs.blogspot.com/2008/07/migrating-docs.html

By the way, NetBeans Spotlight coming soon...Happy NetBeaning :-)

NetBeans Community Docs Blog - July 21, 2008 11:29 PM
Docs La Liga

Hey,

Spain is here again- Diego E. Silva L. has contributed 2 tutorials in Spanish for us. Have a look-

  1. Fragmentos con Visual JSF
  2. Programación Orientada a Aspectos (AOP) con Spring 2.5 y NetBeans 6.1 (Parte 1)
Thanks, Diego and others for contributing in Spanish!


Also, have a look at these contributions-
Hubert A Klein Ikkink is back with another quick tip- Quicksearch in Treeviews in NetBeans


Lets welcome Slim Oeurtani, as he contributed for the first time over Community Docs-
Debugging Spring OSGi with NetBeans IDE

Stay Tuned for more...

Geertjan's Blog - July 21, 2008 09:09 PM
Integrating Meera with Grails and NetBeans

My DZone colleague Meera Subbarao took the new Grails/Groovy support in NetBeans IDE for a spin, with great results. Part of her concluding remarks are: "If you are a Groovy or a Grails fan, download the latest version of NetBeans and give it a try. You can develop, test and run your Grails application without ever opening a command window." Click the pic below to read the whole story:

NetBeans for PHP - July 21, 2008 01:36 PM
Generate Constructor, Getters and Setters

This morning I have committed a feature, which offers generating of constructor, getters and setters in a PHP class. To invoke the functionality, the caret position has to be inside a PHP class and you have to press shortcut ALT+Insert (CTLRL+I on Mac). After invoking the shortcut, all possible generators are offered.

Let's explain on a simple example. I have very simple PHP class, where I have only two properties - $name and $age. At first I want to add constructor. After pressing ALT+Insert (CTLRL+I on Mac), the constructor generator is offered - Constructor... item in the Generate menu. After invoking this item, the Generate Constructor dialog is displayed. There I can choose parameters of the constructor. It is possible to chose any property, then the constructor is generated without any parameter and empty. If I check / uncheck the User class, then all properties are selected / unselected. For my demonstration I have chose $name property.  After pressing OK button, the constructor with one parameter is generated.

Now I want to generate getter for the $name. After invoking Generate menu, you can notice that the Constructor... item is not offer anymore, because the class already has a constructor. I choose Getter... item and Generate Getters dialog is displayed. In the dialog you can choose, for which properties you want to generate getters. Again you can check / uncheck the class node, which selects / unselects all properties.

As the next step I want to generate getter and setter for $age property. After choosing Getter and Setter... item in Generate menu, the dialog offers only $age property, because only this property has neither getter nor setter.

When I invoke Generate menu after creating getter and setter for $age property, only setter generator is offered, because there is not defined only setter for $name property.

The generate functionality is designed that you can work just with the keyboard and you don't have to use mouse.

James' Blog - July 21, 2008 10:04 AM
Ajax and JSP

Hi all,

In my last blog entry, I wrote about adding and configuring Ajax transactions in Visual Web JSF projects. Now I'll show you what it all looks like from behind the scenes.

The image above show the JSP tab of the Visual Designer. It gives you a good idea of what is added when you add the Dynamic Faces component library and add and configure Ajax transactions.

Soon, I'll get into using Ajax with JavaServer Faces (not Visual Web JSF).

Cheers!

--James

Bistro! - July 21, 2008 05:04 AM
Java EE 6 - le point à mi-parcours.

Il y a à peine plus d'un an, je mentionnais pour la première fois Java EE 6 (JSR 316). Il semble y avoir un large consensus sur les différents JSR. Il y a également un consensus sur les trois thèmes proposés: extensibilité, profils et pruning. Clairement les profils a pas mal fait parlé d'eux: faut-il un web profile de type "tomcat" ou bien quelque chose de plus riche (voir le billet de Roberto sur ce sujet). Ce qui est clair c'est qu'il n'y aura qu'un seul profil "web" (pas question de maintenir les profils A et B). Après la présentation de Rod Johnson à Jazoon en Juin dernier, il semble que SpringSource ne s'oppose plus au profil B qui contient EJB 3.1 Lite (session+interface locales), WebBeans 1.0, et JSF 2.0.

Clairement Servlet 3.0 me parait comme une avancé significative. C'est elle qui va permettre en grande partie l'extensibilité (déposer les JAR de son framework dans un répertoire précis suffira, plus d'édition de web.xml), de standardiser les mécanismes de suspend/resume utilisés par Comet, et d'avoir (enfin) une approche POJO (annotation @Servlet). JPA 2.0 (specification séparée des EJB) et EJB 3.1 sont des incréments importants et nécessaires après des versions 1.0 déjà bien réussies.

Le succès de WebBeans me parait être une inconnue même si l'unification du modèle de composant est selon moi un "no-brainer". JAX-RS aura certainement beaucoup de succès mais je vois déjà les discussions "JAX-WS ou JAX-RS?" occuper les architectes dans les entreprises et les SSII y passer du temps (à leur grand plaisir! ;-).

Le calendrier initial était effectivement un peu agressif (sachant également que d'autres ne sont pas encore arrivés encore à Java EE 5). Rendez-vous donc pour la beta Java EE 6 l'année prochaine. GlassFish v3 sera aligné avec cette version de la spécification et la version TechPreview 2 propose déjà quelques implémentations en avance de phase au travers de son update center (EJB 3.1, JAX-RS 1.0, ...).

cld - July 20, 2008 11:50 PM
Sprint's Samsung Instinct Java Contest is Live : Webcast and Details

Sprint's Samsung Instinct Java Contest is now live. There is a great and informative webcast which gives you alot of the programmatic details of the phone. More....

Martin Adamek's Blog - July 20, 2008 07:59 PM
Groovy in NetBeans - Inplace Rename

So we are feature-frozen with NetBeans 6.5. That means no additional functionality can be added until final bits are released. We’ve just started fixing phase, so maybe it’s time to walk through few interesting features (with screenshots, of course :-) in few more regular blog entries. For today I want to show you editor action known by several names, sometimes under Inplace Rename. On my Mac it is invoked by Ctrl+R shortcut. It tries to locate usages of local variable in edited file, highlights them and while you are editing name of the variable in one place, all other occurrences of the same variable are renamed at the same time as you type. To demonstrate this on some real example, I used HTTP POST/GET helper Groovy class from Groovy Cookbook Examples.

inplace-rename.png

Geertjan's Blog - July 20, 2008 03:19 PM
Grails: This Time With Tools

Here's how to get started with Grails in NetBeans IDE 6.5.

  1. Prepare the Environment

    • Read the Grails Quick Start, which presents the scenario that we will reproduce in the sections that follow.

    • Download and install the "Web & Java EE" distribution of NetBeans IDE 6.5 Milestone 1 or later. (Everything done below is done with the latest development build, which is probably the best thing to get for getting to know the IDE's Grails support, if you're okay with unexpected errors now and then.)

    • Download and unzip Grails.

    • In the IDE, go to the Options window and set the location of Grails in the "Groovy" panel. If you want to use Groovy, also set the location of Groovy there.

  2. Create the Application

    Choose the Grails Application project in the New Project wizard (Ctrl-Shift-N):

    Click Next and type the name of the project:

    Click Finish and you should see this:

    Expand the folders and have a look around:

    Also look at the generated files and notice that many of them have default values filled in:

  3. Create the Domain Class

    Right-click on the Domains classes node:

    Name the domain class "Book" and then fill in the following two lines within the generated class:

    String title
    String author

    You should now see this:

    Create some initial values in the Bootstrap.groovy class:

    new Book(author:"Stephen King",title:"The Shining").save()
    new Book(author:"James Patterson",title:"Along Came a Spider").save()

    Use Ctrl-Space to call up code completion and then have a look at the other ways of completing the statements above:

    You should now see this:

  4. Create the Controller

    Right-click the Controllers node:

    Type "Book" and notice that you are shown that the generated class will be called "BookController":

    Then comment out the one line generated within the braces and add this one:

    def scaffold = Book

    You should now see this:

  5. Run the Application

    Right-click the application and choose "Run". The application is deployed to Jetty, as you can see in the Services window:

    The URL is printed to the Output window. Paste it into a browser and then you'll see your application. Click the "BookController" link and you'll see this:

    Click New Book and then create a new entry:

    When you click Create, note that you can edit or delete the entry:

    ...and that the entry is reflected in the list of entries:

There are several other Grails-specific features, such as a Grails shell, support for installing Grails plugins, and menu items for things like Grails stats, upgrade, and WAR-file creation. I will blog about these soon.

cld - July 20, 2008 12:50 AM
Grails : Three New Articles (Legacy DBs, Mobile Web, Google Maps) & LinkedIn Using Grails

The Mastering Grails site has some great articles including three new articles. The latest one is on using Grails and Legacy Databases and Grails and the Mobile Web. Also check out what LinkedIn is doing with Grails. More...