/** * Instantiates a plugin component from its definition class. * * @param name the name of the plugin component's implementation class. * @param context optional additional information. * @return the plugin component that has been created. * @throws CompilerError if a problem occurs during the creation of the * component. */ public Object newComponent(final String name, final Map context) throws ADLException { try { return getClass().getClassLoader().loadClass(name).newInstance(); } catch (final InstantiationException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, "Can't instantiate plugin \"" + name + "\"."); } catch (final IllegalAccessException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, "Can't instantiate plugin \"" + name + "\"."); } catch (final ClassNotFoundException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, "Could not find the plugin class \"" + name + "\"."); } }
public Object newComponentType(final String name, final Map context) throws ADLException { for (final Factory factory : factoryItfs.values()) { try { return factory.newComponentType(name, context); } catch (final ADLException e) { } } throw new CompilerError(GenericErrors.INTERNAL_ERROR, "Coud not instantiate the plugin '" + name + "'"); }
void terminate() throws ADLException, InterruptedException { lock.lock(); try { while (nbRunningThread > 0) { condition.await(); } } finally { lock.unlock(); } if (exception != null) { if (exception instanceof ADLException) throw (ADLException) exception; else throw new CompilerError(GenericErrors.INTERNAL_ERROR, exception, "Unexpected error"); } } }
/** * @param nodeFactory The node factory to be used for instantiating AST nodes. * @param adlDtd The grammar definition for ADL nodes. * @param filename The name of the parsed file. */ public JTBProcessor(final XMLNodeFactory nodeFactory, final String adlDtd, final String filename) { this.nodeFactory = nodeFactory; this.adlDtd = adlDtd; this.filename = filename; try { nodeFactory.checkDTD(adlDtd); } catch (final SAXException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e, "Error in dtd file '" + adlDtd + "'"); } }
/** * Iterates over the list of client factories until one of them successfully * instantiates the requested plugin component. If no client factories manage * to instantiate the requested component, then raises a {@link CompilerError} * * @param name the name of the component to be created. * @param context optional additional information. * @return the component that has been created. The type of this result * depends on the implementation of this interface: it can be a * Fractal component reference (if this factory creates Fractal * components), it can be an identifier (if this factory generates * source code that will create components, instead of directly * creating components), etc. * @throws ADLException if a problem occurs during the creation of the * component. */ public Object newComponent(final String name, final Map context) throws ADLException { for (final Factory factory : factoryItfs.values()) { try { return factory.newComponent(name, context); } catch (final ADLException e) { } } throw new CompilerError(GenericErrors.INTERNAL_ERROR, "Coud not instantiate the plugin '" + name + "'"); }
private Node newNode(final String name, final NodeToken source) { Node node; try { node = nodeFactory.newXMLNode(adlDtd, name); } catch (final SAXException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e, "Unable to create node"); } setSource(node, source); return node; }
throw new CompilerError(GenericErrors.INTERNAL_ERROR, "Name clash in template instance name: \"" + name + "\" and \"" + previousName + "\"");
public Component visit(final List<Node> path, final ComponentContainer node, final Map<Object, Object> context) throws ADLException, TaskException { final Implementation impl = castNodeError(node, ImplementationContainer.class).getImplementation(); if (impl == null) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, "This visitor is only applicable for primitive component."); } return createImplementationTask(node, impl); }
outPS = new PrintStream(new FileOutputStream(outputFile)); } catch (final FileNotFoundException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e, "IO error"); headerOutPS = new PrintStream(new FileOutputStream(headerOutputFile)); } catch (final FileNotFoundException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e, "IO error");
sharedImplementation, context); if (sharedImpl == null) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, "Can't find file " + sharedImplementation); sharedImpl = new File(input.toURI()); } catch (final URISyntaxException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e, "Can't find file " + sharedImplementation);
nodeItfNames); } catch (final ClassNotFoundException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e, "Unexpected error while cloning AST node");
public void visit(final Definition definition, final java.util.Map<Object, Object> context) throws ADLException { if (!(definition instanceof ImplementationContainer)) return; final Source[] sources = ((ImplementationContainer) definition) .getSources(); if (sources.length <= 1) return; final File headerFile = outputFileLocatorItf.getCSourceOutputFile( getImplHeaderFileName(definition), context); if (!inputResourceLocatorItf.isUpToDate(headerFile, InputResourcesHelper .getInputResources(definition), context)) { try { SourceFileWriter.writeToFile(headerFile, getFileContent(definition)); } catch (final IOException e) { throw new CompilerError(IOErrors.WRITE_ERROR, e, headerFile .getAbsolutePath()); } } }
public void visit(final Definition definition, final Map<Object, Object> context) throws ADLException { final File outputFile = outputFileLocatorItf.getCSourceOutputFile( getHeaderFileName(definition), context); if (!inputResourceLocatorItf.isUpToDate(outputFile, InputResourcesHelper .getInputResources(definition), context)) { final StringTemplate st = getInstanceOf("ComponentDefinitionHeader"); st.setAttribute("definition", definition); try { SourceFileWriter.writeToFile(outputFile, st.toString()); } catch (final IOException e) { throw new CompilerError(IOErrors.WRITE_ERROR, e, outputFile .getAbsolutePath()); } } }
SourceFileWriter.writeToFile(outputFile, st.toString()); } catch (final IOException e) { throw new CompilerError(IOErrors.WRITE_ERROR, e, outputFile .getAbsolutePath());
taskGraph = visitorItf.visit(new ArrayList<Node>(), d, context); } catch (final TaskException e1) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e1, "Task component instantiation problem during the creation of the task graph.");
public void visit(final IDL idl, final Map<Object, Object> context) throws ADLException { final String headerFileName; if (idl.getName().startsWith("/")) { headerFileName = PathHelper.replaceExtension(idl.getName(), IDT_FILE_EXT); } else { headerFileName = PathHelper.fullyQualifiedNameToPath(idl.getName(), ITF_FILE_EXT); } final File headerFile = outputFileLocatorItf.getCSourceOutputFile( headerFileName, context); if (!inputResourceLocatorItf.isUpToDate(headerFile, InputResourcesHelper .getInputResources(idl), context)) { final StringTemplate st = getInstanceOf("idlFile"); st.setAttribute("idl", idl); try { writeToFile(headerFile, st.toString()); } catch (final IOException e) { throw new CompilerError(IOErrors.WRITE_ERROR, e, headerFile .getAbsolutePath()); } } }
public void visit(final InstancesDescriptor instanceDesc, final Map<Object, Object> context) throws ADLException { final File outputFile = outputFileLocatorItf.getCSourceOutputFile( getInstancesFileName(instanceDesc), context); final StringTemplate st; if (instanceDesc.topLevelDefinition == instanceDesc.instanceDefinition) { st = getInstanceOf("TopLevelInstances"); st.setAttribute("topLevelDefinition", instanceDesc.topLevelDefinition); st.setAttribute("instances", instanceDesc.instances); final Set<Definition> definitions = new HashSet<Definition>(); for (final ComponentGraph instance : instanceDesc.instances) { addDefinitions(instance, definitions); } st.setAttribute("definitions", definitions); } else { st = getInstanceOf("ComponentInstances"); st.setAttribute("topLevelDefinition", instanceDesc.topLevelDefinition); st.setAttribute("definition", instanceDesc.instanceDefinition); st.setAttribute("instances", instanceDesc.instances); } try { SourceFileWriter.writeToFile(outputFile, st.toString()); } catch (final IOException e) { throw new CompilerError(IOErrors.WRITE_ERROR, e, outputFile .getAbsolutePath()); } }
srcFile = new File(srcURL.toURI()); } catch (final URISyntaxException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e);
SourceFileWriter.writeToFile(outputFile, st.toString()); } catch (final IOException e) { throw new CompilerError(IOErrors.WRITE_ERROR, e, outputFile .getAbsolutePath());
ps.close(); } catch (final IOException e) { throw new CompilerError(IOErrors.WRITE_ERROR, e, srcFile .getAbsolutePath()); srcFile = new File(srcURL.toURI()); } catch (final URISyntaxException e) { throw new CompilerError(GenericErrors.INTERNAL_ERROR, e);