Remove top-level org.springfamework.reactive package

reactive.codec -> core.codec
reactive.io    -> util

These may very well not be the final locations. For now they simply
express that there are classes that belong somewhere in core, i.e.
they are lower level dependencies than web.
This commit is contained in:
Rossen Stoyanchev 2015-11-22 15:02:18 -05:00
parent 911d376922
commit 4a3c0bc3b6
36 changed files with 112 additions and 129 deletions

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec;
package org.springframework.core.codec;
import org.springframework.core.NestedRuntimeException;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.decoder;
package org.springframework.core.codec;
import java.nio.ByteBuffer;
import java.util.List;
@ -22,7 +22,7 @@ import java.util.List;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.reactive.codec.encoder.Encoder;
import org.springframework.core.codec.Encoder;
import org.springframework.util.MimeType;
/**

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.encoder;
package org.springframework.core.codec;
import java.nio.ByteBuffer;
import java.util.List;
@ -22,7 +22,6 @@ import java.util.List;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.reactive.codec.decoder.Decoder;
import org.springframework.util.MimeType;
/**

View File

@ -14,13 +14,14 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.decoder;
package org.springframework.core.codec.support;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.Decoder;
import org.springframework.util.MimeType;
/**

View File

@ -14,13 +14,14 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.encoder;
package org.springframework.core.codec.support;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.Encoder;
import org.springframework.util.MimeType;
/**

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.decoder;
package org.springframework.core.codec.support;
import java.nio.ByteBuffer;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.encoder;
package org.springframework.core.codec.support;
import java.nio.ByteBuffer;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.decoder;
package org.springframework.core.codec.support;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -26,9 +26,9 @@ import org.reactivestreams.Publisher;
import reactor.Publishers;
import org.springframework.core.ResolvableType;
import org.springframework.reactive.codec.CodecException;
import org.springframework.reactive.codec.encoder.JacksonJsonEncoder;
import org.springframework.reactive.io.ByteBufferInputStream;
import org.springframework.core.codec.CodecException;
import org.springframework.core.codec.Decoder;
import org.springframework.util.ByteBufferInputStream;
import org.springframework.util.MimeType;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.encoder;
package org.springframework.core.codec.support;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -26,9 +26,9 @@ import reactor.Publishers;
import reactor.io.buffer.Buffer;
import org.springframework.core.ResolvableType;
import org.springframework.reactive.codec.CodecException;
import org.springframework.reactive.codec.decoder.JacksonJsonDecoder;
import org.springframework.reactive.io.BufferOutputStream;
import org.springframework.core.codec.CodecException;
import org.springframework.core.codec.Encoder;
import org.springframework.util.BufferOutputStream;
import org.springframework.util.MimeType;
/**

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.decoder;
package org.springframework.core.codec.support;
import java.nio.ByteBuffer;
import java.util.concurrent.ConcurrentHashMap;
@ -37,12 +37,11 @@ import org.xml.sax.helpers.XMLReaderFactory;
import reactor.Publishers;
import org.springframework.core.ResolvableType;
import org.springframework.http.MediaType;
import org.springframework.reactive.codec.CodecException;
import org.springframework.reactive.codec.encoder.Jaxb2Encoder;
import org.springframework.reactive.io.ByteBufferPublisherInputStream;
import org.springframework.core.codec.CodecException;
import org.springframework.util.ByteBufferPublisherInputStream;
import org.springframework.util.Assert;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
/**
* Decode from a bytes stream of XML elements to a stream of {@code Object} (POJO).
@ -56,7 +55,7 @@ public class Jaxb2Decoder extends AbstractDecoder<Object> {
public Jaxb2Decoder() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML);
super(MimeTypeUtils.APPLICATION_XML, MimeTypeUtils.TEXT_XML);
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.encoder;
package org.springframework.core.codec.support;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@ -30,13 +30,12 @@ import reactor.Publishers;
import reactor.io.buffer.Buffer;
import org.springframework.core.ResolvableType;
import org.springframework.http.MediaType;
import org.springframework.reactive.codec.CodecException;
import org.springframework.reactive.codec.decoder.Jaxb2Decoder;
import org.springframework.reactive.io.BufferOutputStream;
import org.springframework.core.codec.CodecException;
import org.springframework.util.BufferOutputStream;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
/**
* Encode from an {@code Object} stream to a byte stream of XML elements.
@ -50,7 +49,7 @@ public class Jaxb2Encoder extends AbstractEncoder<Object> {
public Jaxb2Encoder() {
super(MediaType.APPLICATION_XML, MediaType.TEXT_XML);
super(MimeTypeUtils.APPLICATION_XML, MimeTypeUtils.TEXT_XML);
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.decoder;
package org.springframework.core.codec.support;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@ -29,7 +29,6 @@ import reactor.Publishers;
import reactor.fn.Function;
import org.springframework.core.ResolvableType;
import org.springframework.reactive.codec.encoder.JsonObjectEncoder;
import org.springframework.util.MimeType;
/**

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.encoder;
package org.springframework.core.codec.support;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@ -28,7 +28,6 @@ import reactor.core.support.BackpressureUtils;
import reactor.io.buffer.Buffer;
import org.springframework.core.ResolvableType;
import org.springframework.reactive.codec.decoder.JsonObjectDecoder;
import org.springframework.util.MimeType;
import static reactor.Publishers.lift;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.decoder;
package org.springframework.core.codec.support;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
@ -25,7 +25,6 @@ import reactor.Publishers;
import reactor.io.buffer.Buffer;
import org.springframework.core.ResolvableType;
import org.springframework.reactive.codec.encoder.StringEncoder;
import org.springframework.util.MimeType;
/**

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.codec.encoder;
package org.springframework.core.codec.support;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
@ -24,7 +24,6 @@ import org.reactivestreams.Publisher;
import reactor.Publishers;
import org.springframework.core.ResolvableType;
import org.springframework.reactive.codec.decoder.StringDecoder;
import org.springframework.util.MimeType;
/**

View File

@ -19,6 +19,7 @@ package org.springframework.http.server.servlet31;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
@ -28,7 +29,7 @@ import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.springframework.reactive.util.DemandCounter;
import org.springframework.util.Assert;
/**
* @author Arjen Poutsma
@ -165,4 +166,53 @@ public class RequestBodyPublisher implements ReadListener, Publisher<ByteBuffer>
demand.reset();
}
}
/**
* Small utility class for keeping track of Reactive Streams demand.
*/
private static final class DemandCounter {
private final AtomicLong demand = new AtomicLong();
/**
* Increases the demand by the given number
* @param n the positive number to increase demand by
* @return the increased demand
* @see org.reactivestreams.Subscription#request(long)
*/
public long increase(long n) {
Assert.isTrue(n > 0, "'n' must be higher than 0");
return demand.updateAndGet(d -> d != Long.MAX_VALUE ? d + n : Long.MAX_VALUE);
}
/**
* Decreases the demand by one.
* @return the decremented demand
*/
public long decrement() {
return demand.updateAndGet(d -> d != Long.MAX_VALUE ? d - 1 : Long.MAX_VALUE);
}
/**
* Indicates whether this counter has demand, i.e. whether it is higher than 0.
* @return {@code true} if this counter has demand; {@code false} otherwise
*/
public boolean hasDemand() {
return this.demand.get() > 0;
}
/**
* Resets this counter to 0.
* @see org.reactivestreams.Subscription#cancel()
*/
public void reset() {
this.demand.set(0);
}
@Override
public String toString() {
return demand.toString();
}
}
}

