john sal

Ranch Hand
+ Follow
since Jul 30, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by john sal

Following is the problem description:

Class should be singleton for the same index, as object properties may vary from index to index but will remain same for the same index.

Could somebody please let me know if below code is fine or there is any better way to address this ?

getSingletonInst is used to get the singleton object and map contains index to object mapping, I am doing map lookup to check if object is already present for the given index before creating it. fileLoc property will remain same for similar indexes. I am trying to use double check locking to avoid synchronization in case of multiple threads.

8 years ago
I am new to apache CXF and REST.

I am using apache CXF and trying to write a generic rest interface which works with any kind of DTO which implents DTOIntf.

Super interface for each DTO is DTOIntf

rest interface which i want to write would be as follows:


This should recieve JSON from client for specific DTOs which should be converted to DTOIntf.

I am not sure how this will be achieved.

Is there any way to pass specific DTO from client which will be mapped to generic DTO interface "dto" of create method?

Can it be done through customizing Jsonprovider implementation?
10 years ago
I am working on a web client which connects to a external server through a socket connection. Following are the two design approaches

Approach 1st:
Each request from a client opens a new socket connection to a server, sends request and process the response.

Problem: Too many socket connections

Approach 2nd:
There will be only one socket connection, all the client will send request through same connection.

Problem: Not sure how to map a response to a particular request, may be bit slower than approach first.

Approach 3rd:
Its more or same like 2nd approach, there will be only one socket connection between the client and external server, the only difference is for each client request a Runnable object will be created an submitted to the thread pool, which again are going to use the same connection for sending request.

Problem: how to map the response with the request?

Can somebody help me in finding the best way (Or if there is any other way of designing this). More over how can I solve the problem mentioned for 2nd and 3rd approach if I take either of it as a solution?
12 years ago
I am working on a web client which connects to a external server through a socket connection. Following are the two design approaches

Approach 1st:
Each request from a client opens a new socket connection to a server, sends request and process the response.

Problem: Too many socket connections

Approach 2nd:
There will be only one socket connection, all the client will send request through same connection.

Problem: Not sure how to map a response to a particular request, may be bit slower than approach first.

Approach 3rd:
Its more or same like 2nd approach, there will be only one socket connection between the client and external server, the only difference is for each client request a Runnable object will be created an submitted to the thread pool, which again are going to use the same connection for sending request.

Problem: how to map the response with the request?

Can somebody help me in finding the best way (Or if there is any other way of designing this). More over how can I solve the problem mentioned for 2nd and 3rd approach if I take either of it as a solution?
12 years ago
please read your private messages.
Thanks a lot for the help ...
What I want to make sure that after reading the entire article I don't get the same error again....as already spend lot of time in this whereas the alternate is always available.
1. you mean we should keep the xsd and xml as it is.

2. From the code we should remove

factory.setValidating(true);
factory.setXIncludeAware(true);

3. and let the validator validate the xml? using
validator.validate(source, result);

4 and file will have reference to main.xsd

File schemaLocation = new File("main.xsd");

Please correct.

More over can you pl elaborate on follwing lines?

"In loading the xml and xsd, you can set them up with main.xml and main.xsd alone. Let the engines load the included xml and xs:include schema of shiporder.xml and shiporder.xsd. "



let's leave xinclude for now. For the first scenario, the program that i wrote to parse the xml is also giving the same error. "root not defined."
All the files along with the program parsing those files are under the same directory.

I did all the changes as suggested by you however not sure where i am doing wrong.

following is the main.xml



following is the main.xsd


following is shiporder.xml



following is shiporder.xsd



Now following is the code to parser the xml


sorry I tried this as well however again getting the same error...element type root is not declared.

you can also check the same in following tool for xml validation

http://pscode.org/xml/xmltools.html

more over I tried the same with xinclude as well

<?xml version="1.0"?>
<root>
<xi:include href="foo.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
</root>


but this is not including the foo.xml during parsing. All the following attributes are already set. How the same can be done with xinclude?

Thanks for the reply, However I am still getting the same error, when parsing using dom parser.

org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'root'.


Used the same xsd for main.xml posted by you



Seems like in above xsd definition for root tag is missing. Please correct?

I changed the schema for shiporder.xsd as well:




More over can you please elaborate on point[0]:
" First, you have to put the root element name and that of the DOCTYPE agrees with each other. At present, it is "root" in one and "doc" in another. I take it "doc" as the actual name hereinbelow (or switch accordingly). "

please let me know in case any further modification is required in the schema?
I am including one xml file into other:


main.xml
-------------------------------------------------


suppose below is the foo.xml
-----------------------------------------------



xsd for foo.xml is shiporder.xsd.

Now i parsed the main.xml using dom, since there is no xsd defined for main.xml hence during dom parser validation i was getting following exception:

org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'root'.

can someone please let me know how to write an xsd for the main.xml so that I can parse the main.xml. I tried to write the same however not sure how to deal with "<!DOCTYPE doc " in xsd.

(there is already an xsd for foo.xml which i think have to include in main.xsd)


database conncetions are fine....More over the problem is related with the two different session as I am retreiving the User in one session and trying to load the associated object in different session.
I am using spring ORM and getting lazy initialization exception while retrieving the associated object. The scenario is as follows:

There is a user table which is associated with group table. In the User.hbm.xml the lazy attribute is marked as false.

Now I want to get the user and want to access the group objects user is associated with in different class.

The way I am retrieving the User is as follows, Suppose I want to get this in my class Example

class Example{
ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("Spring xml files");

foo(){
UserDao userDao= (User) appContext.getBean("userDao");
user usr = UserDao.getUser();
usr.getGroups(); //giving lazy initialization exception
}
}

UserDao is a dao class that intracts with the database using hibernate APIs


This lazy initialization exception is obvious as I am loading the object in one session and trying to access the associated object in different session.


Is there any way to get away with it apart from making the lazy attribute false? (Keeping in mind that I cannot touch the existing files)
Hi,

I have a requirement where-in I need to call a java program/code from Excel add-in code written in VB.
Would like to know if there is any way to do same ...if yes then how can i do that....?(any third party tool or framework available for this??)
13 years ago