/*
 * Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.  You may obtain a copy of
 * the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed
 * under the License is distributed on an "AS IS" BASIS, without warranties or
 * conditions of any kind, EITHER EXPRESS OR IMPLIED.  See the License for the
 * specific language governing permissions and limitations under the License.
 */

package com.vmware.xenon.workshop;

import com.vmware.xenon.common.Operation;
import com.vmware.xenon.common.ServiceHost;
import com.vmware.xenon.services.common.RootNamespaceService;

public class Demo {

    public static void main(String[] args) throws Throwable {

        ServiceHost host = ServiceHost.create("--sandbox=/tmp/xenon-demo");
        host.start();
        host.startDefaultCoreServicesSynchronously();

        // A simple stateless service which enumerates all the factory services started on the service host.
        host.startService(new RootNamespaceService());

        // A simple stateless service.
        host.startService(new DemoStatelessService());

        // A simple stateful service.
        DemoStatefulService.State initialState = new DemoStatefulService.State();
        initialState.stringValue = "A string value";
        Operation post = Operation.createPost(host, DemoStatefulService.SELF_LINK).setBody(initialState);
        host.startService(post, new DemoStatefulService());

        // A simple factory service.
        host.startService(new DemoFactoryService());
    }
}

@@ -645,16 +645,49 @@
 kshop;%0A%0A
+import java.util.logging.Level;%0A%0A
 import c
@@ -792,44 +792,20 @@
 non.
-services.common.RootNamespaceService
+common.Utils
 ;%0A%0Ap
@@ -1044,173 +1044,8 @@
 );%0A%0A
-        // A simple stateless service which enumerates all the factory services started on the service host.%0A        host.startService(new RootNamespaceService());%0A%0A
     
@@ -1534,40 +1534,789 @@
 tart
-Service(new DemoFactoryService()
+FactoryServicesSynchronously(new DemoFactoryService());%0A%0A        // A POST operation to create a single child service of the factory.%0A        post = Operation.createPost(host, DemoFactoryService.SELF_LINK)%0A                .setBody(initialState)%0A                .setReferer(host.getUri())%0A                .setCompletion((o, e) -%3E %7B%0A                    if (e != null) %7B%0A                        host.log(Level.SEVERE, %22Post failed: %25s%22, Utils.toString(e));%0A                        return;%0A                    %7D%0A                    host.log(Level.INFO, %22Post completed with code %25d and state %25s%22,%0A                            o.getStatusCode(),%0A                            Utils.toJsonHtml(o.getBody(DemoStatefulService.State.class)));%0A                %7D);%0A%0A        host.sendRequest(post
 );%0A 

Update stateful service demo content (2)