[Red5] Spring AOP and application methods
Chris Allen
mrchrisallen at gmail.com
Sat Oct 27 16:28:16 PDT 2007
Hey Dan,
I'm glad to see that you are finding out the benefits of Spring and
its aspect oriented programming support. If you get a chance, please
post a little tutorial on this so others cal learn from it. Anyway,
it's still useful posting your findings on the list, so thanks for
sharing!
I might even try to add something to my Building Red5 Applications
presentation on AOP. I can see how a lot of people would be interested
in it.
-Chris
On 10/26/07, Daniel Rossi <spam at electroteque.org> wrote:
> This one is even better gets all the called methods :)
>
> <aop:after-returning
> pointcut="execution(*
> org.red5.server.api.stream.IStreamAwareScopeHandler.*(..))"
> method="streamClose"
> />
>
> from logging aspect: entering method [execution(connect)] with
> param:RTMPMinaConnection from 127.0.0.1:59680 to localhost (in: 3554, out:
> 3073)
> from logging aspect: exiting method [execution(connect)with return as:true
> from logging aspect: entering method [execution(join)] with param:Client: 0
> from logging aspect: exiting method [execution(join)with return as:true
> from logging aspect: entering method
> [execution(streamSubscriberStart)] with
> param:org.red5.server.stream.PlaylistSubscriberStream at 757277
> from logging aspect: exiting method
> [execution(streamSubscriberStart)with return as:null
> from logging aspect: entering method
> [execution(streamSubscriberClose)] with
> param:org.red5.server.stream.PlaylistSubscriberStream at 757277
> from logging aspect: exiting method
> [execution(streamSubscriberClose)with return as:null
> from logging aspect: entering method [execution(disconnect)] with
> param:RTMPMinaConnection from 127.0.0.1:59680 to localhost (in: 3711, out:
> 3422)
> from logging aspect: exiting method [execution(disconnect)with return
> as:null
> from logging aspect: entering method [execution(leave)] with param:Client: 0
> from logging aspect: exiting method [execution(leave)with return as:null
>
> Here is the partial config i can work with though would it just be easier
> for a second bean to implement IStreamAwareScopeHandler :) I think Ill also
> try and trap a method that adds child scopes aswell to prevent ones not in a
> registered list to be added ! Aop is hot (once its worked out)
>
> <aop:around
> pointcut="execution(*
> org.red5.server.api.stream.IStreamAwareScopeHandler.connect(org.red5.server.api.IConnection,
> org.red5.server.api.IScope, Object[])) and args(conn, scope, params)"
> method="appConnect"
> arg-names="conn, scope, params"
> />
>
>
> <aop:after-returning
> pointcut="execution(*
> org.red5.server.api.stream.IStreamAwareScopeHandler.streamSubscriberClose(org.red5.server.api.stream.ISubscriberStream))
> and args(stream)"
> method="streamSubscriberClose"
> arg-names="stream"
> />
>
>
>
> Oh the pain, access logging pleeeze :)
>
>
> On 26/10/2007, at 11:34 PM, Daniel Rossi wrote:
> Apoligies it seems appConnect isnt being called directly its connect, trying
> to work out an aspect that will trap all methods being called, really good
> for debugging !!!
>
> <aop:pointcut id="logAppConnect"
> expression="execution(* *connect(..))
> "/>
>
>
> <aop:around pointcut-ref="logAppConnect"
> method="appConnect"
> />
>
> public Object appConnect(ProceedingJoinPoint call) throws Throwable
> {
> System.out.println("from logging aspect: entering method [" +
> call.toShortString()
> +"] with param:"+call.getArgs()[0] );
>
> IScope scope = (IScope)call.getArgs()[1];
>
> System.out.println(scope.getName());
> Object point = call.proceed();
>
> System.out.println("from logging aspect: exiting method [" +
> call.toShortString()
> + "with return as:" +point);
>
>
> //return true;
> return point;
> }
>
> so
>
> connect(IConnection conn, IScope scope, Object[] params)
>
> Will need to work out how the stream ones are called if i cant get calls to
> the app adapters ?
>
>
>
>
> On 26/10/2007, at 10:18 PM, Daniel Rossi wrote:
> Hi there, ive been reading up more, and yes it seems i can create a logging
> service without messing with inner code. My problem is everything is setup
> right but its not being called, any ideas where these should be set ?
>
>
> <aop:config>
> <aop:aspect ref="streamStatisticsLog">
> <aop:around
> pointcut="execution(*
> org.red5.server.adapter.IApplication.appConnect(org.red5.server.api.IConnection,
> Object[])) and args(conn, params)"
> method="appConnect"
> arg-names="conn, params"
> />
>
> <aop:around
> pointcut="execution(*
> org.red5.server.adapter.IApplication.roomConnect(org.red5.server.api.IConnection,
> Object[])) and args(conn, params)"
> method="roomConnect"
> arg-names="conn, params"
> />
> </aop:aspect>
> </aop:config>
>
> It should be called methods on the streamStatisticsLog bean and passing the
> parameters so i know what to do with them.
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
>
More information about the Red5
mailing list