Feb 16

RE: Understand AOP In 3 Easy Steps

AOP, Tech 3 Comments »

RMH has written Understand AOP In 3 Easy Steps:

Step 1: Download Russell Miles’ Eclipse/AspectJ distribution
Step 2: Try out the simple “Hello World” example.
Step 3: View demos by Adrian Coyer.

I understand where he is going. If you try these, they don’t take long, and can maybe get you to ‘get it’. When that happens, grab a copy of AspectJ in Action and friends. There are more than 3 steps :)

Also, remember the beauty of the adoption curve with AOP. You can incrementally play with it, debug with it, write policies in it, test with it, and then get into the production side.

It is good to see RMH getting into the AOP world. He wrote The AOP Application Server. Although I can agree with some of the points, I don’t want people to get thinking “AOP == for App Servers”. It is more than interceptors ;)

Feb 06

AOP: It isn’t about the platform

AOP, Tech No Comments »

One of the most exciting side effects of having AspectJ and AspectWerkz merge is that it allows us to move to an area of AOP which I am more passionate about.

Until recently, there has been a lot of work in the core AO platforms. As developers we were chosing between AspectJ, AspectWerkz, JBoss AOP, dynAOP, Spring AOP, etc.

While it was great to have a lot of innovation that these various frameworks bring to the table, and they all helped out the movement, I am hoping that AspectJ 5 will become the major choice for serious AOP development. This isn’t to say that there will not be a need to use the others. I use Spring AOP in my Spring projects. I would use JBoss AOP if I was working on the JBoss platform, etc. However, for projects that get deep into AOP in 2005, I think the majority will use AspectJ 5.

There is one item missing in AspectJ 5. It is time to move from the platform, to the libraries. With AspEn we wanted to create a standard set of enterprise aspects in library form. Our first work was for AspectJ (and is used in aTrack), and we wanted to port this over to AspectWerkz next. They had started their own effort as AWBench. (Spring obviously has a lot of practical solutions as well).

So, at the AOSD 2005 conference in Chicago, I am hopeful that people will get together to work on a great thing:

AJSE: Standard AspectJ Library

AJEE: Enterprise AspectJ Library

These libraries will take us to the next level, and will give users what they want. Aspects which allow you to do the things you want to do (credit where credit is due… JBoss is right about that!).

Jan 26

AOP: No more need for a standard in the Java space

AOP, Java, Tech No Comments »

From time to time the question has come up:

Do we need to have any standardization in the AOP space?

Of course, the first question that comes to mind, is what do you want to standardize?

The AOP Alliance got together several years ago, and gives you an API for dynamic proxy impls to play nice together (you can reuse advice and such with Spring AOP, dynaop, AspectWerkz, etc). However, the effort has stalled to some extend (maybe because it has done its job).

I think people wanted standardization because they wanted to be able to plugin different AOP systems like dynaop/Spring AOP/AspectWerkz/AspectJ. But we haven’t been in a place to do that yet, as the different platforms were really very different. We also don’t want to restrict to a low denominator too early, as we need to allow different frameworks to experiment and push things.

The AspectJ and AspectWerkz merger may well be the end of standards talk. When AspectJ 5 comes out it will be a top solution. We will have the full power of the AspectJ semantic model, yet for those who want it, they can use a Java/annotations view of things versus the AspectJ language.

AspectJ 5 will become the absolute de facto standard. I think it will be great for AOP as people will be able to get stuck in, and move on to more interesting problems, such as practices for using AOP, and even the holy grail of reuseable, REALLY USEFUL aspects :)

Jan 24

Spring AOP using AspectJ 5

AOP, Tech No Comments »

Now AspectJ 5 has been announced, it seems to me a bit of a no-brainer for Spring to have full on support for the more advanced point-cuts of AspectJ/AspectWerkz.

There has been various integration in the past, and I am sure there will be more in the future.

To start with, Alex (of AspectWerkz/AspectJ 5) has written a new AspectWerkzPointcutAdvisor.

So, take a look at before:

<bean id="theMethodExecutionGetTargetAndArgsAroundAdvisor1"
class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref local="theMethodExecutionGetTargetAndArgsAroundAdvice"/>
</property>
<property name="pattern">
<value>.*aroundStackedWithArgAndTarget.*</value>
</property>
</bean>

and now see how you can use the expressive pointcuts:

<bean id="theMethodExecutionAfterThrowingAdvisor"
class="awbench.spring.AspectWerkzPointcutAdvisor">
<property name="advice">
<ref local="theMethodExecutionAfterThrowingAdvice"/>
</property>
<property name="expression">
<value>execution(* *..*.afterThrowingRTE(..))</value>
</property>
</bean>

