001: // Copyright (c) 2004-2005 Sun Microsystems Inc., All Rights Reserved.
002:
003: /*
004: * SequencingEngineContext.java
005: *
006: * SUN PROPRIETARY/CONFIDENTIAL
007: * This software is the proprietary information of Sun Microsystems, Inc.
008: * Use is subject to license term
009: */
010: package com.sun.jbi.engine.sequencing;
011:
012: import java.util.logging.Logger;
013:
014: import javax.jbi.component.ComponentContext;
015: import javax.jbi.messaging.DeliveryChannel;
016:
017: import javax.transaction.TransactionManager;
018:
019: /**
020: * Context object to store sequencing engine specific informaiton.
021: *
022: * @author Sun Microsystems, Inc.
023: */
024: public final class SequencingEngineContext {
025: /**
026: * This object
027: */
028: private static SequencingEngineContext sSeqContext;
029:
030: /**
031: * Engine context
032: */
033: private ComponentContext mContext;
034:
035: /**
036: * Logger object for this component.
037: */
038: private Logger mLogger;
039:
040: /**
041: * Creates a new SequencingEngineContext object.
042: */
043: private SequencingEngineContext() {
044: }
045:
046: /**
047: * Gets the engine channel.
048: *
049: * @return engine channel
050: */
051: public DeliveryChannel getChannel() {
052: DeliveryChannel chnl = null;
053:
054: if (mContext != null) {
055: try {
056: chnl = mContext.getDeliveryChannel();
057: } catch (Exception e) {
058: e.printStackTrace();
059: }
060: }
061:
062: return chnl;
063: }
064:
065: /**
066: * Sets the engine context.
067: *
068: * @param ctx engine context.
069: */
070: public void setContext(ComponentContext ctx) {
071: mContext = ctx;
072: }
073:
074: /**
075: * Returns the jbi context.
076: *
077: * @return engine context
078: */
079: public ComponentContext getContext() {
080: return mContext;
081: }
082:
083: /**
084: * Used to grab a reference of this object.
085: *
086: * @return an initialized SequencingEngineContext reference
087: */
088: public static synchronized SequencingEngineContext getInstance() {
089: if (sSeqContext == null) {
090: sSeqContext = new SequencingEngineContext();
091: }
092:
093: return sSeqContext;
094: }
095:
096: /**
097: * Sets the Logger.
098: *
099: * @param logger logger for this component.
100: */
101: public void setLogger(Logger logger) {
102: mLogger = logger;
103: }
104:
105: /**
106: * Returns the logger.
107: *
108: * @return logger
109: */
110: public Logger getLogger() {
111: if (mLogger == null) {
112: mLogger = Logger.getLogger("com.sun.jbi.engine.sequencing");
113: }
114:
115: return mLogger;
116: }
117:
118: /**
119: * Returns the transaction manager
120: *
121: * @return Transaction manager
122: */
123: public TransactionManager getTransactionManager() {
124: return (javax.transaction.TransactionManager) mContext
125: .getTransactionManager();
126: }
127: }
|