I would like to observe or intercept Conversation.begin() method call in CDI in order to stock the new Conversation.getId() and list all the opened conversation.
I don't find in the spec (JSR-299) how to observe such event. I'm thinking of complex system of Extension which would perhaps use ProcessInjectionTarget or ProcessProducer or other events to do that... but I feel like it exists another simpler solution...
Hmm, these are built in beans and so can't be decorated. In CDI 1.1 you could use ProcessInjectionPoint, or add a request to issues.jboss.org/browse/CDI to be able to decorate built in beans.
So right now, not much idea, sorry.
Related
I want ask if there is way to get an instance of a component if a job (ex:tmap, tmysqlinput) in tjava code and then manipulate it manually using code?
Thank you
Very hazardous. Looking at the generated Java code will give you some answers (I think so).
In fact, accessing to some objects properties is possible (there is blogs and articles about this) but changing anything seems to be dangerous (IMHO).
TRF
What are the different ways to retrieve a node in adobe cq5 and out of those which has to prefer.
I knows three method only one is through session , request and another one is through resourceResolver.
Here are those..
Node rootNode = session.getNode(path);
by request
Node currentNode = request.getResource().adaptTo(Node.class);
by resourceResolver
String resourcePath = "path/to/resource";
Node.node = resourceResolver.getResource(resourcePath).adaptTo(Node.class);
Out of these which one one is best way to retrieve and why ?
First it is discouraged to ask question like this, as it triggers oppinion based answers. Nonetheless I try to be as objecitve as I can. I think it depends on the use case, e.g. where in your code do you want to get the node:
If you already are in a servlet,
request.getResource().adaptTo(Node.class) is probably the most
straightforward way.
If you already have a jcr Session, it is easiest to use the
getNode(path) method
If you already have a ResourceResolver getResource(path) or resolve(path) are fine as well.
Me personally prefer the Sling API over the JCR, so I usually work with Resources anyway thus I mostly use the ResourceResolver or its Adapters: PageManager, TagManager, etc.
I even think internally it all ends up with session.getNode(path) as the ResourceResolver relies on a Session (you can adapt it to it) and request.getResource() probably uses the resolve(path) method.
There is no "best way". If you already have a NODE object then if you are trying to get say... all the children then there is listChildren(). Really the best way is a use case.
The real question is why you want a NODE specifically. Unless you are creating data in the JCR, there is usually no need for the node interface. 99% of the time the system handles node creation for you, so you are reading data, in which case resource.adaptTo(ValueMap.class) is probably your best bet.
If you add more details about WHY you are concerned about this and the context, I can help you further.
I was just curious to know if it's by any means possible to add a sort functionality to the default find action of a model without overriding the same in the controller ?
We do have beforeCreate and afterCreate features in the models which is quite useful in many cases. Similarly beforeFetch or something like that, if exists can be really useful when we want some pre/post processing on the result set while doing a get request.
An example of this would be: localhost:1337/user?sort=id desc
In my app, I have a presenter (Presenter1) which I use to kick off an Editor (EditorView1) which edits a Foo object. This MVP setup is akin to what is described in this answer, https://stackoverflow.com/a/10699346/565863
Now, let's say that I need to create another view (EditorView2 which is kicked off by Presenter2) which also edits a Foo object, but needs to make use of EditorView1.
EditorView1 would be supplied to EditorView2 by Presenter1.
This approach seems sloppy and error prone. Is there another way to do this?
As I was writing this question, I realized a much more clean approach.
The problem with what is described above is that I was intent on re-using the first Presenter, Presenter1.
It would be much cleaner to abstract out the Editor portion of the EditorView1 code into a re-usable Editor widget (Editor1) which could be used by both EditorView1 and EditorView2. Now, I have one presenter, one view, and one EditorDriver. There is no need to juggle nested presenters or multiple EditorDrivers.
Is there a way to use Lift's snippet processing outside the normal request handling process? I know I can call LiftSession.findAndProcessTemplate, but that obviously requires an instance of LiftSession. Is there a way to do that without LiftSession as long as I only use stateless snippets? Alternatively, is there a way to get an "empty" instance of LiftSession?
Sure, you can use net.liftweb.http.S.runTemplate:
http://scala-tools.org/mvnsites/liftweb-2.4-M4/#net.liftweb.http.S