In fact, my guess is that, as time goes on and more people get into the power of AOP… the standard Spring AOP will be displaced by the more powerful Spring-AspectJ style.

However, Spring AOP has its uses, and it is great that you can chop and change so easily with Spring!

Jan 23

Aspect Concurrency Library

AOP, Tech No Comments »

Adrian has taken ideas from Herb Sutter, java.util.conrrency, and run with it.

He put together a small proof of concept which shows how aspects can really help you deal with concurrency issues. This also sits well with Futures (which Brian has been talking a lot about recently).

In theory you can @ParallelExecution on a method and nice things will happen. With Futures setup the threads can be kicked off, and .get(..) will be called to grab the return value.

Another great example for the AJSE library :)

Jan 19

Acegi Security Announces Version 0.7

AOP, Java, Lightweight Containers, Security, Tech No Comments »

A fair amount of Adigio projects have taken advantage of Acegi Security instead of container managed security. They just released version 0.7.

Dear Spring Community

I’m pleased to announce the Acegi Security System for Spring release 0.7.0 is now available from http://acegisecurity.sourceforge.net. The project provides comprehensive security services for The Spring Framework. You can read about the features in detail at http://acegisecurity.sourceforge.net.

There are many changes, improvements and fixes in release 0.7.0 (as listed at http://acegisecurity.sourceforge.net/changes-report.html). The major new feature areas are:

* Significant improvements to ACL security services
* AspectJ support (useful for instance-level security)
* Refactoring of ObjectDefinitionSources (especially useful for web URI
security)
* Automatic propagation of security identity via RMI and HttpInvoker
* Integration with Servlet Spec’s getRemoteUser()
* Refactoring of Contacts sample to use the new ACL security services
* Additional event publishing (now includes authorisation, not just
authentication)
* CVS restructure to use Maven as the build system
* A new project web site with FAQs, links to external articles etc

The new ACL security services deserve special mention, as they make it possible to develop applications that require complex instance-based security without any custom code. The entire configuration of such applications can be declared in the IoC container using standard Acegi Security services, so this should help significantly improve architecture and development time.

As per the Apache APR project versioning guidelines, this is a major release. We expect the next major release will be 1.0.0, although release 0.7.0 should be considered stable enough for most projects to use. There are detailed upgrade instructions included in the release ZIP and on the Acegi Security home page.

For Maven users, Acegi Security’s latest JARs are available from http://acegisecurity.sourceforge.net/maven/acegisecurity/jars. We will also be adding release 0.7.0 and above to iBiblio.

We hope you find this new release useful in your projects.

Best regards
Ben

Jan 19

AspectJ/AspectWerkz. JDO 2.0 Ballot Results. The good and the bad.

AOP, JDO, Java, ORM, Tech No Comments »

The top two posts on TheServerSide are:

  • AspectJ and AspectWerkz Merge Forces
  • JDO 2.0 Public Review Ballot

These give a glimpse at the good and the bad side of the Java community.

On the ‘good’ side we have the AOP news. Here we have two communities coming together for the greater good of the overall community. There isn’t the politics, nor the egos of “my app is better than yours”. They got together and talked about how they could work together and end up with a merger which is going to change AOP forever.

On the ‘bad’ side we have the JDO 2.0 ballot news. Here we have politics getting in the way. There are JDO users who are desperate to get JDO 2.0 implementations into their hands. They need it to take care of their business. Take a look at the vendors who went against the spec, and those who are for it.

I was optimistic, yet worried at the same time, about the EJB 3 / JDO 2 news that came out. It appears that some people are using that news as a way to hold back the JDO 2 spec. A lot of people have spent a LOT of time on that work, and our users deserve it right now.

P.s. I really liked Aslak’s quote regarding the AOP merger:

Forking seems to be more common than merging in the OSS world. This is great news. I wish you good luck.

Jan 19

AspectJ + AspectWerkz = AspectJ 5

AOP, Tech No Comments »

The announcement that the AspectJ and AspectWerkz team are merging is great. I think it is a serious win win for both projects, and more importantly… AOP in general.

I think the merger makes sense for both sides:

What AspectJ gets out of the merger

Top of the list is they get some really smart guys contributing to the new project. There is good work in the AspectWerkz weaver at load/runtime which can be used, and one of the biggest wins is political. There are a group of developers that don’t want to use AspectJ based on the syntax. The fact that it isn’t ‘just Java’. One of the great parts of the merger is that both front ends will be supported. Now developers will have the ability to use the AspectWerkz syntax if they prefer. This has just taken down another barrier to entry.

What AspectWerkz gets out of the merger

The AspectWerkz team has a great product. There are some pieces that they are missing and would like to have. For example, tools: Eclipse/IDEA Plugins, ajdoc, etc. The AspectJ team has several people dedicated to the tools. It is hard to expect Jonas and Alex to work on great tools as WELL as the platform itself. It also doesn’t really make sense for them to reinvent the wheel. Now they don’t have too. They will get to reuse the AspectJ tools, mature backend, and suddenly their development team has grown to include all of the great resources of the AspectJ group. This is a huge win.

The merger has been coming

If you have tracked both projects, you quickly see that the semantics have been getting closer and closer to eachother. Now, there are only a few differences between the core of both projects (semantically). As soon as you get to that point, it is obvious that it doesn’t make sense to compete as you are both so close. Team up and spend time furthering the cause instead of having two sets of tools. Two sets of backend.

The politics

The political side is also interesting. Who would have thought that BEA would be OK with having the project join Eclipse? There are reasons why it makes sense for the project to continue at Eclipse, and they revolve around patent law (remember, the Xerox patent is still out there!)

Read more: AspectJ and AspectWerkz to join forces

AspectJ and AspectWerkz Merge Forces

Jan 17

AspectJ 5 supports Java 5

AOP, Tech No Comments »

Adrian has been talking about getting Java 5 support into AspectJ. I can imagine how much work that has been, and I am impressed to hear that AspectJ 5 now supports full source compilation of Java 5 programs.

AJDT also has integrated in to Eclipse 3.1 M4 with full Java 5 support, eager parsing, and early error indications all working happily (not officially released).

Check out a SimpleAspect. Java 5 style:

import java.util.List;

@MyAnnotation
public aspect SimpleAspect {

int x;
static List myStringList;

public static void main(String[] args) {
for(String s:args) {
System.out.println(s);
myStringList.add(s);
}
C c = new C();
c.whatCsDoBest();
c.somethingElse();
c.myInt(5);
c.somethingElse(new Object(), new Object());
c.whoAmI();
D d = new D();
d.whoAmI();
}

pointcut annotatedExecution() :
execution(@MyAnnotation * *(..));

before() : annotatedExecution() {
System.out.println(thisJoinPoint + " has an annotation.");
}

before() : call(* myInt(..)) && args(int) {
System.out.println("Autoboxing match");
}

before(Object[] objects) : call(* somethingElse(Object...)) && args(objects) {
System.out.print("Varargs match: ");
for (Object o:objects) {
System.out.print(o + " ");
}
System.out.println();
}

before() : execution(C whoAmI()) {
System.out.println("Covariant match on execution(C whoAmI())");
}

before() : execution(D whoAmI()) {
System.out.println("Covariant match on execution(D whoAmI())");
}
}

class C {

@MyAnnotation
public void whatCsDoBest() {

}

public void somethingElse(Object... objects) {

}

public C whoAmI() {
return this;
}

Progress getAspectJ5Progress() {
return Progress.EXCELLENT;
}

public int myInt(Integer i) {
return i;
}

}

class D extends C {
public D whoAmI() {
return this;
}
}

@interface MyAnnotation {}

enum Progress { OK, GOOD, VERYGOOD, EXCELLENT }
Jan 06

Book Shipped: Eclipse AspectJ

AOP, Tech No Comments »

Congrats to Adrian Colyer, Andy Clement, George Harley, & Matthew Webster. They have just released their book: “Eclipse AspectJ”.

The book has examples which use real world technology. For example some of the projects use Hibernate and Spring and you can see how AOP can really help you out.

I’m pleased to say that the book “Eclipse AspectJ” (http://tinyurl.com/5enrc) is now shipping.

As well as comprehensive coverage of the AspectJ language, we use AJDT to teach and demonstrate both AJDT and AspectJ itself (a technique we have found works well when we give our talks and tutorials). The book has a running example of a simple insurance application that builds to eventually include full Hibernate and Spring integration.

The insurance application and many other samples are available for download as Eclipse projects via an update site. This will be on the Addison-Wesley site as soon as possible, and in the meantime we have mirrored it on the aspectprogrammer site: see http://www.aspectprogrammer.org/eclipseaspectj for install instructions.

You can see a full table of contents and download a sample chapter from:

http://www.awprofessional.com/title/0321245873

We hope you enjoy the book. Feedback is always welcome, and reviews posted to Amazon or B&N would be great too.

Thanks,
Adrian Colyer, Andy Clement, George Harley, & Matthew Webster.