Skip to main content
BlueMix free trial
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)

IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)

Sign in to participate Previous Next

Web Service example

Thanks Bjorn for the link... it was an interesting read. I think I have a better idea on how it works with agents now. Thanks Jochen and Simon for your precisions.

If you don't mind, I'd like to ask a web service related question now. Take the following web service:
import lotus.domino.*;

public class JavaWithRecycle {
private Database _dbNames=null;

public JavaWithRecycle() {
try {
Session session = WebServiceBase.getCurrentSession();
_dbNames = session.getDatabase("", "names");
} catch(Exception e) {
e.printStackTrace();
}
}

public String loopPeople() {
StringBuilder sb = new StringBuilder();
try {
View viewNames = _dbNames.getView("($VIMPeople)");
Document docNames = viewNames.getFirstDocument();
Document nextDocNames=null;
while (docNames != null) {
sb.append(docNames.getItemValueString("FullName"));
sb.append(",");
nextDocNames = viewNames.getNextDocument(docNames);
docNames.recycle();
docNames = nextDocNames;
}
viewNames.recycle();
} catch(Exception e) {
e.printStackTrace();
}
return sb.toString();
}

public String loopGroups() {
StringBuilder sb = new StringBuilder();
try {
View viewNames = _dbNames.getView("($VIMGroups)");
Document docNames = viewNames.getFirstDocument();
Document nextDocNames=null;
while (docNames != null) {
sb.append(docNames.getItemValueString("ListName"));
sb.append(",");
nextDocNames = viewNames.getNextDocument(docNames);
docNames.recycle();
docNames = nextDocNames;
}
viewNames.recycle();
} catch(Exception e) {
e.printStackTrace();
}
return sb.toString();
}

}

As you can see in this simple example, I did my best to recycle all Document objects in the loop as well as the View object. So this code doesn't take much memory (as opposed to when I didn't recycle).

My question is, where in the code should I recycle the Database object? It's a member of the class that is initiated in the constructor and use in more than one methods. Also, should the Session object be recycled (and if so, where?)? I've read contradictory things about this.

It's easy to know when a agent completes... but what about web services? If a .NET consumer create a new instance of my web service, the constructor is called and _dbnames is assigned a value. The consumer can then call some methods that uses the _dbnames value. When do we know when a web service completes?

Sorry for asking more questions, I'm just trying to apply what I just learned about Java agents to Java web services.

Your help is very appreciated.


Feedback response number WEBB88VJXC created by S Macgowan on 09/01/2010

Do we need to recycle Notes objects... (S Macgowan 30.Aug.10)
. . answers for 1 and 2 (Jochen Sack 31.Aug.10)
. . . . That's what I thought.... but... (S Macgowan 31.Aug.10)
. . . . . . I've seen similar behaviour with Ja... (Jochen Sack 31.Aug.10)
. . . . . . . . So to recycle wouldn't correct this... (S Macgowan 31.Aug.10)
. . . . . . . . . . two different animals (Jochen Sack 1.Sep.10)
. . . . . . . . . . I did some more tests... (S Macgowan 31.Aug.10)
. . . . . . . . . . . . pretty much in sync with my own exp... (Jochen Sack 1.Sep.10)
. . . . . . . . . . . . now in LotusScript (S Macgowan 31.Aug.10)
. . . . . . . . . . . . . . It doesnt reclaim the memory (Bjorn Tore Olse... 31.Aug.10)
. . . . . . . . . . . . . . . . Web Service example (S Macgowan 1.Sep.10)
. . . . Web services are basically agents. (Simon ODoherty 31.Aug.10)




Printer-friendly

Search this forum


Sign In or Register

 Sign In or Register
Sign in
Forgot your password?
Forgot your user name?
Create new registration

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support


 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite