Marco Ehrentreich

best scout
Bartender
+ Follow
since Mar 07, 2007
Marco likes ...
IntelliJ IDE Java Scala
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
21
Received in last 30 days
0
Total given
9
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Marco Ehrentreich

Hi Adrien,

in my opinion it's a matter of taste and the tooling you have available. Obviously data formats like JSON or YAML are less verbose than XML and should be easier to understand and read by non-technical folks. Despite that fact I personally still often prefer XML over the others because with the right tooling (for example IntelliJ IDEA) it gives me excellent tool support like auto-completion and data validation (structure and content).

But if other people will have to read or edit the said files you probably should simply ask for their opinions ;-)


Marco
2 years ago
JSP
It's a DNS problem. The error message "Unknown host repo.maven.apache.org" clearly says it. Maybe a firewall is blocking outgoing DNS requests or your general network setup is wrong.

Marco
2 years ago
You're welcome ;-) Glad that I could help you at least a little bit on that issue.

And yes, I'm from Germany. How did you know? I hope my English isn't THAT bad :-)
Aah, now I see what you mean ;-)

I must admit I don't know very much about implementation details of the stream API but it seems that with the current implementation in the Oracle JDK the combiner function is only used with parallel streams, i.e. if you'd call roster.parallelStream() instead of roster.stream(). You can easily verify this behavior by setting breakpoints for the methods in your Averager class and running the example in debug mode.

With parallel streams each partition of the whole stream accumulates its partial result in a separate instance of Averager. In this case the combiner function would be used to combine the partial result containers into a single Averager object.

But it seems there are no guarantees if and when the combiner argument is used so you shouldn't make the false assumption that it's only ever used for parallel streams.

Marco
Hi Pierrot,

actually it's not as complicated as it may sound. Just a little bit strange if you're not familiar with functional programming concepts ;-)

The collect() method basically processes all the elements in the stream and allows you to define how they should be aggregated into a single result (container). In your example it takes an Averager object as an accumulator which contains the intermediate result (in this case the total sum of person's ages and the number of persons counted so far) and returns a new Averager object which represents the old result combined with the current element (= person) of the stream. That's why the third argument to the collect method is called "combiner" in the API documentation. Finally if you call average() on the resulting Averager object you get the average age of all counted persons.

I hope this explanation makes it a little bit clearer what is going on ;-)


Marco


Hi Mohit,

I think using Futures this way just complicates your implementation and doesn't have any advantages ;-)

If you really want to implement something like a cache yourself than it could be enough to use an ordinary ConcurrentHashMap for this purpose. With Java 8 it has even more nice features. I guess you'll find enough examples on Google.

Anyway, you probably should consider to use an existing caching framework or something like that for production use!


Marco


Hi Mohit,

your understanding of Future.get() is correct. Calling get() will block your current thread until the computation is finished (additionally you can specify a timeout). So obviously it wouldn't give you any advantages to make some computations in a background thread and block your main thread by waiting on the result from the background thread. This would be similar to simply doing all the work directly in your main thread.

But it really depends on the problem you are trying to solve what a good solution could look like. Java offers a lot more helpful classes and tools for concurrent applications. For example an can be very helpful if you can break down your problem at hand into many smaller problems which can be solved in parallel. But of course this will only work if the smaller problems don't depend on each other and so.

Unfortunately this topic is way too complicated to discuss all the possibilites here. Therefore to give you better advices it would be very helpful to let us know what problem you are trying to solve ;-)

Marco
Unfortunately I don't have practical experience with it but the famous GPars library offers a lot of interesting stuff to handle concurrency problems.

In general I'd say it's as easy in Groovy as it is in Java to mess up concurrency problems. In my experience one of the biggest problems in concurrent applications is mutable shared state and there is not much which prevents the use of mutable shared state, neither in Java nor in Groovy. I think functional languages like Scala or Clojure are better suited for real concurrency problems which doesn't mean that it is not possible to write pefect concurrent applications in Groovy.

Marco

2 years ago
Then it should be very easy for you to learn Groovy because Groovy is (almost) a super set of Java, so you don't have to learn a completely new syntax. It's also very easy to mix Java and Groovy so that you can always use the right tool for the job because both languages have their strenghts and weaknesses. And of course this makes it easy to gradually migrate from Java to Groovy as you can at first use Groovy only for the parts it makes most sense (for example to write tests).

Marco
2 years ago
Hi Will,

I'd say it depends on your background and experience. If you already have experience with Java than it's surely easier to learn Groovy as it uses the same tools and APIs and the syntax is very similar to Java (but more lightweight).


Marco
2 years ago
Hi,

a correct XPath expression to get the text content of element <faultstring> would be


Marco
2 years ago
Hi,

you can simple use this pattern to parse the Strings:
This way the formatter will handle the dates correctly, no matter if the month or day are 2 digits or only 1 digit.

Marco
Hi,

what kind of compilation error do you get? Could you please post the relevant parts of the Maven output?

Did you add any JAXB implementation to the dependencies section of your POM? Maybe you just get an error because your project doesn't know about the JAXB classes and annotations. But it's hard to tell without knowing more details about the compilation error.

Marco
3 years ago
Hi Mahtab,

there are indeed some embedded databases which work directly on files or something like this and don't use a server. But usually there IS some kind of server and that's true for Oracle and MySQL, too. Maybe you just didn't notice that because you used an installation utility which installed the database server transparently for you on your local machine as a Windows service or something like this.

With MongoDB there is no difference at all and of course it's fine to have a MongoDB server running on your local machine for development or testing purposes. Just because there is a "server" doesn't mean this server has to run on a different machine!

Marco
3 years ago
As I said the concepts and principles behind the patterns discussed in this book are still valid today. Tools like ESBs, integration frameworks etc. are just implementations of the most common patterns. Of course these technologies may have improved a lot during the past 10 years but the problems they are trying to solve are mostly the same that are described in the book even if it doesn't mention such tools explicitly.

Marco
3 years ago