Solved

What does this code snippet do in Java?

Posted on 2007-03-28
3
180 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

739 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