raj malhotra

Ranch Hand
+ Follow
since Feb 22, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by raj malhotra

Hi All,

Stateful session bean can maintain the user conversation state across multiple invocations. Same Stateful session bean instance will respond every time when there is only one EJB container.
But if there are  multiple EJB containers behind a load balancer, and on subsequent request , load balancer forwards the request to different EJB container, how that different EJB container will able to get the user state?

Regards,
Raj
Hi Everyone,

I have to write a spring job, which should fetch multiple records from database ,create a zip file using those records and insert the zip file entry, back  into a separate database table. This zip file will be transferred to  some other application, later on. Problem is that there is a 10 MB restriction on data transfer so i need to make a zip file with max size of 10 MB. I thought of using chunk of 500 records. Now suppose 10 MB limit reaches by adding 475 records into the zip file, what should i do with remaining 25 records?

Regards,
Raj
3 years ago
Hi,

I need a general understanding about the scope of objects in a Spring based web applications. Suppose i have a a web application with a Rest Webservice. The  web application either fetches the record from database or persist the  data into database. Is Singleton ,Prototype and prototype with ScopedProxyMode.TARGET_CLASS enough. Should i look into Request scope also?

RestController - BeanObj -> ServiceImpl -> DaoImpl->DB

Regards,
Raj
4 years ago

Jeanne Boyarsky wrote:Raj,
How does the code get used in Java code? From your example, it looks like unused code which probably isn't the intent.



Hi Jeanne,
This class is auto generated by a proprietary framework. During build, the framework read a UI Form document file  and emit such configuration java file for it.

At run time  based on the request payload, framework consult this Configuration class ,  create the Form specific Java Bean and perform the operations like validations, persistence etc. During db fetch, Framework will use this indexes and store the select query result  into the Java bean. Form Java bean has an array to store the data. Each index is fixed and represent a specific field as per document. It is also used in creating a response payload.

Regards,
Raj
4 years ago

Junilu Lacar wrote:Since it is a field declaration, it's not something that any test code can execute directly. So even if you could write a test that asserts something about the array, I doubt it would be reported as being "covered" by a test. The fact that it is a static field declaration guarantees that it wil be executed when that class is loaded.

Are you trying to get 100% coverage? Don't. It's not worth the effort. You worrying about having test coverage for that line of code has already been a waste of time.



Yes I was trying for 100 % code coverage. I will try to convince my team members not to consider such cases. Thanks!!  

Regards,
Raj
4 years ago
Hi Everyone,

Wile running Jacoco , i found the highlighted line without code coverage. I want to know how can i write a test case to test it. It is an array, representing the index of the pojo fields where code will save the result of select query.

public class  MyClass {
.
.
.
.
private static final String SELECT = "SELECT ack_num, testform_detl_id, uniqueno, assment_year, ver_name FROM test_form_detl";
private static final int[] SELECT_IDX = { 32, 34, 35, 36, 37 };
.
.
.
.
.
}



Sorry to use quotes to highlight the red text.

Regards,
Raj
4 years ago
Thanks Jeanne,

Ok i got it. Does Annotation based configuration, as versatile as XML based Metadata?

Regards,
Raj
8 years ago
Hi ,

I want to learn Spring Framework. I want to know which is the preferred way of configuring IOC Container:-
1. XML based Metadata
2. Annotation based Configuration
3. Java based Configuration

I want to use the configuration later on in Enterprise application development.


Thanks,
Raj
8 years ago
Hi Guys,

I aim to become a Software architect in future. I want to select one out of the below books to study the Software architecture principles:-

1. Software Architecture: Foundations, Theory, and Practice
2. Software Architecture in Practice 3rd edition

I have gone through the Table of Contents. But i am still not able to decide, which one should i select.If anyone has read these , please suggest me.


Thanks,
Raj
9 years ago

i know that super keyword is used to call overridden method version of superclass but as universal truth we can't override static method then why it is working here, what is the wrong with java ?



It is not possible to override static method. But it is possible to hide the static method by defining another method with the same signature in the subclass. So actually we can call the supper class static method by invoking SUPER_CLASS.staticMethod() or superClassINstance.staticMethod() or super.staticMethod() in subclass.

Even if you write superClassINstance.staticMethod() , compiler will change it to SUPER_CLASS.staticMethod().

Thanks,
Raj
Yes there should not be setter methods for a derived field.This was just a dummy code since i didn't want to paste original source code from my project. And in a hurry i generated all setter and getters.
Thanks for looking into the code.

-Raj
Hi Mark,

I dont know much about WRML.May be it is far better then my thought.But just i want to know Does your book has strong coupling with WRML? Can i learn REST full webservices with/without WRML from this book? And who is your target audience- Beginner,Intermediate or Advanced users.


Thanks,
Raj
12 years ago
Hi James,

Thanks for reply.Yes you are correct.Then i have to recalculate the properties for other service.I noticed one more thing , even if only one service method is going to use this DAO but still the current code couples the userid with the derived properties.So unless you supply userid you cannot get the derived properties.

Thanks,
Raj
HI,
I have a sample code below.In which i fetch collection of half filled PrefixBeans from database.Then i use a service class to derive the remaining properties of the prefixbean and update the bean.My doubt is since the remaining bean properties are dervied from one or tow bean properties.Should i write the derivation logic in the bean getters or is it ok to calculate the remaining properties in the service class.?If i do in the service class, is it violating any OOP principle?Do you find any code smell here?

The PefixBean will contain the organizationPrefix and existingItemCount already filled by the DAO.



The below service method is used to calculate the remaing fields of the PrefixBean.


String objects which cannot be referenced once the 'for loop' executes are very likely garbage collected, which is why the profiler is unable to show them.



No i am adding all the objects to list using addObj method, so all the strings should not be garbage collectible.Also if I increase the for loop limit to 200000000000000 from current 2000, I will get out of memory exception. Profiler should be able to catch it as it is a memory leak. Is this behavior specific to this profiler only or is common in all the profilers?

Thanks,
Raj
13 years ago