You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/04/05 23:03:04 UTC

[09/50] [abbrv] git commit: updated refs/heads/affinity_groups to ca1a794

Retire unused files to avoid confusions


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/58c962ef
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/58c962ef
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/58c962ef

Branch: refs/heads/affinity_groups
Commit: 58c962ef15d507226a8cc0eb18abca23142cff1f
Parents: 7e54f40
Author: Kelven Yang <ke...@gmail.com>
Authored: Tue Apr 2 15:53:09 2013 -0700
Committer: Kelven Yang <ke...@gmail.com>
Committed: Tue Apr 2 15:55:41 2013 -0700

----------------------------------------------------------------------
 .../configuration/DefaultInterceptorLibrary.java   |   33 ----
 server/src/com/cloud/event/ActionEventUtils.java   |  114 ---------------
 .../utils/component/AnnotationInterceptor.java     |   36 -----
 .../utils/component/ComponentMethodProxyCache.java |   90 ------------
 .../cloud/utils/component/InterceptorLibrary.java  |   25 ---
 .../utils/component/MatchAnyMethodPointcut.java    |   27 ----
 utils/src/com/cloud/utils/db/DatabaseCallback.java |   84 -----------
 .../com/cloud/utils/db/DatabaseCallbackFilter.java |   58 --------
 8 files changed, 0 insertions(+), 467 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c962ef/server/src/com/cloud/configuration/DefaultInterceptorLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultInterceptorLibrary.java b/server/src/com/cloud/configuration/DefaultInterceptorLibrary.java
