1 31 package org.objectweb.proactive.core.component.xml; 32 33 import org.apache.log4j.Logger; 34 35 import org.objectweb.fractal.api.Component; 36 37 import org.objectweb.proactive.ProActive; 38 import org.objectweb.proactive.core.ProActiveException; 39 import org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor; 40 import org.objectweb.proactive.core.runtime.RuntimeFactory; 41 42 43 56 public class Loader { 57 protected static Logger logger = Logger.getLogger(Loader.class.getName()); 58 private ComponentsCache cache; 59 60 public Loader() { 61 } 62 63 71 public void loadComponentsConfiguration(String componentsDescriptorURL, 72 ProActiveDescriptor deploymentDescriptor) throws ProActiveException { 73 RuntimeFactory.getDefaultRuntime(); 74 try { 75 cache = (ComponentsCache) ComponentsDescriptorHandler.createComponentsDescriptorHandler(componentsDescriptorURL, 76 deploymentDescriptor).getResultObject(); 77 } catch (org.xml.sax.SAXException e) { 78 e.printStackTrace(); 79 logger.fatal( 80 "a problem occured when getting the ProActive descriptor or the ComponentsDescriptor"); 81 throw new ProActiveException(e); 82 } catch (java.io.IOException e) { 83 e.printStackTrace(); 84 logger.fatal( 85 "a problem occured during the ProActiveDescriptor object creation"); 86 throw new ProActiveException(e); 87 } 88 } 89 90 96 public void loadComponentsConfiguration( 97 String componentsDescriptorLocation, String deploymentDescriptorLocation) 98 throws ProActiveException { 99 ProActiveDescriptor deploymentDescriptor = ProActive.getProactiveDescriptor(deploymentDescriptorLocation); 100 loadComponentsConfiguration(componentsDescriptorLocation, 101 deploymentDescriptor); 102 } 103 104 109 public Component getComponent(String name) { 110 return cache.getComponent(name); 111 } 112 } 113 | Popular Tags |