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 import org.objectweb.fractal.api.NoSuchInterfaceException; 37 import org.objectweb.fractal.api.factory.GenericFactory; 38 import org.objectweb.fractal.api.factory.InstantiationException; 39 import org.objectweb.fractal.api.type.ComponentType; 40 import org.objectweb.fractal.api.type.TypeFactory; 41 import org.objectweb.fractal.util.Fractal; 42 43 import org.objectweb.proactive.core.ProActiveRuntimeException; 44 import org.objectweb.proactive.core.component.ControllerDescription; 45 import org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor; 46 import org.objectweb.proactive.core.xml.handler.AbstractUnmarshallerDecorator; 47 import org.objectweb.proactive.core.xml.handler.UnmarshallerHandler; 48 import org.objectweb.proactive.core.xml.io.Attributes; 49 50 import org.xml.sax.SAXException ; 51 52 import java.util.HashMap ; 53 54 55 58 public abstract class ComponentHandler extends AbstractUnmarshallerDecorator { 59 public static Logger logger = Logger.getLogger(ComponentHandler.class.getName()); 60 61 protected ControllerDescription controllerDescription; 62 protected String virtualNode; 63 protected ProActiveDescriptor deploymentDescriptor; 64 protected ComponentsCache componentsCache; 65 protected HashMap componentTypes; 66 protected TypeFactory typeFactory; 67 protected GenericFactory cf; 68 protected ComponentType componentType = null; 69 70 73 public ComponentHandler(ProActiveDescriptor deploymentDescriptor, 74 ComponentsCache componentsCache, HashMap componentTypes) { 75 controllerDescription = new ControllerDescription(); 76 this.deploymentDescriptor = deploymentDescriptor; 77 this.componentsCache = componentsCache; 78 this.componentTypes = componentTypes; 79 try { 80 Component boot = Fractal.getBootstrapComponent(); 81 typeFactory = Fractal.getTypeFactory(boot); 82 cf = Fractal.getGenericFactory(boot); 83 } catch (InstantiationException e1) { 84 throw new ProActiveRuntimeException("Cannot find Fractal boot component", 85 e1); 86 } catch (NoSuchInterfaceException e1) { 87 throw new ProActiveRuntimeException("Cannot find Fractal interface", 88 e1); 89 } 90 } 91 92 95 protected void notifyEndActiveHandler(String name, 96 UnmarshallerHandler activeHandler) throws SAXException { 97 } 98 99 102 public Object getResultObject() throws SAXException { 103 return null; 104 } 105 106 109 public void startContextElement(String name, Attributes attributes) 110 throws SAXException { 111 String component_name = attributes.getValue(ComponentsDescriptorConstants.COMPONENT_NAME_TAG); 112 if (!checkNonEmpty(component_name)) { 113 throw new SAXException ("component's name unspecified"); 114 } 115 String virtual_node = attributes.getValue(ComponentsDescriptorConstants.COMPONENT_VIRTUAL_NODE_TAG); 116 if (!checkNonEmpty(virtual_node)) { 117 virtual_node = ComponentsDescriptorConstants.NULL; 118 } 119 String type_name = attributes.getValue(ComponentsDescriptorConstants.COMPONENT_TYPE_ATTRIBUTE_TAG); 120 if (!checkNonEmpty(type_name)) { 121 throw new SAXException ("name of component type unspecified"); 122 } 123 controllerDescription.setName(component_name); 124 virtualNode = virtual_node; 125 componentType = ((ComponentType) componentTypes.get(type_name)); 126 } 127 } 128 | Popular Tags |