View File

@ -1,70 +0,0 @@
/*
* Copyright 2002-2015 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.reactive.util;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.util.Assert;
/**
* Small utility class for keeping track of Reactive Streams demand.
* @author Arjen Poutsma
*/
public final class DemandCounter {
private final AtomicLong demand = new AtomicLong();
/**
* Increases the demand by the given number
* @param n the positive number to increase demand by
* @return the increased demand
* @see org.reactivestreams.Subscription#request(long)
*/
public long increase(long n) {
Assert.isTrue(n > 0, "'n' must be higher than 0");
return demand.updateAndGet(d -> d != Long.MAX_VALUE ? d + n : Long.MAX_VALUE);
}
/**
* Decreases the demand by one.
* @return the decremented demand
*/
public long decrement() {
return demand.updateAndGet(d -> d != Long.MAX_VALUE ? d - 1 : Long.MAX_VALUE);
}
/**
* Indicates whether this counter has demand, i.e. whether it is higher than 0.
* @return {@code true} if this counter has demand; {@code false} otherwise
*/
public boolean hasDemand() {
return this.demand.get() > 0;
}
/**
* Resets this counter to 0.
* @see org.reactivestreams.Subscription#cancel()
*/
public void reset() {
this.demand.set(0);
}
@Override
public String toString() {
return demand.toString();
}
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.io;
package org.springframework.util;
import java.io.IOException;
import java.io.OutputStream;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.io;
package org.springframework.util;
import java.io.IOException;
import java.io.InputStream;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.reactive.io;
package org.springframework.util;
import java.io.IOException;
import java.io.InputStream;
@ -25,8 +25,6 @@ import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;
import reactor.Publishers;
import org.springframework.util.Assert;
/**
* {@code InputStream} implementation based on a byte array {@link Publisher}.
*

View File

@ -27,7 +27,7 @@ import org.springframework.core.ResolvableType;
import org.springframework.core.convert.ConversionService;
import org.springframework.http.MediaType;
import org.springframework.http.server.ReactiveServerHttpRequest;
import org.springframework.reactive.codec.decoder.Decoder;
import org.springframework.core.codec.Decoder;
import org.springframework.web.reactive.method.HandlerMethodArgumentResolver;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestBody;

View File

@ -28,11 +28,11 @@ import org.springframework.core.ResolvableType;
import org.springframework.core.convert.ConversionService;
import org.springframework.http.server.ReactiveServerHttpRequest;
import org.springframework.http.server.ReactiveServerHttpResponse;
import org.springframework.reactive.codec.decoder.ByteBufferDecoder;
import org.springframework.reactive.codec.decoder.Decoder;
import org.springframework.reactive.codec.decoder.JacksonJsonDecoder;
import org.springframework.reactive.codec.decoder.JsonObjectDecoder;
import org.springframework.reactive.codec.decoder.StringDecoder;
import org.springframework.core.codec.support.ByteBufferDecoder;
import org.springframework.core.codec.Decoder;
import org.springframework.core.codec.support.JacksonJsonDecoder;
import org.springframework.core.codec.support.JsonObjectDecoder;
import org.springframework.core.codec.support.StringDecoder;
import org.springframework.web.reactive.HandlerAdapter;
import org.springframework.web.reactive.HandlerResult;
import org.springframework.web.reactive.method.HandlerMethodArgumentResolver;

View File

@ -37,7 +37,7 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.http.MediaType;
import org.springframework.http.server.ReactiveServerHttpRequest;
import org.springframework.http.server.ReactiveServerHttpResponse;
import org.springframework.reactive.codec.encoder.Encoder;
import org.springframework.core.codec.Encoder;
import org.springframework.util.Assert;
import org.springframework.util.MimeType;
import org.springframework.web.HttpMediaTypeNotAcceptableException;

View File

@ -27,8 +27,8 @@ import reactor.io.buffer.Buffer;
import reactor.rx.Streams;
import org.springframework.http.MediaType;
import org.springframework.reactive.io.BufferOutputStream;
import org.springframework.reactive.io.ByteBufferPublisherInputStream;
import org.springframework.util.BufferOutputStream;
import org.springframework.util.ByteBufferPublisherInputStream;
import static org.junit.Assert.fail;

View File

@ -27,6 +27,7 @@ import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.support.ByteBufferDecoder;
import org.springframework.http.MediaType;
/**

View File

@ -28,6 +28,7 @@ import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.support.JacksonJsonDecoder;
import org.springframework.http.MediaType;
import org.springframework.reactive.codec.Pojo;

View File

@ -28,6 +28,7 @@ import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.support.Jaxb2Decoder;
import org.springframework.http.MediaType;
import org.springframework.reactive.codec.Pojo;

View File

@ -26,6 +26,8 @@ import reactor.io.buffer.Buffer;
import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.codec.support.JsonObjectDecoder;
/**
* @author Sebastien Deleuze
*/

View File

@ -29,6 +29,7 @@ import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.support.StringDecoder;
import org.springframework.http.MediaType;
/**

View File

@ -27,6 +27,7 @@ import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.support.ByteBufferEncoder;
import org.springframework.http.MediaType;
/**

View File

@ -26,6 +26,7 @@ import org.junit.Test;
import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.codec.support.JacksonJsonEncoder;
import org.springframework.http.MediaType;
import org.springframework.reactive.codec.Pojo;

View File

@ -26,6 +26,7 @@ import org.junit.Test;
import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.codec.support.Jaxb2Encoder;
import org.springframework.http.MediaType;
import org.springframework.reactive.codec.Pojo;

View File

@ -26,6 +26,8 @@ import reactor.io.buffer.Buffer;
import reactor.rx.Stream;
import reactor.rx.Streams;
import org.springframework.core.codec.support.JsonObjectEncoder;
/**
* @author Sebastien Deleuze
*/

View File

@ -23,10 +23,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.reactivestreams.Publisher;
import reactor.rx.Streams;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.support.StringEncoder;
import org.springframework.http.MediaType;
/**

View File

@ -47,10 +47,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.reactive.codec.encoder.ByteBufferEncoder;
import org.springframework.reactive.codec.encoder.JacksonJsonEncoder;
import org.springframework.reactive.codec.encoder.JsonObjectEncoder;
import org.springframework.reactive.codec.encoder.StringEncoder;
import org.springframework.core.codec.support.ByteBufferEncoder;
import org.springframework.core.codec.support.JacksonJsonEncoder;
import org.springframework.core.codec.support.JsonObjectEncoder;
import org.springframework.core.codec.support.StringEncoder;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.reactive.handler.SimpleHandlerResultHandler;
import org.springframework.http.server.AbstractHttpHandlerIntegrationTests;

View File

@ -23,11 +23,10 @@ import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.reactive.codec.encoder.StringEncoder;
import org.springframework.core.codec.support.StringEncoder;
import org.springframework.web.reactive.HandlerResult;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.reactive.method.annotation.ResponseBodyResultHandler;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;