deleted file mode 100644
index 13a22db..0000000
--- a/server/src/com/cloud/configuration/DefaultInterceptorLibrary.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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 com.cloud.configuration;
-
-import com.cloud.event.ActionEventUtils;
-import com.cloud.utils.component.AnnotationInterceptor;
-import com.cloud.utils.component.InterceptorLibrary;
-import com.cloud.utils.db.DatabaseCallback;
-
-import java.util.List;
-
-public class DefaultInterceptorLibrary implements InterceptorLibrary {
-
-    @Override
-    public void addInterceptors(List<AnnotationInterceptor<?>> interceptors) {
-        interceptors.add(new DatabaseCallback());
-        interceptors.add(new ActionEventUtils.ActionEventCallback());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c962ef/server/src/com/cloud/event/ActionEventUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java
index 3f3ca68..a2d4906 100755
--- a/server/src/com/cloud/event/ActionEventUtils.java
+++ b/server/src/com/cloud/event/ActionEventUtils.java
@@ -22,14 +22,9 @@ import com.cloud.server.ManagementServer;
 import com.cloud.user.Account;
 import com.cloud.user.AccountVO;
 import com.cloud.user.User;
-import com.cloud.user.UserContext;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
-import com.cloud.utils.component.AnnotationInterceptor;
 import com.cloud.utils.component.ComponentContext;
-import net.sf.cglib.proxy.Callback;
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
 import org.apache.cloudstack.framework.events.EventBus;
 import org.apache.cloudstack.framework.events.EventBusException;
 import org.apache.log4j.Logger;
@@ -38,8 +33,6 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -185,111 +178,4 @@ public class ActionEventUtils {
         AccountVO account = _accountDao.findByIdIncludingRemoved(accountId);
         return account.getDomainId();
     }
-
-    public static class ActionEventCallback implements MethodInterceptor, AnnotationInterceptor<EventVO> {
-
-        @Override
-        public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
-            EventVO event = interceptStart(method);
-            boolean success = true;
-            try {
-                return methodProxy.invokeSuper(object, args);
-            } catch (Exception e){
-                success = false;
-                interceptException(method, event);
-                throw e;
-            } finally {
-                if(success){
-                    interceptComplete(method, event);
-                }
-            }
-        }
-
-        @Override
-        public boolean needToIntercept(AnnotatedElement element) {
-            if (!(element instanceof Method)) {
-                return false;
-
-            }
-            Method method = (Method)element;
-            ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
-            if (actionEvent != null) {
-                return true;
-            }
-
-            return false;
-        }
-
-        @Override
-        public EventVO interceptStart(AnnotatedElement element) {
-            EventVO event = null;
-            Method method = (Method)element;
-            ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
-            if (actionEvent != null) {
-                boolean async = actionEvent.async();
-                if(async){
-                    UserContext ctx = UserContext.current();
-                    long userId = ctx.getCallerUserId();
-                    long accountId = ctx.getAccountId();
-                    long startEventId = ctx.getStartEventId();
-                    String eventDescription = actionEvent.eventDescription();
-                    if(ctx.getEventDetails() != null){
-                        eventDescription += ". "+ctx.getEventDetails();
-                    }
-                    ActionEventUtils.onStartedActionEvent(userId, accountId, actionEvent.eventType(), eventDescription, startEventId);
-                }
-            }
-            return event;
-        }
-
-        @Override
-        public void interceptComplete(AnnotatedElement element, EventVO event) {
-            Method method = (Method)element;
-            ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
-            if (actionEvent != null) {
-                UserContext ctx = UserContext.current();
-                long userId = ctx.getCallerUserId();
-                long accountId = ctx.getAccountId();
-                long startEventId = ctx.getStartEventId();
-                String eventDescription = actionEvent.eventDescription();
-                if(ctx.getEventDetails() != null){
-                    eventDescription += ". "+ctx.getEventDetails();
-                }
-                if(actionEvent.create()){
-                    //This start event has to be used for subsequent events of this action
-                    startEventId = ActionEventUtils.onCreatedActionEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully created entity for " + eventDescription);
-                    ctx.setStartEventId(startEventId);
-                } else {
-                    ActionEventUtils.onCompletedActionEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully completed " + eventDescription, startEventId);
-                }
-            }
-        }
-
-        @Override
-        public void interceptException(AnnotatedElement element, EventVO event) {
-            Method method = (Method)element;
-            ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
-            if (actionEvent != null) {
-                UserContext ctx = UserContext.current();
-                long userId = ctx.getCallerUserId();
-                long accountId = ctx.getAccountId();
-                long startEventId = ctx.getStartEventId();
-                String eventDescription = actionEvent.eventDescription();
-                if(ctx.getEventDetails() != null){
-                    eventDescription += ". "+ctx.getEventDetails();
-                }
-                if(actionEvent.create()){
-                    long eventId = ActionEventUtils.onCreatedActionEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while creating entity for " + eventDescription);
-                    ctx.setStartEventId(eventId);
-                } else {
-                    ActionEventUtils.onCompletedActionEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while " + eventDescription, startEventId);
-                }
-            }
-        }
-
-        @Override
-        public Callback getCallback() {
-            return this;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c962ef/utils/src/com/cloud/utils/component/AnnotationInterceptor.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/AnnotationInterceptor.java b/utils/src/com/cloud/utils/component/AnnotationInterceptor.java
deleted file mode 100644
index e69862c..0000000
--- a/utils/src/com/cloud/utils/component/AnnotationInterceptor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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
-// 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 com.cloud.utils.component;
-
-import java.lang.reflect.AnnotatedElement;
-
-import net.sf.cglib.proxy.Callback;
-
-/**
- *  AnnotationIntercepter says it can intercept an annotation.
- */
-public interface AnnotationInterceptor<T> {
-    boolean needToIntercept(AnnotatedElement element);
-    
-    T interceptStart(AnnotatedElement element);
-    
-    void interceptComplete(AnnotatedElement element, T attach);
-    
-    void interceptException(AnnotatedElement element, T attach);
-    
-    Callback getCallback();
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c962ef/utils/src/com/cloud/utils/component/ComponentMethodProxyCache.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentMethodProxyCache.java b/utils/src/com/cloud/utils/component/ComponentMethodProxyCache.java
deleted file mode 100644
index ea3b685..0000000
--- a/utils/src/com/cloud/utils/component/ComponentMethodProxyCache.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// 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
-// 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 com.cloud.utils.component;
-
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Method;
-import java.util.WeakHashMap;
-
-public class ComponentMethodProxyCache {
-
-	private static WeakHashMap<TargetKey, WeakReference<Method>> s_cache = new WeakHashMap<TargetKey, WeakReference<Method>>();
-	
-	public ComponentMethodProxyCache() {
-	}
-	
-	public static Method getTargetMethod(Method method, Object target) {
-		synchronized(s_cache) {
-			WeakReference<Method> targetMethod = s_cache.get(new TargetKey(method, target));
-			if(targetMethod != null && targetMethod.get() != null)
-				return targetMethod.get();
-
-        	Class<?> clazz = target.getClass();
-        	for(Method m : clazz.getMethods()) {
-        		if(isMethodMatched(method, m)) {
-        			s_cache.put(new TargetKey(method, target), new WeakReference<Method>(m));
-        			return m;
-        		}
-        	}
-			
-        	return method;
-		}
-	}
-	
-	private static boolean isMethodMatched(Method m1, Method m2) {
-		if(!m1.getName().equals(m2.getName()))
-			return false;
-		
-		Class<?>[] params1 = m1.getParameterTypes();
-		Class<?>[] params2 = m2.getParameterTypes();
-		
-		if(params1.length != params2.length)
-			return false;
-		
-		for(int i = 0; i < params1.length; i++) {
-			if(!params1[i].isAssignableFrom(params2[i]))
-				return false;
-		}
-		
-		return true;
-	}
-	
-	public static class TargetKey {
-		Method _method;
-		Object _target;
-		
-		public TargetKey(Method method, Object target) {
-			_method = method;
-			_target = target;
-		}
-		
-		@Override
-	    public boolean equals(Object obj) {
-			if(!(obj instanceof TargetKey))
-				return false;
-			
-			// for target object, we just check the reference
-			return _method.equals(((TargetKey)obj)._method) &&
-					_target == ((TargetKey)obj)._target;
-		}
-		
-	    public int hashCode() {
-	    	return _target.hashCode() ^ _target.hashCode();
-	    }
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c962ef/utils/src/com/cloud/utils/component/InterceptorLibrary.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/InterceptorLibrary.java b/utils/src/com/cloud/utils/component/InterceptorLibrary.java
deleted file mode 100644
index 96be50b..0000000
--- a/utils/src/com/cloud/utils/component/InterceptorLibrary.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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
-// 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 com.cloud.utils.component;
-
-import java.util.List;
-
-public interface InterceptorLibrary {
-    
-    void addInterceptors(List<AnnotationInterceptor<?>> interceptors);
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c962ef/utils/src/com/cloud/utils/component/MatchAnyMethodPointcut.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/MatchAnyMethodPointcut.java b/utils/src/com/cloud/utils/component/MatchAnyMethodPointcut.java
deleted file mode 100644
index dd59734..0000000
--- a/utils/src/com/cloud/utils/component/MatchAnyMethodPointcut.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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
-// 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 com.cloud.utils.component;
-
-import java.lang.reflect.Method;
-
-import org.springframework.aop.support.StaticMethodMatcherPointcut;
-
-public class MatchAnyMethodPointcut extends StaticMethodMatcherPointcut {
-	public boolean matches(Method method, Class<?> cls) {
-		return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c962ef/utils/src/com/cloud/utils/db/DatabaseCallback.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/DatabaseCallback.java b/utils/src/com/cloud/utils/db/DatabaseCallback.java
deleted file mode 100644
index 718acf5..0000000
--- a/utils/src/com/cloud/utils/db/DatabaseCallback.java
+++ /dev/null
@@ -1,84 +0,0 @@
-// 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
-// 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 com.cloud.utils.db;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-
-import net.sf.cglib.proxy.Callback;
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-import com.cloud.utils.component.AnnotationInterceptor;
-
-public class DatabaseCallback implements MethodInterceptor, AnnotationInterceptor<Transaction> {
-
-    @Override
-    public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
-        Transaction txn = interceptStart(method);
-        try {
-            return methodProxy.invokeSuper(object, args);
-        } finally {
-            interceptComplete(method, txn);
-        }
-    }
-
-    @Override
-    public boolean needToIntercept(AnnotatedElement element) {
-        if (!(element instanceof Method)) {
-            return false;
-            
-        }
-        Method method = (Method)element;
-        DB db = method.getAnnotation(DB.class);
-        if (db != null) {
-            return db.txn();
-        }
-        
-        Class<?> clazz = method.getDeclaringClass();
-        do {
-            db = clazz.getAnnotation(DB.class);
-            if (db != null) {
-                return db.txn();
-            }
-            clazz = clazz.getSuperclass();
-        } while (clazz != Object.class && clazz != null);
-        
-        return false;
-    }
-
-    @Override
-    public Transaction interceptStart(AnnotatedElement element) {
-        return Transaction.open(((Method)element).getName());
-    }
-
-    @Override
-    public void interceptComplete(AnnotatedElement element, Transaction txn) {
-        txn.close();
-    }
-
-    @Override
-    public void interceptException(AnnotatedElement element, Transaction txn) {
-        txn.close();
-    }
-
-    @Override
-    public Callback getCallback() {
-        return this;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c962ef/utils/src/com/cloud/utils/db/DatabaseCallbackFilter.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/DatabaseCallbackFilter.java b/utils/src/com/cloud/utils/db/DatabaseCallbackFilter.java
deleted file mode 100755
index 7bace70..0000000
--- a/utils/src/com/cloud/utils/db/DatabaseCallbackFilter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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
-// 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 com.cloud.utils.db;
-
-import java.lang.reflect.Method;
-
-import net.sf.cglib.proxy.CallbackFilter;
-
-public class DatabaseCallbackFilter implements CallbackFilter {
-    @Override
-    public int accept(Method method) {
-        return checkAnnotation(method) ? 1 : 0;
-    }
-    
-    public static boolean checkAnnotation(Method method) {
-    	/*Check self*/
-        DB db = method.getAnnotation(DB.class);
-        if (db != null) {
-            return db.txn();
-        }
-        Class<?> clazz = method.getDeclaringClass();
-        
-        /*Check parent method*/
-        try {
-	        Method pMethod = clazz.getMethod(method.getName(), method.getParameterTypes());
-	        db = pMethod.getAnnotation(DB.class);
-	        if (db != null) {
-	            return db.txn();
-	        }
-        } catch (SecurityException e) {
-        } catch (NoSuchMethodException e) {
-        }
-        
-        /*Check class's annotation and ancestor's annotation*/
-        do {
-            db = clazz.getAnnotation(DB.class);
-            if (db != null) {
-                return db.txn();
-            }
-            clazz = clazz.getSuperclass();
-        } while (clazz != Object.class && clazz != null);
-        return false;
-    }
-}