001: // Copyright (c) 2004-2005 Sun Microsystems Inc., All Rights Reserved.
002:
003: /*
004: * FileBindingContext.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.binding.file;
011:
012: import javax.jbi.component.ComponentContext;
013: import javax.jbi.messaging.DeliveryChannel;
014: import java.util.logging.Logger;
015:
016: /**
017: * Context object to store sequencing engine specific informaiton.
018: *
019: * @author Sun Microsystems, Inc.
020: */
021: public final class FileBindingContext {
022: /**
023: * This object
024: */
025: private static FileBindingContext sFileContext;
026:
027: /**
028: * ENgine context
029: */
030: private ComponentContext mContext;
031:
032: /**
033: * Logger object.
034: */
035: private Logger mLogger;
036:
037: /**
038: * DD schema.
039: */
040: private String mDDSchema;
041:
042: /**
043: * Creates a new FileBindingContext object.
044: */
045: private FileBindingContext() {
046: }
047:
048: /**
049: * Gets the engine channel.
050: *
051: * @return engine channel
052: */
053: public DeliveryChannel getChannel() {
054: DeliveryChannel chnl = null;
055:
056: if (mContext != null) {
057: try {
058: chnl = mContext.getDeliveryChannel();
059: } catch (Exception e) {
060: e.printStackTrace();
061: }
062: }
063:
064: return chnl;
065: }
066:
067: /**
068: * Sets the engine context.
069: *
070: * @param ctx engine context.
071: */
072: public void setContext(ComponentContext ctx) {
073: mContext = ctx;
074: }
075:
076: /**
077: * Returns the context.
078: *
079: * @return engine context
080: */
081: public ComponentContext getContext() {
082: return mContext;
083: }
084:
085: /**
086: * Sets the logger.
087: *
088: * @param logger Logger.
089: */
090: public void setLogger(Logger logger) {
091: mLogger = logger;
092: }
093:
094: /**
095: * Returns the logger.
096: *
097: * @return engine context
098: */
099: public Logger getLogger() {
100: if (mLogger == null) {
101: mLogger = Logger.getLogger("com.sun.jbi.binding.file");
102: }
103: return mLogger;
104: }
105:
106: /**
107: * Used to grab a reference of this object.
108: *
109: * @return an initialized FileBindingContext reference
110: */
111: public static synchronized FileBindingContext getInstance() {
112: if (sFileContext == null) {
113: sFileContext = new FileBindingContext();
114: }
115:
116: return sFileContext;
117: }
118:
119: /**
120: * Gets the deployment descriptor schema file path.
121: *
122: * @return Full path of the DD schema file.
123: */
124: public String getDDSchema() {
125: return mDDSchema;
126: }
127:
128: /**
129: * Sets the deployment descriptor schema file path.
130: *
131: * @ return full path of the DD schema.
132: */
133: public void setDDSchema(String sch) {
134: mDDSchema = sch;
135: }
136: }
|