Hallo
ich muss für die Schule eine SingletonRegistry schreiben.
Dafür haben wir ein interface bekommen.
Es hat 3 Methoden die wir selber schreiben sollen.
Nun weiß ich aber nicht genau wie ich das machen soll.
Hab im Internet nicht wirklich was gefunden und wollte jetzt hier mal nachfragen.
Hoffe hab es richtig eingefügt.
Bin für jede Hilfe offen.
Gruß
ich muss für die Schule eine SingletonRegistry schreiben.
Dafür haben wir ein interface bekommen.
Es hat 3 Methoden die wir selber schreiben sollen.
Nun weiß ich aber nicht genau wie ich das machen soll.
Hab im Internet nicht wirklich was gefunden und wollte jetzt hier mal nachfragen.
Java:
public interface SingletonRegistry extends PropertyListenSupport {
/**
* Method to be called by a library upon static initialization to register
* the given class so that the only instance can be retrieved.
* @param <T> generic placeholder for the interface class
* @param clazz the class of the object to be retrieved
* @param value the single implementation of the class
*/
public <T> void registerInstance(Class<T> clazz, T value);
/**
* Method to be called by a library in case a service shall be made
* unavailable
* @param <T> generic placeholder for the interface class
* @param clazz the class of the object to be revoked
*/
public <T> void unregisterInstance(Class<T> clazz);
/**
* Method to retrieve the implementation of the class given as parameter.
* @param <T> generic placeholder for the interface class
* @param clazz the class of the object to be retrieved
* @return an instance of the class or null, if the instance could not
* be retrieved
*/
public <T> T retrieveInstance(Class<T> clazz);
}
Bin für jede Hilfe offen.
Gruß