/** * This prepares the package builder, loads the jars/classpath. * * @return true if everything is good to go, false if its all gone horribly wrong, and we can't * even get the package header up. */ private boolean preparePackage() { // firstly we loadup the classpath builder.addPackage(new PackageDescr(pkg.getName())); // now we deal with the header (imports, templates, globals). addDrl(ServiceImplementation.getDroolsHeader(pkg)); loadDeclaredTypes(); if (builder.hasErrors()) { recordBuilderErrors(pkg); // if we have any failures, lets drop out now, no point in going // any further return false; } loadDSLFiles(); // finally, any functions we will load at this point. AssetItemIterator it = this.pkg.listAssetsByFormat(new String[] {AssetFormats.FUNCTION}); while (it.hasNext()) { AssetItem func = (AssetItem) it.next(); addDrl(func.getContent()); if (builder.hasErrors()) { recordBuilderErrors(func); builder.clearErrors(); } } return errors.size() == 0; }
private void addHeaderToVerifier() { StringBuffer header = new StringBuffer(); header.append("package " + packageItem.getName() + "\n"); header.append(ServiceImplementation.getDroolsHeader(packageItem) + "\n"); verifier.addResourcesToVerify( ResourceFactory.newReaderResource(new StringReader(header.toString())), ResourceType.DRL); }
public String getDRL() { StringBuffer src = new StringBuffer(); src.append("package " + this.pkg.getName() + "\n"); src.append(ServiceImplementation.getDroolsHeader(this.pkg) + "\n\n"); // now we load up the DSL files builder.setDSLFiles( BRMSPackageBuilder.getDSLMappingFiles( pkg, new BRMSPackageBuilder.DSLErrorEvent() { public void recordError(AssetItem asset, String message) { errors.add(new ContentAssemblyError(asset, message)); } })); // do the functions and declared types. AssetItemIterator it = this.pkg.listAssetsByFormat(new String[] {AssetFormats.FUNCTION, AssetFormats.DRL_MODEL}); while (it.hasNext()) { AssetItem func = (AssetItem) it.next(); if (!func.isArchived()) { src.append(func.getContent() + "\n\n"); } } // now the rules Iterator iter = pkg.getAssets(); while (iter.hasNext()) { AssetItem asset = (AssetItem) iter.next(); if (!asset.isArchived()) { ContentHandler h = ContentManager.getHandler(asset.getFormat()); if (h instanceof IRuleAsset) { IRuleAsset ruleAsset = (IRuleAsset) h; ruleAsset.assembleDRL(builder, asset, src); } src.append("\n\n"); } } return src.toString(); }