// ResourceHelperFactory.java
// $Id: ResourceHelperFactory.java,v 1.6 1997/07/21 14:42:36 ylafon Exp $
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html

package w3c.jigadm.editors ;

import java.util.*;
import w3c.jigsaw.admin.*;
import w3c.tools.store.*;
import w3c.jigadm.*;

public class ResourceHelperFactory {

    public static synchronized
    ResourceHelper[] getHelpers(RemoteResourceWrapper rrw) {
	PropertyManager pm        = PropertyManager.getPropertyManager();
	String          classes[] = pm.getHelperClasses(rrw);
	ResourceHelper  helpers[] = null;

	if ( classes != null ) {
	    // Create the helpers (skip impedance mismatch):
	    helpers = new ResourceHelper[classes.length];
	    if ( helpers.length == 0 )
		return null;
	    for (int i = 0 ; i < classes.length ; i++) {
		try {
		    Class c    = Class.forName(classes[i]);
		    helpers[i] = (ResourceHelper) c.newInstance();
		} catch (Exception ex) {
		    // FIXME: should have an object to report that to...
		    System.out.println("cannot create helper: \""+
				       classes[i]+
				       " for \""+
				       rrw);
		}		
	    }
	}
	return helpers;
    }

}
