0 Replies Latest reply on Dec 19, 2002 10:10 AM by bill.burke

    configuration and metadata

    bill.burke

      How will we configure Aspects? Here's what I've come up with. I'll talk in XML first then walk you through it.

      <class-metadata name="somedata" group="transaction" class="com.mycom.MyClass">

      Supports



      RequiresNew


      </class-metadata>

      Ok for this example I'm describing the EJB transaction attributes for the com.mycom.MyClass class. The default value is "supports" this is defined at the class level. Then, every "get" method overrides the default to be RequiresNew. Now, any tag under or will be considered the attribute name, for example.

      <class-metadata name="id2" group="cache" class="com.mycom.MyClass">

      <max-cache-size>1000</max-cache-size>
      <min-cache-size>1</min-cache-size>

      </class-metadata>

      Get it?

      Ok, next concept is, how to resolve metadata/config info? The first scenario is, what if there is no <class-metadata> defined for a given class? For this I'll have a <default-metadata> construct.

      <default-metadata group="transaction">
      Required
      </default-metadata>

      <default-metadata group="cache">
      <max-cache-size>1000000</max-cache-size>
      <min-cache-size>0</min-cache-size>
      </default-metadata>

      So if there is no class-metadata defined then the value is resolved through <default-metadata>.

      Ok, let's take this concept of resolving a step further. Next, there will be different levels that metadata can be overriden. In summary:

      invocation->ThreadLocal->instance->method->class->default

      Let's give examples of each one:
      invocation:
      {
      Advised aspected = (Advised)someobj;
      aspected._getAdvisor().nextInvocationOverride("transaction", "transattribute", "NotSupported");
      someobj.businessMethod();
      }
      In this example, the developer states that the next invocation will override the transattribute for the duration of the invocation and no longer.

      ThreadLocal:
      {
      Advisor.overrideThread("logging", "logginglevel", "debug");
      }

      In this example, any invocations on any aspected objects will have the "loggin", "logginglevel" set to debug for this thread and only this thread.

      Hopefully, I'm making sense. In the future, we will get funkier with the "default-metadata". Like setting up your own chains there. class->default(application->JVM->cluster).

      Bill