<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Flos Blog</title>
	<atom:link href="http://floriansblog.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://floriansblog.wordpress.com</link>
	<description></description>
	<lastBuildDate>Mon, 30 Jan 2012 14:21:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='floriansblog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Flos Blog</title>
		<link>http://floriansblog.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://floriansblog.wordpress.com/osd.xml" title="Flos Blog" />
	<atom:link rel='hub' href='http://floriansblog.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Vaadin &#8211; generic SQLContainer FilterComponent</title>
		<link>http://floriansblog.wordpress.com/2011/07/11/vaadin-generic-sqlcontainer-filtercomponent/</link>
		<comments>http://floriansblog.wordpress.com/2011/07/11/vaadin-generic-sqlcontainer-filtercomponent/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 16:23:11 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[06 - generic SQLContainer FilterComponent]]></category>
		<category><![CDATA[Florians Posts]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[redVoodo]]></category>
		<category><![CDATA[SQLContainer]]></category>
		<category><![CDATA[Vaadin]]></category>
		<category><![CDATA[Vienna]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=1242</guid>
		<description><![CDATA[The last few days i spent my time to write a generic filter form for the vaadin SQLContainer. The main goal is to provide a vaadin component which uses the meta information of a vaadin container and prepares a filter form based on search fields. The form should offer a method which returns a vaadin [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=1242&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">The last few days i spent my time to write a generic filter form for the <a href="http://vaadin.com/addon/vaadin-sqlcontainer" target="_blank">vaadin SQLContainer</a>. The main goal is to provide a vaadin component which uses the meta information of a vaadin container and prepares a filter form based on search fields. The form should offer a method which returns a vaadin filter that can be used as a filter for the container which was used to initialize the filter component.</p>
<p style="text-align:justify;">The search fields should allow the use of wildcards like</p>
<table>
<tbody>
<tr>
<th>Wildcard</th>
<th>Description</th>
</tr>
<tr>
<td>&#8220;ABC&#8221;</td>
<td>ignores wildcards between &#8220;&#8230;&#8221;</td>
</tr>
<tr>
<td>ABC; XYZ</td>
<td>value of ABC or XYZ</td>
</tr>
<tr>
<td>&lt; ABC</td>
<td>lower than ABC</td>
</tr>
<tr>
<td>&gt; ABC</td>
<td>greater than ABC</td>
</tr>
<tr>
<td>&lt;&gt; ABC</td>
<td>not equal ABC</td>
</tr>
<tr>
<td>ABC</td>
<td>equals ABC</td>
</tr>
<tr>
<td>&lt;= ABC</td>
<td>lower equal ABC</td>
</tr>
<tr>
<td>&gt;= ABC</td>
<td>greater equal ABC</td>
</tr>
<tr>
<td>ABC*</td>
<td>starts with ABC</td>
</tr>
<tr>
<td>*ABC</td>
<td>ends with ABC</td>
</tr>
<tr>
<td>*ABC*</td>
<td>ABC between any characters</td>
</tr>
</tbody>
</table>
<p>The form will look like this:</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/07/filterform.png"><img class="alignnone size-full wp-image-1283" title="FilterForm" src="http://floriansblog.files.wordpress.com/2011/07/filterform.png?w=450&#038;h=271" alt="" width="450" height="271" /></a></p>
<h2></h2>
<h2>Filter Component Interface</h2>
<p>The filter component should offer a very simple interface.</p>
<p><pre class="brush: java;">public interface IFilteredComponent{

/**
 * Returns the metadata data source.
 * 
 * @return
 */
Item getMetadataDataSource();

/**
 * Sets the metadata data source. 
 * Based on this datasource the filter form
 * will be generated.
 * 
 * @param container
 */
void setMetadataDataSource(Container container);

/**
 * Returns the filter which matches the value and specified wildcard.
 * 
 * @return
 */
Container.Filter getFilter();</pre></p>
<h3>setMetadataDataSource</h3>
<p>Sets the container which should be filtered. For instance a PersonContainer. Based on the properties of this container a FilterItem is generated by the FilterComponent.</p>
<p><pre class="brush: java;">public class FilterComponent 
	implements	IFilteredComponent {


@Override
public void setMetadataDataSource(Container model) {
	this.model = model;
	// generates a filter item based on the model
	PropertysetItem item = generateFilterItem(model);

	// passes the item as form datasource
	filteredForm.setItemDataSource(item);
}

/**
 * Generates a filter item matching the given model.
 * 
 * @param model
 * @return
 */
protected PropertysetItem generateFilterItem(Container model) {
  PropertysetItem item = new PropertysetItem();
  for (Object propertyId : model.getContainerPropertyIds()) {
	Class&lt;?&gt; type = model.getType(propertyId);
	if (Boolean.class.isAssignableFrom(type)) {
		item.addItemProperty((String) propertyId,
		new FilterProperty&lt;FilterConstants.Bool, Boolean&gt;(
		FilterConstants.Bool.createIgnore(),
		FilterConstants.Bool.class, Boolean.class,
			(String) propertyId));
	} else if (String.class.isAssignableFrom(type)) {
		item.addItemProperty((String) propertyId,
		new FilterProperty&lt;String, String&gt;(&quot;&quot;, String.class,
			String.class, (String) propertyId));
	} else if (Integer.class.isAssignableFrom(type)) {
		item.addItemProperty((String) propertyId,
		new FilterProperty&lt;String, Integer&gt;(&quot;&quot;, String.class,
		Integer.class, (String) propertyId));
	}
  }
  return item;
}</pre></p>
<p>The resulting form which is based on the generated item will be a useable filter form for the given model container. All String, Integer and Boolean properties (For sure, I am going to implement searchfields for more datatypes shortly) can be specified by this form.</p>
<h3>getFilter</h3>
<p>On calling getFilter, the generated filter item and the values specified by the form will be used to generate a filter which can be used by the container. For instance PersonContainer.</p>
<h3>Movie</h3>
<p>I have prepared a movie which shows what i was writing about.<br />
Direct link to the movie:</p>
<p><a href="http://vimeo.com/channels/redvoodo#26276826" target="_blank">http://vimeo.com/channels/redvoodo#26276826</a></p>
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/26276826' width='400' height='225' frameborder='0'></iframe></div>
<h2>Conclusion</h2>
<p>I think that way of creating filters for containers is a very comfortable way to reduce the amount of required source code. And since vaadin offers really great features called Container, Item and Property it is really easy to write such generic implementations.</p>
<p>This component will be provided as a vaadin addon shortly.</p>
<h2>Additional informations</h2>
<p><a href="http://www.redvoodo.org/" target="_blank">redVoodo.org</a><br />
<a href="http://www.vaadin.org/" target="_blank">vaadin.com</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/1242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/1242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/1242/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=1242&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/07/11/vaadin-generic-sqlcontainer-filtercomponent/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/07/filterform.png" medium="image">
			<media:title type="html">FilterForm</media:title>
		</media:content>
	</item>
		<item>
		<title>redVoodo &#8211; a good idea to use eclipse databinding</title>
		<link>http://floriansblog.wordpress.com/2011/06/29/redvoodo-a-good-idea-to-use-eclipse-databinding/</link>
		<comments>http://floriansblog.wordpress.com/2011/06/29/redvoodo-a-good-idea-to-use-eclipse-databinding/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 18:19:27 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[05 why redVoodo uses databinding]]></category>
		<category><![CDATA[Florians Posts]]></category>
		<category><![CDATA[databinding]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[redVoodo]]></category>
		<category><![CDATA[Vaadin]]></category>
		<category><![CDATA[Vienna]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=1152</guid>
		<description><![CDATA[Actually i am writing the UI controllers which are connecting the redVoodo UI model with the UI parts that are responsible to visualize the model. After a sleepless night i decided to refactor the whole controller code. The problem was that i had to implement tons of observing code which observes the UI model for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=1152&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Actually i am writing the UI controllers which are connecting the redVoodo UI model with the UI parts that are responsible to visualize the model. After a sleepless night i decided to refactor the whole controller code. The problem was that i had to implement tons of observing code which observes the UI model for a few nodes and causes the UI parts to reflect these changes immediately. Of course, this solutions would have worked really well, but i did not like the way how this solution works.</p>
<p>In this blog i am going to describe why i decided to use eclipse databinding and show some code.</p>
<h3>The UI model</h3>
<p>RedVoodo offers a functionality called scoped actions and menu items. See post <a href="http://floriansblog.wordpress.com/2011/06/27/redvoodo-scoped-actions-and-menu-items/" target="_blank">redvoodo-scoped-actions-and-menu-items</a></p>
<p>Based on this feature actions and menu items are hidden if they are not in the scope of the active framework or sub application. For instance, an action called &#8220;delete Item&#8221; will only be visible in the &#8220;Item Subapplication&#8221; but will be hidden for the &#8220;Customer Supapplication&#8221;. These actions and menu items have &#8220;subapplication scope&#8221; which means, that they are only visible if a defined sub application is active. But there are also &#8220;framework scoped&#8221; actions and menu items. Their visibilty depends on the active framework like Sales, Inventory,&#8230;</p>
<p>If you want to write an application which tracks the currently active subapplication or framework, perhaps you have to write tons of code if the underlying UI model has a deep structure.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/uimodel.png"><img class="alignnone size-full wp-image-1162" title="uiModel" src="http://floriansblog.files.wordpress.com/2011/06/uimodel.png?w=450&#038;h=311" alt="" width="450" height="311" /></a></p>
<p>This class diagram shows a simplified version of the redVoodo UI model. The root element of the model is called YUiModel. It can contain exactly one YApplication which is an abstraction of the vaadin application. The YApplication contains many YFrameworks (like Sales, Inventory,&#8230;), but only one YFramework can be active at a time. Based on the active framework, different sub applications are shown. So each framework has its own set of YSubapplications. For instance, the framework sales could contain sub applications like Customers, SalesCampains,&#8230;</p>
<p>The application, each framework and each sub application can contain their own set of actions. Depending on the active framework and the active sub application, different actions should be visible at the UI.</p>
<p>This image shows what i am talking about:</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/scopedactions.png"><img class="alignnone size-full wp-image-1116" title="ScopedActions" src="http://floriansblog.files.wordpress.com/2011/06/scopedactions.png?w=450&#038;h=242" alt="" width="450" height="242" /></a></p>
<p>If the sales framework or a different sub application would be selected, completely different actions and menu items would be shown.</p>
<h3></h3>
<p>The model shown above is an EMF model. But since redVoodo should be a very extendable framework, using EMF is the default implementation. The core of redVoodo does not have any dependency to EMF. Instead it has a dependency to model controllers. These controllers are called edit parts. The UI parts like the &#8220;framework switcher&#8221; or the &#8220;sub application tree&#8221; are using these edit parts to visualize the model but do not have a dependency to the underlying model. So everybody can easily change the default implementation and provide edit parts that are based on a JPA implementation or edit parts that are even hardcoded.</p>
<h3>The problem</h3>
<p>Yesterday i started to write a lot of code to observe the ui model. I had to fetch the RootModelEditPart which represents YUiModel.</p>
<ul>
<li>I registered a listener at the RootModelEditPart which will be notified if the active application changes.</li>
<li>Then i implemented the same issue for the active application and added a listener to the active application which becomes notified if the active framework changes.</li>
<li>Then i added a listener to the active framework which becomes notified if the active subapplication changes.</li>
<li>Then i added a listener that becomes notified if actions are added or removed.</li>
<li>Then i started to handle many different constellations based on parts that become active and deactive.</li>
<ul>
<li>Remove listener from the lower containment structure</li>
<li>Switch the parent</li>
<li>Add the listener again to the lower contaiment structure</li>
</ul>
<li>Then i detected that each UI part has a different behaviour to the observables. The SubApplicationTabBar has to observe the OpenSupApplications-reference from YFramework too.</li>
<li>Then, at 10 p.m. i thought -&gt; Hmmmmmmmmmm, what a boring job!</li>
</ul>
<p>After a sleepless night, i took all the controller implementations and put it to trash since eclipse databinding can do all that stuff for me. I can heavily reduce the amount of required code and safe a lot of time.</p>
<h3>The (really easy) solution</h3>
<p><pre class="brush: java;">// 1. define a nested property
// 1. define a nested property
String nestedProperties =
 &quot;application.activeFramework.activeSubapplication.actions&quot;;

// 2. create the observable model value
IObservableValue modelOV = BeansObservables.observeDetailValue(
	new WritableValue(rootModel, IRootEditPart.class),
	nestedProperties, ISubapplicationEditPart.class);

// 3. create the observable target value
IObservableValue targetOV = PojoObservables.observeValue(
	ActionbarPart.this, &quot;subapplicationActions&quot;);

// 4. bind model to target
subapplicationActionsBinding = dbContext.bindValue(targetOV,
  modelOV, new UpdateValueStrategy(
	UpdateValueStrategy.POLICY_NEVER),
  new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)
	.setConverter(new NotNullConverter()));</pre></p>
<h4>1. define a nested property</h4>
<p>This nested property will be splitted by the &#8220;.&#8221; and the reference path starting at the IRootEditPart will be followed for each property.</p>
<p><pre class="brush: java;">// &quot;application.activeFramework.activeSubapplication.actions&quot;
// &quot;application.activeFramework.activeSubapplication.actions&quot;
// can be visualized as:
rootModel
	.getApplication()
	.getActiveFramework()
	.getActiveSubapplication()
	.getActions()</pre></p>
<p>The property &#8220;actions&#8221; inside the &#8220;activeSubapplication&#8221; will be observed. Every time it changes &#8211; nevertheless why it changes (due to a change of active framework or something) &#8211; we are becoming notified.</p>
<p>So we do not have to implement that boring listener hierarchy as described under &#8220;the problem&#8221;.</p>
<h4>2. create the observable model value</h4>
<p>Creates an IObservableValue which represents the &#8220;actions&#8221; property inside the &#8220;activeSubapplication&#8221; inside the &#8220;activeFramework&#8221; inside the &#8220;application&#8221;</p>
<h4>3. create the observable target value</h4>
<p>Addresses the property &#8220;subapplicationActions&#8221; of this instance (ActionbarPart.this). Every time the &#8220;actions&#8221; from &#8220;activeSubapplication&#8221; changes, the setter this#setSubapplicationActions(IActionEditPart editPart) should be invoked.</p>
<h4>4. bind model to target</h4>
<p>Therefore the DatabindingContext is used to bind the ObservableValues (model and target) to each other.</p>
<p>And here you can see the implementation of the setSubapplicationActions-method. It stores the subapplicationActions and puts it to the UI.</p>
<p><pre class="brush: java;">/**
 * Sets the list of subapplication actions.

 * Called by databinding.
 *
 * @param subapplicationActions
 *            the subapplicationActions to set
 */
public void setSubapplicationActions(
		List subapplicationActions) {
	internalSetSubapplicationActions(subapplicationActions);

	toUI_subapplications();
}</pre></p>
<p>That&#8217;s all i had to write to observe a nested property inside my model tree.</p>
<p>I hope you can see the big advantage of eclipse databinding too and hope you give it a try.</p>
<h3>Additional informations</h3>
<p><a href="http://wiki.eclipse.org/JFace_Data_Binding" target="_blank">Eclipse databinding</a><br />
<a href="http://www.redvoodo.org/" target="_blank">redVoodo.org</a><br />
<a href="http://www.vaadin.org/" target="_blank">vaadin.com</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/1152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/1152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/1152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/1152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/1152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/1152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/1152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/1152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/1152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/1152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/1152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/1152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/1152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/1152/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=1152&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/06/29/redvoodo-a-good-idea-to-use-eclipse-databinding/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/uimodel.png" medium="image">
			<media:title type="html">uiModel</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/scopedactions.png" medium="image">
			<media:title type="html">ScopedActions</media:title>
		</media:content>
	</item>
		<item>
		<title>redVoodo &#8211; scoped actions and menu items</title>
		<link>http://floriansblog.wordpress.com/2011/06/27/redvoodo-scoped-actions-and-menu-items/</link>
		<comments>http://floriansblog.wordpress.com/2011/06/27/redvoodo-scoped-actions-and-menu-items/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 15:44:43 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[04 Scoped actions and menu iems]]></category>
		<category><![CDATA[Florians Posts]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[redVoodo]]></category>
		<category><![CDATA[Vaadin]]></category>
		<category><![CDATA[Xtext]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=1104</guid>
		<description><![CDATA[As described in my last post, redVoodo is a project which target is to provide an environment that supports a developer to write business applications on a very quickly and easy way. A lot of base functions like selection support, lookups,&#8230; should be provided by the framework itself. Also the scoping of actions and menu [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=1104&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As described in my last post, redVoodo is a project which target is to provide an environment that supports a developer to write business applications on a very quickly and easy way. A lot of base functions like selection support, lookups,&#8230; should be provided by the framework itself.</p>
<p>Also the scoping of actions and menu items should be handled by redVoodo and no additional code should be required for this issue.</p>
<p>Scoping of actions and menu items means, that only actions and menu items that are in the scope of an active ui part should be visible. If the active ui part changes, also the visible actions and menu items should be adjusted to the current active part. In order to avoid confusion of users it is good practice to hide actions which are not required right now.</p>
<h3></h3>
<h3><a href="http://floriansblog.files.wordpress.com/2011/06/scopedactions.png"><img class="alignnone size-full wp-image-1116" title="ScopedActions" src="http://floriansblog.files.wordpress.com/2011/06/scopedactions.png?w=450&#038;h=242" alt="" width="450" height="242" /></a></h3>
<p>This image shows what i am talking about. The &#8220;purchasing (scoped) actions&#8221; and the &#8220;purchasing (scoped) menu items&#8221; are only visible if the purchasing framework is active.</p>
<p>For instance, if the inventory framework is active, no scoped actions and menu items are available. See next image.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/scopedactions_inventory.png"><img class="alignnone size-full wp-image-1119" title="ScopedActions_Inventory" src="http://floriansblog.files.wordpress.com/2011/06/scopedactions_inventory.png?w=450&#038;h=230" alt="" width="450" height="230" /></a></p>
<p>Of course, scoping is not limited to frameworks. Also active applications can cause actions and menu items to become visible.</p>
<h3>Implementation</h3>
<p>My current solution is well grounded and based on EMF (eclipse modeling framework). The ui is abstracted by an EMF metamodel. Instances of this metamodel (ui models based on this metamodel) are used by the core runtime to build the ui. States like active framework, active subapplication, open subapplications,&#8230; are stored in this model.</p>
<p>Additionally a &#8220;selection support OSGi service&#8221; was implemented. Ui parts are using the selection support to observe active ui model controller like &#8220;active framework controller&#8221; and &#8220;active sub application controller&#8221;. Based on the selections and the ui EMF model the parts are adjusting the actions and menu parts.</p>
<p>Since the ui is based on an EMF model I am going to write a <a href="http://www.xtext.org" target="_blank">Xtext</a> grammar in a few week which allows the developer to define the ui model on a very very comfortable way.</p>
<p>Further it should be also possible to use the redVoodo Xtext grammar to change the ui during runtime.</p>
<ul>
<li>open an redVoodo grammar editor in eclipse</li>
<li>connect to a running OSGi server</li>
<li>open the currently used ui model</li>
<li>modify the ui at runtime</li>
<li>changes are immediatelly pushed to the ui</li>
</ul>
<p>This implementation is a well grounded default. But since redVoodo offers a really extendable API everybody can easily write its own implementation.</p>
<p>The sourcecode will be available in about 2 &#8211; 4 weeks.</p>
<h3>Movie</h3>
<p style="text-align:left;">I have prepared a movie which shows how actions and menu items are hidden and showed again based on an active ui part. I hope you enjoy the movie.<br />
Direct link to the movie:</p>
<p style="text-align:left;"><a href="http://vimeo.com/channels/redvoodo#25664283" target="_blank">http://vimeo.com/channels/redvoodo#25664283</a></p>
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/25664283' width='400' height='225' frameborder='0'></iframe></div>
<h3 style="text-align:left;">Additional information</h3>
<p style="text-align:left;">If you are interested in redVoodo just follow our blogs and website.</p>
<p style="text-align:left;"><a href="http://ekkescorner.wordpress.com/" target="_blank">ekkescorner.wordpress.com</a></p>
<p style="text-align:left;"><a href="http://redvoodo.wordpress.com/" target="_blank">redVoodo.org</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/1104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/1104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/1104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/1104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/1104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/1104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/1104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/1104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/1104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/1104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/1104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/1104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/1104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/1104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=1104&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/06/27/redvoodo-scoped-actions-and-menu-items/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/scopedactions.png" medium="image">
			<media:title type="html">ScopedActions</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/scopedactions_inventory.png" medium="image">
			<media:title type="html">ScopedActions_Inventory</media:title>
		</media:content>
	</item>
		<item>
		<title>redVoodo EOS &#8211; early results</title>
		<link>http://floriansblog.wordpress.com/2011/06/09/redvaadin-eos-earlyresults/</link>
		<comments>http://floriansblog.wordpress.com/2011/06/09/redvaadin-eos-earlyresults/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 16:58:12 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[01 redVoodo EOS - early results]]></category>
		<category><![CDATA[Florians Posts]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[redVoodo]]></category>
		<category><![CDATA[Vaadin]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=1033</guid>
		<description><![CDATA[I am very happy to present the early results of redVoodo EOS. EOS is a independent part / component of redVoodo. It will become a project which offers a lot of base functionality for web based business applications like ui layouting, selection support, business drag and drop, multi tab enablement and many more very useful [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=1033&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am very happy to present the early results of redVoodo EOS.</p>
<p>EOS is a independent part / component of redVoodo.</p>
<p>It will become a project which offers a lot of base functionality for web based business applications like ui layouting, selection support, business drag and drop, multi tab enablement and many more very useful features. It will be highly extendable by the use of OSGi services and can be customized to any requirements.</p>
<p>Today i finished some very important steps.</p>
<ul>
<li>Selection support</li>
<li>Multi browser tab functionality</li>
<li>UI elements contribution services</li>
<li>Active part set management</li>
<li>ICEPush for many browser tabs</li>
<li>&#8230;</li>
</ul>
<p>Right now some basic ui element prototypes like a framework switcher have been finished. It is provided by an OSGi service which can be stopped and started at runtime. Stopping a bundle means, that the ui element is removed from the available elements immediately. Starting the bundle provides the element to EOS again.</p>
<p>Additionally the state of the ui elements is completely decoupled from the ui and is stored in an EMF (Eclipse modeling framework) model. So the state can be restored every time an &#8220;ui element contribution OSGi service&#8221; like the &#8220;framework switcher&#8221; is started.</p>
<p>But you can store the state in your preferred way. EMF is only a default implementation &#8211;&gt; redVoodos basic statement &#8220;convention over configuration&#8221;.</p>
<h3>Movie</h3>
<p style="text-align:left;">I hope you enjoy this movie which demonstrates the result of starting and stopping bundles and restoring ui states.<br />
Direct link to the movie:</p>
<p style="text-align:left;"><a href="http://vimeo.com/channels/redvoodo#24881893" target="_blank">http://vimeo.com/channels/redvoodo#24881893</a></p>
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/24881893' width='400' height='225' frameborder='0'></iframe></div>
<h3 style="text-align:left;">Additional information</h3>
<p style="text-align:left;">If you are interested in redVoodo just follow our blogs and website.</p>
<p style="text-align:left;"><a href="http://ekkescorner.wordpress.com/" target="_blank">ekkescorner.wordpress.com</a></p>
<p style="text-align:left;"><a href="http://redvoodo.wordpress.com/" target="_blank">redVoodo.org</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/1033/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=1033&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/06/09/redvaadin-eos-earlyresults/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>
	</item>
		<item>
		<title>User scoped OSGi services</title>
		<link>http://floriansblog.wordpress.com/2011/06/01/user-scoped-services/</link>
		<comments>http://floriansblog.wordpress.com/2011/06/01/user-scoped-services/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 12:36:21 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[03 User scoped services]]></category>
		<category><![CDATA[Florians Posts]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=933</guid>
		<description><![CDATA[This post describes a possible way to handle and access stateful user scoped OSGi services in an vaadin environment. Of course, we would like to use the powerful dynamics provided by OSGi DS (declarative services). The provided classes and services should be highly extendable and it should be really easy to change the behaviour of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=933&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post describes a possible way to handle and access stateful user scoped OSGi services in an vaadin environment. Of course, we would like to use the powerful dynamics provided by OSGi DS (declarative services). The provided classes and services should be highly extendable and it should be really easy to change the behaviour of the system.</p>
<p>But if you are dealing with user sessions you have to ensure, that some of the used services are session or user based. Which means, that exactly one service instance per user session or user exists. If you want to affect the instantiation process of OSGi services, you have to deal with ComponentFactories.</p>
<p>A ComponentFactory gives you the opportunity to create many instances of the same service with different properties. So we have a tooling to do exactly what we want to do.</p>
<p>But what kind of architecture would be the best one? For the last two weeks i tried different approaches and I&#8217;d like to present that one i like most.</p>
<p>To keeps things simple, i am going create a &#8220;shopping cart&#8221; example. Each user should have it&#8217;s own shopping cart associated by its user id. Many web sessions can share one shopping cart for one user id.</p>
<h2><span style="color:#0000ff;">Defining the service</span></h2>
<p>So lets start.<br />
I am going to prepare an interface for the shopping cart which should be provided as an user scoped service.</p>
<h3>IShoppingCart</h3>
<p><pre class="brush: java;">public interface IShoppingCart {

/**
* Returns the user id this cart is responsible for.
*
* @return
*/
String getUserid();

/**
* Adds an item to the shopping cart.
*
* @param item
*/
void addItem(IItem item);

/**
* Returns the total value in the base currency of the user.
*
* @return
*/
float getTotalValue();

}</pre></p>
<h3>ShoppingCart implementation</h3>
<p>In the next step i am creating an implementation for that interface and provide it as a &#8220;Component Factory Service&#8221;.</p>
<p><pre class="brush: java;">public class ShoppingCart implements IShoppingCart {

private String userId;

/**
* Called by OSGi DS on service activate
*/
void startup(Map&lt;String, Object&gt; properties) {
userId = (String) properties.get(&quot;userId&quot;);
}

@Override
public String getUserid() {
return userId;
}

@Override
public void addItem(IItem item) {
// to be implemented
}

@Override
public float getTotalValue() {
// to be implemented
return 0;
}

}

</pre></p>
<h3>Component Factory Definition</h3>
<p>As explained above, i am going to create a ComponentFactory which is used to create many instances of that service.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/componentfactoryxml1.png"><img class="alignnone size-full wp-image-953" title="ComponentFactoryXML" src="http://floriansblog.files.wordpress.com/2011/06/componentfactoryxml1.png?w=450&#038;h=225" alt="" width="450" height="225" /></a></p>
<p>Since the created IShoppingCart service will be associated with an user id, i am adding a property called user id to service definition.</p>
<p><strong>Attention</strong>: This property will be changed before the session based service is created. So i gave it a value called &#8220;ToBeDefinedAtRuntime&#8221; which should visualize that this property exists, but its value has to be redefined.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/shoppingcartusesproperty.png"><img class="alignnone size-full wp-image-955" title="ShoppingCartUsesProperty" src="http://floriansblog.files.wordpress.com/2011/06/shoppingcartusesproperty.png?w=450&#038;h=238" alt="" width="450" height="238" /></a></p>
<p>The xml tag &#8220;activate&#8221; from the ComponentFactoryDefinition targets a method called startup. This method will be called after the session based service has been created. As an argument the properties which have been used to create that service are passed. And for sure, these properties are containing the user id of the user this shopping cart is associated with.</p>
<h2><span style="color:#0000ff;">Writing a scoped service manager<br />
</span></h2>
<p>Well, we have created a shopping cart service and a component factory definition. But for sure, we want to access our shopping cart instance by user id. If an instance for a given user id exists, we want to reuse it. Otherwise we prepare a new instance of the shopping cart service and configure it with the user id property.</p>
<h3>IShoppingCartManager</h3>
<p>So let&#8217;s write a ShoppingCartManager. This manager is an OSGi service and we use it to cache all created shopping cart services. This manager offers a method to access a shopping cart by an user id and a method to dispose the created service.</p>
<p><pre class="brush: java;">public interface IShoppingCartManager {

/**
* Returns a shopping cart for the user.
*
* @param userId
* @return
*/
IShoppingCart getShoppingCart(String userId);

/**
* Has to be called if the shopping cart should
* be destroyed. For instance if the user
* account was deleted.
*
* @param userId
*/
void disposeCart(String userId);

}</pre></p>
<h3>ShoppingCartManager implementation</h3>
<p><pre class="brush: java;">public class ShoppingCartManager implements IShoppingCartManager {

private ComponentFactory factory;
private Map&lt;String, ComponentInstance&gt; shoppingCarts =
      Collections.synchronizedMap(
      new HashMap&lt;String, ComponentInstance&gt;());

/**
* Called by OSGi DS
*
* @param factory
*/
void bindShoppingCartFactory(ComponentFactory factory) {
     this.factory = factory;
}

/**
* Called by OSGi DS
*
* @param factory
*/
void unbindShoppingCartFactory(ComponentFactory factory) {
     this.factory = null;
}

@Override
public IShoppingCart getShoppingCart(String userId) {
    if (!shoppingCarts.containsKey(userId)) {
    // create a new instance
    //
    shoppingCarts.put(userId,
    newInstance(userId));
}

    // return the instance
    //
    ComponentInstance instance =
       shoppingCarts.get(userId);
    return (IShoppingCart) instance.getInstance();
}

private ComponentInstance newInstance(String userId) {
    // create properties with user id
    //
    Hashtable&lt;String, Object&gt; properties =
       new Hashtable&lt;String, Object&gt;();
       properties.put(&quot;userId&quot;, userId);

    // create a new instance
    //
    ComponentInstance instance =
      factory.newInstance(properties);
    return instance;
}

@Override
public void disposeCart(String userId) {
    if (shoppingCarts.containsKey(userId)) {
      ComponentInstance instance =
        shoppingCarts.remove(userId);
      instance.dispose();
     }
}
}</pre></p>
<h3>ShoppingCartManager service definition</h3>
<p>And the service component definition.<br />
<a href="http://floriansblog.files.wordpress.com/2011/06/shoppingcartmanagerxml2.png"><img class="alignnone size-full wp-image-1027" title="ShoppingCartManagerXML" src="http://floriansblog.files.wordpress.com/2011/06/shoppingcartmanagerxml2.png?w=450&#038;h=173" alt="" width="450" height="173" /></a></p>
<h3>How does it work?</h3>
<p>The following images show you how this manager uses the component factory to create new instance of the shopping cart service.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/howworks11.png"><img class="alignnone size-full wp-image-982" title="HowWorks1" src="http://floriansblog.files.wordpress.com/2011/06/howworks11.png?w=450&#038;h=166" alt="" width="450" height="166" /></a></p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/howworks21.png"><img class="alignnone size-full wp-image-981" title="HowWorks2" src="http://floriansblog.files.wordpress.com/2011/06/howworks21.png?w=450&#038;h=175" alt="" width="450" height="175" /></a></p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/howworks3.png"><img class="alignnone size-full wp-image-977" title="HowWorks3" src="http://floriansblog.files.wordpress.com/2011/06/howworks3.png?w=450&#038;h=139" alt="" width="450" height="139" /></a></p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/howworks4.png"><img class="alignnone size-full wp-image-978" title="HowWorks4" src="http://floriansblog.files.wordpress.com/2011/06/howworks4.png?w=450&#038;h=148" alt="" width="450" height="148" /></a></p>
<h2>Summary</h2>
<p>So far we have prepared a service and a service manager.</p>
<ul>
<li>The services for the shopping carts are</li>
<ul>
<li>scoped by user id</li>
<li>cached by the shopping cart service manager</li>
</ul>
<li>The manager allows you to access the cached services by the user id</li>
<li>If no service exists yet, the manager creates a new instance configured with the user id</li>
</ul>
<h2><span style="color:#0000ff;">Consume the service</span></h2>
<p>The last thing you have to do, is to use the service manager inside your code.</p>
<p><pre class="brush: java;">public class MyService implements IMyService {

/**
* Called by OSGi DS
*
* @param manager
*/
@SuppressWarnings(&quot;unused&quot;)
void bindShoppingCartManager(IShoppingCartManager manager) {
  IShoppingCart cart1 = manager.getShoppingCart(&quot;user1&quot;);
  IShoppingCart cart2 = manager.getShoppingCart(&quot;user2&quot;);
}

/**
* Called by OSGi DS
*
* @param manager
*/
void unbindShoppingCartManager(IShoppingCartManager manager) {

}
}

</pre></p>
<h2><span style="color:#0000ff;">Service Overview</span></h2>
<p>This image shows an overview about the services created above and their relations.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/06/overview.png"><img class="alignnone size-full wp-image-1018" title="Overview" src="http://floriansblog.files.wordpress.com/2011/06/overview.png?w=450&#038;h=600" alt="" width="450" height="600" /></a></p>
<h2><span style="color:#0000ff;">Conclusion</span></h2>
<p>If you have any suggestions please let me know. Any comments are highly welcome.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/933/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/933/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/933/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=933&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/06/01/user-scoped-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/componentfactoryxml1.png" medium="image">
			<media:title type="html">ComponentFactoryXML</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/shoppingcartusesproperty.png" medium="image">
			<media:title type="html">ShoppingCartUsesProperty</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/shoppingcartmanagerxml2.png" medium="image">
			<media:title type="html">ShoppingCartManagerXML</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/howworks11.png" medium="image">
			<media:title type="html">HowWorks1</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/howworks21.png" medium="image">
			<media:title type="html">HowWorks2</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/howworks3.png" medium="image">
			<media:title type="html">HowWorks3</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/howworks4.png" medium="image">
			<media:title type="html">HowWorks4</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/06/overview.png" medium="image">
			<media:title type="html">Overview</media:title>
		</media:content>
	</item>
		<item>
		<title>Something you can&#8217;t do with ComponentFactories</title>
		<link>http://floriansblog.wordpress.com/2011/05/26/something-you-cant-do-with-componentfactories/</link>
		<comments>http://floriansblog.wordpress.com/2011/05/26/something-you-cant-do-with-componentfactories/#comments</comments>
		<pubDate>Thu, 26 May 2011 10:17:42 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[00 ComponentFactory]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Florians Posts]]></category>
		<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=829</guid>
		<description><![CDATA[About 2 weeks ago i started to implement the main architecture of EOS which is a subproject based on redVoodo. The main goal is to provide a very flexible and extendable base implementation for business applications. Based on OSGi DS (declarative services) i started to design my application. I decided to use ComponentFactories to create [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=829&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>About 2 weeks ago i started to implement the main architecture of EOS which is a subproject based on <a href="http://www.redvoodo.org/" target="_blank">redVoodo</a>. The main goal is to provide a very flexible and extendable base implementation for business applications. Based on OSGi DS (declarative services) i started to design my application. I decided to use ComponentFactories to create different instances of the same interface / class. For instance this is necessary to provide web session based classes like an ApplicationContext with application scope. I was suppressed how powerful OSGi services are. But then i recognized, that i have used ComponentFactory a way they are not intended to be used. See <a title="www.eclipse.org/forums" href="http://www.eclipse.org/forums/index.php/t/209483/">http://www.eclipse.org/forums/index.php/t/209483/</a></p>
<p>This post should explain the problems i faced during the implementation of EOS. Therefore i have prepared a simple example based on &#8220;shapes&#8221;. A IShapeFactory provides instances of IShapes for different types (circle, square,&#8230;). Implementations of IShapes are provided by ComponentFactories. These componenteFactories are required by the shapeFactory.</p>
<h2>Class dependencies</h2>
<p>This image shows the dependencies between the classes involved and their function.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/study1_classhierarchy2.png"><img class="alignnone size-full wp-image-867" title="Study1_ClassHierarchy" src="http://floriansblog.files.wordpress.com/2011/05/study1_classhierarchy2.png?w=450&#038;h=570" alt="" width="450" height="570" /></a></p>
<h3>ShapeFactory</h3>
<p><pre class="brush: java;">
public interface IShapeFactory {

/**
* Creates a new shape for the given type or &lt;code&gt;null&lt;/code&gt; if no shape
* is registered for the type.
*
* @param type
* @return
*/
IShape createNewShape(String type);

}
</pre></p>
<p>Based on the shape factory several new instances of a shape can be created. Since the architecture of this factory is extendable, the type should be specified by a property (study1.shapeType) in the OSGi component definition of the IShape component factory. The component factories are registered at the shapeFactory by the OSGi DS (declarative service) framework.</p>
<p>If createNewShape is called, the factory tries to find a component factory which is responsible for the given type and uses this factory to create a new instance of IShape.</p>
<h3>IShape</h3>
<p><pre class="brush: java;">public interface IShape {

/**
* Calling this method will paint the
* content of that shape instance.
*/
void paint();

}
</pre></p>
<p>Instances of IShape are used to paint the shape defined by the implementation. For instance it paints a circle or a square or something else.<br />
Since each visualized shape is a new instance of the IShape interface, i decided to use a ComponentFactory which provides new instances of that interface. How this works will be described later.</p>
<p>A really nice way, which allows the new instantiated components to use OSGi &#8220;declarative services&#8221; as well. If we would instantiate the shapes with &#8220;new SomeShape()&#8221;, that classes can not use DS since they are not defined by a service component definition. But since we are using ComponentFactories the IColorProvider from image above could also be defined as a required service for the class Circle. That&#8217;s the BIG advantage using ComponentFactories.</p>
<h2>Service dependencies</h2>
<p>This image shows the service dependencies.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/study1_services_firstapproach3.png"><img class="alignnone size-full wp-image-874" title="Study1_Services_FirstApproach" src="http://floriansblog.files.wordpress.com/2011/05/study1_services_firstapproach3.png?w=450&#038;h=605" alt="" width="450" height="605" /></a></p>
<h3>org.redvoodo.osgi.study1.services</h3>
<p>This bundle contains all service interfaces. The ComponentFactory rectangle in the image above is only displayed there to make the visualization much clearer. So it is not really contained in that bundle.</p>
<h3>org.redvoodo.osgi.componentfactory.shape</h3>
<p>This bundle contains 2 IShape implementations. Square and Circle. Instead of providing the IShape interface, it provides a ComponentFactory service which can be used to create new instances of the IShape implementation.</p>
<pre><a href="http://floriansblog.files.wordpress.com/2011/05/study1_services_xml.png"><img class="alignnone size-full wp-image-916" title="Study1_Services_XML" src="http://floriansblog.files.wordpress.com/2011/05/study1_services_xml.png?w=450&#038;h=108" alt="" width="450" height="108" /></a></pre>
<p>The really important entries in that service component definition are:</p>
<pre>factory="study1.shapesfactory"</pre>
<p>Defines the service component as a component factory.</p>
<pre>property name="study1.shapeType" type="String" value="circle"</pre>
<p>Adds a shape type property to the component definition. The shapeFactory should use this property to identify the type of the shape which is provided by the component factory.</p>
<h3>org.redvoodo.osgi.componentfactory.factory</h3>
<p>It provides the IShapeFactory service and contains an implementation of ShapeFactory. The ShapeFactory requires 0:n &#8220;ComponentFactories providing IShape&#8221;.</p>
<p>If a ComponentFactory was added (addShapeComponentFactory), the passed properties will be used to determine the type of the shape that is provided by the component factory. And the component factory is registered in an internal map.</p>
<p>If a ComponentFactory was removed, it will be removed from the internal map by its type.</p>
<p>If createNewShape(String) is called, the factory registered by the given type will be used to create a new instance of the shape. If no registered factory could be found, null will be returned.</p>
<p><pre class="brush: java;">public class ShapeFactoryImpl implements IShapeFactory {

private Map&lt;String, ComponentFactory&gt; factories
= new HashMap&lt;String, ComponentFactory&gt;();

/**
* Called by OSGi
*
* @param shapeFactory
* @param properties
*/
protected void addShapeComponentFactory(
     ComponentFactory shapeFactory,
     Map&lt;String, Object&gt; properties) {

     String type = (String)
       properties.get(&quot;study1.shapeType&quot;);
     factories.put(type, shapeFactory);
}

/**
* Called by OSGi
*
* @param shapeFactory
* @param properties
*/
protected void removeShapeComponentFactory(
     ComponentFactory shapeFactory,
     Map&lt;String, Object&gt; properties) {

     String type = (String)
       properties.get(&quot;study1.shapeType&quot;);
     factories.remove(type);
}

@Override
public IShape createNewShape(String type) {
     IShape result = null;
     if (factories.containsKey(type)) {
        ComponentFactory factory =
          factories.get(type);
        result = (IShape) factory
          .newInstance(null).getInstance();
        // for normal you should also
       // handle the lifecycle of
       // ComponentInstance
     }
  return result;
}</pre></p>
<h2>Conclusion</h2>
<p>After finishing this implementation i was really suppressed. Really suppressed that nothing happend! My architecture did not work at all.</p>
<p>But what is the problem? Well, the problem was, that i did not know some issues about ComponentFactories. So i asked at the newsgroup (<a href="http://www.eclipse.org/forums/index.php/t/209483/">equinox newsgroup</a>) an got following answer:</p>
<blockquote><p>BJ Hargrave</p>
<p><em>DS spec. From 112.2.4 Factory Component:</em></p>
<p><em> SCR must register a Component Factory service on behalf of the component as soon as the component factory is satisfied. The service properties must be:</em></p>
<p><em> * component.name The name of the component. </em><br />
<em> * component.factory The factory identifier.</em></p>
<p><em> The service properties of the Component Factory service must not include the component properties.</em></p></blockquote>
<h2>The error</h2>
<p>Now i know why this kind of architecture does not work.</p>
<p style="text-align:justify;">I assumed, that the properties specified in the service component definition of the ComponentFactory are passed as properties to the instance of the ComponentFactory. But, as DS spec. about Factory Components describes, only the properties component.name and component.factory are passed to the service. So the ShapeFactory could not determine the type the ComponentFactory is responsible for!</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/study1_services_error_xml.png"><img title="Study1_Services_Error_XML" src="http://floriansblog.files.wordpress.com/2011/05/study1_services_error_xml.png?w=450&#038;h=168" alt="" width="450" height="168" /></a></p>
<p style="text-align:justify;">This property is not accessible for the component factory service!</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/study1_services_error_factory.png"><img class="alignnone size-full wp-image-921" title="Study1_Services_Error_Factory" src="http://floriansblog.files.wordpress.com/2011/05/study1_services_error_factory.png?w=450&#038;h=150" alt="" width="450" height="150" /></a></p>
<p>And so the type will always be null.</p>
<h2>The solution</h2>
<p>Currently i am working on a nested component factory solution. It uses a service which provides some kind of IFactory. Implementations of the IFactory are using nested ComponentFactories to avoid the instantiation by new().</p>
<p>The solution should be probably finished next week. Then i am writing a new post about it.</p>
<p>If you have any suggestions feel free to post a comment. Any input is welcome!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/829/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=829&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/05/26/something-you-cant-do-with-componentfactories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/study1_classhierarchy2.png" medium="image">
			<media:title type="html">Study1_ClassHierarchy</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/study1_services_firstapproach3.png" medium="image">
			<media:title type="html">Study1_Services_FirstApproach</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/study1_services_xml.png" medium="image">
			<media:title type="html">Study1_Services_XML</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/study1_services_error_xml.png" medium="image">
			<media:title type="html">Study1_Services_Error_XML</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/study1_services_error_factory.png" medium="image">
			<media:title type="html">Study1_Services_Error_Factory</media:title>
		</media:content>
	</item>
		<item>
		<title>Eclipse Democamp Vienna Flyers Indigo 2011</title>
		<link>http://floriansblog.wordpress.com/2011/05/20/eclipse-democamp-flyers-indigo-2011/</link>
		<comments>http://floriansblog.wordpress.com/2011/05/20/eclipse-democamp-flyers-indigo-2011/#comments</comments>
		<pubDate>Fri, 20 May 2011 06:29:34 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[indogo 2011]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=806</guid>
		<description><![CDATA[Flyers democamp indigo 2011 To promote the eclipse democamp indigo in vienna, daria motamedi sponsored the design of flyers. Yesterday we could send them to the printing shop. In about 4 days they should be ready for shipment. I think that they became really nice. Thanks a lot to daria. and stickers Of course we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=806&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Flyers democamp indigo 2011</h2>
<p>To promote the <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_Indigo_2011/Vienna" target="_blank">eclipse democamp</a> indigo in vienna, <a href="http://en.gravatar.com/dariabella" target="_blank">daria motamedi</a> sponsored the design of flyers. Yesterday we could send them to the printing shop. In about 4 days they should be ready for shipment.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/flyer_frontside.png"><img class="alignnone size-full wp-image-810" title="Flyer_frontside" src="http://floriansblog.files.wordpress.com/2011/05/flyer_frontside.png?w=450&#038;h=211" alt="" width="450" height="211" /></a></p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/flyer_backside1.png"><img class="alignnone size-full wp-image-812" title="Flyer_backside" src="http://floriansblog.files.wordpress.com/2011/05/flyer_backside1.png?w=450&#038;h=210" alt="" width="450" height="210" /></a></p>
<p>I think that they became really nice. Thanks a lot to daria.</p>
<h2>and stickers</h2>
<p>Of course we have stickers for all attendees too. We have printed 250 pieces. So i think we should have enough.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/button.png"><img class="alignnone size-full wp-image-815" title="Button" src="http://floriansblog.files.wordpress.com/2011/05/button.png?w=450&#038;h=452" alt="" width="450" height="452" /></a></p>
<p>If you would like to attend, follow this link to the <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_Indigo_2011/Vienna" target="_blank">eclipse demo website</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/806/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/806/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/806/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/806/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/806/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/806/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/806/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/806/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/806/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/806/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/806/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/806/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/806/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/806/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=806&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/05/20/eclipse-democamp-flyers-indigo-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/flyer_frontside.png" medium="image">
			<media:title type="html">Flyer_frontside</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/flyer_backside1.png" medium="image">
			<media:title type="html">Flyer_backside</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/button.png" medium="image">
			<media:title type="html">Button</media:title>
		</media:content>
	</item>
		<item>
		<title>Vaadin OSGi ICEPush Services</title>
		<link>http://floriansblog.wordpress.com/2011/05/08/vaadin-osgi-icepush-services/</link>
		<comments>http://floriansblog.wordpress.com/2011/05/08/vaadin-osgi-icepush-services/#comments</comments>
		<pubDate>Sun, 08 May 2011 13:00:28 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[02 ICEPush services]]></category>
		<category><![CDATA[Florians Posts]]></category>
		<category><![CDATA[ICEPush]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Vaadin]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=566</guid>
		<description><![CDATA[1. Introduction About 4 years ago i started working with OSGi, but this is the first project i am using declarative OSGi services. The concept of OSGI allows to build very extendable and loose coupled software environments. In particular the use of OSGI-services is very important to create some kind of plugin architecture which allows [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=566&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>1. Introduction</h2>
<p>About 4 years ago i started working with OSGi, but this is the first project i am using declarative OSGi services. The concept of OSGI allows to build very extendable and loose coupled software environments. In particular the use of OSGI-services is very important to create some kind of plugin architecture which allows to provide functionality on a very flexible way.</p>
<h3>OSGi and vaadin</h3>
<p>So far web applications did not support these concepts very well. Some time ago Chris Brind, Neil Bartlett and Peter Kriens have written different vaadin OSGi integrations which make it possible to run vaadin inside an OSGi container. (See blog from Chris Brind: <a href="http://www.perplentropy.com/2010/07/comparing-approaches-to-vaadin-and-osgi.html" target="_blank">Comparing approaches to vaadin and OSGi</a>)</p>
<p>Vaadin is a framework to build web applications based on java code. It uses GWT (google web toolkit) to render the UI elements and offers serversided counterparts to the client UI widgets. A really amazing framework to build high level web UIs.</p>
<h3>Kai Tödters vaadin demo app</h3>
<p>The vaadin OSGi implementation from Chris Brind was used by Kai Toedter to write his amazing vaadin application based on OSGI-services. Using the &#8220;whiteboard pattern&#8221;, OSGi-services that are used to provide UI elements like Actions and Components are injected into the com.vaadin.Application. With this approach Kai could build a very loose coupled application environment. The UI elements &#8220;contributed&#8221; to the application depend on the installed and started OSGi-bundles.</p>
<p>Basically Kai&#8217;s vaadin application can be divided into two different parts:</p>
<ol>
<li>The main bundle with its main application that <strong>requires OSGi-services</strong> to build the UI.</li>
<li>Contributor bundles <strong>providing services</strong> required by the main application.</li>
</ol>
<p>The <strong>main bundle defines the layout</strong> of the main application but there is <strong>no</strong> <strong>knowledge </strong>about the <strong>exact content</strong> of the application involved. The <strong>content is provided</strong> by <strong>&#8220;contributor bundles&#8221;</strong> and may contain <strong>Actions,</strong> <strong>Buttons</strong> or <strong>Views</strong> as some kind of vaadin.Component.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/kais_app_description.png"><img class="size-full wp-image-579 alignnone" title="kais_app_description" src="http://floriansblog.files.wordpress.com/2011/05/kais_app_description.png?w=450&#038;h=260" alt="" width="450" height="260" /></a></p>
<p style="text-align:justify;">This image displays Kai&#8217;s demo application. All shown bundles contain OSGi-services that are used to access the UI-elements. As an example the red arrows are pointing to the provided UI elements.</p>
<p>The next image gives you a summary about the bundle dependencies. To keep things simple, we only consider the IViewContribution service. IActionContribution works nearly the same way.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/kais_application_services1.png"><img class="size-full wp-image-634 alignnone" title="kais_application_Services" src="http://floriansblog.files.wordpress.com/2011/05/kais_application_services1.png?w=450&#038;h=375" alt="" width="450" height="375" /></a></p>
<p>The main bundle requires IViewContribution services which offer access to the UI elements that should be added to the user interface. The interface IViewContribution will be implemented by classes located in different bundles. The OSGi-service-component-runtime observes starting and stopping bundles and injects the upcomming services into the bound MainApplication. Bindings are defined in the service component definition.</p>
<p>Service component definition:<br />
com.siemens.ct.osgi.vaadin.pm.main/META-INF/vaadinMain.xml</p>
<h3>Contribution to Kai&#8217;s demo application</h3>
<p>At the end of this blog i am going to tell you, how applications can be push enabled automagically. All you have to do is to install and start a couple of bundles and all vaadin applications have the capability to become pushed.</p>
<p>Therefore we have to enhance Kai&#8217;s application by a provided interface called IApplicationProvider.</p>
<p><pre class="brush: java;">
public interface IApplicationProvider {

/**
* Returns the provided application.
*
* @return
*/
Application getApplication();

}
</pre></p>
<p>That interface returns an instance of the application associated with this applicationProvider.</p>
<p>Additionally we let Kai&#8217;s application implement that interface and return &#8220;this&#8221; as the reference.</p>
<p><pre class="brush: java;">
public class MainApplication extends Application implements
IApplicationProvider {

@Override
public Application getApplication() {
return this;
}
</pre></p>
<p>No we are going to provide the MainApplication.class as an OSGi-service for the interface IApplicationProvider.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/kais_application_applicationprovider.png"><img class="size-full wp-image-693 alignnone" title="kais_application_ApplicationProvider" src="http://floriansblog.files.wordpress.com/2011/05/kais_application_applicationprovider.png?w=450&#038;h=143" alt="" width="450" height="143" /></a></p>
<p style="text-align:justify;">Each time a new application was created by the component factory, then service components which reference this interface will be called.</p>
<h2></h2>
<h2></h2>
<h2>2. Services come and services go</h2>
<p>Before i start writing about the vaadin osgi push service, i&#8217;d like to talk about the flexibility of OSGi-services.</p>
<p>People already using OSGi know that bundles have a lifecycle. They can become installed, started, stopped,&#8230; into a running OSGi container without the requirement of restarting the container. A very flexible way of providing functionality.</p>
<p>Of course, if a bundle contains OSGI-services and the bundle was started a new service is offered by the framework. If the bundle becomes stopped, the service will be deregistered from the OSGi-runtime. It would be good practice to handle this flexibility inside your applications if you are using OSGi-services. Of course you can assume that services are static, but if you don&#8217;t so, then your application should be designed to handle the lifecycle of bundles.</p>
<p>Referring to Kai&#8217;s application this would imply that stopping a service bundle (a yellow one from image above) will remove all UI contributions like actions, menu bar actions and views associated with this bundle from the UI. You can use Kai&#8217;s &#8220;bundle view&#8221; to demo this issue.</p>
<p>Stopping or starting a bundle like &#8220;com.siemens.ct.osgi.vaadin.pm.printaction&#8221; will remove a service from the main application which reflects the changes immediatly and updates the UI. The menu bar action and the button &#8220;print&#8221; will be removed.</p>
<h3>OSGi management console</h3>
<p>Kai used the client UI of his application to control the lifecycle of bundles, but OSGi offers another way. You can use the OSGi management console. The commands &#8220;start bundleNumber&#8221; and &#8220;stop bundlenumber&#8221; will start and stop these bundles.</p>
<p>But if you are using the management console with Kai&#8217;s application, a starting or stopping bundle will not update the UI immediately since the server cannot notify the UI about this change! So you have to wait for the next UI refresh until the client UI has reflected the stopped bundle.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_notpossible.png"><img class="size-full wp-image-648 alignnone" title="kais_application_DirtyState_NotPossible" src="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_notpossible.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">This image displays the problem using the management console to control the lifecycle of bundles. If a bundle becomes stopped, the serversided components get a dirtyState, which cannot be pushed to the client!</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_poll.png"><img class="size-full wp-image-649 alignnone" title="kais_application_DirtyState_Poll" src="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_poll.png?w=450" alt=""   /></a></p>
<p>The changes will be transfered to the client at the next client UI refresh. Since vaadin clients are not pushable without using any addons, the server cannot inform the client about changes.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_push1.png"><img class="alignnone size-full wp-image-715" title="kais_application_DirtyState_Push" src="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_push1.png?w=450&#038;h=362" alt="" width="450" height="362" /></a></p>
<p>But vaadin offers an addon called <a href="http://vaadin.com/directory#addon/icepush">ICEPush</a>. ICEPush allows the client UI to be notified by the server on changes. A really helpful addon which perfectly matches the requirements described above.</p>
<h2>3. Details about the implementation</h2>
<p>This chapter of my post gives you an introduction how i have implemented ICEPush using the vaadin OSGi integration from Chris Brind.</p>
<p>Main goal was to provide bundles which enable the <a href="http://vaadin.com/directory#addon/icepush">ICEPush addon</a> and the <a href="http://vaadin.com/directory#addon/vaadin-osgi">&#8220;vaadin OSGi &#8221; addon</a> at the same time. And to push changes from the server the client UI in OSGi environments.</p>
<h3>Main issue</h3>
<p>ICEPush and vaadin-OSGi both provide their own servlet.</p>
<ul>
<li><strong>ICEPushServlet</strong> is responsible to serve the ICEPush javascript code and to handle requests ending with &#8220;.icepush&#8221;</li>
<li><strong>VaadinOSGiServlet</strong> is responsible to create a new instance of com.vaadin.Application based on an OSGi-ComponentFactory</li>
</ul>
<h3>Servlet</h3>
<p>Since exactly one servlet is required for my issue i decided to merge the contents of both servlets and to create a new one called <strong>ICEPushVaadinOSGiServlet</strong>. Luckily both implementations are based on the &#8220;Apache License 2.0&#8243; license and so it was legal to combine them.</p>
<p>The <strong>ICEPushVaadinOSGiServlet</strong> offers a compound functionality as <strong>ICEPushServlet</strong> and <strong>VaadinOSGIServlet</strong> do.</p>
<p>This code displays a stub of the new servlet class. At the beginning of the method stub you can see where is it original from.</p>
<p><pre class="brush: java;">
/**
* Merges org.vaadin.osgi.VaadinOSGiServlet (vaadins osgi addon) and
* {@link org.vaadin.artur.icepush.ICEPushServlet} (vaadins icePush addon).
*/
public class ICEPushVaadinOSGiServlet extends AbstractApplicationServlet {

// from org.vaadin.osgi.VaadinOSGiServlet
@Override
protected Class&lt;? extends Application&gt; getApplicationClass()
throws ClassNotFoundException {
return Application.class;
}

// from org.vaadin.osgi.VaadinOSGiServlet
@Override
protected Application getNewApplication(HttpServletRequest request)
throws ServletException {
// ...
}

@Override
// from org.vaadin.artur.icepush.ICEPushServlet
public void init(ServletConfig servletConfig) throws ServletException {
// ...
}

@Override
// from org.vaadin.artur.icepush.ICEPushServlet
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// ...
}

/**
* Sends the ICEPush javascript code to the client.&lt;br&gt;
* from org.vaadin.artur.icepush.ICEPushServlet
*
* @param request
* @param response
* @throws IOException
*/
private void serveIcePushCode(HttpServletRequest request,
HttpServletResponse response) throws IOException {
// ...
}

/**
* Track the component instance and session. If this is disposed the entire
* associated http session is also disposed.&lt;br&gt;
*
* from org.vaadin.osgi.VaadinOSGiServlet
*/
class VaadinSession {
// ...
}
}
</pre></p>
<h3>VaadinOSGiApplicationManager</h3>
<p>The <strong>VaadinOSGiApplicationManager</strong> is the main class of the vaadin OSGi integration. It runs as an OSGi component and is responsible to create and register a servlet at the http service. In the org.vaadin implementation the <strong>VaadinOSGiServlet</strong> is used.</p>
<p>I  enhanced this manager and <strong>added a required OSGi-service</strong> (interface == IServletFactory ) which <strong>provides</strong> a <strong>HttpServlet</strong>. With this approach the used <strong>servlet</strong> is <strong>very loose coupled</strong> and can be provided by OSGi-services. The service has to provide an implementation of the <strong>IServletFactory</strong> which creates new instances from a http servlet.</p>
<p><pre class="brush: java;">
/**
* A factory provided by OSGI-Services to contribute servlets.
*/
public interface IServletFactory {

/**
* Returns a servlet to be used by the {@link VaadinOSGiApplicationManager}.
*
* @param factory
*            which has create the {@link Application}
* @param servletpath
*            which is used to register the servlet
* @param initialProperties
*            Properties registered against the component factory.
* @return
*/
HttpServlet createServlet(ComponentFactory factory, String servletpath,
Map&lt;String, Object&gt; initialProperties);

}
</pre></p>
<h2>4. Vaadin OSGi Push Addon bundles</h2>
<p>The original <strong>VaadinOSGiApplicationManager</strong> was <strong>copied</strong> since i did not want to change the &#8220;none pushing osgi vaadin&#8221; implementation from Chris Brind and have created a <strong>new bundle called org.vaadin.pushosgi</strong>.</p>
<p>This bundle is <strong>replacing</strong> the <strong>org.vaadin.osgi </strong>bundle and contains the VaadinOSGiApplicationManager including the extended IServletFactory functionality.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/pushosgi_bundle.png"><img class="size-full wp-image-605 alignnone" title="pushOsgi_bundle" src="http://floriansblog.files.wordpress.com/2011/05/pushosgi_bundle.png?w=450" alt=""   /></a></p>
<p>As you can see, no servlets are contained in the bundle. Since the servlets are provided by OSGi-services, they are defined in different bundles.</p>
<p>The next image displays two servlet contributor bundles which offer OSGi-services.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/pushosgi_bundle_servlets.png"><img class="size-full wp-image-609 alignnone" title="pushOsgi_bundle_servlets" src="http://floriansblog.files.wordpress.com/2011/05/pushosgi_bundle_servlets.png?w=450&#038;h=466" alt="" width="450" height="466" /></a></p>
<p style="text-align:justify;">With this approach you only have to decide which servlet should be used and to install the prefered bundle into the target platform. No further steps are required. The dependencies between the OSGi bundles and services will be resolved by the OSGi framework and the installed servlet will be used automatically.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/vaadinosgiapplicationmanager.png"><img class="size-full wp-image-658 alignnone" title="VaadinOSGiApplicationManager" src="http://floriansblog.files.wordpress.com/2011/05/vaadinosgiapplicationmanager.png?w=450&#038;h=345" alt="" width="450" height="345" /></a></p>
<p style="text-align:left;">That image displays a summary about the bundles involved.</p>
<h3 style="text-align:justify;">ICEPush implementation</h3>
<p style="text-align:justify;">If you are using the <a href="http://vaadin.com/directory#addon/icepush">ICEPush addon</a> by Artur Signell you have to install the ICEPush addon. It is divided into a server side and a client UI part.</p>
<h4 style="text-align:justify;">Serverside</h4>
<p style="text-align:justify;">All required java code for the server side is contained in the bundle &#8220;<strong>org.redvoodo.vaadin.addon.icepush</strong>&#8220;. No changes have been made to the sourcecode. Just an OSGi-bundle has been created from the ICEPush-jar-files.</p>
<h4 style="text-align:justify;">Client UI</h4>
<p>Using vaadin all client side addons have to be compiled at once. The resulting widgetset has to be provided as described in <a href="http://redvoodo.wordpress.com/howto/howto-use-vaadin-add-ons/">redvoodo.org</a>. The example from this post uses the widgetset from bundle-fragment &#8220;<strong>org.redvoodo.extension.ct.osgi.widgetset.fragment</strong>&#8220;.</p>
<p>The widgetset has been speficied in the launch configuration:</p>
<pre>-Dorg.redvoodo.addon.osgi.push.servlet.widgetset=</pre>
<pre style="padding-left:30px;">org.redvoodo.extension.ct.osgi.pushosgi.widgetset.PushosgiWidgetset</pre>
<h3 style="text-align:justify;">Minimal bundle requirement</h3>
<p>If you want to use the vaadin OSGi ICEPush, you have to install a minimal set of bundles:</p>
<ul>
<li style="text-align:left;"><strong>org.vaadin.pushosgi</strong> &#8211; the main bundle which contains VaadinOSGiApplicationManager</li>
<li style="text-align:left;"><strong>org.redvoodo.addon.osgi.push.servlet</strong> &#8211; provides the ICEPushVaadinOSGiServlet</li>
<li style="text-align:left;"><strong>org.redvoodo.vaadin.addon.icepush</strong> &#8211; server side java classes from ICEPush</li>
<li style="text-align:left;">some fragment bundle like <strong>org.redvoodo.extension.ct.osgi.widgetset.fragment </strong>containing the compiled widgetset</li>
</ul>
<p>Thats all you have to add to your OSGi launch configuration to have a properly configured &#8220;vaadin OSGi pushable application&#8221;.</p>
<p>But there is no further support. You have to handle the ICEPush yourself.</p>
<p><pre class="brush: java;">
pusher = new ICEPush();
application.getMainWindow().addComponent(pusher);

// doing the push
pusher.push();
</pre></p>
<h3>Demo</h3>
<p>This movie demos what i was writing about so far:<br />
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/23404339' width='480' height='270' frameborder='0'></iframe></div></p>
<h2>5. redVoodo Push Services</h2>
<p>So far you can use ICEPush in vaadin OSGi applications. But there is no further support for some kind of &#8220;OSGi push services&#8221;.</p>
<p>Therefore i have prepared a set of very flexible and loose coupled bundles which offer &#8220;OSGi push services&#8221; and help you to manage your pushing applications.</p>
<p>Bundles:</p>
<ul>
<li style="text-align:left;"><strong>org.redvoodo.addon.osgi.push.services</strong> &#8211; The service interface definition</li>
<li style="text-align:left;"><strong>org.redvoodo.addon.osgi.push.services.impl.service</strong> &#8211; Provides default implementation for IPushService</li>
<li style="text-align:left;"><strong>org.redvoodo.addon.osgi.push.services.impl.manager</strong> &#8211; Provides default implementation for IPushServiceManager</li>
<li style="text-align:left;"><strong></strong><strong>org.redvoodo.addon.osgi.push.services.impl.managed.pusher</strong> &#8211; Provides default implementation for IManagedPusher</li>
<li style="text-align:left;"><strong>org.redvoodo.addon.osgi.push.services.application.bridge</strong> &#8211; The queen of this addon. Bridges IApplicationProvider and IManagedPusher</li>
</ul>
<h3>org.redvoodo.addon.osgi.push.services</h3>
<p>Lets start with the service interfaces:</p>
<p>The main interfaces of these services are IPusher and IPushService:</p>
<p><pre class="brush: java;">
public interface IPusher {

/**
* Forces a push to the client. If the pusher is not active, a call to
* this method must not result in an error.
*
* @return true if the push was successful. False otherwise. If the pusher
*         was not active, false will be returned.
*/
boolean push();

/**
* Returns the application the pusher is prepared for. Or &lt;code&gt;null&lt;/code&gt;
* if the pusher is a compound pusher which pushes several applications.
*
* @return
*/
Application getApplication();

}
</pre></p>
<p>The IPusher is responsible to push changes to the client. Each pusher is associated with exactly one Application.</p>
<p><pre class="brush: java;">
/**
* A push service is used to notify the client, that it should refresh its
* state.
*/
public interface IPushService {

/**
* Activates the push functionality for the given application and ensures,
* that the pusher for this application can be accessed by this service.&lt;br&gt;
* The acitvated pusher will be stored in this service until deactivate
* pusher is called.
*
* @param application
* @return
*/
IPusher activatePusher(Application application);

/**
* Deactivates the push functionality for the given application. Further
* calls to a pusher associated with this application will result in an
* error.
*
* @param application
* @return
*/
void deactivatePusher(Application application);

/**
* Deactivates the push functionality for the application associated with
* the given pusher. Further calls to pusher associated with this
* application will result in an error.
*
* @param application
* @return
*/
void deactivatePusher(IPusher pusher);

/**
* Returns a pusher which pushes all applications that are registered within
* this pushService.
*
* @return
*/
IPusher getGlobalPusher();

/**
* Returns a pusher for the given application.
*
* @param application
* @return
*/
IPusher getPusher(Application application);

/**
* Returns a compound pusher based on the scope. The scope allows to collect
* pushers which are registered within this pushService.
*
* @param scope
* @return
*/
IPusher getPusher(IScope scope);

/**
* Scope is used to create a compound pusher based on other pushers.
*/
public static interface IScope {

/**
* Returns a compound pusher which delegates the push call to the
* contained pusher.
*
* @param pushers
* @return
*/
IPusher getPusher(Map&lt;Application, IPusher&gt; pushers);

}
}
</pre></p>
<p>The IPushService is responsible to activate and deactivate pusher for their associated Application and to access them.</p>
<p>Since IPushService is an OSGi-service, you have to handle the lifecycle of that service. See chapter &#8220;services come and services go&#8221;.</p>
<h3><strong><strong>org.redvoodo.addon.osgi.push.services.application</strong></strong></h3>
<p><strong><strong><span style="color:#ff0000;">ATTENTION: </span></strong></strong><span style="color:#ff0000;">Bundle was removed with 0.7.2. Was not an OSGi like approach.</span><strong><strong><span style="color:#ff0000;"><br />
</span></strong></strong></p>
<h3>org.redvoodo.addon.osgi.push.services.impl.service</h3>
<p><span style="color:#ff0000;">ATTENTION: In Version 0.7.1 this bundle was named</span></p>
<pre><span style="color:#ff0000;">org.redvoodo.addon.osgi.push.services.impl</span></pre>
<p>This image is a summary about the service and its default implementation.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/05/pushservices_defaultimpl2.png"><img class="alignnone size-full wp-image-740" title="PushServices_DefaultImpl" src="http://floriansblog.files.wordpress.com/2011/05/pushservices_defaultimpl2.png?w=450&#038;h=454" alt="" width="450" height="454" /></a></p>
<p>The bundle org.redvoodo.addon.osgi.push.services.impl.service can be used as a default implementation of the push service. But you can write your own implementation and provide it as a service.</p>
<h3>org.redvoodo.addon.osgi.push.services.impl.manager</h3>
<p><span style="color:#ff0000;">Was added with 0.7.2</span></p>
<p>The image shows a summary and the default implementation of the IPushServiceManager. The PushServiceManager is responsible to manage IPushServices. It allows clients to register listener and to observe the services and their lifecycle.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/pushservicesmanager_defaultimpl.png"><img class="alignnone size-full wp-image-742" title="PushServicesManager_DefaultImpl" src="http://floriansblog.files.wordpress.com/2011/05/pushservicesmanager_defaultimpl.png?w=450&#038;h=587" alt="" width="450" height="587" /></a></p>
<p>The bundle org.redvoodo.addon.osgi.push.services.impl.manager can be used as a default implementation of the IPushServiceManager. But you can write your own implementation and provide it as a service.</p>
<h3><strong>org.redvoodo.addon.osgi.push.services.impl.managed.pusher</strong></h3>
<p><span style="color:#ff0000;">Was added with 0.7.2</span><strong><br />
</strong></p>
<p>To hide the lifecycle of IPushService and IPushServiceManager, i have prepared an interface which describes some kind of a helper class.</p>
<h4>IManagedPusher.class</h4>
<p>It internally uses the IPushServiceManager and IPushService, but hides the lifecycle handling from the developer. If services come and services go, the ManagedPusher does not have to be refreshed externally. All the refreshing stuff is handled internally.</p>
<p>A very useful class to minimize the amount of effort required to use the redVoodo push services.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/managedpusher_defaultimpl.png"><img class="alignnone size-full wp-image-748" title="ManagedPusher_DefaultImpl" src="http://floriansblog.files.wordpress.com/2011/05/managedpusher_defaultimpl.png?w=450&#038;h=584" alt="" width="450" height="584" /></a></p>
<p>The component factory can be required as any OSGi-service. But you have to specify the target of the requirement.</p>
<pre>(component.factory=org.redvoodo.addon.osgi.push.services.managed.pusher)</pre>
<p>Code samples how to use the service:</p>
<p><pre class="brush: java;">
/**
* Called by the OSGi framework
*/
public void bindManagedPusherFactory(ComponentFactory pusherFactory,
Map&lt;String, Object&gt; properties) {
      this.pusherFactory = pusherFactory;
}

/**
* Called by the OSGi framework
*/
public void unbindManagedPusherFactory(ComponentFactory factory,
Map&lt;String, Object&gt; properties) {
      this.pusherFactory = null;
}

// to create a new pusher
IManagedPusher pusher = (IManagedPusher) pusherFactory.
newInstance(null).getInstance();
pusher.setup(application);
pusher.pushToClient();

// to dispose the pusher
pusher.dispose();
</pre></p>
<p>For details how to use see class</p>
<pre>org.redvoodo.addon.osgi.push.services.application.bridge.ApplicationPusherBridge</pre>
<h3><strong>org.redvoodo.addon.osgi.push.services.application.bridge</strong></h3>
<p>This bundle is a really important bundle for the vaadin OSGi push services addon. It bridges the IApplicationProvider and the IManagedPusher. Installing this bundle into the target platform will automatically enable push for all applications provided by IApplicationProvider.</p>
<p><a href="http://floriansblog.files.wordpress.com/2011/05/pushservices_appbundle_bridge2.png"><img class="alignnone size-full wp-image-784" title="PushServices_AppBundle_Bridge" src="http://floriansblog.files.wordpress.com/2011/05/pushservices_appbundle_bridge2.png?w=450&#038;h=818" alt="" width="450" height="818" /></a></p>
<p>The org.redvoodo.addon.osgi.push.services.application.bridge bundle requires the IApplicationProvider OSGi-Service. Each time a new application was created by the component factory, the service component will be notified about the new application and uses the ComponentFactory to create an instance of IManagedPusher. The managed pusher itself handles the registration at the IPushService. If the application is destroyed the service component will also be notified and the pusher for the destroyed application will be removed.</p>
<p>Additionally this class requires the componentFactory-service. If a new ComponentFactory for IManagedPusher became available, the class will handle this notification. If no factory was installed yet, nor of the applications are push enabled. But an upcoming component factory service causes the bridge to create new instances of IManagedPusher for each application. And so all applications become push enabled.</p>
<p>Referring to Kai&#8217;s demo application, only one change had to be made to his application. The IApplicationProvider was added to the vaadin.xml compontent definition as a provided service. But his application does not have any dependency to the redVoodo push services. Immediately after the instantiation of an application by a component factory, the application becomes push enabled automatically.</p>
<p>The push to Kai&#8217;s application is triggered by the bundle &#8220;org.redvoodo.extension.ct.osgi.observer&#8221; (All org.redvoodo.extension.ct.osgi bundles are extensions of Kai&#8217;s application). Since this bundle requires the IPushServiceManager service, it has access to all registered push enabled applications and can use that service to push all applications. (Remember: The applications have been registered at the pushService by the ManagedPusher above).</p>
<p><pre class="brush: java;">
String symbolicName = event.getBundle().getSymbolicName();
if ((symbolicName.startsWith(&quot;com.siemens.ct.osgi.vaadin.pm&quot;)
|| symbolicName.startsWith(&quot;com.siemens.ct.pm.model.&quot;))
&amp;&amp; !((symbolicName.contains(&quot;main&quot;)
|| symbolicName.contains(&quot;theme&quot;)
|| symbolicName.contains(&quot;bundleview&quot;)
|| symbolicName.contains(&quot;logback&quot;)))) {
       // push all registered clients
       serviceManager.getPushService().getGlobalPusher().push();
}
</pre></p>
<p>If a bundle becomes started or stopped, the bundleChanged event will be called. For specified bundles the AppPusherPlugin#pushAll() method will be called, which pushed all dirty states to the client.</p>
<h2>How to use push services</h2>
<p>There are several ways how redVoodo push services can be used.</p>
<h4>Require a service</h4>
<p>Require a service like IPushServiceManger, IPushService or IManagedPusher. Depends what the service will be used for.</p>
<h4>Use the default implementations</h4>
<p>Provided by bundles:</p>
<ul>
<li>org.redvoodo.addon.osgi.push.services.impl.managed.pusher</li>
<li>org.redvoodo.addon.osgi.push.services.impl.manager</li>
<li>org.redvoodo.addon.osgi.push.services.impl.service</li>
</ul>
<h4>Write your own services</h4>
<p>Feel free to write your own services and to provide them as a service.</p>
<h2>Conclusion</h2>
<p>I hope this blog post could give you an introduction about the redVoodo OSGi ICEPush services. If you have any suggestions it would be really nice if you may write a comment.</p>
<p>Thanks a lot to Kai Tödter, Chris Brind, Neil Bartlett and Peter Kriens for the really great available code and blog posts how vaadin OSGi integration can be implemented.</p>
<h2>Further informations</h2>
<p><a href="http://www.perplentropy.com/2010/02/in-bed-with-vaadin-and-osgi.html">In bed with vaadin and OSGi</a> by Chris Brind</p>
<p><a href="http://www.toedter.com/blog/?p=412">Dynamic modular Web Applications with Vaadin and OSGi</a> by Kai Tödter</p>
<p><a href="https://github.com/bnd/aQute.vaadin">OSGi vaadin integration</a> by Peter Kriens</p>
<p><a href="http://njbartlett.name">blog</a> by Neil Bartlett</p>
<p><a href="http://ekkescorner.wordpress.com/">blog</a> by Ekkehard Gentz</p>
<p><a href="http://www.redvoodo.org/" target="_blank">redVoodo.org</a></p>
<p><a href="http://redvoodo.wordpress.com/howto/how-to-use-vaadin-osgi/" target="_blank">how to use vaadin and OSGi</a> from redVoodo</p>
<p><a href="http://redvoodo.wordpress.com/howto/howto-use-vaadin-add-ons/">how to use vaadin addons</a> from redVoodo</p>
<p><a href="http://redvoodo.wordpress.com/howto/howto-push-to-browser">how to push to browser</a> from redVoodo</p>
<p><a href="http://www.perplentropy.com/2010/07/comparing-approaches-to-vaadin-and-osgi.html">Comparing approaches</a> by Chris Brind</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/566/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=566&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/05/08/vaadin-osgi-icepush-services/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/kais_app_description.png" medium="image">
			<media:title type="html">kais_app_description</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/kais_application_services1.png" medium="image">
			<media:title type="html">kais_application_Services</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/kais_application_applicationprovider.png" medium="image">
			<media:title type="html">kais_application_ApplicationProvider</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_notpossible.png" medium="image">
			<media:title type="html">kais_application_DirtyState_NotPossible</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_poll.png" medium="image">
			<media:title type="html">kais_application_DirtyState_Poll</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/kais_application_dirtystate_push1.png" medium="image">
			<media:title type="html">kais_application_DirtyState_Push</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/pushosgi_bundle.png" medium="image">
			<media:title type="html">pushOsgi_bundle</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/pushosgi_bundle_servlets.png" medium="image">
			<media:title type="html">pushOsgi_bundle_servlets</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/vaadinosgiapplicationmanager.png" medium="image">
			<media:title type="html">VaadinOSGiApplicationManager</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/pushservices_defaultimpl2.png" medium="image">
			<media:title type="html">PushServices_DefaultImpl</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/pushservicesmanager_defaultimpl.png" medium="image">
			<media:title type="html">PushServicesManager_DefaultImpl</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/managedpusher_defaultimpl.png" medium="image">
			<media:title type="html">ManagedPusher_DefaultImpl</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/05/pushservices_appbundle_bridge2.png" medium="image">
			<media:title type="html">PushServices_AppBundle_Bridge</media:title>
		</media:content>
	</item>
		<item>
		<title>06 &#8211; Attributes</title>
		<link>http://floriansblog.wordpress.com/2011/03/19/06-attributes/</link>
		<comments>http://floriansblog.wordpress.com/2011/03/19/06-attributes/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 17:25:39 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[06 Attributes]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Entwicklung]]></category>
		<category><![CDATA[Florian Pirchner]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Vienna]]></category>
		<category><![CDATA[Wien]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=417</guid>
		<description><![CDATA[The way how variables are defined in Objective-C is very different to Java. Since Objective-C is dealing with pointers (see (NSString **) value) and developers have to be aware of memory management, the definition of variables is much more complicated and powerful than in Java. 1 &#8211; Java attributes In this blog post I decided [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=417&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The way how variables are defined in Objective-C is very different to Java. Since Objective-C is dealing with pointers (see <a href="http://floriansblog.wordpress.com/category/iphoneosx/java-versus-objective-c/03-nsstring-value/">(NSString **) value</a>) and developers have to be aware of memory management, the definition of variables is much more complicated and powerful than in Java.</p>
<h2>1 &#8211; Java attributes</h2>
<p>In this blog post I decided to start with the very basics based on Java.</p>
<p>We are deciding between two different kind of variables:</p>
<ul>
<li>instance variables</li>
<li>class variables</li>
</ul>
<h3>1.1 &#8211; Instance variables</h3>
<p>An instance variable is an attribute from a classes instance and exists for each instance. It will be initialized during the creation of the class instance. Instance variables can only be accessed by class instances and not by classes.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_instanceatt1.png"><img class="size-full wp-image-437" title="Variables_InstanceAtt" src="http://floriansblog.files.wordpress.com/2011/03/variables_instanceatt1.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">Instance variables are accessed like this:</p>
<blockquote><p><code> SomeObject object = new SomeObject();</code><br />
<code> String value = object.value;</code></p></blockquote>
<p style="text-align:justify;">&nbsp;</p>
<p style="text-align:justify;">&nbsp;</p>
<h3>1.2 &#8211; Class variables</h3>
<p>A class variable is an attribute of a class and exists exactly once  by class and classloader. It will be initialized at class loading time  and can be accessed by classes and class instances. All instances of a class will share this unique state of the variable. If you change the variable, it becomes changed for all instances of this class.<br />
<a href="http://floriansblog.files.wordpress.com/2011/03/variables_classatt.png"><img title="Variables_ClassAtt" src="http://floriansblog.files.wordpress.com/2011/03/variables_classatt.png?w=437&#038;h=144" alt="" width="437" height="144" /></a><br />
Class variables are accessed like this:</p>
<blockquote><p><code> String value = SomeObject.value;</code></p></blockquote>
<p style="text-align:justify;">&nbsp;</p>
<h3 style="text-align:justify;">1.3 &#8211; Visibility Modifier</h3>
<p>Java decides 4 different visibilities:</p>
<ul>
<li>public &#8211; visible for all objects</li>
<li>protected &#8211; visible for all subclasses. Also visbile for classes in the same package</li>
<li>private &#8211; only visible inside the class</li>
<li>default &#8211; only visible for classes in the same package</li>
</ul>
<h3>1.4 &#8211; Final Modifier</h3>
<p>The final modifier defines, that a variable has to be initialized once during the class loading or instance creation, but must never change.</p>
<h4>1.4.1 &#8211; Final instance variable</h4>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_instanceatt_final.png"><img class="size-full wp-image-444" title="Variables_InstanceAtt_Final" src="http://floriansblog.files.wordpress.com/2011/03/variables_instanceatt_final.png?w=450&#038;h=172" alt="" width="450" height="172" /></a></p>
<p style="text-align:justify;">&nbsp;</p>
<p style="text-align:justify;">Final instance variables are used for different behaviours. Eg to ease the handling of concurreny or to protect the state of a class.</p>
<h4 style="text-align:justify;">1.4.2 &#8211; Final static variable</h4>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_classatt_final.png"><img class="size-full wp-image-446" title="Variables_ClassAtt_Final" src="http://floriansblog.files.wordpress.com/2011/03/variables_classatt_final.png?w=450&#038;h=141" alt="" width="450" height="141" /></a></p>
<p style="text-align:justify;">&nbsp;</p>
<p style="text-align:justify;">Final class variables are often used for constant definitions. &#8220;static final String&#8221; are very common to define constants.</p>
<p style="text-align:justify;">&nbsp;</p>
<h2>2 &#8211; Objective-C attributes</h2>
<p>In the second part of this post i am going to define the attributes defined above using Objective-C.</p>
<p>We are going to start with instance variables.</p>
<h3>2.1 &#8211; Instance variables</h3>
<p>Variables are defined in the .h interface file.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt.png"><img class="size-full wp-image-452" title="Variables_ObjC_InstanceAtt" src="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">If you do not define something special, the attribute has visibility <em><strong>&#8220;protected&#8221;</strong></em>. You can use it in the .m implementation file and deal with it. Also subclasses of MyClass can access the attribute.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_accesssubclass.png"><img class="size-full wp-image-454" title="Variables_ObjC_InstanceAtt_AccessSubclass" src="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_accesssubclass.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">This image shows the attribute access in a subclass of MyClass.</p>
<p style="text-align:justify;">See also: <a href="http://iphonedevelopertips.com/objective-c/java-developers-guide-to-static-variables-in-objective-c.html" target="_blank">iphonedevelopertips.com</a>, <a href="http://www.omnigroup.com/mailman/archive/macosx-dev/2002-April/037869.html" target="_blank">omnigroup.com</a></p>
<h3>2.2 &#8211; Class variables</h3>
<p style="text-align:justify;">Differing to Java, Objective-C does not allow to use public / protected class variables. If variables are defined as static, they are allways private.</p>
<pre>static NSString *anAttribute;</pre>
<p style="text-align:justify;">This variable can only be used inside of the class which defines this variable.</p>
<p style="text-align:justify;">Another very confusing behaviour of static attributes is the fact, that they can be defined inside a method and will retain their value during subsequent calls. For instance the singleton pattern uses this very havily.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_classatt_definmethod.png"><img class="size-full wp-image-526" title="Variables_ClassAtt_DefInMethod" src="http://floriansblog.files.wordpress.com/2011/03/variables_classatt_definmethod.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">See <a href="http://stackoverflow.com/questions/554969/using-static-keyword-in-objective-c-when-defining-a-cached-variable" target="_blank">stackoverflow.com</a> for a similar example and a detailed description.</p>
<p style="text-align:justify;">&nbsp;</p>
<h3>2.3 &#8211; Visibility Modifier</h3>
<p style="text-align:justify;">If the attribtue should be accessible from other classes, you have to use <em><strong>visibility modifiers</strong></em>.</p>
<p style="text-align:justify;"><strong>Please not, that static attributes are always private.</strong></p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_visibility.png"><img class="size-full wp-image-456" title="Variables_ObjC_InstanceAtt_Visibility" src="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_visibility.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">For explanation i changed MyClass and added 3 attribtues with 3 different visibilities.</p>
<p style="text-align:justify;">&nbsp;</p>
<p style="text-align:justify;">No i am trying to access them from</p>
<ul>
<li>MyClass.m &#8211; should work for all 3 attributes</li>
<li>MySubClass.m &#8211; should work for protected and public</li>
<li>OtherClass.m &#8211; should work for public</li>
</ul>
<h5>MyClass.m</h5>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accessclass.png"><img class="size-full wp-image-457" title="Variables_ObjC_InstanceAtt_Vis_AccessClass" src="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accessclass.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">Everything is fine. No problems reported.</p>
<p style="text-align:justify;">&nbsp;</p>
<h5 style="text-align:justify;">MySubClass.m</h5>
<p><a href="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accesssubclass.png"><img class="alignleft size-full wp-image-458" title="Variables_ObjC_InstanceAtt_Vis_AccessSubClass" src="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accesssubclass.png?w=450&#038;h=114" alt="" width="450" height="114" /></a></p>
<p style="text-align:justify;">&nbsp;</p>
<p style="text-align:justify;">Private attributes can not be accessed by subclasses.</p>
<p style="text-align:justify;">&nbsp;</p>
<h5 style="text-align:justify;">OtherClass.m</h5>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accessotherclass.png"><img class="size-full wp-image-459" title="Variables_ObjC_InstanceAtt_Vis_AccessOtherClass" src="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accessotherclass.png?w=450&#038;h=105" alt="" width="450" height="105" /></a></p>
<p style="text-align:justify;">Since OtherClass is not a subclass of MyClass, only public attributes can be accessed. For sure, directly accessing public attributes from classes outside the typehierarchy is not good pratice! But for demonstration it is really well.</p>
<p style="text-align:justify;">&nbsp;</p>
<h3 style="text-align:justify;">2.4 &#8211; Final modifier</h3>
<p>As you could see, the visibility modifier has a very close semantic to java. But what is about the <strong>final</strong> modifier?</p>
<p>Actually, Objective-C does not provide a <em><strong>final</strong></em> modifier, but the keyword <em><strong>const </strong></em>(means constant).</p>
<p>But Const offers a much more complex semantic as final does. It allows pointers and / or values of pointers to be defined as <em>&#8220;constant&#8221;</em>.<br />
<em>&#8220;Final&#8221;</em> only defines a constant reference which can not be changed, since java does not divide between reference and its value.</p>
<p>Lets compare the different possibilities:</p>
<blockquote><p><span style="color:#ff0000;">Java</span></p>
<p><code>private final Char someString;</code></p>
<p>The one and only way to define the char as final using java. Final means, that the value of the attribtue can only be assigned once. (During initilization)</p></blockquote>
<blockquote><p><span style="color:#ff0000;">Objective-C</span><br />
It provides 3 different combinations of the const keyword.<br />
<code><br />
// Pointer to constant char<br />
const char* someString;<br />
</code><br />
<code><br />
// Constant Pointer to char<br />
char* const someString;<br />
</code><br />
<code><br />
// Constant Pointer to constant char<br />
const char* const someString;</code></p></blockquote>
<p>We are going to use a few lines of code to get a feeling what i am talking about. The following image shows the three combinations of const mentioned above.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_instance_constants_code.png"><img class="size-full wp-image-486" title="Variables_Instance_Constants_Code" src="http://floriansblog.files.wordpress.com/2011/03/variables_instance_constants_code.png?w=450&#038;h=296" alt="" width="450" height="296" /></a></p>
<p style="text-align:justify;">&nbsp;</p>
<ul>
<li><strong>Example 1</strong> &#8211; <em>&#8220;const char* charPtr1&#8243;</em> means that the <strong>pointer <em>charPtr1</em> is <em>variable</em></strong>, but <strong><em>&#8220;the data the pointer is pointing to&#8221;</em> is <em>const</em></strong>. So only the <em>&#8220;adress the pointer points to&#8221;</em> can be changed. The <em>&#8220;value the pointer is pointing to&#8221;</em> is constant.</li>
</ul>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_constcharvarptr.png"><img class="size-full wp-image-493" title="Variables_ConstCharVarPtr" src="http://floriansblog.files.wordpress.com/2011/03/variables_constcharvarptr.png?w=450&#038;h=347" alt="" width="450" height="347" /></a></p>
<p style="text-align:justify;">&nbsp;</p>
<ul>
<li><strong>Example 2</strong> &#8211; <em>&#8220;char* const charPtr2&#8243;</em> means that the <strong>pointer <em>charPtr2</em> is constant</strong>, but <strong><em>&#8220;the data the pointer is pointing to&#8221;</em><em> </em> is <em>variable</em></strong>. So only the <em>&#8220;</em><em>value the pointer is pointing to</em>&#8221; can be changed. The <em>&#8220;adress of the pointer&#8221;</em> is constant.</li>
</ul>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_varcharconstptr.png"><img class="size-full wp-image-495" title="Variables_VarCharConstPtr" src="http://floriansblog.files.wordpress.com/2011/03/variables_varcharconstptr.png?w=450&#038;h=276" alt="" width="450" height="276" /></a></p>
<p style="text-align:justify;">&nbsp;</p>
<ul>
<li><strong>Example 3</strong> &#8211; <em>&#8220;const char* const charPtr3&#8243;</em> means that the <strong>pointer <em>charPtr3</em> is constant</strong>, and <strong><em>&#8220;value the pointer is pointing to&#8221;</em><em> </em> is <em>constant</em></strong>. Nor the <em>&#8220;value or the adress&#8221;</em> of the pointer can be changed.</li>
</ul>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_constcharconstptr.png"><img class="size-full wp-image-496" title="Variables_ConstCharConstPtr" src="http://floriansblog.files.wordpress.com/2011/03/variables_constcharconstptr.png?w=450&#038;h=303" alt="" width="450" height="303" /></a></p>
<h3><strong>How to define final variables using Objective-C?</strong></h3>
<p>I found  a nice discussion about this issue: See <a href="http://iphonedevelopertips.com/objective-c/java-developers-guide-to-string-constants-in-objective-c.html" target="_blank">iphonedevelopertips.com</a></p>
<h4>Example 1 : final instance variable</h4>
<blockquote><p><strong>Java</strong><br />
<code>public final String MY_STRING = "MyString";</code></p>
<p style="text-align:justify;"><strong>Objective-C:</strong><br />
.h-File:<br />
<code>extern const NSString* const MYSTRING;</code><br />
<a href="http://floriansblog.files.wordpress.com/2011/03/variables_extern_const_header1.png"><img class="size-full wp-image-511" title="Variables_Extern_Const_Header" src="http://floriansblog.files.wordpress.com/2011/03/variables_extern_const_header1.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">.m-File<br />
<code>const NSString* const MYSTRING = @"myValue";</code><br />
<a href="http://floriansblog.files.wordpress.com/2011/03/variables_extern_const_impl1.png"><img class="size-full wp-image-512" title="Variables_Extern_Const_Impl" src="http://floriansblog.files.wordpress.com/2011/03/variables_extern_const_impl1.png?w=450" alt=""   /></a></p>
<p style="text-align:justify;">&nbsp;</p>
</blockquote>
<h4>Example 2 : final static variable</h4>
<p>Since static attributes are always private, we do not have to specify anything in the header file. It is enough to specify the attribute in the implementation file.</p>
<blockquote><p><strong>Java</strong><br />
<code>public static final String MY_STRING = "MyString";</code></p>
<p style="text-align:justify;"><strong>Objective-C:</strong><br />
.h-File:<br />
<code>==&gt; Nothing to do. static attribute is always private!<br />
</code></p>
<p style="text-align:justify;">.m-File<br />
<code>static const NSString* const MYSTRING = @"myValue";</code></p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/variables_static_const_impl.png"><img class="alignleft size-full wp-image-514" title="Variables_Static_Const_Impl" src="http://floriansblog.files.wordpress.com/2011/03/variables_static_const_impl.png?w=450" alt=""   /></a></p>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/417/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/417/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/417/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=417&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/03/19/06-attributes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_instanceatt1.png" medium="image">
			<media:title type="html">Variables_InstanceAtt</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_classatt.png" medium="image">
			<media:title type="html">Variables_ClassAtt</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_instanceatt_final.png" medium="image">
			<media:title type="html">Variables_InstanceAtt_Final</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_classatt_final.png" medium="image">
			<media:title type="html">Variables_ClassAtt_Final</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt.png" medium="image">
			<media:title type="html">Variables_ObjC_InstanceAtt</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_accesssubclass.png" medium="image">
			<media:title type="html">Variables_ObjC_InstanceAtt_AccessSubclass</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_classatt_definmethod.png" medium="image">
			<media:title type="html">Variables_ClassAtt_DefInMethod</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_visibility.png" medium="image">
			<media:title type="html">Variables_ObjC_InstanceAtt_Visibility</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accessclass.png" medium="image">
			<media:title type="html">Variables_ObjC_InstanceAtt_Vis_AccessClass</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accesssubclass.png" medium="image">
			<media:title type="html">Variables_ObjC_InstanceAtt_Vis_AccessSubClass</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_objc_instanceatt_vis_accessotherclass.png" medium="image">
			<media:title type="html">Variables_ObjC_InstanceAtt_Vis_AccessOtherClass</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_instance_constants_code.png" medium="image">
			<media:title type="html">Variables_Instance_Constants_Code</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_constcharvarptr.png" medium="image">
			<media:title type="html">Variables_ConstCharVarPtr</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_varcharconstptr.png" medium="image">
			<media:title type="html">Variables_VarCharConstPtr</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_constcharconstptr.png" medium="image">
			<media:title type="html">Variables_ConstCharConstPtr</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_extern_const_header1.png" medium="image">
			<media:title type="html">Variables_Extern_Const_Header</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_extern_const_impl1.png" medium="image">
			<media:title type="html">Variables_Extern_Const_Impl</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/variables_static_const_impl.png" medium="image">
			<media:title type="html">Variables_Static_Const_Impl</media:title>
		</media:content>
	</item>
		<item>
		<title>WordPress in google webmaster tools</title>
		<link>http://floriansblog.wordpress.com/2011/03/13/wordpress-in-google-webmaster-tools/</link>
		<comments>http://floriansblog.wordpress.com/2011/03/13/wordpress-in-google-webmaster-tools/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 10:26:51 +0000</pubDate>
		<dc:creator>Florian Pirchner</dc:creator>
				<category><![CDATA[Florians Posts]]></category>
		<category><![CDATA[Wordpress at google webmaster]]></category>
		<category><![CDATA[Florian Pirchner]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Vienna]]></category>
		<category><![CDATA[Wien]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://floriansblog.wordpress.com/?p=375</guid>
		<description><![CDATA[How to register your blog at webmaster tools The last hours it tried to register this wordpress blog in google webmaster tools. After several unavailing attempts using the &#8220;Upload an HTML file to your server&#8221; option, i found a really simple solution. Some time ago it seemed, that registering a wordpress blog at the google [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=375&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>How to register your blog at webmaster tools</h2>
<p>The last hours it tried to register this wordpress blog in <a href="http://www.google.com/webmasters/">google webmaster tools</a>.</p>
<p>After several unavailing attempts using the &#8220;Upload an HTML file to your server&#8221; option, i found a really simple solution.</p>
<p>Some time ago it seemed, that registering a wordpress blog at the google webmaster tooling was performed using the &#8220;Upload an HTML file to your server&#8221;. But it does not work anymore! I always got the error that the content of the website has wrong format.</p>
<h2>The way to do</h2>
<p>Assumed you already have a google webmaster account, i am going to explain the steps required to register a wordpress blog.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/webmasters_addsite.png"><img class="size-full wp-image-378" title="Webmasters_addSite" src="http://floriansblog.files.wordpress.com/2011/03/webmasters_addsite.png?w=450&#038;h=248" alt="" width="450" height="248" /></a></p>
<p>The first step is to add your site. There is nothing special.</p>
<p>To perform the next step, you have to select the option &#8220;Add a meta tag to your   home page&#8221;. For normal you would have to paste this meta tag to the  head  section of your html-file.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/webmasters_metatag.png"><img class="size-full wp-image-379" title="Webmasters_MetaTag" src="http://floriansblog.files.wordpress.com/2011/03/webmasters_metatag.png?w=450" alt=""   /></a></p>
<p>Since we do not have access to the wordpresssite head tag, we are using a feature provided by wordpress.</p>
<p>Navigate to tools and paste the meta tag to the input field &#8220;Google Webmaster Tools&#8221;. Accept your input by saving the settings.</p>
<p style="text-align:justify;"><a href="http://floriansblog.files.wordpress.com/2011/03/webmasters_paste_metatag.png"><img class="size-full wp-image-380" title="Webmasters_Paste_MetaTag" src="http://floriansblog.files.wordpress.com/2011/03/webmasters_paste_metatag.png?w=450&#038;h=170" alt="" width="450" height="170" /></a></p>
<p>Final step &#8211; now you can return to &#8220;google webmaster tools&#8221; and verify your site. Everything should work properly and your wordpress blog had been added to the &#8220;google webmaster tools&#8221;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/floriansblog.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/floriansblog.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/floriansblog.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/floriansblog.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/floriansblog.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/floriansblog.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/floriansblog.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/floriansblog.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/floriansblog.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/floriansblog.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/floriansblog.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/floriansblog.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/floriansblog.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/floriansblog.wordpress.com/375/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=floriansblog.wordpress.com&amp;blog=9007243&amp;post=375&amp;subd=floriansblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://floriansblog.wordpress.com/2011/03/13/wordpress-in-google-webmaster-tools/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7f5b7b1719594c2e13fb3b81576da6c0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">florianpi</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/webmasters_addsite.png" medium="image">
			<media:title type="html">Webmasters_addSite</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/webmasters_metatag.png" medium="image">
			<media:title type="html">Webmasters_MetaTag</media:title>
		</media:content>

		<media:content url="http://floriansblog.files.wordpress.com/2011/03/webmasters_paste_metatag.png" medium="image">
			<media:title type="html">Webmasters_Paste_MetaTag</media:title>
		</media:content>
	</item>
	</channel>
</rss>
