forked from apache/camel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#342 from jboss-fuse/ENTESB-7948
ENTESB-7948
- Loading branch information
Showing
9 changed files
with
331 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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 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
48 changes: 48 additions & 0 deletions
48
...main/java/org/apache/camel/component/netty4/DefaultNettyCamelStateCorrelationManager.java
This file contains 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,48 @@ | ||
/** | ||
* 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.camel.component.netty4; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import io.netty.channel.Channel; | ||
import io.netty.channel.ChannelHandlerContext; | ||
|
||
public class DefaultNettyCamelStateCorrelationManager implements NettyCamelStateCorrelationManager { | ||
|
||
private final Map<Channel, NettyCamelState> cache = new ConcurrentHashMap<Channel, NettyCamelState>(); | ||
|
||
@Override | ||
public void putState(Channel channel, NettyCamelState state) { | ||
cache.put(channel, state); | ||
} | ||
|
||
@Override | ||
public void removeState(ChannelHandlerContext ctx, Channel channel) { | ||
cache.remove(channel); | ||
} | ||
|
||
@Override | ||
public NettyCamelState getState(ChannelHandlerContext ctx, Channel channel, Object msg) { | ||
return cache.get(channel); | ||
} | ||
|
||
@Override | ||
public NettyCamelState getState(ChannelHandlerContext ctx, Channel channel, Throwable cause) { | ||
return cache.get(channel); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...y4/src/main/java/org/apache/camel/component/netty4/NettyCamelStateCorrelationManager.java
This file contains 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,65 @@ | ||
/** | ||
* 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.camel.component.netty4; | ||
|
||
import io.netty.channel.Channel; | ||
import io.netty.channel.ChannelHandlerContext; | ||
|
||
/** | ||
* To manage and correlate state of {@link NettyCamelState} when doing request/reply via {@link NettyProducer}. | ||
* <p/> | ||
* This SPI allows custom implementations to correlate the request and replies. | ||
*/ | ||
public interface NettyCamelStateCorrelationManager { | ||
|
||
/** | ||
* Puts the state. | ||
* <p/> | ||
* You can get access to the Camel message from the {@link NettyCamelState} instance. | ||
* | ||
* @param channel the channel | ||
* @param state the Camel state to be stored | ||
*/ | ||
void putState(Channel channel, NettyCamelState state); | ||
|
||
/** | ||
* Removes the state when the channel is inactive. | ||
* | ||
* @param ctx netty channel handler context | ||
* @param channel the channel | ||
*/ | ||
void removeState(ChannelHandlerContext ctx, Channel channel); | ||
|
||
/** | ||
* Gets the state when a response message has been received. | ||
* | ||
* @param ctx netty channel handler context | ||
* @param channel the channel | ||
* @param msg the response message | ||
*/ | ||
NettyCamelState getState(ChannelHandlerContext ctx, Channel channel, Object msg); | ||
|
||
/** | ||
* Gets the state when some error occurred. | ||
* | ||
* @param ctx netty channel handler context | ||
* @param channel the channel | ||
* @param cause the error | ||
*/ | ||
NettyCamelState getState(ChannelHandlerContext ctx, Channel channel, Throwable cause); | ||
|
||
} |
This file contains 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 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 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.