forked from spring-projects/spring-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Micha Kiener
committed
Jan 5, 2010
1 parent
444c475
commit 004a388
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...xt/src/main/java/org/springframework/conversation/scope/AbstractConversationResolver.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,32 @@ | ||
/* | ||
* Copyright 2002-2008 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.conversation.scope; | ||
|
||
/** | ||
* The abstract implementation for a {@link ConversationResolver}. | ||
* | ||
* @author Micha Kiener | ||
* @since 3.1 | ||
*/ | ||
public abstract class AbstractConversationResolver implements ConversationResolver { | ||
|
||
/** | ||
* @see org.springframework.conversation.scope.ConversationResolver#hasCurrentConversationId() | ||
*/ | ||
public boolean hasCurrentConversationId() { | ||
return (getCurrentConversationId() != null); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.../main/java/org/springframework/conversation/scope/ThreadAttachedConversationResolver.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,43 @@ | ||
/* | ||
* Copyright 2002-2008 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.conversation.scope; | ||
|
||
/** | ||
* An implementation of the {@link ConversationResolver} where the currently | ||
* used conversation id is bound to the current thread. This implementation | ||
* should only be used in a batch environment, never in a web environment. | ||
* | ||
* @author Micha Kiener | ||
* @since 3.1 | ||
*/ | ||
public class ThreadAttachedConversationResolver extends AbstractConversationResolver { | ||
/** The thread local attribute where the current conversation id is stored. */ | ||
private static final ThreadLocal<String> CURRENT_CONVERSATION_ID = new ThreadLocal<String>(); | ||
|
||
/** | ||
* @see org.springframework.conversation.scope.ConversationResolver#getCurrentConversationId() | ||
*/ | ||
public String getCurrentConversationId() { | ||
return CURRENT_CONVERSATION_ID.get(); | ||
} | ||
|
||
/** | ||
* @see org.springframework.conversation.scope.ConversationResolver#setCurrentConversationId(java.lang.String) | ||
*/ | ||
public void setCurrentConversationId(String conversationId) { | ||
CURRENT_CONVERSATION_ID.set(conversationId); | ||
} | ||
} |