[jboss-svn-commits] JBL Code SVN: r5349 - in labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks: . src src/org/jboss/soa/esb/samples/loanbroker/banks test/org/jboss/soa/esb/samples/loanbroker/banks
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 28 18:46:03 EDT 2006
Author: kurt.stam at jboss.com
Date: 2006-07-28 18:45:58 -0400 (Fri, 28 Jul 2006)
New Revision: 5349
Added:
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java
Removed:
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/config/
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/META-INF/
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManagerFactory.java
Modified:
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java
labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
Log:
adding bank code for the loan broker example
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/bank.properties 2006-07-28 22:45:58 UTC (rev 5349)
@@ -1 +1 @@
-deploy.dir=/cygwin/home/kstam/apps/jboss-4.0.3SP1/jbossesb/server/default/deploy
+monitored.directory=C:/Temp
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/build.xml 2006-07-28 22:45:58 UTC (rev 5349)
@@ -15,13 +15,14 @@
<path id="org.jboss.esb.samples.loanbroker.banks.classpath">
<fileset dir="${org.jboss.esb.samples.loanbroker.banks.lib.ext.dir}" includes="*.jar"/>
- <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="log4j.jar"/>
+ <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="log4j.jar,jbossall-client.jar"/>
</path>
<path id="org.jboss.esb.samples.loanbroker.banks.testclasspath">
<fileset dir="${org.jboss.esb.samples.loanbroker.banks.lib.ext.dir}" includes="*.jar"/>
- <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="log4j.jar"/>
+ <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="log4j.jar,jbossall-client.jar"/>
<pathelement location="${org.jboss.esb.samples.loanbroker.banks.classes.dir}"/>
<pathelement location="${org.jboss.esb.samples.loanbroker.banks.testclasses.dir}"/>
+ <fileset dir="${basedir}" includes="log4j.xml"/>
</path>
<target name="clean">
@@ -78,31 +79,27 @@
</jar>
</target>
- <target name="org.jboss.esb.samples.loanbroker.banks.ear" depends="org.jboss.esb.samples.loanbroker.banks.jar">
- <ear destfile="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/jbossesb-banks-appl.ear"
- appxml="src/META-INF/application.xml">
- <fileset dir="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/lib"
- includes="bank.jar,pollmgt.sar" />
- <fileset dir="${org.jboss.esb.samples.loanbroker.banks.lib.ext.dir}"
- includes="xstream-1.1.3.jar" />
- <fileset dir="${basedir}/src"
- includes="META-INF/jboss-app.xml" />
- </ear>
- </target>
+ <target name="runJMSBank" depends="org.jboss.esb.samples.loanbroker.banks.jar">
+ <echo>Running JMS Based Bank</echo>
+ <echo>Note that your app-server on host: localhost needs to be up and running!</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.loanbroker.banks.ManagerJMS" failonerror="true">
+ <sysproperty key="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"/>
+ <sysproperty key="java.naming.provider.url" value="localhost:1099"/>
+ <classpath refid="org.jboss.esb.samples.loanbroker.banks.testclasspath"/>
+ </java>
+ </target>
- <target name="deploy_banks" depends="org.jboss.esb.samples.loanbroker.banks.ear">
- <copy todir="${deploy.dir}" overwrite="true">
- <fileset dir="${org.jboss.esb.samples.loanbroker.banks.dest}/dist/">
- <include name="jbossesb-banks-appl.ear"/>
- </fileset>
- </copy>
- </target>
+ <target name="runFileBank" depends="org.jboss.esb.samples.loanbroker.banks.jar">
+ <echo>Running File Based Bank</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.loanbroker.banks.ManagerFlatFile" failonerror="true" args="${monitored.directory}">
+ <classpath refid="org.jboss.esb.samples.loanbroker.banks.testclasspath"/>
+ </java>
+ </target>
<!-- Short target names -->
<target name="compile" depends="org.jboss.esb.samples.loanbroker.banks.compile"/>
<target name="test" depends="org.jboss.esb.samples.loanbroker.banks.test"/>
<target name="jar" depends="org.jboss.esb.samples.loanbroker.banks.jar"/>
- <target name="ear" depends="org.jboss.esb.samples.loanbroker.banks.ear"/>
<!-- ====================================================================== -->
<!-- U N I T T E S T S -->
Added: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/log4j.xml 2006-07-28 22:45:58 UTC (rev 5349)
@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ====================== -->
+ <!-- More Appender examples -->
+ <!-- ====================== -->
+
+ <!-- Buffer events and log them asynchronously
+ <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="SMTP"/>
+ </appender>
+ -->
+
+ <!-- EMail events to an administrator
+ <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="To" value="admin at myhost.domain.com"/>
+ <param name="From" value="nobody at myhost.domain.com"/>
+ <param name="Subject" value="JBoss Sever Errors"/>
+ <param name="SMTPHost" value="localhost"/>
+ <param name="BufferSize" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Syslog events
+ <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Facility" value="LOCAL7"/>
+ <param name="FacilityPrinting" value="true"/>
+ <param name="SyslogHost" value="localhost"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Log events to JMS (requires a topic to be created)
+ <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+ <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+ </appender>
+ -->
+
+ <!-- Log events through SNMP
+ <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
+ <param name="ManagementHost" value="127.0.0.1"/>
+ <param name="ManagementHostTrapListenPort" value="162"/>
+ <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
+ <param name="LocalIPAddress" value="127.0.0.1"/>
+ <param name="LocalTrapSendPort" value="161"/>
+ <param name="GenericTrapType" value="6"/>
+ <param name="SpecificTrapType" value="12345678"/>
+ <param name="CommunityString" value="public"/>
+ <param name="ForwardStackTraceWithTrap" value="true"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Emit events as JMX notifications
+ <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+
+ <param name="Threshold" value="WARN"/>
+ <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+ <category name="org.apache">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+ <category name="org.jgroups">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit jboss axis to INFO as its DEBUG is even more verbose -->
+ <category name="org.jboss.axis">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit JBoss categories
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+ -->
+
+ <!-- Limit the JSR77 categories -->
+ <category name="org.jboss.management">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit JBoss webservice category
+ <category name="org.jboss.webservice">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Decrease the priority threshold for the org.jboss.varia category
+ <category name="org.jboss.varia">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
+ <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!--
+ | An example of enabling the custom TRACE level priority that is used
+ | by the JBoss internals to diagnose low level details. This example
+ | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+ | subpackages. This will produce A LOT of logging output.
+ <category name="org.jboss.system">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ <category name="org.jboss.ejb.plugins">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!--
+ | Logs these events to SNMP:
+ - server starts/stops
+ - cluster evolution (node death/startup)
+ - When an EJB archive is deployed (and associated verified messages)
+ - When an EAR archive is deployed
+
+ <category name="org.jboss.system.server.Server">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.MainDeployer">
+ <priority value="ERROR" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ejb.EJBDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.EARDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ -->
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+ <!-- Clustering logging -->
+ <!-- Uncomment the following to redirect the org.jgroups and
+ org.jboss.ha categories to a cluster.log file.
+
+ <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.home.dir}/log/cluster.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ <category name="org.jgroups">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ <category name="org.jboss.ha">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ -->
+
+</log4j:configuration>
Deleted: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java 2006-07-28 22:45:58 UTC (rev 5349)
@@ -1,184 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.io.File;
-import java.math.BigDecimal;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.sadun.util.polling.BasePollManager;
-import org.sadun.util.polling.CycleEndEvent;
-import org.sadun.util.polling.CycleStartEvent;
-import org.sadun.util.polling.DirectoryLookupEndEvent;
-import org.sadun.util.polling.DirectoryLookupStartEvent;
-import org.sadun.util.polling.FileFoundEvent;
-import org.sadun.util.polling.FileSetFoundEvent;
-
-/**
- * The FlatFilePollManager monitors a directory specified in the configuration. When a file arrives it
- * tries to process the content assuming it contains one line with loan request information.
- * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
- * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
- * and finally the LoanTerm [month]. The request will be processed and a BankQouteReply is generated. The
- * original file is moved to a 'processed' directory, and the BankQuoteReply is serialized to an 'outgoing'
- * directory from the it can be picked up by the system that dropped the request.
- *
- * @author kstam
- *
- */
-
-class FlatFilePollManager extends BasePollManager
-{
- private Logger logger = Logger.getLogger(this.getClass());
-
- private static final String BANK_NAME = "FileBasedBank";
- private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.25);
- private static final int MAXLOANTERM = 120;
- protected static final String OUTGOING_DIR = "outgoing";
- protected static final String PREFIX = "reply_to_";
- protected static final String PROCESSED_DIR = "processed";
- /**
- * Handle to the cycle start event.
- */
- public void cycleStarted(CycleStartEvent evt) {
- logger.log(Priority.DEBUG, "Poller awakened "
- + (evt.getPoller().getFilter() == null ? "(no filtering)" : evt
- .getPoller().getFilter().toString()));
- }
- /**
- * Handle to the cycle end event.
- */
- public void cycleEnded(CycleEndEvent evt) {
- logger.log(Priority.DEBUG, "Poller going to sleep");
- }
- /**
- * Handle to the directory lookup start event.
- */
- public void directoryLookupStarted(DirectoryLookupStartEvent evt) {
- logger.log(Priority.DEBUG, "Scanning " + evt.getDirectory());
- }
- /**
- * Handle to the directory lookup end event.
- */
- public void directoryLookupEnded(DirectoryLookupEndEvent evt) {
- logger.log(Priority.DEBUG, "Finished scanning " + evt.getDirectory());
- }
- /**
- * Handle to the file set found event. Currenty this is the only event that
- * is actually used to proces the incoming loan quote requests. Each file
- * is send to be processed.
- */
- public void fileSetFound(FileSetFoundEvent evt) {
- File[] files = evt.getFiles();
-
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- processFile(file);
- }
- }
- /**
- * Handle to the file found event.
- */
- public void fileFound(FileFoundEvent evt) {
- logger.log(Priority.DEBUG, evt);
- // Add artificial delay
- }
- /**
- * Returns the name of this PollManager and a quick summary of what it does.
- */
- public String toString() {
- return "FlatFilePollManager - a pollmanager which processed incoming -flat file based- loan requests";
- }
- /**
- * Each file is processed assuming it contains one line with loan request information.
- * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
- * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
- * and finally the LoanTerm [month]. The BankQuoteRequest is processed and a BankQouteReply is generated. The
- * original file is moved to a processed directory, and the BankQuoteReply is serialized to an 'outgoing'
- * directory from the it can be picked up by the system that dropped the request.
- *
- * @param file - incoming flat file with loan quote request info.
- */
- protected void processFile(File file)
- {
- BankQuoteReply bankQuoteReply=new BankQuoteReply();
- bankQuoteReply.setQuoteId(BANK_NAME);
- int errorCode=6;
- String message=null;
- logger.log(Priority.INFO, "Found " + file.getAbsolutePath() );
-
- try {
- BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
- //Read the content of the file into a String
- message=FileUtil.readTextFile(file);
- String[] messagePart = message.split(",");
-
- errorCode=1;
- bankQuoteRequest.setSsn(Integer.valueOf(messagePart[0]));
- errorCode=2;
- bankQuoteRequest.setCreditScore(Integer.valueOf(messagePart[1]));
- errorCode=3;
- bankQuoteRequest.setHistoryLength(Integer.valueOf(messagePart[2]));
- errorCode=4;
- bankQuoteRequest.setLoanAmount(Integer.valueOf(messagePart[3]));
- errorCode=5;
- bankQuoteRequest.setLoanTerm(Integer.valueOf(messagePart[4]));
-
- Bank fileBasedBank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
- bankQuoteReply = fileBasedBank.processMessage(bankQuoteRequest);
- } catch (Throwable e) {
- //Package up the error, so it can be processed
- logger.log(Priority.ERROR, e.getMessage());
- bankQuoteReply.setErrorCode(errorCode);
- }
-
- try {
- //Create the outgoing response file
- File outgoingDir = new File(file.getParent() + "/" + OUTGOING_DIR);
- if (!outgoingDir.exists()) {
- outgoingDir.mkdir();
- }
- File outgoingFile = new File(outgoingDir + "/" + PREFIX + file.getName());
- logger.log(Priority.INFO, "Creating outgoing file " + outgoingFile.getAbsolutePath());
- outgoingFile.createNewFile();
- String reply=bankQuoteReply.getInterestRate() + "," + bankQuoteReply.getQuoteId() + "," + bankQuoteReply.getErrorCode();
- logger.log(Priority.INFO, "Writing reply " + reply);
- FileUtil.writeTextFile(outgoingFile, reply);
-
- //Move the processed file away so it does not get processed again
- File processedDir = new File(file.getParent() + "/" + PROCESSED_DIR);
- if (!processedDir.exists()) {
- processedDir.mkdir();
- }
- logger.log(Priority.INFO, "Moving file " + file.getName() + " to processed directory");
- File processedFile = new File(processedDir.getAbsolutePath() + "/" + file.getName());
- file.renameTo(processedFile);
- if (file.exists()) {
- file.delete();
- }
- } catch (Exception e) {
- logger.log(Priority.ERROR, e.getMessage(), e);
- }
- }
-
-}
\ No newline at end of file
Deleted: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManagerFactory.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManagerFactory.java 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManagerFactory.java 2006-07-28 22:45:58 UTC (rev 5349)
@@ -1,61 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.soa.esb.samples.loanbroker.banks;
-
-import java.util.logging.Level;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.sadun.util.polling.PollManager;
-import org.sadun.util.polling.PollManagerFactory;
-import org.sadun.util.polling.pollmanagers.LoggerHistoryPollManager;
-
-/**
- * A {@link org.sadun.util.polling.PollManagerFactory PollManagerFactory} which produces one
- * instance of {@link org.jboss.soa.esb.samples.loanbroker.banks.FlatFilePollManager BankPollManager}
- *
- * @author kstam
- */
-public class FlatFilePollManagerFactory implements PollManagerFactory
-{
- private Logger logger = Logger.getLogger(this.getClass());
- /**
- * @see org.sadun.util.polling.PollManagerFactory#createPollManagers()
- */
- public PollManager[] createPollManagers(String name) {
- // In this particular factory, the MBean name is not used
- java.util.logging.Logger.getLogger("bank_f").setLevel(Level.WARNING);
- logger.log(Priority.INFO, "Creating FlatFilePollManager for MBean <"+name+">");
- return new PollManager[] { new FlatFilePollManager(), new LoggerHistoryPollManager("bank_f") };
- }
-
- /**
- * @see org.sadun.util.polling.PollManagerFactory#getDescription()
- */
- public String getDescription() {
- return "A factory producing one instance of org.jboss.soa.esb.samples.loanbroker.banks.FlatFilePollManager";
- }
-
-}
-
-
\ No newline at end of file
Copied: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java (from rev 5343, labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java)
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/FlatFilePollManager.java 2006-07-28 14:03:07 UTC (rev 5343)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerFlatFile.java 2006-07-28 22:45:58 UTC (rev 5349)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.io.File;
+import java.math.BigDecimal;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.sadun.util.polling.BasePollManager;
+import org.sadun.util.polling.CycleEndEvent;
+import org.sadun.util.polling.CycleStartEvent;
+import org.sadun.util.polling.DirectoryLookupEndEvent;
+import org.sadun.util.polling.DirectoryLookupStartEvent;
+import org.sadun.util.polling.DirectoryPoller;
+import org.sadun.util.polling.FileFoundEvent;
+import org.sadun.util.polling.FileSetFoundEvent;
+
+/**
+ * The FlatFilePollManager monitors a directory specified in the configuration. When a file arrives it
+ * tries to process the content assuming it contains one line with loan request information.
+ * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
+ * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
+ * and finally the LoanTerm [month]. The request will be processed and a BankQouteReply is generated. The
+ * original file is moved to a 'processed' directory, and the BankQuoteReply is serialized to an 'outgoing'
+ * directory from the it can be picked up by the system that dropped the request.
+ *
+ * @author kstam
+ *
+ */
+
+class ManagerFlatFile extends BasePollManager
+{
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ private static final String BANK_NAME = "FileBasedBank";
+ private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.25);
+ private static final int MAXLOANTERM = 120;
+ protected static final String OUTGOING_DIR = "outgoing";
+ protected static final String PREFIX = "reply_to_";
+ protected static final String PROCESSED_DIR = "processed";
+ /**
+ * Handle to the cycle start event.
+ */
+ public void cycleStarted(CycleStartEvent evt) {
+ logger.log(Priority.DEBUG, "Poller awakened "
+ + (evt.getPoller().getFilter() == null ? "(no filtering)" : evt
+ .getPoller().getFilter().toString()));
+ }
+ /**
+ * Handle to the cycle end event.
+ */
+ public void cycleEnded(CycleEndEvent evt) {
+ logger.log(Priority.DEBUG, "Poller going to sleep");
+ }
+ /**
+ * Handle to the directory lookup start event.
+ */
+ public void directoryLookupStarted(DirectoryLookupStartEvent evt) {
+ logger.log(Priority.DEBUG, "Scanning " + evt.getDirectory());
+ }
+ /**
+ * Handle to the directory lookup end event.
+ */
+ public void directoryLookupEnded(DirectoryLookupEndEvent evt) {
+ logger.log(Priority.DEBUG, "Finished scanning " + evt.getDirectory());
+ }
+ /**
+ * Handle to the file set found event. Currenty this is the only event that
+ * is actually used to proces the incoming loan quote requests. Each file
+ * is send to be processed.
+ */
+ public void fileSetFound(FileSetFoundEvent evt) {
+ File[] files = evt.getFiles();
+
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ processFile(file);
+ }
+ }
+ /**
+ * Handle to the file found event.
+ */
+ public void fileFound(FileFoundEvent evt) {
+ logger.log(Priority.DEBUG, evt);
+ // Add artificial delay
+ }
+ /**
+ * Returns the name of this PollManager and a quick summary of what it does.
+ */
+ public String toString() {
+ return "FlatFilePollManager - a pollmanager which processed incoming -flat file based- loan requests";
+ }
+ /**
+ * Each file is processed assuming it contains one line with loan request information.
+ * So for example the content of the file could read some like <br>23456890,3,4,20000,5<br>
+ * The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar],
+ * and finally the LoanTerm [month]. The BankQuoteRequest is processed and a BankQouteReply is generated. The
+ * original file is moved to a processed directory, and the BankQuoteReply is serialized to an 'outgoing'
+ * directory from the it can be picked up by the system that dropped the request.
+ *
+ * @param file - incoming flat file with loan quote request info.
+ */
+ protected void processFile(File file)
+ {
+ BankQuoteReply bankQuoteReply=new BankQuoteReply();
+ bankQuoteReply.setQuoteId(BANK_NAME);
+ int errorCode=6;
+ String message=null;
+ logger.log(Priority.INFO, "Found " + file.getAbsolutePath() );
+
+ try {
+ BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
+ //Read the content of the file into a String
+ message=FileUtil.readTextFile(file);
+ String[] messagePart = message.split(",");
+
+ errorCode=1;
+ bankQuoteRequest.setSsn(Integer.valueOf(messagePart[0]));
+ errorCode=2;
+ bankQuoteRequest.setCreditScore(Integer.valueOf(messagePart[1]));
+ errorCode=3;
+ bankQuoteRequest.setHistoryLength(Integer.valueOf(messagePart[2]));
+ errorCode=4;
+ bankQuoteRequest.setLoanAmount(Integer.valueOf(messagePart[3]));
+ errorCode=5;
+ bankQuoteRequest.setLoanTerm(Integer.valueOf(messagePart[4]));
+
+ Bank fileBasedBank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
+ bankQuoteReply = fileBasedBank.processMessage(bankQuoteRequest);
+ } catch (Throwable e) {
+ //Package up the error, so it can be processed
+ logger.log(Priority.ERROR, e.getMessage());
+ bankQuoteReply.setErrorCode(errorCode);
+ }
+
+ try {
+ //Create the outgoing response file
+ File outgoingDir = new File(file.getParent() + "/" + OUTGOING_DIR);
+ if (!outgoingDir.exists()) {
+ outgoingDir.mkdir();
+ }
+ File outgoingFile = new File(outgoingDir + "/" + PREFIX + file.getName());
+ logger.log(Priority.INFO, "Creating outgoing file " + outgoingFile.getAbsolutePath());
+ outgoingFile.createNewFile();
+ String reply=bankQuoteReply.getInterestRate() + "," + bankQuoteReply.getQuoteId() + "," + bankQuoteReply.getErrorCode();
+ logger.log(Priority.INFO, "Writing reply " + reply);
+ FileUtil.writeTextFile(outgoingFile, reply);
+
+ //Move the processed file away so it does not get processed again
+ File processedDir = new File(file.getParent() + "/" + PROCESSED_DIR);
+ if (!processedDir.exists()) {
+ processedDir.mkdir();
+ }
+ logger.log(Priority.INFO, "Moving file " + file.getName() + " to processed directory");
+ File processedFile = new File(processedDir.getAbsolutePath() + "/" + file.getName());
+ file.renameTo(processedFile);
+ if (file.exists()) {
+ file.delete();
+ }
+ } catch (Exception e) {
+ logger.log(Priority.ERROR, e.getMessage(), e);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ DOMConfigurator.configure("log4j.xml");
+ String monitoredDirectoryStr = "C:/Temp";
+ if (args!=null && args.length > 0) {
+ monitoredDirectoryStr=args[0];
+ }
+ File monitoredDirectory = new File(monitoredDirectoryStr);
+ if (!monitoredDirectory.exists() || !monitoredDirectory.isDirectory()){
+ System.out.println("Invalid directory " + monitoredDirectory.getAbsolutePath());
+ }
+ DirectoryPoller poller = new DirectoryPoller(monitoredDirectory);
+ poller.addPollManager(new ManagerFlatFile());
+ poller.start();
+ }
+
+
+}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/src/org/jboss/soa/esb/samples/loanbroker/banks/ManagerJMS.java 2006-07-28 22:45:58 UTC (rev 5349)
@@ -0,0 +1,121 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.math.BigDecimal;
+import java.util.Properties;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+
+public class ManagerJMS implements javax.jms.MessageListener
+{
+ private static Logger log = Logger.getLogger(ManagerJMS.class);
+ private static final String BANK_NAME = "JMSBasedBank";
+ private static final BigDecimal RATE_PREMIUM = BigDecimal.valueOf(0.50);
+ private static final int MAXLOANTERM = 120;
+ private static InitialContext ctx;
+ private static Properties properties = new Properties();
+ QueueConnection inQueueConnection;
+
+ public void listen()
+ {
+ try {
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
+ properties.put(Context.PROVIDER_URL, "localhost");
+ ctx = new InitialContext(properties);
+ log.info("Looking up queue");
+ Queue inQueue = (Queue) ctx.lookup("queue/A");
+ log.info("Looking up connection factory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("UIL2ConnectionFactory");
+ log.info("Creating connection");
+ inQueueConnection = qcf.createQueueConnection();
+ log.info("Creating session");
+ QueueSession qs = inQueueConnection .createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+ QueueReceiver qr = qs.createReceiver(inQueue);
+ qr.setMessageListener(this);
+ inQueueConnection .start();
+ } catch (Exception e) {
+ log.error(e.getMessage(),e);
+ }
+ }
+
+ public void onMessage(Message message) {
+ QueueConnection outQueueConnection;
+ log.info("Got message: " + message);
+ try {
+ TextMessage textMessage = (TextMessage) message;
+ String xml=textMessage.getText();
+ XStream xstream = new XStream(new DomDriver());
+ BankQuoteRequest bankQuoteRequest = (BankQuoteRequest) xstream.fromXML(xml);
+ Bank bank = new Bank(BANK_NAME, RATE_PREMIUM, MAXLOANTERM);
+ BankQuoteReply bankQuoteReply = bank.processMessage(bankQuoteRequest);
+ String bankQuoteReplyXML = xstream.toXML(bankQuoteReply);
+ Queue outQueue = (Queue) ctx.lookup("queue/B");
+ log.info("Looking up connection factory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("UIL2ConnectionFactory");
+ log.info("Creating connection");
+ outQueueConnection = qcf.createQueueConnection();
+ try {
+ log.info("Creating session");
+ QueueSession qs = outQueueConnection.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+ TextMessage responseTextMessage =qs.createTextMessage(bankQuoteReplyXML);
+ QueueSender queueSender = qs.createSender(outQueue);
+ queueSender.send(responseTextMessage);
+ } catch (JMSException je) {
+ log.error(je.getMessage(),je);
+ }finally {
+ outQueueConnection.close();
+ }
+ } catch (Exception e) {
+ log.error(e.getMessage(),e);
+ }
+ }
+
+ public void close() throws JMSException{
+ inQueueConnection.close();
+ }
+
+ public static void main(String[] args)
+ {
+ DOMConfigurator.configure("log4j.xml");
+ ManagerJMS managerJMS = new ManagerJMS();
+ managerJMS.listen();
+ }
+}
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/BankTest.java 2006-07-28 22:45:58 UTC (rev 5349)
@@ -39,7 +39,7 @@
* Tests the computation of the interestRate for the TestBank.
*
*/
- @Test public void obtainExampleXML(){
+ @Test public void processLoanRequest(){
//Building a BankQuoteRequest
BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
Modified: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/FlatFileProcessorTest.java 2006-07-28 22:45:58 UTC (rev 5349)
@@ -70,21 +70,21 @@
FileUtil.writeTextFile(loanRequestFile, str);
logger.log(Priority.INFO, "Processing FlatFileProcessorTest.txt");
- FlatFilePollManager pollManager = new FlatFilePollManager();
+ ManagerFlatFile pollManager = new ManagerFlatFile();
pollManager.processFile(loanRequestFile);
//Check to see if the file is now moved.
assertFalse(loanRequestFile.exists());
File processedFile = new File(writableDir.getAbsolutePath() + "/"
- + FlatFilePollManager.PROCESSED_DIR + "/" + FLAT_FILE);
+ + ManagerFlatFile.PROCESSED_DIR + "/" + FLAT_FILE);
logger.log(Priority.INFO, "Check to see if " + processedFile.getAbsolutePath()
+ " exists");
assertTrue(processedFile.exists());
logger.log(Priority.INFO, "OK");
File replyToFile = new File(writableDir.getAbsolutePath() + "/"
- + FlatFilePollManager.OUTGOING_DIR + "/" + FlatFilePollManager.PREFIX
+ + ManagerFlatFile.OUTGOING_DIR + "/" + ManagerFlatFile.PREFIX
+ FLAT_FILE);
logger.log(Priority.INFO, "Check to see if " + replyToFile.getAbsolutePath()
+ " exists");
Added: labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java
===================================================================
--- labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java 2006-07-28 21:49:25 UTC (rev 5348)
+++ labs/jbossesb/trunk/product/docs/samples/trailblazer/bankloanbrokerdemo/banks/test/org/jboss/soa/esb/samples/loanbroker/banks/JmsProcessorTest.java 2006-07-28 22:45:58 UTC (rev 5349)
@@ -0,0 +1,90 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.samples.loanbroker.banks;
+
+import java.util.Properties;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+//import org.junit.Ignore;
+import org.junit.Test;
+import com.thoughtworks.xstream.XStream;
+
+public class JmsProcessorTest {
+
+ private Logger logger = Logger.getLogger(this.getClass());
+
+ /**
+ * This can be activate if the server is running and you want
+ * to drop a message on the queue
+ *
+ */
+ @Test public void sendLoanRequestXML()
+ {
+
+ // Building a BankQuoteRequest
+ BankQuoteRequest bankQuoteRequest = new BankQuoteRequest();
+ bankQuoteRequest.setSsn(123456890);
+ bankQuoteRequest.setCreditScore(3);
+ bankQuoteRequest.setHistoryLength(4);
+ bankQuoteRequest.setLoanTerm(72);
+ bankQuoteRequest.setLoanAmount(20000);
+ logger.log(Priority.INFO, bankQuoteRequest);
+ XStream xstream = new XStream();
+ String bankQuoteRequestXml=xstream.toXML(bankQuoteRequest);
+
+ QueueSession sess;
+ Queue queue;
+ try {
+ Properties properties = new Properties();
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ properties.put(Context.URL_PKG_PREFIXES , "org.jnp.interfaces");
+ properties.put(Context.PROVIDER_URL , "localhost");
+ InitialContext ctx = new InitialContext(properties);
+ queue = (Queue) ctx.lookup("queue/A");
+ QueueConnectionFactory factory = (QueueConnectionFactory) ctx
+ .lookup("ConnectionFactory");
+ QueueConnection cnn = factory.createQueueConnection();
+ sess = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ TextMessage msg = sess.createTextMessage(bankQuoteRequestXml);
+ QueueSender sender = sess.createSender(queue);
+ sender.send(msg);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static junit.framework.Test suite() {
+ return new JUnit4TestAdapter(JmsProcessorTest.class);
+ }
+}
More information about the jboss-svn-commits
mailing list