Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Example Use Case

We start out with a simple JSR175 annotation type called DeploymentInfo.

DeploymentInfo.java

Generate Phase

The first thing we have to do is generate an AnnoBean that will act as a proxy to instances of DeploymentInfo. To do this, we simply run Annogen's compilation task on DeploymentInfo:

build.xml

This generates a DeploymentInfoAnnoBean that implements DeploymentInfo:

DeploymentInfoAnnoBean.java

Override Phase

Notice that the generated DeploymentInfoAnnoBean has a setter. We're now going to create an AnnoOverrider} which uses that setter to effectively change the size of the cache on {{TinyCacheEJB. We first create an instance of StoredAnnoOverrider, which is a helper class Annogen provides for building simple AnnoOverriders.

User.java

StoredAnnoOverrider requires us to make an ElementId} for the {{TinyCacheEJB class:

User.java

The StoredAnnoOverrider will provide this DeplyomentInfoAnnoBean as a replacement for the DeploymentInfo annotation on TinyCacheEJB. So, if we change the value of cacheSize on it:

User.java

We have changed the value of cache size for TinyCacheEJB as it will appear when our framework code views its DeploymentInfo annotation.

View Phase

Compared to the Override phase, the View phase is very simple. All we have to do is create an AnnoViewer using the AnnoOverrider which we created above:

DeployerTool.java

This annoViewer can now tell us about any annotations want to know about. If get the DeploymentInfo for TinyCacheEJB:

DeployerTool.java

we will get back a DeploymentInfo annotation object which reflects our cacheSize override. In reality, deploymentInfo is an instance of DeploymentInfoAnnoBean, but the nice thing here is that it is an isntance of our regular 175 annotation type, DeploymentInfo.

  • No labels