How to display timeline information for routines used by controllers in glimpse/Asp.NET MVC - glimpse

I am currently using Asp.Net MVC 4 and I would like to include the time of some routines used by my controllers in the glimpse's timeline tab.
I know that I have to create an ITimeLineMessage Implementation and send the timing information with a message broker. But how to create the ITimeLineMessage ?

Here is an implementation using anthonyv's suggestion:
https://gist.github.com/droyad/8292852

Here is a way but its not very nice and not supported:
Retrieve the MessageBroker for the following static method:
Glimpse.Core.Framework.GlimpseConfiguration.GetConfiguredMessageBroker()
Then publish an ITimelineMessage to the MessageBroker:
messageBroker.Publish(timelineMessage)
Note, you could create a generic message type that you use over again that implements ITimelineMessage
To populate the properties of your ITimelineMessage implementation you might also need IExecutionTimer. You can get this via the following static method:
Glimpse.Core.Framework.GlimpseConfiguration.GetConfiguredTimerStrategy()
The above will have the knowledge of when the request started for offsets etc.
As #nikmd23 said, we know this is about as bad as what you could ever want to do but v2 will see a much much more simple way of doing this.

You can create any custom class you want, that class just has to implement ITimelineMessage.
As a general heads up, we are currently working through a way to make this WAY easier. If the approach described there interests you, please do provide your feedback.

Related

How to create custom abstract objects with attributes in Typo3?

I am now familiar with "basic" Typo3 - Usage and templating. Right now, I am stuck though, because I am not familiar with custom extensions etc.
I am looking for a way to represent Objects, that I get via methods of my own php-class from an XML-DB-Interface, in Typo3.
To be more precise :
I have a really complex XML-Interface and a php-class which is complete already, to interact with that interface, making methods available, that are meant to interact with different object-types in the underlying DB.
I now want to create abstract objects with the corresponding attributes in Typo3 to be able to work with them in typo3 (display/create/modify).
Furthermore, it would be helpful to find a way to "link" the functions of my php class to typo3-functions, so I can (perhaps?!) build up some kind of simple report-generator that generates conditional reports of those objects.
Could anybody lead me into the right direction and link (a) HowTo(s) or perhaps even examples that I could modify?
Thanks in advance, Oliver
Check how DBAL extension is coded.
https://docs.typo3.org/typo3cms/extensions/dbal/
You might want to implement this XML system as your own abstraction system to store your objects and use TYPO3 backend forms to manipulate those.

Webappclass loader unable to load superclass in a hook?

I am using liferay ce 6.1.0.I need to extend LayoutAction class in a hook.But the class cannot be loaded in the hook by the class loader
Caused by: java.lang.NoClassDefFoundError: com/liferay/portal/action/LayoutAction
java.lang.ClassNotFoundException: com.liferay.portal.action.LayoutAction
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
Is this the issue with the class loader or am I supposed use a different subclass of the following in order to extends.
Thanks in advance
I want to override includeLayoutContent() method of LayoutAction class in order to have a track on the number of views of a page.If this class cannot be extended,is there any other means or class which can be extended to achieve the same
com.liferay.portal.action.LayoutAction is in portal-impl.jar, which is not available to hooks. Therefor you cannot do this.
If you would give us a hint what you want to achieve with this, somebody might be able to tell you how to do what you want to do.
With your added information I'll give you a hint: Typically, a write operation for every pageview is considered to be quite expensive: Your portal's performance will suffer from this. I'd rather advise to use external tools like google anayltics, piwik or similar ones to generate statistics, including the pageviews for specific pages.
Another method, if you can live with the lower potential performance, is to embed such a method in your theme - the theme gets access to the current page and can execute additional functionality with this. Preferably you'll position this at the end of the page, when everything else has already been rendered and sent to the client.

What is PortletURLListener used for? And can I make use of it in a hook?

Can somebody give me a use case as to how can the PortletURLListener be used? if it can be used at all?
Like we have ModelListener can we also use PortletURLListener?
Just like in ModelListener we can inject functionality on creation of a model, on update of a model or on delete and so on.
So can we use the PortletURLListener the same way like ModelListener to do
something when a specific URL is called? Any other approach if not PortletURLListener? Since the name is such I thought that could be of help.
And can we use it in a hook? or it is just used by Liferay? Any other practical usecase you have seen or implemented by extending or using this class?
Thanks in advance.
Thanks Mark for the prompt :-)
The PortletURLListener is used e.g. for deploying and undeploying by Liferay core. For more details see Liferay sources for PortletHotDeployListener:
https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/deploy/hot/PortletHotDeployListener.java
Answer after Update:
You can create hook and put servlet.service.events.post=com.my.MyAfterChangeAction propery to the portal.properties. The MyAfterChangeAction class must implements com.liferay.portal.kernel.events.Action.

Any refreshable groovy classloader implement?

I am looking for a refreshable groovy classloader,I want to let groovy file change on fly,I know
GroovyScriptEngine do the thing,but if I have AClass.groovy and BClass.groovy, and I write in AClass:
Class pageClass = ClassUtils.forName("BClass", this.getClass().getClassLoader());
and auto reloading BClass is not work when BClass.groovy is not work.
I think the best solution is need a refreshable ClassLoader,but I can not find the exisiting implemention.
And I am not using spring-groovy and grails,I want a independent implemention.
Thanks
Not exactly what you want I'm sure but if you want to do something ONLY with Groovy (no Spring or Grails) that allows you to change stuff and not have to restart your application, you might look at doing some initial work with Groovlets -> http://groovy.codehaus.org/Groovlets
This is only for servlet container work and probably won't be extremely useful as your application gets large but it would allow you to initially change things frequently and simply refresh with a call to the Groovlet.
If you did consider using Spring, scripted beans are 'refreshable' and you can implement that yourself using Java's dynamic language support but I'd suggest simply letting Spring do it for you.

Dynamically create class that mocks another class (like remotingProxy) in haxe

I want to be able to dynamically create a new class that has all of the methods of another class. In particular, I want to make my own kind of remoting proxy.
class ApiProxy extends haxe.remoting.Proxy { }
The new class ApiProxy would have all of the same method names and signatures as Api, and would be compile time checked. Only every invocation is done over the wire, instead of handled locally.
I think that remoting.Proxy is a magic internal class - is this true? Do regular users have the ability to define a class that is as powerfully static as this? I've never seen this done in Java and I'm impressed with it's capabilities in Haxe.
How would I implement my own class like remoting.Proxy?
you can achieve this with macros
take a look at this post to get the idea:
http://haxe.1354130.n2.nabble.com/Macros-Are-Awesome-tc5945711.html
You can write, save to filesystem and register a new Class inside of a Macro, based on type information that was passed to the function.
haxe.remoting.Proxy is indeed "magic", it is described that way in the source comments:
http://code.google.com/p/haxe/source/browse/trunk/std/haxe/remoting/Proxy.hx?r=3592
You can't replicate with "normal" haxe code. Adding/modifying functionality to haxe.remoting.Proxy for your own class will be difficult, but maybe not impossible.
Check the tutorial for the "equivalent" api implementing code:
http://haxe.org/doc/remoting/proxy
However, something like this is probably possible with macros:
http://haxe.org/manual/macros
Working with macros is challenging right now. There is little in the way of documentation or examples, and the macro feature is still under development. However, it lets you have a some control over the compiler during the compilation process, which can be amazingly useful at times.
good luck!

Resources