// ResourceHelperFactory.java
// $Id: ResourceHelperFactory.java,v 1.7 1998/01/22 13:27:33 bmahe Exp $
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html

package org.w3c.jigadm.editors ;

import java.util.*;
import org.w3c.jigsaw.admin.*;
import org.w3c.tools.resources.*;
import org.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;
    }

}
