Issue with lightwire (Version: 0.71), Property substitution and custom factories
2 views
Skip to first unread message
Adiefatlady
unread,
Feb 23, 2011, 5:41:32 AM2/23/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Lightwire Framework
Used lightwire when it was part of coldbox and worked ok as an
alternative to coldspring.
Downloaded the latest version mentioned above and had a few issues.
Had to change addBeanFromFactory function in BaseConfigObject.cfc to
below adding in the last 4 lines as without them the line
If
(StructCount(variables.Config[arguments.ObjectName].ConstructorDependencyStruct))
{ObjectDependencyList =
StructKeyList(variables.Config[arguments.ObjectName].ConstructorDependencyStruct);}
in getDependencyObjectList in Lightwire.cfc breaks
<cffunction name="addBeanFromFactory" returntype="void" hint="I add
the configuration properties for a Singleton or Transient that is
created by a factory to the config file." output="false">
<cfargument name="FactoryBean" required="true" type="string"
hint="The name of the factory to use to create this bean (the factory
must also have been defined as a Singleton in the LightWire config
file).">
<cfargument name="FactoryMethod" required="true"
type="string"
hint="The name of the method to call on the factory bean to create
this bean.">
<cfargument name="BeanName" required="true" type="string"
hint="The
required name to use to refer to this bean.">
<cfargument name="Singleton" required="true" hint="Whether the
bean
is a Singleton (1) or Transient(0).">
<cfscript>
// Set the config properties for the Singleton
// Create the necessary struct
variables.config[BeanName] = StructNew();
// Set it as a Singleton
variables.config[BeanName].Singleton = Singleton;
// Set the Factory bean
variables.config[BeanName].FactoryBean = FactoryBean;
// Set the Factory method
variables.config[BeanName].FactoryMethod =
FactoryMethod;
// Initialize the dependency lists
variables.config[BeanName].ConstructorDependencies =
"";
variables.config[BeanName].SetterDependencies = "";
variables.config[BeanName].MixinDependencies = "";
variables.config[BeanName].InitMethod = "";
variables.config[BeanName].ConstructorDependencyStruct
=
StructNew();
variables.config[BeanName].SetterDependencyStruct =
StructNew();
variables.config[BeanName].MixinDependencyStruct =
StructNew();
</cfscript>
</cffunction>
I think you only need the above if you create beans from factories
e.g. i have
<!-- So can get stuff from coldbox and inject it into other beans -->
<bean id="coldboxFactory"
class="coldbox.system.ioc.ColdboxFactory" /
<bean id="iocPlugin" factory-bean="ColdboxFactory" factory-
method="getPlugin">
<constructor-arg name="plugin">
<value>ioc</value>
</constructor-arg>
</bean>
<bean id="coldboxController" factory-bean="ColdboxFactory"
factory-
method="getColdbox">
</bean>
And just for kicks Lightwire no longer supports property replacement
in maps e.g. if you have someting like below it will no longer
replace the placeholders in the value fields
<constructor-arg name="userTypeIds">
<map>
<entry key="NO_USER_TYPE_ID">
<value>${NO_USER_TYPE_ID}</
value>
</entry>
<entry key="REGISTERED_USER_TYPE_ID">
<value>$
{REGISTERED_USER_TYPE_ID}</value>
</entry>
<entry
key="NON_REGISTERED_USER_TYPE_ID">
<value>$
{NON_REGISTERED_USER_TYPE_ID}</value>
</entry>
<entry
key="CAMPAIGN_REGISTERED_USER_TYPE_ID">
<value>$
{CAMPAIGN_REGISTERED_USER_TYPE_ID}</value>
</entry>
</map>
</constructor-arg>
only things like this will get replaced
<property name="firstPartyMappedNewsletters">
<value>${FIRST_PARTY_WRAPPER_VALUES}</value>
</property>
take a look in translateBeanChildren method in
lightwire.BaseConfigObject youll see that substitution doesnt happen
for maps it seems
Hope this helps somebody