Brian,

Were you able to create a test case for that?  I am sure I experienced the exact same problem and just to move things at the time, I end up taking Chris approach of using setter injection. Although it seems like a bug to me.

Thanks

Qasim


On 4/4/06, Brian Kotek <[EMAIL PROTECTED]> wrote:
Hi Peter, yes I'm sure because if I go set the access attribute of setSessionManager() to public ColdSpring WILL call the setter method. I could probably live with this but it still seemed worth bringing up becuase I'm explictily telling CS to pass it as an argument to the constructor and not call the setter method (constructor-arg instead of property).

On 4/4/06, Peter J. Farrell <[EMAIL PROTECTED] > wrote:
Brian Kotek said the following on 4/4/2006 4:54 PM:
> Thanks Sean, yes I double checked all that even to the point of
> cutting and pasting the exact same argument name from the CFC to the
> ColdSpring XML:
>
>     <cffunction name="init" access="public" returntype="any"
> output="false"  hint="I perform all initialization">
>         <cfargument name="reactor"
> type="reactor.reactorFactory" required="true" />
>         <cfargument name="sessionManager" type="any" required="true"
> hint="Reference to the session manager." />
>         <cfset variables.instance = structNew() />
>         <cfscript>
>             setReactor( reactor=arguments.reactor );
>             setSessionManager(arguments.sessionManager );
>         </cfscript>
>         <cfreturn this />
>     </cffunction>
>
> Any other idears? Thanks.
I know this is a dumb question, but are you sure that your
setSessionManager() method is defined this service?  Check the spelling
etc.?

You might try adding something like this in your init() just to see if
CS is passing in the SessionManager:

<cfiif NOT StructKeyExists(arguments, "sessionManager")>
    <cfthrow type="appplication" message="I didn't get the session
manager from CS!"/>
</cfif>

I always try to prefer setter injection versus constructor-arg injection
if at all possible.  I only use constructor-arg inject the object
absolutely requires another object to init and may be consumed  by
another object on its' init.  You can always use property injection and
the have CS "setup" the service after all the dependencies have been
wired together.  Something like this:

<bean id="someService"
    class="someApp.model.sys.some.someService"
    init-method="setup">
    <property name="someDao"><ref bean="someDao"/></property>
    <property name="someGateway"><ref bean="someGateway"/></property>
    <property name="udfs"><ref bean="udfs"/></property>
</bean>

CS will call the init(), wire all the dependencies, then call all of the
init-methods (which in this case is setup()).

Best,
.Peter

--
Peter J. Farrell :: Maestro Publishing
Member Team Mach-II :: Member Team Fusion
http://blog.maestropublishing.com

Create boilerplate beans and transfer objects for ColdFusion!
Fire up a cup of Rooibos!
http://rooibos.maestropublishing.com/





Reply via email to