Need a design pattern for representing multiple information sources

Posted by hsmit on Stack Overflow See other posts from Stack Overflow or by hsmit
Published on 2010-04-05T11:35:10Z Indexed on 2010/04/05 12:13 UTC
Read the original article Hit count: 391

I'm building a Java application that retrieves information from differing information sources. I'm using a sensor, a set of RecordStores and a few online web services.

In the basic application all these resources are loaded by default. Some of these sources are directly read in a separate thread (load database, read sensor etc.). From this basic application some functions are started that use these sources.

The classes that contain these functions (usually combining multiple sources information) are currently paramterized with a set of resources like this:

AppPart a1 = new AppPart(source1, source2, source3);

I could also do it like this

AppPart a1 = new AppPart(this);

..where I need to make my sources public in order to read them.

I'm also thinking about a kind of stage/collection to publish all sources on, e.g:

public SourceCollectionStage sStage = new SourceCollectionStage();

and later:

 sStage.getSensor();

.. for example.

What do you guys think is the best or most often used way to do this?

Btw: the user interface is often implemented by the specific funtion classes, not by the main class. Should I do this in another way?

© Stack Overflow or respective owner

Related posts about java

Related posts about pattern