Skip to content
Advertisement

When to use Spring Integration vs. Camel?

As a seasoned Spring user I was assuming that Spring Integration would make the most sense in a recent project requiring some (JMS) messaging capabilities (more details). After some days working with Spring Integration it still feels like a lot of configuration overhead given the amount of channels you have to configure to bring some request-response (listening on different JMS

Shortcut for adding to List in a HashMap

I often have a need to take a list of objects and group them into a Map based on a value contained in the object. Eg. take a list of Users and group by Country. My code for this usually looks like: However I can’t help thinking that this is awkward and some guru has a better approach. The closest

Very Simple Regex Question

I have a very simple regex question. Suppose I have 2 conditions: url =http://www.abc.com/cde/def url =https://www.abc.com/sadfl/dsaf How can I extract the baseUrl using regex? Sample output: http://www.abc.com https://www.abc.com Answer Like this: However, you should use the URI class instead, like this:

Difference between FetchType LAZY and EAGER in Java Persistence API?

What is the difference between FetchType.LAZY and FetchType.EAGER in Java Persistence API? Answer Sometimes you have two entities and there’s a relationship between them. For example, you might have an entity called University and another entity called Student and a University might have many Students: The University entity might have some basic properties such as id, name, address, etc. as

What are the differences between ArrayList and Vector?

What are the differences between the two data structures ArrayList and Vector, and where should you use each of them? Answer Differences Vectors are synchronized, ArrayLists are not. Data Growth Methods Use ArrayLists if there is no specific requirement to use Vectors. Synchronization If multiple threads access an ArrayList concurrently then we must externally synchronize the block of code which

String assembly by StringBuilder vs StringWriter and PrintWriter

I recently encountered an idiom I haven’t seen before: string assembly by StringWriter and PrintWriter. I mean, I know how to use them, but I’ve always used StringBuilder. Is there a concrete reason for preferring one over the other? The StringBuilder method seems much more natural to me, but is it just style? I’ve looked at several questions here (including

String, StringBuffer, and StringBuilder

Please tell me a real time situation to compare String, StringBuffer, and StringBuilder? Answer Mutability Difference: String is immutable, if you try to alter their values, another object gets created, whereas StringBuffer and StringBuilder are mutable so they can change their values. Thread-Safety Difference: The difference between StringBuffer and StringBuilder is that StringBuffer is thread-safe. So when the application needs

update attribute a element in arraylist on java?

I have a class extent fron class : Now in token i have arraylist token , i want to update attribute frequency of token in Texchunks when have more than one tokens same . For clearly a give a example : Texchunks :” in particular in domain and range in some ” So have 8 token : in,particular,in,domain,and,range,in,some i want

Advertisement