Solved

What does this attribute array do in this java code snippet?

Posted on 2007-03-28
3
207 Views
Last Modified: 2010-03-31
What does this attribute array do in this Java Snippet?
public Attribute[] writeSessionLog(Session session) throws ManagementSupportException {

            TEServiceStub.SaveSession request = new TEServiceStub.SaveSession();
            request.setLabID(session.getLabid());
            request.setSessionUID(session.getSessionId());

            //create Attribute from the session
            TEServiceStub.AttributeArray array = new TEServiceStub.AttributeArray();

            TEServiceStub.Attribute hwVersion = new TEServiceStub.Attribute();
            hwVersion.setName("HW_VERSION");
            hwVersion.setValue(session.getHwVersion());
            array.addAttributes(hwVersion);

            TEServiceStub.Attribute startTime = new TEServiceStub.Attribute();
            startTime.setName("START_TIME");
            //FIXME: what format the time should be?
            startTime.setValue(session.getStartTime() == null ? new Date().toString() : session.getStartTime().toString());
            array.addAttributes(startTime);

            TEServiceStub.Attribute finishTime = new TEServiceStub.Attribute();
            finishTime.setName("FINISH_TIME");
            finishTime.setValue(session.getFinishTime() == null ? new Date().toString() : session.getFinishTime().toString());
            array.addAttributes(finishTime);

            TEServiceStub.Attribute tester = new TEServiceStub.Attribute();
            tester.setName("TESTER");
            tester.setValue(session.getTester());
            array.addAttributes(tester);

            TEServiceStub.Attribute testEvent = new TEServiceStub.Attribute();
            testEvent.setName("TEST_EVENT");
            testEvent.setValue(session.getTestEvent());
            array.addAttributes(testEvent);

            TEServiceStub.Attribute testOrg = new TEServiceStub.Attribute();
            testOrg.setName("TEST_ORG");
            testOrg.setValue(session.getTestOrg());
            array.addAttributes(testOrg);

            request.setAttributes(array);

            TEServiceStub.RequestStatus status = null;
            TEServiceStub.SaveSessionResponse response = null;
            try{
                  response = stub.saveSession(request);
                  status = response.getStatus();
            } catch(Exception e) {
                  logger.warn("Fail to call TEService :" + e);
                  throw new ManagementSupportException("Fail to call TEService :" + e);
            }

            if(!status.getSuccess()) {
                  logger.warn("TEService return failure while call saveSession()");
                  throw new ManagementSupportException("TEService return failure while call saveSession()");
            }

            return cast(response.getAttributes());
      }
0
Comment
Question by:yankeebushsoftware
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
elfe69 earned 250 total points
ID: 18814086
I do not know what TEServiceStub does, but as I see, array is used to store an array of attributes in the HTTP session (in order to retrieve those attributes later).
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 250 total points
ID: 18814093
1. All kind of attributes are stored in the array

>> array.addAttributes(hwVersion);
>> ...
>> array.addAttributes(startTime);
>> ...
>> ...
>> array.addAttributes(testOrg);

2. Then the array is set as an attribute on 'request'
    That way all the attributes are passed to the party that made the request

>> request.setAttributes(array);
0
 
LVL 37

Expert Comment

by:zzynx
ID: 18814591
thanx 4 axxepting
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
simple java question 3 55
Error in @AspectJ Based AOP with Spring 2 13
hibernate example issues from command prompt 10 40
Android development question 2 34
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

786 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