-
Notifications
You must be signed in to change notification settings - Fork 691
GEODE-6557: Moving geode-web classes to geode-web #3351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
upthewaterspout
merged 3 commits into
apache:develop
from
upthewaterspout:feature/move-admin-web-GEODE-6557
Mar 27, 2019
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
99 changes: 99 additions & 0 deletions
99
.../management/internal/web/http/converter/ServerSerializableObjectHttpMessageConverter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * 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.geode.management.internal.web.http.converter; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.Serializable; | ||
|
|
||
| import org.springframework.http.HttpInputMessage; | ||
| import org.springframework.http.HttpMessage; | ||
| import org.springframework.http.HttpOutputMessage; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.converter.AbstractHttpMessageConverter; | ||
| import org.springframework.http.converter.HttpMessageConverter; | ||
| import org.springframework.http.converter.HttpMessageNotReadableException; | ||
| import org.springframework.http.converter.HttpMessageNotWritableException; | ||
| import org.springframework.util.StreamUtils; | ||
|
|
||
| import org.apache.geode.internal.util.IOUtils; | ||
|
|
||
| /** | ||
| * The ServerSerializableObjectHttpMessageConverter class is a Spring HttpMessageConverter for | ||
| * converting | ||
| * bytes streams to/from Serializable Objects. | ||
| * | ||
| * This class is the same as {@link ServerSerializableObjectHttpMessageConverter}. However, to | ||
| * avoid classloader issues due to the fact that geode-web.war needs to use this converter | ||
| * as well as geode-core (because the converter is used by gfsh), this class is duplicated in | ||
| * geode-web. This ensures that the version used by the war will implement | ||
| * {@link HttpMessageConverter} | ||
| * from the geode-web war's classloader rather than geode-core's classloader and interoperate | ||
| * with other classes loaded in the geode-web war's classloader. | ||
| * <p/> | ||
| * | ||
| * @see Serializable | ||
| * @see HttpInputMessage | ||
| * @see HttpMessage | ||
| * @see HttpOutputMessage | ||
| * @see MediaType | ||
| * @see AbstractHttpMessageConverter | ||
| * @since GemFire 8.0 | ||
| */ | ||
| @SuppressWarnings("unused") | ||
| public class ServerSerializableObjectHttpMessageConverter | ||
| extends AbstractHttpMessageConverter<Serializable> { | ||
|
|
||
| public ServerSerializableObjectHttpMessageConverter() { | ||
| super(MediaType.APPLICATION_OCTET_STREAM, MediaType.ALL); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean supports(final Class<?> type) { | ||
| if (logger.isTraceEnabled()) { | ||
| logger.trace(String.format("%1$s.supports(%2$s)", getClass().getName(), type.getName()), | ||
| new Throwable()); | ||
| } | ||
|
|
||
| return (type != null && Serializable.class.isAssignableFrom(type)); | ||
| } | ||
|
|
||
| @Override | ||
| protected Serializable readInternal(final Class<? extends Serializable> type, | ||
| final HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { | ||
| try { | ||
| ClassLoader classLoader = type.getClassLoader(); | ||
| return type.cast(IOUtils.deserializeObject(IOUtils.toByteArray(inputMessage.getBody()), | ||
| classLoader != null ? classLoader : getClass().getClassLoader())); | ||
| } catch (ClassNotFoundException e) { | ||
| throw new HttpMessageNotReadableException( | ||
| String.format("Unable to convert the HTTP message body into an Object of type (%1$s)", | ||
| type.getName()), | ||
| e); | ||
| } | ||
| } | ||
|
|
||
| protected void setContentLength(final HttpMessage message, final byte[] messageBody) { | ||
| message.getHeaders().setContentLength(messageBody.length); | ||
| } | ||
|
|
||
| @Override | ||
| protected void writeInternal(final Serializable serializableObject, | ||
| final HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { | ||
| final byte[] messageBody = IOUtils.serializeObject(serializableObject); | ||
| setContentLength(outputMessage, messageBody); | ||
| StreamUtils.copy(messageBody, outputMessage.getBody()); | ||
| } | ||
|
|
||
| } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.