summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2006-01-18 14:37:02 +0000
committeracolyer <acolyer>2006-01-18 14:37:02 +0000
commit6c16b86a6a68fc7063ea5a8f206d495cb6a36e0f (patch)
treed2eb6dab07c31c78bfd4646d4150dcbfd76d851d
parente0d6f5412b278639a1cc889eda1d8fba041d50ba (diff)
downloadaspectj-6c16b86a6a68fc7063ea5a8f206d495cb6a36e0f.tar.gz
aspectj-6c16b86a6a68fc7063ea5a8f206d495cb6a36e0f.zip
an additional interface that custom message handlers may choose to implement. Implementors get callbacks when a build is starting and when a build has finished (allowing them to perform before and after build processing, like closing output files etc..).
-rw-r--r--bridge/src/org/aspectj/bridge/ILifecycleAware.java35
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java7
2 files changed, 42 insertions, 0 deletions
diff --git a/bridge/src/org/aspectj/bridge/ILifecycleAware.java b/bridge/src/org/aspectj/bridge/ILifecycleAware.java
new file mode 100644
index 000000000..c5ac9b149
--- /dev/null
+++ b/bridge/src/org/aspectj/bridge/ILifecycleAware.java
@@ -0,0 +1,35 @@
+/* *******************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer Initial implementation
+ * ******************************************************************/
+package org.aspectj.bridge;
+
+/**
+ * Interface that can be implemented by MessageHandlers that need to
+ * perform some additional processing when a build is starting and
+ * when it has finished.
+ *
+ * @author Adrian Colyer
+ * @since 1.5.1
+ */
+public interface ILifecycleAware {
+
+ /**
+ * called when a build starts
+ */
+ void buildStarting(boolean isIncremental);
+
+ /**
+ * called when a batch build finishes
+ *
+ */
+ void buildFinished(boolean wasIncremental);
+
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
index 0cbb761db..1468bed19 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
@@ -52,6 +52,7 @@ import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.internal.ProgramElement;
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.CountingMessageHandler;
+import org.aspectj.bridge.ILifecycleAware;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.IProgressListener;
@@ -172,6 +173,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
boolean ret = true;
batchCompile = batch;
+ if (baseHandler instanceof ILifecycleAware) {
+ ((ILifecycleAware)baseHandler).buildStarting(!batch);
+ }
int phase = batch ? CompilationAndWeavingContext.BATCH_BUILD : CompilationAndWeavingContext.INCREMENTAL_BUILD;
ContextToken ct = CompilationAndWeavingContext.enteringPhase(phase ,buildConfig);
try {
@@ -311,6 +315,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
CompilationAndWeavingContext.leavingPhase(ct);
} finally {
+ if (baseHandler instanceof ILifecycleAware) {
+ ((ILifecycleAware)baseHandler).buildFinished(!batch);
+ }
if (zos != null) {
closeOutputStream(buildConfig.getOutputJar());
}