Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
e42328fa
Commit
e42328fa
authored
Jul 14, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compiler warnings
parent
0f85b5ac
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
350 additions
and
243 deletions
+350
-243
pom.xml
pom.xml
+16
-0
pom.xml
spring-platform-netflix-core/pom.xml
+61
-61
ConfigurableEnvironmentConfiguration.java
...etflix/archaius/ConfigurableEnvironmentConfiguration.java
+15
-5
CircuitBreakerConfiguration.java
...m/netflix/circuitbreaker/CircuitBreakerConfiguration.java
+1
-1
ServletWrappingEndpoint.java
...rk/platform/netflix/endpoint/ServletWrappingEndpoint.java
+1
-1
EurekaRegistryAvailableEvent.java
...platform/netflix/eureka/EurekaRegistryAvailableEvent.java
+36
-0
EurekaServerAutoConfiguration.java
...latform/netflix/eureka/EurekaServerAutoConfiguration.java
+4
-0
EurekaServerStartedEvent.java
...ork/platform/netflix/eureka/EurekaServerStartedEvent.java
+36
-0
FeignBase.java
...org/springframework/platform/netflix/feign/FeignBase.java
+9
-7
SpringDecoder.java
...springframework/platform/netflix/feign/SpringDecoder.java
+74
-73
SpringEncoder.java
...springframework/platform/netflix/feign/SpringEncoder.java
+85
-77
SpringMvcContract.java
...ngframework/platform/netflix/feign/SpringMvcContract.java
+6
-6
application.yml
...-platform-netflix-core/src/test/resources/application.yml
+2
-0
pom.xml
spring-platform-netflix-hystrix/pom.xml
+4
-12
No files found.
pom.xml
View file @
e42328fa
...
@@ -35,6 +35,12 @@
...
@@ -35,6 +35,12 @@
<groupId>
com.netflix.archaius
</groupId>
<groupId>
com.netflix.archaius
</groupId>
<artifactId>
archaius-core
</artifactId>
<artifactId>
archaius-core
</artifactId>
<version>
${archaius.version}
</version>
<version>
${archaius.version}
</version>
<exclusions>
<exclusion>
<artifactId>
commons-logging
</artifactId>
<groupId>
commons-logging
</groupId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.netflix.eureka
</groupId>
<groupId>
com.netflix.eureka
</groupId>
...
@@ -45,6 +51,16 @@
...
@@ -45,6 +51,16 @@
<groupId>
com.netflix.eureka
</groupId>
<groupId>
com.netflix.eureka
</groupId>
<artifactId>
eureka-core
</artifactId>
<artifactId>
eureka-core
</artifactId>
<version>
${eureka.version}
</version>
<version>
${eureka.version}
</version>
<exclusions>
<exclusion>
<artifactId>
commons-logging
</artifactId>
<groupId>
commons-logging
</groupId>
</exclusion>
<exclusion>
<artifactId>
log4j
</artifactId>
<groupId>
log4j
</groupId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.netflix.feign
</groupId>
<groupId>
com.netflix.feign
</groupId>
...
...
spring-platform-netflix-core/pom.xml
View file @
e42328fa
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
spring-platform-netflix-core
</artifactId>
<artifactId>
spring-platform-netflix-core
</artifactId>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<name>
spring-platform-netflix-core
</name>
<name>
spring-platform-netflix-core
</name>
<description>
Spring Platform Netflix Core
</description>
<description>
Spring Platform Netflix Core
</description>
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<version>
1.0.0.BUILD-SNAPSHOT
</version>
<version>
1.0.0.BUILD-SNAPSHOT
</version>
<relativePath>
..
</relativePath>
<relativePath>
..
</relativePath>
</parent>
</parent>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
@@ -24,68 +24,68 @@
...
@@ -24,68 +24,68 @@
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.netflix.archaius
</groupId>
<groupId>
com.netflix.archaius
</groupId>
<artifactId>
archaius-core
</artifactId>
<artifactId>
archaius-core
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.netflix.eureka
</groupId>
<groupId>
com.netflix.eureka
</groupId>
<artifactId>
eureka-client
</artifactId>
<artifactId>
eureka-client
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.netflix.eureka
</groupId>
<groupId>
com.netflix.eureka
</groupId>
<artifactId>
eureka-core
</artifactId>
<artifactId>
eureka-core
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
net.java.dev.rome
</groupId>
<groupId>
net.java.dev.rome
</groupId>
<artifactId>
rome
</artifactId>
<artifactId>
rome
</artifactId>
<version>
1.0.0
</version>
<version>
1.0.0
</version>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.netflix.feign
</groupId>
<groupId>
com.netflix.feign
</groupId>
<artifactId>
feign-core
</artifactId>
<artifactId>
feign-core
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.netflix.feign
</groupId>
<groupId>
com.netflix.feign
</groupId>
<artifactId>
feign-ribbon
</artifactId>
<artifactId>
feign-ribbon
</artifactId>
</dependency>
</dependency>
<!--<dependency>
<!--<dependency> <groupId>com.netflix.feign</groupId> <artifactId>feign-slf4j</artifactId>
<groupId>com.netflix.feign</groupId>
</dependency> -->
<artifactId>feign-slf4j</artifactId>
<dependency>
</dependency>-->
<groupId>
com.netflix.hystrix
</groupId>
<dependency>
<artifactId>
hystrix-core
</artifactId>
<groupId>
com.netflix.hystrix
</groupId>
<optional>
true
</optional>
<artifactId>
hystrix-core
</artifactId>
</dependency>
<optional>
true
</optional>
<dependency>
</dependency>
<groupId>
com.netflix.hystrix
</groupId>
<dependency>
<artifactId>
hystrix-metrics-event-stream
</artifactId>
<groupId>
com.netflix.hystrix
</groupId>
<optional>
true
</optional>
<artifactId>
hystrix-metrics-event-stream
</artifactId>
</dependency>
<optional>
true
</optional>
<dependency>
</dependency>
<groupId>
com.netflix.hystrix
</groupId>
<dependency>
<artifactId>
hystrix-javanica
</artifactId>
<groupId>
com.netflix.hystrix
</groupId>
<optional>
true
</optional>
<artifactId>
hystrix-javanica
</artifactId>
</dependency>
<optional>
true
</optional>
<dependency>
</dependency>
<groupId>
com.netflix.ribbon
</groupId>
<dependency>
<artifactId>
ribbon-core
</artifactId>
<groupId>
com.netflix.ribbon
</groupId>
<optional>
true
</optional>
<artifactId>
ribbon-core
</artifactId>
</dependency>
<optional>
true
</optional>
<dependency>
</dependency>
<groupId>
com.netflix.ribbon
</groupId>
<dependency>
<artifactId>
ribbon-eureka
</artifactId>
<groupId>
com.netflix.ribbon
</groupId>
<optional>
true
</optional>
<artifactId>
ribbon-eureka
</artifactId>
</dependency>
<optional>
true
</optional>
</dependency>
<dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
<!-- Only needed at compile time -->
<scope>
provided
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
...
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/archaius/ConfigurableEnvironmentConfiguration.java
View file @
e42328fa
package
org
.
springframework
.
platform
.
netflix
.
archaius
;
package
org
.
springframework
.
platform
.
netflix
.
archaius
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.commons.configuration.AbstractConfiguration
;
import
org.apache.commons.configuration.AbstractConfiguration
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.CompositePropertySource
;
import
org.springframework.core.env.*
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.EnumerablePropertySource
;
import
org.springframework.core.env.MutablePropertySources
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.ReflectionUtils
;
import
java.lang.reflect.Field
;
import
java.util.*
;
/**
/**
* Created by sgibb on 6/27/14.
* Created by sgibb on 6/27/14.
*/
*/
...
...
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/circuitbreaker/CircuitBreakerConfiguration.java
View file @
e42328fa
...
@@ -50,7 +50,7 @@ public class CircuitBreakerConfiguration implements ImportAware {
...
@@ -50,7 +50,7 @@ public class CircuitBreakerConfiguration implements ImportAware {
throw
new
IllegalStateException
(
"Only one TransactionManagementConfigurer may exist"
);
throw
new
IllegalStateException
(
"Only one TransactionManagementConfigurer may exist"
);
}
}
//TODO: create CircuitBreakerConfigurer API
//TODO: create CircuitBreakerConfigurer API
CircuitBreakerConfigurer
configurer
=
configurers
.
iterator
().
next
();
//
CircuitBreakerConfigurer configurer = configurers.iterator().next();
//this.txManager = configurer.annotationDrivenTransactionManager();
//this.txManager = configurer.annotationDrivenTransactionManager();
}
}
}
}
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/endpoint/ServletWrappingEndpoint.java
View file @
e42328fa
...
@@ -70,7 +70,7 @@ public abstract class ServletWrappingEndpoint implements InitializingBean,
...
@@ -70,7 +70,7 @@ public abstract class ServletWrappingEndpoint implements InitializingBean,
}
}
@Override
@Override
public
Class
<?
extends
Endpoint
>
getEndpointType
()
{
public
Class
<?
extends
Endpoint
<?>
>
getEndpointType
()
{
return
null
;
return
null
;
}
}
}
}
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/eureka/EurekaRegistryAvailableEvent.java
0 → 100644
View file @
e42328fa
/*
* 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
.
netflix
.
eureka
;
import
org.springframework.context.ApplicationEvent
;
import
com.netflix.eureka.EurekaServerConfig
;
/**
* @author Dave Syer
*
*/
@SuppressWarnings
(
"serial"
)
public
class
EurekaRegistryAvailableEvent
extends
ApplicationEvent
{
/**
* @param eurekaServerConfig
*/
public
EurekaRegistryAvailableEvent
(
EurekaServerConfig
eurekaServerConfig
)
{
super
(
eurekaServerConfig
);
}
}
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/eureka/EurekaServerAutoConfiguration.java
View file @
e42328fa
...
@@ -31,6 +31,7 @@ import com.netflix.blitz4j.LoggingConfiguration;
...
@@ -31,6 +31,7 @@ import com.netflix.blitz4j.LoggingConfiguration;
import
com.netflix.eureka.EurekaBootStrap
;
import
com.netflix.eureka.EurekaBootStrap
;
import
com.netflix.eureka.EurekaServerConfig
;
import
com.netflix.eureka.EurekaServerConfig
;
import
com.netflix.eureka.EurekaServerConfigurationManager
;
import
com.netflix.eureka.EurekaServerConfigurationManager
;
import
com.netflix.eureka.PeerAwareInstanceRegistry
;
/**
/**
* @author Dave Syer
* @author Dave Syer
...
@@ -69,9 +70,12 @@ public class EurekaServerAutoConfiguration implements ServletContextAware,
...
@@ -69,9 +70,12 @@ public class EurekaServerAutoConfiguration implements ServletContextAware,
LoggingConfiguration
.
getInstance
().
configure
();
LoggingConfiguration
.
getInstance
().
configure
();
EurekaServerConfigurationManager
.
getInstance
()
EurekaServerConfigurationManager
.
getInstance
()
.
setConfiguration
(
eurekaServerConfig
);
.
setConfiguration
(
eurekaServerConfig
);
PeerAwareInstanceRegistry
.
getInstance
();
applicationContext
.
publishEvent
(
new
EurekaRegistryAvailableEvent
(
eurekaServerConfig
));
}
}
}.
contextInitialized
(
new
ServletContextEvent
(
servletContext
));
}.
contextInitialized
(
new
ServletContextEvent
(
servletContext
));
running
=
true
;
running
=
true
;
applicationContext
.
publishEvent
(
new
EurekaServerStartedEvent
(
eurekaServerConfig
));
}
}
}).
start
();
}).
start
();
}
}
...
...
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/eureka/EurekaServerStartedEvent.java
0 → 100644
View file @
e42328fa
/*
* 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
.
netflix
.
eureka
;
import
org.springframework.context.ApplicationEvent
;
import
com.netflix.eureka.EurekaServerConfig
;
/**
* @author Dave Syer
*
*/
@SuppressWarnings
(
"serial"
)
public
class
EurekaServerStartedEvent
extends
ApplicationEvent
{
/**
* @param eurekaServerConfig
*/
public
EurekaServerStartedEvent
(
EurekaServerConfig
eurekaServerConfig
)
{
super
(
eurekaServerConfig
);
}
}
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/feign/FeignBase.java
View file @
e42328fa
package
org
.
springframework
.
platform
.
netflix
.
feign
;
package
org
.
springframework
.
platform
.
netflix
.
feign
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
import
javax.xml.transform.Source
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.converter.ByteArrayHttpMessageConverter
;
import
org.springframework.http.converter.ByteArrayHttpMessageConverter
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.HttpMessageConverter
;
...
@@ -14,12 +21,6 @@ import org.springframework.http.converter.xml.SourceHttpMessageConverter;
...
@@ -14,12 +21,6 @@ import org.springframework.http.converter.xml.SourceHttpMessageConverter;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
import
javax.xml.transform.Source
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* Created by sgibb on 6/27/14.
* Created by sgibb on 6/27/14.
*/
*/
...
@@ -54,7 +55,8 @@ public class FeignBase {
...
@@ -54,7 +55,8 @@ public class FeignBase {
this
.
messageConverters
.
addAll
(
messageConverters
);
this
.
messageConverters
.
addAll
(
messageConverters
);
}
}
protected
void
addDefaultConverters
(
List
<
HttpMessageConverter
<?>>
messageConverters
)
{
@SuppressWarnings
(
"deprecation"
)
protected
void
addDefaultConverters
(
List
<
HttpMessageConverter
<?>>
messageConverters
)
{
messageConverters
.
add
(
new
ByteArrayHttpMessageConverter
());
messageConverters
.
add
(
new
ByteArrayHttpMessageConverter
());
messageConverters
.
add
(
new
StringHttpMessageConverter
());
messageConverters
.
add
(
new
StringHttpMessageConverter
());
messageConverters
.
add
(
new
ResourceHttpMessageConverter
());
messageConverters
.
add
(
new
ResourceHttpMessageConverter
());
...
...
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/feign/SpringDecoder.java
View file @
e42328fa
package
org
.
springframework
.
platform
.
netflix
.
feign
;
package
org
.
springframework
.
platform
.
netflix
.
feign
;
import
feign.FeignException
;
import
java.io.IOException
;
import
feign.Response
;
import
java.io.InputStream
;
import
feign.codec.DecodeException
;
import
java.lang.reflect.Type
;
import
feign.codec.Decoder
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.web.client.HttpMessageConverterExtractor
;
import
org.springframework.web.client.HttpMessageConverterExtractor
;
import
java.io.IO
Exception
;
import
feign.Feign
Exception
;
import
java.io.InputStream
;
import
feign.Response
;
import
java.lang.reflect.Type
;
import
feign.codec.DecodeException
;
import
java.util.List
;
import
feign.codec.Decoder
;
/**
/**
* Created by sgibb on 6/26/14.
* Created by sgibb on 6/26/14.
*/
*/
public
class
SpringDecoder
extends
FeignBase
implements
Decoder
{
public
class
SpringDecoder
extends
FeignBase
implements
Decoder
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SpringDecoder
.
class
);
public
SpringDecoder
()
{
public
SpringDecoder
()
{
}
}
public
SpringDecoder
(
List
<
HttpMessageConverter
<?>>
messageConverters
)
{
public
SpringDecoder
(
List
<
HttpMessageConverter
<?>>
messageConverters
)
{
super
(
messageConverters
);
super
(
messageConverters
);
}
}
@Override
@Override
public
Object
decode
(
final
Response
response
,
Type
type
)
throws
IOException
,
public
Object
decode
(
final
Response
response
,
Type
type
)
throws
IOException
,
DecodeException
,
FeignException
{
DecodeException
,
FeignException
{
if
(
type
instanceof
Class
)
{
if
(
type
instanceof
Class
)
{
HttpMessageConverterExtractor
<?>
extractor
=
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
new
HttpMessageConverterExtractor
((
Class
<?>)
type
,
getMessageConverters
());
HttpMessageConverterExtractor
<?>
extractor
=
new
HttpMessageConverterExtractor
(
(
Class
<?>)
type
,
getMessageConverters
());
Object
data
=
extractor
.
extractData
(
new
FeignResponseAdapter
(
response
));
return
data
;
Object
data
=
extractor
.
extractData
(
new
FeignResponseAdapter
(
response
));
}
return
data
;
throw
new
DecodeException
(
"type is not an instance of Class: "
+
type
);
}
}
throw
new
DecodeException
(
"type is not an instance of Class: "
+
type
);
}
private
class
FeignResponseAdapter
implements
ClientHttpResponse
{
private
final
Response
response
;
private
class
FeignResponseAdapter
implements
ClientHttpResponse
{
private
final
Response
response
;
private
FeignResponseAdapter
(
Response
response
)
{
this
.
response
=
response
;
private
FeignResponseAdapter
(
Response
response
)
{
}
this
.
response
=
response
;
}
@Override
public
HttpStatus
getStatusCode
()
throws
IOException
{
@Override
return
HttpStatus
.
valueOf
(
response
.
status
());
public
HttpStatus
getStatusCode
()
throws
IOException
{
}
return
HttpStatus
.
valueOf
(
response
.
status
());
}
@Override
public
int
getRawStatusCode
()
throws
IOException
{
@Override
return
response
.
status
();
public
int
getRawStatusCode
()
throws
IOException
{
}
return
response
.
status
();
}
@Override
public
String
getStatusText
()
throws
IOException
{
@Override
return
response
.
reason
();
public
String
getStatusText
()
throws
IOException
{
}
return
response
.
reason
();
}
@Override
public
void
close
()
{
@Override
try
{
public
void
close
()
{
response
.
body
().
close
();
try
{
}
catch
(
IOException
e
)
{
response
.
body
().
close
();
e
.
printStackTrace
();
}
}
catch
(
IOException
e
)
{
}
e
.
printStackTrace
();
}
@Override
}
public
InputStream
getBody
()
throws
IOException
{
return
response
.
body
().
asInputStream
();
@Override
}
public
InputStream
getBody
()
throws
IOException
{
return
response
.
body
().
asInputStream
();
@Override
}
public
HttpHeaders
getHeaders
()
{
return
getHttpHeaders
(
response
.
headers
());
@Override
}
public
HttpHeaders
getHeaders
()
{
return
getHttpHeaders
(
response
.
headers
());
}
}
}
}
}
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/feign/SpringEncoder.java
View file @
e42328fa
package
org
.
springframework
.
platform
.
netflix
.
feign
;
package
org
.
springframework
.
platform
.
netflix
.
feign
;
import
com.google.common.base.Charsets
;
import
com.google.common.base.Charsets
;
import
feign.RequestTemplate
;
import
feign.RequestTemplate
;
import
feign.codec.EncodeException
;
import
feign.codec.EncodeException
;
import
feign.codec.Encoder
;
import
feign.codec.Encoder
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
...
@@ -21,81 +23,87 @@ import java.util.List;
...
@@ -21,81 +23,87 @@ import java.util.List;
* Created by sgibb on 6/26/14.
* Created by sgibb on 6/26/14.
*/
*/
public
class
SpringEncoder
extends
FeignBase
implements
Encoder
{
public
class
SpringEncoder
extends
FeignBase
implements
Encoder
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SpringEncoder
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SpringEncoder
.
class
);
public
SpringEncoder
()
{
public
SpringEncoder
()
{
}
}
public
SpringEncoder
(
List
<
HttpMessageConverter
<?>>
messageConverters
)
{
public
SpringEncoder
(
List
<
HttpMessageConverter
<?>>
messageConverters
)
{
super
(
messageConverters
);
super
(
messageConverters
);
}
}
@Override
@Override
public
void
encode
(
Object
requestBody
,
RequestTemplate
request
)
throws
EncodeException
{
public
void
encode
(
Object
requestBody
,
RequestTemplate
request
)
//template.body(conversionService.convert(object, String.class));
throws
EncodeException
{
if
(
requestBody
!=
null
)
{
// template.body(conversionService.convert(object, String.class));
Class
<?>
requestType
=
requestBody
.
getClass
();
if
(
requestBody
!=
null
)
{
Collection
<
String
>
contentTypes
=
request
.
headers
().
get
(
"Content-Type"
);
Class
<?>
requestType
=
requestBody
.
getClass
();
Collection
<
String
>
contentTypes
=
request
.
headers
().
get
(
"Content-Type"
);
MediaType
requestContentType
=
null
;
if
(
contentTypes
!=
null
&&
!
contentTypes
.
isEmpty
())
{
MediaType
requestContentType
=
null
;
String
type
=
contentTypes
.
iterator
().
next
();
if
(
contentTypes
!=
null
&&
!
contentTypes
.
isEmpty
())
{
requestContentType
=
MediaType
.
valueOf
(
type
);
String
type
=
contentTypes
.
iterator
().
next
();
}
requestContentType
=
MediaType
.
valueOf
(
type
);
}
for
(
HttpMessageConverter
<?>
messageConverter
:
getMessageConverters
())
{
if
(
messageConverter
.
canWrite
(
requestType
,
requestContentType
))
{
for
(
HttpMessageConverter
<?>
messageConverter
:
getMessageConverters
())
{
if
(
logger
.
isDebugEnabled
())
{
if
(
messageConverter
.
canWrite
(
requestType
,
requestContentType
))
{
if
(
requestContentType
!=
null
)
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Writing ["
+
requestBody
+
"] as \""
+
requestContentType
+
if
(
requestContentType
!=
null
)
{
"\" using ["
+
messageConverter
+
"]"
);
logger
.
debug
(
"Writing ["
+
requestBody
+
"] as \""
}
+
requestContentType
+
"\" using ["
else
{
+
messageConverter
+
"]"
);
logger
.
debug
(
"Writing ["
+
requestBody
+
"] using ["
+
messageConverter
+
"]"
);
}
}
else
{
logger
.
debug
(
"Writing ["
+
requestBody
+
"] using ["
}
+
messageConverter
+
"]"
);
}
FeignOutputMessage
outputMessage
=
new
FeignOutputMessage
(
request
);
try
{
}
((
HttpMessageConverter
<
Object
>)
messageConverter
).
write
(
requestBody
,
requestContentType
,
outputMessage
);
FeignOutputMessage
outputMessage
=
new
FeignOutputMessage
(
request
);
}
catch
(
IOException
e
)
{
try
{
throw
new
EncodeException
(
"Error converting request body"
,
e
);
@SuppressWarnings
(
"unchecked"
)
}
HttpMessageConverter
<
Object
>
copy
=
(
HttpMessageConverter
<
Object
>)
messageConverter
;
request
.
body
(
outputMessage
.
getOutputStream
().
toByteArray
(),
Charsets
.
UTF_8
);
//TODO: set charset
copy
.
write
(
requestBody
,
requestContentType
,
outputMessage
);
return
;
}
}
catch
(
IOException
e
)
{
}
throw
new
EncodeException
(
"Error converting request body"
,
e
);
String
message
=
"Could not write request: no suitable HttpMessageConverter found for request type ["
+
}
requestType
.
getName
()
+
"]"
;
request
.
body
(
outputMessage
.
getOutputStream
().
toByteArray
(),
if
(
requestContentType
!=
null
)
{
Charsets
.
UTF_8
);
// TODO: set charset
message
+=
" and content type ["
+
requestContentType
+
"]"
;
return
;
}
}
throw
new
EncodeException
(
message
);
}
}
String
message
=
"Could not write request: no suitable HttpMessageConverter found for request type ["
}
+
requestType
.
getName
()
+
"]"
;
if
(
requestContentType
!=
null
)
{
private
class
FeignOutputMessage
implements
HttpOutputMessage
{
message
+=
" and content type ["
+
requestContentType
+
"]"
;
final
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
}
RequestTemplate
request
;
throw
new
EncodeException
(
message
);
}
private
FeignOutputMessage
(
RequestTemplate
request
)
{
}
this
.
request
=
request
;
}
private
class
FeignOutputMessage
implements
HttpOutputMessage
{
final
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
@Override
RequestTemplate
request
;
public
OutputStream
getBody
()
throws
IOException
{
return
outputStream
;
private
FeignOutputMessage
(
RequestTemplate
request
)
{
}
this
.
request
=
request
;
}
@Override
public
HttpHeaders
getHeaders
()
{
@Override
return
getHttpHeaders
(
request
.
headers
());
public
OutputStream
getBody
()
throws
IOException
{
}
return
outputStream
;
}
public
ByteArrayOutputStream
getOutputStream
()
{
return
outputStream
;
@Override
}
public
HttpHeaders
getHeaders
()
{
}
return
getHttpHeaders
(
request
.
headers
());
}
public
ByteArrayOutputStream
getOutputStream
()
{
return
outputStream
;
}
}
}
}
spring-platform-netflix-core/src/main/java/org/springframework/platform/netflix/feign/SpringMvcContract.java
View file @
e42328fa
package
org
.
springframework
.
platform
.
netflix
.
feign
;
package
org
.
springframework
.
platform
.
netflix
.
feign
;
import
feign.Contract
;
import
static
feign
.
Util
.
checkState
;
import
feign.MethodMetadata
;
import
static
feign
.
Util
.
emptyToNull
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
java.lang.annotation.Annotation
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
static
feign
.
Util
.
checkState
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
static
feign
.
Util
.
emptyToNull
;
import
feign.Contract
;
import
feign.MethodMetadata
;
/**
/**
* Created by sgibb on 6/27/14.
* Created by sgibb on 6/27/14.
...
@@ -20,7 +21,6 @@ public class SpringMvcContract extends Contract.BaseContract {
...
@@ -20,7 +21,6 @@ public class SpringMvcContract extends Contract.BaseContract {
@Override
@Override
protected
void
processAnnotationOnMethod
(
MethodMetadata
data
,
Annotation
methodAnnotation
,
Method
method
)
{
protected
void
processAnnotationOnMethod
(
MethodMetadata
data
,
Annotation
methodAnnotation
,
Method
method
)
{
Class
<?
extends
Annotation
>
annotationType
=
methodAnnotation
.
annotationType
();
RequestMapping
mapping
=
RequestMapping
.
class
.
cast
(
methodAnnotation
);
RequestMapping
mapping
=
RequestMapping
.
class
.
cast
(
methodAnnotation
);
if
(
mapping
!=
null
)
{
if
(
mapping
!=
null
)
{
//HTTP Method
//HTTP Method
...
...
spring-platform-netflix-core/src/test/resources/application.yml
View file @
e42328fa
...
@@ -4,6 +4,8 @@ spring:
...
@@ -4,6 +4,8 @@ spring:
application
:
application
:
name
:
client
name
:
client
eureka
:
eureka
:
server
:
enabled
:
false
client
:
client
:
serviceUrl
:
serviceUrl
:
defaultZone
:
http://localhost:8080/v2/
defaultZone
:
http://localhost:8080/v2/
...
...
spring-platform-netflix-hystrix/pom.xml
View file @
e42328fa
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.springframework.platform
</groupId>
<artifactId>
spring-platform-netflix-hystrix
</artifactId>
<artifactId>
spring-platform-netflix-hystrix
</artifactId>
<version>
1.0.0.BUILD-SNAPSHOT
</version>
<packaging>
war
</packaging>
<packaging>
war
</packaging>
<name>
Spring Platform Netflix Hystrix
</name>
<name>
Spring Platform Netflix Hystrix
</name>
<url>
http://projects.spring.io/spring-platform/
</url>
<url>
http://projects.spring.io/spring-platform/
</url>
...
@@ -17,15 +15,6 @@
...
@@ -17,15 +15,6 @@
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.1
</version>
<configuration>
<source>
1.7
</source>
<target>
1.7
</target>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugin>
...
@@ -55,7 +44,10 @@
...
@@ -55,7 +44,10 @@
<dependency>
<dependency>
<groupId>
org.springframework.platform
</groupId>
<groupId>
org.springframework.platform
</groupId>
<artifactId>
spring-platform-netflix-core
</artifactId>
<artifactId>
spring-platform-netflix-core
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.platform
</groupId>
<groupId>
org.springframework.platform
</groupId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment