Tartan 1.0.5 Preview coming soon
For those who are interested, the next version of Tartan (1.0.5) is coming soon. In the last couple of months I have gone ahead and made a number of changes, and I figured this would be a good time to introduce them.
Property Manager - tartan.core.PropertyManager
This has been added to address the need to have access to service-level properties from the LocalService class and any Command defined for that service. This enables command handlers to access service data without having to explicitly pass it around through command arguments. Before, if two or more commands needed to access the same model, it was the responsiblity of the calling service class to make sure it passed it in. Now properties can be declared in the configuration XML, set by service methods, and inside commands. The PropertyManager class has a number of methods that give it the general behavior of a struct/map. These include methods such as getProperty(), setProperty(), getProperties().
Here is an idea of how it looks in the XML configuration:
<service name="SERVICENAME" class="CLASSNAME"> <properties> <property name="prop1" value="value1"/> <property name="prop2" value="value2"/> </properties> ... </service>
ServiceContext - tartan.context.ServiceContext
This class was created to consolidate the management of the various factories that are used with a service and made available to command handlers. The CommandContext used to be initialized with the factories themselves, and the it accessed them directly. Now the CommandContext is initialized with the ServiceContext and all access to the factories is done through it. Additionaly, the PropertyManager is also accessible only through the ServiceContext.
There is a one-to-one relationship between service objects and ServiceContext objects. It is planned for the near future that all access to a service object will be through its ServiceContext. This includes remote calls, local proxies and even between individual services. This will enable finer-grained control over the lifecycle of the service, including how it is called.
User-defined Factories - tartan.core.Factory (abstract base class)
One of the limitations placed upon Tartan users was that all objects/factories had to be those provided by the framework. Existing classes did not fit cleanly into the services since it was up to the LocalService class itself to create and manage the creation of those classes/objects. With the addition of user-defined factories, a user of the framework can create a simple wrapper for their own factory classes and declare it for the service. One example of this is the wrapper for a ColdSpring bean factory which can be found at "tartan.contrib.ColdSpringBeanFactory".
The only requirement is that the wrapper class extends the class "tartan.core.Factory" and it implements the "getObject()" and "getObjectNames()" methods. It can create any type of object that ColdFusion can work with. The factory is available via the ServiceContext object's "getObject()" method.
Here is an idea of how it looks in the XML configuration:
<service name="SERVICENAME" class="CLASSNAME"> ... <factory name="FACTORYNAME" class="CLASSNAME"> <parameters> <parameter name="param1" value="value1"/> <parameter name="param2" value="value2"/> </parameters> </factory> ... </service>
A number of changes have also been made to some of the existing classes as well, a couple of which have been renamed for greater clarity. First, the class "tartan.command.Event" was renamed to "tartan.context.Command", and the class "tartan.command.Command" was renamed to "tartan.command.CommandHandler". Basically, a Command is a logical name with a set of named values, and a CommandHandler is responsible for processing that command object. For me, the Event class never really fit since in the context of commands. For backwards compatibility the old classes will work the same as before, however, any new code should use the new classes.
configure() method
Additionally, the method "configure()" has been added to the following classes:
- tartan.service.LocalService
- tartan.command.CommandHandler
- tartan.data.DAO
- tartan.vo.ValueObject
- tartan.exception.ExceptionHandler
- tartan.core.Factory
This method is a place for user-defined initialization. Before, the only place for this was in the "init()" method and then it was up to the user to call "super.init()" which is less ideal and places an unneeded dependence on the implementation of the underlying abstract class.
Flash Remoting
There have also been some fixes for Flash Remoting as well. It seems that before service method arguments were not being properly converted from ASObjects to CFCs. Additionaly, arrays of CFCs/ASObjects are now properly handled in the conversion process.
XmlReaders/Builders
The various dynamic factory classes have handled the reading and interpretation of the Xml configuration. One of the changes I have made for this release is to separate the Xml configuration from the construction of the factory classes. Now, the reading of XML configuration has been delegated to the classes in the "tartan.xml.readers.*" package, and they produce an intermediate configuration. Also, the creation of the various factories has been moved into the classes in the "tartan.builders.*" package. The configuration generated by the XmlReaders can be fed into the Builder classes to produce the objects needed for each service. One of the benefits of doing this is that the dynamic factories are now simpler since they no longer deal with reading of XML. Additionally, it should make it easier to add different sources for the service configuration.
Sample Applications
There have been a couple of sample applications added to show some of the newer functionality. They are listed below:
- Contact Manager (MachII, Flex)
- Task Manager (Fusebox)
The other sample apps have also been updated.
Anyhow, these are most of the changes in this release candidate. I am interested to hear what you have to say.
Until I get the code in a single download, you can download the framework from the project's CVS repository. If you are interested in checking it out, you can find it here:
CVSROOT
:pserver:anonymous@cvs.sourceforge.net/cvsroot/openxcf
MODULE
tartan_framework
TAG
Tartan-Framework-1_0_5-RC1
