Logo Search packages:      
Sourcecode: aspectj version File versions  Download package

void org::aspectj::weaver::loadtime::ClassLoaderWeavingAdaptor::registerOptions ( final BcelWeaver  weaver,
final ClassLoader  loader,
final List  definitions 
) [inline, private]

Configure the weaver according to the option directives TODO av - don't know if it is that good to reuse, since we only allow a small subset of options in LTW

Parameters:
weaver 
loader 
definitions 

Definition at line 293 of file ClassLoaderWeavingAdaptor.java.

References org::aspectj::weaver::World::getLint(), org::aspectj::weaver::loadtime::definition::Definition::getWeaverOptions(), org::aspectj::weaver::World::performExtraConfiguration(), org::aspectj::weaver::World::setAddSerialVerUID(), org::aspectj::weaver::World::setBehaveInJava5Way(), org::aspectj::weaver::World::setOptionalJoinpoints(), org::aspectj::weaver::World::setPinpointMode(), org::aspectj::weaver::World::setXHasMemberSupportEnabled(), org::aspectj::weaver::World::setXlazyTjp(), and org::aspectj::weaver::World::setXnoInline().

                                                                                                              {
            StringBuffer allOptions = new StringBuffer();
            for (Iterator iterator = definitions.iterator(); iterator.hasNext();) {
                  Definition definition = (Definition) iterator.next();
                  allOptions.append(definition.getWeaverOptions()).append(' ');
            }

            Options.WeaverOption weaverOption = Options.parse(allOptions.toString(), loader, getMessageHandler());

            // configure the weaver and world
            // AV - code duplicates AspectJBuilder.initWorldAndWeaver()
            World world = weaver.getWorld();
            setMessageHandler(weaverOption.messageHandler);
            world.setXlazyTjp(weaverOption.lazyTjp);
            world.setXHasMemberSupportEnabled(weaverOption.hasMember);
            world.setOptionalJoinpoints(weaverOption.optionalJoinpoints);
            world.setPinpointMode(weaverOption.pinpoint);
            weaver.setReweavableMode(weaverOption.notReWeavable);
            world.performExtraConfiguration(weaverOption.xSet);
            world.setXnoInline(weaverOption.noInline);
            // AMC - autodetect as per line below, needed for AtAjLTWTests.testLTWUnweavable
            world.setBehaveInJava5Way(LangUtil.is15VMOrGreater());
            world.setAddSerialVerUID(weaverOption.addSerialVersionUID);

            /* First load defaults */
            bcelWorld.getLint().loadDefaultProperties();

            /* Second overlay LTW defaults */
            bcelWorld.getLint().adviceDidNotMatch.setKind(null);

            /* Third load user file using -Xlintfile so that -Xlint wins */
            if (weaverOption.lintFile != null) {
                  InputStream resource = null;
                  try {
                        resource = loader.getResourceAsStream(weaverOption.lintFile);
                        Exception failure = null;
                        if (resource != null) {
                              try {
                                    Properties properties = new Properties();
                                    properties.load(resource);
                                    world.getLint().setFromProperties(properties);
                              } catch (IOException e) {
                                    failure = e;
                              }
                        }
                        if (failure != null || resource == null) {
                              warn("Cannot access resource for -Xlintfile:" + weaverOption.lintFile, failure);
                              // world.getMessageHandler().handleMessage(new Message(
                              // "Cannot access resource for -Xlintfile:"+weaverOption.lintFile,
                              // IMessage.WARNING,
                              // failure,
                              // null));
                        }
                  } finally {
                        try {
                              resource.close();
                        } catch (Throwable t) {
                        }
                  }
            }

            /* Fourth override with -Xlint */
            if (weaverOption.lint != null) {
                  if (weaverOption.lint.equals("default")) {// FIXME should be AjBuildConfig.AJLINT_DEFAULT but yetanother deps..
                        bcelWorld.getLint().loadDefaultProperties();
                  } else {
                        bcelWorld.getLint().setAll(weaverOption.lint);
                  }
            }
            // TODO proceedOnError option
      }


Generated by  Doxygen 1.6.0   Back to index