You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by bp...@apache.org on 2016/01/27 15:34:26 UTC

[1/9] celix git commit: CELIX-236: Initial drop of celix-bootstrap

Repository: celix
Updated Branches:
  refs/heads/develop d5666c571 -> 01136093e


CELIX-236: Initial drop of celix-bootstrap


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/5d703d3a
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/5d703d3a
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/5d703d3a

Branch: refs/heads/develop
Commit: 5d703d3ae9949072d433f3893c49316b6ccf4eaf
Parents: e2598c1
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Fri May 15 21:33:15 2015 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Fri May 15 21:33:15 2015 +0200

----------------------------------------------------------------------
 celix-bootstrap/README.md                       |  56 +++
 celix-bootstrap/celix/__init__.py               |   2 +
 celix-bootstrap/celix/bootstrap/__init__.py     |   0
 celix-bootstrap/celix/bootstrap/__main__.py     |   4 +
 .../celix/bootstrap/argument_parser.py          |  73 +++
 celix-bootstrap/celix/bootstrap/generators.py   | 163 +++++++
 .../bootstrap/templates/bundle/CMakeLists.txt   |  55 +++
 .../bootstrap/templates/bundle/bundle.json      |  18 +
 .../templates/bundle/bundle_activator.c         | 471 +++++++++++++++++++
 .../bootstrap/templates/bundle/component.c      | 174 +++++++
 .../bootstrap/templates/bundle/component.h      |  69 +++
 .../bootstrap/templates/bundle/deploy.cmake     |  18 +
 .../bootstrap/templates/project/CMakeLists.txt  |  30 ++
 .../bootstrap/templates/project/project.json    |   4 +
 .../bootstrap/templates/services/service.h      |  48 ++
 .../bootstrap/templates/services/services.json  |   4 +
 celix-bootstrap/scripts/celix-bootstrap         |   5 +
 celix-bootstrap/setup.py                        |  31 ++
 18 files changed, 1225 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/README.md
