28 October 2010

Jersey – Some issues with XMLElement / XMLWrapperElement in JAVA

using JAXB, Jetty and Jersey.
Any XMLElement that has a get function could not use the XMLElement or XMLElementWrapper. They can only use the get method if the variable name is not the string following the get in get method exactly. Or the variable should be set to public so that there is no get and set method is needed for it.
If you have private variable, do not use set and get methods and only use @XMLElement, it will be outputted. If you define it as public variable, then no need to use @XMLElement either.

xmlElement

old note: Static Method (Function)
If a method’s outcome is not really related to the object and is more of a general issue in the class or in your project, it might be a wise idea to define that as a Static method. Not defining it, do not create any harms but it is better to create as a Static method so that when you take a glance at your class, easily distinguish which methods are really related to an object.
tool_validation

27 October 2010

Google Data – GData

JAXB–Default Constructor

Working with JAXB, you need to have an empty constructor within your class. Any class that you are referring to from within your class is better to have this empty constructor class. I am using JAXB as part of Jetty Framework.
One other note: if you want to return result as a group (something that indent a little bit), then you need to return it as a separate class, which is a List (or ArrayList) of some other class (preferably String class).
If you want something to be shown this way:

           "initial"
you shouldn’t specify an XMLElement at the level of definition of the attribute in your class. If you do that, all the XML elements’ names will be the same. This way the first element will be different than the child nodes, which is really desirable.
Note: Apparently this only works in one level, you can not have multiple levels. I have tried creating different levels of classes, subclasses, inner classes, child classes but no one works. The best way to do is to use the following code
@XmlElementWrapper(name = "initialValues")
@XmlElement(name="initialValue")
public List initialValueEntries;
and then Wrap things up in an XMLElementWrapper.
You can learn more about the default constructor of classes using the JAXB framework here.

26 October 2010

String presentation of a Double

I am trying to create an XML document. I like all elements to be String elements in the Java file. Don’t want to mess things up having different kind of elements there.
So the question is how to transfer a double into String without loosing the formatting ? something like 1.323434E7 is not what I want to be presented in the XML format. There should be a way to create a complete String presentation of a Double.
I will update this post as I figure it out. I have remembered the vice versa operation, from String to Double but not this one. It is one of those obvious things that you can not remember when it is almost HOME time!

22 October 2010

Atom Publishing Protocol

If you are new to AtomPub, like me, you might want to check this video from Google that describes AtomPub video.

The person talking in the video is Joe Gregorio.

  • To add an entry to a feed you need to POST an entry to your feed.
  • To delete and entry you need to send a DELETE entry to the server.
  • To update an entry, you need to GET the feed, update it and then PUT it back (send it back to server)

REST Architecture

These are some good videos and tutorials about RESTful Architecture.

  • It is architecture.
  • you can use it using HTTP protocol
HTTP requests
  • GET
  • PUT
  • DELETE
  • HEAD
  • POST
Cacheable: the response can be cashed along the way
Idempotent: The request can be done multiple times
Safe: There are no side effects using that.
  • Get: Safe, Idempotent, Cacheable
  • PUT: Idempotent
  • DELETE: Idempotent
  • HEAD: Safe, Idempotent
  • POST
Code on demand: Load code on the fly (and to the browser and load them and use them)
Cache-Control: How long a response can be cached
Difference between Proxy and Gateway: Proxies are selected by user (user agent) while Gateways are selected by servers.
You can use XML-RPC and AtomPub
XML-RPC uses POST. It is not idempotent, cacheable and safe.
ATOMPUB (Zippable too, unlike XML-RPC)
  • GET – retrieve the info
  • POST- Create Resource
  • PUT- Update the resource
  • DELETE – Delete the resource

15 October 2010

Deprecated removal–First bug with high Severity

Can’t believe it, my first bug assigned is to remove a deprecated tag for a function and make it undeprecated. The severity of the problem is SERIOUS. Probably the severity is so high because of customers using the API. The easiest bug I ever fixed in my whole life.
For more information about Deprecation please refer to the wiki page.
This is a short paragraph from there:
In computer software or authoring programs standards and documentation, the term deprecation is applied to software features that are superseded and should be avoided. Although deprecated features remain in the current version, their use may raise warning messages recommending alternative practices, and deprecation may indicate that the feature will be removed in the future. Features are deprecated—rather than being removed—in order to provide backward compatibility and give programmers who have used the feature time to bring their code into compliance with the new standard.

14 October 2010

Windows 7 VMWare Issue

Today I have encountered with a VMWare problem. Not sure why it happens, but it doesn’t let me to join the network via the bridge connection. I am trying to sort it out. Using VMWare on a Windows 7 and hosting a Win 2008 server hosted on that. When Using NAT, everything works fine. However, the bridge connection does not work at all. It seems that the McAfee antivirus is sitting on top of my network card and doesn’t allow access to it via the VMWare.

vmware_workstation

Found this article about how to set up the bridge conenction in windows 7. However, the title suggests it should be fixed by now as the article discusses version 6.5 of VMWare while I am using version 7 of the VMWare.
Apparently updating to the latest version of WMWare (version 7.1.2) solved the problem that VMWare couldn’t diagnose the network adapter and just was loading the McAfee network adapter.
TIP: The source was because of an authentication failure. You might want to trick windows 7 and disable the Wired Auto Config service in Local Services (in Manage panel in Windows Control Panel). You also can disable the service from auto-start to disable so you won’t find any problem.

9 October 2010

Web Service Scenario

Looking for a way to present the way web services may call each other, come to the definition (which I was known it from before but in a different way) to workflow. Regarding this article a workflow can be used to describe how a scenario of web services can be accomplished.