Gavin Tranter

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

Recent posts by Gavin Tranter

Ok, seems the easiest way was to call the main class of the jar from an external class that had already added a naive security provide that just accepted everything.

Not the cleanest but it works.
13 years ago
Hi all,
I am trying to test an application I have control over, however I can not change the application as that would invalidate the testing I am trying to carry out.
The application uses certificates to talk to a third party server.

The problem is, the values are hard coded, and we have hacked hosts file and iptables so we can connect it to the the third parties testing site.
(please dont ask, its horrible if you ask I may cry).

So the test site is a sub domain (partners.test.somedomain.com rather than partners.somedomain.com) and of course java complains.
So I would like to create a trust provider that just trusts everything.

Is it possible, from the command line, to somehow "install" this provider into the virtual machine so that my application will just trust all the responses?



Thanks
G

13 years ago
Not sure I am getting how E super Record would help as the things I am putting into E are subtypes.

On the other hand I think you might be right about not gaining anything from it. If i get a chance I will see if it works any better with just a List<Record> or List<? extends Record>.

Thanks
G
13 years ago
I thought that E super Record means that E is a super type of Record?

I think you are right in general and I will have to document that as a possibility. However I am only passing in list of one type (ie List<SomeTypeOfRecord>) rather then extends x.
Its a bit of a worry
13 years ago
Hi all,
I think this is more advice then a question as I think I now understand what the above message is trying to tell me.
Here is the setup:



Ok, so in my mind and Eclipse this all works fine, but line //EEEK fails big time on the command line.
I think basicly what is happening is that javac donst know what E should be, even though it has been told it will extend Record (which is why I think it should work), E is some object that extends Record, toNetSuiteRecord is returning some object that extends Record. It should all be fine.

I think the only way to fix this is to replace EEEK with:

Then provide the required class.

Can anybody offer any better advice?

For the record I am using generics because Record is just a Super type, it dosnt group the generic Record functionality, it is just there for structure, much like a marker interface, so this was the only may I could think of to offer the conversion for the many different sub types of Record I need.

Thanks
G
13 years ago
Have you tried starting from the point of view of trying to loop through the List and printing every value?
13 years ago
Thanks Rob, that really helped, I am now happier with my generic method, which I hope is robust enough and will reduce the maintenance of the code.

I ended up with this:


So I am passing in the two objects that need to be used in the synchronisation, and return the synchronised object.
The returned object is of the same type as the passed in object.

I am having to cast record to the type I need such as Customer, but I am happy with this, as I would have
to perform some sort of cast if I had made record generic.

G
13 years ago
the other reason I was trying to use generics, I wanted to minimize the amount of casting in the client code, which I would have been able to do if I set the parameter to the OurCrm super interface.
13 years ago
Do you know what, I have read the generics chapter of Effective Java at least twice. Yet I dont think it ever puts it like that, or given as an example, and yet that simple statement made more sense to me, thanks Rob.

Ok, I think I tried that and it didnt work, I was getting lots of red squiggles, perhaps more to do with the model. I will have a look at it again though as I would rather the method, private or otherwise is as robust as possible.

Seems I am not as good at generics as I would like to think I am ;)
13 years ago
hmmmm an interesting thought. I hadnt really given it much thought before.

I think, partly what I am trying to do is to make something as type safe as possible, from a very bad model.

I think I was seeing things from the API, it should take a generic object, search for it, then synchronise the found object with the existing object (thus syncing to different systems). I was trying to restrict the types of object that could be considered legal.
The method was private as I didnt see any need for it to be an API method.

Having thought about it, and having right a two solution, I think I was trying to use generics as a replacement for overloading/polymorphism due to the fundamentally flawed (in my opinion) models I am having to work with.
The model that we own, has three interfaces, which all inheritate from a base interface, then one class that implements those three interfaces.
Each interface represents an entity in a database.
The other model has no way of creating a search object from one of its records, or no way of linking the two.

I think the implementation I am happiest with, has one delegate for each of the database entities I am trying to sync.

Perhaps I was using generics as a golden hammer. I will look at my implementation again.
Thanks for your reply.

G
13 years ago
Hi all,
I am trying to bridge two, object models, one is our company DB, the other is from a 3rd Party CRM system.

Some interesting choices where made, and I have ended up with three interface that extend from a common interface, and
one object that implement the three interfaces!!!

So I am trying to "sync" two objects, ourCustomer with crmCustomer, and I am trying to use generics to do this, its work fine, all but for this last bit.
I chose this way as 90% of the code is "generic" between the three Classes, only the sync is really different and proving a headache.

I am hoping you guys can tell me if I am doing this right:



RecordType is the type of the crmRecords, I am using this to provide some form of type safety.
What I am trying to say, is that this method will take as a param an Object that extends from OurCrm and will return an Object of is of that type.

Not sure I explained that well.
Thanks
G

13 years ago
Thanks guys, esp for the quick response.
That clears that up, I wasnt aware that the values where cached at all.

G
13 years ago
Hi,
Sorry to be asking such a question, not sure where else to ask it.
A friend sent me the below code as it was performing oddly (she is a tester trying to pick up Java).

I think there is some strange autoboxing thing going, now I avoid autoboxing as much as possible.

in the first two comparisons, I think the comparison is being autoboxed so that it is comparing the
value of the Integers.
In the third one I think it is comparing the addresses of foo and bar.
So far so good, the next two comparising I think are autoboxed.

Now here is where the madness kicks in, the final comparison returns true, foo1 and bar1 are equal.
So is it autoboxing, well I dont think so. As it turns out, in InteliJ the reference for foo1 and bar1 are the same!!!
Is this the result of a widening operation?

Any help or suggestions would be great.
Thanks.

Gavin

13 years ago
These sound a little like home work to me.

1) Try a google search I am sure this will be able to define each of the 3 concepts and give examples.
2) Google OOA, I am sure there are a lot of articales that will allow you to draw a conclusion as to why we would want to use OOA principles, and hopefully cases where you may not wwant too.
14 years ago
Actual, I phrased that badly.
The default constructor will only be created by the compilor if no other constructors exist for the class.
14 years ago