Skip to content

Commit

Permalink
SPR-6422, conversation resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
Micha Kiener committed Jan 5, 2010
1 parent 444c475 commit 004a388
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
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);
}
}
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);
}
}

0 comments on commit 004a388

Please sign in to comment.