AOP on Remote Proxies

51 views
Skip to first unread message

Srinivaas D

unread,
Apr 2, 2012, 10:35:20 AM4/2/12
to coldspri...@googlegroups.com

Hello All,

I am trying to use AOP for my current assignment by following the quick start expamples from the coldpsring site. I am trying to intercept method calls made to remote proxies via webservices from Flex. However the method calls seems not be intercepted. I am not getting any error I am getting the result back whatever the undelying method should return. This is how a part of my coldpsring config file looks. I am not sure whether I am missing anything here.  Any pointers are deeply appreciated.

<bean id="ABCService" class="com.model.pos.ABCService" parent="abstractService">

<!-- List Of Other bean entries this bean is dependent on -->

</bean>

 
<bean id="ABC_Remote" class="coldspring.aop.framework.RemoteFactoryBean" lazy-init="false">
               <property name="target"><ref bean="ABCService" /></property>
              <property name="serviceName"><value>ABCWebServices</value></property>
              <property name="relativePath"><value>/com/webservices/</value></property>
              <property name="remoteMethodNames"><value>*</value></property>
<property name="beanFactoryName"><value>cs</value></property>
<property name="interceptorNames"><list><value>ABCInterceptor</value></list></property>
</bean>
 
<!--define the interceptor service -->
  <bean id="RequestAdviceInspector" class="com.aop.RequestAdviceInspector" />  
  <bean id="pointOfSaleInterceptor" class="coldspring.aop.support.NamedMethodPointcutAdvisor">
<property name="advice"><ref bean="RequestAdviceInspector" /></property>
     <property name="mappedNames"><value>*</value></property>
   </bean>
 
 
Advice File:
 

<cfcomponent output="false" extends="coldspring.aop.MethodInterceptor">
 <cffunction name="init" returntype="any" output="false" access="public" hint="Constructor"> 
        <cfreturn this /> 
     </cffunction>
  <cffunction name="invokeMethod" returntype="any" access="public" output="false" hint=""> 
        <cfargument name="methodInvocation" type="coldspring.aop.MethodInvocation" required="true" hint="" /> 
        <cfset var local =  StructNew() /> 
 
        <!--- Capture the arguments and method name being invoked. ---> 
        <cfset local.logData = StructNew() /> 
        <cfset local.logData.args = StructCopy(arguments.methodInvocation.getArguments()) /> 
        <cfset local.logData.method = arguments.methodInvocation.getMethod().getMethodName() />
        <cfset request.logData = local.logData /> 
   <!--- Proceed with the method call to the underlying CFC. --->    
        <cfset local.result = arguments.methodInvocation.proceed() />          
        <!--- Return the result of the method call. ---> 
        <cfreturn local.result /> 
    </cffunction>
</cfcomponent> 

The Test File Code.

<cfscript>

ABCWS = createObject("webservice",http://infospherix.dev/webservices/com/webservices/ABCWebServices.cfc?wsdl);

response = ABCWS.getTransactions(argumentsinXMLFormat);

</cfscript>
<cfdump var="#Request#" />
 
Thanks,
Srinivaas

Brian Kotek

unread,
Apr 2, 2012, 11:27:36 AM4/2/12
to coldspri...@googlegroups.com
Well if CS is generating the ABCWebServices CFC and you can invoke methods on it, it sounds like CS is setting things up correctly. If it wasn't creating ABCWebServices.cfc you'd get an error immediately. So my guess is that your interceptor isn't working as you expect. I would try adding some logging calls to your interceptor and the underlying ABCService to write to the log file to see if you can trace what is going on.

--
You received this message because you are subscribed to the Google Groups "ColdSpring-Users" group.
To post to this group, send email to coldspri...@googlegroups.com.
To unsubscribe from this group, send email to coldspring-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/coldspring-users?hl=en.

Srinivaas D

unread,
Apr 2, 2012, 11:35:09 AM4/2/12
to coldspri...@googlegroups.com
Thanks Brian. I will certainly do that. Howver I found out that using cs.getBean("ABC_Remote") in my test file to get the remote object instead of doing webservices invocation the method calls seems to get intercepted.

Srinivaas D

unread,
Apr 2, 2012, 3:23:30 PM4/2/12
to coldspri...@googlegroups.com
Hi Brian,
 
After logging the requests  every stage of interception found out that the request was indeed getting logged. But for some strange reason this particular line in my interceptor file is not doing its job as intended " <cfset request.logData = local.logData />".  I am not sure whether we can log anything in Request scope in a webservices call. My original thinking was we can write into request scope for a webservices call.
 
Thanks for all the help.

Reply all
Reply to author
Forward
0 new messages