Esempio n. 1
0
  /**
   * 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;
  }
Esempio n. 2
0
 /** Builds assets that are "rule" assets (ie things that are not functions etc). */
 private void buildAsset(AssetItem asset) {
   ContentHandler h = ContentManager.getHandler(asset.getFormat());
   if (h instanceof IRuleAsset) {
     try {
       ((IRuleAsset) h).compile(builder, asset, new ErrorLogger());
       if (builder.hasErrors()) {
         this.recordBuilderErrors(asset);
         // clear the errors, so we don't double report.
         builder.clearErrors();
       }
     } catch (DroolsParserException e) {
       throw new RulesRepositoryException(e);
     } catch (IOException e) {
       throw new RulesRepositoryException(e);
     }
   }
 }