Additional removals of deprecated classes from core

This commit is contained in:
Oleg Zhurakousky
2021-11-08 17:20:49 +01:00
parent 3eea7082f6
commit 0e2334b154
4 changed files with 0 additions and 219 deletions

View File

@@ -1,27 +0,0 @@
/*
* Copyright 2012-2019 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
*
* https://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.cloud.function.core;
/**
* @author Dave Syer
*
*/
public interface Isolated {
ClassLoader getClassLoader();
}

View File

@@ -1,55 +0,0 @@
/*
* Copyright 2012-2019 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
*
* https://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.cloud.function.core;
import java.util.function.Consumer;
import org.springframework.util.ClassUtils;
/**
* @param <T> type to consume
* @author Dave Syer
*/
public class IsolatedConsumer<T> implements Consumer<T>, Isolated {
private final Consumer<T> consumer;
private final ClassLoader classLoader;
public IsolatedConsumer(Consumer<T> consumer) {
this.consumer = consumer;
this.classLoader = consumer.getClass().getClassLoader();
}
@Override
public ClassLoader getClassLoader() {
return this.classLoader;
}
@Override
public void accept(T item) {
ClassLoader context = ClassUtils
.overrideThreadContextClassLoader(this.classLoader);
try {
this.consumer.accept(item);
}
finally {
ClassUtils.overrideThreadContextClassLoader(context);
}
}
}

View File

@@ -1,56 +0,0 @@
/*
* Copyright 2012-2019 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
*
* https://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.cloud.function.core;
import java.util.function.Function;
import org.springframework.util.ClassUtils;
/**
* @param <S> input type
* @param <T> output type
* @author Dave Syer
*/
public class IsolatedFunction<S, T> implements Function<S, T>, Isolated {
private final Function<S, T> function;
private final ClassLoader classLoader;
public IsolatedFunction(Function<S, T> function) {
this.function = function;
this.classLoader = function.getClass().getClassLoader();
}
@Override
public ClassLoader getClassLoader() {
return this.classLoader;
}
@Override
public T apply(S item) {
ClassLoader context = ClassUtils
.overrideThreadContextClassLoader(this.classLoader);
try {
return this.function.apply(item);
}
finally {
ClassUtils.overrideThreadContextClassLoader(context);
}
}
}