Thread: [Asterisk-java-devel] ChannelFactory for Live
Brought to you by:
srt
From: Colin W. <co...@bi...> - 2011-03-04 20:02:20
|
Following along on the recent addition of a ChannelFactory for the agi package, I was thinking of implementing something similar for the live package. I have a question regarding architecture before anything significant can be accomplished. It seems like in the actual meat of the live package, nothing uses the interfaces, they all use direct references to the *Impl classes. For example, in the ChannelManager.addNewChannel method, it directly creates an AsteriskChannelImpl object. For example, > final AsteriskChannelImpl channel = new AsteriskChannelImpl(server, name, > uniqueId, dateOfCreation); as opposed to > final AsteriskChannel channel = new AsteriskChannelImpl(server, name, > uniqueId, dateOfCreation); In addition, many of the methods called on these objects are only available in the AsteriskChannelImpl object, and so the objects are all stored as Impl's. This works great, but poses a problem with the addition of a ChannelFactory. In order to correctly implement a ChannelFactory, it must either: 1. return subclasses of AsteriskChannelImpl. This would force the AsteriskChannelImpl object into public scope, which is probably not a good idea. 2. return classes that implement the AsteriskChannel interface. This would be a more correct method to follow, but it would also require significant refactoring of at least the channel tracking portions of the live package, and possibly more. This could break backwards compatibility with the API, as some methods may need to be moved from the AsteriskChannelImpl class to the AsteriskChannel interface. If there are additional options, I'd love to hear them. I don't have a problem with doing all the refactoring mentioned in the second option, but I'd prefer to get confirmation that such sweeping changes have a chance of being accepted back into the master branch. I'd very much prefer to contribute the changes back into the project than keep them to myself or fork. Thanks for any advice, --Colin -- Colin Williams |
From: daniel m. <dan...@go...> - 2011-03-05 11:32:07
|
Hi > as some methods may need to be moved from the AsteriskChannelImpl class to > the AsteriskChannel interface. from the docu: * channels). <p/> AsteriskServer is still in an early state of development. So, * when using AsteriskServer be aware that it might change in the future. I did not discover the live packet yet, but I do not see the point in defining interfaces but coding against concrete classes. The interface is only useless overhead that does not give any advantage (like loose coupling), so in my personal opinion the refactoring seems to be a good idea. Why do you think it would be bad design to open the AsteriskChannelImpl to public? It provides a lot of functionality that I probably do not want to recode in custom channels, so allowing to inherit from the class would make things easier. Daniel |
From: Colin W. <co...@bi...> - 2011-03-07 07:03:20
|
> I did not discover the live packet yet, but I do not see the point in > defining interfaces but coding against concrete classes. The interface > is only useless overhead that does not give any advantage (like loose > coupling), so in my personal opinion the refactoring seems to be a > good idea. > As best as I can tell, it's mostly used to restrict access to methods that generally shouldn't be called by programs using the API, such as those responsible for firing Live Events, those responsible for handling the direct ManagerEvents being handled, etc. Why do you think it would be bad design to open the > AsteriskChannelImpl to public? It provides a lot of functionality that > I probably do not want to recode in custom channels, so allowing to > inherit from the class would make things easier. I agree, it does provide a lot of nice default functionality. However, it seems to me to be designed to be used internally only. Most of the properties of the channel are read-only in actuality, such as name, unique id, caller id, etc, but have setters defined. It could be confusing to users to have these setters available publicly, since they don't do anything to the channel itself, only to the java object representing it. -- Colin Williams |
From: Stefan R. <ste...@re...> - 2011-03-07 08:32:20
|
Hi, > As best as I can tell, it's mostly used to restrict access to methods > that generally shouldn't be called by programs using the API, such as > those responsible for firing Live Events, those responsible for handling > the direct ManagerEvents being handled, etc. Yes that was the idea behind it. The methods in the interface are for users of the API and the methods of the *Impl classes that are not part of the interface are for the corresponding *Manager to update the state of the live object when the AMI events are processed. > I agree, it does provide a lot of nice default functionality. However, > it seems to me to be designed to be used internally only. Most of the > properties of the channel are read-only in actuality, such as name, > unique id, caller id, etc, but have setters defined. It could be > confusing to users to have these setters available publicly, since they > don't do anything to the channel itself, only to the java object > representing it. Indeed. The "write" methods in the interface cause interaction with Asterisk and actually modify the state of the corresponding concept there. What is lacking currently is a clear and easy way of extending the live API. This would require extending the *Manager, the *Impl and the interface. I would like to keep the interface for the "end user" separate from what the *Manager uses to update the state. This can either be done by the current interface/impl separation or maybe by having some kind of a companion class for the live object. =Stefan |