<?xml version="1.0" encoding="UTF-8"?>
<MetamergeConfig IDIversion="Created by TDI6.1.1 - 2008-11-26" created="Mon Feb 09 15:42:13 CET 2009" createdBy="NO010196" modified="Mon Feb 09 15:46:23 CET 2009" modifiedBy="NO010196" version="6.1.1">
<Folder name="AssemblyLines">
<AssemblyLine name="example">
<Settings>
<parameter name="ALPoolSettingsDialog">showALPoolSettings</parameter>
<parameter name="automapattributes">false</parameter>
<parameter name="createTombstones">false</parameter>
<parameter name="debug">false</parameter>
<parameter name="includeGlobalPrologs">true</parameter>
<parameter name="includePrologs">_logLib</parameter>
<parameter name="nullBehaviorDialog">showNullBehavior</parameter>
</Settings>
<Hooks/>
<CheckpointConfig/>
<SandboxConfig/>
<LogConfig/>
<ContainerEF name="EntryFeedContainer"/>
<ContainerDF name="DataFlowContainer">
<Connector name="test _logLib">
<ConnectorMode>Script</ConnectorMode>
<ConnectorState>Enabled</ConnectorState>
<Configuration/>
<ConnectorScript><![CDATA[// log = new _logLib("C:/mylog.xml", false, "ibmdi.XML", "ibmdi.FileSystem", true);
log = new _logLib("C:/mylog.xml");

log.msg("test");
log.msg("test 2");
log.msg("test 3");

log.closeLog(); // this is important. Do it (for example) in the AL Epilog Hook after AL cycling is done.]]></ConnectorScript>
<Parser/>
<AttributeMap name="Input"/>
<AttributeMap name="Output"/>
<DeltaSettings/>
<Schema name="Input"/>
<Schema name="Output"/>
<LinkCriteria/>
<Hooks/>
<CheckpointConfig/>
<SandboxConfig/>
<Reconnect>
<InheritFrom>[parent]</InheritFrom>
</Reconnect>
<Operations/>
<PoolDefinition>
<InheritFrom>[parent]</InheritFrom>
</PoolDefinition>
<PoolInstance/>
</Connector>
</ContainerDF>
<ThreadOptions/>
<Operations/>
<InitParams>
<Schema name="AssemblyLineInitParams"/>
</InitParams>
</AssemblyLine>
</Folder>
<Folder name="Connectors"/>
<Folder name="Parsers"/>
<Folder name="EventHandlers"/>
<Folder name="Scripts">
<Script name="_logLib">
<parameter name="script"><![CDATA[// JSON object that makes it easier to make your own
// customized logging. You can make many copies of this
// one by copying to a "log2", "logAlert", etc.
//
// Note only the first argument (filepath) is mandatory
//
// usage:    var log = new _logLib("c:\mylog.xml", true, "ibmdi.xml", "ibmdi.FileSystem", debug); // last 2 are optional
//           log.msg("Here comes the message");
//

var _logLib = function(filePath, append, parser, connector, debug) {
	this.prototype.logAttributes = [ 
//				--   Rename as you choose
				"Message",   // the text you pass in: log.msg("this");
				"Timestamp", // ret.value = new java.util.Date()
				"Connector", // thisConnector.getName() + Connector Interface (JDBC, LDAP, ...)
			    ];

	var logFile = null;
	var logEntry = null;

	//------------------------------------------------------------
	// msg(textMsg)
	//
	this.prototype.msg = function(textMsg) {
		if (!this.logFile)
			this.initializeLog(this.useFilePath);

		this.logEntry.removeAllAttributes();
		this.logEntry.setAttribute(this.logAttributes[0], textMsg);
		this.logEntry.setAttribute(this.logAttributes[1], new java.util.Date());

		this.logEntry.setAttribute(this.logAttributes[2], this.getComponentDetails());

		if (this.deBug) {
			main.logmsg("** logLib::msg() - textMsg: " + textMsg);
			main.dumpEntry(this.logEntry);				
		}
			
		this.logFile.putEntry(this.logEntry);
	}

	//------------------------------------------------------------
	//
	this.prototype.initializeLog = function(filePath, append, parser, connector, debug) { // Returns the initialized CI
		var parserInterface = null;

		this.deBug = debug;

		main.logmsg("** logLib vrs. 1.0 loading...");
		main.logmsg("** logLib::initializeLog() - filePath: " + filePath);

		if (this.logFile) {
			this.logFile.terminate();
		}

		if (typeof(connector) == "undefined" || !connector)
			connector = "ibmdi.FileSystem";

		if (typeof(parser) == "undefined" || !parser)
			parser = "ibmdi.XML";

		if (typeof(debug) == "undefined" || !debug)
			debug = false
		else
			debug = true;
			
		if (typeof(append) == "undefined" || !append)
			append = false
		else
			append = true;
			
		this.connector = connector;
		this.parser = parser;
		this.deBug = debug;
		this.append = append;

		this.logFile = null; // un-set logFile

		this.logFile = system.getConnector(this.connector); // get CI
		if (this.logFile == null)
			throw "Unable to load Connector: " + this.connector;

		this.logFile.setParam("filePath", filePath);
		this.logFile.setParam("fileAppend", append);
		
		parserInterface = system.getParser(this.parser);
		if (parserInterface == null)
			throw "Unable to load Parser: " + this.parser;

		if (this.deBug)
			main.logmsg("** logLib::initializeLog() - parser: " + parserInterface);

		this.logFile.setParser(parserInterface);
		this.logFile.initialize(null); // throws exception on error

		this.logEntry = system.newEntry();

		return this;
	}

	//------------------------------------------------------------
	//
	this.prototype.closeLog = function () {
		if (this.logFile)
			this.logFile.terminate();
		this.logFile = null;
	}

	//------------------------------------------------------------
	//
	this.prototype.getComponentDetails =  function() {
		if (typeof(thisConnector) == "undefined" || !thisConnector)
			return "Unknown (AL Init/Shutdown)";

		var cname = thisConnector.getClass().getName();
		var intrface = null;

		if (cname.endsWith("AssemblyLineConnector"))
			intrface = thisConnector.getConnector();

		if (cname.endsWith("AssemblyLineFC"))
			intrface = thisConnector.getFunction();

		if (intrface)
			return thisConnector.getName() + 
				" | " +thisConnector.getClass().getName() + 
				"->" + intrface.getClass().getName()
		else
			return thisConnector.getName() + 
				" | " +thisConnector.getClass().getName();
	}

	//------------------------------------------------------------
	// Main area for this function-object. Returns a pointer to this
	// instance.
	//

	return this.initializeLog(filePath, append, parser, connector, debug);

}
]]></parameter>
</Script>
</Folder>
<JavaLibraries/>
<JavaProperties/>
<Folder name="Includes"/>
<Folder name="Config">
<LogConfig name="Logging"/>
<InstanceProperties name="AutoStart">
<AutoStart/>
</InstanceProperties>
<TombstonesConfig name="Tombstones"/>
<SolutionInterface name="SolutionInterface"/>
</Folder>
<Folder name="Functions"/>
<Folder name="AttributeMaps"/>
<Properties name="Properties">
<Stores>
<PropertyStore name="Solution-Properties">
<Parser/>
<RawConnector>
<InheritFrom>system:/Connectors/ibmdi.Properties</InheritFrom>
<parameter name="collectionType">Solution-Properties</parameter>
</RawConnector>
<Key>key</Key>
<Value>value</Value>
<ReadOnly>false</ReadOnly>
<InitialLoad>true</InitialLoad>
<CacheTimeout>0</CacheTimeout>
</PropertyStore>
<PropertyStore name="Global-Properties">
<Parser/>
<RawConnector>
<InheritFrom>system:/Connectors/ibmdi.Properties</InheritFrom>
<parameter name="collectionType">Global-Properties</parameter>
</RawConnector>
<Key>key</Key>
<Value>value</Value>
<ReadOnly>false</ReadOnly>
<InitialLoad>true</InitialLoad>
<CacheTimeout>0</CacheTimeout>
</PropertyStore>
<PropertyStore name="Java-Properties">
<Parser/>
<RawConnector>
<InheritFrom>system:/Connectors/ibmdi.Properties</InheritFrom>
<parameter name="collectionType">Java-Properties</parameter>
</RawConnector>
<Key>key</Key>
<Value>value</Value>
<ReadOnly>false</ReadOnly>
<InitialLoad>true</InitialLoad>
<CacheTimeout>0</CacheTimeout>
</PropertyStore>
<PropertyStore name="System-Properties">
<Parser/>
<RawConnector>
<InheritFrom>system:/Connectors/ibmdi.Properties</InheritFrom>
<parameter name="collectionType">System-Properties</parameter>
</RawConnector>
<Key>key</Key>
<Value>value</Value>
<ReadOnly>false</ReadOnly>
<InitialLoad>true</InitialLoad>
<CacheTimeout>0</CacheTimeout>
</PropertyStore>
</Stores>
</Properties>
</MetamergeConfig>
