Architecture of NetBeans YouTube Integration

The architecture of the YouTube integration that I showed yesterday is kind of interesting. To ensure that anyone can plug in their own embedded browser component, I separated the WebRenderer API and its implementation into a separate module suite from where the YouTube API and its implementation are found:

As a result, there could be several other browser components too, just like the WebRenderer API and implementation above. For example, you could make a suite called "YouTubeJDICWindow". It would contain the JDIC API together with a module containing a window that implements the API. Then, the user would be able to choose whether they want to install the WebRenderer modules or the JDIC modules.

And how do the window modules interact with the YouTube toolbar? There's only one point where interaction is necessary. That's when the user clicks on a title in the list. At that point, the window should open, displaying the selected movie. But, the window is in a different module to the toolbar, and both are in different module suites, so that no dependencies can be declared between them. So... how is the window opened by the toolbar?

And the answer is... the TopComponentGroup interface. When the user clicks the title in the list and the movie is correctly retrieved from YouTube, the following code is used to open the window:

TopComponentGroup group = WindowManager.getDefault().findTopComponentGroup("YouTubeGroup");
if (group == null) {

Hence, the WebRenderer implementation module registers its TopComponent in a TopComponent group called "YouTubeGroup". Any other module could do so too. But, since the user is only going to be using one window to display their movie (i.e., either the WebRenderer window, or the JDIC window, or the XYZ web component window), there will always only be one TopComponent registered in the group. And that's the TopComponent that will open when the above code is executed.

In this way, despite having no dependencies of any kind on each other, the two modules can interact (indirectly), thanks to the NetBeans System Filesystem. The end user notices nothing of all this, of course. All this happens seamlessly under the hood, but lets the developer provide a range of different user interfaces for the same YouTube movies.


Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« July 2016