cancel
Showing results for 
Search instead for 
Did you mean: 

Plz help me understand the concept of Singleton

Former Member
0 Kudos

Hello All,

Am new to Web Dynpro and reading about the Singleton property of Contexts.

Am referring to link: http://help.sap.com/saphelp_nw2004s/helpdata/en/81/95384162316532e10000000a1550b0/frameset.htm

but did not get the concept.

Would appreciate if you plz help me understand the same.

Awaiting Reply.

Thanks and Warm Regards,

Ritu

Message was edited by: Ritu Hunjan

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

This is a bloga nd it is pretty much in detail about singlton and

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/wdjava/cardinality%2bproperty%2csingleton%2bprope... this link is blog related to pin in using singlton:https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/4810. [original link is broken] [original link is broken] [original link is broken] [original link is broken]

Thanks

Former Member
0 Kudos

Hi Gareth

If you see the properties of root context node, always

cardinality : 1..1

singleton : true

because only one instance of root context exists.

if you create a node under root context node that can have signleton : true or false

if true you can not create more than one instance and bind it to the root context.

else if false you can create multiple instances of the node and bind it to the root context.

hope it clears..the confusion.

Regards

Abhimanyu L

Former Member
0 Kudos

Hi,

You might also want to search on Google for singleton explanations - the singleton principal is one that applies to most object orientated languages (Java and ABAP just being some examples) so you may find a simple example of what a singleton is elsewhere that you can then relate to Web Dynpro contexts.

Hope this helps,

Gareth.

Former Member
0 Kudos

The singleton property of context nodes has nothing to do with the "Singleton" design pattern.

Armin

Former Member
0 Kudos

Doesn't it?!

It's always seemed pretty similar to me... If a context node has its singleton property set to true then it can only exist once for the context - is that correct?

Gareth.

Former Member
0 Kudos

I don't know. Singleton context node does not mean "single instance of node per context" but "single instance of node inside parent node".

Armin

Former Member
0 Kudos

Ok - now I'm more confused than usual

Former Member
0 Kudos

Hi Gareth

If you see the properties of root context node, always

cardinality : 1..1

singleton : true

because only one instance of root context exists.

if you create a node under root context node that can have signleton : true or false

if true you can create more than one instance and bind it to the root context.

else if false you can create multiple instances of the node and bind it to the root context.

hope it clears..the confusion.

Regards

Abhimanyu L

Former Member
0 Kudos

Hi Ritu,

If you have node hierarchy in the context like, You have Node1 and inside Node1 you have childNode1.

Both nodes have 0..N or 1..N cardinality.

Now, ChildNode1 elements are depends on the parent node elements.

There are two possibilities:

1. All the childNode1 elements are common for all the Node1 elements. Each Node1 elements have common bunch of elements from ChildNode1.

2. All Node1 elements have their own bunch of the ChildNode1 elements.

Regards,

Bhavik

Former Member
0 Kudos

The "singleton" property defines if a context node instance exists per

- parent element (non-singleton)

- parent node (singleton)

Chris Whealy's book "Inside Web Dynpro for Java" explains the concept rather good.

Armin

Former Member
0 Kudos

Hi

See the Thread

Kind Regards

Mukesh

sridhar_k2
Active Contributor
0 Kudos

Hi Ritu,

The Singleton is a useful Design Pattern for allowing only one instance of your class.

The Singleton's purpose is to control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes. Since there is only one Singleton instance, any instance fields of a Singleton will occur only once per class, just like static fields.

Singletons often control access to resources such as database connections or sockets.

Ex :- If you want to access your Database with one connection, then make the connection class implements Singleton Interface.

public class DataBaseConn implements Singleton{

}

In WebDynpro

Singleton decides whether a single instance exists at a time for a node. If you declare a node as singleton, how much ever elements you create for the node, it will access the same element.

Regards,

Sridhar