001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)SequencingEngineContext.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.engine.sequencing;
030:
031: import java.util.logging.Logger;
032:
033: import javax.jbi.component.ComponentContext;
034: import javax.jbi.messaging.DeliveryChannel;
035:
036: import javax.transaction.TransactionManager;
037:
038: /**
039: * Context object to store sequencing engine specific informaiton.
040: *
041: * @author Sun Microsystems, Inc.
042: */
043: public final class SequencingEngineContext {
044: /**
045: * This object
046: */
047: private static SequencingEngineContext sSeqContext;
048:
049: /**
050: * Engine context
051: */
052: private ComponentContext mContext;
053:
054: /**
055: * Logger object for this component.
056: */
057: private Logger mLogger;
058:
059: /**
060: * Creates a new SequencingEngineContext object.
061: */
062: private SequencingEngineContext() {
063: }
064:
065: /**
066: * Gets the engine channel.
067: *
068: * @return engine channel
069: */
070: public DeliveryChannel getChannel() {
071: DeliveryChannel chnl = null;
072:
073: if (mContext != null) {
074: try {
075: chnl = mContext.getDeliveryChannel();
076: } catch (Exception e) {
077: e.printStackTrace();
078: }
079: }
080:
081: return chnl;
082: }
083:
084: /**
085: * Sets the engine context.
086: *
087: * @param ctx engine context.
088: */
089: public void setContext(ComponentContext ctx) {
090: mContext = ctx;
091: }
092:
093: /**
094: * Returns the jbi context.
095: *
096: * @return engine context
097: */
098: public ComponentContext getContext() {
099: return mContext;
100: }
101:
102: /**
103: * Used to grab a reference of this object.
104: *
105: * @return an initialized SequencingEngineContext reference
106: */
107: public static synchronized SequencingEngineContext getInstance() {
108: if (sSeqContext == null) {
109: sSeqContext = new SequencingEngineContext();
110: }
111:
112: return sSeqContext;
113: }
114:
115: /**
116: * Sets the Logger.
117: *
118: * @param logger logger for this component.
119: */
120: public void setLogger(Logger logger) {
121: mLogger = logger;
122: }
123:
124: /**
125: * Returns the logger.
126: *
127: * @return logger
128: */
129: public Logger getLogger() {
130: if (mLogger == null) {
131: mLogger = Logger.getLogger("com.sun.jbi.engine.sequencing");
132: }
133:
134: return mLogger;
135: }
136:
137: /**
138: * Returns the transaction manager
139: *
140: * @return Transaction manager
141: */
142: public TransactionManager getTransactionManager() {
143: return (javax.transaction.TransactionManager) mContext
144: .getTransactionManager();
145: }
146: }
|