Solved

What does this code snippet do in Java?

Posted on 2007-03-28
3
176 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:mayankeagle
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:mayankeagle
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
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 goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
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…

747 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

13 Experts available now in Live!

Get 1:1 Help Now