To instantiate interfaces.
Kai Kunstmann
Kai.Kunstmann at combase.de
Thu Apr 14 10:34:09 PDT 2011
Hi,
There is a "Design Pattern" called "Strategy" for this kind of
behaviour. Have a look at Google's Guice library or the Spring Framework
for pluggable components.
Cheers,
Kai
Am Donnerstag, den 14.04.2011, 12:53 -0300 schrieb Davi Sáránszky
Mesquita:
> Maybe i am late, but i will love to receive critic's about this.
>
> thansks,
> SMALL LANGUAGE CHANGE PROPOSAL FORM *AUTHOR(S):* Davi Saranszky Mesquita,
> SCJP 6.0
>
> *OVERVIEW*
> Ability to instantiate interfaces using pre-implemented behavior.
>
> When we have lots of factories and native implemented Java. Cloud and
> multi-platform implementations needs to creates factories and interface
> oriented programing.
>
> For example: For the Google App Engine, we create an interface with
> pre-implemented behavior. When we ship this product to another platform, the
> only thing we need to do its using the same interface.
>
> The excess of using this will result in bigger Jar libraries.
>
>
> *EXAMPLES*
>
>
> A TARGET 6 EXAMPLE:
>
> // FILE: StoreFile.java
>
> import java.io.File;
>
> interface StoreFile {
>
> void doIt(File file);
>
> }
>
> // FILE: StoreFileImpl.java
> import java.io.File;
> class StoreFileImpl implements StoreFile {
> public void doIt(File file) {
> // DO MAJOR USER IMPLEMENTATION
> }
> }
>
> A TARGET 7 EXAMPLE:
>
> // FILE: StoreFile.java
>
> import java.io.File;
>
> interface StoreFile {
>
> void doIt(File file) {
> public void doIt(File file) {
> // DO MAJOR USER IMPLEMENTATION
> }
> }
>
> }
>
> At this point on target 7 example, we can instantiate the interface OR
> implements that for changing behaviors.
>
> // FILE StoreFileGAE.java
> import java.io.File;
> class StoreFileGAE implements StoreFile {
>
> void doIt(File file) {
> public void doIt(File file) {
> // DO Google App Engine NATIVE IMPLEMENTATION
> }
> }
> }
>
> At this point. We can just does nothing for just instantiations interfaces.
>
> The: new StoreFile();
>
> just works.
>
> For localhost or the major products but for this example we can ship to
> Google App Engine for changing the implementations.
>
> This can be used for cloud storeges, cloud threads and task workers, for
> private grid and clustering like Cassandra or Haboop.
>
>
>
> Davi
> +55 (11) 8180-9411 TIM
>
More information about the coin-dev
mailing list