Skip to content

Commit

Permalink
Merge branch 'master' into pascal_semi
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Jan 25, 2011
2 parents b22bba6 + 1ae7e59 commit 4aca3f5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
38 changes: 38 additions & 0 deletions corpus/annotations/transactions/Transactional.ceylon
@@ -0,0 +1,38 @@
shared annotation {
ofElements = methods;
occurs = onceEachElement;
}
Transactional transactional(Boolean requiresNew = false) {
return Transactional(requiresNew)
}

shared class Transactional(Boolean requiresNew)
satisfies MethodAnnotation {

shared Boolean requiresNew = requiresNew;

doc "This method is called whenever Ceylon loads a class with a method
annotated |transactional|. It registers a transaction management
interceptor for the method."
shared actual void onDefineMethod<X,T,P...>(OpenMethod<X,T,P...> method) {
method.intercept()
onInvoke(X instance, T proceed(P... args), P... args) {
if (currentTransaction.inProcess || !requiresNew) {
return proceed(args)
}
else {
currentTransaction.begin();
try {
T result = proceed(args);
currentTransaction.commit();
return result
}
catch (Exception e) {
currentTransaction.rollback();
throw e
}
}
}
}

}
23 changes: 23 additions & 0 deletions corpus/ui/component/Component.ceylon
@@ -0,0 +1,23 @@
shared abstract class Component() {

OpenList<Observer> observers = none;

shared Observer[] currentObservers {
return observers
}

shared void addObserver(Observer o)() {
observers.append(o);
void remove() {
observers.remove(o);
}
return remove
}

shared void fire(Event event) {
for (Observer o in observers) {
o.observe(event);
}
}

}

0 comments on commit 4aca3f5

Please sign in to comment.