9.4 Inspect Remotely

Metawidget inspects back-end metadata and creates front-end UI widgets. If your application is split over multiple tiers, however, sometimes the back-end metadata is not accessible from the front-end. For example, annotations (such as JPA ones) are designed to 'fall away' if the class is transferred to a tier without their JAR (such as ejb3-persistence.jar) in its classpath. Equally, configuration files may not be accessible across tiers.

Metawidget supports these situations. Because each remoting environment is different, however, you will need to add a little code yourself. Every Inspector returns an XML string, which is inherently serializable and safe to pass across tiers. Therefore, to run inspection remotely:

An example of this technique can be seen in GwtRemoteInspectorProxy and GwtRemoteInspectorImpl.

All Inspectors are immutable. Therefore you only need one Inspector for your entire application. Some remoting architectures support 'singletons' or 'service beans' well suited to this.

9.4.1 Combine Remote Inspections

If your architecture is strongly separated, some metadata may only be available in one tier (e.g. JPA annotations in the back-end) and some only available in another tier (e.g. struts-config.xml in the front-end).

For this, CompositeInspector supplies an overloaded method outside the normal Inspector interface. The overloaded CompositeInspector.inspect method takes an additional XML string of inspection results, and merges forthcoming inspection results with it.

Therefore, to combine metadata from different tiers:

  • create a front-end class that implements the Inspector interface

  • implement the interface by first remoting to the back-end class and returning the XML string, as before

  • next, delegate to a CompositeInspector to inspect the front-end, passing it the XML string from the back-end as a starting point