From b1a5962cc3b22854f5dbcc4885e581008a2d34c6 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 7 Aug 2014 11:31:56 -0700 Subject: [PATCH] Move piggy back stuff to netflix jar --- .../broker/CatalogLeaseManager.java | 1 + .../cloudfoundry/broker/LeaseManagerLite.java | 28 -------- .../broker/PiggybackMethodInterceptor.java | 64 ------------------- .../ServiceBrokerAutoConfiguration.java | 2 + 4 files changed, 3 insertions(+), 92 deletions(-) delete mode 100644 src/main/java/org/springframework/platform/cloudfoundry/broker/LeaseManagerLite.java delete mode 100644 src/main/java/org/springframework/platform/cloudfoundry/broker/PiggybackMethodInterceptor.java diff --git a/src/main/java/org/springframework/platform/cloudfoundry/broker/CatalogLeaseManager.java b/src/main/java/org/springframework/platform/cloudfoundry/broker/CatalogLeaseManager.java index f9647ed..7cc9056 100644 --- a/src/main/java/org/springframework/platform/cloudfoundry/broker/CatalogLeaseManager.java +++ b/src/main/java/org/springframework/platform/cloudfoundry/broker/CatalogLeaseManager.java @@ -25,6 +25,7 @@ import org.cloudfoundry.community.servicebroker.model.Catalog; import org.cloudfoundry.community.servicebroker.model.ServiceDefinition; import org.cloudfoundry.community.servicebroker.service.BeanCatalogService; import org.cloudfoundry.community.servicebroker.service.CatalogService; +import org.springframework.platform.netflix.eureka.advice.LeaseManagerLite; import com.netflix.appinfo.InstanceInfo; import com.netflix.appinfo.InstanceInfo.ActionType; diff --git a/src/main/java/org/springframework/platform/cloudfoundry/broker/LeaseManagerLite.java b/src/main/java/org/springframework/platform/cloudfoundry/broker/LeaseManagerLite.java deleted file mode 100644 index bff18f2..0000000 --- a/src/main/java/org/springframework/platform/cloudfoundry/broker/LeaseManagerLite.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013-2014 the original author or authors. - * - * Licensed 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.springframework.platform.cloudfoundry.broker; - -import com.netflix.appinfo.InstanceInfo; - -/** - * @author Dave Syer - * - */ -public interface LeaseManagerLite { - - void register(final InstanceInfo info, final boolean isReplication); - -} diff --git a/src/main/java/org/springframework/platform/cloudfoundry/broker/PiggybackMethodInterceptor.java b/src/main/java/org/springframework/platform/cloudfoundry/broker/PiggybackMethodInterceptor.java deleted file mode 100644 index 2171e0c..0000000 --- a/src/main/java/org/springframework/platform/cloudfoundry/broker/PiggybackMethodInterceptor.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2013-2014 the original author or authors. - * - * Licensed 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.springframework.platform.cloudfoundry.broker; - -import java.lang.reflect.Method; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.springframework.util.ReflectionUtils; - -/** - * @author Dave Syer - * - */ -public class PiggybackMethodInterceptor implements MethodInterceptor { - - private Object delegate; - private Class[] types; - - public PiggybackMethodInterceptor(Object delegate, Class... types) { - this.delegate = delegate; - this.types = types; - } - - @Override - public Object invoke(MethodInvocation invocation) throws Throwable { - Object result = invocation.proceed(); - invokeAfter(invocation.getMethod(), invocation.getArguments()); - return result; - } - - private void invokeAfter(Method method, Object[] arguments) throws Exception { - for (Class type : types) { - Method target = getTarget(type, method); - if (target != null) { - target.invoke(delegate, arguments); - return; - } - } - } - - private Method getTarget(Class type, Method method) { - Method target = ReflectionUtils.findMethod(type, method.getName(), - method.getParameterTypes()); - if (target != null) { - return target; - } - return null; - } - -} diff --git a/src/main/java/org/springframework/platform/cloudfoundry/broker/ServiceBrokerAutoConfiguration.java b/src/main/java/org/springframework/platform/cloudfoundry/broker/ServiceBrokerAutoConfiguration.java index 9d475b7..ab4c629 100644 --- a/src/main/java/org/springframework/platform/cloudfoundry/broker/ServiceBrokerAutoConfiguration.java +++ b/src/main/java/org/springframework/platform/cloudfoundry/broker/ServiceBrokerAutoConfiguration.java @@ -42,6 +42,8 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.platform.netflix.eureka.EurekaRegistryAvailableEvent; +import org.springframework.platform.netflix.eureka.advice.LeaseManagerLite; +import org.springframework.platform.netflix.eureka.advice.PiggybackMethodInterceptor; import org.springframework.stereotype.Component; import org.springframework.util.ReflectionUtils;