Solved

What does this code snippet do in Java?

Posted on 2007-03-28
3
178 Views
Last Modified: 2010-03-31
What does this code do? Can someone put some comments in it so I can understand it

      public String getNodeAttribute(long nodeId, String attributeName) throws ManagementSupportException {

            TEServiceStub.GetNodeAttribute request = new TEServiceStub.GetNodeAttribute();
            request.setAttributeName(attributeName);
            request.setNodeID(nodeId);

            TEServiceStub.GetNodeAttributeResponse response = null;
            try {
                  response = stub.getNodeAttribute(request);
            } catch (RemoteException e) {
                  logger.warn("Fail to call TEService :" + e);
                  throw new ManagementSupportException("Fail to call TEService :" + e);
            }

            if(!response.getStatus().getSuccess()) {
                  logger.warn("TEService return failure while call getNodeAttribute()");
                  throw new ManagementSupportException("TEService return failure while call getNodeAttribute()");
            }
            return response.getAttributeValue();
      }
0
Comment
Question by:yankeebushsoftware
  • 2
3 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 18813741
Looks like a code to call a web-service or something of that sort using a proxy. Difficult to tell without knowing what TEServiceStub and GetNodeAttribute are.
0
 
LVL 9

Accepted Solution

by:
arioh earned 500 total points
ID: 18813742
I suppose, it invokes web service's methods

     public String getNodeAttribute(long nodeId, String attributeName) throws ManagementSupportException {

            // creating "request" object using service's method
            TEServiceStub.GetNodeAttribute request = new TEServiceStub.GetNodeAttribute();
            // setting "request" object attributes
            request.setAttributeName(attributeName);
            request.setNodeID(nodeId);

            // declaring "response" object
            TEServiceStub.GetNodeAttributeResponse response = null;
            try {
                  // invoking web service's method
                  response = stub.getNodeAttribute(request);
            } catch (RemoteException e) {
                  logger.warn("Fail to call TEService :" + e);
                  throw new ManagementSupportException("Fail to call TEService :" + e);
            }
 
           // processing "response" object
            if(!response.getStatus().getSuccess()) {
                  logger.warn("TEService return failure while call getNodeAttribute()");
                  throw new ManagementSupportException("TEService return failure while call getNodeAttribute()");
            }
            // returning result
            return response.getAttributeValue();
      }
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18813905
I think this should have been a split - I was the first one to say it calls a web service method.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now