psmith 2003/12/23 20:08:45 Added: src/java/org/apache/log4j/chainsaw/favourites package.html Favourite.java FavouritesRegistry.java Log: The beginnings of Favourites (save Plugin state). Eventually the saved state of a prototype plugin will re-use the <plugin ... > syntax that is found in a log4j.xml file. Revision Changes Path 1.1 jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites/package.html Index: package.html =================================================================== <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <title></title> </head> <body> <p>The Favourites package. <hr> <h2>Prototype Rules</h2> The following rules are checked against a potential prototype instance to ensure it can be used and saved for later use: <ul> <LI > Have a public no-arg constructor available <li> TODO - more rules </ul> </body> </html> 1.1 jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites/Favourite.java Index: Favourite.java =================================================================== package org.apache.log4j.chainsaw.favourites; /** * A Fauvourite is just a named container of on object that can be used * as a basis (prototype) for the creation of exact copies. * * Clients should use the FavouritesRegistry to create instances of this class * so that explicit checks can be performed about the suitability of the * prototype. * * @author Paul Smith <[EMAIL PROTECTED]> * */ public final class Favourite { private String name; private Object prototype; /** * @param name * @param object */ Favourite(String name, Object prtotype) { this.name = name; this.prototype = prtotype; } /** * @return Returns the name. */ public final String getName() { return name; } /** * Returns the object that would be used as a basis to create new * instances of that same object. * @return Returns the prototype. */ public final Object getPrototype() { return prototype; } } 1.1 jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites/FavouritesRegistry.java Index: FavouritesRegistry.java =================================================================== package org.apache.log4j.chainsaw.favourites; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; /** * A singleton class that is used as a Registry of instances of JavaBeans * that are in a state that a user prefers. * * @author Paul Smith <[EMAIL PROTECTED]> * */ public class FavouritesRegistry{ private final FavouritesRegistry instance = new FavouritesRegistry(); private final List favourites = new ArrayList(); /** * Returns a Collection of Favourite instances whose getPrototype() method * returns an object whose class is assignable from clazz, or more formally, such that * clazz.isAssignableFrom(favourite.getPrototype().getClass()) * @param clazz * @return */ public synchronized Collection getFavouritesByClass(Class clazz) { throw new UnsupportedOperationException("Work In Progress"); } /** * Adds a favourite to this Registry * @param favourite */ public synchronized void addFavourite(Favourite favourite) { throw new UnsupportedOperationException("Work In Progress"); } /** * Returns an unmodifiable List of all the known Favourite instances * @return */ public List getFavourites() { return Collections.unmodifiableList(favourites); } /** * Creates a new Favourite instance after running throught some * suitability checks to make sure the object class is ok to be used * as a prototype. * * @param name The name to use for the favourite * @param prototype The object to register * @throws IllegalArgumentException if the prototype does not conform * to the necessary rules to be used as a prototype (see the package documentation). * * @return */ public void addFavourite(String name, Object prototype) { favourites.add(createFavourite(name, prototype)); } private Favourite createFavourite(String name, Object prototype) { checkSuitability(prototype); return new Favourite(name, prototype); } /** * Checks the suitability of an object to make sure it conforms to all the rules * for being a prototype, * @param prototype * @throws IllegalArgumentException if the prototype is not suitable */ private void checkSuitability(Object prototype) throws IllegalArgumentException{ // TODO Auto-generated method stub throw new UnsupportedOperationException("Work in Progress"); } private FavouritesRegistry() { } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]