1 /*
2 * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3 * the spring framework, http://el4j.sf.net
4 * Copyright (C) 2010 by ELCA Informatique SA, Av. de la Harpe 22-24,
5 * 1000 Lausanne, Switzerland, http://www.elca.ch
6 *
7 * EL4J is published under the GNU Lesser General Public License (LGPL)
8 * Version 2.1. See http://www.gnu.org/licenses/
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * For alternative licensing, please contact info@elca.ch
16 */
17 package ch.elca.el4j.core.correlationId;
18
19 import ch.elca.el4j.core.contextpassing.AbstractImplicitContextPasser;
20 import ch.elca.el4j.services.monitoring.notification.CoreNotificationHelper;
21
22 /**
23 *
24 * Context Passer for CorrelationId variable.
25 *
26 * @svnLink $Revision: 4253 $;$Date: 2010-12-21 11:08:04 +0100 (Di, 21. Dez 2010) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/core/src/main/java/ch/elca/el4j/core/correlationId/CorrelationIdImplicitContextPasser.java $
27 *
28 * @author Simon Stelling (SST)
29 */
30 public class CorrelationIdImplicitContextPasser extends AbstractImplicitContextPasser {
31
32 /**
33 * The correlation id manager through which correlation ids are retrieved and set.
34 */
35 private CorrelationIdManager correlationIdManager;
36
37 /**
38 * @return Returns the correlationIdManager.
39 */
40 public CorrelationIdManager getCorrelationIdManager() {
41 return correlationIdManager;
42 }
43
44 /**
45 * @param correlationIdManager Is the correlationIdManager to set.
46 */
47 public void setCorrelationIdManager(CorrelationIdManager correlationIdManager) {
48 this.correlationIdManager = correlationIdManager;
49 }
50
51 /** {@inheritDoc} */
52 @Override
53 public String getImplicitlyPassedContext() {
54 return correlationIdManager.getCurrentCorrelationId();
55 }
56
57 /** {@inheritDoc} */
58 @Override
59 public void pushImplicitlyPassedContext(Object context) {
60 correlationIdManager.setCurrentCorrelationId((String) context);
61 }
62
63 /**
64 * checks correct setup.
65 */
66 @Override
67 public void afterPropertiesSet() throws Exception {
68 super.afterPropertiesSet();
69 if (correlationIdManager == null) {
70 CoreNotificationHelper.notifyLackingEssentialProperty(
71 "correlationIdManager", this);
72 }
73 }
74
75 }