DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Containerize Gradle Apps and Deploy to Kubernetes With JKube Kubernetes Gradle Plugin
  • A Spring Boot App With Half the Startup Time
  • Key Takeaways From Integrating a RAG Application With LangSmith
  • Improving Java Application Reliability with Dynatrace AI Engine

Trending

  • WebSocket Debugging Without a Proxy — A Browser-First Workflow
  • Persistent Memory for AI Agents Using LangChain's Deep Agents
  • Introducing RAI Audit Kit: Evidence-Grade Responsible AI Audits in Python
  • Feature Flag Debt: Performance Impact in Enterprise Applications
  1. DZone
  2. Coding
  3. Languages
  4. How to Create Modular Groovy Applications in 5 Steps!

How to Create Modular Groovy Applications in 5 Steps!

By 
Geertjan Wielenga user avatar
Geertjan Wielenga
·
Feb. 14, 09 · News
Likes (0)
Comment
Save
Tweet
Share
21.8K Views

Join the DZone community and get the full member experience.

Join For Free

let's create a modular groovy application! why?! modularity is an enabler of scaleability. as your groovy application increases in size, you increasingly need to manage code dependencies, structure your code in units that are larger than packages, and distribute pieces of your application to developers located in different locations and conflicting time zones. welcome to modularity.

the netbeans platform already provides it (plus, osgi is coming to the netbeans platform ). beyond modularity, there are specific features that the netbeans platform provides that will remain unique, such as a shared filesystem for intermodular communication and the concept of "context" (i.e., netbeans lookup), which not only applications have (as with the jdk 6 serviceloader class), but netbeans platform objects such as windows themselves. welcome to loosely coupled modularity.

now, let's get started.

  1. start up netbeans ide 6.5.

  2. go to this page and download the groovy console template and use the plugin manager (in the tools menu) to install it into the ide.

  3. now, in the new project dialog, you should see this new project template:

  4. click next, give your new application a name (such as "helloworld") and a location on disk, and then click finish. expand a few folders and you should now see this:

    briefly, the template gives you a groovy pojo, with this content:

    package org.my.app

    public class demopojo {

    def foo

    }

    the template also gives you a moduleinstall class, which handles the lifecycle of the module:

    package org.my.app

    import org.openide.modules.moduleinstall as mi

    public class installer extends mi {

    @override
    public void restored() {

    for(int i = 0; i < 10; i++) {
    demopojo dp = new demopojo()
    dp.setfoo(i)
    println("number: " + dp.getfoo())
    }

    }

    }

    so, we have some standard groovy constructs here, simply to get you started in the ecosystem of the netbeans platform. the module also includes a properties file for internationalization purposes and a layer.xml file, for the module's contributions to the shared filesystem.

  5. run the application (i.e., without doing anything at all, no tweaking, no post processing, nothing at all, just run it). look in the output window of netbeans ide and you will see this:

so, you can see that you only have the absolute minimum set of modules to start with. also you're using the groovy compiler (thanks to an additional target that's added to the demo module's build.xml file). that's how to get started with modular groovy applications. have fun with groovy on the netbeans platform!

application Groovy (programming language)

Opinions expressed by DZone contributors are their own.

Related

  • Containerize Gradle Apps and Deploy to Kubernetes With JKube Kubernetes Gradle Plugin
  • A Spring Boot App With Half the Startup Time
  • Key Takeaways From Integrating a RAG Application With LangSmith
  • Improving Java Application Reliability with Dynatrace AI Engine

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook