<< Pointcuts and Advice | Contents | Grammar >>
Aspect Deployment
Def: Aspect deployment is an activation of the advice of an object on a certain runtime scope.
General Rules (depl.gen)
(depl.gen.1) The joinpoints at which a piece of advice is called are limited by the shadow of its pointcut and runtime condition determined by its deployment type.
(depl.gen.2) If an object is not deployed its pieces of advice are never called.
(depl.gen.3) The same objects can be deployed on different scopes as well as using different types of deployment
(depl.gen.4) Repeated deployment on the same scope using the same deployment has no effect.
(depl.gen.5) All types of deployment are reversible. Object can be undeployed from any of the scope on which it was deployed
(depl.gen.6) An object undeployed from one scope, still it remains deployed on other scopes.
(depl.gen.7) Undeploying object from the scope on which it was not deployed has no effect.
(depl.gen.8) The pieces of advice of objects deployed on the same scope using the same type of deployment are called in the same order as objects were deployed.
(depl.gen.9) The call order of advice is undefined between different types of deployment.
Deployment Types (depl.types)
(depl.types.1) There are following predefined deployment types:
- Local deployment.
- Deployment on a thread.
- Deployment on remote process.
Local Deployment (depl.local)
(depl.local.1) Local deployment ensures that the advice of an object is called at the joinpoints in the local JVM
(depl.local.2) An object can be locally deployed using statement
deploy asp;
(depl.local.3) An object can be undeployed using
undeploy asp;
(depl.local.4) Static class field can be deployed statically on local scope using
deployed
keyword.
(depl.local.5) If a class has modifier
deployed
an implicit instance of the class is created and deployed locally.
- This is allowed only for top level, concrete (not abstract) Caesar classes.
Deployment on a Thread (depl.thread)
(depl.thread.1) Deployment on thread ensures that the advice of an object is called at the joinpoints in a certain thread.
(depl.thread.2) Using
deploy
statement the parameter object is deployed on the current thread within the scope of the block.
MyAspectClass myAspectObject = new MyAspectClass();
deploy(myAspectObject) {
/* deployed within the block */
doSomething();
}
(depl.thread.3) Nested
deploy
block on the same object has no effect.
MyAspectClass myAspectObject = new MyAspectClass();
deploy(myAspectObject) {
deploy(myAspectObject) { /* no effect */
doSomething();
}
}
Remote Deployment (depl.remote)
(depl.remote.1) Remote deployment ensures that the advice of an object is called at the joinpoints in a certain remote JVM process.
(depl.remote.2) An object can be deployed on a remote process in following way:
- An instance of
CaesarHost
class must be created in the remote process and initialized with a freely selected URL. activateAspectDeployment()
method must be called on the instance.
CaesarHost host = new CaesarHost("rmi://myprocessurl.net/");
host.activateAspectDeployment();
- An instance of
CaesarHost
must be created on the same process as the object to be deployed and initialized with the same URL as was used in the remote process.
- Object can be deployed on the remote process by calling
deployAspect
on the CaesarHost
instance
MyAspectClass myAspectObject = new MyAspectClass();
CaesarHost host = new CaesarHost("rmi://myprocessurl.net/");
host.deployAspect(myAspectObject);
- Object can be undeployed from the remote process by calling
undeployAspect
on the CaesarHost
instance
host.undeployAspect(myAspectObject);
<< Pointcuts and Advice | Contents | Grammar >>