[Asterisk-java-cvs] CVS: asterisk-java/src/java/net/sf/asterisk/manager DefaultAsteriskManager.java,
Brought to you by:
srt
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21466/src/java/net/sf/asterisk/manager Modified Files: DefaultAsteriskManager.java ManagerReader.java ChannelStateEnum.java Channel.java ManagerConnectionFactory.java Util.java TimeoutException.java ManagerConnection.java MultiAsterisksManager.java ManagerEventHandler.java AsteriskManager.java AuthenticationFailedException.java ManagerResponseHandler.java AsteriskServer.java ActionBuilder.java EventBuilder.java Queue.java DefaultManagerConnection.java Log Message: added license header Index: DefaultAsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultAsteriskManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- DefaultAsteriskManager.java 23 Feb 2005 12:45:20 -0000 1.1 +++ DefaultAsteriskManager.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Oct 28, 2004 */ package net.sf.asterisk.manager; @@ -62,7 +73,7 @@ public class DefaultAsteriskManager impl this.queues = Collections.synchronizedMap(new HashMap()); this.queuedEvents = Collections.synchronizedList(new ArrayList()); this.channelsInitialized = false; - //TODO fix detection of queuesInitialized + // TODO fix detection of queuesInitialized this.queuesInitialized = true; this.initialized = false; } @@ -104,8 +115,8 @@ public class DefaultAsteriskManager impl /** * Handles all events received from the asterisk server.<br> - * Events are queued until channels and queues are initialized and then - * delegated to the dispatchEvent method. + * Events are queued until channels and queues are initialized and then delegated to the + * dispatchEvent method. */ public void handleEvent(ManagerEvent event) { @@ -273,7 +284,7 @@ public class DefaultAsteriskManager impl } /** - * Resets the internal state when the connection to the asterisk server is lost. + * Resets the internal state when the connection to the asterisk server is lost. */ protected void handleDisconnectEvent(DisconnectEvent disconnectEvent) { @@ -281,7 +292,7 @@ public class DefaultAsteriskManager impl this.queues.clear(); this.queuedEvents.clear(); this.channelsInitialized = false; - //TODO fix detection of queuesInitialized + // TODO fix detection of queuesInitialized this.queuesInitialized = true; this.initialized = false; } @@ -371,7 +382,7 @@ public class DefaultAsteriskManager impl */ private Channel getChannelByName(String name) { - //TODO must get unique + // TODO must get unique Channel channel = null; Iterator channelIterator = channels.values().iterator(); while (channelIterator.hasNext()) Index: ManagerReader.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ManagerReader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ManagerReader.java 23 Feb 2005 12:45:20 -0000 1.1 +++ ManagerReader.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 22, 2004 */ package net.sf.asterisk.manager; @@ -26,10 +37,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * The ManagerReader is a Thread that reads events and responses from an asterisk - * server, parses them to the corresponding ManagerEvent and ManagerResponse objects and - * dispatches them via the associated DefaultManagerConnection. - * <br> + * The ManagerReader is a Thread that reads events and responses from an asterisk server, parses + * them to the corresponding ManagerEvent and ManagerResponse objects and dispatches them via the + * associated DefaultManagerConnection. <br> * This class is intended to be used only by the DefaultManagerConnection. * * @see net.sf.asterisk.manager.event.ManagerEvent @@ -61,9 +71,8 @@ class ManagerReader extends Thread } /** - * Reads line by line from the asterisk server, sets the protocol identifier - * as soon as it is received and dispatches the received - * events and responses via the associated connection. + * Reads line by line from the asterisk server, sets the protocol identifier as soon as it is + * received and dispatches the received events and responses via the associated connection. * * @see DefaultManagerConnection#dispatchEvent(ManagerEvent) * @see DefaultManagerConnection#dispatchResponse(ManagerResponse) @@ -80,7 +89,8 @@ class ManagerReader extends Thread { while ((line = reader.readLine()) != null && !die) { - // dirty hack for handling the CommandAction. Needs fix when manager protocol is enhanced. + // dirty hack for handling the CommandAction. Needs fix when manager protocol is + // enhanced. if (processingCommandResult) { if ("--END COMMAND--".equals(line)) Index: ChannelStateEnum.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ChannelStateEnum.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ChannelStateEnum.java 23 Feb 2005 12:45:20 -0000 1.1 +++ ChannelStateEnum.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Oct 29, 2004 */ package net.sf.asterisk.manager; @@ -13,12 +24,15 @@ import org.apache.commons.lang.enums.Enu /** * Enumeration that represents the state of a channel. - * + * * @author srt * @version $Id$ */ public class ChannelStateEnum extends Enum { + /** + * Serializable version identifier + */ private static final long serialVersionUID = 6436381500165485011L; public static final ChannelStateEnum DOWN = new ChannelStateEnum("Down"); public static final ChannelStateEnum OFF_HOOK = new ChannelStateEnum("OffHook"); Index: Channel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Channel.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- Channel.java 23 Feb 2005 21:33:10 -0000 1.2 +++ Channel.java 23 Feb 2005 22:50:57 -0000 1.3 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Oct 29, 2004 */ package net.sf.asterisk.manager; @@ -17,6 +28,9 @@ import org.apache.commons.lang.builder.T */ public class Channel implements Serializable { + /** + * Serializable version identifier + */ private static final long serialVersionUID = -6919877370396385380L; private AsteriskServer asteriskServer; @@ -64,6 +78,7 @@ public class Channel implements Serializ /** * Creates a new Channel. + * * @param name name of this channel, for example "SIP/1310-20da". * @param id unique id of this channel, for example "1099015093.165". */ @@ -75,6 +90,7 @@ public class Channel implements Serializ /** * Creates a new Channel on the given server. + * * @param name name of this channel, for example "SIP/1310-20da". * @param id unique id of this channel, for example "1099015093.165". * @param server the Asterisk server this channel exists on. @@ -88,6 +104,7 @@ public class Channel implements Serializ /** * Returns the Asterisk server. + * * @return the Asterisk server. */ public final AsteriskServer getAsteriskServer() @@ -97,6 +114,7 @@ public class Channel implements Serializ /** * Sets the Asterisk server. + * * @param asteriskServer the Asterisk server to set. */ public final void setAsteriskServer(final AsteriskServer asteriskServer) @@ -106,6 +124,7 @@ public class Channel implements Serializ /** * Returns the unique id of this channel, for example "1099015093.165". + * * @return the unique id of this channel. */ public final String getId() @@ -115,6 +134,7 @@ public class Channel implements Serializ /** * Returns the name of this channel, for example "SIP/1310-20da". + * * @return the name of this channel. */ public final String getName() @@ -124,6 +144,7 @@ public class Channel implements Serializ /** * Sets the name of this channel. + * * @param name the name of this channel. */ public final void setName(final String name) @@ -133,6 +154,7 @@ public class Channel implements Serializ /** * Returns the caller id of this channel. + * * @return the caller id of this channel. */ public final String getCallerId() @@ -142,6 +164,7 @@ public class Channel implements Serializ /** * Sets the caller id of this channel. + * * @param callerId the calleid id of this channel. */ public final void setCallerId(final String callerId) @@ -151,6 +174,7 @@ public class Channel implements Serializ /** * Returns the state of this channel. + * * @return the state of this channel. */ public final ChannelStateEnum getState() @@ -160,6 +184,7 @@ public class Channel implements Serializ /** * Sets the state of this channel. + * * @param state the state of this channel. */ public final void setState(final ChannelStateEnum state) @@ -169,6 +194,7 @@ public class Channel implements Serializ /** * Returns the account code used to bill this channel. + * * @return the account code used to bill this channel. */ public final String getAccount() @@ -178,6 +204,7 @@ public class Channel implements Serializ /** * Sets the account code used to bill this channel. + * * @param account the account code used to bill this channel. */ public final void setAccount(final String account) @@ -237,6 +264,7 @@ public class Channel implements Serializ /** * Returns the date this channel has been created. + * * @return the date this channel has been created. */ public final Date getDateOfCreation() @@ -246,6 +274,7 @@ public class Channel implements Serializ /** * Sets the date this channel has been created. + * * @param dateOfCreation the date this channel has been created. */ public final void setDateOfCreation(final Date dateOfCreation) @@ -254,9 +283,10 @@ public class Channel implements Serializ } /** - * Returns the channel this channel is bridged with, if any. + * Returns the channel this channel is bridged with, if any. + * * @return the channel this channel is bridged with, or <code>null</code> if this channel is - * currently not bridged to another channel. + * currently not bridged to another channel. */ public final Channel getLinkedChannel() { @@ -265,6 +295,7 @@ public class Channel implements Serializ /** * Sets the channel this channel is bridged with. + * * @param linkedChannel the channel this channel is bridged with. */ public final void setLinkedChannel(final Channel linkedChannel) Index: ManagerConnectionFactory.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ManagerConnectionFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ManagerConnectionFactory.java 23 Feb 2005 12:45:20 -0000 1.1 +++ ManagerConnectionFactory.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 23, 2004 */ package net.sf.asterisk.manager; @@ -29,8 +40,8 @@ public class ManagerConnectionFactory } /** - * Returns a new ManagerConnection to an asterisk server running on localhost with - * the call manager interface listening on its default port 5038. + * Returns a new ManagerConnection to an asterisk server running on localhost with the call + * manager interface listening on its default port 5038. * * @param username the username as specified in asterisk's <code>manager.conf</code> * @param password the password as specified in asterisk's <code>manager.conf</code> @@ -45,10 +56,10 @@ public class ManagerConnectionFactory } /** - * Returns a new ManagerConnection to an asterisk server running on given host with - * the call manager interface listening on its default port 5038. - * - * @param hostname the name of the host the asterisk server is running on + * Returns a new ManagerConnection to an asterisk server running on given host with the call + * manager interface listening on its default port 5038. + * + * @param hostname the name of the host the asterisk server is running on * @param username the username as specified in asterisk's <code>manager.conf</code> * @param password the password as specified in asterisk's <code>manager.conf</code> * @@ -62,11 +73,11 @@ public class ManagerConnectionFactory } /** - * Returns a new ManagerConnection to an asterisk server running on given host with - * the call manager interface listening on the given port. - * + * Returns a new ManagerConnection to an asterisk server running on given host with the call + * manager interface listening on the given port. + * * @param hostname the name of the host the asterisk server is running on - * @param port the port the call manager interface is listening on + * @param port the port the call manager interface is listening on * @param username the username as specified in asterisk's <code>manager.conf</code> * @param password the password as specified in asterisk's <code>manager.conf</code> * Index: Util.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Util.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- Util.java 23 Feb 2005 12:45:20 -0000 1.1 +++ Util.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,13 +1,23 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 23, 2004 */ package net.sf.asterisk.manager; /** - * Utilitiy class with some static helper methods that are used in multiple - * contexts. + * Utilitiy class with some static helper methods that are used in multiple contexts. * * @author srt * @version $Id$ @@ -17,8 +27,8 @@ public class Util /** * The hex digits used to build a hex string representation of a byte array. */ - private static final char[] hexChar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', - 'f' }; + private static final char[] hexChar = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', + 'f'}; /** * Converts a byte array to a hex string representing it. The hex digits are lower case. Index: TimeoutException.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/TimeoutException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- TimeoutException.java 23 Feb 2005 12:45:20 -0000 1.1 +++ TimeoutException.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,22 +1,40 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 22, 2004 */ package net.sf.asterisk.manager; /** - * A TimeoutException is thrown if a ManagerResponse is not - * received within the expected time period. + * A TimeoutException is thrown if a ManagerResponse is not received within the expected time + * period. * * @author srt * @version $Id$ */ public class TimeoutException extends Exception { + /** + * Serial version identifier + */ static final long serialVersionUID = 7674248607624140309L; - public TimeoutException(String message) + /** + * Creates a new TimeoutException with the given message. + * @param message message with details about the timeout. + */ + public TimeoutException(final String message) { super(message); } Index: ManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ManagerConnection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ManagerConnection.java 23 Feb 2005 12:45:20 -0000 1.1 +++ ManagerConnection.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 23, 2004 */ package net.sf.asterisk.manager; @@ -11,8 +22,8 @@ import net.sf.asterisk.manager.action.Ma import net.sf.asterisk.manager.response.ManagerResponse; /** - * The main interface to talk to an asterisk server via the manager api. - * A concrete implementation of this interface is obtained from a ManagerConnectionFactory. + * The main interface to talk to an asterisk server via the manager api. A concrete implementation + * of this interface is obtained from a ManagerConnectionFactory. * * @see net.sf.asterisk.manager.ManagerConnectionFactory * @@ -26,12 +37,11 @@ public interface ManagerConnection * was created. * * @throws IOException - * @throws AuthenticationFailedException if the username and/or password are incorrect - * or the ChallengeResponse could not be built. - * @throws TimeoutException if no response is received within the default timeout period. - * If the implementation uses challenge/response this can either be a - * timeout of the ChallengeAction or the LoginAction; otherwise it - * is always a timeout of the LoginAction. + * @throws AuthenticationFailedException if the username and/or password are incorrect or the + * ChallengeResponse could not be built. + * @throws TimeoutException if no response is received within the default timeout period. If the + * implementation uses challenge/response this can either be a timeout of the ChallengeAction or + * the LoginAction; otherwise it is always a timeout of the LoginAction. * * @see net.sf.asterisk.manager.action.LoginAction * @see net.sf.asterisk.manager.action.ChallengeAction @@ -43,7 +53,7 @@ public interface ManagerConnection * * @throws IOException * @throws TimeoutException if no response to the logoff action is received within the default - * timeout period. + * timeout period. * * @see net.sf.asterisk.manager.action.LogoffAction */ @@ -53,13 +63,13 @@ public interface ManagerConnection * Returns the protocol identifier, i.e. a string like "Asterisk Call Manager/1.0". * * @return the protocol identifier of the asterisk manager interface in use if it has already - * been received; <code>null</code> otherwise + * been received; <code>null</code> otherwise */ String getProtocolIdentifier(); /** - * Sends a ManagerAction to the asterisk manager interface and waits for the - * corresponding ManagerResponse. + * Sends a ManagerAction to the asterisk manager interface and waits for the corresponding + * ManagerResponse. * * @param action the action to send to the asterisk server * @@ -74,8 +84,8 @@ public interface ManagerConnection ManagerResponse sendAction(ManagerAction action) throws IOException, TimeoutException; /** - * Sends a ManagerAction to the asterisk manager interface and waits for the - * corresponding {@link ManagerResponse}. + * Sends a ManagerAction to the asterisk manager interface and waits for the corresponding + * {@link ManagerResponse}. * * @param action the action to send to the asterisk server * @param timeout milliseconds to wait for the reponse before throwing a TimeoutException @@ -84,14 +94,14 @@ public interface ManagerConnection * * @throws IOException * @throws TimeoutException if no reponse is received within the given timeout period. - * + * * @see #sendAction(ManagerAction, ManagerResponseHandler) */ ManagerResponse sendAction(ManagerAction action, long timeout) throws IOException, TimeoutException; /** - * Sends a ManagerAction to the asterisk manager interface and registers a callback handler - * to be called when the corresponding ManagerResponse is received. + * Sends a ManagerAction to the asterisk manager interface and registers a callback handler to + * be called when the corresponding ManagerResponse is received. * * @param action the action to send to the asterisk server * @param callbackHandler the callback handler to call when the response is received @@ -101,8 +111,8 @@ public interface ManagerConnection void sendAction(ManagerAction action, ManagerResponseHandler callbackHandler) throws IOException; /** - * Registers an event handler to be called whenever an {@link net.sf.asterisk.manager.event.ManagerEvent} - * is receiced from the asterisk server. + * Registers an event handler to be called whenever an + * {@link net.sf.asterisk.manager.event.ManagerEvent} is receiced from the asterisk server. * * @param eventHandler the handler to call whenever a manager event is received * Index: MultiAsterisksManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/MultiAsterisksManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- MultiAsterisksManager.java 23 Feb 2005 12:45:20 -0000 1.1 +++ MultiAsterisksManager.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -24,16 +24,15 @@ public class MultiAsterisksManager imple private Map managerConnections; /** - * A map of all active channel by theirs hostname of connection and unique id. - * keyMap -> "hostname:uniqueId" + * A map of all active channel by theirs hostname of connection and unique id. keyMap -> + * "hostname:uniqueId" */ private Map channels; private Map queues; private List queuedEvents; /** - * A map of all "Initiallize flag" per connection. - * keyMap -> "hostname" + * A map of all "Initiallize flag" per connection. keyMap -> "hostname" */ private Map initialized; @@ -52,7 +51,7 @@ public class MultiAsterisksManager imple Hashtable initializedBoolean = new Hashtable(3, 1); initializedBoolean.put("channelsInitialized", new Boolean(false)); - // TODO fix detection of queuesInitialized + // TODO fix detection of queuesInitialized initializedBoolean.put("queuesInitialized", new Boolean(true)); initializedBoolean.put("initialized", new Boolean(false)); @@ -88,8 +87,8 @@ public class MultiAsterisksManager imple /** * Handles all events received from the asterisk server.<br> - * Events are queued until channels and queues are initialized and then - * delegated to the dispatchEvent method. + * Events are queued until channels and queues are initialized and then delegated to the + * dispatchEvent method. */ public void handleEvent(ManagerEvent event) { @@ -312,7 +311,7 @@ public class MultiAsterisksManager imple */ private Channel getChannelByName(String name) { - //TODO must get unique + // TODO must get unique Channel channel = null; Iterator channelIterator = channels.values().iterator(); while (channelIterator.hasNext()) @@ -452,7 +451,9 @@ public class MultiAsterisksManager imple channel.setName(event.getNewname()); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see net.sf.asterisk.manager.AsteriskManager#originateCall(net.sf.asterisk.manager.action.OriginateAction) */ public String originateCall(OriginateAction originateAction) throws TimeoutException, IOException Index: ManagerEventHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ManagerEventHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ManagerEventHandler.java 23 Feb 2005 12:45:20 -0000 1.1 +++ ManagerEventHandler.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 22, 2004 */ package net.sf.asterisk.manager; Index: AsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/AsteriskManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AsteriskManager.java 23 Feb 2005 14:05:01 -0000 1.3 +++ AsteriskManager.java 23 Feb 2005 22:50:57 -0000 1.4 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Oct 28, 2004 */ package net.sf.asterisk.manager; @@ -18,10 +29,10 @@ public interface AsteriskManager { /** * Generates an outgoing call. - * + * * @param originateAction conatins the details of the call to originate * @return the unique id of the created channel (this one is also found in the cdr) - * + * * @throws TimeoutException if the originated call is not answered in time * @throws IOException if the action cannot be sent to the asterisk server */ @@ -31,6 +42,7 @@ public interface AsteriskManager * Returns a Map of active channels.<br> * The map contain the channel names as keys and objects of type * {@link net.sf.asterisk.manager.Channel} as values. + * * @return a Map of active channels. */ Map getChannels(); @@ -38,6 +50,7 @@ public interface AsteriskManager /** * Returns a Map of all queues.<br> * The map contains the queue names as keys and objects of type {@link Queue} as values. + * * @return a Map of queues. */ Map getQueues(); Index: AuthenticationFailedException.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/AuthenticationFailedException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AuthenticationFailedException.java 23 Feb 2005 14:05:00 -0000 1.2 +++ AuthenticationFailedException.java 23 Feb 2005 22:50:57 -0000 1.3 @@ -1,23 +1,38 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 22, 2004 */ package net.sf.asterisk.manager; /** - * An AuthenticationFailedException is thrown when a login fails due to an - * incorrect username and/or password. - * + * An AuthenticationFailedException is thrown when a login fails due to an incorrect username and/or + * password. + * * @author srt * @version $Id$ */ public class AuthenticationFailedException extends Exception { + /** + * Serializable version identifier + */ static final long serialVersionUID = 7674248607624140309L; /** * Creates a new AuthenticationFailedException with the given message. + * * @param message message describing the authentication failure */ public AuthenticationFailedException(final String message) @@ -27,6 +42,7 @@ public class AuthenticationFailedExcepti /** * Creates a new AuthenticationFailedException with the given message and cause. + * * @param message message describing the authentication failure * @param cause exception that caused the authentication failure */ Index: ManagerResponseHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ManagerResponseHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- ManagerResponseHandler.java 23 Feb 2005 12:45:20 -0000 1.1 +++ ManagerResponseHandler.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 22, 2004 */ package net.sf.asterisk.manager; Index: AsteriskServer.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/AsteriskServer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AsteriskServer.java 23 Feb 2005 21:33:10 -0000 1.2 +++ AsteriskServer.java 23 Feb 2005 22:50:57 -0000 1.3 @@ -8,12 +8,15 @@ import java.io.Serializable; /** * Represents an Asterisk server that is connected via the Manager API. - * + * * @author PY * @version $Id$ */ public class AsteriskServer implements Serializable { + /** + * Serializable version identifier + */ private static final long serialVersionUID = 3257284738393125176L; /** @@ -47,6 +50,7 @@ public class AsteriskServer implements S /** * Creates a new Asterisk server with the given hostname and port. + * * @param hostname the hostname of the Asterisk server * @param port the port on the Asterisk server the Asterisk Manager API is listening on */ @@ -58,6 +62,7 @@ public class AsteriskServer implements S /** * Returns the hostname. + * * @return the hostname */ public final String getHostname() @@ -67,6 +72,7 @@ public class AsteriskServer implements S /** * Sets the hostname. + * * @param hostname the hostname to set */ public final void setHostname(final String hostname) @@ -76,6 +82,7 @@ public class AsteriskServer implements S /** * Returns the port. + * * @return the port */ public final int getPort() @@ -85,6 +92,7 @@ public class AsteriskServer implements S /** * Sets the port. + * * @param port the port to set. */ public final void setPort(final int port) Index: ActionBuilder.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ActionBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ActionBuilder.java 23 Feb 2005 12:55:41 -0000 1.2 +++ ActionBuilder.java 23 Feb 2005 22:50:57 -0000 1.3 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Sep 24, 2004 */ package net.sf.asterisk.manager; @@ -20,7 +31,7 @@ import org.apache.commons.logging.LogFac /** * Transforms ManagerActions to Strings suitable to be sent to Asterisk.<br> * The attributes are determined using reflection. - * + * * @author srt * @version $Id$ */ @@ -33,9 +44,10 @@ public class ActionBuilder /** * Builds a String suitable to be sent to Asterisk based on the given action object.<br> - * Asterisk actions consist of an unordered set of key value pairs corresponding to - * the attributes of the ManagerActions. Key and value are separated by a colon (":"), key - * value pairs by a CR/NL ("\r\n"). An action is terminated by an empty line ("\r\n\r\n"). + * Asterisk actions consist of an unordered set of key value pairs corresponding to the + * attributes of the ManagerActions. Key and value are separated by a colon (":"), key value + * pairs by a CR/NL ("\r\n"). An action is terminated by an empty line ("\r\n\r\n"). + * * @param action the action to transform * @return a String representing the given action in an asterisk compatible format */ @@ -65,7 +77,7 @@ public class ActionBuilder getter = (Method) getters.get(name); try { - value = getter.invoke(action, new Object[] {}); + value = getter.invoke(action, new Object[]{}); } catch (IllegalAccessException ex) { @@ -104,10 +116,10 @@ public class ActionBuilder /** * Returns a Map of getter methods of the given class.<br> - * The key of the map contains the name of the attribute that can be accessed by the - * getter, the value the getter itself (an instance of java.lang.reflect.Method). - * A method is considered a getter if its name starts with "get", it is declared public - * and takes no arguments. + * The key of the map contains the name of the attribute that can be accessed by the getter, the + * value the getter itself (an instance of java.lang.reflect.Method). A method is considered a + * getter if its name starts with "get", it is declared public and takes no arguments. + * * @param clazz the class to return the getters for * @return a Map of attributes and their accessor methods (getters) */ Index: EventBuilder.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/EventBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- EventBuilder.java 23 Feb 2005 12:45:20 -0000 1.1 +++ EventBuilder.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Sep 24, 2004 */ package net.sf.asterisk.manager; @@ -115,12 +126,12 @@ public class EventBuilder } /** - * Registers a new event class. The event this class is registered for is simply derived - * from the name of the class by stripping any package name (if present) and stripping - * the sufffix "Event". - * For example <code>net.sf.asterisk.manager.event.JoinEvent</code> is registered for the - * event "Join". - * @param clazz the event class to register, must extend net.sf.asterisk.manager.event.Event. + * Registers a new event class. The event this class is registered for is simply derived from + * the name of the class by stripping any package name (if present) and stripping the sufffix + * "Event". For example <code>net.sf.asterisk.manager.event.JoinEvent</code> is registered for + * the event "Join". + * + * @param clazz the event class to register, must extend net.sf.asterisk.manager.event.Event. */ public void registerEventClass(Class clazz) { @@ -140,8 +151,9 @@ public class EventBuilder /** * Registers a new event class for the event given by eventType. + * * @param eventType the name of the event to register the class for. For example "Join". - * @param clazz the event class to register, must extend net.sf.asterisk.manager.event.Event. + * @param clazz the event class to register, must extend net.sf.asterisk.manager.event.Event. */ public void registerEventClass(String eventType, Class clazz) { @@ -159,7 +171,7 @@ public class EventBuilder try { - defaultConstructor = clazz.getConstructor(new Class[] { Object.class }); + defaultConstructor = clazz.getConstructor(new Class[]{Object.class}); } catch (NoSuchMethodException ex) { @@ -199,7 +211,7 @@ public class EventBuilder try { - constructor = eventClass.getConstructor(new Class[] { Object.class }); + constructor = eventClass.getConstructor(new Class[]{Object.class}); } catch (NoSuchMethodException ex) { @@ -209,7 +221,7 @@ public class EventBuilder try { - event = (ManagerEvent) constructor.newInstance(new Object[] { source }); + event = (ManagerEvent) constructor.newInstance(new Object[]{source}); } catch (InstantiationException ex) { @@ -267,9 +279,8 @@ public class EventBuilder } /* - * The source property needs special handling as it is already defined - * in java.util.EventObject (the base class of ManagerEvent), so we - * have to translate it. + * The source property needs special handling as it is already defined in + * java.util.EventObject (the base class of ManagerEvent), so we have to translate it. */ if ("source".equals(name)) { @@ -296,8 +307,8 @@ public class EventBuilder { try { - Constructor constructor = dataType.getConstructor(new Class[] { String.class }); - value = constructor.newInstance(new Object[] { attributes.get(name) }); + Constructor constructor = dataType.getConstructor(new Class[]{String.class}); + value = constructor.newInstance(new Object[]{attributes.get(name)}); } catch (Exception e) { @@ -309,7 +320,7 @@ public class EventBuilder try { - setter.invoke(event, new Object[] { value }); + setter.invoke(event, new Object[]{value}); } catch (Exception e) { Index: Queue.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Queue.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- Queue.java 23 Feb 2005 12:45:20 -0000 1.1 +++ Queue.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Oct 31, 2004 */ package net.sf.asterisk.manager; @@ -16,6 +27,9 @@ import java.util.List; */ public class Queue implements Serializable { + /** + * Serial version identifier + */ private static final long serialVersionUID = -6597536667933738312L; private String name; private Integer max; Index: DefaultManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultManagerConnection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- DefaultManagerConnection.java 23 Feb 2005 12:45:20 -0000 1.1 +++ DefaultManagerConnection.java 23 Feb 2005 22:50:57 -0000 1.2 @@ -1,7 +1,18 @@ /* - * (c) 2004 Stefan Reuter + * 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. * - * Created on Apr 22, 2004 */ package net.sf.asterisk.manager; @@ -88,8 +99,8 @@ public class DefaultManagerConnection im } /** - * Sets the port to use to connect to the asterisk server. This is - * the port specified in asterisk's <code>manager.conf</code> file.<br> + * Sets the port to use to connect to the asterisk server. This is the port specified in + * asterisk's <code>manager.conf</code> file.<br> * Default is 5038. * * @param port the port to connect to @@ -100,8 +111,8 @@ public class DefaultManagerConnection im } /** - * Sets the username to use to connect to the asterisk server. This is - * the username specified in asterisk's <code>manager.conf</code> file. + * Sets the username to use to connect to the asterisk server. This is the username specified in + * asterisk's <code>manager.conf</code> file. * * @param username the username to use for login */ @@ -111,8 +122,8 @@ public class DefaultManagerConnection im } /** - * Sets the password to use to connect to the asterisk server. This is - * the password specified in asterisk's <code>manager.conf</code> file. + * Sets the password to use to connect to the asterisk server. This is the password specified in + * asterisk's <code>manager.conf</code> file. * * @param password the password to use for login */ @@ -122,9 +133,8 @@ public class DefaultManagerConnection im } /** - * Sets the time in milli seconds the synchronous method - * {@link #sendAction(ManagerAction)} will wait for a response before throwing - * a TimeoutException.<br> + * Sets the time in milli seconds the synchronous method {@link #sendAction(ManagerAction)} will + * wait for a response before throwing a TimeoutException.<br> * Default is 2000. * * @param defaultTimeout default timeout in milli seconds @@ -135,13 +145,13 @@ public class DefaultManagerConnection im } /** - * Sets the time in milli seconds the synchronous methods - * {@link #sendAction(ManagerAction)} and {@link #sendAction(ManagerAction, long)} - * will sleep between two checks for the arrival of a response. This value should - * be rather small.<br> + * Sets the time in milli seconds the synchronous methods {@link #sendAction(ManagerAction)} and + * {@link #sendAction(ManagerAction, long)} will sleep between two checks for the arrival of a + * response. This value should be rather small.<br> * Default is 50. * - * @param sleepTime time in milli seconds to sleep between two checks for the arrival of a responser + * @param sleepTime time in milli seconds to sleep between two checks for the arrival of a + * responser */ public void setSleepTime(long sleepTime) { @@ -161,14 +171,14 @@ public class DefaultManagerConnection im /* Implementation of ManagerConnection interface */ /** - * Logs in to the asterisk manager using asterisk's MD5 based challenge/response protocol. - * The login is delayed until the protocol identifier has been received by the reader. + * Logs in to the asterisk manager using asterisk's MD5 based challenge/response protocol. The + * login is delayed until the protocol identifier has been received by the reader. * * @throws AuthenticationFailedException if the username and/or password are incorrect * @throws TimeoutException if there no response is received within the specified timeout period * * @see ChallengeAction - * @see LoginAction + * @see LoginAction */ public void login() throws IOException, AuthenticationFailedException, TimeoutException { @@ -380,8 +390,8 @@ public class DefaultManagerConnection im } /** - * Creates a new unique internal action id based on the hash code of this - * connection and a sequence. + * Creates a new unique internal action id based on the hash code of this connection and a + * sequence. */ private String createInternalActionId() { @@ -422,8 +432,8 @@ public class DefaultManagerConnection im /* Callbacks for ManagerReader */ /** - * This method is called by the reader whenever a {@link ManagerResponse} - * is received. The response is dispatched to the associated {@link ManagerResponseHandler}. + * This method is called by the reader whenever a {@link ManagerResponse} is received. The + * response is dispatched to the associated {@link ManagerResponseHandler}. * * @param response the resonse received by the reader * @@ -484,8 +494,8 @@ public class DefaultManagerConnection im } /** - * This method is called by the reader whenever a ManagerEvent - * is received. The event is dispatched to all registered ManagerEventHandlers. + * This method is called by the reader whenever a ManagerEvent is received. The event is + * dispatched to all registered ManagerEventHandlers. * * @param event the event received by the reader * @@ -527,9 +537,9 @@ public class DefaultManagerConnection im } /** - * This method is called by the reader when the asterisk server - * receives the protocol identifier, i.e. a string like "Asterisk Call Manager/1.0". - * Having received a correct protocol identifier is the precodition for logging in. + * This method is called by the reader when the asterisk server receives the protocol + * identifier, i.e. a string like "Asterisk Call Manager/1.0". Having received a correct + * protocol identifier is the precodition for logging in. * * @param protocolIdentifier the protocol version received by the reader * @@ -550,11 +560,11 @@ public class DefaultManagerConnection im } /** - * This method is called by the reader if the connection to the asterisk server is lost. - * While keepAlive is <code>true</code> we will try to reconnect. Reconnection attempts - * will be stopped when the {@link #logoff()} method is called or when the login after a - * successful reconnect results in an {@link AuthenticationFailedException} suggesting that - * the manager credentials have changed and keepAliveAfterAuthenticationFailure is not set. + * This method is called by the reader if the connection to the asterisk server is lost. While + * keepAlive is <code>true</code> we will try to reconnect. Reconnection attempts will be + * stopped when the {@link #logoff()} method is called or when the login after a successful + * reconnect results in an {@link AuthenticationFailedException} suggesting that the manager + * credentials have changed and keepAliveAfterAuthenticationFailure is not set. */ void handleDisconnection() { @@ -580,7 +590,7 @@ public class DefaultManagerConnection im } else { - // slow down after 10 unsuccessful attempts asuming a + // slow down after 10 unsuccessful attempts asuming a // shutdown of the server Thread.sleep(5000); } @@ -632,10 +642,13 @@ public class DefaultManagerConnection im /* Helper classes */ /** - * A simple data object to store a ManagerResult. + * A simple data object to store a ManagerResult. */ private class ResponseHandlerResult implements Serializable { + /** + * Serializable version identifier + */ private static final long serialVersionUID = 7831097958568769220L; private ManagerResponse response; @@ -655,11 +668,14 @@ public class DefaultManagerConnection im } /** - * A simple response handler that stores the received response in - * a ResponseHandlerResult for further processing. + * A simple response handler that stores the received response in a ResponseHandlerResult for + * further processing. */ private class DefaultResponseHandler implements ManagerResponseHandler, Serializable { + /** + * Serializable version identifier + */ private static final long serialVersionUID = 2926598671855316803L; private ResponseHandlerResult result; |