Glass Life-Cycle

In this chapter we will focus on Glass life-cycle. First lets try to rephrase again what Content Glass and State Orineted Sharing are.

The Glass Concept

  • A Glass (in terms of ContentGlass) is mechnism for sharing content.

  • Content is represented as Widgets which are components that hold the shared data and possibly some application logic related with the data.

  • Content Glass sharing is State Oriented - it means that widgets are shared in relation with state of some Context. 

  • This Context may refer to virtual and physical objects and things from the world around us. In terms of Content Glass a website is and object as well as newspaper as well as heartbeat.

  • In terms of Content Glass anything that may have State representation is a potential Context for State Oriented Sharing and Content Glass provide the means for sharing content in relation with that Context

  • When you do state oriented sharing you associate the shared widget with State of some context. A State in terms of Content Glass is some collection of information that  represent some state of the context object (the object related with the widget). 

  • State can be for example: some code, some word(s), some image, some value some URL etc'. Generally State is is representation of an object

  • Shared Widgets are associated with State

  • When State Oriented Sharing App (SOSA) or Website with installed Content Glass are in a given state, and there are widgets that was previously shared in relation with current state, the Widgets will be presented. For example, if you related a Widget with some bar-code then when other user that uses your app, and scan the same bar-code will see the Widget! That the idea

  • But there is something more- Widgets are not only shared in relation with State of an object but are also set to be visible by limited scope of peers. The other users that can see a shared widgets are considered as the peers-group of this widget. 

  • And peers-group can be either determine by the user that create the shared widget, or by the application itself. It depends on the Glass Pattern (refer to advance tutorial that explain some patterns) .


Creating the Glass Engine

The first step of setting up a Glass is to create and initialize the glass. The operation of initialization preare the internal Content Glass engine however at this step the Glass is not yet ready to eithere share new widgets or present shared widget. The reason is that for sharing to happen we first need our app to determine the State (of something) by which we want to either create shared widgets,and/or present new widgets.


Seeting the State Layer 

For Content Glass in order to create and/or show shared widgets, you should first set at least one State layer. Content Glass engine provide with layers mechnism that let the same engine manage multiple state layers. Each layer holds an info for a single State representation of the Context object.

No we can rephrase the above - For Content Glass in order to create and/or share widgets you sould first define in your app the State by which sharing is associated with. This State is represented by Layers. Content Glass let you define one or more layers. Many times one layer at a time is enough however there are case where we need to run two or more layers at the same time. For example when using Content Glass over web-page - the user visit some page and this page belongs at the same time to specific:

  • page url
  • domain
  • top level domain

Each of the above are States of the website (the context), and we may want to show user on a certain URL widgets that has been shared in relation with each of thse states. this is an example of using three states at the same time. 

Note that in the case of current tutorial we create an app that uses only one state at a given time. This state is made of code that user enter. As been told prevously this application is very abstract and intend to demonstrate the ideas. So lets imagine that the code represent some physical object.

Now we can say that setting a State layer is the act of preparing our Glass to share new widgets or show previo9usly created widgets in relation with some physical object which is represented by a code.  


Starting The Glass

Once state layer has been set we can start the Glass. After starting the Glass we are able to:

  • Create new widgets that will be associated with the current selected State
  • Show shared widgets that has been shared in relation with current State.  
  • Allow collaboration between on-line peers that view the same shared widgets 

And of course our app may perform other variations of the above operations such as getting shared widgets but only the owned one, and more. The concepts is however simple - once State is defined (by layers) sharing operations can take place. 

In Content Glass you do not have to deal with the actual sharing algorithm and resources. It is transparent for you and handled internally by the Content Glass engine. What you can do is for example create new type of Widgets which are suitable for your application and let the user share these widgets. You can also define your own State wizard, as will be discussed by next chapter. 


Stop The Glass

After glass has been started it can also be stopped. This is usually the case when switching between glasses, which is not discussed here.  After stopping it is possible to start again


Destroy the Glass

Glass can also be destroy. After destroy you can't start the glass and you have to start from beginning.


Advanced Cases

There are more advanced cases of Glass life cycle for example:

  • Switching between Glasses
  • Dynamically update state layers

However for this tutorial we will stay on the basic level.



The basic Glass Life Cycle is 

  1. Create and initialize the Glass
  2. Set the State layer
  3. Start the Glass
  4. Stop the Glass
  5. Destroy the Glass