----------------------------------------------------------------------
diff --git a/celix-bootstrap/README.md b/celix-bootstrap/README.md
new file mode 100644
index 0000000..ef63c8a
--- /dev/null
+++ b/celix-bootstrap/README.md
@@ -0,0 +1,56 @@
+# celix-bootstrap
+A (python based) code generation tool for [Apache Celix](https://celix.apache.org/) projects and bundles.
+
+##Installation
+
+###Option 1 (install with distutils)
+
+* Download Cog from https://pypi.python.org/pypi/cogapp
+* Unpack and run `python setup.py install' in the cogapp directory
+* Clone this repository
+* Run `python setup.py install` in the celix-bootstrap directory
+
+###Option 2 (configure with alias)
+* Download Cog from https://pypi.python.org/pypi/cogapp
+* Unpack it in a convenient directory 
+* Clone this repository
+* Create a celix-bootstrap alias:
+```
+alias celix-bootstrap='PYTHONPATH=${cog_dir}:${celix-boostrap_dir} python -m celix-bootstrap'
+```
+
+#Concept
+The idea behind celix-boostrap is to enable users of Apache Celix to very fast setup of Apache Celix bundle projects. And after that to be able to generate and update the initial bundle code based on some declaritive attributes.
+
+celix-boostrap is build on top of [Cog](https://celix.apache.org/). "Cog is a file generation tool. It lets you use pieces of Python code as generators in your source files to generate whatever text you need." 
+
+The code generation code is added in the comments of the source code (in this case C or CMake syntax). This enables a
+source files which contains manual code and generated code to coexists and to able to rerun code generation after manual editing source files.
+
+Is good to known that you should not edit anything between the following comments.
+```
+{{
+{{end}}
+```
+
+#Usage
+
+You can setup a new Apache Celix project by executing following steps:
+* Choose a project directory and cd to it
+* Run `celix-bootstrap create_project .`
+* Edit the project.json file and ensure that the celix_install_dir points to the directory where Apache Celix is installed
+* Run `celix-bootstrap update .` to generate the needed files
+* (Optional) Update the project.json file and run `celix-bootstrap update .` again to update the generated files
+* (Optional) Run `celix-bootstrap update . -e` to update the project source files one more time and remove the code generation parts
+
+You can create a new bundle by executing the following steps:
+* cd to the project directory
+* Run `celix-bootstrap create_bundle mybundle`
+* Edit the `mybundle/bundle.json` file to declare which components you like to create and what services those components depends on and/or provide
+* Run `celix-bootstrap update mybundle` to generate the neccesary files
+* Add the bundle to the project CMakeLists.txt file by adding the `add_subdirectory(mybundle)` line
+* Add code to the component and when providing service also add the necesarry code to the bundle activator
+* (Optional) Run `celix-bootstrap update . -e` to update the bundle source files one more time and remove the code generation parts
+
+Additional Info
+* You can use the -t argument to use a different set of template (project & bundle) files. The original template files can be found at ${celix-bootstrap_dir}/templates

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/__init__.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/__init__.py b/celix-bootstrap/celix/__init__.py
new file mode 100644
index 0000000..139597f
--- /dev/null
+++ b/celix-bootstrap/celix/__init__.py
@@ -0,0 +1,2 @@
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/__init__.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/__init__.py b/celix-bootstrap/celix/bootstrap/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/__main__.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/__main__.py b/celix-bootstrap/celix/bootstrap/__main__.py
new file mode 100644
index 0000000..0701ac8
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/__main__.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+from . import argument_parser
+
+argument_parser.main()

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/argument_parser.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/argument_parser.py b/celix-bootstrap/celix/bootstrap/argument_parser.py
new file mode 100644
index 0000000..6919e9a
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/argument_parser.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+import os
+import argparse
+from . import generators
+
+#TODO add support to add licence text to all created files
+#TODO add support to select pthread or celix_threads
+
+def main() :
+	parser = argparse.ArgumentParser("celix-bootstrap")
+
+	CREATE_PROJECT_COMMAND = "create_project"	
+	CREATE_BUNDLE_COMMAND = "create_bundle"
+	CREATE_SERVICE_COMMAND = "create_services"
+
+	UPDATE_COMMAND = "update"
+
+	#positional
+	parser.add_argument("command", help="The command to executee", choices=(CREATE_PROJECT_COMMAND, CREATE_BUNDLE_COMMAND, CREATE_SERVICE_COMMAND, UPDATE_COMMAND))
+	parser.add_argument("directory", help="The directory to work on")
+
+	#optional
+	parser.add_argument("-e", "--erase", help="erase cog code when updating", action="store_true")
+	parser.add_argument("-t", "--template_dir", help="define which template directory to use. Default is '%s/templates'" % os.path.dirname(__file__), action="store")
+
+	args = parser.parse_args()
+	
+	gm = GeneratorMediator(args.directory, args.erase, args.template_dir)
+
+	if args.command == CREATE_BUNDLE_COMMAND :
+		gm.createBundle()
+	elif args.command == CREATE_PROJECT_COMMAND :
+		gm.createProject()
+	elif args.command == CREATE_SERVICE_COMMAND :
+		gm.createServices()
+	elif args.command == UPDATE_COMMAND :
+		gm.update()
+	else :
+		sys.exit()
+
+
+class GeneratorMediator :
+	
+	gendir = None
+	bundleGenerator = None
+	projectGenerator = None
+	servicesGenerator = None
+	
+	def __init__(self, gendir, erase, template_dir) :		
+		self.gendir = gendir
+		self.bundleGenerator = generators.Bundle(gendir, erase, template_dir)
+		self.projectGenerator = generators.Project(gendir, erase, template_dir)
+		self.servicesGenerator = generators.Services(gendir, erase, template_dir)
+
+	def createBundle(self) :
+		self.bundleGenerator.create()
+	
+	def createProject(self) :
+		self.projectGenerator.create()	
+	
+	def createServices(self) :
+		self.servicesGenerator.create()
+
+	def update(self) :
+		if os.path.isfile(os.path.join(self.gendir, "bundle.json")) :
+			print("Generating/updating bundle code")
+			self.bundleGenerator.update()
+		if os.path.isfile(os.path.join(self.gendir, "project.json")) :
+			print("Generating/updating project code")
+			self.projectGenerator.update()
+		if os.path.isfile(os.path.join(self.gendir, "services.json")) :
+			print("Generating/updating services code")
+			self.servicesGenerator.update()

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/generators.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/generators.py b/celix-bootstrap/celix/bootstrap/generators.py
new file mode 100644
index 0000000..58e13df
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/generators.py
@@ -0,0 +1,163 @@
+import shutil
+import os
+import sys
+import json
+import cogapp
+
+class BaseGenerator:
+	gendir = None
+	descriptor = None
+	erase_cog = False
+	template_dir = None
+	profile= None
+	gen_code_suffix = "do not edit, generated code"
+	markers="{{ }} {{end}}"
+
+	def __init__(self, gendir, profile, erase, template_dir) :
+		self.gendir = gendir
+		self.descriptor = "%s/%s.json" % (gendir, profile)
+		self.template_dir = os.path.join(os.getcwd(), os.path.dirname(__file__), "templates")
+		self.profile = profile
+		self.erase_cog = erase
+		if template_dir is not None :
+			self.template_dir = template_dir
+
+	def set_erase_cog(self, erase) :
+		self.erase_cog = erase
+
+	def set_template_dir(self, tdir) :
+		self.template_dir = tdir
+
+	def set_gen_cod_suffic(self, suffix) :
+		self.gen_code_suffic = suffix
+
+	def set_cog_markers(markers) :
+		self.markers = markers
+		
+	def create(self) :
+		if os.path.exists(self.descriptor) :
+			print("%s Already exists. Will not override existing %s.json" % (self.descriptor, self.profile))
+		else :
+			if not os.path.exists(self.gendir) :
+				os.makedirs(self.gendir)
+			shutil.copyfile(os.path.join(self.template_dir, self.profile, "%s.json" % self.profile), self.descriptor)
+			
+			print("Edit the %s file and run 'celix-bootstrap update %s' to generate the source files" % (self.descriptor, self.gendir))
+
+	def read_descriptor(self) :
+		if os.path.isdir(self.gendir) and os.path.exists(self.descriptor) :
+			with open(self.descriptor) as inputFile :
+				try :
+					return json.load(inputFile)
+				except ValueError as e:
+					print("ERROR: %s is not a valid json file: %s" % (self.descriptor, e))
+					sys.exit(1)
+
+	def update_file(self, template, targetFile, options=[], commentsPrefix="//") :
+		cog_file = os.path.join(self.gendir, targetFile)
+		if not os.path.exists(cog_file) :
+			print("Creating file %s" % cog_file)
+			if not os.path.exists(os.path.dirname(cog_file)) :
+				os.makedirs(os.path.dirname(cog_file))
+			template_abs = os.path.join(self.template_dir, self.profile,  template)
+			shutil.copyfile(template_abs, cog_file)
+	
+		backup_cog_file = "%s/.cog/%s" % (self.gendir, targetFile)
+		if self.erase_cog :
+			if os.path.exists(backup_cog_file) :
+				print("Will not erase cog code, backup file (%s) for source already exists." % backup_cog_file)
+				sys.exit(1)
+			else :
+				if not os.path.exists(os.path.dirname(backup_cog_file)) :
+					os.makedirs(os.path.dirname(backup_cog_file))
+				shutil.copy(cog_file, backup_cog_file)
+		
+		cog = cogapp.Cog()
+		cog_options = ["cog", "--markers=%s" % self.markers] + options 
+		if self.erase_cog :
+			cog_options += ["-d", "-o", cog_file, backup_cog_file]
+		else :
+			cog_options += ["-r", "-e", "-s", " %s%s" %(commentsPrefix, self.gen_code_suffix), cog_file]
+		cog.main(cog_options)
+	
+
+class Bundle(BaseGenerator):
+
+	def __init__(self, gendir, erase, template_dir) :
+		BaseGenerator.__init__(self, gendir, "bundle", erase, template_dir)
+		#python3 super(Bundle, self).__init__(gendir, "bundle")
+
+	def update_cmakelists(self) :
+		options = ["-D", "bundleFile=%s" % self.descriptor]
+		self.update_file("CMakeLists.txt", "CMakeLists.txt", options, "#")	
+		
+	def update_deploy_file(self) :
+		options = ["-D", "bundleFile=%s" % self.descriptor]
+		self.update_file("deploy.cmake", "deploy.cmake", options, "#")	
+
+	def update_activator(self) :
+		options = ["-D", "bundleFile=%s" % self.descriptor]
+		self.update_file("bundle_activator.c", "private/src/bundle_activator.c", options)
+
+	def update_component_header(self, componentName) :
+		genfile = "private/include/%s.h" % componentName
+		options = ["-D", "bundleFile=%s" % self.descriptor, "-D", "componentName=%s" % componentName]
+		self.update_file("component.h", genfile, options)
+
+	def update_component_source(self, componentName) :
+		genfile = "private/src/%s.c" % componentName
+		options = ["-D", "bundleFile=%s" % self.descriptor, "-D", "componentName=%s" % componentName]
+		self.update_file("component.c", genfile, options)
+
+	def update(self) :
+		bd = self.read_descriptor()
+		if bd is None :
+			print("%s does not exist or does not contain a bundle.json file" % self.gendir)
+		else :
+			self.update_cmakelists()	
+			self.update_deploy_file()
+			self.update_activator()
+			for comp in bd['components'] :
+				self.update_component_header(comp['name'])
+				self.update_component_source(comp['name'])
+
+class Project(BaseGenerator):
+
+	def __init__(self, gendir, erase, template_dir) :
+		BaseGenerator.__init__(self, gendir, "project", erase, template_dir)
+		#python3 super(Project, self).__init__(gendir, "project")
+
+	def update_cmakelists(self) :
+		options = ["-D", "projectFile=%s" % self.descriptor]
+		self.update_file("CMakeLists.txt", "CMakeLists.txt", options, "#")	
+
+	def update(self) :
+		descriptor = self.read_descriptor()
+		if descriptor is None :
+			print("%s does not exist or does not contain a project.json file" % self.gendir)
+		else :
+			self.update_cmakelists()	
+
+
+class Services(BaseGenerator):
+
+	def __init__(self, gendir, erase, template_dir) :
+		BaseGenerator.__init__(self, gendir, "services", erase, template_dir)
+		#python3 super(Services, self).__init__(gendir, "services")
+
+	def update_cmakelists(self) :
+		options = ["-D", "projectFile=%s" % self.descriptor]
+		self.update_file("CMakeLists.txt", "CMakeLists.txt", options, "#")	
+
+	def update_service_header(self, serviceName) :
+		genfile = "public/include/%s.h" % serviceName
+		options = ["-D", "descriptorFile=%s" % self.descriptor, "-D", "serviceName=%s" % serviceName]
+		self.update_file("service.h", genfile, options)
+
+	def update(self) :
+		descriptor = self.read_descriptor()
+		if descriptor is None :
+			print("%s does not exist or does not contain a services.json file" % self.gendir)
+		else :
+			for serv in descriptor :
+				self.update_service_header(serv['name'])

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt b/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
new file mode 100644
index 0000000..5bc1979
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
@@ -0,0 +1,55 @@
+#{{
+#import json
+#bundle = None 
+#with open(bundleFile) as input :
+#	bundle = json.load(input)
+#}}
+#{{end}}
+
+
+SET(
+	BUNDLE_NAME 
+#{{ 
+#cog.outl("\t\"%s\"" % bundle['name']) 
+#}}
+"mybundle" #do not edit, generated code
+#{{end}}
+)
+
+SET(
+	BUNDLE_SYMBOLICNAME 
+#{{ 
+#cog.outl("\t\"%s\"" % bundle['symbolicName']) 
+#}}
+"org.example.mybundle" #do not edit, generated code
+#{{end}}
+)
+
+SET(BUNDLE_VERSION "0.0.1")
+
+include_directories(
+	"private/include"
+	"public/include"
+)
+
+bundle(
+#{{ 
+#cog.outl("\t%s SOURCES" % bundle['name']) 
+#cog.outl("\t\tprivate/src/bundle_activator")
+#for comp in bundle['components'] :
+#	cog.outl("\t\tprivate/src/%s" % comp['name'])
+#}}
+mybundle SOURCES #do not edit, generated code
+	private/src/bundle_activator #do not edit, generated code
+	private/src/example #do not edit, generated code
+#{{end}}
+)
+
+
+#{{ 
+#cog.outl("SET(BUNDLE_LIB \"%s\")" % bundle['name']) 
+#}}
+SET(BUNDLE_LIB "mybundle") #do not edit, generated code
+#{{end}}
+
+target_link_libraries(${BUNDLE_LIB} ${CELIX_FRAMEWORK_LIBRARY} ${CELIX_UTILS_LIBRARY})

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.json
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.json b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.json
new file mode 100644
index 0000000..558bd72
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.json
@@ -0,0 +1,18 @@
+{
+ 	"name" : "mybundle",
+	"symbolicName": "org.example.mybundle",
+	"components" : [
+		{
+			"name" : "example",
+			"serviceDependencies" : [
+				{ "include" : "log_service/log_service.h" , "name" : "logger", "service_name" : "OSGI_LOGSERVICE_NAME", "type" : "log_service_pt", "cardinality" : "one" },
+				{ "include" : "log_service/log_service.h" , "name" : "loggerOptional", "service_name" : "OSGI_LOGSERVICE_NAME", "type" : "log_service_pt", "cardinality" : "optional" },
+				{ "include" : "log_service/log_service.h" , "name" : "loggerMany", "filter" : "(objectClass=log_service)", "type" : "log_service_pt", "cardinality" : "many" }
+			],
+			"providedServices" : [
+				{ "include" : "shell/command.h" , "name" : "command", "service_name" : "\"commandService\"", "type" : "command_service_pt" },
+				{ "include" : "shell/command.h" , "name" : "command2", "service_name" : "\"commandService\"", "type" : "command_service_pt" }
+			] 
+		}
+	]
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
new file mode 100644
index 0000000..b946961
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
@@ -0,0 +1,471 @@
+//TODO update fields from <service>Type to <service>For<component>Type
+//TODO improve names to camel case (e.g. from _add_logger_for_example to _addLoggerToExample)
+//{{
+//import json
+//bundle = None 
+//with open(bundleFile) as input :
+//	bundle = json.load(input)
+//}}
+//{{end}}
+#include <stdlib.h>
+
+#include <pthread.h>
+
+#include <constants.h>
+#include <bundle_context.h>
+#include <service_tracker.h>
+#include <hash_map.h>
+
+//Includes for the services / components
+//{{
+//for comp in bundle['components'] : 
+//	cog.outl("#include \"%s.h\"" % comp['name'])
+//	for service in comp['serviceDependencies'] :
+//		cog.outl("#include <%s>" % service['include'])
+//	for service in comp['providedServices'] :
+//		cog.outl("#include <%s>" % service['include'])
+//}}
+#include "example.h" //do not edit, generated code
+#include <log_service/log_service.h> //do not edit, generated code
+#include <log_service/log_service.h> //do not edit, generated code
+#include <log_service/log_service.h> //do not edit, generated code
+#include <shell/command.h> //do not edit, generated code
+#include <shell/command.h> //do not edit, generated code
+//{{end}}
+
+
+
+//Private (static) function declarations
+//{{
+//for comp in bundle['components'] :
+//	cog.outl("static bundleActivator_resolveState_for_%s(struct activator *activator);" % comp['name'])
+//	for service in comp['serviceDependencies'] :
+//		cog.outl("static celix_status_t bundleActivator_add_%s_for_%s(void *handle, service_reference_pt ref, void *service);" % (service['name'], comp['name']))
+//		cog.outl("static celix_status_t bundleActivator_remove_%s_for_%s(void *handle, service_reference_pt ref, void *service);" % (service['name'], comp['name']))
+//}}
+static bundleActivator_resolveState_for_example(struct activator *activator); //do not edit, generated code
+static celix_status_t bundleActivator_add_logger_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_remove_logger_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_add_loggerOptional_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_remove_loggerOptional_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_add_loggerMany_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_remove_loggerMany_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+//{{end}}
+static celix_status_t bundleActivator_getFirst(hash_map_pt services, void **result);
+
+typedef enum component_state {
+	COMPONENT_STATE_UNKNOWN = 0,
+	COMPONENT_STATE_CREATED = 1,
+	COMPONENT_STATE_STARTED = 2,
+	COMPONENT_STATE_STOPPED = 3,
+	COMPONENT_STATE_DESTROYED = 4
+} component_state_type;
+
+struct activator {
+	bundle_context_pt context;
+//Fields for components, service structs, service registries and trackers
+//{{
+//cog.outl("//no indent marker")
+//for comp in bundle['components'] :
+//	cog.outl("\t%s_pt %s;" % (comp['name'], comp['name']))
+//	cog.outl("\tpthread_mutex_t %sLock;" % comp['name'])
+//	cog.outl("\tcomponent_state_type %sState;" % comp['name'])
+//	for service in comp['serviceDependencies'] :
+//		cog.outl("\tservice_tracker_customizer_pt %sCustomizer;" % service['name'])
+//		cog.outl("\tservice_tracker_pt %sServiceTracker;" % service['name'])
+//		if service['cardinality'] == "one" or service['cardinality'] == "optional" :
+//			cog.outl("\thash_map_pt %s_services_for_%s;" % (service['name'], comp['name']))
+//			cog.outl("\t%s current_%s_service_for_%s;" % (service['type'], service['name'], comp['name'])) 
+//	for service in comp['providedServices'] :
+//		cog.outl("\t%s %s;" % (service['type'], service['name']))
+//		cog.outl("\tservice_registration_pt %sServiceRegistry;" % service['name'])
+//	cog.outl("")
+//}}
+//no indent marker //do not edit, generated code
+	example_pt example; //do not edit, generated code
+	pthread_mutex_t exampleLock; //do not edit, generated code
+	component_state_type exampleState; //do not edit, generated code
+	service_tracker_customizer_pt loggerCustomizer; //do not edit, generated code
+	service_tracker_pt loggerServiceTracker; //do not edit, generated code
+	hash_map_pt logger_services_for_example; //do not edit, generated code
+	log_service_pt current_logger_service_for_example; //do not edit, generated code
+	service_tracker_customizer_pt loggerOptionalCustomizer; //do not edit, generated code
+	service_tracker_pt loggerOptionalServiceTracker; //do not edit, generated code
+	hash_map_pt loggerOptional_services_for_example; //do not edit, generated code
+	log_service_pt current_loggerOptional_service_for_example; //do not edit, generated code
+	service_tracker_customizer_pt loggerManyCustomizer; //do not edit, generated code
+	service_tracker_pt loggerManyServiceTracker; //do not edit, generated code
+	command_service_pt command; //do not edit, generated code
+	service_registration_pt commandServiceRegistry; //do not edit, generated code
+	command_service_pt command2; //do not edit, generated code
+	service_registration_pt command2ServiceRegistry; //do not edit, generated code
+
+//{{end}}
+};
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = calloc(1, sizeof(struct activator));
+	if (activator != NULL) {
+		(*userData) = activator;
+//{{
+//for comp in bundle['components'] :
+//	cog.outl("//no indent marker")
+//	cog.outl("\t\tactivator->%s = NULL;" % comp['name'])
+//	cog.outl("\t\t%s_create(&activator->%s);" % (comp['name'], comp['name']))
+//	cog.outl("\t\tactivator->%sState = COMPONENT_STATE_CREATED;" % (comp['name']))
+//	cog.outl("\t\tpthread_mutex_init(&activator->%sLock, NULL);" % comp['name'])
+//	for service in comp['serviceDependencies'] :
+//		cog.outl("\t\tactivator->%sServiceTracker = NULL;" % service['name'])
+//		cog.outl("\t\tserviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_%s_for_%s, NULL, bundleActivator_remove_%s_for_%s, &activator->%sCustomizer);" % (service['name'], comp['name'], service['name'], comp['name'], service['name']))
+//		if 'service_name' in service :
+//			cog.outl("\t\tserviceTracker_create(context, (char *) %s, activator->%sCustomizer, &activator->%sServiceTracker);" % (service['service_name'], service['name'], service['name']))
+//		else :
+//			cog.outl("\t\tserviceTracker_createWithService(context, \"%s\", activator->%sCustomizer, &activator->%sServiceTracker);" % (service['filter'], service['name'], service['name']))
+//		if service['cardinality'] == "one" or service['cardinality'] == "optional" :
+//			cog.outl("\t\tactivator->%s_services_for_%s = hashMap_create(NULL, NULL, NULL, NULL);" % (service['name'], comp['name']))
+//			cog.outl("\t\tactivator->current_%s_service_for_%s = NULL;" % (service['name'], comp['name']))
+//	for service in comp['providedServices'] :
+//		cog.outl("\t\tactivator->%s = NULL;" % service['name'])
+//		cog.outl("\t\tactivator->%sServiceRegistry = NULL;" % service['name'])
+//	cog.outl("")
+//}}
+//no indent marker //do not edit, generated code
+		activator->example = NULL; //do not edit, generated code
+		example_create(&activator->example); //do not edit, generated code
+		activator->exampleState = COMPONENT_STATE_CREATED; //do not edit, generated code
+		pthread_mutex_init(&activator->exampleLock, NULL); //do not edit, generated code
+		activator->loggerServiceTracker = NULL; //do not edit, generated code
+		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_logger_for_example, NULL, bundleActivator_remove_logger_for_example, &activator->loggerCustomizer); //do not edit, generated code
+		serviceTracker_create(context, (char *) OSGI_LOGSERVICE_NAME, activator->loggerCustomizer, &activator->loggerServiceTracker); //do not edit, generated code
+		activator->logger_services_for_example = hashMap_create(NULL, NULL, NULL, NULL); //do not edit, generated code
+		activator->current_logger_service_for_example = NULL; //do not edit, generated code
+		activator->loggerOptionalServiceTracker = NULL; //do not edit, generated code
+		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_loggerOptional_for_example, NULL, bundleActivator_remove_loggerOptional_for_example, &activator->loggerOptionalCustomizer); //do not edit, generated code
+		serviceTracker_create(context, (char *) OSGI_LOGSERVICE_NAME, activator->loggerOptionalCustomizer, &activator->loggerOptionalServiceTracker); //do not edit, generated code
+		activator->loggerOptional_services_for_example = hashMap_create(NULL, NULL, NULL, NULL); //do not edit, generated code
+		activator->current_loggerOptional_service_for_example = NULL; //do not edit, generated code
+		activator->loggerManyServiceTracker = NULL; //do not edit, generated code
+		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_loggerMany_for_example, NULL, bundleActivator_remove_loggerMany_for_example, &activator->loggerManyCustomizer); //do not edit, generated code
+		serviceTracker_create(context, (char *) OSGI_LOGSERVICE_NAME, activator->loggerManyCustomizer, &activator->loggerManyServiceTracker); //do not edit, generated code
+		activator->command = NULL; //do not edit, generated code
+		activator->commandServiceRegistry = NULL; //do not edit, generated code
+		activator->command2 = NULL; //do not edit, generated code
+		activator->command2ServiceRegistry = NULL; //do not edit, generated code
+
+//{{end}}
+	} else {
+		status = CELIX_ENOMEM;
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void *userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+
+	//TODO allocate and assign all declared provided services  
+	//e.g:
+	//activator->command = calloc(1, sizeof(*activator->command));
+	//activator->command->command = activator->example;
+	//activator->command->getName = example_getStateCommandName;
+	//activator->command->getUsage = example_getUsage;
+	//activator->command->getShortDescription = example_getStateCommandShortDescription;
+	//activator->command->executeCommand = example_executeStateCommand;
+
+//Start compnent, register service if the service struct is allocated
+//{{
+//cog.outl("//indent marker")
+//for comp in bundle['components'] :
+//	cog.outl("\t%s_start(activator->%s);" % (comp['name'], comp['name']))
+//	for service in comp['serviceDependencies'] :
+//		cog.outl("\tserviceTracker_open(activator->%sServiceTracker);" % service['name'])
+//	for service in comp['providedServices'] :
+//		cog.outl("\tif (activator->%s != NULL) {" % service['name'])
+//		cog.outl("\t\tbundleContext_registerService(context, (char *)%s, activator->%s, NULL, &activator->%sServiceRegistry);" % (service['service_name'], service['name'], service['name']))
+//		cog.outl("\t}")
+//}}
+//indent marker //do not edit, generated code
+	example_start(activator->example); //do not edit, generated code
+	serviceTracker_open(activator->loggerServiceTracker); //do not edit, generated code
+	serviceTracker_open(activator->loggerOptionalServiceTracker); //do not edit, generated code
+	serviceTracker_open(activator->loggerManyServiceTracker); //do not edit, generated code
+	if (activator->command != NULL) { //do not edit, generated code
+		bundleContext_registerService(context, (char *)"commandService", activator->command, NULL, &activator->commandServiceRegistry); //do not edit, generated code
+	} //do not edit, generated code
+	if (activator->command2 != NULL) { //do not edit, generated code
+		bundleContext_registerService(context, (char *)"commandService", activator->command2, NULL, &activator->command2ServiceRegistry); //do not edit, generated code
+	} //do not edit, generated code
+//{{end}}
+
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+
+//Stop compnent, unregister service if the service struct is allocated
+//{{
+//cog.outl("//indent marker")
+//for comp in bundle['components'] :
+//	for service in comp['providedServices'] :
+//		cog.outl("\tif (activator->%s != NULL) {" % service['name'])
+//		cog.outl("\t\tserviceRegistration_unregister(activator->%sServiceRegistry);" % (service['name']))
+//		cog.outl("\t}")
+//	for service in comp['serviceDependencies'] :
+//		cog.outl("\tserviceTracker_close(activator->%sServiceTracker);" % service['name'])
+//	cog.outl("\t%s_stop(activator->%s);" % (comp['name'], comp['name']))
+//}}
+//indent marker //do not edit, generated code
+	if (activator->command != NULL) { //do not edit, generated code
+		serviceRegistration_unregister(activator->commandServiceRegistry); //do not edit, generated code
+	} //do not edit, generated code
+	if (activator->command2 != NULL) { //do not edit, generated code
+		serviceRegistration_unregister(activator->command2ServiceRegistry); //do not edit, generated code
+	} //do not edit, generated code
+	serviceTracker_close(activator->loggerServiceTracker); //do not edit, generated code
+	serviceTracker_close(activator->loggerOptionalServiceTracker); //do not edit, generated code
+	serviceTracker_close(activator->loggerManyServiceTracker); //do not edit, generated code
+	example_stop(activator->example); //do not edit, generated code
+//{{end}}
+
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void *userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+
+//Stop compnent, unregister service if the service struct is allocated
+//{{
+//cog.outl("//indent marker")
+//for comp in bundle['components'] :
+//	cog.outl("\t%s_destroy(activator->%s);" % (comp['name'], comp['name']))
+//	for service in comp['serviceDependencies'] :
+//		cog.outl("\tserviceTracker_destroy(activator->%sServiceTracker);" % service['name'])
+//	for service in comp['providedServices'] :
+//		cog.outl("\tif (activator->%s != NULL) {" % service['name'])
+//		cog.outl("\t\tfree(activator->%s);" % (service['name']))
+//		cog.outl("\t\tactivator->%sState = COMPONENT_STATE_DESTROYED;" % comp['name'])
+//		cog.outl("\t}")
+//}}
+//indent marker //do not edit, generated code
+	example_destroy(activator->example); //do not edit, generated code
+	serviceTracker_destroy(activator->loggerServiceTracker); //do not edit, generated code
+	serviceTracker_destroy(activator->loggerOptionalServiceTracker); //do not edit, generated code
+	serviceTracker_destroy(activator->loggerManyServiceTracker); //do not edit, generated code
+	if (activator->command != NULL) { //do not edit, generated code
+		free(activator->command); //do not edit, generated code
+		activator->exampleState = COMPONENT_STATE_DESTROYED; //do not edit, generated code
+	} //do not edit, generated code
+	if (activator->command2 != NULL) { //do not edit, generated code
+		free(activator->command2); //do not edit, generated code
+		activator->exampleState = COMPONENT_STATE_DESTROYED; //do not edit, generated code
+	} //do not edit, generated code
+//{{end}}
+
+	return status;
+}
+
+
+static celix_status_t bundleActivator_getFirst(hash_map_pt services, void **result) {
+	celix_status_t status = CELIX_SUCCESS;
+	void *highestPrio = NULL;
+	int highestPrioRanking = -1;
+	int highestPrioServiceId = -1;
+	char *rankingStr;
+	int ranking;
+	char *serviceIdStr;
+	int serviceId;
+	
+	hash_map_iterator_pt iter = hashMapIterator_create(services); 
+	while (hashMapIterator_hasNext(iter)) {
+		service_reference_pt ref = hashMapIterator_nextKey(iter);
+		rankingStr = NULL;
+		serviceIdStr = NULL;
+		serviceReference_getProperty(ref, (char *)OSGI_FRAMEWORK_SERVICE_RANKING, &rankingStr);
+		if (rankingStr != NULL) {
+			ranking = atoi(rankingStr);	
+		} else {
+			ranking = 0;
+		}
+		serviceReference_getProperty(ref, (char *)OSGI_FRAMEWORK_SERVICE_RANKING, &serviceIdStr);
+		serviceId  = atoi(serviceIdStr);
+
+		if (ranking > highestPrioRanking) {
+			highestPrio = hashMap_get(services, ref);
+		} else if (ranking == highestPrioRanking && serviceId < highestPrioServiceId) {
+			highestPrio = hashMap_get(services, ref);
+		}
+	}
+
+	if (highestPrio != NULL) {
+		(*result) = highestPrio;
+	}
+	return status;
+}
+
+
+//ResolveNewState
+//{{
+//for comp in bundle['components'] :
+//	cog.outl("static bundleActivator_resolveState_for_%s(struct activator *activator) {" % comp['name'])
+//	cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//
+//	cog.out("\tif (activator->%sState == COMPONENT_STATE_CREATED && " % comp['name'])
+//	conditions = [("activator->current_%s_service_for_%s != NULL" % (serv['name'], comp['name'])) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"] 
+//	cog.out(" && ".join(conditions))
+//	cog.outl(") {")
+//	cog.outl("\t\t%s_start(activator->%s);" % (comp['name'], comp['name']))
+//	cog.outl("\t}")
+//
+//	cog.out("\tif (activator->%sState == COMPONENT_STATE_STARTED && (" % comp['name'])
+//	conditions = [("activator->current_%s_service_for_%s == NULL" % (serv['name'], comp['name'])) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"] 
+//	cog.out(" || ".join(conditions))
+//	cog.outl(")) {")
+//	cog.outl("\t\t%s_stop(activator->%s);" % (comp['name'], comp['name']))
+//	cog.outl("\t}")
+//
+//	cog.outl("\treturn status;")
+//	cog.outl("}")
+//}}
+static bundleActivator_resolveState_for_example(struct activator *activator) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	if (activator->exampleState == COMPONENT_STATE_CREATED && activator->current_logger_service_for_example != NULL) { //do not edit, generated code
+		example_start(activator->example); //do not edit, generated code
+	} //do not edit, generated code
+	if (activator->exampleState == COMPONENT_STATE_STARTED && (activator->current_logger_service_for_example == NULL)) { //do not edit, generated code
+		example_stop(activator->example); //do not edit, generated code
+	} //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+//{{end}}
+
+//Add/Remove functions for the trakkers
+//{{
+//for comp in bundle['components'] :
+//	for service in comp['serviceDependencies'] :
+//			cog.outl("static celix_status_t bundleActivator_add_%s_for_%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'], comp['name']))
+//			cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//			cog.outl("\tstruct activator *activator = handle;")
+//			cog.outl("\t%s %s = service;" % (service['type'], service['name']))
+//			if service['cardinality'] == "many" :
+//				cog.outl("\t%s_add_%s(activator->%s, %s);" % (comp['name'], service['name'], comp['name'], service['name']))
+//			else :
+//				cog.outl("\tpthread_mutex_lock(&activator->%sLock);" % comp['name']);
+//				cog.outl("\t%s highest = NULL;" % service['type']);
+//				cog.outl("\tbundleActivator_getFirst(activator->%s_services_for_%s, (void **)&highest);" % (service['name'], comp['name']))
+//				cog.outl("\tif (highest != activator->current_%s_service_for_%s) {" % (service['name'], comp['name']))
+//				cog.outl("\t\tactivator->current_%s_service_for_%s = highest;" % (service['name'], comp['name']))
+//				cog.outl("\t\t%s_set_%s(activator->%s, highest);" % (comp['name'], service['name'], comp['name'])) 
+//				cog.outl("\t\tbundleActivator_resolveState_for_%s(activator);" % comp['name']);
+//				cog.outl("\t}")
+//				cog.outl("\tpthread_mutex_unlock(&activator->%sLock);" % comp['name']);
+//			cog.outl("\treturn status;")
+//			cog.outl("}")
+//			cog.outl("")
+//			cog.outl("static celix_status_t bundleActivator_remove_%s_for_%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'], comp['name']))
+//			cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//			cog.outl("\tstruct activator *activator = handle;")
+//			cog.outl("\t%s %s = service;" % (service['type'], service['name']))
+//			if service['cardinality'] == "many" :
+//				cog.outl("\t%s_remove_%s(activator->%s, %s);" % (comp['name'], service['name'], comp['name'], service['name']))
+//			else :
+//				cog.outl("\tpthread_mutex_lock(&activator->%sLock);" % comp['name']);
+//				cog.outl("\thashMap_remove(activator->%s_services_for_%s, ref);" % (service['name'], comp['name']))
+//				cog.outl("\tif (activator->current_%s_service_for_%s == service) { " % (service['name'], comp['name']))
+//				cog.outl("\t\t%s highest = NULL;" % service['type']);
+//				cog.outl("\t\tbundleActivator_getFirst(activator->%s_services_for_%s, (void **)&highest);" % (service['name'], comp['name']))
+//				cog.outl("\t\tactivator->current_%s_service_for_%s = highest;" % (service['name'], comp['name']))
+//				cog.outl("\t\tbundleActivator_resolveState_for_%s(activator);" % comp['name']);
+//				cog.outl("\t\t%s_set_%s(activator->%s, highest);" % (comp['name'], service['name'], comp['name'])) 
+//				cog.outl("\t}")
+//				cog.outl("\tpthread_mutex_unlock(&activator->%sLock);" % comp['name']);
+//			cog.outl("\treturn status;")
+//			cog.outl("}")
+//			cog.outl("")
+//}}
+static celix_status_t bundleActivator_add_logger_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	struct activator *activator = handle; //do not edit, generated code
+	log_service_pt logger = service; //do not edit, generated code
+	pthread_mutex_lock(&activator->exampleLock); //do not edit, generated code
+	log_service_pt highest = NULL; //do not edit, generated code
+	bundleActivator_getFirst(activator->logger_services_for_example, (void **)&highest); //do not edit, generated code
+	if (highest != activator->current_logger_service_for_example) { //do not edit, generated code
+		activator->current_logger_service_for_example = highest; //do not edit, generated code
+		example_set_logger(activator->example, highest); //do not edit, generated code
+		bundleActivator_resolveState_for_example(activator); //do not edit, generated code
+	} //do not edit, generated code
+	pthread_mutex_unlock(&activator->exampleLock); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+static celix_status_t bundleActivator_remove_logger_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	struct activator *activator = handle; //do not edit, generated code
+	log_service_pt logger = service; //do not edit, generated code
+	pthread_mutex_lock(&activator->exampleLock); //do not edit, generated code
+	hashMap_remove(activator->logger_services_for_example, ref); //do not edit, generated code
+	if (activator->current_logger_service_for_example == service) {  //do not edit, generated code
+		log_service_pt highest = NULL; //do not edit, generated code
+		bundleActivator_getFirst(activator->logger_services_for_example, (void **)&highest); //do not edit, generated code
+		activator->current_logger_service_for_example = highest; //do not edit, generated code
+		bundleActivator_resolveState_for_example(activator); //do not edit, generated code
+		example_set_logger(activator->example, highest); //do not edit, generated code
+	} //do not edit, generated code
+	pthread_mutex_unlock(&activator->exampleLock); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+static celix_status_t bundleActivator_add_loggerOptional_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	struct activator *activator = handle; //do not edit, generated code
+	log_service_pt loggerOptional = service; //do not edit, generated code
+	pthread_mutex_lock(&activator->exampleLock); //do not edit, generated code
+	log_service_pt highest = NULL; //do not edit, generated code
+	bundleActivator_getFirst(activator->loggerOptional_services_for_example, (void **)&highest); //do not edit, generated code
+	if (highest != activator->current_loggerOptional_service_for_example) { //do not edit, generated code
+		activator->current_loggerOptional_service_for_example = highest; //do not edit, generated code
+		example_set_loggerOptional(activator->example, highest); //do not edit, generated code
+		bundleActivator_resolveState_for_example(activator); //do not edit, generated code
+	} //do not edit, generated code
+	pthread_mutex_unlock(&activator->exampleLock); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+static celix_status_t bundleActivator_remove_loggerOptional_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	struct activator *activator = handle; //do not edit, generated code
+	log_service_pt loggerOptional = service; //do not edit, generated code
+	pthread_mutex_lock(&activator->exampleLock); //do not edit, generated code
+	hashMap_remove(activator->loggerOptional_services_for_example, ref); //do not edit, generated code
+	if (activator->current_loggerOptional_service_for_example == service) {  //do not edit, generated code
+		log_service_pt highest = NULL; //do not edit, generated code
+		bundleActivator_getFirst(activator->loggerOptional_services_for_example, (void **)&highest); //do not edit, generated code
+		activator->current_loggerOptional_service_for_example = highest; //do not edit, generated code
+		bundleActivator_resolveState_for_example(activator); //do not edit, generated code
+		example_set_loggerOptional(activator->example, highest); //do not edit, generated code
+	} //do not edit, generated code
+	pthread_mutex_unlock(&activator->exampleLock); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+static celix_status_t bundleActivator_add_loggerMany_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	struct activator *activator = handle; //do not edit, generated code
+	log_service_pt loggerMany = service; //do not edit, generated code
+	example_add_loggerMany(activator->example, loggerMany); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+static celix_status_t bundleActivator_remove_loggerMany_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	struct activator *activator = handle; //do not edit, generated code
+	log_service_pt loggerMany = service; //do not edit, generated code
+	example_remove_loggerMany(activator->example, loggerMany); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+//{{end}}

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/component.c b/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
new file mode 100644
index 0000000..4be4e9a
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
@@ -0,0 +1,174 @@
+//{{
+//import json
+//bundle = None 
+//component = None
+//with open(bundleFile) as input :
+//	bundle = json.load(input)
+//for comp in bundle['components'] :
+//	if comp['name'] == componentName :
+//		component = comp
+//		break
+//}}
+//{{end}}
+
+
+#include <stdlib.h>
+
+#include <pthread.h>
+
+//Component Struct
+//{{
+//cog.outl("#include \"%s.h\"" % componentName);
+//cog.outl("")
+//cog.outl("struct %s {" % componentName)
+//for service in component['serviceDependencies'] : 
+//	if service['cardinality'] == "many" :
+//		cog.outl("\tarray_list_pt %sServices;" % (service['name']))	
+//		cog.outl("\tpthread_mutex_t mutex_for_%sServices;" % service['name']);
+//	else :
+//		cog.outl("\t%s %s;" % (service['type'], service['name']))	
+//		cog.outl("\tpthread_mutex_t mutex_for_%s;" % service['name']);
+//}}
+#include "example.h" //do not edit, generated code
+
+struct example { //do not edit, generated code
+	log_service_pt logger; //do not edit, generated code
+	pthread_mutex_t mutex_for_logger; //do not edit, generated code
+	log_service_pt loggerOptional; //do not edit, generated code
+	pthread_mutex_t mutex_for_loggerOptional; //do not edit, generated code
+	array_list_pt loggerManyServices; //do not edit, generated code
+	pthread_mutex_t mutex_for_loggerManyServices; //do not edit, generated code
+//{{end}}
+};
+
+//Create function
+//{{
+//cog.outl("celix_status_t %s_create(%s_pt *result) {" % (componentName, componentName))
+//cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//cog.outl("\t%s_pt component = calloc(1, sizeof(*component));" % componentName)
+//cog.outl("\tif (component != NULL) {")
+//for service in component['serviceDependencies'] :
+//	if service['cardinality'] == "many" :
+//		cog.outl("\t\tcomponent->%sServices = NULL;" % service['name'])
+//		cog.outl("\t\tstatus = arrayList_create(&component->%sServices);" % service['name'])
+//		cog.outl("\t\tpthread_mutex_init(&component->mutex_for_%sServices, NULL);" % service['name'])
+//	else :
+//		cog.outl("\t\tcomponent->%s = NULL;" % service['name'])
+//		cog.outl("\t\tpthread_mutex_init(&component->mutex_for_%s, NULL);" % service['name'])
+//}}
+celix_status_t example_create(example_pt *result) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	example_pt component = calloc(1, sizeof(*component)); //do not edit, generated code
+	if (component != NULL) { //do not edit, generated code
+		component->logger = NULL; //do not edit, generated code
+		pthread_mutex_init(&component->mutex_for_logger, NULL); //do not edit, generated code
+		component->loggerOptional = NULL; //do not edit, generated code
+		pthread_mutex_init(&component->mutex_for_loggerOptional, NULL); //do not edit, generated code
+		component->loggerManyServices = NULL; //do not edit, generated code
+		status = arrayList_create(&component->loggerManyServices); //do not edit, generated code
+		pthread_mutex_init(&component->mutex_for_loggerManyServices, NULL); //do not edit, generated code
+//{{end}}
+		(*result) = component;
+	} else {
+		status = CELIX_ENOMEM;
+	}	
+	return status;
+}
+
+
+//Destroy function
+//{{
+//cog.outl("celix_status_t %s_destroy(%s_pt component) {" % (componentName,componentName))
+//}}
+celix_status_t example_destroy(example_pt component) { //do not edit, generated code
+//{{end}}
+	celix_status_t status = CELIX_SUCCESS;
+	if (component != NULL) {
+		free(component);
+	} else {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+	return status;
+}
+
+//Start function
+//{{
+//cog.outl("celix_status_t %s_start(%s_pt component) {" % (componentName,componentName))
+//}}
+celix_status_t example_start(example_pt component) { //do not edit, generated code
+//{{end}}
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+//Stop function
+//{{
+//cog.outl("celix_status_t %s_stop(%s_pt component) {" % (componentName,componentName))
+//}}
+celix_status_t example_stop(example_pt component) { //do not edit, generated code
+//{{end}}
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+//{{
+//for service in component['serviceDependencies'] :
+//	if service['cardinality'] == "many" :
+//		cog.outl("celix_status_t %s_add_%s(%s_pt component, %s %s) {" % (componentName, service['name'], componentName, service['type'], service['name'])) 
+//		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//		cog.outl("\tpthread_mutex_lock(&component->mutex_for_%sServices);" % service['name'])
+//		cog.outl("\tarrayList_add(component->%sServices, %s);" % (service['name'], service['name']))
+//		cog.outl("\tpthread_mutex_unlock(&component->mutex_for_%sServices);" % service['name'])
+//		cog.outl("\treturn status;")
+//		cog.outl("}")
+//		cog.outl("")
+//		cog.outl("celix_status_t %s_remove_%s(%s_pt component, %s %s) {" % (componentName, service['name'], componentName, service['type'], service['name'])) 
+//		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//		cog.outl("\tpthread_mutex_lock(&component->mutex_for_%sServices);" % service['name'])
+//		cog.outl("\tarrayList_removeElement(component->%sServices, %s);" % (service['name'], service['name']))
+//		cog.outl("\tpthread_mutex_unlock(&component->mutex_for_%sServices);" % service['name'])
+//		cog.outl("\treturn status;")
+//		cog.outl("}")
+//	else :
+//		cog.outl("celix_status_t %s_set_%s(%s_pt component, %s %s) {" % (componentName, service['name'], componentName, service['type'], service['name'])) 
+//		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//		cog.outl("\tpthread_mutex_lock(&component->mutex_for_%s);" % service['name'])
+//		cog.outl("\tcomponent->%s == %s;" % (service['name'], service['name']))
+//		cog.outl("\tpthread_mutex_unlock(&component->mutex_for_%s);" % service['name'])
+//		cog.outl("\treturn status;")
+//		cog.outl("}")
+//	cog.outl("")	
+//}}
+celix_status_t example_set_logger(example_pt component, log_service_pt logger) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	pthread_mutex_lock(&component->mutex_for_logger); //do not edit, generated code
+	component->logger == logger; //do not edit, generated code
+	pthread_mutex_unlock(&component->mutex_for_logger); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+celix_status_t example_set_loggerOptional(example_pt component, log_service_pt loggerOptional) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	pthread_mutex_lock(&component->mutex_for_loggerOptional); //do not edit, generated code
+	component->loggerOptional == loggerOptional; //do not edit, generated code
+	pthread_mutex_unlock(&component->mutex_for_loggerOptional); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+celix_status_t example_add_loggerMany(example_pt component, log_service_pt loggerMany) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	pthread_mutex_lock(&component->mutex_for_loggerManyServices); //do not edit, generated code
+	arrayList_add(component->loggerManyServices, loggerMany); //do not edit, generated code
+	pthread_mutex_unlock(&component->mutex_for_loggerManyServices); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+celix_status_t example_remove_loggerMany(example_pt component, log_service_pt loggerMany) { //do not edit, generated code
+	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
+	pthread_mutex_lock(&component->mutex_for_loggerManyServices); //do not edit, generated code
+	arrayList_removeElement(component->loggerManyServices, loggerMany); //do not edit, generated code
+	pthread_mutex_unlock(&component->mutex_for_loggerManyServices); //do not edit, generated code
+	return status; //do not edit, generated code
+} //do not edit, generated code
+
+//{{end}}

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/component.h b/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
new file mode 100644
index 0000000..15fdfba
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
@@ -0,0 +1,69 @@
+//{{
+//import json
+//bundle = None 
+//component = None
+//with open(bundleFile) as input :
+//	bundle = json.load(input)
+//for comp in bundle['components'] :
+//	if comp['name'] == componentName :
+//		component = comp
+//		break
+//
+//cog.outl("#ifndef __%s_H_" % componentName.upper())
+//cog.outl("#define __%s_H_" % componentName.upper())
+//cog.outl("")
+//
+//for service in component['serviceDependencies'] :
+//	cog.outl("#include <%s>" % service['include'])
+//cog.outl("")
+//
+//}}
+#ifndef __EXAMPLE_H_ //do not edit, generated code
+#define __EXAMPLE_H_ //do not edit, generated code
+
+#include <log_service/log_service.h> //do not edit, generated code
+#include <log_service/log_service.h> //do not edit, generated code
+#include <log_service/log_service.h> //do not edit, generated code
+
+//{{end}}
+
+#include <celix_errno.h>
+#include <array_list.h>
+
+//{{
+//cog.outl("typedef struct %s *%s_pt;" % (componentName, componentName))
+//cog.outl("")
+//cog.outl("celix_status_t %s_create(%s_pt *component);" % (componentName, componentName))
+//cog.outl("celix_status_t %s_start(%s_pt component);" % (componentName, componentName))
+//cog.outl("celix_status_t %s_stop(%s_pt component);" % (componentName, componentName))
+//cog.outl("celix_status_t %s_destroy(%s_pt component);" % (componentName, componentName))
+//
+//#TODO add remote of service dependencies
+//}}
+typedef struct example *example_pt; //do not edit, generated code
+
+celix_status_t example_create(example_pt *component); //do not edit, generated code
+celix_status_t example_start(example_pt component); //do not edit, generated code
+celix_status_t example_stop(example_pt component); //do not edit, generated code
+celix_status_t example_destroy(example_pt component); //do not edit, generated code
+//{{end}}
+
+//{{
+//for service in component['serviceDependencies'] :
+//	if service['cardinality'] == "many" :
+//		cog.outl("celix_status_t %s_add_%s(%s_pt component, %s %s);" % (componentName, service['name'], componentName, service['type'], service['name']))
+//		cog.outl("celix_status_t %s_remove_%s(%s_pt component, %s %s);" % (componentName, service['name'], componentName, service['type'], service['name']))
+//	else :
+//		cog.outl("celix_status_t %s_set_%s(%s_pt component, %s %s);" % (componentName, service['name'], componentName, service['type'], service['name']))
+//}}
+celix_status_t example_set_logger(example_pt component, log_service_pt logger); //do not edit, generated code
+celix_status_t example_set_loggerOptional(example_pt component, log_service_pt loggerOptional); //do not edit, generated code
+celix_status_t example_add_loggerMany(example_pt component, log_service_pt loggerMany); //do not edit, generated code
+celix_status_t example_remove_loggerMany(example_pt component, log_service_pt loggerMany); //do not edit, generated code
+//{{end}}
+
+//{{
+//cog.outl("#endif //__%s_H_" % componentName.upper())
+//}}
+#endif //__EXAMPLE_H_ //do not edit, generated code
+//{{end}}

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake b/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake
new file mode 100644
index 0000000..6157f1d
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake
@@ -0,0 +1,18 @@
+#{{
+#import json
+#bundle = None 
+#with open(bundleFile) as input :
+#	bundle = json.load(input)
+#cog.outl("deploy( \"%s\" BUNDLES" % bundle['name'])
+#cog.outl("\t${CELIX_BUNDLES_DIR}/shell.zip")
+#cog.outl("\t${CELIX_BUNDLES_DIR}/shell_tui.zip")
+#cog.outl("\t${CELIX_BUNDLES_DIR}/log_service.zip")
+#cog.outl("\t%s" % bundle['name'])
+#}}
+deploy( "mybundle" BUNDLES #do not edit, generated code
+	${CELIX_BUNDLES_DIR}/shell.zip #do not edit, generated code
+	${CELIX_BUNDLES_DIR}/shell_tui.zip #do not edit, generated code
+	${CELIX_BUNDLES_DIR}/log_service.zip #do not edit, generated code
+	mybundle #do not edit, generated code
+#{{end}}
+)

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt b/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt
new file mode 100644
index 0000000..04fea0b
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt
@@ -0,0 +1,30 @@
+#{{
+#	import json
+#	project = None 
+#	with open(projectFile) as input :
+#		project = json.load(input)
+#}}
+#{{end}}
+
+cmake_minimum_required(VERSION 2.8)
+
+#{{
+#	cog.outl("project(%s C)" % project['name'])
+#}}
+project(myproject C) #do not edit, generated code
+#{{end}}
+
+#{{ 
+#	cog.outl("set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} \"%s/share/celix/cmake/modules\")" % project['celix_install_dir'])
+#}}
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/local/share/celix/cmake/modules") #do not edit, generated code
+#{{end}}
+
+find_package(CELIX REQUIRED)
+include_directories(${CELIX_INCLUDE_DIRS})
+
+#TODO add sub directory for every bundle
+#e.g. 
+#add_subdirectory(mybundle)
+
+deploy_targets()

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/project/project.json
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/project/project.json b/celix-bootstrap/celix/bootstrap/templates/project/project.json
new file mode 100644
index 0000000..db48217
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/project/project.json
@@ -0,0 +1,4 @@
+{
+ 	"name" : "myproject",
+	"celix_install_dir": "/usr/local"
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/services/service.h
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/services/service.h b/celix-bootstrap/celix/bootstrap/templates/services/service.h
new file mode 100644
index 0000000..9a8aae9
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/services/service.h
@@ -0,0 +1,48 @@
+//{{
+//import json
+//services = None
+//service = None
+//with open(descriptorFile) as input :
+//	services = json.load(input)
+//for serv in services :
+//	if serv['name'] == serviceName :
+//		service = serv
+//		break
+//
+//cog.outl("#ifndef __%s_H_" % serviceName.upper())
+//cog.outl("#define __%s_H_" % serviceName.upper())
+//cog.outl("")
+//
+//}}
+#ifndef __EXAMPLE_H_ //do not edit, generated code
+#define __EXAMPLE_H_ //do not edit, generated code
+//{{end}}
+
+//TODO add needed includes
+
+//{{
+//cog.outl("#define %s_SERVICE_NAME \"%s_service\"" % (serviceName.upper(), serviceName))
+//cog.outl("")
+//cog.outl("typedef struct %s_service *%s_service_pt;" % (serviceName, serviceName))
+//cog.outl("")
+//cog.outl("struct %s_service {" % serviceName)
+//cog.outl("\tvoid *handle;")
+//}}
+#define BENCHMARK_SERVICE_NAME "benchmark_service"
+typedef struct benchmark_service *benchmark_service_pt;
+
+struct benchmark_service {
+	benchmark_handler_pt handler;
+//{{end}}}
+
+	//TODO add service methods
+
+//{{
+//cog.outl("};")
+//cog.outl("")
+//cog.outl("")
+//cog.outl("#endif /* __%s_H_ */" % serviceName)
+//}}
+};
+#endif /* BENCHMARK_SERVICE_H_ */
+//{{end}}

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/celix/bootstrap/templates/services/services.json
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/services/services.json b/celix-bootstrap/celix/bootstrap/templates/services/services.json
new file mode 100644
index 0000000..f6efc03
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/services/services.json
@@ -0,0 +1,4 @@
+[
+	{ "name" : "example1" },
+	{ "name" : "example2" }
+]

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/scripts/celix-bootstrap
----------------------------------------------------------------------
diff --git a/celix-bootstrap/scripts/celix-bootstrap b/celix-bootstrap/scripts/celix-bootstrap
new file mode 100755
index 0000000..22d43ec
--- /dev/null
+++ b/celix-bootstrap/scripts/celix-bootstrap
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+import celix.bootstrap.argument_parser
+
+celix.bootstrap.argument_parser.main()

http://git-wip-us.apache.org/repos/asf/celix/blob/5d703d3a/celix-bootstrap/setup.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/setup.py b/celix-bootstrap/setup.py
new file mode 100644
index 0000000..f8245d2
--- /dev/null
+++ b/celix-bootstrap/setup.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+""" Setup.py for Cog
+    http://nedbatchelder.com/code/cog
+
+    Copyright 2004-2015, Ned Batchelder.
+"""
+
+from distutils.core import setup
+
+setup(
+    name = 'celix-bootstrap',    
+    version = '0.1.0',
+    url = '',
+    author = '',
+    author_email = '',
+    description =
+        'celix-bootstrap: A code generator / project generator for Apache Celix.',
+
+    license = 'Apache License, Version 2.0',
+
+    packages = [
+        'celix',
+	'celix/bootstrap'
+        ],
+
+    scripts = [
+        'scripts/celix-bootstrap',
+        ],
+
+    package_data={'celix' : ['bootstrap/templates/**/*']},
+)


[3/9] celix git commit: CELIX-236: change name format to camelCase

Posted by bp...@apache.org.
CELIX-236: change name format to camelCase


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/6a56692b
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/6a56692b
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/6a56692b

Branch: refs/heads/develop
Commit: 6a56692b7870881a9ed490ab7340f39fbb57e032
Parents: 4feeabc
Author: Bjoern Petri <bp...@apache.org>
Authored: Thu Jan 14 10:45:00 2016 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Thu Jan 14 10:45:00 2016 +0100

----------------------------------------------------------------------
 .../celix/bootstrap/argument_parser.py          |   2 +-
 .../bootstrap/templates/bundle/CMakeLists.txt   |  14 +-
 .../templates/bundle/bundle_activator.c         | 158 +++++++++----------
 .../bootstrap/templates/bundle/component.c      |  66 ++++----
 .../bootstrap/templates/bundle/component.h      |  14 +-
 5 files changed, 133 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/6a56692b/celix-bootstrap/celix/bootstrap/argument_parser.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/argument_parser.py b/celix-bootstrap/celix/bootstrap/argument_parser.py
index 922d98c..ad477f9 100644
--- a/celix-bootstrap/celix/bootstrap/argument_parser.py
+++ b/celix-bootstrap/celix/bootstrap/argument_parser.py
@@ -12,7 +12,7 @@ def main() :
 	UPDATE_COMMAND = "update"
 
 	#positional
-	parser.add_argument("command", help="The command to executee", choices=(CREATE_PROJECT_COMMAND, CREATE_BUNDLE_COMMAND, CREATE_SERVICE_COMMAND, UPDATE_COMMAND))
+	parser.add_argument("command", help="The command to execute", choices=(CREATE_PROJECT_COMMAND, CREATE_BUNDLE_COMMAND, UPDATE_COMMAND))
 	parser.add_argument("directory", help="The directory to work on")
 
 	#optional

http://git-wip-us.apache.org/repos/asf/celix/blob/6a56692b/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt b/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
index 98c45f5..a6295b2 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
@@ -1,11 +1,15 @@
 #{{
-#import yaml
+#import os, yaml
 #bundle = None 
 #with open(bundleFile) as input :
 #	bundle = yaml.load(input)
 #
 #if not 'components' in bundle or bundle['components'] is None:
 # 	bundle['components'] = []
+#else:
+#	for comp in bundle['components'] : 
+#		if not 'serviceDependencies' in comp or comp['serviceDependencies'] is None:
+#			comp['serviceDependencies'] = []
 #
 #}}
 #{{end}}
@@ -34,6 +38,14 @@ SET(BUNDLE_VERSION "0.0.1")
 include_directories(
 	"private/include"
 	"public/include"
+#{{ 
+#for comp in bundle['components'] : 
+#	for service in comp['serviceDependencies']:
+#			cog.outl("\t\"%s\"" % os.path.dirname(service['include'])) 
+#}}
+"org.example.mybundle" #do not edit, generated code
+#{{end}}
+
 )
 
 bundle(

http://git-wip-us.apache.org/repos/asf/celix/blob/6a56692b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
index a62b1f0..d28b73c 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
@@ -1,7 +1,7 @@
 //TODO update fields from <service>Type to <service>For<component>Type
-//TODO improve names to camel case (e.g. from _add_logger_for_example to _addLoggerToExample)
+
 //{{
-//import yaml
+//import os, yaml
 //bundle = None 
 //with open(bundleFile) as input :
 //	bundle = yaml.load(input)
@@ -32,7 +32,7 @@
 //	for service in comp['providedServices'] :
 //		cog.outl("#include <%s>" % service['include'])
 //	for service in comp['serviceDependencies'] :
-//		cog.outl("#include <%s>" % service['include'])
+//		cog.outl("#include <%s>" % os.path.split(service['include'])[1])
 //}}
 //{{end}}
 
@@ -41,18 +41,18 @@
 //Private (static) function declarations
 //{{
 //for comp in bundle['components'] :
-//	cog.outl("static bundleActivator_resolveState_for_%s(struct activator *activator);" % comp['name'])
+//	cog.outl("static bundleActivator_resolveStateFor%s(struct activator *activator);" % comp['name'].title())
 //	for service in comp['serviceDependencies'] :
-//		cog.outl("static celix_status_t bundleActivator_add_%s_for_%s(void *handle, service_reference_pt ref, void *service);" % (service['name'], comp['name']))
-//		cog.outl("static celix_status_t bundleActivator_remove_%s_for_%s(void *handle, service_reference_pt ref, void *service);" % (service['name'], comp['name']))
+//		cog.outl("static celix_status_t bundleActivator_add%sFor%s(void *handle, service_reference_pt ref, void *service);" % (service['name'].title(), comp['name'].title()))
+//		cog.outl("static celix_status_t bundleActivator_remove%sFor%s(void *handle, service_reference_pt ref, void *service);" % (service['name'].title(), comp['name'].title()))
 //}}
-static bundleActivator_resolveState_for_example(struct activator *activator); //do not edit, generated code
-static celix_status_t bundleActivator_add_logger_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
-static celix_status_t bundleActivator_remove_logger_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
-static celix_status_t bundleActivator_add_loggerOptional_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
-static celix_status_t bundleActivator_remove_loggerOptional_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
-static celix_status_t bundleActivator_add_loggerMany_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
-static celix_status_t bundleActivator_remove_loggerMany_for_example(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static bundleActivator_resolveStateForExample(struct activator *activator); //do not edit, generated code
+static celix_status_t bundleActivator_addLoggerForExample(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_removeLoggerForExample(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_addLoggerOptionalForExample(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_removeLoggerOptionalForExample(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_addLoggerManyForExample(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
+static celix_status_t bundleActivator_removeLoggerManyForExample(void *handle, service_reference_pt ref, void *service); //do not edit, generated code
 //{{end}}
 static celix_status_t bundleActivator_getFirst(hash_map_pt services, void **result);
 
@@ -77,8 +77,8 @@ struct activator {
 //		cog.outl("\tservice_tracker_customizer_pt %sCustomizer;" % service['name'])
 //		cog.outl("\tservice_tracker_pt %sServiceTracker;" % service['name'])
 //		if service['cardinality'] == "one" or service['cardinality'] == "optional" :
-//			cog.outl("\thash_map_pt %s_services_for_%s;" % (service['name'], comp['name']))
-//			cog.outl("\t%s current_%s_service_for_%s;" % (service['type'], service['name'], comp['name'])) 
+//			cog.outl("\thash_map_pt %sServicesFor%s;" % (service['name'], comp['name'].title()))
+//			cog.outl("\t%s current%sServiceFor%s;" % (service['type'], service['name'].title(), comp['name'].title())) 
 //	for service in comp['providedServices'] :
 //		cog.outl("\t%s %s;" % (service['type'], service['name']))
 //		cog.outl("\tservice_registration_pt %sServiceRegistry;" % service['name'])
@@ -90,12 +90,12 @@ struct activator {
 	component_state_type exampleState; //do not edit, generated code
 	service_tracker_customizer_pt loggerCustomizer; //do not edit, generated code
 	service_tracker_pt loggerServiceTracker; //do not edit, generated code
-	hash_map_pt logger_services_for_example; //do not edit, generated code
-	log_service_pt current_logger_service_for_example; //do not edit, generated code
+	hash_map_pt loggerServicesForExample; //do not edit, generated code
+	log_service_pt currentLoggerServiceForExample; //do not edit, generated code
 	service_tracker_customizer_pt loggerOptionalCustomizer; //do not edit, generated code
 	service_tracker_pt loggerOptionalServiceTracker; //do not edit, generated code
-	hash_map_pt loggerOptional_services_for_example; //do not edit, generated code
-	log_service_pt current_loggerOptional_service_for_example; //do not edit, generated code
+	hash_map_pt loggerOptionalServicesForExample; //do not edit, generated code
+	log_service_pt currentLoggerOptionalServiceForExample; //do not edit, generated code
 	service_tracker_customizer_pt loggerManyCustomizer; //do not edit, generated code
 	service_tracker_pt loggerManyServiceTracker; //do not edit, generated code
 	command_service_pt command; //do not edit, generated code
@@ -121,14 +121,14 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 //
 //	for service in comp['serviceDependencies'] :
 //		cog.outl("\t\tactivator->%sServiceTracker = NULL;" % service['name'])
-//		cog.outl("\t\tserviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_%s_for_%s, NULL, bundleActivator_remove_%s_for_%s, &activator->%sCustomizer);" % (service['name'], comp['name'], service['name'], comp['name'], service['name']))
+//		cog.outl("\t\tserviceTrackerCustomizer_create(activator, NULL, bundleActivator_add%sFor%s, NULL, bundleActivator_remove%sFor%s, &activator->%sCustomizer);" % (service['name'].title(), comp['name'].title(), service['name'].title(), comp['name'].title(), service['name']))
 //		if 'service_name' in service :
 //			cog.outl("\t\tserviceTracker_create(context, (char *) %s, activator->%sCustomizer, &activator->%sServiceTracker);" % (service['service_name'], service['name'], service['name']))
 //		else :
 //			cog.outl("\t\tserviceTracker_createWithService(context, \"%s\", activator->%sCustomizer, &activator->%sServiceTracker);" % (service['filter'], service['name'], service['name']))
 //		if service['cardinality'] == "one" or service['cardinality'] == "optional" :
-//			cog.outl("\t\tactivator->%s_services_for_%s = hashMap_create(NULL, NULL, NULL, NULL);" % (service['name'], comp['name']))
-//			cog.outl("\t\tactivator->current_%s_service_for_%s = NULL;" % (service['name'], comp['name']))
+//			cog.outl("\t\tactivator->%sServicesFor%s = hashMap_create(NULL, NULL, NULL, NULL);" % (service['name'], comp['name'].title()))
+//			cog.outl("\t\tactivator->current%sServiceFor%s = NULL;" % (service['name'].title(), comp['name'].title()))
 //
 //	for service in comp['providedServices'] :
 //		cog.outl("\t\tactivator->%s = NULL;" % service['name'])
@@ -141,17 +141,17 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 		activator->exampleState = COMPONENT_STATE_CREATED; //do not edit, generated code
 		pthread_mutex_init(&activator->exampleLock, NULL); //do not edit, generated code
 		activator->loggerServiceTracker = NULL; //do not edit, generated code
-		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_logger_for_example, NULL, bundleActivator_remove_logger_for_example, &activator->loggerCustomizer); //do not edit, generated code
+		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_addLoggerForExample, NULL, bundleActivator_removeLoggerForExample, &activator->loggerCustomizer); //do not edit, generated code
 		serviceTracker_create(context, (char *) OSGI_LOGSERVICE_NAME, activator->loggerCustomizer, &activator->loggerServiceTracker); //do not edit, generated code
-		activator->logger_services_for_example = hashMap_create(NULL, NULL, NULL, NULL); //do not edit, generated code
-		activator->current_logger_service_for_example = NULL; //do not edit, generated code
+		activator->loggerServicesForExample = hashMap_create(NULL, NULL, NULL, NULL); //do not edit, generated code
+		activator->currentLoggerServiceForExample = NULL; //do not edit, generated code
 		activator->loggerOptionalServiceTracker = NULL; //do not edit, generated code
-		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_loggerOptional_for_example, NULL, bundleActivator_remove_loggerOptional_for_example, &activator->loggerOptionalCustomizer); //do not edit, generated code
+		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_addLoggerOptionalForExample, NULL, bundleActivator_removeLoggerOptionalForExample, &activator->loggerOptionalCustomizer); //do not edit, generated code
 		serviceTracker_create(context, (char *) OSGI_LOGSERVICE_NAME, activator->loggerOptionalCustomizer, &activator->loggerOptionalServiceTracker); //do not edit, generated code
-		activator->loggerOptional_services_for_example = hashMap_create(NULL, NULL, NULL, NULL); //do not edit, generated code
-		activator->current_loggerOptional_service_for_example = NULL; //do not edit, generated code
+		activator->loggerOptionalServicesForExample = hashMap_create(NULL, NULL, NULL, NULL); //do not edit, generated code
+		activator->currentLoggerOptionalServiceForExample = NULL; //do not edit, generated code
 		activator->loggerManyServiceTracker = NULL; //do not edit, generated code
-		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_loggerMany_for_example, NULL, bundleActivator_remove_loggerMany_for_example, &activator->loggerManyCustomizer); //do not edit, generated code
+		serviceTrackerCustomizer_create(activator, NULL, bundleActivator_addLoggerManyForExample, NULL, bundleActivator_removeLoggerManyForExample, &activator->loggerManyCustomizer); //do not edit, generated code
 		serviceTracker_create(context, (char *) OSGI_LOGSERVICE_NAME, activator->loggerManyCustomizer, &activator->loggerManyServiceTracker); //do not edit, generated code
 		activator->command = NULL; //do not edit, generated code
 		activator->commandServiceRegistry = NULL; //do not edit, generated code
@@ -316,11 +316,11 @@ static celix_status_t bundleActivator_getFirst(hash_map_pt services, void **resu
 //ResolveNewState
 //{{
 //for comp in bundle['components'] :
-//	cog.outl("static bundleActivator_resolveState_for_%s(struct activator *activator) {" % comp['name'])
+//	cog.outl("static bundleActivator_resolveStateFor%s(struct activator *activator) {" % comp['name'].title())
 //	cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
 //
 //	cog.out("\tif (activator->%sState == COMPONENT_STATE_CREATED " % comp['name'])
-//	conditions = [("activator->current_%s_service_for_%s != NULL" % (serv['name'], comp['name'])) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"] 
+//	conditions = [("activator->current%sServiceFor%s != NULL" % (serv['name'].title(), comp['name'].title())) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"] 
 //	if len(conditions) > 0: 
 //		cog.out(" && ")
 //		cog.out(" && ".join(conditions))
@@ -329,7 +329,7 @@ static celix_status_t bundleActivator_getFirst(hash_map_pt services, void **resu
 //	cog.outl("\t}")
 //
 //	cog.out("\tif (activator->%sState == COMPONENT_STATE_STARTED " % comp['name'])
-//	conditions = [("activator->current_%s_service_for_%s == NULL" % (serv['name'], comp['name'])) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"]
+//	conditions = [("activator->current%sServiceFor%s == NULL" % (serv['name'].title(), comp['name'].title())) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"]
 //	if len(conditions) > 0:
 //		cog.out(" && (");
 //		cog.out(" || ".join(conditions))
@@ -341,42 +341,42 @@ static celix_status_t bundleActivator_getFirst(hash_map_pt services, void **resu
 //	cog.outl("\treturn status;")
 //	cog.outl("}")
 //}}
-static bundleActivator_resolveState_for_example(struct activator *activator) { //do not edit, generated code
+static bundleActivator_resolveStateForExample(struct activator *activator) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
-	if (activator->exampleState == COMPONENT_STATE_CREATED && activator->current_logger_service_for_example != NULL) { //do not edit, generated code
+	if (activator->exampleState == COMPONENT_STATE_CREATED && activator->currentLoggerServiceForExample != NULL) { //do not edit, generated code
 		example_start(activator->example); //do not edit, generated code
 	} //do not edit, generated code
-	if (activator->exampleState == COMPONENT_STATE_STARTED && (activator->current_logger_service_for_example == NULL)) { //do not edit, generated code
+	if (activator->exampleState == COMPONENT_STATE_STARTED && (activator->currentLoggerServiceForExample == NULL)) { //do not edit, generated code
 		example_stop(activator->example); //do not edit, generated code
 	} //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 //{{end}}
 
-//Add/Remove functions for the trakkers
+//Add/Remove functions for the trackers
 //{{
 //for comp in bundle['components'] :
 //	for service in comp['serviceDependencies'] :
-//		cog.outl("static celix_status_t bundleActivator_add_%s_for_%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'], comp['name']))
+//		cog.outl("static celix_status_t bundleActivator_add%sFor%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'].title(), comp['name'].title()))
 //		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
 //		cog.outl("\tstruct activator *activator = handle;")
 //		cog.outl("\t%s %s = service;" % (service['type'], service['name']))
 //		if service['cardinality'] == "many" :
-//			cog.outl("\t%s_add_%s(activator->%s, %s);" % (comp['name'], service['name'], comp['name'], service['name']))
+//			cog.outl("\t%s_add%s(activator->%s, %s);" % (comp['name'], service['name'].title(), comp['name'], service['name']))
 //		else :
 //			cog.outl("\tpthread_mutex_lock(&activator->%sLock);" % comp['name']);
 //			cog.outl("\t%s highest = NULL;" % service['type']);
-//			cog.outl("\tbundleActivator_getFirst(activator->%s_services_for_%s, (void **)&highest);" % (service['name'], comp['name']))
-//			cog.outl("\tif (highest != activator->current_%s_service_for_%s) {" % (service['name'], comp['name']))
-//			cog.outl("\t\tactivator->current_%s_service_for_%s = highest;" % (service['name'], comp['name']))
-//			cog.outl("\t\t%s_set_%s(activator->%s, highest);" % (comp['name'], service['name'], comp['name'])) 
-//			cog.outl("\t\tbundleActivator_resolveState_for_%s(activator);" % comp['name']);
+//			cog.outl("\tbundleActivator_getFirst(activator->%sServicesFor%s, (void **)&highest);" % (service['name'], comp['name'].title()))
+//			cog.outl("\tif (highest != activator->current%sServiceFor%s) {" % (service['name'].title(), comp['name'].title()))
+//			cog.outl("\t\tactivator->current%sServiceFor%s = highest;" % (service['name'].title(), comp['name'].title()))
+//			cog.outl("\t\t%s_set%s(activator->%s, highest);" % (comp['name'], service['name'].title(), comp['name'])) 
+//			cog.outl("\t\tbundleActivator_resolveStateFor%s(activator);" % comp['name'].title());
 //			cog.outl("\t}")
 //			cog.outl("\tpthread_mutex_unlock(&activator->%sLock);" % comp['name']);
 //		cog.outl("\treturn status;")
 //		cog.outl("}")
 //		cog.outl("")
-//		cog.outl("static celix_status_t bundleActivator_remove_%s_for_%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'], comp['name']))
+//		cog.outl("static celix_status_t bundleActivator_remove%sFor%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'].title(), comp['name'].title()))
 //		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
 //		cog.outl("\tstruct activator *activator = handle;")
 //		cog.outl("\t%s %s = service;" % (service['type'], service['name']))
@@ -385,94 +385,94 @@ static bundleActivator_resolveState_for_example(struct activator *activator) { /
 //			cog.outl("\t%s_remove_%s(activator->%s, %s);" % (comp['name'], service['name'], comp['name'], service['name']))
 //		else :
 //			cog.outl("\tpthread_mutex_lock(&activator->%sLock);" % comp['name']);
-//			cog.outl("\thashMap_remove(activator->%s_services_for_%s, ref);" % (service['name'], comp['name']))
-//			cog.outl("\tif (activator->current_%s_service_for_%s == service) { " % (service['name'], comp['name']))
+//			cog.outl("\thashMap_remove(activator->%sServicesFor%s, ref);" % (service['name'], comp['name'].title()))
+//			cog.outl("\tif (activator->current%sServiceFor%s == service) { " % (service['name'].title(), comp['name'].title()))
 //			cog.outl("\t\t%s highest = NULL;" % service['type']);
-//		cog.outl("\t\tbundleActivator_getFirst(activator->%s_services_for_%s, (void **)&highest);" % (service['name'], comp['name']))
-//		cog.outl("\t\tactivator->current_%s_service_for_%s = highest;" % (service['name'], comp['name']))
-//		cog.outl("\t\tbundleActivator_resolveState_for_%s(activator);" % comp['name']);
-//		cog.outl("\t\t%s_set_%s(activator->%s, highest);" % (comp['name'], service['name'], comp['name'])) 
+//		cog.outl("\t\tbundleActivator_getFirst(activator->%sServicesFor%s, (void **)&highest);" % (service['name'], comp['name'].title()))
+//		cog.outl("\t\tactivator->current%sServiceFor%s = highest;" % (service['name'].title(), comp['name'].title()))
+//		cog.outl("\t\tbundleActivator_resolveStateFor%s(activator);" % comp['name'].title());
+//		cog.outl("\t\t%s_set%s(activator->%s, highest);" % (comp['name'], service['name'].title(), comp['name'])) 
 //		cog.outl("\t}")
 //		cog.outl("\tpthread_mutex_unlock(&activator->%sLock);" % comp['name']);
 //		cog.outl("\treturn status;")
 //		cog.outl("}")
 //		cog.outl("")
 //}}
-static celix_status_t bundleActivator_add_logger_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+static celix_status_t bundleActivator_addLoggerForExample(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
 	struct activator *activator = handle; //do not edit, generated code
 	log_service_pt logger = service; //do not edit, generated code
 	pthread_mutex_lock(&activator->exampleLock); //do not edit, generated code
 	log_service_pt highest = NULL; //do not edit, generated code
-	bundleActivator_getFirst(activator->logger_services_for_example, (void **)&highest); //do not edit, generated code
-	if (highest != activator->current_logger_service_for_example) { //do not edit, generated code
-		activator->current_logger_service_for_example = highest; //do not edit, generated code
-		example_set_logger(activator->example, highest); //do not edit, generated code
-		bundleActivator_resolveState_for_example(activator); //do not edit, generated code
+	bundleActivator_getFirst(activator->loggerServicesForExample, (void **)&highest); //do not edit, generated code
+	if (highest != activator->currentLoggerServiceForExample) { //do not edit, generated code
+		activator->currentLoggerServiceForExample = highest; //do not edit, generated code
+		example_setLogger(activator->example, highest); //do not edit, generated code
+		bundleActivator_resolveStateForExample(activator); //do not edit, generated code
 	} //do not edit, generated code
 	pthread_mutex_unlock(&activator->exampleLock); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 
-static celix_status_t bundleActivator_remove_logger_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+static celix_status_t bundleActivator_removeLoggerForExample(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
 	struct activator *activator = handle; //do not edit, generated code
 	log_service_pt logger = service; //do not edit, generated code
 	pthread_mutex_lock(&activator->exampleLock); //do not edit, generated code
-	hashMap_remove(activator->logger_services_for_example, ref); //do not edit, generated code
-	if (activator->current_logger_service_for_example == service) {  //do not edit, generated code
+	hashMap_remove(activator->loggerServicesForExample, ref); //do not edit, generated code
+	if (activator->currentLoggerServiceForExample == service) {  //do not edit, generated code
 		log_service_pt highest = NULL; //do not edit, generated code
-		bundleActivator_getFirst(activator->logger_services_for_example, (void **)&highest); //do not edit, generated code
-		activator->current_logger_service_for_example = highest; //do not edit, generated code
-		bundleActivator_resolveState_for_example(activator); //do not edit, generated code
-		example_set_logger(activator->example, highest); //do not edit, generated code
+		bundleActivator_getFirst(activator->loggerServicesForExample, (void **)&highest); //do not edit, generated code
+		activator->currentLoggerServiceForExample = highest; //do not edit, generated code
+		bundleActivator_resolveStateForExample(activator); //do not edit, generated code
+		example_setLogger(activator->example, highest); //do not edit, generated code
 	} //do not edit, generated code
 	pthread_mutex_unlock(&activator->exampleLock); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 
-static celix_status_t bundleActivator_add_loggerOptional_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+static celix_status_t bundleActivator_addLoggerOptionalForExample(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
 	struct activator *activator = handle; //do not edit, generated code
 	log_service_pt loggerOptional = service; //do not edit, generated code
 	pthread_mutex_lock(&activator->exampleLock); //do not edit, generated code
 	log_service_pt highest = NULL; //do not edit, generated code
-	bundleActivator_getFirst(activator->loggerOptional_services_for_example, (void **)&highest); //do not edit, generated code
-	if (highest != activator->current_loggerOptional_service_for_example) { //do not edit, generated code
-		activator->current_loggerOptional_service_for_example = highest; //do not edit, generated code
-		example_set_loggerOptional(activator->example, highest); //do not edit, generated code
-		bundleActivator_resolveState_for_example(activator); //do not edit, generated code
+	bundleActivator_getFirst(activator->loggerOptionalServicesForExample, (void **)&highest); //do not edit, generated code
+	if (highest != activator->currentLoggerOptionalServiceForExample) { //do not edit, generated code
+		activator->currentLoggerOptionalServiceForExample = highest; //do not edit, generated code
+		example_setLoggerOptional(activator->example, highest); //do not edit, generated code
+		bundleActivator_resolveStateForExample(activator); //do not edit, generated code
 	} //do not edit, generated code
 	pthread_mutex_unlock(&activator->exampleLock); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 
-static celix_status_t bundleActivator_remove_loggerOptional_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+static celix_status_t bundleActivator_removeLoggerOptionalForExample(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
 	struct activator *activator = handle; //do not edit, generated code
 	log_service_pt loggerOptional = service; //do not edit, generated code
 	pthread_mutex_lock(&activator->exampleLock); //do not edit, generated code
-	hashMap_remove(activator->loggerOptional_services_for_example, ref); //do not edit, generated code
-	if (activator->current_loggerOptional_service_for_example == service) {  //do not edit, generated code
+	hashMap_remove(activator->loggerOptionalServicesForExample, ref); //do not edit, generated code
+	if (activator->currentLoggerOptionalServiceForExample == service) {  //do not edit, generated code
 		log_service_pt highest = NULL; //do not edit, generated code
-		bundleActivator_getFirst(activator->loggerOptional_services_for_example, (void **)&highest); //do not edit, generated code
-		activator->current_loggerOptional_service_for_example = highest; //do not edit, generated code
-		bundleActivator_resolveState_for_example(activator); //do not edit, generated code
-		example_set_loggerOptional(activator->example, highest); //do not edit, generated code
+		bundleActivator_getFirst(activator->loggerOptionalServicesForExample, (void **) &highest); //do not edit, generated code
+		activator->currentLoggerOptionalServiceForExample = highest; //do not edit, generated code
+		bundleActivator_resolveStateForExample(activator); //do not edit, generated code
+		example_setLoggerOptional(activator->example, highest); //do not edit, generated code
 	} //do not edit, generated code
 	pthread_mutex_unlock(&activator->exampleLock); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 
-static celix_status_t bundleActivator_add_loggerMany_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+static celix_status_t bundleActivator_addLoggerManyForExample(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
 	struct activator *activator = handle; //do not edit, generated code
 	log_service_pt loggerMany = service; //do not edit, generated code
-	example_add_loggerMany(activator->example, loggerMany); //do not edit, generated code
+	example_addLoggerMany(activator->example, loggerMany); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 
-static celix_status_t bundleActivator_remove_loggerMany_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
+static celix_status_t bundleActivator_removeLoggerManyForExample(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
 	struct activator *activator = handle; //do not edit, generated code
 	log_service_pt loggerMany = service; //do not edit, generated code

http://git-wip-us.apache.org/repos/asf/celix/blob/6a56692b/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/component.c b/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
index 68b0a17..78ccdd2 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
@@ -34,20 +34,20 @@
 //for service in component['serviceDependencies'] : 
 //	if service['cardinality'] == "many" :
 //		cog.outl("\tarray_list_pt %sServices;" % (service['name']))	
-//		cog.outl("\tpthread_mutex_t mutex_for_%sServices;" % service['name']);
+//		cog.outl("\tpthread_mutex_t mutexFor%sServices;" % service['name'].title());
 //	else :
 //		cog.outl("\t%s %s;" % (service['type'], service['name']))	
-//		cog.outl("\tpthread_mutex_t mutex_for_%s;" % service['name']);
+//		cog.outl("\tpthread_mutex_t mutexFor%s;" % service['name'].title());
 //}}
 #include "example.h" //do not edit, generated code
 
 struct example { //do not edit, generated code
 	log_service_pt logger; //do not edit, generated code
-	pthread_mutex_t mutex_for_logger; //do not edit, generated code
+	pthread_mutex_t mutexForLogger; //do not edit, generated code
 	log_service_pt loggerOptional; //do not edit, generated code
-	pthread_mutex_t mutex_for_loggerOptional; //do not edit, generated code
+	pthread_mutex_t mutexForLoggerOptional; //do not edit, generated code
 	array_list_pt loggerManyServices; //do not edit, generated code
-	pthread_mutex_t mutex_for_loggerManyServices; //do not edit, generated code
+	pthread_mutex_t mutexForLoggerManyServices; //do not edit, generated code
 //{{end}}
 };
 
@@ -62,22 +62,22 @@ struct example { //do not edit, generated code
 //	if service['cardinality'] == "many" :
 //		cog.outl("\t\tcomponent->%sServices = NULL;" % service['name'])
 //		cog.outl("\t\tstatus = arrayList_create(&component->%sServices);" % service['name'])
-//		cog.outl("\t\tpthread_mutex_init(&component->mutex_for_%sServices, NULL);" % service['name'])
+//		cog.outl("\t\tpthread_mutex_init(&component->mutexFor%sServices, NULL);" % service['name'].title())
 //	else :
 //		cog.outl("\t\tcomponent->%s = NULL;" % service['name'])
-//		cog.outl("\t\tpthread_mutex_init(&component->mutex_for_%s, NULL);" % service['name'])
+//		cog.outl("\t\tpthread_mutex_init(&component->mutexFor%s, NULL);" % service['name'].title())
 //}}
 celix_status_t example_create(example_pt *result) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
 	example_pt component = calloc(1, sizeof(*component)); //do not edit, generated code
 	if (component != NULL) { //do not edit, generated code
 		component->logger = NULL; //do not edit, generated code
-		pthread_mutex_init(&component->mutex_for_logger, NULL); //do not edit, generated code
+		pthread_mutex_init(&component->mutexForLogger, NULL); //do not edit, generated code
 		component->loggerOptional = NULL; //do not edit, generated code
-		pthread_mutex_init(&component->mutex_for_loggerOptional, NULL); //do not edit, generated code
+		pthread_mutex_init(&component->mutexForLoggerOptional, NULL); //do not edit, generated code
 		component->loggerManyServices = NULL; //do not edit, generated code
 		status = arrayList_create(&component->loggerManyServices); //do not edit, generated code
-		pthread_mutex_init(&component->mutex_for_loggerManyServices, NULL); //do not edit, generated code
+		pthread_mutex_init(&component->mutexForLoggerManyServices, NULL); //do not edit, generated code
 //{{end}}
 		(*result) = component;
 	} else {
@@ -128,62 +128,62 @@ celix_status_t example_stop(example_pt component) { //do not edit, generated cod
 //{{
 //for service in component['serviceDependencies'] :
 //	if service['cardinality'] == "many" :
-//		cog.outl("celix_status_t %s_add_%s(%s_pt component, %s %s) {" % (componentName, service['name'], componentName, service['type'], service['name'])) 
+//		cog.outl("celix_status_t %s_add%s(%s_pt component, %s %s) {" % (componentName, service['name'].title(), componentName, service['type'], service['name'])) 
 //		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
-//		cog.outl("printf(\" %s_add_%s called.\\n\");" % (componentName, service['name']))
-//		cog.outl("\tpthread_mutex_lock(&component->mutex_for_%sServices);" % service['name'])
+//		cog.outl("printf(\" %s_add%s called.\\n\");" % (componentName, service['name'].title()))
+//		cog.outl("\tpthread_mutex_lock(&component->mutexFor%sServices);" % service['name'].title())
 //		cog.outl("\tarrayList_add(component->%sServices, %s);" % (service['name'], service['name']))
-//		cog.outl("\tpthread_mutex_unlock(&component->mutex_for_%sServices);" % service['name'])
+//		cog.outl("\tpthread_mutex_unlock(&component->mutexFor%sServices);" % service['name'].title())
 //		cog.outl("\treturn status;")
 //		cog.outl("}")
 //		cog.outl("")
-//		cog.outl("celix_status_t %s_remove_%s(%s_pt component, %s %s) {" % (componentName, service['name'], componentName, service['type'], service['name'])) 
+//		cog.outl("celix_status_t %s_remove%s(%s_pt component, %s %s) {" % (componentName, service['name'].title(), componentName, service['type'], service['name'])) 
 //		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
-//		cog.outl("\tpthread_mutex_lock(&component->mutex_for_%sServices);" % service['name'])
+//		cog.outl("\tpthread_mutex_lock(&component->mutexFor%sServices);" % service['name'].title())
 //		cog.outl("\tarrayList_removeElement(component->%sServices, %s);" % (service['name'], service['name']))
-//		cog.outl("\tpthread_mutex_unlock(&component->mutex_for_%sServices);" % service['name'])
+//		cog.outl("\tpthread_mutex_unlock(&component->mutexFor%sServices);" % service['name'].title())
 //		cog.outl("\treturn status;")
 //		cog.outl("}")
 //	else :
-//		cog.outl("celix_status_t %s_set_%s(%s_pt component, %s %s) {" % (componentName, service['name'], componentName, service['type'], service['name'])) 
+//		cog.outl("celix_status_t %s_set%s(%s_pt component, %s %s) {" % (componentName, service['name'].title(), componentName, service['type'], service['name'])) 
 //		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
-//		cog.outl("printf(\" %s_set_%s called.\\n\");" % (componentName, service['name']))
-//		cog.outl("\tpthread_mutex_lock(&component->mutex_for_%s);" % service['name'])
+//		cog.outl("printf(\" %s_set%s called.\\n\");" % (componentName, service['name'].title()))
+//		cog.outl("\tpthread_mutex_lock(&component->mutexFor%s);" % service['name'].title())
 //		cog.outl("\tcomponent->%s == %s;" % (service['name'], service['name']))
-//		cog.outl("\tpthread_mutex_unlock(&component->mutex_for_%s);" % service['name'])
+//		cog.outl("\tpthread_mutex_unlock(&component->mutexFor%s);" % service['name'].title())
 //		cog.outl("\treturn status;")
 //		cog.outl("}")
 //		cog.outl("")	
 //}}
-celix_status_t example_set_logger(example_pt component, log_service_pt logger) { //do not edit, generated code
+celix_status_t example_setLogger(example_pt component, log_service_pt logger) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
-	pthread_mutex_lock(&component->mutex_for_logger); //do not edit, generated code
+	pthread_mutex_lock(&component->mutexFor:ogger); //do not edit, generated code
 	component->logger == logger; //do not edit, generated code
-	pthread_mutex_unlock(&component->mutex_for_logger); //do not edit, generated code
+	pthread_mutex_unlock(&component->mutexForLogger); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 
-celix_status_t example_set_loggerOptional(example_pt component, log_service_pt loggerOptional) { //do not edit, generated code
+celix_status_t example_setLoggerOptional(example_pt component, log_service_pt loggerOptional) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
-	pthread_mutex_lock(&component->mutex_for_loggerOptional); //do not edit, generated code
+	pthread_mutex_lock(&component->mutexForLoggerOptional); //do not edit, generated code
 	component->loggerOptional == loggerOptional; //do not edit, generated code
-	pthread_mutex_unlock(&component->mutex_for_loggerOptional); //do not edit, generated code
+	pthread_mutex_unlock(&component->mutexForLoggerOptional); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 
-celix_status_t example_add_loggerMany(example_pt component, log_service_pt loggerMany) { //do not edit, generated code
+celix_status_t example_addLoggerMany(example_pt component, log_service_pt loggerMany) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
-	pthread_mutex_lock(&component->mutex_for_loggerManyServices); //do not edit, generated code
+	pthread_mutex_lock(&component->mutexFor:oggerManyServices); //do not edit, generated code
 	arrayList_add(component->loggerManyServices, loggerMany); //do not edit, generated code
-	pthread_mutex_unlock(&component->mutex_for_loggerManyServices); //do not edit, generated code
+	pthread_mutex_unlock(&component->mutexForLoggerManyServices); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 
-celix_status_t example_remove_loggerMany(example_pt component, log_service_pt loggerMany) { //do not edit, generated code
+celix_status_t example_removeLoggerMany(example_pt component, log_service_pt loggerMany) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code
-	pthread_mutex_lock(&component->mutex_for_loggerManyServices); //do not edit, generated code
+	pthread_mutex_lock(&component->mutexForLoggerManyServices); //do not edit, generated code
 	arrayList_removeElement(component->loggerManyServices, loggerMany); //do not edit, generated code
-	pthread_mutex_unlock(&component->mutex_for_loggerManyServices); //do not edit, generated code
+	pthread_mutex_unlock(&component->mutexForLoggerManyServices); //do not edit, generated code
 	return status; //do not edit, generated code
 } //do not edit, generated code
 

http://git-wip-us.apache.org/repos/asf/celix/blob/6a56692b/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/component.h b/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
index e036bbd..64972fd 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
@@ -62,15 +62,15 @@ celix_status_t example_destroy(example_pt component); //do not edit, generated c
 //{{
 //for service in component['serviceDependencies'] :
 //	if service['cardinality'] == "many" :
-//		cog.outl("celix_status_t %s_add_%s(%s_pt component, %s %s);" % (componentName, service['name'], componentName, service['type'], service['name']))
-//		cog.outl("celix_status_t %s_remove_%s(%s_pt component, %s %s);" % (componentName, service['name'], componentName, service['type'], service['name']))
+//		cog.outl("celix_status_t %s_add%s(%s_pt component, %s %s);" % (componentName, service['name'].title(), componentName, service['type'], service['name']))
+//		cog.outl("celix_status_t %s_remove%s(%s_pt component, %s %s);" % (componentName, service['name'].title(), componentName, service['type'], service['name']))
 //	else :
-//		cog.outl("celix_status_t %s_set_%s(%s_pt component, %s %s);" % (componentName, service['name'], componentName, service['type'], service['name']))
+//		cog.outl("celix_status_t %s_set%s(%s_pt component, %s %s);" % (componentName, service['name'].title(), componentName, service['type'], service['name']))
 //}}
-celix_status_t example_set_logger(example_pt component, log_service_pt logger); //do not edit, generated code
-celix_status_t example_set_loggerOptional(example_pt component, log_service_pt loggerOptional); //do not edit, generated code
-celix_status_t example_add_loggerMany(example_pt component, log_service_pt loggerMany); //do not edit, generated code
-celix_status_t example_remove_loggerMany(example_pt component, log_service_pt loggerMany); //do not edit, generated code
+celix_status_t example_setLogger(example_pt component, log_service_pt logger); //do not edit, generated code
+celix_status_t example_setLoggerOptional(example_pt component, log_service_pt loggerOptional); //do not edit, generated code
+celix_status_t example_add:oggerMany(example_pt component, log_service_pt loggerMany); //do not edit, generated code
+celix_status_t example_removeLoggerMany(example_pt component, log_service_pt loggerMany); //do not edit, generated code
 //{{end}}
 
 //{{


[8/9] celix git commit: CELIX-236: Added 'pip install pyyaml' instructions for the readme

Posted by bp...@apache.org.
CELIX-236: Added 'pip install pyyaml' instructions for the readme


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/15b41d22
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/15b41d22
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/15b41d22

Branch: refs/heads/develop
Commit: 15b41d221bbcd7acd04214ba4374ed635ec948e0
Parents: 2729299
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Jan 26 12:59:26 2016 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Jan 26 12:59:26 2016 +0100

----------------------------------------------------------------------
 celix-bootstrap/README.md | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/15b41d22/celix-bootstrap/README.md
----------------------------------------------------------------------
diff --git a/celix-bootstrap/README.md b/celix-bootstrap/README.md
index cbd1f58..32296c6 100644
--- a/celix-bootstrap/README.md
+++ b/celix-bootstrap/README.md
@@ -5,12 +5,15 @@ A (python based) code generation tool for [Apache Celix](https://celix.apache.or
 
 ###Option 1 (install with distutils)
 
+* Install PyYAML: `pip install pyyaml`
 * Download Cog from https://pypi.python.org/pypi/cogapp
 * Unpack and run `python setup.py install' in the cogapp directory
 * Clone this repository
 * Run `python setup.py install` in the celix-bootstrap directory
 
 ###Option 2 (configure with alias)
+
+* Install PyYAML: `pip install pyyaml`
 * Download Cog from https://pypi.python.org/pypi/cogapp
 * Unpack it in a convenient directory 
 * Clone this repository


[4/9] celix git commit: CELIX-236: add project deployment, fixed include path

Posted by bp...@apache.org.
CELIX-236: add project deployment, fixed include path


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/a4939dee
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/a4939dee
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/a4939dee

Branch: refs/heads/develop
Commit: a4939dee831659ec4925300b70765a6bab49eba8
Parents: 6a56692
Author: Bjoern Petri <bp...@apache.org>
Authored: Thu Jan 14 12:44:19 2016 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Thu Jan 14 12:44:19 2016 +0100

----------------------------------------------------------------------
 .../bootstrap/templates/project/deploy.cmake    | 32 ++++++++++++++++++++
 1 file changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/a4939dee/celix-bootstrap/celix/bootstrap/templates/project/deploy.cmake
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/project/deploy.cmake b/celix-bootstrap/celix/bootstrap/templates/project/deploy.cmake
new file mode 100644
index 0000000..899c83b
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/project/deploy.cmake
@@ -0,0 +1,32 @@
+#{{
+#import fnmatch
+#import os
+#import yaml
+#
+#project = None 
+#bundle = None 
+#
+#with open(projectFile) as input :
+#	project = yaml.load(input)
+#
+#cog.outl("deploy( \"%s\" BUNDLES" % project['name'])
+#cog.outl("\t${CELIX_BUNDLES_DIR}/shell.zip")
+#cog.outl("\t${CELIX_BUNDLES_DIR}/shell_tui.zip")
+#cog.outl("\t${CELIX_BUNDLES_DIR}/log_service.zip")
+#
+#
+#for root, dirs, filenames in os.walk('.'):
+#	for foundFile in fnmatch.filter(filenames, 'bundle.yaml'):
+#		bundleFile = root + '/' + foundFile
+#		with open(bundleFile) as input :
+#			bundle = yaml.load(input)
+#			cog.outl("\t%s" % bundle['name'])
+#
+#}}
+deploy( "mybundle" BUNDLES #do not edit, generated code
+	${CELIX_BUNDLES_DIR}/shell.zip #do not edit, generated code
+	${CELIX_BUNDLES_DIR}/shell_tui.zip #do not edit, generated code
+	${CELIX_BUNDLES_DIR}/log_service.zip #do not edit, generated code
+	mybundle #do not edit, generated code
+#{{end}}
+)


[5/9] celix git commit: CELIX-236: Add build command

Posted by bp...@apache.org.
CELIX-236: Add build command


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/29814470
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/29814470
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/29814470

Branch: refs/heads/develop
Commit: 2981447083fe090c4b15791a7861551a91484181
Parents: a4939de
Author: Bjoern Petri <bp...@apache.org>
Authored: Mon Jan 18 19:31:47 2016 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Mon Jan 18 19:31:47 2016 +0100

----------------------------------------------------------------------
 .../celix/bootstrap/argument_parser.py           | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/29814470/celix-bootstrap/celix/bootstrap/argument_parser.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/argument_parser.py b/celix-bootstrap/celix/bootstrap/argument_parser.py
index ad477f9..0fe2649 100644
--- a/celix-bootstrap/celix/bootstrap/argument_parser.py
+++ b/celix-bootstrap/celix/bootstrap/argument_parser.py
@@ -2,6 +2,7 @@
 import os
 import argparse
 from . import generators
+import subprocess
 
 def main() :
 	parser = argparse.ArgumentParser("celix-bootstrap")
@@ -10,9 +11,10 @@ def main() :
 	CREATE_BUNDLE_COMMAND = "create_bundle"
 
 	UPDATE_COMMAND = "update"
+	BUILD_COMMAND = "build"
 
 	#positional
-	parser.add_argument("command", help="The command to execute", choices=(CREATE_PROJECT_COMMAND, CREATE_BUNDLE_COMMAND, UPDATE_COMMAND))
+	parser.add_argument("command", help="The command to execute", choices=(CREATE_PROJECT_COMMAND, CREATE_BUNDLE_COMMAND, UPDATE_COMMAND, BUILD_COMMAND))
 	parser.add_argument("directory", help="The directory to work on")
 
 	#optional
@@ -29,6 +31,8 @@ def main() :
 		gm.createProject()
 	elif args.command == UPDATE_COMMAND :
 		gm.update()
+	elif args.command == BUILD_COMMAND :
+		gm.build()
 	else :
 		sys.exit()
 
@@ -58,3 +62,16 @@ class GeneratorMediator :
 		if os.path.isfile(os.path.join(self.gendir, "project.yaml")) :
 			print("Generating/updating project code")
 			self.projectGenerator.update()
+
+	def build(self) :
+		if not os.path.exists(self.gendir):
+			print("Creating Directory " + self.gendir)
+			os.makedirs(self.gendir)
+
+		cmake = subprocess.Popen(["cmake", os.getcwd()], cwd=self.gendir, stderr=subprocess.STDOUT)
+		if cmake.wait() != 0:
+			print("Cmake run failed. Do you perform to need an update run first?")
+		else:
+			make = subprocess.Popen(["make", "all", "deploy"], cwd=self.gendir, stderr=subprocess.STDOUT)
+			if make.wait() != 0:
+				print("Compilation failed. Please check your code")


[6/9] celix git commit: CELIX-236: Update README

Posted by bp...@apache.org.
CELIX-236: Update README


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/e5297485
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/e5297485
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/e5297485

Branch: refs/heads/develop
Commit: e5297485d2a2f825a60eb5581ea6e751091d4e52
Parents: 2981447
Author: Bjoern Petri <bp...@apache.org>
Authored: Mon Jan 18 19:37:23 2016 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Mon Jan 18 19:37:23 2016 +0100

----------------------------------------------------------------------
 celix-bootstrap/README.md | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/e5297485/celix-bootstrap/README.md
----------------------------------------------------------------------
diff --git a/celix-bootstrap/README.md b/celix-bootstrap/README.md
index ef63c8a..cbd1f58 100644
--- a/celix-bootstrap/README.md
+++ b/celix-bootstrap/README.md
@@ -38,19 +38,24 @@ Is good to known that you should not edit anything between the following comment
 You can setup a new Apache Celix project by executing following steps:
 * Choose a project directory and cd to it
 * Run `celix-bootstrap create_project .`
-* Edit the project.json file and ensure that the celix_install_dir points to the directory where Apache Celix is installed
+* Edit the project.yaml file and ensure that the celix_install_dir points to the directory where Apache Celix is installed
 * Run `celix-bootstrap update .` to generate the needed files
-* (Optional) Update the project.json file and run `celix-bootstrap update .` again to update the generated files
+* (Optional) Update the project.yaml file and run `celix-bootstrap update .` again to update the generated files
 * (Optional) Run `celix-bootstrap update . -e` to update the project source files one more time and remove the code generation parts
 
 You can create a new bundle by executing the following steps:
 * cd to the project directory
 * Run `celix-bootstrap create_bundle mybundle`
-* Edit the `mybundle/bundle.json` file to declare which components you like to create and what services those components depends on and/or provide
+* Edit the `mybundle/bundle.yaml` file to declare which components you like to create and what services those components depends on and/or provide
 * Run `celix-bootstrap update mybundle` to generate the neccesary files
-* Add the bundle to the project CMakeLists.txt file by adding the `add_subdirectory(mybundle)` line
+* Run `celix-bootstrap update .` to include the new bundle into the CMakeLists.txt 
 * Add code to the component and when providing service also add the necesarry code to the bundle activator
 * (Optional) Run `celix-bootstrap update . -e` to update the bundle source files one more time and remove the code generation parts
 
+You can build your whole project with the following step:
+* cd to the project directory
+* Run `celix-bootstrap build buildDirectory` to build and the deploy the code within the buildDirectory
+* In case the build was successful, you'll find several deployed configuration at buildDirectory/deploy
+
 Additional Info
 * You can use the -t argument to use a different set of template (project & bundle) files. The original template files can be found at ${celix-bootstrap_dir}/templates


[2/9] celix git commit: CELIX-236: adapted celix-bootstrap to use yaml instead of json to be able to cog the yaml files as well. Added auto completion for the celix installation directory as well as the include files, service names and serivce types. Add

Posted by bp...@apache.org.
CELIX-236: adapted celix-bootstrap to use yaml instead of json to be able to cog the yaml files as well. Added auto completion for the celix installation directory as well as the include files, service names and serivce types. Added service header generation for bundle services. Added error handling in case no provided/depended services are given.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/4feeabc5
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/4feeabc5
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/4feeabc5

Branch: refs/heads/develop
Commit: 4feeabc5999466be41eb28de30015af05a91adc9
Parents: 5d703d3
Author: Bjoern Petri <bp...@apache.org>
Authored: Thu Jan 14 08:24:18 2016 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Thu Jan 14 08:24:18 2016 +0100

----------------------------------------------------------------------
 .../celix/bootstrap/argument_parser.py          |  17 +--
 celix-bootstrap/celix/bootstrap/generators.py   |  71 +++++------
 .../bootstrap/templates/bundle/CMakeLists.txt   |   8 +-
 .../bootstrap/templates/bundle/bundle.json      |  18 ---
 .../bootstrap/templates/bundle/bundle.yaml      |  66 ++++++++++
 .../templates/bundle/bundle_activator.c         | 126 ++++++++++---------
 .../bootstrap/templates/bundle/component.c      |  22 +++-
 .../bootstrap/templates/bundle/component.h      |  21 +++-
 .../bootstrap/templates/bundle/deploy.cmake     |   4 +-
 .../celix/bootstrap/templates/bundle/service.h  |  58 +++++++++
 .../bootstrap/templates/project/CMakeLists.txt  |  21 ++--
 .../bootstrap/templates/project/project.json    |   4 -
 .../bootstrap/templates/project/project.yaml    |  19 +++
 .../bootstrap/templates/services/service.h      |  48 -------
 .../bootstrap/templates/services/services.json  |   4 -
 15 files changed, 305 insertions(+), 202 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/argument_parser.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/argument_parser.py b/celix-bootstrap/celix/bootstrap/argument_parser.py
index 6919e9a..922d98c 100644
--- a/celix-bootstrap/celix/bootstrap/argument_parser.py
+++ b/celix-bootstrap/celix/bootstrap/argument_parser.py
@@ -3,15 +3,11 @@ import os
 import argparse
 from . import generators
 
-#TODO add support to add licence text to all created files
-#TODO add support to select pthread or celix_threads
-
 def main() :
 	parser = argparse.ArgumentParser("celix-bootstrap")
 
 	CREATE_PROJECT_COMMAND = "create_project"	
 	CREATE_BUNDLE_COMMAND = "create_bundle"
-	CREATE_SERVICE_COMMAND = "create_services"
 
 	UPDATE_COMMAND = "update"
 
@@ -31,8 +27,6 @@ def main() :
 		gm.createBundle()
 	elif args.command == CREATE_PROJECT_COMMAND :
 		gm.createProject()
-	elif args.command == CREATE_SERVICE_COMMAND :
-		gm.createServices()
 	elif args.command == UPDATE_COMMAND :
 		gm.update()
 	else :
@@ -44,13 +38,11 @@ class GeneratorMediator :
 	gendir = None
 	bundleGenerator = None
 	projectGenerator = None
-	servicesGenerator = None
 	
 	def __init__(self, gendir, erase, template_dir) :		
 		self.gendir = gendir
 		self.bundleGenerator = generators.Bundle(gendir, erase, template_dir)
 		self.projectGenerator = generators.Project(gendir, erase, template_dir)
-		self.servicesGenerator = generators.Services(gendir, erase, template_dir)
 
 	def createBundle(self) :
 		self.bundleGenerator.create()
@@ -58,16 +50,11 @@ class GeneratorMediator :
 	def createProject(self) :
 		self.projectGenerator.create()	
 	
-	def createServices(self) :
-		self.servicesGenerator.create()
 
 	def update(self) :
-		if os.path.isfile(os.path.join(self.gendir, "bundle.json")) :
+		if os.path.isfile(os.path.join(self.gendir, "bundle.yaml")) :
 			print("Generating/updating bundle code")
 			self.bundleGenerator.update()
-		if os.path.isfile(os.path.join(self.gendir, "project.json")) :
+		if os.path.isfile(os.path.join(self.gendir, "project.yaml")) :
 			print("Generating/updating project code")
 			self.projectGenerator.update()
-		if os.path.isfile(os.path.join(self.gendir, "services.json")) :
-			print("Generating/updating services code")
-			self.servicesGenerator.update()

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/generators.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/generators.py b/celix-bootstrap/celix/bootstrap/generators.py
index 58e13df..7854f3f 100644
--- a/celix-bootstrap/celix/bootstrap/generators.py
+++ b/celix-bootstrap/celix/bootstrap/generators.py
@@ -1,10 +1,10 @@
 import shutil
 import os
 import sys
-import json
+import yaml
 import cogapp
 
-class BaseGenerator:
+class BaseGenerator(object):
 	gendir = None
 	descriptor = None
 	erase_cog = False
@@ -15,7 +15,7 @@ class BaseGenerator:
 
 	def __init__(self, gendir, profile, erase, template_dir) :
 		self.gendir = gendir
-		self.descriptor = "%s/%s.json" % (gendir, profile)
+		self.descriptor = "%s/%s.yaml" % (gendir, profile)
 		self.template_dir = os.path.join(os.getcwd(), os.path.dirname(__file__), "templates")
 		self.profile = profile
 		self.erase_cog = erase
@@ -36,11 +36,11 @@ class BaseGenerator:
 		
 	def create(self) :
 		if os.path.exists(self.descriptor) :
-			print("%s Already exists. Will not override existing %s.json" % (self.descriptor, self.profile))
+			print("%s Already exists. Will not override existing %s.yaml" % (self.descriptor, self.profile))
 		else :
 			if not os.path.exists(self.gendir) :
 				os.makedirs(self.gendir)
-			shutil.copyfile(os.path.join(self.template_dir, self.profile, "%s.json" % self.profile), self.descriptor)
+			shutil.copyfile(os.path.join(self.template_dir, self.profile, "%s.yaml" % self.profile), self.descriptor)
 			
 			print("Edit the %s file and run 'celix-bootstrap update %s' to generate the source files" % (self.descriptor, self.gendir))
 
@@ -48,13 +48,15 @@ class BaseGenerator:
 		if os.path.isdir(self.gendir) and os.path.exists(self.descriptor) :
 			with open(self.descriptor) as inputFile :
 				try :
-					return json.load(inputFile)
+					return yaml.load(inputFile)
 				except ValueError as e:
-					print("ERROR: %s is not a valid json file: %s" % (self.descriptor, e))
+					print("ERROR: %s is not a valid yaml file: %s" % (self.descriptor, e))
 					sys.exit(1)
 
 	def update_file(self, template, targetFile, options=[], commentsPrefix="//") :
+		print("Creating file %s %s" % (self.gendir, targetFile))
 		cog_file = os.path.join(self.gendir, targetFile)
+#		cog_file = os.path.join('.', targetFile)
 		if not os.path.exists(cog_file) :
 			print("Creating file %s" % cog_file)
 			if not os.path.exists(os.path.dirname(cog_file)) :
@@ -77,7 +79,11 @@ class BaseGenerator:
 		if self.erase_cog :
 			cog_options += ["-d", "-o", cog_file, backup_cog_file]
 		else :
-			cog_options += ["-r", "-e", "-s", " %s%s" %(commentsPrefix, self.gen_code_suffix), cog_file]
+			cog_options += ["-r", "-e" ]
+			if commentsPrefix is not None: 
+				cog_options += [ "-s", " %s%s" %(commentsPrefix, self.gen_code_suffix)]
+			cog_options += [cog_file]
+
 		cog.main(cog_options)
 	
 
@@ -109,17 +115,29 @@ class Bundle(BaseGenerator):
 		options = ["-D", "bundleFile=%s" % self.descriptor, "-D", "componentName=%s" % componentName]
 		self.update_file("component.c", genfile, options)
 
+	def update_service_header(self, componentName, service) :
+		genfile = "public/include/%s" % service['include']
+		options = ["-D", "bundleFile=%s" % self.descriptor,  "-D", "componentName=%s" % componentName, "-D", "serviceName=%s" % service['name']]
+		self.update_file("service.h", genfile, options)
+
+	def create(self) :
+		self.update_file(os.path.join(self.template_dir, self.profile, "%s.yaml" % self.profile), "%s.yaml" % self.profile, [], None)
+
 	def update(self) :
 		bd = self.read_descriptor()
 		if bd is None :
-			print("%s does not exist or does not contain a bundle.json file" % self.gendir)
+			print("%s does not exist or does not contain a bundle.yaml file" % self.gendir)
 		else :
 			self.update_cmakelists()	
 			self.update_deploy_file()
 			self.update_activator()
-			for comp in bd['components'] :
-				self.update_component_header(comp['name'])
-				self.update_component_source(comp['name'])
+			if 'components' in bd and bd['components'] is not None:
+				for comp in bd['components'] :
+					self.update_component_header(comp['name'])
+					self.update_component_source(comp['name'])
+					if 'providedServices' in comp and comp['providedServices'] is not None:
+						for service in comp['providedServices']:
+							self.update_service_header(comp['name'], service)
 
 class Project(BaseGenerator):
 
@@ -131,33 +149,12 @@ class Project(BaseGenerator):
 		options = ["-D", "projectFile=%s" % self.descriptor]
 		self.update_file("CMakeLists.txt", "CMakeLists.txt", options, "#")	
 
-	def update(self) :
-		descriptor = self.read_descriptor()
-		if descriptor is None :
-			print("%s does not exist or does not contain a project.json file" % self.gendir)
-		else :
-			self.update_cmakelists()	
-
-
-class Services(BaseGenerator):
-
-	def __init__(self, gendir, erase, template_dir) :
-		BaseGenerator.__init__(self, gendir, "services", erase, template_dir)
-		#python3 super(Services, self).__init__(gendir, "services")
-
-	def update_cmakelists(self) :
-		options = ["-D", "projectFile=%s" % self.descriptor]
-		self.update_file("CMakeLists.txt", "CMakeLists.txt", options, "#")	
-
-	def update_service_header(self, serviceName) :
-		genfile = "public/include/%s.h" % serviceName
-		options = ["-D", "descriptorFile=%s" % self.descriptor, "-D", "serviceName=%s" % serviceName]
-		self.update_file("service.h", genfile, options)
+	def create(self) :
+		self.update_file(os.path.join(self.template_dir, self.profile, "%s.yaml" % self.profile),  "%s.yaml" % self.profile, [], None)	
 
 	def update(self) :
 		descriptor = self.read_descriptor()
 		if descriptor is None :
-			print("%s does not exist or does not contain a services.json file" % self.gendir)
+			print("%s does not exist or does not contain a project.yaml file" % self.gendir)
 		else :
-			for serv in descriptor :
-				self.update_service_header(serv['name'])
+			self.update_cmakelists()	

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt b/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
index 5bc1979..98c45f5 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/CMakeLists.txt
@@ -1,8 +1,12 @@
 #{{
-#import json
+#import yaml
 #bundle = None 
 #with open(bundleFile) as input :
-#	bundle = json.load(input)
+#	bundle = yaml.load(input)
+#
+#if not 'components' in bundle or bundle['components'] is None:
+# 	bundle['components'] = []
+#
 #}}
 #{{end}}
 

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.json
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.json b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.json
deleted file mode 100644
index 558bd72..0000000
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- 	"name" : "mybundle",
-	"symbolicName": "org.example.mybundle",
-	"components" : [
-		{
-			"name" : "example",
-			"serviceDependencies" : [
-				{ "include" : "log_service/log_service.h" , "name" : "logger", "service_name" : "OSGI_LOGSERVICE_NAME", "type" : "log_service_pt", "cardinality" : "one" },
-				{ "include" : "log_service/log_service.h" , "name" : "loggerOptional", "service_name" : "OSGI_LOGSERVICE_NAME", "type" : "log_service_pt", "cardinality" : "optional" },
-				{ "include" : "log_service/log_service.h" , "name" : "loggerMany", "filter" : "(objectClass=log_service)", "type" : "log_service_pt", "cardinality" : "many" }
-			],
-			"providedServices" : [
-				{ "include" : "shell/command.h" , "name" : "command", "service_name" : "\"commandService\"", "type" : "command_service_pt" },
-				{ "include" : "shell/command.h" , "name" : "command2", "service_name" : "\"commandService\"", "type" : "command_service_pt" }
-			] 
-		}
-	]
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.yaml
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.yaml b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.yaml
new file mode 100644
index 0000000..d85030d
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle.yaml
@@ -0,0 +1,66 @@
+#{{
+#from celix.bootstrap.celix_utils import *
+#}}
+#{{end}}
+
+
+#{{ 
+# name = checkInput('\nPlease enter bundleName', '([a-zA-Z_][a-zA-Z0-9_]*)', 'mybundle')
+# cog.out('name : \'%s\'' % name )
+#}}
+name: 'mybundle'
+#{{end}}
+
+#{{
+# symName = checkInput('\nPlease enter symbolicName', '([a-zA-Z_][a-zA-Z0-9_.]*)', 'org.example.mybundle') 
+# cog.out('symbolicName: \'%s\'' % symName )
+#}}
+symbolicName: 'org.example.mybundle'
+#{{end}}
+
+components: 
+    #{{
+    #
+    #while yn('Do you want to add ' + ('a' if 'componentName' not in vars() else 'another') + ' component?'):
+    #		componentName = checkInput('\nPlease enter componentName', '([a-zA-Z_][a-zA-Z0-9_]*)', 'example') 
+    #		cog.outl('- name: \'%s\'' % componentName )
+    #		cog.outl('  providedServices:')
+    #		while yn('Should component \'%s\' provide %s service?' % (componentName, 'a' if 'psInclude' not in vars() else 'another')):
+    #			psServiceName1 = checkInput('(1) Please enter a name, which can be used for the filename and the include guards', '([a-zA-Z_][a-zA-Z0-9_]*)'); 
+    #			psServiceName2 = checkInput('(2) Please enter a name, which is used to register and lookup the service', '([a-zA-Z_][a-zA-Z0-9_]*)', (psServiceName1.lower() + ('_service' if not psServiceName1.endswith('_service') else ''))); 
+    #			psServiceType = checkInput('(3) Please enter a type', '([a-zA-Z_][a-zA-Z0-9_]*)',  (psServiceName1.lower() + ('_service_pt' if not psServiceName1.endswith('_service_pt') else ''))  );
+    #			psInclude = checkInput('(4) Please enter the name of the include file', '(.+?)(\.[^.]*$|$)', psServiceName1.lower() + '.h'); 
+    #
+    #			print("\n Summary:")	
+    #			print("\tname :\t%s" % (psServiceName1))	
+    #			print("\tservice_name:\t%s" % (psServiceName2))	
+    #			print("\tservice_type:\t%s" % (psServiceType))	
+    #			print("\tinclude file:\t%s" % (psInclude)) 
+    #			if yn('Are those information correct?'):
+    #				cog.outl('      - {include: \'%s\', name: \'%s\', service_name: \'%s\', type: \'%s\'}' % (psInclude, psServiceName1, psServiceName2, psServiceType))
+    #			else:
+    #				print("Service was not added.")
+    #
+    #		cog.outl('  serviceDependencies:')
+    #		while yn('Should component \'%s\' depend on %s service?' % (componentName, 'a' if 'sdInclude' not in vars() else 'another')):
+    #			sdInclude = checkInclude('(1) Please enter the include filename, which describes the service', '(.+?)(\.[^.]*$|$)'); 
+    #			sdServiceName1 = checkInput('(2) Please enter a name, which is used to generate the code', '([a-zA-Z_][a-zA-Z0-9_]*)'); 
+    #			sdServiceName2 = checkIncludeContent('(3) Please enter the variable/constants, which is used to register the service within the framework', sdInclude); 
+    #			sdServiceType = checkIncludeContent('(4) Please enter the type of the service', sdInclude);
+    #			sdCardinality = checkInput('(5) Please enter the cardinality (one|many|optional)', '(one)|(many)|(optional)');
+    #
+    #			print("\n Summary:")	
+    #			print("\tname :\t%s" % (sdServiceName1))	
+    #			print("\tservice_name:\t%s" % (sdServiceName2))	
+    #			print("\tservice_type:\t%s" % (sdServiceType))	
+    #			print("\tcardinality:\t%s" % (sdCardinality)) 
+    #			print("\tinclude file:\t%s" % (sdInclude)) 
+    #			if yn('Are those information correct?'):
+    #				cog.outl('      - {include: \'%s\', name: \'%s\', service_name: \'%s\', type: \'%s\', cardinality: \'%s\'}' % (sdInclude, sdServiceName1, sdServiceName2, sdServiceType, sdCardinality))
+    #			else:
+    #				print("Service dependency was not added.")
+    #}}
+    #{{end}}
+
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
index b946961..a62b1f0 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/bundle_activator.c
@@ -1,10 +1,19 @@
 //TODO update fields from <service>Type to <service>For<component>Type
 //TODO improve names to camel case (e.g. from _add_logger_for_example to _addLoggerToExample)
 //{{
-//import json
+//import yaml
 //bundle = None 
 //with open(bundleFile) as input :
-//	bundle = json.load(input)
+//	bundle = yaml.load(input)
+//
+//if not 'components' in bundle or bundle['components'] is None:
+// 	bundle['components'] = []
+//else:
+//	for comp in bundle['components'] : 
+//		if not 'serviceDependencies' in comp or comp['serviceDependencies'] is None:
+//			comp['serviceDependencies'] = []
+//		if not 'providedServices' in comp or comp['providedServices'] is None:
+//			comp['providedServices'] = []
 //}}
 //{{end}}
 #include <stdlib.h>
@@ -20,17 +29,11 @@
 //{{
 //for comp in bundle['components'] : 
 //	cog.outl("#include \"%s.h\"" % comp['name'])
-//	for service in comp['serviceDependencies'] :
-//		cog.outl("#include <%s>" % service['include'])
 //	for service in comp['providedServices'] :
 //		cog.outl("#include <%s>" % service['include'])
+//	for service in comp['serviceDependencies'] :
+//		cog.outl("#include <%s>" % service['include'])
 //}}
-#include "example.h" //do not edit, generated code
-#include <log_service/log_service.h> //do not edit, generated code
-#include <log_service/log_service.h> //do not edit, generated code
-#include <log_service/log_service.h> //do not edit, generated code
-#include <shell/command.h> //do not edit, generated code
-#include <shell/command.h> //do not edit, generated code
 //{{end}}
 
 
@@ -115,6 +118,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 //	cog.outl("\t\t%s_create(&activator->%s);" % (comp['name'], comp['name']))
 //	cog.outl("\t\tactivator->%sState = COMPONENT_STATE_CREATED;" % (comp['name']))
 //	cog.outl("\t\tpthread_mutex_init(&activator->%sLock, NULL);" % comp['name'])
+//
 //	for service in comp['serviceDependencies'] :
 //		cog.outl("\t\tactivator->%sServiceTracker = NULL;" % service['name'])
 //		cog.outl("\t\tserviceTrackerCustomizer_create(activator, NULL, bundleActivator_add_%s_for_%s, NULL, bundleActivator_remove_%s_for_%s, &activator->%sCustomizer);" % (service['name'], comp['name'], service['name'], comp['name'], service['name']))
@@ -125,6 +129,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 //		if service['cardinality'] == "one" or service['cardinality'] == "optional" :
 //			cog.outl("\t\tactivator->%s_services_for_%s = hashMap_create(NULL, NULL, NULL, NULL);" % (service['name'], comp['name']))
 //			cog.outl("\t\tactivator->current_%s_service_for_%s = NULL;" % (service['name'], comp['name']))
+//
 //	for service in comp['providedServices'] :
 //		cog.outl("\t\tactivator->%s = NULL;" % service['name'])
 //		cog.outl("\t\tactivator->%sServiceRegistry = NULL;" % service['name'])
@@ -182,7 +187,7 @@ celix_status_t bundleActivator_start(void *userData, bundle_context_pt context)
 //		cog.outl("\tserviceTracker_open(activator->%sServiceTracker);" % service['name'])
 //	for service in comp['providedServices'] :
 //		cog.outl("\tif (activator->%s != NULL) {" % service['name'])
-//		cog.outl("\t\tbundleContext_registerService(context, (char *)%s, activator->%s, NULL, &activator->%sServiceRegistry);" % (service['service_name'], service['name'], service['name']))
+//		cog.outl("\t\tbundleContext_registerService(context, (char *)  %s_SERVICE_NAME, activator->%s, NULL, &activator->%sServiceRegistry);" % (service['name'].upper(), service['name'], service['name']))
 //		cog.outl("\t}")
 //}}
 //indent marker //do not edit, generated code
@@ -213,9 +218,10 @@ celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context) {
 //		cog.outl("\tif (activator->%s != NULL) {" % service['name'])
 //		cog.outl("\t\tserviceRegistration_unregister(activator->%sServiceRegistry);" % (service['name']))
 //		cog.outl("\t}")
+//
 //	for service in comp['serviceDependencies'] :
 //		cog.outl("\tserviceTracker_close(activator->%sServiceTracker);" % service['name'])
-//	cog.outl("\t%s_stop(activator->%s);" % (comp['name'], comp['name']))
+//		cog.outl("\t%s_stop(activator->%s);" % (comp['name'], comp['name']))
 //}}
 //indent marker //do not edit, generated code
 	if (activator->command != NULL) { //do not edit, generated code
@@ -313,17 +319,22 @@ static celix_status_t bundleActivator_getFirst(hash_map_pt services, void **resu
 //	cog.outl("static bundleActivator_resolveState_for_%s(struct activator *activator) {" % comp['name'])
 //	cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
 //
-//	cog.out("\tif (activator->%sState == COMPONENT_STATE_CREATED && " % comp['name'])
+//	cog.out("\tif (activator->%sState == COMPONENT_STATE_CREATED " % comp['name'])
 //	conditions = [("activator->current_%s_service_for_%s != NULL" % (serv['name'], comp['name'])) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"] 
-//	cog.out(" && ".join(conditions))
+//	if len(conditions) > 0: 
+//		cog.out(" && ")
+//		cog.out(" && ".join(conditions))
 //	cog.outl(") {")
 //	cog.outl("\t\t%s_start(activator->%s);" % (comp['name'], comp['name']))
 //	cog.outl("\t}")
 //
-//	cog.out("\tif (activator->%sState == COMPONENT_STATE_STARTED && (" % comp['name'])
-//	conditions = [("activator->current_%s_service_for_%s == NULL" % (serv['name'], comp['name'])) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"] 
-//	cog.out(" || ".join(conditions))
-//	cog.outl(")) {")
+//	cog.out("\tif (activator->%sState == COMPONENT_STATE_STARTED " % comp['name'])
+//	conditions = [("activator->current_%s_service_for_%s == NULL" % (serv['name'], comp['name'])) for serv in comp['serviceDependencies'] if serv['cardinality'] == "one"]
+//	if len(conditions) > 0:
+//		cog.out(" && (");
+//		cog.out(" || ".join(conditions))
+//		cog.out(")"); 
+//	cog.outl(") {")
 //	cog.outl("\t\t%s_stop(activator->%s);" % (comp['name'], comp['name']))
 //	cog.outl("\t}")
 //
@@ -346,45 +357,46 @@ static bundleActivator_resolveState_for_example(struct activator *activator) { /
 //{{
 //for comp in bundle['components'] :
 //	for service in comp['serviceDependencies'] :
-//			cog.outl("static celix_status_t bundleActivator_add_%s_for_%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'], comp['name']))
-//			cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
-//			cog.outl("\tstruct activator *activator = handle;")
-//			cog.outl("\t%s %s = service;" % (service['type'], service['name']))
-//			if service['cardinality'] == "many" :
-//				cog.outl("\t%s_add_%s(activator->%s, %s);" % (comp['name'], service['name'], comp['name'], service['name']))
-//			else :
-//				cog.outl("\tpthread_mutex_lock(&activator->%sLock);" % comp['name']);
-//				cog.outl("\t%s highest = NULL;" % service['type']);
-//				cog.outl("\tbundleActivator_getFirst(activator->%s_services_for_%s, (void **)&highest);" % (service['name'], comp['name']))
-//				cog.outl("\tif (highest != activator->current_%s_service_for_%s) {" % (service['name'], comp['name']))
-//				cog.outl("\t\tactivator->current_%s_service_for_%s = highest;" % (service['name'], comp['name']))
-//				cog.outl("\t\t%s_set_%s(activator->%s, highest);" % (comp['name'], service['name'], comp['name'])) 
-//				cog.outl("\t\tbundleActivator_resolveState_for_%s(activator);" % comp['name']);
-//				cog.outl("\t}")
-//				cog.outl("\tpthread_mutex_unlock(&activator->%sLock);" % comp['name']);
-//			cog.outl("\treturn status;")
-//			cog.outl("}")
-//			cog.outl("")
-//			cog.outl("static celix_status_t bundleActivator_remove_%s_for_%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'], comp['name']))
-//			cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
-//			cog.outl("\tstruct activator *activator = handle;")
-//			cog.outl("\t%s %s = service;" % (service['type'], service['name']))
-//			if service['cardinality'] == "many" :
-//				cog.outl("\t%s_remove_%s(activator->%s, %s);" % (comp['name'], service['name'], comp['name'], service['name']))
-//			else :
-//				cog.outl("\tpthread_mutex_lock(&activator->%sLock);" % comp['name']);
-//				cog.outl("\thashMap_remove(activator->%s_services_for_%s, ref);" % (service['name'], comp['name']))
-//				cog.outl("\tif (activator->current_%s_service_for_%s == service) { " % (service['name'], comp['name']))
-//				cog.outl("\t\t%s highest = NULL;" % service['type']);
-//				cog.outl("\t\tbundleActivator_getFirst(activator->%s_services_for_%s, (void **)&highest);" % (service['name'], comp['name']))
-//				cog.outl("\t\tactivator->current_%s_service_for_%s = highest;" % (service['name'], comp['name']))
-//				cog.outl("\t\tbundleActivator_resolveState_for_%s(activator);" % comp['name']);
-//				cog.outl("\t\t%s_set_%s(activator->%s, highest);" % (comp['name'], service['name'], comp['name'])) 
-//				cog.outl("\t}")
-//				cog.outl("\tpthread_mutex_unlock(&activator->%sLock);" % comp['name']);
-//			cog.outl("\treturn status;")
-//			cog.outl("}")
-//			cog.outl("")
+//		cog.outl("static celix_status_t bundleActivator_add_%s_for_%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'], comp['name']))
+//		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//		cog.outl("\tstruct activator *activator = handle;")
+//		cog.outl("\t%s %s = service;" % (service['type'], service['name']))
+//		if service['cardinality'] == "many" :
+//			cog.outl("\t%s_add_%s(activator->%s, %s);" % (comp['name'], service['name'], comp['name'], service['name']))
+//		else :
+//			cog.outl("\tpthread_mutex_lock(&activator->%sLock);" % comp['name']);
+//			cog.outl("\t%s highest = NULL;" % service['type']);
+//			cog.outl("\tbundleActivator_getFirst(activator->%s_services_for_%s, (void **)&highest);" % (service['name'], comp['name']))
+//			cog.outl("\tif (highest != activator->current_%s_service_for_%s) {" % (service['name'], comp['name']))
+//			cog.outl("\t\tactivator->current_%s_service_for_%s = highest;" % (service['name'], comp['name']))
+//			cog.outl("\t\t%s_set_%s(activator->%s, highest);" % (comp['name'], service['name'], comp['name'])) 
+//			cog.outl("\t\tbundleActivator_resolveState_for_%s(activator);" % comp['name']);
+//			cog.outl("\t}")
+//			cog.outl("\tpthread_mutex_unlock(&activator->%sLock);" % comp['name']);
+//		cog.outl("\treturn status;")
+//		cog.outl("}")
+//		cog.outl("")
+//		cog.outl("static celix_status_t bundleActivator_remove_%s_for_%s(void *handle, service_reference_pt ref, void *service) {" % (service['name'], comp['name']))
+//		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//		cog.outl("\tstruct activator *activator = handle;")
+//		cog.outl("\t%s %s = service;" % (service['type'], service['name']))
+//
+//		if service['cardinality'] == "many" :
+//			cog.outl("\t%s_remove_%s(activator->%s, %s);" % (comp['name'], service['name'], comp['name'], service['name']))
+//		else :
+//			cog.outl("\tpthread_mutex_lock(&activator->%sLock);" % comp['name']);
+//			cog.outl("\thashMap_remove(activator->%s_services_for_%s, ref);" % (service['name'], comp['name']))
+//			cog.outl("\tif (activator->current_%s_service_for_%s == service) { " % (service['name'], comp['name']))
+//			cog.outl("\t\t%s highest = NULL;" % service['type']);
+//		cog.outl("\t\tbundleActivator_getFirst(activator->%s_services_for_%s, (void **)&highest);" % (service['name'], comp['name']))
+//		cog.outl("\t\tactivator->current_%s_service_for_%s = highest;" % (service['name'], comp['name']))
+//		cog.outl("\t\tbundleActivator_resolveState_for_%s(activator);" % comp['name']);
+//		cog.outl("\t\t%s_set_%s(activator->%s, highest);" % (comp['name'], service['name'], comp['name'])) 
+//		cog.outl("\t}")
+//		cog.outl("\tpthread_mutex_unlock(&activator->%sLock);" % comp['name']);
+//		cog.outl("\treturn status;")
+//		cog.outl("}")
+//		cog.outl("")
 //}}
 static celix_status_t bundleActivator_add_logger_for_example(void *handle, service_reference_pt ref, void *service) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/component.c b/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
index 4be4e9a..68b0a17 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/component.c
@@ -1,9 +1,19 @@
 //{{
-//import json
+//import yaml
 //bundle = None 
 //component = None
 //with open(bundleFile) as input :
-//	bundle = json.load(input)
+//	bundle = yaml.load(input)
+//
+//if not 'components' in bundle or bundle['components'] is None:
+// 	bundle['components'] = []
+//else:
+//	for comp in bundle['components'] : 
+//		if not 'serviceDependencies' in comp or comp['serviceDependencies'] is None:
+//			comp['serviceDependencies'] = []
+//		if not 'providedServices' in comp or comp['providedServices'] is None:
+//			comp['providedServices'] = []
+//
 //for comp in bundle['components'] :
 //	if comp['name'] == componentName :
 //		component = comp
@@ -45,6 +55,7 @@ struct example { //do not edit, generated code
 //{{
 //cog.outl("celix_status_t %s_create(%s_pt *result) {" % (componentName, componentName))
 //cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//cog.outl("printf(\" %s_create called.\\n\");" % (componentName))
 //cog.outl("\t%s_pt component = calloc(1, sizeof(*component));" % componentName)
 //cog.outl("\tif (component != NULL) {")
 //for service in component['serviceDependencies'] :
@@ -79,6 +90,7 @@ celix_status_t example_create(example_pt *result) { //do not edit, generated cod
 //Destroy function
 //{{
 //cog.outl("celix_status_t %s_destroy(%s_pt component) {" % (componentName,componentName))
+//cog.outl("printf(\" %s_destroy called.\\n\");" % (componentName))
 //}}
 celix_status_t example_destroy(example_pt component) { //do not edit, generated code
 //{{end}}
@@ -94,6 +106,7 @@ celix_status_t example_destroy(example_pt component) { //do not edit, generated
 //Start function
 //{{
 //cog.outl("celix_status_t %s_start(%s_pt component) {" % (componentName,componentName))
+//cog.outl("printf(\" %s_start called.\\n\");" % (componentName))
 //}}
 celix_status_t example_start(example_pt component) { //do not edit, generated code
 //{{end}}
@@ -104,6 +117,7 @@ celix_status_t example_start(example_pt component) { //do not edit, generated co
 //Stop function
 //{{
 //cog.outl("celix_status_t %s_stop(%s_pt component) {" % (componentName,componentName))
+//cog.outl("printf(\" %s_stop called.\\n\");" % (componentName))
 //}}
 celix_status_t example_stop(example_pt component) { //do not edit, generated code
 //{{end}}
@@ -116,6 +130,7 @@ celix_status_t example_stop(example_pt component) { //do not edit, generated cod
 //	if service['cardinality'] == "many" :
 //		cog.outl("celix_status_t %s_add_%s(%s_pt component, %s %s) {" % (componentName, service['name'], componentName, service['type'], service['name'])) 
 //		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//		cog.outl("printf(\" %s_add_%s called.\\n\");" % (componentName, service['name']))
 //		cog.outl("\tpthread_mutex_lock(&component->mutex_for_%sServices);" % service['name'])
 //		cog.outl("\tarrayList_add(component->%sServices, %s);" % (service['name'], service['name']))
 //		cog.outl("\tpthread_mutex_unlock(&component->mutex_for_%sServices);" % service['name'])
@@ -132,12 +147,13 @@ celix_status_t example_stop(example_pt component) { //do not edit, generated cod
 //	else :
 //		cog.outl("celix_status_t %s_set_%s(%s_pt component, %s %s) {" % (componentName, service['name'], componentName, service['type'], service['name'])) 
 //		cog.outl("\tcelix_status_t status = CELIX_SUCCESS;")
+//		cog.outl("printf(\" %s_set_%s called.\\n\");" % (componentName, service['name']))
 //		cog.outl("\tpthread_mutex_lock(&component->mutex_for_%s);" % service['name'])
 //		cog.outl("\tcomponent->%s == %s;" % (service['name'], service['name']))
 //		cog.outl("\tpthread_mutex_unlock(&component->mutex_for_%s);" % service['name'])
 //		cog.outl("\treturn status;")
 //		cog.outl("}")
-//	cog.outl("")	
+//		cog.outl("")	
 //}}
 celix_status_t example_set_logger(example_pt component, log_service_pt logger) { //do not edit, generated code
 	celix_status_t status = CELIX_SUCCESS; //do not edit, generated code

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/component.h b/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
index 15fdfba..e036bbd 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/component.h
@@ -1,9 +1,19 @@
 //{{
-//import json
+//import yaml
 //bundle = None 
 //component = None
 //with open(bundleFile) as input :
-//	bundle = json.load(input)
+//	bundle = yaml.load(input)
+//
+//if not 'components' in bundle or bundle['components'] is None:
+// 	bundle['components'] = []
+//else:
+//	for comp in bundle['components'] : 
+//		if not 'serviceDependencies' in comp or comp['serviceDependencies'] is None:
+//			comp['serviceDependencies'] = []
+//		if not 'providedServices' in comp or comp['providedServices'] is None:
+//			comp['providedServices'] = []
+//
 //for comp in bundle['components'] :
 //	if comp['name'] == componentName :
 //		component = comp
@@ -13,9 +23,10 @@
 //cog.outl("#define __%s_H_" % componentName.upper())
 //cog.outl("")
 //
-//for service in component['serviceDependencies'] :
-//	cog.outl("#include <%s>" % service['include'])
-//cog.outl("")
+//if 'serviceDependencies' in comp and comp['serviceDependencies'] is not None:
+//	for service in component['serviceDependencies'] :
+//		cog.outl("#include <%s>" % service['include'])
+//	cog.outl("")
 //
 //}}
 #ifndef __EXAMPLE_H_ //do not edit, generated code

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake b/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake
index 6157f1d..2dbf2cc 100644
--- a/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/deploy.cmake
@@ -1,8 +1,8 @@
 #{{
-#import json
+#import yaml
 #bundle = None 
 #with open(bundleFile) as input :
-#	bundle = json.load(input)
+#	bundle = yaml.load(input)
 #cog.outl("deploy( \"%s\" BUNDLES" % bundle['name'])
 #cog.outl("\t${CELIX_BUNDLES_DIR}/shell.zip")
 #cog.outl("\t${CELIX_BUNDLES_DIR}/shell_tui.zip")

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/bundle/service.h
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/bundle/service.h b/celix-bootstrap/celix/bootstrap/templates/bundle/service.h
new file mode 100644
index 0000000..a6b1fd8
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/bundle/service.h
@@ -0,0 +1,58 @@
+//{{
+//import yaml
+//bundle = None
+//with open(bundleFile) as input :
+//	bundle = yaml.load(input)
+//if not 'components' in bundle or bundle['components'] is None:
+// 	bundle['components'] = []
+//else:
+//	for comp in bundle['components'] : 
+//		if not 'providedServices' in comp or comp['providedServices'] is None:
+//			comp['providedServices'] = []
+//
+//for comp in bundle['components'] :
+//	if comp['name'] == componentName :
+//		component = comp
+//
+//		for serv in comp['providedServices'] :
+//			if serv['name'] == serviceName :
+//				service = serv
+//				break
+//
+//cog.outl("#ifndef __%s_H_" % service['name'].upper())
+//cog.outl("#define __%s_H_" % service['name'].upper())
+//cog.outl("")
+//
+//}}
+#ifndef __EXAMPLE_H_ //do not edit, generated code
+#define __EXAMPLE_H_ //do not edit, generated code
+//{{end}}
+
+//TODO add needed includes
+
+//{{
+//cog.outl("#define %s_SERVICE_NAME \"%s_service\"" % (service['name'].upper(), service['service_name']))
+//cog.outl("")
+//cog.outl("typedef struct %s_service* %s;" % (service['name'], service['type']))
+//cog.outl("")
+//cog.outl("struct %s_service {" % service['name'])
+//cog.outl("\tvoid *handle;")
+//}}
+#define BENCHMARK_SERVICE_NAME "benchmark_service"
+typedef struct benchmark_service *benchmark_service_pt;
+
+struct benchmark_service {
+	benchmark_handler_pt handler;
+//{{end}}}
+
+	//TODO add service methods
+
+//{{
+//cog.outl("};")
+//cog.outl("")
+//cog.outl("")
+//cog.outl("#endif /* __%s_H_ */" % service['name'])
+//}}
+};
+#endif /* BENCHMARK_SERVICE_H_ */
+//{{end}}

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt b/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt
index 04fea0b..b6f7958 100644
--- a/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt
+++ b/celix-bootstrap/celix/bootstrap/templates/project/CMakeLists.txt
@@ -1,8 +1,10 @@
 #{{
-#	import json
-#	project = None 
-#	with open(projectFile) as input :
-#		project = json.load(input)
+#import fnmatch
+#import os
+#import yaml
+#project = None 
+#with open(projectFile) as input :
+#	project = yaml.load(input)
 #}}
 #{{end}}
 
@@ -23,8 +25,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/local/share/celix/cmake/modules
 find_package(CELIX REQUIRED)
 include_directories(${CELIX_INCLUDE_DIRS})
 
-#TODO add sub directory for every bundle
-#e.g. 
-#add_subdirectory(mybundle)
+
+#{{
+#for root, dirs, filenames in os.walk('.'):
+#	for foundFile in fnmatch.filter(filenames, 'bundle.yaml'):
+#		cog.outl("add_subdirectory(%s)" % root)
+#}}
+#
+#{{end}}
 
 deploy_targets()

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/project/project.json
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/project/project.json b/celix-bootstrap/celix/bootstrap/templates/project/project.json
deleted file mode 100644
index db48217..0000000
--- a/celix-bootstrap/celix/bootstrap/templates/project/project.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- 	"name" : "myproject",
-	"celix_install_dir": "/usr/local"
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/project/project.yaml
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/project/project.yaml b/celix-bootstrap/celix/bootstrap/templates/project/project.yaml
new file mode 100644
index 0000000..a7832a9
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/templates/project/project.yaml
@@ -0,0 +1,19 @@
+#{{
+#from celix.bootstrap.celix_utils import *
+#}}
+#{{end}}
+
+
+# {{ 
+# name = checkInput('\nPlease enter projectname', '([a-zA-Z_][a-zA-Z0-9_]*)', 'myproject')
+# cog.outl('name: \"%s\"' % name )
+# }}
+name: "myproject"
+# {{end}}
+
+# {{  
+# install = checkCelixInstallation()
+# cog.outl('celix_install_dir: \"%s\"' % install ) 
+# }}
+celix_install_dir: "/usr/local"
+# {{end}}

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/services/service.h
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/services/service.h b/celix-bootstrap/celix/bootstrap/templates/services/service.h
deleted file mode 100644
index 9a8aae9..0000000
--- a/celix-bootstrap/celix/bootstrap/templates/services/service.h
+++ /dev/null
@@ -1,48 +0,0 @@
-//{{
-//import json
-//services = None
-//service = None
-//with open(descriptorFile) as input :
-//	services = json.load(input)
-//for serv in services :
-//	if serv['name'] == serviceName :
-//		service = serv
-//		break
-//
-//cog.outl("#ifndef __%s_H_" % serviceName.upper())
-//cog.outl("#define __%s_H_" % serviceName.upper())
-//cog.outl("")
-//
-//}}
-#ifndef __EXAMPLE_H_ //do not edit, generated code
-#define __EXAMPLE_H_ //do not edit, generated code
-//{{end}}
-
-//TODO add needed includes
-
-//{{
-//cog.outl("#define %s_SERVICE_NAME \"%s_service\"" % (serviceName.upper(), serviceName))
-//cog.outl("")
-//cog.outl("typedef struct %s_service *%s_service_pt;" % (serviceName, serviceName))
-//cog.outl("")
-//cog.outl("struct %s_service {" % serviceName)
-//cog.outl("\tvoid *handle;")
-//}}
-#define BENCHMARK_SERVICE_NAME "benchmark_service"
-typedef struct benchmark_service *benchmark_service_pt;
-
-struct benchmark_service {
-	benchmark_handler_pt handler;
-//{{end}}}
-
-	//TODO add service methods
-
-//{{
-//cog.outl("};")
-//cog.outl("")
-//cog.outl("")
-//cog.outl("#endif /* __%s_H_ */" % serviceName)
-//}}
-};
-#endif /* BENCHMARK_SERVICE_H_ */
-//{{end}}

http://git-wip-us.apache.org/repos/asf/celix/blob/4feeabc5/celix-bootstrap/celix/bootstrap/templates/services/services.json
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/templates/services/services.json b/celix-bootstrap/celix/bootstrap/templates/services/services.json
deleted file mode 100644
index f6efc03..0000000
--- a/celix-bootstrap/celix/bootstrap/templates/services/services.json
+++ /dev/null
@@ -1,4 +0,0 @@
-[
-	{ "name" : "example1" },
-	{ "name" : "example2" }
-]


[7/9] celix git commit: CELIX-236: Add celix-utils

Posted by bp...@apache.org.
CELIX-236: Add celix-utils


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/27292997
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/27292997
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/27292997

Branch: refs/heads/develop
Commit: 2729299714c4bd9fb66ddef7370128837f50abfb
Parents: e529748
Author: Bjoern Petri <bp...@apache.org>
Authored: Tue Jan 19 12:03:45 2016 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Tue Jan 19 12:03:45 2016 +0100

----------------------------------------------------------------------
 celix-bootstrap/celix/bootstrap/celix_utils.py | 138 ++++++++++++++++++++
 1 file changed, 138 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/27292997/celix-bootstrap/celix/bootstrap/celix_utils.py
----------------------------------------------------------------------
diff --git a/celix-bootstrap/celix/bootstrap/celix_utils.py b/celix-bootstrap/celix/bootstrap/celix_utils.py
new file mode 100644
index 0000000..bcc5667
--- /dev/null
+++ b/celix-bootstrap/celix/bootstrap/celix_utils.py
@@ -0,0 +1,138 @@
+import cmd
+import glob
+import os.path
+import re
+import readline
+import sys
+
+class PathCompleter(object):
+
+    def __init__(self, suffix=None):
+        self.suffix=suffix
+
+    def _listdir(self, root=''):
+        res = []
+        for name in glob.glob(root + '*'): 
+            path = os.path.join(root, name)
+            if os.path.isdir(path):
+                name += os.sep
+            	res.append(name)
+	    else:
+		if self.suffix is None:
+            		res.append(name)
+		elif name.endswith(self.suffix):
+            		res.append(name)
+
+        return res
+
+    def complete(self, text, state):
+        buffer = readline.get_line_buffer()
+        return self._listdir(buffer.strip())[state]
+
+
+class FileContentCompleter(object):
+    def __init__(self, filename, keywords=[]):
+        self._indexFile(filename, keywords)
+
+    def _indexFile(self, filename, keywords=[], delimiter_chars=":;#,.!?{}*)(=\\\"/"):
+        try:
+	    txt_fil = open(filename, "r")
+	    self.found_words = []
+
+            for line in txt_fil:
+		# ignore commented lines
+		if not (line.strip()).startswith(("/*", "*", "//")):
+                    words = line.split()
+                    words2 = [ word.strip(delimiter_chars) for word in words ]
+
+                    for word in words2:
+                        if not word in self.found_words and not word in keywords and not word.isdigit() and not any(i in word for i in delimiter_chars):
+                            self.found_words.append(word)
+
+            txt_fil.close()
+        except IOError as ioe:
+             sys.stderr.write("Caught IOError: " + repr(ioe) + "\n")
+        except Exception as e:
+             sys.stderr.write("Caught Exception: " + repr(e) + "\n")
+
+    def checkWord(self, word):
+        if word in self.found_words:
+		return True
+	else:
+		return False
+
+    def complete(self, text, state):
+        buffr = readline.get_line_buffer()
+	wordlist = [w for w in self.found_words if w.startswith(buffr)]
+
+        return wordlist[state]
+
+def checkInput(msg, regex='', default=''):
+	while True:
+		msgDefault = msg + ' [' + default + ']: ' if default is not '' else msg + ': '
+ 		inpt = raw_input(msgDefault).strip() or default
+		
+		if regex is not '':
+			res = re.match(regex, inpt);
+			if res is not None and inpt == res.group():
+				return inpt
+			else:
+				print('Invalid Input.')
+		else:
+			return inpt
+
+def yn(msg, default = 'y'):
+	while True:
+		addComponent = raw_input("%s [%s]:" % (msg, default)) or default
+      		if addComponent.lower() in ('y', 'yes', 'n', 'no'):
+			return addComponent.lower() in ('y', 'yes')
+		else:
+			print("Invalid Input.")
+
+
+def checkCelixInstallation():
+	while True:
+		comp = PathCompleter()
+		# we want to treat '/' as part of a word, so override the delimiters
+		readline.set_completer_delims(' \t\n;')
+		readline.parse_and_bind("tab: complete")
+		readline.set_completer(comp.complete)
+
+ 		installDir = checkInput('Please enter celix installation location', '(?:/[^/]+)*$', '/usr/local')
+
+		if os.path.exists(installDir + '/bin/celix'):
+			return installDir
+		else:
+			print('celix launcher could not be found at ' + installDir + '/bin/celix')
+
+
+
+def checkInclude(msg, regex):
+	comp = PathCompleter(".h")
+	# we want to treat '/' as part of a word, so override the delimiters
+	readline.set_completer_delims(' \t\n;')
+	readline.parse_and_bind("tab: complete")
+	readline.set_completer(comp.complete)
+
+	headerFile = checkInput(msg, regex)
+
+	return headerFile
+
+def checkIncludeContent(msg, filename):
+	keywords = ["auto","break","case","char","const","continue","define", "default","do","double","else","endif", "enum","extern","float","for","goto","if","ifndef", "include", "inline","int","long","register","restrict","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while", "celix_status_t"];
+
+	comp = None	
+
+	if os.path.exists(filename):
+		comp = FileContentCompleter(filename, keywords)
+		readline.set_completer_delims(' \t\n;')
+		readline.parse_and_bind("tab: complete")
+		readline.set_completer(comp.complete)
+
+	inpt = checkInput(msg, '[^\s]+');
+
+	if comp is not None:
+		while(comp.checkWord(inpt) == False and yn('\''+ inpt + '\'  was not found in the given include file. Do you really want to use it?', 'n') == False):
+			inpt = checkInput(msg, '[^\s]+');
+
+	return inpt


[9/9] celix git commit: Merge branch 'feature/CELIX-236_celix-boostrap' into develop

Posted by bp...@apache.org.
Merge branch 'feature/CELIX-236_celix-boostrap' into develop


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/01136093
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/01136093
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/01136093

Branch: refs/heads/develop
Commit: 01136093e0cac8532340025996188217458ea0f7
Parents: d5666c5 15b41d2
Author: Bjoern Petri <bp...@apache.org>
Authored: Wed Jan 27 15:33:58 2016 +0100
Committer: Bjoern Petri <bp...@apache.org>
Committed: Wed Jan 27 15:33:58 2016 +0100

----------------------------------------------------------------------
 celix-bootstrap/README.md                       |  64 +++
 celix-bootstrap/celix/__init__.py               |   2 +
 celix-bootstrap/celix/bootstrap/__init__.py     |   0
 celix-bootstrap/celix/bootstrap/__main__.py     |   4 +
 .../celix/bootstrap/argument_parser.py          |  77 +++
 celix-bootstrap/celix/bootstrap/celix_utils.py  | 138 ++++++
 celix-bootstrap/celix/bootstrap/generators.py   | 160 ++++++
 .../bootstrap/templates/bundle/CMakeLists.txt   |  71 +++
 .../bootstrap/templates/bundle/bundle.yaml      |  66 +++
 .../templates/bundle/bundle_activator.c         | 483 +++++++++++++++++++
 .../bootstrap/templates/bundle/component.c      | 190 ++++++++
 .../bootstrap/templates/bundle/component.h      |  80 +++
 .../bootstrap/templates/bundle/deploy.cmake     |  18 +
 .../celix/bootstrap/templates/bundle/service.h  |  58 +++
 .../bootstrap/templates/project/CMakeLists.txt  |  37 ++
 .../bootstrap/templates/project/deploy.cmake    |  32 ++
 .../bootstrap/templates/project/project.yaml    |  19 +
 celix-bootstrap/scripts/celix-bootstrap         |   5 +
 celix-bootstrap/setup.py                        |  31 ++
 19 files changed, 1535 insertions(+)
----------------------------------------------------------------------