Author: ozzy
Date: Tue Nov 17 13:25:02 2009
New Revision: 881273

URL: http://svn.apache.org/viewvc?rev=881273&view=rev
Log:
ARIES-47 Adding interceptor support

Added:
    
incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/Interceptor.java

Added: 
incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/Interceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/Interceptor.java?rev=881273&view=auto
==============================================================================
--- 
incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/Interceptor.java
 (added)
+++ 
incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/Interceptor.java
 Tue Nov 17 13:25:02 2009
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint;
+
+import java.lang.reflect.Method;
+
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+
+/**
+ * An Interceptor interface provides support for custom interceptor 
implementation.
+ */
+public interface Interceptor {
+    /**
+     * This is called just before the method m is invocation.
+     * @param cm : the component's metada
+     * @param m: the method to be invoked
+     * @param parameters: method parameters
+     * @return token which will subsequently be passed to postCall
+     * @throws Throwable
+     */
+    public Object preCall(ComponentMetadata cm, Method m, Object... 
parameters) throws Throwable;
+    
+    /**
+     * This method is called after the method m is invoked and returned 
normally.
+     * @param cm: the component metadata
+     * @param m: the method invoked
+     * @param returnType : the return object
+     * @param preCallToken token returned by preCall
+     * @throws Throwable
+     */
+    public void postCallWithReturn(ComponentMetadata cm, Method m, Object 
returnType, Object preCallToken) throws Throwable;
+    
+    /**
+     * The method is called after the method m is invoked and causes an 
exception.
+     * @param cm : the component metadata
+     * @param m : the method invoked
+     * @param ex : the exception thrown
+     * @param preCallToken token returned by preCall
+     * @throws Throwable
+     */
+    public void postCallWithException(ComponentMetadata cm, Method m, 
Exception ex, Object preCallToken) throws Throwable;
+    
+    
+    /**
+     * Return the rank of the interceptor, which is used to determine the 
order of the interceptors to be invoked
+     * Rank is between Integer.MIN_VALUE and Integer.MAX_VALUE, interceptors 
are called in the order of highest value
+     * rank first to lowest value rank last i.e. an interceptor with rank 
Integer.MAX_VALUE will be called before 
+     * all others (except of the same rank).
+     * @return the rank of the interceptor
+     */
+    public int getRank();
+}


Reply via email to