Win a copy of Terraform in Action this week in the Cloud forum!

Mahendra Shelke

Greenhorn
+ Follow
since May 08, 2006
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mahendra Shelke

Hello Folks,

After months of hard work I have finally submitted the assignment , on Monday 14th Feb 2011.
Thanks to all the Rancher's , without your help it would have been very difficult.

Although I still have one question lingering, I have booked the essay examination on Sunday 20th Feb 2011.

I was not sure I will have to take the essay exam first , will it be a problem ?

Thanks once again!

Regards,
Mahendra

Roberto Perillo wrote:

Roel De Nijs wrote:And as a side note: I don't get why you need this getURLyBirdServiceInstance-method



Me neither!



You guys are right, ofcourse I dont need getInstance there , the reason I had added it because I was facing class cast exception , which was totally wierd , had forgotten to mention it , I have removed it now.

Roberto Perillo wrote:Howdy, Mahendra!

I just didn't get well the point of your getInstance method: do you want your UrlyBirdRemoteServiceImpl class to be a singleton? I think it is better to only instantiate the business component when the application starts and use this instance throughout the code. How about something like this:



There is no singleton involved.

The basic problem I was facing was UrlyBirdService was also a Remote , It was difficult to remove as It would have thrown a Cast exception.
A simpler way of doing it was to create a new interface UrlyBirdRemoteService only to be implemented by Remote object , i.e RemoteUrlyBirdServiceImpl .

Now RemoteUrlyBirdServiceImpl is bound to the registry, and in the controller I simply do a getURLyBirdServiceInstance() on RemoteUrlyBirdServiceImpl , which returns me the UrlyBirdService.

This solves the purpose.

Roel De Nijs wrote:But the functionality has changed: now each invocation of the getInstance method returns the same instance and before it always returned a new instance. I don't know if it's intentional (and your program needs it).


No Roel , The functionality is exactly the same , If you see the implementation RemoteUrlyBirdServiceImpl , getURLyBirdServiceInstance() method always returns "this" which dosent make it a singleton.


To make it cleaner, I have removed UrlyBirdRemoteServiceImpl class completely , and now RemoteUrlyBirdServiceImpl is implementing UrlyBirdRemoteService.

Please see the code below;




Thanks,
Mahendra

Hi Roel,

I guess you did not see the implementation properly or I miscommunicated.

These interfaces are not similar in anyway, I am only dealing with one interface ( UrlyBirdService ) in my Controller.

UrlyBirdRemoteService.getURLyBirdServiceInstance() will return UrlyBirdService instance which I'll use for invoking high level service actions.

UrlyBirdRemoteServiceImpl is only a wrapper for binding the remote object and implementing Remote.

Please let me know if its not making sense even now.

Thanks
Mahendra



Thanks for your quick reply Roel,

I have modified my design to include the following interface



UrlyBirdService no longer extends from Remote hence DirectUrlyBirdServiceImpl wont be a Remote object any more.

Please let me know if this makes sense ?


Thanks
Mahendra
Howdy Roberto,

I am doing great , thanks for a prompt reply, I appreciate it.

UrlyBirdServiceFactory.getInstance() returns DirectUrlyBirdServiceImpl for direct connections and returns RemoteUrlyBirdServiceImpl in case of remote connections.

UrlyBirdService is a wrapper over low level DB operations , I am using it directly in my Controller , like

The real problem is UrlyBirdService is extending from Remote, which I cannot remove as there would be ClassCastException , after casting the object received from lookup.

So do you think DirectUrlyBirdServiceImpl extending from Remote is okay ?

I have been through the post you mentioned, I don't think my design is getting cloudier as of now , apart from the service extending Remote issue, I hope you agree.

Looking forward to your reply.

Thanks,
Mahendra
Hello Ranchers,

Javaranch has been always a great help to everyone seeking one, I really appreciate everyone's efforts in solving other's query.
I have a design question , I am not sure if it contradict's with Sun's requirement , as highlighted below;

In either case, the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used , in which case, the networking must be bypassed entirely.

I have a service interface which extends from Remote and two classes one for standalone viz. DirectUrlyBirdServiceImpl and another for RMI implementation (RemoteUrlyBirdServiceImpl) implement this interface. Out of which only RMIUnicastRemoteObject extends from UnicastRemoteObject out the two.

Please see the code snippet below;




UrlyBirdServiceFactory.getInstance() is being used when binding the remote object , and also while creating an instance of DirectUrlyBirdServiceImpl in Controller for direct connections.


Now whenever I run rmic tool on all the classes stub & skeleton are generated for both DirectUrlyBirdServiceImpl and RemoteUrlyBirdServiceImpl ( As UrlyBirdService is extending from Remote interface )

Is this approach correct ?

Am I contradicting SCJD's requirement mentioned above or other in any way ?

Though I am bypassing networking completely , I feel the generated stubs may send incorrect signals to the examiner , although stub & skeleton for DirectUrlyBirdServiceImpl can be very well suppressed , I do not feel it would be the right way of doing things.

I really appreciate your help on this.

Thanking in advance & wishing you all a very happy and prosperous new year!

Mahendra
Sorry for those slang Peter ..
I got the answer , thanks a lot guys for your help ..


public class JNITest
{
static
{
System.loadLibrary("JNITest");
}

native void showMessage(String str);

public JNITest()
{
System.out.println("In the constructor of the java program");
}

public static void main(String s[])
{
JNITest JNT = new JNITest();
JNT.showMessage("Passing string from Java");
}
}


14 years ago
Hi All ,
I have been trying to find a solution for loading an ActiveX component dll thru JNI and executing one of its functions.
I have created a dll and wrote a simple funtion in it.
Using System.load() method i loaded the same dll in da memory.
But i am not able to make any native calls .
Please could anyone suggest me any alternative to this.
Please find the code pasted below.


Program Output :

Loaded !!
Exception in thread "main" java.lang.UnsatisfiedLinkError: printMessage
at scjp.TestNullVector.printMessage(Native Method)
at scjp.TestNullVector.main(TestNullVector.java:23)


Can someone throw some light on the same ..
14 years ago
You are correct the answer is 1 , that is because v is final without any initialization parameters i.e it is a blank final and must be initialized in the constructor to null or any other valid value you wish to.
I guess package private is nothing but default access modifier .. nothing new has been added explicitly ..
Hi Fellow Ranchers , since a few days this question is bugging me a lot .. I am not able to decipher it ..

just fool the compiler



here the compiler will think that flag will be false sometime and will result in compilation ..