use of org.drools.drl.ast.descr.EntryPointDeclarationDescr in project drools by kiegroup.
the class RuleParserTest method testEntryPointDeclaration.
@Test
public void testEntryPointDeclaration() throws Exception {
final String text = "package org.drools\n" + "declare entry-point eventStream\n" + " @source(\"jndi://queues/events\")\n" + " @foo( true )\n" + "end";
PackageDescr pkg = (PackageDescr) parse("compilationUnit", text);
assertEquals("org.drools", pkg.getName());
assertEquals(1, pkg.getEntryPointDeclarations().size());
EntryPointDeclarationDescr epd = pkg.getEntryPointDeclarations().iterator().next();
assertEquals("eventStream", epd.getEntryPointId());
assertEquals(2, epd.getAnnotations().size());
assertEquals("\"jndi://queues/events\"", epd.getAnnotation("source").getValue());
assertEquals("true", epd.getAnnotation("foo").getValue());
}
use of org.drools.drl.ast.descr.EntryPointDeclarationDescr in project drools by kiegroup.
the class CompositePackageDescr method internalAdd.
private void internalAdd(Resource resource, PackageDescr packageDescr) {
for (ImportDescr descr : packageDescr.getImports()) {
addImport(descr);
descr.setResource(resource);
}
for (FunctionImportDescr descr : packageDescr.getFunctionImports()) {
addFunctionImport(descr);
descr.setResource(resource);
}
for (AccumulateImportDescr descr : packageDescr.getAccumulateImports()) {
addAccumulateImport(descr);
descr.setResource(resource);
}
for (AttributeDescr descr : packageDescr.getAttributes()) {
addAttribute(descr);
descr.setResource(resource);
}
for (GlobalDescr descr : packageDescr.getGlobals()) {
addGlobal(descr);
descr.setResource(resource);
}
for (FunctionDescr descr : packageDescr.getFunctions()) {
addFunction(descr);
descr.setResource(resource);
}
for (RuleDescr descr : packageDescr.getRules()) {
addRule(descr);
descr.setResource(resource);
}
// Avoid adding the same type declaration twice, see
// TypeDeclarationTest.testDuplicatedTypeDeclarationInDifferentResources
// IncrementalCompilationTest.testIncrementalCompilationWithAmbiguousRedeclares
// RHDM-1738
Set<TypeDeclarationDescr> typeDeclarationDescrs = new HashSet<>(getTypeDeclarations());
for (TypeDeclarationDescr descr : packageDescr.getTypeDeclarations()) {
if (!typeDeclarationDescrs.contains(descr)) {
addTypeDeclaration(descr);
descr.setResource(resource);
}
}
for (EnumDeclarationDescr enumDescr : packageDescr.getEnumDeclarations()) {
addEnumDeclaration(enumDescr);
enumDescr.setResource(resource);
}
for (EntryPointDeclarationDescr descr : packageDescr.getEntryPointDeclarations()) {
addEntryPointDeclaration(descr);
descr.setResource(resource);
}
for (WindowDeclarationDescr descr : packageDescr.getWindowDeclarations()) {
addWindowDeclaration(descr);
descr.setResource(resource);
}
packageDescr.getPreferredPkgUUID().ifPresent(pkgUUID -> {
if (getPreferredPkgUUID().isPresent() && !pkgUUID.equals(getPreferredPkgUUID().get())) {
throw new RuntimeException(String.format("Trying to overwrite preferredPkgUUID %s with a different value %s", getPreferredPkgUUID().get(), pkgUUID));
}
setPreferredPkgUUID(pkgUUID);
});
}
Aggregations