Async call using java 1.4 - asynchronous

i'm trying to find an easy way to execute an async call using the 1.4 java framework.
It's a very easy example... Run the async method, continue executing actions on main thread an when the async method ends raise an event to get the results.
I'll appreciate any example, thanks!

If you were using Java 5+, you'd use the Executor framework. You're using Java 1.4, though, so you can't....
..... but, the Java5 executor framework is actually based upon a pre-existing concurrency library, and since then the Java5 version has been back-ported to Java 1.4 (backport-util-concurrent).
Check out the java.util.concurrent package in Java5 to see how this works (specifically, the Executors class).

I found a really good post about how to deal with events:
http://www.javaworld.com/javaworld/javaqa/2002-03/01-qa-0315-happyevent.html?page=1
Besides this and launching a thread i found the way to to what i was asking for.
Thanks!

Related

How to create Elastic APM spans for each pipeline call

I would like a recommendation on how to instrument each pipeline call using Elastic APM API on Intershop 7.10.
I want to to create a separate span as described here:
https://www.elastic.co/guide/en/apm/agent/java/master/public-api.html#api-span-start-span
(Using try catch block with parent.startSpan())
For now I have tried looking into ICM knowledge base for topics regarding ELK stack (found none) and looked in Component Framework section on how to inject some code around PipelineProcessorImpl.executePipeline or put another pipeline processor implementation through component framewowrk but couldn't find nothing, it seems for now that pipeline processor implementation are not hooked through Component Framework.
General answer is, you should not bother replacing PipelineProcessor with your own implementation. Even for such a seemingly small task of feeding your own monitoring solution.
I (may) have a better solution for you. Haven't tested it though. Have a look at the detailed answer to this intershop question: Adding a servlet to run in Intershop 7.4 application server context
You don't want to add a new servlet but you want to bind a new javax.servlet.Filter implementation that hooks into the Application Server request chain. You can do that the same way as described, but invoke method filter("/servlet/Beehive/*") instead of serve("/servlet/DEMO/*")

Interacting with OptaPlanner through CLI instead of GUI

I am looking for a way to interact with OptaPlanner directly from the command line interface (CLI) without having to use the graphical user interface (GUI).
More specifically, I am looking to pass an XML file to the Employee Rostering function, and to get the solved XML back. Ultimately, I am looking to interact with OctaPlanner from my PHP application.
Any documentation for this?
Here is some what of an example of what I which to achieve:
http://www.c0940097.ferozo.com/applying-optaplanner-to-everyday-problems/
The UI is only for the examples. Take a look at CloudBalancingHelloWorld.java which solves without a UI.
Or, if you're looking for a more enterprise approach, use OptaPlanner Execution Server (also ASL), which exposes everything as REST api's.

Get context path in init method in Servlet 2.3 (so no ServletContext#getContextPath() available)

I'm using servlet 2.3 for my project development due to some legacy code we have. Is there a way to get the context path in the init method or any other way of the servlet?
I know it's possible on higher versions of Servlet and can get it in hacky way using the getRealPath() method on servlet 2.3. However I'm still looking for a better and cleaner code.
I wasn't able to do this. The best way I found was to move to 2.5 spec.
Posting answer just in case anyone is trying the same.

Caliburn.Micro IEventAggregator Publish method missing an overload

I'm working through some tutorials online learning Caliburn.Micro for the first time. Some of the tutorials are using the older 1.3.0 version, I'm using the newer 2.0.0.6 version which was the latest Nuget package which is likely the source of this discrepancy:
When trying to publish the following message:
public void Red()
{
_events.Publish(new ColorEvent(new SolidColorBrush(Colors.Red)));
}
The compiler throws an error saying that the overload wasn't found. The only overload for Publish that is available has the following signature:
void Publish(object message, Action marshal)
I got this to work by using the background worker thread method shown below but in my case it seems like overkill. Was the single parameter overload really removed from Caliburn.Micro?
Also, the documentation is here:
https://caliburnmicro.codeplex.com/wikipage?title=The%20Event%20Aggregator
still show examples using the more basic, single parameter example where you simply pass a message. Is the documentation at this link the latest that correctly describes 2.0.0.6?
public void Red()
{
_events.Publish(new ColorEvent(new SolidColorBrush(Colors.Red)),
action => Task.Factory.StartNew(action));
}
Finally, for bonus points:
What is this 2nd parameter good for other than publishing the message on a background thread? Can someone give some other example(s) of what this overload can be used for?
In Caliburn Micro version 2.0, the EventAggregator.Publish method also takes an action to marshal the event. To maintain the pre-2.0 behavior, you should switch to the EventAggregator.PublishOnUIThread method instead. See the migration instructions here for information on incompatibilities between 1.5 and 2.0.
In general, I believe that the Codeplex documentation is a little bit outdated. Please refer to the new dedicated web site for most up-to-date documentation.

client event handler for sending message to groups in SignalR

I'm trying to integrate SignalR in my MVC project and everything works fine,
however ther is something I can't get right,
Using the latest version of signalR:
http://blogs.msdn.com/b/webdev/archive/2012/08/22/announcing-the-release-of-signalr-0-5-3.aspx
And writing the group functionality described in this wiki:
https://github.com/SignalR/SignalR/wiki/Hubs
Especifically in thr MANAGING GROUPS topic, there is the following code to send a message to a specific group:
public Task Send(string message)
{
return Clients.Group("foo").addMessage(message);
}
I can't figure two things: as the way the code is stated I have the following exception:
'System.Threading.Tasks.Task<object>' does not contain a definition for 'addMessage'
Besides that, what exactly is the event raised in the client to handle it properly with jquery?
Sorry for the confusion. The documentation is updated to be the latest release which is 1.0 alpha2. http://weblogs.asp.net/davidfowler/archive/2012/11/11/microsoft-asp-net-signalr.aspx.
To install it do:
Install-Package Microsoft.AspNet.SignalR -pre
We're going to be deprecating the older packages soon.

Resources