• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

What is the analog to WordPress hooks/filters? (or: how to design an extensible application?)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First post. I have a lot of experience writing PHP, specifically custom plugins for WordPress. It's probably a topic of debate, but I do understand the design point of WP in terms of how hooks and filters work, in that platform. Very simply stated, a hook is comprised of an action and a call-back function that responds to that action. For example, there is a hook (paraphrasing here) called "When a user submits a new post". Based on that event happening, I can register a call-back function that implements "Send Chuck a text message when any user submits a new post".

So basically, the platform is extensible without having to touch any of the core WP code.

At my job now, I am about to embark on the creation of a Java web application. I wrote a lot of Java. but it was many years ago, so I have a lot to relearn. One thing I would like to do is design the system for ease of extension. So my question is, what should I go learn/study about best practices for doing this in Java?

Do I strive to model the WP paradigm and embed action "firing" code within my Java classes? Or is there a better way to think about this?

Any pointers would be very appreciated.
 
Rancher
Posts: 924
22
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chuck,
Could you please elaborate on what you consider a Java web application, is that a JavaScript application or what?
Les

Chuck Cintron wrote:Java web application

 
Chuck Cintron
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks...I am talking about a traditional Java application running on a server (in this case Websphere), along with a client-side UX in a browser...thinking of handling that part as close to a single-page web app as possible, levering jQuery and AJAX, etc.

I've done some reading about using the Spring framework and also the OSGi pattern...my head hurts. But if that's the right answer I will work through it.
 
Marshal
Posts: 71047
291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
…and welcome to the Ranch

That question sounds too difficult for the “beginning” forum; let's try a different forum.
 
Saloon Keeper
Posts: 12488
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should probably read up on the observer pattern. You can implement this in plain Java.

If you want to use plugins, you can take a look at ServiceLoader. A client can extend your framework simply by running the application with their plugins on the class path.

For something more advanced, you can have a look at OSGi or NetBeans RCP, but it's not for the faint of heart.
 
Chuck Cintron
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the advice; I looked at observer pattern - looks like that's the ticket. Much appreciated.
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic