Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

The AspectJ Programming Language

Prednáška 2, AOVS 2017/18, fiit.sk/~vranic/aovs
by

Valentino Vranić

on 24 September 2018

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of The AspectJ Programming Language

The AspectJ Programming Language
Valentino Vranić
vranic@stuba.sk fiit.sk/~vranic
> The complexity of asymetric AOP lies in the pointcut language

> A captured join point and its context is under the control of the piece of advice

> It's difficult to create good pointcuts

> Introducing elements into classes using inter-type declarations mimicks symmetric aspect-oriented programming
AOSD 2018/19
24/9/2018
Lecture 2:
fiit.sk/~vranic/aosd/feedback
If you would be proposing
an aspect-oriented language,
capturing of
what kinds of join points
would it enable?
How the join points that need to be captured could be specified?
What can be done with a captured join point?
Symetric aspect-oriented decomposition makes possible to have separate views of the same class.

How could we mimick this in asymetric aspect-oriented programming?
Aspects modify program execution in join points

- Join points are determined by
pointcuts
- Modifications are expressed as
advice

- A piece of advice is executed before, after, or around (instead of) a join point

Aspects can add new elements and inheritance relationships to classes using
inter-type declarations

Aspect instances are created automatically
Exposed join points in AspectJ

- Methods and constructors: call and execution

- Field access: reading and writing

- Exception handling: exception handler execution

- Initialization of classes and objects: static inicitializer block execution, object initialization and object preinitialization

- Advice execution: execution of all pieces of advice in a program
Kinds of primitive pointcuts

- method and constructor calls and executions
- control flow based pointcuts
- execution object pointcuts
- argument pointcuts
- pointcuts based on the lexical structure
- field access
- intialization
- exception handling
- advice execution
- conditional pointcut
- annotation based pointcuts
Any pointcut is good. Is it really?

What problems can there be with pointcuts?

An example form AspectJ in Action (http://www.manning.com/laddad/)

public abstract class Account {
private float _balance;
private int _accountNumber;

public Account(int accountNumber) {
_accountNumber = accountNumber;
}

public void credit(float amount) {
setBalance(getBalance() + amount);
}

public void debit(float amount) throws InsufficientBalanceException {
float balance = getBalance();
if (balance < amount) {
throw new InsufficientBalanceException(
"Total balance not sufficient");
}
else {
setBalance(balance - amount);
}
}
public float getBalance() {
return _balance;
}

public void setBalance(float balance) {
_balance = balance;
}
}



public class SavingsAccount extends Account {
public SavingsAccount(int accountNumber) {
super(accountNumber);
}
}



public aspect MinimumBalanceRuleAspect {
private float Account._minimumBalance;

public float Account.getAvailableBalance() {
return getBalance() - _minimumBalance;
}

after(Account account):
execution(SavingsAccount.new(..)) && this(account) {
account._minimumBalance = 25;
}

before(Account account, float amount) throws
InsufficientBalanceException:
execution(* Account.debit()) && this(account) && args(amount) {
if (account.getAvailableBalance() < amount) {
throw new InsufficientBalanceException(
"Insufficient available balance");
}
}
}




aspect AccountTrackingAspect {
declare parents: banking..entities.* implements Identifiable
}
Join point: a point captured in program execution

Join point shadow: the corresponding programming language construct
Institute of Informatics, Information Systems, and Software Engineering
Full transcript