?
Solved

What does this code snippet do in Java?

Posted on 2007-03-28
3
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 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