Need citation for Extension Interface pattern in Java -


One of the following Java interface design of an object without changing the client allows to expand. Additional detail can be applied to the object interface. The client can ask for objects to the interface is that it does apply. I read about it in a blog post, but my Google skills again failed to find blog posts. I am not advocating the design of the qualifications. I just want to find a blog post. For example, a domain model for transport vehicles to imagine. The implementation of this interface is that each vehicle body:

  public interface Extendable {/ ** * Object asks if this extension is to provide the ultimate extension intephesa * * * @ requested extensions to apply * @ return the object to the requested extension, or if not available, then {@code null}. * / & Lt; T & gt; T query extensions (Class & lt; T & gt; extension interface); }  

Fixed-wing aircraft flight control surface, but not other types of vehicle. For the convenience of the control surfaces to define an interface:

  {String found kantrolasarphesa public interface elerona (); The string elevator to get (); String gains (); }  

Fixed-wing aircraft class ControlSurfaces provides extensions:

  public class provides phiksdadingaaikrakaphta vehicle is {@SuppressWarnings ( "unchecked") public & lt; T & gt; T query extensions (Class & lt; T & gt; expansion interface) {if (ControlSurfacesclassequals (extensionInterface)) {return (T) new ControlSurfacesImpl (); } Return null; Let's say that a domain model is, therefore, a service object storage for the vehicle to save for things to continue to be responsible. The interface for the vehicle to expand the service should ask which should also be saved.  
  public class VehicleServiceImpl {private vehicle to drive the vehicle; Private niyantranasuraphesadao niyantranasuraphesadao; Public void save (Vehicle Vehicle) {vehicle vehicle (vehicle); Niyantranaksetra control suraphasa = vahanakucha extension (kantrolasarphsaklasa); If (the control surface! = Null) {controlSurfacesDao.save (vehicle, control security); }}}}  

The "Extension interface" pattern of a Java example, as the "pattern oriented software architecture" presented in section 2 (pioesae 2), Schmidt, stall, rohanarta and busamana, Wiley, 2000 by.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -