Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #61: "joint point" should be "join point" #62

Merged
merged 1 commit into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ts-node demo/index.ts

# API

The library offers the following combinations of advices and joint points:
The library offers the following combinations of advices and join points:

## Method calls

Expand Down Expand Up @@ -185,7 +185,7 @@ Here's a UML class diagram which shows the relations between the individual abst
- [x] Throwing
- [x] Returning
- [x] Around
- [x] Implement the following joint points:
- [x] Implement the following join points:
- [x] Method execution
- [x] Static method execution
- [x] Filed get
Expand Down
8 changes: 4 additions & 4 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {MethodSelector, MemberSelector} from './src/joint_points/selectors';
import {MethodSelector, MemberSelector} from './src/join_points/selectors';
import {
BeforeAdvice,
AroundAdvice,
Expand All @@ -7,11 +7,11 @@ import {

AsyncOnThrowAdvice,
} from './src/advices';
import {makeMethodCallAdviceDecorator, makeStaticMethodAdviceDecorator} from './src/joint_points';
import {makeFieldGetAdviceDecorator, makeFieldSetAdviceDecorator} from './src/joint_points';
import {makeMethodCallAdviceDecorator, makeStaticMethodAdviceDecorator} from './src/join_points';
import {makeFieldGetAdviceDecorator, makeFieldSetAdviceDecorator} from './src/join_points';

export {Wove, Metadata, MethodMetadata, AspectRegistry as _AspectRegistry, Targets as _Targets} from './src/core';
export {MemberPrecondition} from './src/joint_points';
export {MemberPrecondition} from './src/join_points';

export const beforeMethod = makeMethodCallAdviceDecorator(BeforeAdvice);
export const afterMethod = makeMethodCallAdviceDecorator(AfterAdvice);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/core.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './core/advice';
export * from './core/aspect';
export * from './core/joint_point';
export * from './core/join_point';
export * from './core/metadata';
export * from './core/pointcut';
export * from './core/wove';
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/src/core/pointcut.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { JointPoint } from './joint_point';
import { JointPoint } from './join_point';
import { Advice } from './advice';

export class Pointcut {
public jointPoints: JointPoint[];
public joinPoints: JointPoint[];
public advice: Advice;
private _applications = new Set<Function>();

Expand All @@ -11,6 +11,6 @@ export class Pointcut {
return;
}
this._applications.add(fn);
this.jointPoints.forEach(jp => jp.wove({ fn, matches: jp.match(fn), woveMetadata }, this.advice));
this.joinPoints.forEach(jp => jp.wove({ fn, matches: jp.match(fn), woveMetadata }, this.advice));
}
}
7 changes: 7 additions & 0 deletions lib/src/join_points.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from './join_points/preconditions';
export * from './join_points/selectors';

export * from './join_points/method_call';
export * from './join_points/accessor_use';
export * from './join_points/static_method';

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JointPoint, Precondition } from '../core/joint_point';
import { JointPoint, Precondition } from '../core/join_point';
import { Advice } from '../core/advice';
import { Pointcut } from '../core/pointcut';
import { AspectRegistry, Targets, Aspect } from '../core/aspect';
Expand Down Expand Up @@ -52,12 +52,12 @@ export class AccessorJointPoint extends JointPoint {
export function makeFieldGetAdviceDecorator(constr: new (...args: any[]) => Advice) {
return function(...selectors: MemberSelector[]): MethodDecorator {
return function<T>(target: Object, prop: string | symbol, descriptor: TypedPropertyDescriptor<T>) {
const jointpoints = selectors.map(selector => {
const joinpoints = selectors.map(selector => {
return new AccessorJointPoint(new MemberPrecondition(selector), 'get');
});
const pointcut = new Pointcut();
pointcut.advice = <Advice>new constr(target, descriptor.value);
pointcut.jointPoints = jointpoints;
pointcut.joinPoints = joinpoints;
const aspectName = target.constructor.name;
const aspect = AspectRegistry.get(aspectName) || new Aspect();
aspect.pointcuts.push(pointcut);
Expand All @@ -70,12 +70,12 @@ export function makeFieldGetAdviceDecorator(constr: new (...args: any[]) => Advi
export function makeFieldSetAdviceDecorator(constr: new (...args: any[]) => Advice) {
return function(...selectors: MemberSelector[]): MethodDecorator {
return function<T>(target: Object, prop: string | symbol, descriptor: TypedPropertyDescriptor<T>) {
const jointpoints = selectors.map(selector => {
const joinpoints = selectors.map(selector => {
return new AccessorJointPoint(new MemberPrecondition(selector), 'set');
});
const pointcut = new Pointcut();
pointcut.advice = <Advice>new constr(target, descriptor.value);
pointcut.jointPoints = jointpoints;
pointcut.joinPoints = joinpoints;
const aspectName = target.constructor.name;
const aspect = AspectRegistry.get(aspectName) || new Aspect();
aspect.pointcuts.push(pointcut);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Precondition, JointPoint } from '../core/joint_point';
import { Precondition, JointPoint } from '../core/join_point';
import { Advice } from '../core/advice';
import { Pointcut } from '../core/pointcut';
import { AspectRegistry, Targets, Aspect } from '../core/aspect';
Expand Down Expand Up @@ -50,12 +50,12 @@ export class MethodCallJointPoint extends JointPoint {
export function makeMethodCallAdviceDecorator(constr: any) {
return function(...selectors: MethodSelector[]): MethodDecorator {
return function<T>(target: Object, prop: symbol | string, descriptor: TypedPropertyDescriptor<T>) {
let jointpoints = selectors.map(selector => {
let joinpoints = selectors.map(selector => {
return new MethodCallJointPoint(new MethodPrecondition(selector));
});
let pointcut = new Pointcut();
pointcut.advice = <Advice>new constr(target, descriptor.value);
pointcut.jointPoints = jointpoints;
pointcut.joinPoints = joinpoints;
let aspectName = target.constructor.name;
let aspect = AspectRegistry.get(aspectName) || new Aspect();
aspect.pointcuts.push(pointcut);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Precondition } from '../core/joint_point';
import { Precondition } from '../core/join_point';
import { MethodSelector, MemberSelector } from './selectors';
import { weave } from '../core/wove';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Precondition, JointPoint } from '../core/joint_point';
import { Precondition, JointPoint } from '../core/join_point';
import { Advice } from '../core/advice';
import { Pointcut } from '../core/pointcut';
import { AspectRegistry, Targets, Aspect } from '../core/aspect';
Expand Down Expand Up @@ -43,12 +43,12 @@ export class StaticMethodJointPoint extends JointPoint {
export function makeStaticMethodAdviceDecorator(constr: any) {
return function(...selectors: MethodSelector[]): MethodDecorator {
return function<T>(target: Object, prop: symbol | string, descriptor: TypedPropertyDescriptor<T>) {
let jointpoints = selectors.map(selector => {
let joinpoints = selectors.map(selector => {
return new StaticMethodJointPoint(new MethodPrecondition(selector));
});
let pointcut = new Pointcut();
pointcut.advice = <Advice>new constr(target, descriptor.value);
pointcut.jointPoints = jointpoints;
pointcut.joinPoints = joinpoints;
let aspectName = target.constructor.name;
let aspect = AspectRegistry.get(aspectName) || new Aspect();
aspect.pointcuts.push(pointcut);
Expand Down
7 changes: 0 additions & 7 deletions lib/src/joint_points.ts

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"javascript",
"decorators",
"pointcut",
"joint point"
"join point",
"joinpoint"
],
"author": "Minko Gechev <mgechev@gmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion test/core/pointcut.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Pointcut', () => {

jp2 = new SimpleJP(new SimplePrecondition());
jp2.precondition = new SimplePrecondition();
pc.jointPoints = [jp1, jp2];
pc.joinPoints = [jp1, jp2];
});
it('Match should be invoked', done => {
let bak = jp1.match;
Expand Down
4 changes: 2 additions & 2 deletions test/core/preconditions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MemberSelector } from './../../lib/src/joint_points/selectors';
import { MemberPrecondition } from './../../lib/src/joint_points/preconditions';
import { MemberSelector } from './../../lib/src/join_points/selectors';
import { MemberPrecondition } from './../../lib/src/join_points/preconditions';

import { expect } from 'chai';

Expand Down