Win a copy of Rust Web Development this week in the Other Languages forum!

Swerrgy Smith

Ranch Hand
+ Follow
since Mar 26, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
26
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Swerrgy Smith

Hi all,

Suppose that we have a businessLogic() method that does 2 things: write some information in a local cache and save the same information in the DB using JDBC so that the contents of the cache and the DB are always the same.

I know we can use Spring's JDBC Datasource Transaction Manager to automatically rollback the DB in case of exception. However, how can we define a custom transaction manager that also rollbacks the content of the cache in this case, so that the contents of the cache and the DB are always in sync?

Thank you.
2 years ago
Hi all,

I have a question about changing role dynamically in runtime. Suppose that we have a social network application (like Facebook) and we are using Spring security for authentication/authorization purpose.
When a person open his Homepage this person has the ADMIN role and can do everything with his Homepage. However, when he is visiting another friend's Homepage he should only have the role USER which can only do some restricted actions (he cannot delete posts in the Homepage of his friend, for example).
If we use AuthenticationManagerBuilder then we can only set one fixed role for each user.

Can anyone help me with this question?

Thank you.
2 years ago
Hello,

I would like to know if a generational garbage collector visits all objects during a minor GC or it only visits the objects in the Young Generation?
If the answer is no, how can it do this? Because in my understanding, it has to start from a "root" and visit all reachable objects from this "root". There is no way it can knows in advance which objects are in the Young Generation and which objects are in Old Generation.

If the answer is yes, how it can be better than a traditional garbage collector while it also has to spend time to visit all objects.

Thank you very much.
6 years ago
Thanks Jeanne, it works better than my first version but it seems that I still have to to some kind of type cast in the method if I really want to use the list and add some element. Is there anyway to avoid completely the type cast?



Jeanne Boyarsky wrote:This works. It doesn't use the enum, but keeps it to preserve your method signature:

6 years ago
Hello all,

Suppose that I have a super class Animal.java and sub-classes Dog.java and Cat.java
How can I write a "factory" method that return a list of Dog or Cat based on the parameter without explicit type case.

For example:


And I think of the factoryMethod signature like that:


However, this code doesn't work.

If I use explicit type cast then it work but that's what I want to avoid:

Can anyone help me?

Thanks a lot.
6 years ago
Hello all,

I have to merge regularly from a trunk and a branch using tortoise SVN.
Can you please tell me how to check what revisions I have merged from the trunk and the branch?
(I want to make sure that I do not forget to update anything from the trunk the the branch)

Thank you very much
Hello,

Thanks for your reply.
I have another questions: How can I know which revisions I already merged to the branch? (In case I already forgot my activities in the past)

Thanks very much
Hi all,

Suppose that I have a trunk with revisions from 1-30 (HEAD is 30th revision) and a branch which I create after I committed the 10th revision.
What are the differences among the 3 scenarios below:
1) Merge a range of revisions from 15-HEAD (as can be seen in the text box in the attached picture) to the branch
2) Merge the HEAD to the branch (the text box contains "HEAD")
3) No revision from the trunk is specified (the text box is empty)

Thank you very much.

Jaikiran Pai wrote:I had the IDE open in front of me, so I just tried it in debug mode. Clicked "Evaluate expressions" and then clicked the "Code Fragment mode" button and in the top area editor entered:



and then hit the "Evaluate" button. The output, 7, was shown in the "Result" text area. See screenshot for details.



Yes, I know what you mean. However, it seems that we cannot do something more complex as we can do with Eclipse.
For example, I have a Set<String_FullName> named infoSet that have 100000 elements. In "Display View" of eclipse, at one break point I can enter some code to verify whether this set contains the name "Robert" or not. I can insert my code as:



In the "Evaluate expressions" I don't see I can do this.
Hi all,

In Eclipse, we can open "Display View" to enter some code and execute this code while debugging.
In IntelliJ, how can we do it? I already tried "Evaluating Expressions" but it seems that I can only see values of variables and I cannot enter my customized code (even in "code fragment evaluation" mode).

Thank you very much.

Gregg Bolinger wrote:You should name your test methods based on what you're attempting to assert. For example, suppose your class Biz has a method called calculateTotal(). You might name your test methods as such:



Test methods should be as well defined as your methods being tested. testCalculateTotal_xxx is a bad idea.



Thanks for your excellent advice, Gregg.
7 years ago
Hi all,

Suppose I want to test the method doSomething() of the class Biz; I create a test class BizTest.
If I want to write many test methods to test doSomething(), how should I name these methods? I am thinking of some thing like: testDoSomething_1(), testDoSomething_2() ... but it will look like a automatically generated test (and not a test written by a person); furthermore, it will not tell the nature of each test (e.g. what the test method testDoSomething_1() is supposed to do).

What do you think about that? Or should I write only 1 method testDoSomething() and put a lot of assertxxxx inside?

Thanks for your advice.
7 years ago
Hi all,

Can you tell me why we always need to use a class (or a name of a class) in the getLogger method?


Why don't we simply use a same name (for example "ABCDEFGH") for every .java file ?


Thank you very much.
Thank Henry for your replies.

I also found a very helpful answer to my question here:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html

As I understand from the article, the most EXPENSIVE operation is not to mark the objects (i.e. traversing the object tree) but it's the compacting process.
Using Generational GC can help optimize the compacting process. Instead of compacting the WHOLE heap memory each time, the GC just needs to move all the "survived" objects from the Eden region to the Survive regions (first S0, then S1). After this "moving step", the Eden region, which is the busiest region, is clear and ready to use.

In this model, the compacting process is done much less frequently and only with the old generation region.

Please correct me if I'm wrong!

Thank you all.
7 years ago
Hi all,

I would like to know how we can deploy one Web application on multiple server to share the work between them?
My first thought is that we just deploy the same war file on different servers that connect to the same database. However, what will happen when a user enter something like www.webdomain.com ?
How can multiple servers share the same domain name and how the requests from different users are redirected to these different server?

Any help will be very appreciated!

Thank you very much.
7 years ago