asterisk-java-cvs Mailing List for Asterisk-Java Library (Page 90)
Brought to you by:
srt
You can subscribe to this list here.
2005 |
Jan
(4) |
Feb
(75) |
Mar
(211) |
Apr
(70) |
May
(12) |
Jun
(7) |
Jul
(96) |
Aug
(90) |
Sep
(11) |
Oct
(42) |
Nov
(45) |
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(20) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(32) |
Aug
|
Sep
(4) |
Oct
(2) |
Nov
(10) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(3) |
Aug
(73) |
Sep
(13) |
Oct
(4) |
Nov
(1) |
Dec
(7) |
2009 |
Jan
(1) |
Feb
(2) |
Mar
(48) |
Apr
(21) |
May
(14) |
Jun
(11) |
Jul
(9) |
Aug
(2) |
Sep
(11) |
Oct
(14) |
Nov
(6) |
Dec
(4) |
2010 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
|
May
(3) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
(9) |
Nov
|
Dec
(12) |
2011 |
Jan
(1) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(10) |
Sep
|
Oct
(5) |
Nov
|
Dec
|
2012 |
Jan
(3) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
(2) |
Dec
(2) |
2013 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(5) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(25) |
May
(10) |
Jun
(4) |
Jul
(7) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(3) |
Dec
(1) |
2016 |
Jan
|
Feb
(42) |
Mar
(6) |
Apr
(15) |
May
(3) |
Jun
(1) |
Jul
(11) |
Aug
|
Sep
|
Oct
(17) |
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
(4) |
Mar
(1) |
Apr
(3) |
May
(2) |
Jun
(3) |
Jul
(7) |
Aug
(11) |
Sep
(5) |
Oct
(7) |
Nov
(4) |
Dec
(4) |
2018 |
Jan
(11) |
Feb
(11) |
Mar
(3) |
Apr
|
May
(9) |
Jun
(6) |
Jul
(17) |
Aug
(9) |
Sep
(2) |
Oct
(4) |
Nov
(3) |
Dec
(3) |
2019 |
Jan
(13) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(6) |
Sep
|
Oct
|
Nov
(3) |
Dec
|
2020 |
Jan
(2) |
Feb
(72) |
Mar
(8) |
Apr
(11) |
May
(12) |
Jun
(3) |
Jul
(12) |
Aug
(3) |
Sep
(5) |
Oct
(4) |
Nov
|
Dec
(9) |
2021 |
Jan
|
Feb
(31) |
Mar
(6) |
Apr
(3) |
May
|
Jun
(2) |
Jul
|
Aug
(2) |
Sep
|
Oct
(9) |
Nov
|
Dec
(32) |
2022 |
Jan
(5) |
Feb
(7) |
Mar
(2) |
Apr
(3) |
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
(2) |
Oct
(111) |
Nov
(105) |
Dec
(26) |
2023 |
Jan
(25) |
Feb
(6) |
Mar
(10) |
Apr
(54) |
May
(41) |
Jun
(24) |
Jul
(6) |
Aug
(11) |
Sep
(9) |
Oct
(8) |
Nov
(55) |
Dec
(34) |
2024 |
Jan
(6) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(89) |
Sep
(48) |
Oct
(31) |
Nov
(9) |
Dec
(19) |
2025 |
Jan
(12) |
Feb
(18) |
Mar
(9) |
Apr
(7) |
May
|
Jun
(7) |
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Stefan R. <sr...@us...> - 2005-03-11 13:58:54
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30982/src/java/net/sf/asterisk/fastagi/command Modified Files: SetPriorityCommand.java Log Message: Fixed property priority to be of type String (was int) Index: SetPriorityCommand.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command/SetPriorityCommand.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- SetPriorityCommand.java 8 Mar 2005 16:48:34 -0000 1.2 +++ SetPriorityCommand.java 11 Mar 2005 13:58:43 -0000 1.3 @@ -32,7 +32,7 @@ public class SetPriorityCommand extends /** * The priority for continuation upon exiting the application. */ - private int priority; + private String priority; /** * Creates a new SetPriorityCommand. @@ -40,7 +40,7 @@ public class SetPriorityCommand extends * @param priority the priority for continuation upon exiting the * application. */ - public SetPriorityCommand(int priority) + public SetPriorityCommand(String priority) { this.priority = priority; } @@ -50,7 +50,7 @@ public class SetPriorityCommand extends * * @return the priority for continuation upon exiting the application. */ - public int getPriority() + public String getPriority() { return priority; } @@ -61,7 +61,7 @@ public class SetPriorityCommand extends * @param priority the priority for continuation upon exiting the * application. */ - public void setPriority(int priority) + public void setPriority(String priority) { this.priority = priority; } |
From: Stefan R. <sr...@us...> - 2005-03-11 13:49:38
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28541/src/java/net/sf/asterisk/fastagi Modified Files: AbstractAGIScript.java Log Message: Fixed getVariable(): result code 1 indicates success (not 0) Index: AbstractAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AbstractAGIScript.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- AbstractAGIScript.java 11 Mar 2005 13:40:39 -0000 1.4 +++ AbstractAGIScript.java 11 Mar 2005 13:49:26 -0000 1.5 @@ -60,7 +60,7 @@ public abstract class AbstractAGIScript AGIReply reply; reply = channel.sendCommand(new GetVariableCommand(name)); - if (reply.getResultCode() != 0) + if (reply.getResultCode() != 1) { return null; } |
From: Stefan R. <sr...@us...> - 2005-03-11 13:42:01
|
Update of /cvsroot/asterisk-java/asterisk-java/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26351/xdocs Modified Files: samples.xml index.xml building.xml Log Message: Fixed keywords Index: samples.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/samples.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- samples.xml 24 Feb 2005 22:26:06 -0000 1.1 +++ samples.xml 11 Mar 2005 13:41:51 -0000 1.2 @@ -22,7 +22,7 @@ <author email="srt at users.sourceforge.net">Stefan Reuter</author> <title>Samples</title> </properties> - <meta name="keyword" content="asterisk,java,pbx,manager api,library"/> + <meta name="keywords" content="Asterisk,asterisk,Java,java,Manager API,FastAGI,AGI,example,sample"/> <body> <section name="Samples"> <p>To be done.</p> Index: index.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/index.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- index.xml 8 Mar 2005 02:26:45 -0000 1.5 +++ index.xml 11 Mar 2005 13:41:51 -0000 1.6 @@ -22,7 +22,7 @@ <author email="srt at users.sourceforge.net">Stefan Reuter</author> <title>The asterisk-java Library</title> </properties> - <meta name="keyword" content="asterisk,java,pbx,manager api,library"/> + <meta name="keywords" content="Asterisk,asterisk,Java,java,Manager API,FastAGI,AGI"/> <body> <section name="Asterisk Java"> <subsection name="What is asterisk-java?"> Index: building.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/building.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- building.xml 24 Feb 2005 22:26:06 -0000 1.1 +++ building.xml 11 Mar 2005 13:41:51 -0000 1.2 @@ -22,7 +22,7 @@ <author email="srt at users.sourceforge.net">Stefan Reuter</author> <title>Building with Maven</title> </properties> - <meta name="keyword" content="asterisk,java,pbx,manager api,library"/> + <meta name="keywords" content="Asterisk,asterisk,Java,java,Manager API,FastAGI,AGI"/> <body> <section name="Building with Maven"> <p>To be done.</p> |
From: Stefan R. <sr...@us...> - 2005-03-11 13:41:25
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26213/src/java/net/sf/asterisk/fastagi/command Modified Files: GetVariableCommand.java Log Message: Index: GetVariableCommand.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command/GetVariableCommand.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- GetVariableCommand.java 10 Mar 2005 21:48:11 -0000 1.3 +++ GetVariableCommand.java 11 Mar 2005 13:41:13 -0000 1.4 @@ -18,8 +18,8 @@ package net.sf.asterisk.fastagi.command; /** * Returns the value of the given channel varible.<br> - * Returns 0 if is not set. Returns 1 if the variable is set and returns the - * variable in parenthesis.<br> + * Returns 0 if the variable is not set. Returns 1 if the variable is set and + * returns the variable in parenthesis.<br> * Example return code: 200 result=1 (testvariable) * * @author srt |
From: Stefan R. <sr...@us...> - 2005-03-11 13:40:53
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26067/src/java/net/sf/asterisk/fastagi Modified Files: AbstractAGIScript.java Log Message: Added getVariable() and setVariable() Index: AbstractAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AbstractAGIScript.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AbstractAGIScript.java 11 Mar 2005 09:37:39 -0000 1.3 +++ AbstractAGIScript.java 11 Mar 2005 13:40:39 -0000 1.4 @@ -17,7 +17,10 @@ package net.sf.asterisk.fastagi; import net.sf.asterisk.fastagi.command.AnswerCommand; +import net.sf.asterisk.fastagi.command.GetVariableCommand; import net.sf.asterisk.fastagi.command.HangupCommand; +import net.sf.asterisk.fastagi.command.SetVariableCommand; +import net.sf.asterisk.fastagi.reply.AGIReply; /** * The AbstractAGIScript provides some convinience methods to make it easier to @@ -30,10 +33,6 @@ public abstract class AbstractAGIScript { /** * Answers the channel. - * - * @param channel the channel as received by the service method. - * - * @throws AGIException if the command can't be sent to Asterisk. */ protected void answer(AGIChannel channel) throws AGIException { @@ -42,13 +41,41 @@ public abstract class AbstractAGIScript /** * Hangs the channel up. - * - * @param channel the channel as received by the service method. - * - * @throws AGIException if the command can't be sent to Asterisk. */ protected void hangup(AGIChannel channel) throws AGIException { channel.sendCommand(new HangupCommand()); } + + /** + * Returns the value of the given channel variable. + * + * @param name the name of the variable to retrieve. + * @return the value of the given variable or <code>null</code> if not + * set. + */ + protected String getVariable(AGIChannel channel, String name) + throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new GetVariableCommand(name)); + if (reply.getResultCode() != 0) + { + return null; + } + return reply.getExtra(); + } + + /** + * Sets the value of the given channel variable to a new value. + * + * @param name the name of the variable to retrieve. + * @param value the new value to set. + */ + protected void setVariable(AGIChannel channel, String name, String value) + throws AGIException + { + channel.sendCommand(new SetVariableCommand(name, value)); + } } |
From: Stefan R. <sr...@us...> - 2005-03-11 13:40:24
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/reply In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25827/src/java/net/sf/asterisk/fastagi/reply Modified Files: AGIReply.java Log Message: Added extra and attributes properties to AGIReply Index: AGIReply.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/reply/AGIReply.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- AGIReply.java 10 Mar 2005 13:54:06 -0000 1.9 +++ AGIReply.java 11 Mar 2005 13:40:06 -0000 1.10 @@ -17,6 +17,8 @@ package net.sf.asterisk.fastagi.reply; import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; @@ -65,9 +67,9 @@ public class AGIReply implements Seriali private static final long serialVersionUID = 3256727294671337012L; /** - * The return code. + * The result. */ - private int result; + private String result; /** * The status code. @@ -75,6 +77,16 @@ public class AGIReply implements Seriali private int status; /** + * Additional attributes contained in this reply, for example endpos. + */ + private Map attributes; + + /** + * The contents of the parenthesis. + */ + private String extra; + + /** * In case of status == 520 (invalid command syntax) this attribute contains * the synopsis of the command. */ @@ -87,33 +99,63 @@ public class AGIReply implements Seriali private String usage; /** - * Returns the return code. + * Returns the return code (the result as int). * - * @return the return code. + * @return the return code or -1 if the result is not an int. */ - public int getResult() + public int getResultCode() { - return result; + if (result == null) + { + return -1; + } + + try + { + return Integer.parseInt(result); + } + catch (NumberFormatException e) + { + return -1; + } } /** - * Sets the return code. + * Returns the return code as character. * - * @param result the return code to set. + * @return the return code as character. */ - public void setResult(int result) + public char getResultCodeAsChar() { - this.result = result; + int resultCode; + + resultCode = getResultCode(); + if (resultCode < 0) + { + return 0x0; + } + + return (char) resultCode; } /** - * Returns the return code as character. + * Returns the result. * - * @return the return code as character. + * @return the result. */ - public char getResultAsChar() + public String getResult() { - return (char) result; + return result; + } + + /** + * Sets the result. + * + * @param result the result to set. + */ + public void setResult(String result) + { + this.result = result; } /** @@ -143,6 +185,72 @@ public class AGIReply implements Seriali } /** + * Returns an additional attribute contained in the reply.<br> + * For example the reply to the StreamFileCommand contains an additional + * endpos attribute indicating the frame where the playback was stopped. + * This can be retrieved by calling getAttribute("endpos") on the + * corresponding reply. + * + * @param name the name of the attribute to retrieve. The name is case + * insensitive. + * @return the value of the attribute or <code>null</code> if it is not + * set. + */ + public String getAttribute(String name) + { + if ("result".equalsIgnoreCase(name)) + { + return getResult(); + } + + if (attributes == null) + { + return null; + } + + return (String) attributes.get(name.toLowerCase()); + } + + /** + * Sets an additional attribute. + * + * @param name the name of the attribute to set. + * @param value the value of the attribute to set. + */ + public void setAttribute(String name, String value) + { + if (attributes == null) + { + attributes = new HashMap(); + } + + attributes.put(name.toLowerCase(), value); + } + + /** + * Returns the text in parenthesis contained in this reply.<br> + * The meaning of this property depends on the command sent. Sometimes it + * contains a flag like "timeout" or "hangup" or - in case of the + * GetVariableCommand - the value of the variable. + * + * @return the text in the parenthesis or <code>null</code> if not set. + */ + public String getExtra() + { + return extra; + } + + /** + * Sets the text in parenthesis in this reply. + * + * @param extra the text in parenthesis to set. + */ + public void setExtra(String extra) + { + this.extra = extra; + } + + /** * Returns the synopsis of the command sent if Asterisk expected a different * syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). * |
From: Stefan R. <sr...@us...> - 2005-03-11 13:40:24
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25827/src/java/net/sf/asterisk/fastagi Modified Files: ReplyBuilderImpl.java Log Message: Added extra and attributes properties to AGIReply Index: ReplyBuilderImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/ReplyBuilderImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ReplyBuilderImpl.java 9 Mar 2005 20:31:35 -0000 1.1 +++ ReplyBuilderImpl.java 11 Mar 2005 13:40:06 -0000 1.2 @@ -33,7 +33,13 @@ public class ReplyBuilderImpl implements private static final Pattern STATUS_PATTERN = Pattern .compile("^(\\d{3})[ -]"); private static final Pattern RESULT_PATTERN = Pattern - .compile("^200 result=(\\d+) "); + .compile("^200 result=(\\S+)"); + private static final Pattern PARENTHESIS_PATTERN = Pattern + .compile("^200 result=\\S+ \\((.*)\\)"); + private static final Pattern ADDITIONAL_ATTRIBUTES_PATTERN = Pattern + .compile("^200 result=\\S+( \\(.*\\) )?(.+)$"); + private static final Pattern ADDITIONAL_ATTRIBUTE_PATTERN = Pattern + .compile("(\\S+)=(\\S+)"); private static final Pattern SYNOPSIS_PATTERN = Pattern .compile("^\\s*Usage:\\s*(.*)\\s*$"); private static final String END_OF_PROPER_USAGE = "520 End of proper usage."; @@ -42,8 +48,7 @@ public class ReplyBuilderImpl implements { String firstLine; AGIReply reply; - Matcher statusMatcher; - Matcher resultMatcher; + Matcher matcher; if (lines.size() == 0) { @@ -54,19 +59,47 @@ public class ReplyBuilderImpl implements firstLine = (String) lines.get(0); - statusMatcher = STATUS_PATTERN.matcher(firstLine); - if (statusMatcher.find()) + matcher = STATUS_PATTERN.matcher(firstLine); + if (matcher.find()) { - reply.setStatus(Integer.parseInt(statusMatcher.group(1))); + reply.setStatus(Integer.parseInt(matcher.group(1))); } - resultMatcher = RESULT_PATTERN.matcher(firstLine); - if (resultMatcher.find()) + if (reply.getStatus() == AGIReply.SC_SUCCESS) { - reply.setResult(Integer.parseInt(resultMatcher.group(1))); - } - if (reply.getStatus() == AGIReply.SC_INVALID_COMMAND_SYNTAX) + matcher = RESULT_PATTERN.matcher(firstLine); + if (matcher.find()) + { + reply.setResult(matcher.group(1)); + } + + matcher = PARENTHESIS_PATTERN.matcher(firstLine); + if (matcher.find()) + { + reply.setExtra(matcher.group(1)); + } + + matcher = ADDITIONAL_ATTRIBUTES_PATTERN.matcher(firstLine); + if (matcher.find()) + { + String s; + Matcher attributeMatcher; + + s = matcher.group(2); + attributeMatcher = ADDITIONAL_ATTRIBUTE_PATTERN.matcher(s); + while (attributeMatcher.find()) + { + String key; + String value; + + key = attributeMatcher.group(1); + value = attributeMatcher.group(2); + reply.setAttribute(key, value); + } + } + } + else if (reply.getStatus() == AGIReply.SC_INVALID_COMMAND_SYNTAX) { StringBuffer usageSB; |
From: Stefan R. <sr...@us...> - 2005-03-11 13:40:24
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25827/src/test/net/sf/asterisk/fastagi Modified Files: AGIChannelImplTest.java ReplyBuilderImplTest.java AGIReaderImplTest.java Log Message: Added extra and attributes properties to AGIReply Index: AGIChannelImplTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/AGIChannelImplTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIChannelImplTest.java 10 Mar 2005 23:57:07 -0000 1.1 +++ AGIChannelImplTest.java 11 Mar 2005 13:40:06 -0000 1.2 @@ -49,7 +49,7 @@ public class AGIChannelImplTest extends reply = new AGIReply(); reply.setStatus(AGIReply.SC_SUCCESS); - reply.setResult(0); + reply.setResult("0"); command = new NoopCommand(); Index: ReplyBuilderImplTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/ReplyBuilderImplTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ReplyBuilderImplTest.java 9 Mar 2005 23:42:09 -0000 1.2 +++ ReplyBuilderImplTest.java 11 Mar 2005 13:40:06 -0000 1.3 @@ -38,13 +38,84 @@ public class ReplyBuilderImplTest extend { AGIReply reply; + lines.add("200 result=49"); + + reply = replyBuilder.buildReply(lines); + + assertEquals("Incorrect status", AGIReply.SC_SUCCESS, reply.getStatus()); + assertEquals("Incorrect result", 49, reply.getResultCode()); + assertEquals("Incorrect result as character", '1', reply + .getResultCodeAsChar()); + assertEquals("Incorrect result when get via getAttribute()", "49", + reply.getAttribute("result")); + } + + public void testBuildReplyWithAdditionalAttribute() + { + AGIReply reply; + lines.add("200 result=49 endpos=2240"); reply = replyBuilder.buildReply(lines); assertEquals("Incorrect status", AGIReply.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 49, reply.getResult()); - assertEquals("Incorrect result as character", '1', reply.getResultAsChar()); + assertEquals("Incorrect result", 49, reply.getResultCode()); + assertEquals("Incorrect result as character", '1', reply + .getResultCodeAsChar()); + assertEquals("Incorrect result when get via getAttribute()", "49", + reply.getAttribute("result")); + assertEquals("Incorrect endpos attribute", "2240", reply + .getAttribute("endpos")); + } + + public void testBuildReplyWithMultipleAdditionalAttribute() + { + AGIReply reply; + + lines.add("200 result=49 startpos=1234 endpos=2240"); + + reply = replyBuilder.buildReply(lines); + + assertEquals("Incorrect status", AGIReply.SC_SUCCESS, reply.getStatus()); + assertEquals("Incorrect result", 49, reply.getResultCode()); + assertEquals("Incorrect result as character", '1', reply + .getResultCodeAsChar()); + assertEquals("Incorrect result when get via getAttribute()", "49", + reply.getAttribute("result")); + assertEquals("Incorrect startpos attribute", "1234", reply + .getAttribute("startpos")); + assertEquals("Incorrect endpos attribute", "2240", reply + .getAttribute("endpos")); + } + + public void testBuildReplyWithParenthesis() + { + AGIReply reply; + + lines.add("200 result=1 ((hello)(world))"); + + reply = replyBuilder.buildReply(lines); + + assertEquals("Incorrect status", AGIReply.SC_SUCCESS, reply.getStatus()); + assertEquals("Incorrect result", 1, reply.getResultCode()); + assertEquals("Incorrect parenthesis", "(hello)(world)", reply + .getExtra()); + } + + public void testBuildReplyWithAdditionalAttributeAndParenthesis() + { + AGIReply reply; + + lines.add("200 result=1 ((hello)(world)) endpos=2240"); + + reply = replyBuilder.buildReply(lines); + + assertEquals("Incorrect status", AGIReply.SC_SUCCESS, reply.getStatus()); + assertEquals("Incorrect result", 1, reply.getResultCode()); + assertEquals("Incorrect parenthesis", "(hello)(world)", reply + .getExtra()); + assertEquals("Incorrect endpos attribute", "2240", reply + .getAttribute("endpos")); } public void testBuildReplyInvalidOrUnknownCommand() Index: AGIReaderImplTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/AGIReaderImplTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AGIReaderImplTest.java 11 Mar 2005 00:23:25 -0000 1.3 +++ AGIReaderImplTest.java 11 Mar 2005 13:40:06 -0000 1.4 @@ -75,7 +75,7 @@ public class AGIReaderImplTest extends T reply = agiReader.readReply(); assertEquals("Incorrect status", AGIReply.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 49, reply.getResult()); + assertEquals("Incorrect result", 49, reply.getResultCode()); socketMC.verify(); } |
From: Stefan R. <sr...@us...> - 2005-03-11 09:37:51
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23195/src/java/net/sf/asterisk/fastagi Modified Files: AGIReader.java AGIChannelImpl.java AGIWriter.java AGIConnectionHandler.java AbstractAGIScript.java AGIReaderImpl.java AGIWriterImpl.java AGIException.java AGIChannel.java AGIScript.java Added Files: AGINetworkException.java Log Message: Added AGINetworkException Wrapped IOExceptions in new AGINetworkException --- NEW FILE: AGINetworkException.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; /** * The AGINetworkException usally wraps an IOException denoting a network * problem when talking to the Asterisk server. * * @author srt * @version $Id: AGINetworkException.java,v 1.1 2005/03/11 09:37:39 srt Exp $ */ public class AGINetworkException extends AGIException { /** * Serial version identifier. */ private static final long serialVersionUID = 3256445789629723703L; public AGINetworkException(String message, Throwable cause) { super(message, cause); } } Index: AGIReader.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIReader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- AGIReader.java 11 Mar 2005 00:23:25 -0000 1.4 +++ AGIReader.java 11 Mar 2005 09:37:37 -0000 1.5 @@ -16,8 +16,6 @@ */ package net.sf.asterisk.fastagi; -import java.io.IOException; - import net.sf.asterisk.fastagi.reply.AGIReply; /** @@ -33,16 +31,15 @@ public interface AGIReader * Reads the initial request data from Asterisk. * * @return the request read. - * @throws IOException if the request can't be read. + * @throws AGIException if the request can't be read. */ - AGIRequest readRequest() throws IOException; + AGIRequest readRequest() throws AGIException; /** * Reads one reply to an AGICommand from Asterisk. * * @return the reply read. - * @throws AGIHangupException if the channel has been hang up while reading the reply. - * @throws IOException if the reply can't be read. + * @throws AGIException if the reply can't be read. */ - AGIReply readReply() throws AGIHangupException, IOException; + AGIReply readReply() throws AGIException; } Index: AGIChannelImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIChannelImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AGIChannelImpl.java 11 Mar 2005 00:23:25 -0000 1.2 +++ AGIChannelImpl.java 11 Mar 2005 09:37:39 -0000 1.3 @@ -16,8 +16,6 @@ */ package net.sf.asterisk.fastagi; -import java.io.IOException; - import net.sf.asterisk.fastagi.command.AGICommand; import net.sf.asterisk.fastagi.reply.AGIReply; import net.sf.asterisk.io.SocketConnectionFacade; @@ -47,7 +45,7 @@ public class AGIChannelImpl implements A this.agiReader = agiReader; } - public synchronized AGIReply sendCommand(AGICommand command) throws AGIException, IOException + public synchronized AGIReply sendCommand(AGICommand command) throws AGIException { AGIReply reply; Index: AGIWriter.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIWriter.java 9 Mar 2005 23:52:48 -0000 1.1 +++ AGIWriter.java 11 Mar 2005 09:37:39 -0000 1.2 @@ -16,8 +16,6 @@ */ package net.sf.asterisk.fastagi; -import java.io.IOException; - import net.sf.asterisk.fastagi.command.AGICommand; /** @@ -32,7 +30,7 @@ public interface AGIWriter * Sends the given command to the Asterisk server. * * @param command the command to send. - * @throws IOException if the command can't be sent. + * @throws AGIException if the command can't be sent. */ - void sendCommand(AGICommand command) throws IOException; + void sendCommand(AGICommand command) throws AGIException; } Index: AGIConnectionHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIConnectionHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- AGIConnectionHandler.java 11 Mar 2005 00:23:25 -0000 1.5 +++ AGIConnectionHandler.java 11 Mar 2005 09:37:39 -0000 1.6 @@ -99,14 +99,14 @@ public class AGIConnectionHandler implem + request.getRequestURL()); } } - catch (IOException e) - { - logger.error("IOException while handling request", e); - } catch (AGIException e) { logger.error("AGIException while handling request: " + e.getMessage()); } + catch (Exception e) + { + logger.error("Unexpected Exception while handling request", e); + } finally { try Index: AbstractAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AbstractAGIScript.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AbstractAGIScript.java 11 Mar 2005 00:23:25 -0000 1.2 +++ AbstractAGIScript.java 11 Mar 2005 09:37:39 -0000 1.3 @@ -16,8 +16,6 @@ */ package net.sf.asterisk.fastagi; -import java.io.IOException; - import net.sf.asterisk.fastagi.command.AnswerCommand; import net.sf.asterisk.fastagi.command.HangupCommand; @@ -35,12 +33,9 @@ public abstract class AbstractAGIScript * * @param channel the channel as received by the service method. * - * @throws AGIException if the command can't be sent to Asterisk because the - * channel was hung up. - * @throws IOException if the command can't be sent to Asterisk due to - * network problems. + * @throws AGIException if the command can't be sent to Asterisk. */ - protected void answer(AGIChannel channel) throws AGIException, IOException + protected void answer(AGIChannel channel) throws AGIException { channel.sendCommand(new AnswerCommand()); } @@ -50,12 +45,9 @@ public abstract class AbstractAGIScript * * @param channel the channel as received by the service method. * - * @throws AGIException if the command can't be sent to Asterisk because the - * channel was already hung up. - * @throws IOException if the command can't be sent to Asterisk due to - * network problems. + * @throws AGIException if the command can't be sent to Asterisk. */ - protected void hangup(AGIChannel channel) throws AGIException, IOException + protected void hangup(AGIChannel channel) throws AGIException { channel.sendCommand(new HangupCommand()); } Index: AGIReaderImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIReaderImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AGIReaderImpl.java 11 Mar 2005 00:23:25 -0000 1.3 +++ AGIReaderImpl.java 11 Mar 2005 09:37:39 -0000 1.4 @@ -42,30 +42,39 @@ public class AGIReaderImpl implements AG this.requestBuilder = new RequestBuilderImpl(); } - public AGIRequest readRequest() throws IOException + public AGIRequest readRequest() throws AGIException { AGIRequest request; String line; List lines; - + lines = new ArrayList(); - - while ((line = socket.readLine()) != null) + + try { - if (line.length() == 0) + while ((line = socket.readLine()) != null) { - break; + if (line.length() == 0) + { + break; + } + + lines.add(line); } - - lines.add(line); } - + catch (IOException e) + { + throw new AGINetworkException( + "Unable to read request from Asterisk: " + e.getMessage(), + e); + } + request = requestBuilder.buildRequest(lines); - + return request; } - - public AGIReply readReply() throws IOException, AGIHangupException + + public AGIReply readReply() throws AGIException { AGIReply reply; List lines; @@ -73,28 +82,45 @@ public class AGIReaderImpl implements AG lines = new ArrayList(); - line = socket.readLine(); - + try + { + line = socket.readLine(); + } + catch (IOException e) + { + throw new AGINetworkException( + "Unable to read reply from Asterisk: " + e.getMessage(), e); + } + if (line == null) { throw new AGIHangupException(); } - + lines.add(line); // read synopsis and usage if statuscode is 520 if (line.startsWith(Integer .toString(AGIReply.SC_INVALID_COMMAND_SYNTAX))) { - while ((line = socket.readLine()) != null) + try { - lines.add(line); - if (line.startsWith(Integer - .toString(AGIReply.SC_INVALID_COMMAND_SYNTAX))) + while ((line = socket.readLine()) != null) { - break; + lines.add(line); + if (line.startsWith(Integer + .toString(AGIReply.SC_INVALID_COMMAND_SYNTAX))) + { + break; + } } } + catch (IOException e) + { + throw new AGINetworkException( + "Unable to read reply from Asterisk: " + e.getMessage(), + e); + } } reply = replyBuilder.buildReply(lines); Index: AGIWriterImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIWriterImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIWriterImpl.java 9 Mar 2005 23:52:48 -0000 1.1 +++ AGIWriterImpl.java 11 Mar 2005 09:37:39 -0000 1.2 @@ -36,9 +36,17 @@ public class AGIWriterImpl implements AG this.socket = socket; } - public void sendCommand(AGICommand command) throws IOException + public void sendCommand(AGICommand command) throws AGIException { - socket.write(command.buildCommand() + "\n"); - socket.flush(); + try + { + socket.write(command.buildCommand() + "\n"); + socket.flush(); + } + catch (IOException e) + { + throw new AGINetworkException( + "Unable to send command to Asterisk: " + e.getMessage(), e); + } } } Index: AGIException.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIException.java 11 Mar 2005 00:23:25 -0000 1.1 +++ AGIException.java 11 Mar 2005 09:37:39 -0000 1.2 @@ -42,4 +42,15 @@ public abstract class AGIException exten super(message); } + + /** + * Creates a new AGIExeption with the given message and cause. + * + * @param message a message decribing the AGIException. + * @param cause the throwable that caused this exception to be thrown. + */ + public AGIException(String message, Throwable cause) + { + super(message, cause); + } } Index: AGIChannel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIChannel.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AGIChannel.java 11 Mar 2005 00:23:25 -0000 1.2 +++ AGIChannel.java 11 Mar 2005 09:37:39 -0000 1.3 @@ -16,8 +16,6 @@ */ package net.sf.asterisk.fastagi; -import java.io.IOException; - import net.sf.asterisk.fastagi.command.AGICommand; import net.sf.asterisk.fastagi.reply.AGIReply; @@ -38,9 +36,8 @@ public interface AGIChannel * @param command the command to send. * @return the reply of the asterisk server containing the return value. * - * @throws AGIException if the command can't be sent (for example because - * the channel has been hung up) - * @throws IOException if there is a network problem sending the command. + * @throws AGIException if the command can't be sent to Asterisk (for + * example because the channel has been hung up) */ - AGIReply sendCommand(AGICommand command) throws AGIException, IOException; + AGIReply sendCommand(AGICommand command) throws AGIException; } Index: AGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIScript.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- AGIScript.java 11 Mar 2005 00:23:25 -0000 1.5 +++ AGIScript.java 11 Mar 2005 09:37:39 -0000 1.6 @@ -16,8 +16,6 @@ */ package net.sf.asterisk.fastagi; -import java.io.IOException; - /** * AGIScripts are used by the AsteriskServer to handle AGIRequests received from * the Asterisk server.<br> @@ -36,13 +34,12 @@ public interface AGIScript * AGIScript should handle an incoming AGIRequest. * * @param request the initial data received from Asterisk when requesting - * this script. + * this script. * @param channel a handle to communicate with Asterisk such as sending - * commands to the channel sending the request. + * commands to the channel sending the request. * * @throws AGIException any exception thrown by your script will be logged. - * @throws IOException any exception thrown by your script will be logged. */ void service(final AGIRequest request, final AGIChannel channel) - throws AGIException, IOException; + throws AGIException; } |
From: Stefan R. <sr...@us...> - 2005-03-11 01:17:13
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15391/src/java/net/sf/asterisk/fastagi Modified Files: AGIConnectionHandler.java AGIScript.java Added Files: AGIChannelImpl.java AbstractAGIScript.java AGIChannel.java Removed Files: AGIResponse.java AGIResponseImpl.java Log Message: Renamed AGIResponse to AGIChannel --- NEW FILE: AGIChannelImpl.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; import java.io.IOException; import net.sf.asterisk.fastagi.command.AGICommand; import net.sf.asterisk.fastagi.reply.AGIReply; import net.sf.asterisk.io.SocketConnectionFacade; /** * Default implementation of the AGIChannel interface. * * @author srt * @version $Id: AGIChannelImpl.java,v 1.1 2005/03/10 23:57:06 srt Exp $ */ public class AGIChannelImpl implements AGIChannel { private AGIWriter agiWriter; private AGIReader agiReader; private SocketConnectionFacade socket; public AGIChannelImpl(SocketConnectionFacade socket) { this.socket = socket; this.agiWriter = new AGIWriterImpl(socket); this.agiReader = new AGIReaderImpl(socket); } public AGIChannelImpl(AGIWriter agiWriter, AGIReader agiReader) { this.agiWriter = agiWriter; this.agiReader = agiReader; } public synchronized AGIReply sendCommand(AGICommand command) throws IOException { AGIReply reply; agiWriter.sendCommand(command); reply = agiReader.readReply(); return reply; } } --- NEW FILE: AbstractAGIScript.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; import java.io.IOException; import net.sf.asterisk.fastagi.command.AnswerCommand; import net.sf.asterisk.fastagi.command.HangupCommand; /** * The AbstractAGIScript provides some convinience methods to make it easier to * write custom AGIScripts. * * @author srt * @version $Id: AbstractAGIScript.java,v 1.1 2005/03/10 23:57:06 srt Exp $ */ public abstract class AbstractAGIScript implements AGIScript { /** * Answers the channel. * * @param channel the channel as received by the service method. * @throws IOException if the command can't be sent to Asterisk. */ protected void answer(AGIChannel channel) throws IOException { channel.sendCommand(new AnswerCommand()); } /** * Hangs the channel up. * * @param channel the channel as received by the service method. * @throws IOException if the command can't be sent to Asterisk. */ protected void hangup(AGIChannel channel) throws IOException { channel.sendCommand(new HangupCommand()); } } --- NEW FILE: AGIChannel.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; import java.io.IOException; import net.sf.asterisk.fastagi.command.AGICommand; import net.sf.asterisk.fastagi.reply.AGIReply; /** * Provides the functionality to send AGICommands to Asterisk while handling an * AGIRequest.<br> * This interface is supposed to be used by AGIScripts for interaction with the * Asterisk server. * * @author srt * @version $Id: AGIChannel.java,v 1.1 2005/03/10 23:57:06 srt Exp $ */ public interface AGIChannel { /** * Sends a command to asterisk and returns the corresponding reply. * * @param command the command to send. * @return the reply of the asterisk server containing the return value. * * @throws IOException if there is a problem sending the command. */ AGIReply sendCommand(AGICommand command) throws IOException; } Index: AGIConnectionHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIConnectionHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AGIConnectionHandler.java 10 Mar 2005 23:34:13 -0000 1.3 +++ AGIConnectionHandler.java 10 Mar 2005 23:57:06 -0000 1.4 @@ -77,21 +77,21 @@ public class AGIConnectionHandler implem AGIReader reader; AGIWriter writer; AGIRequest request; - AGIResponse response; + AGIChannel channel; AGIScript script; reader = createReader(); writer = createWriter(); request = reader.readRequest(); - response = new AGIResponseImpl(writer, reader); + channel = new AGIChannelImpl(writer, reader); script = mappingStrategy.determineScript(request); if (script != null) { logger.info("Running AGIScript " + script.getClass().getName()); - script.service(request, response); + script.service(request, channel); } else { Index: AGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIScript.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AGIScript.java 10 Mar 2005 23:35:04 -0000 1.3 +++ AGIScript.java 10 Mar 2005 23:57:06 -0000 1.4 @@ -37,9 +37,9 @@ public interface AGIScript * * @param request the initial data received from Asterisk when requesting * this script. - * @param response a handle to communicate with Asterisk such as sending - * commands in response to the request. + * @param channel a handle to communicate with Asterisk such as sending + * commands to the channel sending the request. * @throws IOException if there is a problem with the network connection. */ - void service(final AGIRequest request, final AGIResponse response) throws IOException; + void service(final AGIRequest request, final AGIChannel channel) throws IOException; } --- AGIResponse.java DELETED --- --- AGIResponseImpl.java DELETED --- |
From: Stefan R. <sr...@us...> - 2005-03-11 00:23:38
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22390/src/java/net/sf/asterisk/fastagi Modified Files: AGIReader.java AGIChannelImpl.java AGIConnectionHandler.java AbstractAGIScript.java AGIReaderImpl.java AGIChannel.java AGIScript.java Added Files: AGIHangupException.java AGIException.java Log Message: Added AGIExceptions --- NEW FILE: AGIHangupException.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; /** * The AGIHangupException is thrown if the channel has been hang up while * processing the AGIRequest. * * @author srt * @version $Id: AGIHangupException.java,v 1.1 2005/03/11 00:23:25 srt Exp $ */ public class AGIHangupException extends AGIException { /** * Serial version identifier. */ private static final long serialVersionUID = 3256444698691252274L; public AGIHangupException() { super("Channel was hang up."); } } --- NEW FILE: AGIException.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; /** * Abstract base class for all AGI specific exceptions. * * @author srt * @version $Id: AGIException.java,v 1.1 2005/03/11 00:23:25 srt Exp $ */ public abstract class AGIException extends Exception { /** * */ public AGIException() { super(); } /** * Creates a new AGIExeption with the given message. * * @param message a message decribing the AGIException. */ public AGIException(String message) { super(message); } } Index: AGIReader.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIReader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AGIReader.java 10 Mar 2005 13:45:23 -0000 1.3 +++ AGIReader.java 11 Mar 2005 00:23:25 -0000 1.4 @@ -41,7 +41,8 @@ public interface AGIReader * Reads one reply to an AGICommand from Asterisk. * * @return the reply read. + * @throws AGIHangupException if the channel has been hang up while reading the reply. * @throws IOException if the reply can't be read. */ - AGIReply readReply() throws IOException; + AGIReply readReply() throws AGIHangupException, IOException; } Index: AGIChannelImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIChannelImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIChannelImpl.java 10 Mar 2005 23:57:06 -0000 1.1 +++ AGIChannelImpl.java 11 Mar 2005 00:23:25 -0000 1.2 @@ -47,7 +47,7 @@ public class AGIChannelImpl implements A this.agiReader = agiReader; } - public synchronized AGIReply sendCommand(AGICommand command) throws IOException + public synchronized AGIReply sendCommand(AGICommand command) throws AGIException, IOException { AGIReply reply; Index: AGIConnectionHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIConnectionHandler.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- AGIConnectionHandler.java 10 Mar 2005 23:57:06 -0000 1.4 +++ AGIConnectionHandler.java 11 Mar 2005 00:23:25 -0000 1.5 @@ -103,6 +103,10 @@ public class AGIConnectionHandler implem { logger.error("IOException while handling request", e); } + catch (AGIException e) + { + logger.error("AGIException while handling request: " + e.getMessage()); + } finally { try Index: AbstractAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AbstractAGIScript.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AbstractAGIScript.java 10 Mar 2005 23:57:06 -0000 1.1 +++ AbstractAGIScript.java 11 Mar 2005 00:23:25 -0000 1.2 @@ -34,9 +34,13 @@ public abstract class AbstractAGIScript * Answers the channel. * * @param channel the channel as received by the service method. - * @throws IOException if the command can't be sent to Asterisk. + * + * @throws AGIException if the command can't be sent to Asterisk because the + * channel was hung up. + * @throws IOException if the command can't be sent to Asterisk due to + * network problems. */ - protected void answer(AGIChannel channel) throws IOException + protected void answer(AGIChannel channel) throws AGIException, IOException { channel.sendCommand(new AnswerCommand()); } @@ -45,9 +49,13 @@ public abstract class AbstractAGIScript * Hangs the channel up. * * @param channel the channel as received by the service method. - * @throws IOException if the command can't be sent to Asterisk. + * + * @throws AGIException if the command can't be sent to Asterisk because the + * channel was already hung up. + * @throws IOException if the command can't be sent to Asterisk due to + * network problems. */ - protected void hangup(AGIChannel channel) throws IOException + protected void hangup(AGIChannel channel) throws AGIException, IOException { channel.sendCommand(new HangupCommand()); } Index: AGIReaderImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIReaderImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AGIReaderImpl.java 10 Mar 2005 13:45:23 -0000 1.2 +++ AGIReaderImpl.java 11 Mar 2005 00:23:25 -0000 1.3 @@ -65,7 +65,7 @@ public class AGIReaderImpl implements AG return request; } - public AGIReply readReply() throws IOException + public AGIReply readReply() throws IOException, AGIHangupException { AGIReply reply; List lines; @@ -74,6 +74,12 @@ public class AGIReaderImpl implements AG lines = new ArrayList(); line = socket.readLine(); + + if (line == null) + { + throw new AGIHangupException(); + } + lines.add(line); // read synopsis and usage if statuscode is 520 Index: AGIChannel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIChannel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIChannel.java 10 Mar 2005 23:57:06 -0000 1.1 +++ AGIChannel.java 11 Mar 2005 00:23:25 -0000 1.2 @@ -38,7 +38,9 @@ public interface AGIChannel * @param command the command to send. * @return the reply of the asterisk server containing the return value. * - * @throws IOException if there is a problem sending the command. + * @throws AGIException if the command can't be sent (for example because + * the channel has been hung up) + * @throws IOException if there is a network problem sending the command. */ - AGIReply sendCommand(AGICommand command) throws IOException; + AGIReply sendCommand(AGICommand command) throws AGIException, IOException; } Index: AGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIScript.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- AGIScript.java 10 Mar 2005 23:57:06 -0000 1.4 +++ AGIScript.java 11 Mar 2005 00:23:25 -0000 1.5 @@ -36,10 +36,13 @@ public interface AGIScript * AGIScript should handle an incoming AGIRequest. * * @param request the initial data received from Asterisk when requesting - * this script. + * this script. * @param channel a handle to communicate with Asterisk such as sending - * commands to the channel sending the request. - * @throws IOException if there is a problem with the network connection. + * commands to the channel sending the request. + * + * @throws AGIException any exception thrown by your script will be logged. + * @throws IOException any exception thrown by your script will be logged. */ - void service(final AGIRequest request, final AGIChannel channel) throws IOException; + void service(final AGIRequest request, final AGIChannel channel) + throws AGIException, IOException; } |
From: Stefan R. <sr...@us...> - 2005-03-11 00:23:37
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22390/src/test/net/sf/asterisk/fastagi Modified Files: AGIReaderImplTest.java Log Message: Added AGIExceptions Index: AGIReaderImplTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/AGIReaderImplTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AGIReaderImplTest.java 10 Mar 2005 13:45:23 -0000 1.2 +++ AGIReaderImplTest.java 11 Mar 2005 00:23:25 -0000 1.3 @@ -127,4 +127,24 @@ public class AGIReaderImplTest extends T socketMC.verify(); } + + public void testReadReplyWhenHungUp() throws Exception + { + socket.readLine(); + socketMC.setReturnValue(null); + + socketMC.replay(); + + try + { + agiReader.readReply(); + fail("Must throw AGIHangupException"); + } + catch (AGIHangupException e) + { + } + + socketMC.verify(); + } + } |
From: Stefan R. <sr...@us...> - 2005-03-11 00:13:47
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15391/src/test/net/sf/asterisk/fastagi Modified Files: HelloAGIScript.java Added Files: AGIChannelImplTest.java Removed Files: AGIResponseImplTest.java Log Message: Renamed AGIResponse to AGIChannel --- NEW FILE: AGIChannelImplTest.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; import net.sf.asterisk.fastagi.command.NoopCommand; import net.sf.asterisk.fastagi.reply.AGIReply; import org.easymock.MockControl; import junit.framework.TestCase; public class AGIChannelImplTest extends TestCase { private MockControl agiWriterMC; private AGIWriter agiWriter; private MockControl agiReaderMC; private AGIReader agiReader; private AGIChannel agiChannel; protected void setUp() throws Exception { super.setUp(); this.agiWriterMC = MockControl.createControl(AGIWriter.class); this.agiWriter = (AGIWriter) agiWriterMC.getMock(); this.agiReaderMC = MockControl.createControl(AGIReader.class); this.agiReader = (AGIReader) agiReaderMC.getMock(); this.agiChannel = new AGIChannelImpl(agiWriter, agiReader); } public void testSendCommand() throws Exception { AGIReply reply; NoopCommand command; reply = new AGIReply(); reply.setStatus(AGIReply.SC_SUCCESS); reply.setResult(0); command = new NoopCommand(); agiWriter.sendCommand(command); agiReader.readReply(); agiReaderMC.setReturnValue(reply); agiWriterMC.replay(); agiReaderMC.replay(); assertEquals(reply, agiChannel.sendCommand(command)); agiWriterMC.verify(); agiReaderMC.verify(); } } Index: HelloAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/HelloAGIScript.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- HelloAGIScript.java 10 Mar 2005 21:31:31 -0000 1.1 +++ HelloAGIScript.java 10 Mar 2005 23:57:07 -0000 1.2 @@ -29,7 +29,7 @@ public class HelloAGIScript implements A } - public void service(AGIRequest request, AGIResponse response) + public void service(AGIRequest request, AGIChannel channel) { return; } --- AGIResponseImplTest.java DELETED --- |
From: Stefan R. <sr...@us...> - 2005-03-10 23:42:48
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11871/src/java/net/sf/asterisk/fastagi Modified Files: DefaultAGIServer.java Log Message: Added configuration via fastagi.properties Index: DefaultAGIServer.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/DefaultAGIServer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- DefaultAGIServer.java 10 Mar 2005 21:31:30 -0000 1.3 +++ DefaultAGIServer.java 10 Mar 2005 23:42:35 -0000 1.4 @@ -17,6 +17,8 @@ package net.sf.asterisk.fastagi; import java.io.IOException; +import java.util.MissingResourceException; +import java.util.ResourceBundle; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,6 +31,11 @@ import net.sf.asterisk.util.ThreadPool; public class DefaultAGIServer implements AGIServer { /** + * The default name of the resource bundle that contains the config. + */ + private static final String DEFAULT_CONFIG_RESOURCE_BUNDLE_NAME = "fastagi"; + + /** * The default bind port. */ private static final int DEFAULT_BIND_PORT = 4573; @@ -82,6 +89,8 @@ public class DefaultAGIServer implements this.bindPort = DEFAULT_BIND_PORT; this.poolSize = DEFAULT_POOL_SIZE; this.mappingStrategy = new ResourceBundleMappingStrategy(); + + loadConfig(); } /** @@ -117,6 +126,45 @@ public class DefaultAGIServer implements this.mappingStrategy = mappingStrategy; } + private void loadConfig() + { + ResourceBundle resourceBundle; + + try + { + resourceBundle = ResourceBundle + .getBundle(DEFAULT_CONFIG_RESOURCE_BUNDLE_NAME); + } + catch (MissingResourceException e) + { + return; + } + + try + { + String bindPortString; + + bindPortString = resourceBundle.getString("bindPort"); + bindPort = Integer.parseInt(bindPortString); + } + catch(Exception e) + { + //swallow + } + + try + { + String poolSizeString; + + poolSizeString = resourceBundle.getString("poolSize"); + poolSize = Integer.parseInt(poolSizeString); + } + catch(Exception e) + { + //swallow + } + } + protected ServerSocketFacade createServerSocket() throws IOException { return new ServerSocketFacadeImpl(bindPort, 0, null); |
From: Stefan R. <sr...@us...> - 2005-03-10 23:35:18
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9847/src/java/net/sf/asterisk/fastagi Modified Files: AGIScript.java Log Message: Added throws IOException to service() Index: AGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIScript.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AGIScript.java 8 Mar 2005 16:48:34 -0000 1.2 +++ AGIScript.java 10 Mar 2005 23:35:04 -0000 1.3 @@ -16,6 +16,8 @@ */ package net.sf.asterisk.fastagi; +import java.io.IOException; + /** * AGIScripts are used by the AsteriskServer to handle AGIRequests received from * the Asterisk server.<br> @@ -37,6 +39,7 @@ public interface AGIScript * this script. * @param response a handle to communicate with Asterisk such as sending * commands in response to the request. + * @throws IOException if there is a problem with the network connection. */ - void service(final AGIRequest request, final AGIResponse response); + void service(final AGIRequest request, final AGIResponse response) throws IOException; } |
From: Stefan R. <sr...@us...> - 2005-03-10 23:34:25
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9561/src/java/net/sf/asterisk/fastagi Modified Files: AGIConnectionHandler.java Log Message: Added logging which script is run Index: AGIConnectionHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIConnectionHandler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AGIConnectionHandler.java 10 Mar 2005 16:36:43 -0000 1.2 +++ AGIConnectionHandler.java 10 Mar 2005 23:34:13 -0000 1.3 @@ -90,6 +90,7 @@ public class AGIConnectionHandler implem if (script != null) { + logger.info("Running AGIScript " + script.getClass().getName()); script.service(request, response); } else |
From: Stefan R. <sr...@us...> - 2005-03-10 23:16:22
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4987 Modified Files: project.xml Log Message: Moved resources to src/resources Index: project.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/project.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -p -r1.8 -r1.9 --- project.xml 2 Mar 2005 23:28:17 -0000 1.8 +++ project.xml 10 Mar 2005 23:16:10 -0000 1.9 @@ -137,7 +137,12 @@ <excludes> <exclude>**/RepositoryTest.java</exclude> </excludes> - </unitTest> + <resources><resource> +<directory>${basedir}/src/resources/fastagi</directory> + <includes> + <include>test-mapping.properties</include> + </includes> </resource></resources> + </unitTest> </build> </project> |
From: Stefan R. <sr...@us...> - 2005-03-10 23:16:22
|
Update of /cvsroot/asterisk-java/asterisk-java/src/resources/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4987/src/resources/fastagi Added Files: test-mapping.properties Log Message: Moved resources to src/resources --- NEW FILE: test-mapping.properties --- hello.agi = net.sf.asterisk.fastagi.HelloAGIScript string.agi = java.lang.String nonexisting.agi = net.sf.asterisk.fastagi.NonExistingAGIScript |
From: Stefan R. <sr...@us...> - 2005-03-10 23:16:22
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4987/src/test/net/sf/asterisk/fastagi Modified Files: ResourceBundleMappingStrategyTest.java Removed Files: fastagi-mapping.properties Log Message: Moved resources to src/resources Index: ResourceBundleMappingStrategyTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/ResourceBundleMappingStrategyTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ResourceBundleMappingStrategyTest.java 10 Mar 2005 21:31:31 -0000 1.1 +++ ResourceBundleMappingStrategyTest.java 10 Mar 2005 23:16:11 -0000 1.2 @@ -26,8 +26,7 @@ public class ResourceBundleMappingStrate { super.setUp(); this.mappingStrategy = new ResourceBundleMappingStrategy(); - this.mappingStrategy - .setResourceBundleName("net.sf.asterisk.fastagi.fastagi-mapping"); + this.mappingStrategy.setResourceBundleName("test-mapping"); } public void testDetermineScript() @@ -56,7 +55,8 @@ public class ResourceBundleMappingStrate request = new AGIRequestImpl(); request.setScript("hello.agi"); - mappingStrategy.setResourceBundleName("net.sf.asterisk.fastagi.unavailable"); + mappingStrategy + .setResourceBundleName("net.sf.asterisk.fastagi.unavailable"); assertNull(mappingStrategy.determineScript(request)); } } --- fastagi-mapping.properties DELETED --- |
From: Stefan R. <sr...@us...> - 2005-03-10 23:15:29
|
Update of /cvsroot/asterisk-java/asterisk-java/src/resources/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4785/src/resources/fastagi Log Message: Directory /cvsroot/asterisk-java/asterisk-java/src/resources/fastagi added to the repository |
From: Stefan R. <sr...@us...> - 2005-03-10 23:15:29
|
Update of /cvsroot/asterisk-java/asterisk-java/src/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4785/src/resources Log Message: Directory /cvsroot/asterisk-java/asterisk-java/src/resources added to the repository |
From: Stefan R. <sr...@us...> - 2005-03-10 23:14:54
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4631/src/test/net/sf/asterisk/fastagi Modified Files: DefaultAGIServerTest.java Log Message: Fixed timing issues Index: DefaultAGIServerTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/DefaultAGIServerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- DefaultAGIServerTest.java 10 Mar 2005 16:36:43 -0000 1.2 +++ DefaultAGIServerTest.java 10 Mar 2005 23:14:43 -0000 1.3 @@ -27,15 +27,15 @@ import junit.framework.TestCase; public class DefaultAGIServerTest extends TestCase { private DefaultAGIServer server; - private MockControl serverSocketMC; - private ServerSocketFacade serverSocket; + private MockedServerSocketFacade serverSocket; + private MockControl socketMC; + private SocketConnectionFacade socket; protected void setUp() throws Exception { super.setUp(); - serverSocketMC = MockControl.createControl(ServerSocketFacade.class); - serverSocket = (ServerSocketFacade) serverSocketMC.getMock(); + serverSocket = new MockedServerSocketFacade(); server = new MockedDefaultAGIServer(); } @@ -47,9 +47,6 @@ public class DefaultAGIServerTest extend public void testStartup() throws Exception { - MockControl socketMC; - SocketConnectionFacade socket; - socketMC = MockControl.createControl(SocketConnectionFacade.class); socket = (SocketConnectionFacade) socketMC.getMock(); @@ -58,17 +55,15 @@ public class DefaultAGIServerTest extend socket.close(); socketMC.replay(); - serverSocket.accept(); - serverSocketMC.setReturnValue(socket); - serverSocket.accept(); - serverSocketMC.setThrowable(new IOException("Unexpected IOException")); - serverSocket.close(); - - serverSocketMC.replay(); - server.startup(); + + Thread.sleep(500); + + assertEquals("serverSocket.accept() not called 2 times", 2, + serverSocket.acceptCalls); + assertEquals("serverSocket.close() not called", 1, + serverSocket.closeCalls); - serverSocketMC.verify(); socketMC.verify(); } @@ -79,4 +74,36 @@ public class DefaultAGIServerTest extend return serverSocket; } } + + class MockedServerSocketFacade implements ServerSocketFacade + { + public int acceptCalls = 0; + public int closeCalls = 0; + + public SocketConnectionFacade accept() throws IOException + { + acceptCalls++; + try + { + Thread.sleep(100); + } + catch (InterruptedException e) + { + } + + if (acceptCalls == 1) + { + return socket; + } + else + { + throw new IOException("Provoked IOException"); + } + } + + public void close() throws IOException + { + closeCalls++; + } + } } |
From: Stefan R. <sr...@us...> - 2005-03-10 22:19:41
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22299/src/java/net/sf/asterisk/manager/event Modified Files: DialEvent.java Log Message: Fixed parameter names Index: DialEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/DialEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- DialEvent.java 10 Mar 2005 22:11:27 -0000 1.2 +++ DialEvent.java 10 Mar 2005 22:19:27 -0000 1.3 @@ -61,6 +61,8 @@ public class DialEvent extends ManagerEv private String destUniqueId; /** + * Creates a new DialEvent. + * * @param source */ public DialEvent(Object source) @@ -81,7 +83,7 @@ public class DialEvent extends ManagerEv /** * Sets the name of the source channel. * - * @param source the name of the source channel. + * @param src the name of the source channel. */ public void setSrc(String src) { @@ -163,9 +165,9 @@ public class DialEvent extends ManagerEv * * @param srcUniqueId the unique ID of the source channel. */ - public void setSrcUniqueId(String srcuniqueid) + public void setSrcUniqueId(String srcUniqueId) { - this.srcUniqueId = srcuniqueid; + this.srcUniqueId = srcUniqueId; } /** |
From: Stefan R. <sr...@us...> - 2005-03-10 22:12:23
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20225/src/java/net/sf/asterisk/io Modified Files: ServerSocketFacade.java Log Message: Fixed javadoc Index: ServerSocketFacade.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/io/ServerSocketFacade.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ServerSocketFacade.java 8 Mar 2005 16:48:35 -0000 1.1 +++ ServerSocketFacade.java 10 Mar 2005 22:12:13 -0000 1.2 @@ -28,7 +28,7 @@ public interface ServerSocketFacade /** * Waits for a new incoming connection. * - * @return + * @return the new connection. * @throws IOException */ SocketConnectionFacade accept() throws IOException; |
From: Stefan R. <sr...@us...> - 2005-03-10 22:11:38
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20008/src/java/net/sf/asterisk/manager/event Modified Files: DialEvent.java Log Message: Fixed parameter names Index: DialEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/DialEvent.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- DialEvent.java 2 Mar 2005 01:57:29 -0000 1.1 +++ DialEvent.java 10 Mar 2005 22:11:27 -0000 1.2 @@ -123,9 +123,9 @@ public class DialEvent extends ManagerEv * * @param callerId the caller*ID. */ - public void setCallerId(String callerid) + public void setCallerId(String callerId) { - this.callerId = callerid; + this.callerId = callerId; } /** @@ -139,11 +139,13 @@ public class DialEvent extends ManagerEv } /** - * Sets the callerId name. + * Sets the Caller*Id Name. + * + * @param callerIdName the Caller*Id Name to set. */ - public void setCallerIdName(String calleridname) + public void setCallerIdName(String callerIdName) { - this.callerIdName = calleridname; + this.callerIdName = callerIdName; } /** @@ -167,9 +169,9 @@ public class DialEvent extends ManagerEv } /** - * Returns the unique ID of the deistination channel. + * Returns the unique ID of the distination channel. * - * @return the unique ID of the deistination channel. + * @return the unique ID of the distination channel. */ public String getDestUniqueId() { @@ -181,8 +183,8 @@ public class DialEvent extends ManagerEv * * @param destUniqueId the unique ID of the distination channel. */ - public void setDestUniqueId(String destuniqueid) + public void setDestUniqueId(String destUniqueId) { - this.destUniqueId = destuniqueid; + this.destUniqueId = destUniqueId; } } |