You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2016/10/16 12:47:01 UTC
[1/8] celix git commit: CELIX-281: Moved fmemopen/open_memstream to
utils. Added usage of open_memstream to bonjour shell for OSX.
Repository: celix
Updated Branches:
refs/heads/develop 652741c91 -> 5e2d7907f
CELIX-281: Moved fmemopen/open_memstream to utils. Added usage of open_memstream to bonjour shell for OSX.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/2c74cc35
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/2c74cc35
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/2c74cc35
Branch: refs/heads/develop
Commit: 2c74cc35b573eb2e0b587065808181286f830362
Parents: 652741c
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Fri Oct 14 21:10:15 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Fri Oct 14 21:10:15 2016 +0200
----------------------------------------------------------------------
dfi/CMakeLists.txt | 8 +-
dfi/private/src/memstream/fmemopen.c | 78 -----------
dfi/private/src/memstream/open_memstream.c | 130 -------------------
dfi/public/include/memstream/README.md | 49 -------
dfi/public/include/memstream/fmemopen.h | 52 --------
dfi/public/include/memstream/open_memstream.h | 15 ---
shell_bonjour/CMakeLists.txt | 8 +-
shell_bonjour/private/src/activator.c | 2 +-
shell_bonjour/private/src/bonjour_shell.c | 15 ++-
utils/private/src/memstream/fmemopen.c | 78 +++++++++++
utils/private/src/memstream/open_memstream.c | 130 +++++++++++++++++++
utils/public/include/memstream/README.md | 49 +++++++
utils/public/include/memstream/fmemopen.h | 52 ++++++++
utils/public/include/memstream/open_memstream.h | 15 +++
14 files changed, 348 insertions(+), 333 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/dfi/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dfi/CMakeLists.txt b/dfi/CMakeLists.txt
index 6fe7071..c672f94 100644
--- a/dfi/CMakeLists.txt
+++ b/dfi/CMakeLists.txt
@@ -28,10 +28,10 @@ include_directories(
set(MEMSTREAM_SOURCES )
set(MEMSTREAM_INCLUDES )
-if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ANDROID)
- set(MEMSTREAM_SOURCES private/src/memstream/open_memstream.c private/src/memstream/fmemopen.c)
- set(MEMSTREAM_INCLUDES public/include/memstream/open_memstream.h public/include/memstream/fmemopen.h)
- include_directories(public/include/memstream)
+if (APPLE OR ANDROID)
+ set(MEMSTREAM_SOURCES ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/open_memstream.c ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/fmemopen.c)
+ set(MEMSTREAM_INCLUDES ${PROJECT_SOURCE_DIR}/utils/public/include/memstream/open_memstream.h ${PROJECT_SOURCE_DIR}/utils/public/include/memstream/fmemopen.h)
+ include_directories(${PROJECT_SOURCE_DIR}/utils/public/include/memstream)
endif()
add_library(celix_dfi SHARED
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/dfi/private/src/memstream/fmemopen.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/memstream/fmemopen.c b/dfi/private/src/memstream/fmemopen.c
deleted file mode 100644
index 66fc9c5..0000000
--- a/dfi/private/src/memstream/fmemopen.c
+++ /dev/null
@@ -1,78 +0,0 @@
-
-/*
- * fmem.c : fmemopen() on top of BSD's funopen()
- * 20081017 AF
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef linux
-struct fmem {
- size_t pos;
- size_t size;
- char *buffer;
-};
-typedef struct fmem fmem_t;
-
-static int readfn(void *handler, char *buf, int size)
-{
- int count = 0;
- fmem_t *mem = handler;
- size_t available = mem->size - mem->pos;
-
- if(size > available) size = available;
- for(count=0; count < size; mem->pos++, count++)
- buf[count] = mem->buffer[mem->pos];
-
- return count;
-}
-
-static int writefn(void *handler, const char *buf, int size)
-{
- int count = 0;
- fmem_t *mem = handler;
- size_t available = mem->size - mem->pos;
-
- if(size > available) size = available;
- for(count=0; count < size; mem->pos++, count++)
- mem->buffer[mem->pos] = buf[count];
-
- return count; // ? count : size;
-}
-
-static fpos_t seekfn(void *handler, fpos_t offset, int whence)
-{
- size_t pos;
- fmem_t *mem = handler;
-
- switch(whence) {
- case SEEK_SET: pos = offset; break;
- case SEEK_CUR: pos = mem->pos + offset; break;
- case SEEK_END: pos = mem->size + offset; break;
- default: return -1;
- }
-
- if(pos > mem->size) return -1;
-
- mem->pos = pos;
- return (fpos_t) pos;
-}
-
-static int closefn(void *handler)
-{
- free(handler);
- return 0;
-}
-
-/* simple, but portable version of fmemopen for OS X / BSD */
-FILE *fmemopen(void *buf, size_t size, const char *mode)
-{
- fmem_t *mem = (fmem_t *) malloc(sizeof(fmem_t));
-
- memset(mem, 0, sizeof(fmem_t));
- mem->size = size, mem->buffer = buf;
- return funopen(mem, readfn, writefn, seekfn, closefn);
-}
-#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/dfi/private/src/memstream/open_memstream.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/memstream/open_memstream.c b/dfi/private/src/memstream/open_memstream.c
deleted file mode 100644
index 6bc4f01..0000000
--- a/dfi/private/src/memstream/open_memstream.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* Use funopen(3) to provide open_memstream(3) like functionality. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-struct memstream {
- char **cp;
- size_t *lenp;
- size_t offset;
-};
-
-static void
-memstream_grow(struct memstream *ms, size_t newsize)
-{
- char *buf;
-
- if (newsize > *ms->lenp) {
- buf = realloc(*ms->cp, newsize + 1);
- if (buf != NULL) {
-#ifdef DEBUG
- fprintf(stderr, "MS: %p growing from %zd to %zd\n",
- ms, *ms->lenp, newsize);
-#endif
- memset(buf + *ms->lenp + 1, 0, newsize - *ms->lenp);
- *ms->cp = buf;
- *ms->lenp = newsize;
- }
- }
-}
-
-static int
-memstream_read(void *cookie, char *buf, int len)
-{
- struct memstream *ms;
- int tocopy;
-
- ms = cookie;
- memstream_grow(ms, ms->offset + len);
- tocopy = *ms->lenp - ms->offset;
- if (len < tocopy)
- tocopy = len;
- memcpy(buf, *ms->cp + ms->offset, tocopy);
- ms->offset += tocopy;
-#ifdef DEBUG
- fprintf(stderr, "MS: read(%p, %d) = %d\n", ms, len, tocopy);
-#endif
- return (tocopy);
-}
-
-static int
-memstream_write(void *cookie, const char *buf, int len)
-{
- struct memstream *ms;
- int tocopy;
-
- ms = cookie;
- memstream_grow(ms, ms->offset + len);
- tocopy = *ms->lenp - ms->offset;
- if (len < tocopy)
- tocopy = len;
- memcpy(*ms->cp + ms->offset, buf, tocopy);
- ms->offset += tocopy;
-#ifdef DEBUG
- fprintf(stderr, "MS: write(%p, %d) = %d\n", ms, len, tocopy);
-#endif
- return (tocopy);
-}
-
-static fpos_t
-memstream_seek(void *cookie, fpos_t pos, int whence)
-{
- struct memstream *ms;
-#ifdef DEBUG
- size_t old;
-#endif
-
- ms = cookie;
-#ifdef DEBUG
- old = ms->offset;
-#endif
- switch (whence) {
- case SEEK_SET:
- ms->offset = pos;
- break;
- case SEEK_CUR:
- ms->offset += pos;
- break;
- case SEEK_END:
- ms->offset = *ms->lenp + pos;
- break;
- }
-#ifdef DEBUG
- fprintf(stderr, "MS: seek(%p, %zd, %d) %zd -> %zd\n", ms, pos, whence,
- old, ms->offset);
-#endif
- return (ms->offset);
-}
-
-static int
-memstream_close(void *cookie)
-{
-
- free(cookie);
- return (0);
-}
-
-FILE *
-open_memstream(char **cp, size_t *lenp)
-{
- struct memstream *ms;
- int save_errno;
- FILE *fp;
-
- *cp = NULL;
- *lenp = 0;
- ms = malloc(sizeof(*ms));
- ms->cp = cp;
- ms->lenp = lenp;
- ms->offset = 0;
- fp = funopen(ms, memstream_read, memstream_write, memstream_seek,
- memstream_close);
- if (fp == NULL) {
- save_errno = errno;
- free(ms);
- errno = save_errno;
- }
- return (fp);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/dfi/public/include/memstream/README.md
----------------------------------------------------------------------
diff --git a/dfi/public/include/memstream/README.md b/dfi/public/include/memstream/README.md
deleted file mode 100644
index 476810e..0000000
--- a/dfi/public/include/memstream/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-fmemopen for Mac OS and iOS
-===========================
-
-Originally ported from [ingenuitas python-tesseract](https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c). Ported by Jeff Verkoeyen under the Apache 2.0 License.
-
-From the fmemopen man page:
-
-> FILE *fmemopen(void *buf, size_t size, const char *mode);
->
-> The fmemopen() function opens a stream that permits the access specified by mode. The stream
-> allows I/O to be performed on the string or memory buffer pointed to by buf. This buffer must be
-> at least size bytes long.
-
-Alas, this method does not exist on BSD operating systems (specifically Mac OS X and iOS). It is
-possible to recreate this functionality using a BSD-specific method called `funopen`.
-
-From the funopen man page:
-
-> FILE * funopen(const void *cookie, int (*readfn)(void *, char *, int),
-> int (*writefn)(void *, const char *, int), fpos_t (*seekfn)(void *, fpos_t, int),
-> int (*closefn)(void *));
->
-> The funopen() function associates a stream with up to four ``I/O functions''. Either readfn or
-> writefn must be specified; the others can be given as an appropriately-typed NULL pointer. These
-> I/O functions will be used to read, write, seek and close the new stream.
-
-fmemopen.c provides a simple implementation of fmemopen using funopen so that you can create FILE
-pointers to blocks of memory.
-
-Adding it to your Project
-=========================
-
-Drag fmemopen.h and fmemopen.c to your project and add them to your target. `#include "fmemopen.h"`
-wherever you need to use `fmemopen`.
-
-Examples
-========
-
-```obj-c
-#import "fmemopen.h"
-
-NSString* string = @"fmemopen in Objective-C";
-const char* cstr = [string UTF8String];
-FILE* file = fmemopen((void *)cstr, sizeof(char) * (string.length + 1), "r");
-
-// fread on file will now read the contents of the NSString
-
-fclose(file);
-```
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/dfi/public/include/memstream/fmemopen.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/memstream/fmemopen.h b/dfi/public/include/memstream/fmemopen.h
deleted file mode 100644
index 3d06b20..0000000
--- a/dfi/public/include/memstream/fmemopen.h
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Copyright 2012 Jeff Verkoeyen
-// Originally ported from https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#ifndef FMEMOPEN_H_
-#define FMEMOPEN_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**
- * A BSD port of the fmemopen Linux method using funopen.
- *
- * man docs for fmemopen:
- * http://linux.die.net/man/3/fmemopen
- *
- * man docs for funopen:
- * https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html
- *
- * This method is ported from ingenuitas' python-tesseract project.
- *
- * You must call fclose on the returned file pointer or memory will be leaked.
- *
- * @param buf The data that will be used to back the FILE* methods. Must be at least
- * @c size bytes.
- * @param size The size of the @c buf data.
- * @param mode The permitted stream operation modes.
- * @returns A pointer that can be used in the fread/fwrite/fseek/fclose family of methods.
- * If a failure occurred NULL will be returned.
- */
-FILE *fmemopen(void *buf, size_t size, const char *mode);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // #ifndef FMEMOPEN_H_
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/dfi/public/include/memstream/open_memstream.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/memstream/open_memstream.h b/dfi/public/include/memstream/open_memstream.h
deleted file mode 100644
index e87bb0a..0000000
--- a/dfi/public/include/memstream/open_memstream.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef OPEN_MEMSTREAM_H_
-#define OPEN_MEMSTREAM_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-FILE *open_memstream(char **cp, size_t *lenp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // #ifndef FMEMOPEN_H_
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/shell_bonjour/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/shell_bonjour/CMakeLists.txt b/shell_bonjour/CMakeLists.txt
index 38ef9a1..300fef0 100644
--- a/shell_bonjour/CMakeLists.txt
+++ b/shell_bonjour/CMakeLists.txt
@@ -30,12 +30,18 @@ if (SHELL_BONJOUR)
include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
include_directories("${LIBXML2_INCLUDE_DIR}")
include_directories("private/include")
-
+
+ set(MEMSTREAM_SOURCES )
+ if (APPLE OR ANDROID)
+ set(MEMSTREAM_SOURCES ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/open_memstream.c ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/fmemopen.c)
+ include_directories(${PROJECT_SOURCE_DIR}/utils/public/include/memstream)
+ endif()
add_bundle(bonjour_shell
VERSION "1.0.0"
SOURCES
private/src/activator.c
private/src/bonjour_shell.c
+ ${MEMSTREAM_SOURCES}
)
target_link_libraries(bonjour_shell celix_framework celix_utils ${LIBXML2_LIBRARIES} ${DNS_SD_LIB})
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/shell_bonjour/private/src/activator.c
----------------------------------------------------------------------
diff --git a/shell_bonjour/private/src/activator.c b/shell_bonjour/private/src/activator.c
index 75340b2..e05211d 100644
--- a/shell_bonjour/private/src/activator.c
+++ b/shell_bonjour/private/src/activator.c
@@ -73,7 +73,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
char id[128];
if (bonjourShellId != NULL) {
- snprintf(id, 128, bonjourShellId);
+ snprintf(id, 128, "%s", bonjourShellId);
} else if (hostname != NULL) {
snprintf(id, 128, "Celix-%.8s@%s", uuid, hostname);
} else {
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/shell_bonjour/private/src/bonjour_shell.c
----------------------------------------------------------------------
diff --git a/shell_bonjour/private/src/bonjour_shell.c b/shell_bonjour/private/src/bonjour_shell.c
index a93d3e1..59ee18a 100644
--- a/shell_bonjour/private/src/bonjour_shell.c
+++ b/shell_bonjour/private/src/bonjour_shell.c
@@ -40,6 +40,11 @@
#include <celixbool.h>
#include <shell.h>
+#if defined(BSD) || defined(__APPLE__) || defined(ANDROID)
+#include "open_memstream.h"
+#include "fmemopen.h"
+#endif
+
#define MAX_BUFFER_SIZE 5120
//static xmlBufferPtr buf; //FOR DEBUG
@@ -358,9 +363,13 @@ static void bonjourShell_parseCommand(bonjour_shell_pt shell, struct connection_
static void bonjourShell_addDataToCurrentContext(const char* out, const char* err) {
pthread_mutex_lock(¤tContext->mutex);
- arrayList_add(currentContext->dataList, strdup(out));
- arrayList_add(currentContext->dataList, strdup(err));
- gettimeofday(¤tContext->lastUpdated, NULL);
+ if (out != NULL) {
+ arrayList_add(currentContext->dataList, strdup(out));
+ }
+ if (err != NULL) {
+ arrayList_add(currentContext->dataList, strdup(err));
+ }
+ gettimeofday(¤tContext->lastUpdated, NULL);
pthread_mutex_unlock(¤tContext->mutex);
pthread_cond_signal(¤tContext->dataAvailCond);
}
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/utils/private/src/memstream/fmemopen.c
----------------------------------------------------------------------
diff --git a/utils/private/src/memstream/fmemopen.c b/utils/private/src/memstream/fmemopen.c
new file mode 100644
index 0000000..66fc9c5
--- /dev/null
+++ b/utils/private/src/memstream/fmemopen.c
@@ -0,0 +1,78 @@
+
+/*
+ * fmem.c : fmemopen() on top of BSD's funopen()
+ * 20081017 AF
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef linux
+struct fmem {
+ size_t pos;
+ size_t size;
+ char *buffer;
+};
+typedef struct fmem fmem_t;
+
+static int readfn(void *handler, char *buf, int size)
+{
+ int count = 0;
+ fmem_t *mem = handler;
+ size_t available = mem->size - mem->pos;
+
+ if(size > available) size = available;
+ for(count=0; count < size; mem->pos++, count++)
+ buf[count] = mem->buffer[mem->pos];
+
+ return count;
+}
+
+static int writefn(void *handler, const char *buf, int size)
+{
+ int count = 0;
+ fmem_t *mem = handler;
+ size_t available = mem->size - mem->pos;
+
+ if(size > available) size = available;
+ for(count=0; count < size; mem->pos++, count++)
+ mem->buffer[mem->pos] = buf[count];
+
+ return count; // ? count : size;
+}
+
+static fpos_t seekfn(void *handler, fpos_t offset, int whence)
+{
+ size_t pos;
+ fmem_t *mem = handler;
+
+ switch(whence) {
+ case SEEK_SET: pos = offset; break;
+ case SEEK_CUR: pos = mem->pos + offset; break;
+ case SEEK_END: pos = mem->size + offset; break;
+ default: return -1;
+ }
+
+ if(pos > mem->size) return -1;
+
+ mem->pos = pos;
+ return (fpos_t) pos;
+}
+
+static int closefn(void *handler)
+{
+ free(handler);
+ return 0;
+}
+
+/* simple, but portable version of fmemopen for OS X / BSD */
+FILE *fmemopen(void *buf, size_t size, const char *mode)
+{
+ fmem_t *mem = (fmem_t *) malloc(sizeof(fmem_t));
+
+ memset(mem, 0, sizeof(fmem_t));
+ mem->size = size, mem->buffer = buf;
+ return funopen(mem, readfn, writefn, seekfn, closefn);
+}
+#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/utils/private/src/memstream/open_memstream.c
----------------------------------------------------------------------
diff --git a/utils/private/src/memstream/open_memstream.c b/utils/private/src/memstream/open_memstream.c
new file mode 100644
index 0000000..6bc4f01
--- /dev/null
+++ b/utils/private/src/memstream/open_memstream.c
@@ -0,0 +1,130 @@
+/* Use funopen(3) to provide open_memstream(3) like functionality. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+struct memstream {
+ char **cp;
+ size_t *lenp;
+ size_t offset;
+};
+
+static void
+memstream_grow(struct memstream *ms, size_t newsize)
+{
+ char *buf;
+
+ if (newsize > *ms->lenp) {
+ buf = realloc(*ms->cp, newsize + 1);
+ if (buf != NULL) {
+#ifdef DEBUG
+ fprintf(stderr, "MS: %p growing from %zd to %zd\n",
+ ms, *ms->lenp, newsize);
+#endif
+ memset(buf + *ms->lenp + 1, 0, newsize - *ms->lenp);
+ *ms->cp = buf;
+ *ms->lenp = newsize;
+ }
+ }
+}
+
+static int
+memstream_read(void *cookie, char *buf, int len)
+{
+ struct memstream *ms;
+ int tocopy;
+
+ ms = cookie;
+ memstream_grow(ms, ms->offset + len);
+ tocopy = *ms->lenp - ms->offset;
+ if (len < tocopy)
+ tocopy = len;
+ memcpy(buf, *ms->cp + ms->offset, tocopy);
+ ms->offset += tocopy;
+#ifdef DEBUG
+ fprintf(stderr, "MS: read(%p, %d) = %d\n", ms, len, tocopy);
+#endif
+ return (tocopy);
+}
+
+static int
+memstream_write(void *cookie, const char *buf, int len)
+{
+ struct memstream *ms;
+ int tocopy;
+
+ ms = cookie;
+ memstream_grow(ms, ms->offset + len);
+ tocopy = *ms->lenp - ms->offset;
+ if (len < tocopy)
+ tocopy = len;
+ memcpy(*ms->cp + ms->offset, buf, tocopy);
+ ms->offset += tocopy;
+#ifdef DEBUG
+ fprintf(stderr, "MS: write(%p, %d) = %d\n", ms, len, tocopy);
+#endif
+ return (tocopy);
+}
+
+static fpos_t
+memstream_seek(void *cookie, fpos_t pos, int whence)
+{
+ struct memstream *ms;
+#ifdef DEBUG
+ size_t old;
+#endif
+
+ ms = cookie;
+#ifdef DEBUG
+ old = ms->offset;
+#endif
+ switch (whence) {
+ case SEEK_SET:
+ ms->offset = pos;
+ break;
+ case SEEK_CUR:
+ ms->offset += pos;
+ break;
+ case SEEK_END:
+ ms->offset = *ms->lenp + pos;
+ break;
+ }
+#ifdef DEBUG
+ fprintf(stderr, "MS: seek(%p, %zd, %d) %zd -> %zd\n", ms, pos, whence,
+ old, ms->offset);
+#endif
+ return (ms->offset);
+}
+
+static int
+memstream_close(void *cookie)
+{
+
+ free(cookie);
+ return (0);
+}
+
+FILE *
+open_memstream(char **cp, size_t *lenp)
+{
+ struct memstream *ms;
+ int save_errno;
+ FILE *fp;
+
+ *cp = NULL;
+ *lenp = 0;
+ ms = malloc(sizeof(*ms));
+ ms->cp = cp;
+ ms->lenp = lenp;
+ ms->offset = 0;
+ fp = funopen(ms, memstream_read, memstream_write, memstream_seek,
+ memstream_close);
+ if (fp == NULL) {
+ save_errno = errno;
+ free(ms);
+ errno = save_errno;
+ }
+ return (fp);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/utils/public/include/memstream/README.md
----------------------------------------------------------------------
diff --git a/utils/public/include/memstream/README.md b/utils/public/include/memstream/README.md
new file mode 100644
index 0000000..476810e
--- /dev/null
+++ b/utils/public/include/memstream/README.md
@@ -0,0 +1,49 @@
+fmemopen for Mac OS and iOS
+===========================
+
+Originally ported from [ingenuitas python-tesseract](https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c). Ported by Jeff Verkoeyen under the Apache 2.0 License.
+
+From the fmemopen man page:
+
+> FILE *fmemopen(void *buf, size_t size, const char *mode);
+>
+> The fmemopen() function opens a stream that permits the access specified by mode. The stream
+> allows I/O to be performed on the string or memory buffer pointed to by buf. This buffer must be
+> at least size bytes long.
+
+Alas, this method does not exist on BSD operating systems (specifically Mac OS X and iOS). It is
+possible to recreate this functionality using a BSD-specific method called `funopen`.
+
+From the funopen man page:
+
+> FILE * funopen(const void *cookie, int (*readfn)(void *, char *, int),
+> int (*writefn)(void *, const char *, int), fpos_t (*seekfn)(void *, fpos_t, int),
+> int (*closefn)(void *));
+>
+> The funopen() function associates a stream with up to four ``I/O functions''. Either readfn or
+> writefn must be specified; the others can be given as an appropriately-typed NULL pointer. These
+> I/O functions will be used to read, write, seek and close the new stream.
+
+fmemopen.c provides a simple implementation of fmemopen using funopen so that you can create FILE
+pointers to blocks of memory.
+
+Adding it to your Project
+=========================
+
+Drag fmemopen.h and fmemopen.c to your project and add them to your target. `#include "fmemopen.h"`
+wherever you need to use `fmemopen`.
+
+Examples
+========
+
+```obj-c
+#import "fmemopen.h"
+
+NSString* string = @"fmemopen in Objective-C";
+const char* cstr = [string UTF8String];
+FILE* file = fmemopen((void *)cstr, sizeof(char) * (string.length + 1), "r");
+
+// fread on file will now read the contents of the NSString
+
+fclose(file);
+```
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/utils/public/include/memstream/fmemopen.h
----------------------------------------------------------------------
diff --git a/utils/public/include/memstream/fmemopen.h b/utils/public/include/memstream/fmemopen.h
new file mode 100644
index 0000000..3d06b20
--- /dev/null
+++ b/utils/public/include/memstream/fmemopen.h
@@ -0,0 +1,52 @@
+//
+// Copyright 2012 Jeff Verkoeyen
+// Originally ported from https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef FMEMOPEN_H_
+#define FMEMOPEN_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * A BSD port of the fmemopen Linux method using funopen.
+ *
+ * man docs for fmemopen:
+ * http://linux.die.net/man/3/fmemopen
+ *
+ * man docs for funopen:
+ * https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html
+ *
+ * This method is ported from ingenuitas' python-tesseract project.
+ *
+ * You must call fclose on the returned file pointer or memory will be leaked.
+ *
+ * @param buf The data that will be used to back the FILE* methods. Must be at least
+ * @c size bytes.
+ * @param size The size of the @c buf data.
+ * @param mode The permitted stream operation modes.
+ * @returns A pointer that can be used in the fread/fwrite/fseek/fclose family of methods.
+ * If a failure occurred NULL will be returned.
+ */
+FILE *fmemopen(void *buf, size_t size, const char *mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef FMEMOPEN_H_
http://git-wip-us.apache.org/repos/asf/celix/blob/2c74cc35/utils/public/include/memstream/open_memstream.h
----------------------------------------------------------------------
diff --git a/utils/public/include/memstream/open_memstream.h b/utils/public/include/memstream/open_memstream.h
new file mode 100644
index 0000000..e87bb0a
--- /dev/null
+++ b/utils/public/include/memstream/open_memstream.h
@@ -0,0 +1,15 @@
+#ifndef OPEN_MEMSTREAM_H_
+#define OPEN_MEMSTREAM_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+FILE *open_memstream(char **cp, size_t *lenp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef FMEMOPEN_H_
[8/8] celix git commit: CELIX-376: Fixes an error for wronly printing
about dandling references, not sure when it was introduced
Posted by pn...@apache.org.
CELIX-376: Fixes an error for wronly printing about dandling references, not sure when it was introduced
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/5e2d7907
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/5e2d7907
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/5e2d7907
Branch: refs/heads/develop
Commit: 5e2d7907f22613ce3e033b3cb8e8d99075ab096e
Parents: 505f6a8
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Sun Oct 16 14:48:41 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Sun Oct 16 14:48:41 2016 +0200
----------------------------------------------------------------------
.../private/src/dm_service_dependency.c | 47 +++++++--------
framework/private/src/bundle.c | 3 +-
framework/private/src/module.c | 2 +-
framework/private/src/service_reference.c | 12 ++--
framework/private/src/service_registration.c | 5 +-
framework/private/src/service_registry.c | 61 ++++++++++++--------
6 files changed, 71 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/5e2d7907/dependency_manager/private/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_service_dependency.c b/dependency_manager/private/src/dm_service_dependency.c
index 3c5d2a0..233593c 100644
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ b/dependency_manager/private/src/dm_service_dependency.c
@@ -396,7 +396,6 @@ celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) {
celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
celix_status_t status = CELIX_SUCCESS;
- celix_status_t tmp_status;
if (!dependency) {
status = CELIX_ILLEGAL_ARGUMENT;
@@ -406,16 +405,11 @@ celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
dependency->isStarted = false;
}
- if (status == CELIX_SUCCESS) {
- if (dependency->tracker) {
- tmp_status = serviceTracker_close(dependency->tracker);
- if (tmp_status != CELIX_SUCCESS) {
- status = tmp_status;
- }
- tmp_status = serviceTracker_destroy(dependency->tracker);
- if (tmp_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
- status = tmp_status;
- }
+ if (status == CELIX_SUCCESS && dependency->tracker) {
+ status = serviceTracker_close(dependency->tracker);
+ if (status == CELIX_SUCCESS) {
+ serviceTracker_destroy(dependency->tracker);
+ dependency->tracker = NULL;
}
}
@@ -485,29 +479,30 @@ celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency,
curServRef = serviceReference;
}
} else {
- arrayList_destroy(serviceReferences);
- return status;
+ break;
}
}
arrayList_destroy(serviceReferences);
- if (curServRef) {
- status = bundleContext_getService(event->context, curServRef, &service);
- } else {
- service = NULL;
- }
+ if (status == CELIX_SUCCESS) {
+ if (curServRef) {
+ status = bundleContext_getService(event->context, curServRef, &service);
+ } else {
+ service = NULL;
+ }
- if (dependency->set) {
- dependency->set(serviceDependency_getCallbackHandle(dependency), service);
- }
- if (dependency->set_with_ref) {
- dependency->set_with_ref(serviceDependency_getCallbackHandle(dependency), curServRef, service);
- }
+ if (dependency->set) {
+ dependency->set(serviceDependency_getCallbackHandle(dependency), service);
+ }
+ if (dependency->set_with_ref) {
+ dependency->set_with_ref(serviceDependency_getCallbackHandle(dependency), curServRef, service);
+ }
- if (curServRef) {
- bundleContext_ungetService(event->context, curServRef, NULL);
+ if (curServRef) {
+ bundleContext_ungetService(event->context, curServRef, NULL);
+ }
}
return status;
http://git-wip-us.apache.org/repos/asf/celix/blob/5e2d7907/framework/private/src/bundle.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle.c b/framework/private/src/bundle.c
index 9e957d6..a0e6b3d 100644
--- a/framework/private/src/bundle.c
+++ b/framework/private/src/bundle.c
@@ -142,13 +142,12 @@ celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive) {
celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module) {
celix_status_t status = CELIX_SUCCESS;
- if (bundle == NULL || *module != NULL || arrayList_size(bundle->modules)==0 ) {
+ if (bundle == NULL || arrayList_size(bundle->modules)==0 ) {
status = CELIX_ILLEGAL_ARGUMENT;
} else {
*module = arrayList_get(bundle->modules, arrayList_size(bundle->modules) - 1);
}
-
return status;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/5e2d7907/framework/private/src/module.c
----------------------------------------------------------------------
diff --git a/framework/private/src/module.c b/framework/private/src/module.c
index 6d64f9f..e81a1ee 100644
--- a/framework/private/src/module.c
+++ b/framework/private/src/module.c
@@ -177,7 +177,7 @@ version_pt module_getVersion(module_pt module) {
celix_status_t module_getSymbolicName(module_pt module, const char **symbolicName) {
celix_status_t status = CELIX_SUCCESS;
- if (module == NULL || *symbolicName != NULL) {
+ if (module == NULL) {
status = CELIX_ILLEGAL_ARGUMENT;
} else {
*symbolicName = module->symbolicName;
http://git-wip-us.apache.org/repos/asf/celix/blob/5e2d7907/framework/private/src/service_reference.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_reference.c b/framework/private/src/service_reference.c
index b89aaf2..545426d 100644
--- a/framework/private/src/service_reference.c
+++ b/framework/private/src/service_reference.c
@@ -193,10 +193,14 @@ celix_status_t serviceReference_getOwner(service_reference_pt ref, bundle_pt *ow
}
celix_status_t serviceReference_getServiceRegistration(service_reference_pt ref, service_registration_pt *out) {
- celixThreadRwlock_readLock(&ref->lock);
- *out = ref->registration;
- celixThreadRwlock_unlock(&ref->lock);
- return CELIX_SUCCESS;
+ if (ref != NULL) {
+ celixThreadRwlock_readLock(&ref->lock);
+ *out = ref->registration;
+ celixThreadRwlock_unlock(&ref->lock);
+ return CELIX_SUCCESS;
+ } else {
+ return CELIX_ILLEGAL_ARGUMENT;
+ }
}
celix_status_t serviceReference_getProperty(service_reference_pt ref, const char* key, const char** value) {
http://git-wip-us.apache.org/repos/asf/celix/blob/5e2d7907/framework/private/src/service_registration.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registration.c b/framework/private/src/service_registration.c
index e2932f9..e916457 100644
--- a/framework/private/src/service_registration.c
+++ b/framework/private/src/service_registration.c
@@ -255,7 +255,10 @@ celix_status_t serviceRegistration_setProperties(service_registration_pt registr
celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle) {
- celix_status_t status = CELIX_SUCCESS;
+ celix_status_t status = CELIX_SUCCESS;
+ if (registration == NULL) {
+ return CELIX_ILLEGAL_ARGUMENT;
+ }
if (registration != NULL && *bundle == NULL) {
celixThreadRwlock_readLock(®istration->lock);
http://git-wip-us.apache.org/repos/asf/celix/blob/5e2d7907/framework/private/src/service_registry.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registry.c b/framework/private/src/service_registry.c
index 139ee70..c0dafc7 100644
--- a/framework/private/src/service_registry.c
+++ b/framework/private/src/service_registry.c
@@ -44,7 +44,7 @@
static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration);
static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, const char* serviceName, const void *serviceObject, service_registration_pt registration);
static celix_status_t serviceRegistry_removeHook(service_registry_pt registry, service_registration_pt registration);
-static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry, size_t usageCount, size_t refCount);
+static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry, bundle_pt bundle, service_reference_pt ref, size_t usageCount, size_t refCount);
static void serviceRegistry_logWarningServiceRegistration(service_registry_pt registry, service_registration_pt reg);
static celix_status_t serviceRegistry_checkReference(service_registry_pt registry, service_reference_pt ref,
reference_status_t *refStatus);
@@ -448,30 +448,30 @@ celix_status_t serviceRegistry_ungetServiceReference(service_registry_pt registr
if (destroyed) {
if (count > 0) {
- serviceRegistry_logWarningServiceReferenceUsageCount(registry, count, 0);
+ serviceRegistry_logWarningServiceReferenceUsageCount(registry, bundle, reference, count, 0);
}
hash_map_pt refsMap = hashMap_get(registry->serviceReferences, bundle);
- unsigned long reg = 0UL;
+ unsigned long refId = 0UL;
service_reference_pt ref = NULL;
hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
while (hashMapIterator_hasNext(iter)) {
hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
- reg = (unsigned long)hashMapEntry_getKey(entry); //note could be invalid e.g. freed
+ refId = (unsigned long)hashMapEntry_getKey(entry); //note could be invalid e.g. freed
ref = hashMapEntry_getValue(entry);
if (ref == reference) {
break;
} else {
ref = NULL;
- reg = 0UL;
+ refId = 0UL;
}
}
hashMapIterator_destroy(iter);
if (ref != NULL) {
- hashMap_remove(refsMap, (void*)reg);
+ hashMap_remove(refsMap, (void*)refId);
int size = hashMap_size(refsMap);
if (size == 0) {
hashMap_destroy(refsMap, false, false);
@@ -527,12 +527,35 @@ static celix_status_t serviceRegistry_checkReference(service_registry_pt registr
return status;
}
-static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry __attribute__((unused)), size_t usageCount, size_t refCount) {
+static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registry_pt registry __attribute__((unused)), bundle_pt bundle, service_reference_pt ref, size_t usageCount, size_t refCount) {
if (usageCount > 0) {
- fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Service Reference destroyed with usage count is %zu. Look for missing bundleContext_ungetService calls.", usageCount);
+ fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Service Reference destroyed with usage count is %zu, expected 0. Look for missing bundleContext_ungetService calls.", usageCount);
}
- if (refCount > 0) {
- fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Dangling service reference. Reference count is %zu. Look for missing bundleContext_ungetServiceReference calls.", refCount);
+ if (refCount > 1) {
+ fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Dangling service reference. Reference count is %zu, expected 1. Look for missing bundleContext_ungetServiceReference calls.", refCount);
+ }
+
+ if(usageCount > 0 || refCount > 1) {
+ module_pt module_ptr = NULL;
+ bundle_getCurrentModule(bundle, &module_ptr);
+ const char* bundle_name = NULL;
+ module_getSymbolicName(module_ptr, &bundle_name);
+
+ const char* service_name = "unknown";
+ const char* bundle_provider_name = "unknown";
+ if (ref != NULL) {
+ serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &service_name);
+
+ service_registration_pt reg = NULL;
+ bundle_pt bundle = NULL;
+ module_pt mod = NULL;
+ serviceReference_getServiceRegistration(ref, ®);
+ serviceRegistration_getBundle(reg, &bundle);
+ bundle_getCurrentModule(bundle, &mod);
+ module_getSymbolicName(mod, &bundle_provider_name);
+ }
+
+ fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "Previous Dangling service reference warnings caused by bundle '%s', for service '%s', provided by bundle '%s'", bundle_name, service_name, bundle_provider_name);
}
}
@@ -540,7 +563,6 @@ static void serviceRegistry_logWarningServiceReferenceUsageCount(service_registr
celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry, bundle_pt bundle) {
celix_status_t status = CELIX_SUCCESS;
- int echoName =0;
celixThreadRwlock_writeLock(®istry->lock);
hash_map_pt refsMap = hashMap_remove(registry->serviceReferences, bundle);
@@ -553,12 +575,10 @@ celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry,
serviceReference_getUsageCount(ref, &usageCount);
serviceReference_getReferenceCount(ref, &refCount);
- if(refCount>0)
- {
- echoName++;
- }
- serviceRegistry_logWarningServiceReferenceUsageCount(registry, usageCount, refCount);
+ if (refCount > 1 || usageCount > 0) {
+ serviceRegistry_logWarningServiceReferenceUsageCount(registry, bundle, ref, usageCount, refCount);
+ }
while (usageCount > 0) {
serviceReference_decreaseUsage(ref, &usageCount);
@@ -575,15 +595,6 @@ celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry,
hashMap_destroy(refsMap, false, false);
}
- if(echoName >0)
- {
- module_pt module_ptr = NULL;
- bundle_getCurrentModule(bundle, &module_ptr);
- const char *name_str = NULL;
- module_getSymbolicName(module_ptr, &name_str);
- fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING,"Previous Dangling service reference warnings caused by bundle: %s",name_str);
- }
-
celixThreadRwlock_unlock(®istry->lock);
return status;
[4/8] celix git commit: CELIX-282: Removes superfluous examples.
Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/producer/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/producer/private/src/activator.c b/examples/producer_consumer/producer/private/src/activator.c
deleted file mode 100644
index 914b982..0000000
--- a/examples/producer_consumer/producer/private/src/activator.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * activator.c
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-
-#include <unistd.h>
-
-#include <sys/time.h>
-#include <stdlib.h>
-#include <bundle_activator.h>
-#include <service_tracker.h>
-#include <constants.h>
-
-#include <array_list.h>
-
-#include "writer_service.h"
-#include "data.h"
-
-struct activator {
- service_tracker_pt tracker;
- array_list_pt readerServices;
- bool running;
- celix_thread_t worker;
-};
-
-celix_status_t writerServiceAdded(void *handle, service_reference_pt reference, void *service);
-celix_status_t writerServiceRemoved(void *handle, service_reference_pt reference, void *service);
-
-int globalDataId = 0;
-
-void *produceData(void *handle);
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- celix_status_t status = CELIX_SUCCESS;
- *userData = calloc(1, sizeof(struct activator));
- if (*userData) {
- ((struct activator *) *userData)->tracker = NULL;
- ((struct activator *) *userData)->readerServices = NULL;
- ((struct activator *) *userData)->running = false;
- ((struct activator *) *userData)->worker = celix_thread_default;
- } 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;
-
- // create list for services
- arrayList_create(&activator->readerServices);
-
- // start the thread
- activator->running = true;
- status = celixThread_create(&activator->worker, NULL, produceData, activator);
-
- if (status == CELIX_SUCCESS) {
- service_tracker_customizer_pt customizer = NULL;
- serviceTrackerCustomizer_create(userData, NULL, writerServiceAdded, NULL, writerServiceRemoved, &customizer);
-
- serviceTracker_create(context, WRITER_SERVICE_NAME, customizer, &activator->tracker);
- serviceTracker_open(activator->tracker);
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
-
- // stop the thread
- activator->running = false;
- celixThread_join(activator->worker, NULL);
-
- serviceTracker_close(activator->tracker);
- serviceTracker_destroy(activator->tracker);
-
- // destroy the list of services
- arrayList_destroy(activator->readerServices);
-
- return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
-
- free(activator);
-
- return status;
-}
-
-celix_status_t writerServiceAdded(void *handle, service_reference_pt reference, void *service) {
- struct activator *activator = handle;
- arrayList_add(activator->readerServices, service);
- printf("Producer: Writer Service Added.\n");
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t writerServiceRemoved(void *handle, service_reference_pt reference, void *service) {
- struct activator *activator = handle;
- arrayList_removeElement(activator->readerServices, service);
- printf("Producer: Writer Service Removed.\n");
-
- return CELIX_SUCCESS;
-}
-
-void *produceData(void *handle) {
- struct activator *activator = handle;
-
- while (activator->running) {
- int i;
- for (i = 0; i < arrayList_size(activator->readerServices); i++) {
- writer_service_pt service = arrayList_get(activator->readerServices, i);
- data_pt newData = calloc(1, sizeof(struct data));
-
- newData->id = globalDataId++;
- snprintf(newData->description, 100, "%d : Some Description", newData->id);
-
- if (service->writerService_storeData(service->handler, newData) == CELIX_SUCCESS) {
- printf(" Data #%d stored.\n", newData->id);
- } else {
- printf(" Could not store data. \n");
- }
-
- srand(time(NULL));
- int r = rand() % 100;
-
- if (r > 70)
- sleep(10);
- }
- }
-
- return NULL;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/whiteboard/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/whiteboard/CMakeLists.txt b/examples/whiteboard/CMakeLists.txt
index 5f01b87..b904241 100644
--- a/examples/whiteboard/CMakeLists.txt
+++ b/examples/whiteboard/CMakeLists.txt
@@ -18,4 +18,7 @@
add_subdirectory(publisherA)
add_subdirectory(publisherB)
add_subdirectory(tracker)
-add_subdirectory(tracker_depman)
\ No newline at end of file
+add_subdirectory(tracker_depman)
+
+add_deploy("whiteboard" GROUP whiteboard BUNDLES tracker publisherA publisherB shell shell_tui log_service log_writer)
+add_deploy("whiteboard_dependency_manager" GROUP whiteboard BUNDLES tracker_depman publisherA publisherB shell shell_tui log_service log_writer dm_shell)
\ No newline at end of file
[3/8] celix git commit: CELIX-381: Invokeset now called after suspend
for dependency in a dm component.
Posted by pn...@apache.org.
CELIX-381: Invokeset now called after suspend for dependency in a dm component.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/210f87c2
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/210f87c2
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/210f87c2
Branch: refs/heads/develop
Commit: 210f87c2109bdcbe3450b81ded2af780098900de
Parents: 2489419
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Sat Oct 15 17:14:56 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Sat Oct 15 17:14:56 2016 +0200
----------------------------------------------------------------------
.../private/src/dm_component_impl.c | 20 +++++++++++---------
.../phase2a/private/src/phase2a_cmp.c | 2 +-
.../phase2b/private/src/phase2b_cmp.c | 2 +-
.../dm_example/phase3/private/src/phase3_cmp.c | 2 +-
4 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/210f87c2/dependency_manager/private/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_component_impl.c b/dependency_manager/private/src/dm_component_impl.c
index 5b5c0ca..27db3a5 100644
--- a/dependency_manager/private/src/dm_component_impl.c
+++ b/dependency_manager/private/src/dm_component_impl.c
@@ -468,9 +468,9 @@ celix_status_t component_handleAdded(dm_component_pt component, dm_service_depen
serviceDependency_setAvailable(dependency, true);
- serviceDependency_invokeSet(dependency, event);
switch (component->state) {
case DM_CMP_STATE_WAITING_FOR_REQUIRED: {
+ serviceDependency_invokeSet(dependency, event);
bool required = false;
serviceDependency_isRequired(dependency, &required);
if (required) {
@@ -485,6 +485,7 @@ celix_status_t component_handleAdded(dm_component_pt component, dm_service_depen
serviceDependency_isRequired(dependency, &required);
if (!instanceBound) {
if (required) {
+ serviceDependency_invokeSet(dependency, event);
serviceDependency_invokeAdd(dependency, event);
}
dm_event_pt event = NULL;
@@ -498,9 +499,10 @@ celix_status_t component_handleAdded(dm_component_pt component, dm_service_depen
break;
}
case DM_CMP_STATE_TRACKING_OPTIONAL:
- component_suspend(component,dependency);
+ component_suspend(component,dependency);
+ serviceDependency_invokeSet(dependency, event);
serviceDependency_invokeAdd(dependency, event);
- component_resume(component,dependency);
+ component_resume(component,dependency);
dm_event_pt event = NULL;
component_getDependencyEvent(component, dependency, &event);
component_updateInstance(component, dependency, event, false, true);
@@ -529,9 +531,9 @@ celix_status_t component_handleChanged(dm_component_pt component, dm_service_dep
serviceDependency_invokeSet(dependency, event);
switch (component->state) {
case DM_CMP_STATE_TRACKING_OPTIONAL:
- component_suspend(component,dependency);
+ component_suspend(component,dependency);
serviceDependency_invokeChange(dependency, event);
- component_resume(component,dependency);
+ component_resume(component,dependency);
dm_event_pt hevent = NULL;
component_getDependencyEvent(component, dependency, &hevent);
component_updateInstance(component, dependency, hevent, true, false);
@@ -598,10 +600,10 @@ celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dep
break;
}
case DM_CMP_STATE_TRACKING_OPTIONAL:
- component_suspend(component,dependency);
+ component_suspend(component,dependency);
serviceDependency_invokeSet(dependency, event);
serviceDependency_invokeRemove(dependency, event);
- component_resume(component,dependency);
+ component_resume(component,dependency);
dm_event_pt hevent = NULL;
component_getDependencyEvent(component, dependency, &hevent);
component_updateInstance(component, dependency, hevent, false, false);
@@ -651,9 +653,9 @@ celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dep
break;
}
case DM_CMP_STATE_TRACKING_OPTIONAL:
- component_suspend(component,dependency);
+ component_suspend(component,dependency);
serviceDependency_invokeSwap(dependency, event, newEvent);
- component_resume(component,dependency);
+ component_resume(component,dependency);
break;
default:
break;
http://git-wip-us.apache.org/repos/asf/celix/blob/210f87c2/examples/dm_example/phase2a/private/src/phase2a_cmp.c
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase2a/private/src/phase2a_cmp.c b/examples/dm_example/phase2a/private/src/phase2a_cmp.c
index 3d04196..e0b1cc8 100644
--- a/examples/dm_example/phase2a/private/src/phase2a_cmp.c
+++ b/examples/dm_example/phase2a/private/src/phase2a_cmp.c
@@ -74,7 +74,7 @@ int phase2a_stop(phase2a_cmp_t *cmp) {
}
int phase2a_deinit(phase2a_cmp_t *cmp) {
- printf("deinit phase1\n");
+ printf("deinit phase2a\n");
return 0;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/210f87c2/examples/dm_example/phase2b/private/src/phase2b_cmp.c
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase2b/private/src/phase2b_cmp.c b/examples/dm_example/phase2b/private/src/phase2b_cmp.c
index 4c86f42..ccaa94d 100644
--- a/examples/dm_example/phase2b/private/src/phase2b_cmp.c
+++ b/examples/dm_example/phase2b/private/src/phase2b_cmp.c
@@ -74,7 +74,7 @@ int phase2b_stop(phase2b_cmp_t *cmp) {
}
int phase2b_deinit(phase2b_cmp_t *cmp) {
- printf("deinit phase1\n");
+ printf("deinit phase2b\n");
return 0;
}
http://git-wip-us.apache.org/repos/asf/celix/blob/210f87c2/examples/dm_example/phase3/private/src/phase3_cmp.c
----------------------------------------------------------------------
diff --git a/examples/dm_example/phase3/private/src/phase3_cmp.c b/examples/dm_example/phase3/private/src/phase3_cmp.c
index 0d421c8..47cb720 100644
--- a/examples/dm_example/phase3/private/src/phase3_cmp.c
+++ b/examples/dm_example/phase3/private/src/phase3_cmp.c
@@ -74,7 +74,7 @@ int phase3_stop(phase3_cmp_t *cmp) {
}
int phase3_deinit(phase3_cmp_t *cmp) {
- printf("deinit phase1\n");
+ printf("deinit phase3\n");
return 0;
}
[7/8] celix git commit: CELIX-282: Removes superfluous examples.
Posted by pn...@apache.org.
CELIX-282: Removes superfluous examples.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/505f6a84
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/505f6a84
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/505f6a84
Branch: refs/heads/develop
Commit: 505f6a8460ca885e5d92c6ee3448114956fb7aaa
Parents: 210f87c
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Sun Oct 16 13:38:10 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Sun Oct 16 13:38:10 2016 +0200
----------------------------------------------------------------------
examples/CMakeLists.txt | 28 +-
examples/echo_service/CMakeLists.txt | 19 -
examples/echo_service/client/CMakeLists.txt | 33 --
.../private/include/echo_client_private.h | 49 ---
.../client/private/src/echo_client.c | 78 ----
.../client/private/src/echo_client_activator.c | 83 -----
examples/echo_service/server/CMakeLists.txt | 32 --
.../private/include/echo_server_private.h | 36 --
.../server/private/src/echo_server.c | 49 ---
.../server/private/src/echo_server_activator.c | 78 ----
.../server/public/include/echo_server.h | 41 --
examples/embedding/private/src/main.c | 1 +
examples/hello_world/CMakeLists.txt | 2 +-
examples/locking/CMakeLists.txt | 34 --
examples/locking/benchmark/CMakeLists.txt | 31 --
.../private/src/benchmark_runner_activator.c | 290 ---------------
.../benchmark/public/include/benchmark.h | 41 --
.../benchmark/public/include/benchmark_result.h | 33 --
.../benchmark/public/src/benchmark_activator.c | 119 ------
examples/locking/consumer.c | 372 -------------------
examples/locking/math_provider/CMakeLists.txt | 32 --
.../private/include/math_component.h | 32 --
.../math_provider/private/src/math_component.c | 41 --
.../private/src/provider_activator.c | 228 ------------
.../modified_bool_benchmark/CMakeLists.txt | 29 --
.../private/src/modified_bool_benchmark.c | 180 ---------
examples/locking/mutex_benchmark/CMakeLists.txt | 32 --
.../private/src/mutex_benchmark.c | 135 -------
.../locking/reference_benchmark/CMakeLists.txt | 29 --
.../private/src/reference_benchmark.c | 128 -------
examples/locking/services/benchmark_service.h | 39 --
examples/locking/services/frequency_service.h | 47 ---
examples/locking/services/math_service.h | 40 --
.../locking/start_stop_benchmark/CMakeLists.txt | 29 --
.../private/src/start_stop_benchmark.c | 201 ----------
examples/mongoose/CMakeLists.txt | 2 +
.../chapter01-greeting-example/CMakeLists.txt | 19 -
.../chapter01-greeting-example/README.TXT | 24 --
.../client/CMakeLists.txt | 21 --
.../client/private/src/client.c | 65 ----
.../greeting/CMakeLists.txt | 28 --
.../greeting/private/include/greeting_impl.h | 38 --
.../greeting/private/src/activator.c | 91 -----
.../greeting/private/src/greeting_impl.c | 32 --
.../greeting/public/include/greeting_service.h | 39 --
.../chapter04-correct-listener/CMakeLists.txt | 22 --
.../chapter04-correct-listener/README.TXT | 23 --
.../private/src/listener_example.c | 197 ----------
.../chapter04-correct-lookup/CMakeLists.txt | 21 --
.../private/src/activator.c | 179 ---------
.../chapter04-paint-example/CMakeLists.txt | 31 --
.../circle/CMakeLists.txt | 46 ---
.../circle/private/include/circle_shape.h | 33 --
.../circle/private/src/activator.c | 82 ----
.../circle/private/src/circle.png | Bin 1664 -> 0 bytes
.../circle/private/src/circle_shape.c | 109 ------
.../paint/CMakeLists.txt | 53 ---
.../chapter04-paint-example/paint/gtktest.glade | 59 ---
.../paint/private/include/default_shape.h | 31 --
.../paint/private/include/paint_frame.h | 59 ---
.../paint/private/include/shape_component.h | 45 ---
.../paint/private/src/activator.c | 139 -------
.../paint/private/src/default_shape.c | 96 -----
.../paint/private/src/paint_frame.c | 363 ------------------
.../paint/private/src/shape_component.c | 69 ----
.../paint/private/src/underc.png | Bin 526 -> 0 bytes
.../simple/public/include/simple_shape.h | 42 ---
.../square/CMakeLists.txt | 45 ---
.../square/private/include/square_shape.h | 31 --
.../square/private/src/activator.c | 77 ----
.../square/private/src/square.png | Bin 351 -> 0 bytes
.../square/private/src/square_shape.c | 95 -----
.../triangle/CMakeLists.txt | 45 ---
.../triangle/private/include/triangle_shape.h | 32 --
.../triangle/private/src/activator.c | 77 ----
.../triangle/private/src/triangle.png | Bin 1375 -> 0 bytes
.../triangle/private/src/triangle_shape.c | 97 -----
examples/producer_consumer/CMakeLists.txt | 20 -
.../producer_consumer/consumer/CMakeLists.txt | 27 --
.../consumer/private/src/activator.c | 195 ----------
.../producer_consumer/database/CMakeLists.txt | 30 --
.../private/include/reader_service_impl.h | 39 --
.../private/include/writer_service_impl.h | 40 --
.../database/private/src/activator.c | 157 --------
.../database/private/src/reader.c | 73 ----
.../database/private/src/writer.c | 68 ----
.../database/public/include/data.h | 38 --
.../database/public/include/database.h | 44 ---
.../database/public/include/reader_service.h | 50 ---
.../database/public/include/writer_service.h | 48 ---
.../producer_consumer/producer/CMakeLists.txt | 27 --
.../producer/private/src/activator.c | 162 --------
examples/whiteboard/CMakeLists.txt | 5 +-
93 files changed, 11 insertions(+), 6240 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 0e3f87e..5192ee3 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -22,35 +22,13 @@ if (EXAMPLES)
add_subdirectory(services_example_c)
add_subdirectory(services_example_cxx)
+ add_subdirectory(dm_example)
+ add_subdirectory(dm_example_cxx)
+
if (NOT ANDROID)
add_subdirectory(mongoose)
endif()
-
add_subdirectory(whiteboard)
- add_subdirectory(echo_service)
- add_subdirectory(producer_consumer)
- add_subdirectory(dm_example)
- add_subdirectory(dm_example_cxx)
-
- add_subdirectory(osgi-in-action/chapter04-correct-lookup)
- add_subdirectory(osgi-in-action/chapter04-correct-listener)
- add_subdirectory(osgi-in-action/chapter01-greeting-example)
- #add_subdirectory(osgi-in-action/chapter04-paint-example) chapter4 example is still based on APR
- add_subdirectory(locking)
-
add_subdirectory(embedding)
- add_deploy(chapter01-greeting-example-d BUNDLES shell shell_tui log_service chapter01-greeting-example-client chapter01-greeting-example)
- add_deploy(chapter04-correct-lookup-d BUNDLES shell shell_tui log_service chapter04-correct-lookup)
- add_deploy(chapter04-correct-listener-d BUNDLES shell shell_tui log_service chapter04-correct-listener)
-
- #deploy("hello_world" BUNDLES shell shell_tui apache_celix_examples_hello_world hello_world_test log_service log_writer)
- add_deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui log_service log_writer)
- add_deploy("wb_dp" BUNDLES tracker_depman publisherA publisherB shell shell_tui log_service log_writer dm_shell)
- add_deploy("echo" BUNDLES echo_server echo_client shell shell_tui)
- add_deploy("producer_consumer" BUNDLES producer consumer database shell shell_tui)
- if (NOT ANDROID)
- add_deploy("mongoose_deploy" BUNDLES shell shell_tui log_service mongoose)
- endif ()
-
endif(EXAMPLES)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/echo_service/CMakeLists.txt b/examples/echo_service/CMakeLists.txt
deleted file mode 100644
index 0b4682c..0000000
--- a/examples/echo_service/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_subdirectory(server)
-add_subdirectory(client)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/client/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/echo_service/client/CMakeLists.txt b/examples/echo_service/client/CMakeLists.txt
deleted file mode 100644
index de66952..0000000
--- a/examples/echo_service/client/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_bundle(echo_client
- SYMBOLIC_NAME "apache_celix_examples_echo_client"
- VERSION "0.0.1"
- NAME "Apache Celix Echo Client"
- SOURCES
- private/src/echo_client_activator
- private/src/echo_client
-
- private/include/echo_client_private.h
-)
-
-include_directories("private/include")
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("../server/public/include")
-target_link_libraries(echo_client celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/client/private/include/echo_client_private.h
----------------------------------------------------------------------
diff --git a/examples/echo_service/client/private/include/echo_client_private.h b/examples/echo_service/client/private/include/echo_client_private.h
deleted file mode 100644
index e57597a..0000000
--- a/examples/echo_service/client/private/include/echo_client_private.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_client_private.h
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef ECHO_CLIENT_PRIVATE_H_
-#define ECHO_CLIENT_PRIVATE_H_
-
-#include <celixbool.h>
-
-struct echoClient {
- service_tracker_pt tracker;
- bool running;
- pthread_t sender_thread;
- char *ident;
-};
-
-typedef struct echoClient * echo_client_pt;
-
-echo_client_pt echoClient_create(service_tracker_pt context);
-
-void echoClient_start(echo_client_pt client);
-void echoClient_stop(echo_client_pt client);
-
-void echoClient_destroy(echo_client_pt client);
-
-
-#endif /* ECHO_CLIENT_PRIVATE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/client/private/src/echo_client.c
----------------------------------------------------------------------
diff --git a/examples/echo_service/client/private/src/echo_client.c b/examples/echo_service/client/private/src/echo_client.c
deleted file mode 100644
index 6670684..0000000
--- a/examples/echo_service/client/private/src/echo_client.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_client.c
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
-
-#include "service_tracker.h"
-
-#include "echo_client_private.h"
-#include "echo_server.h"
-
-static void *trk_send(void *handle) {
-
- echo_client_pt client = (echo_client_pt) handle;
-
- while (client->running) {
- echo_service_pt service = (echo_service_pt) serviceTracker_getService(client->tracker);
- if (service != NULL) {
- service->echo(service->server, client->ident);
- }
- sleep(1);
- }
-
- pthread_exit(NULL);
-
- return NULL;
-}
-
-echo_client_pt echoClient_create(service_tracker_pt echoServiceTracker) {
- echo_client_pt client = malloc(sizeof(*client));
-
- client->tracker = echoServiceTracker;
- client->running = false;
- client->ident = "OSX rules";
-
- return client;
-}
-
-void echoClient_start(echo_client_pt client) {
- client->running = true;
- pthread_create(&client->sender_thread, NULL, trk_send, client);
-}
-
-void echoClient_stop(echo_client_pt client) {
- client->running = false;
- pthread_join(client->sender_thread, NULL);
-}
-
-void echoClient_destroy(echo_client_pt client) {
- client->tracker = NULL;
- client->sender_thread = 0;
- free(client);
- client = NULL;
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/client/private/src/echo_client_activator.c
----------------------------------------------------------------------
diff --git a/examples/echo_service/client/private/src/echo_client_activator.c b/examples/echo_service/client/private/src/echo_client_activator.c
deleted file mode 100644
index 4026886..0000000
--- a/examples/echo_service/client/private/src/echo_client_activator.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_client_activator.c
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "service_tracker.h"
-
-#include "echo_server.h"
-#include "echo_client_private.h"
-
-struct echoActivator {
- echo_client_pt client;
- service_tracker_pt tracker;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt __attribute__((unused)) context, void **userData) {
- struct echoActivator * act = malloc(sizeof(*act));
- act->client = NULL;
- act->tracker = NULL;
- *userData = act;
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
- struct echoActivator * act = (struct echoActivator *) userData;
-
- service_tracker_pt tracker = NULL;
- echo_client_pt client = NULL;
-
- serviceTracker_create(context, ECHO_SERVICE_NAME, NULL, &tracker);
-
- act->tracker = tracker;
-
- client = echoClient_create(tracker);
- act->client = client;
-
- echoClient_start(act->client);
- serviceTracker_open(act->tracker);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt __attribute__((unused)) context) {
- struct echoActivator * act = (struct echoActivator *) userData;
- serviceTracker_close(act->tracker);
- echoClient_stop(act->client);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt __attribute__((unused)) context) {
- struct echoActivator * act = (struct echoActivator *) userData;
- serviceTracker_destroy(act->tracker);
- echoClient_destroy(act->client);
-
- free(act);
-
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/server/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/echo_service/server/CMakeLists.txt b/examples/echo_service/server/CMakeLists.txt
deleted file mode 100644
index fe2b268..0000000
--- a/examples/echo_service/server/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_bundle(echo_server
- SYMBOLIC_NAME "apache_celix_examples_echo_server"
- VERSION "0.0.1"
- NAME "Apache Celix Echo Server"
- SOURCES
- private/src/echo_server_activator
- private/src/echo_server
-
- private/include/echo_server_private.h
-)
-
-include_directories("private/include")
-include_directories("public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-target_link_libraries(echo_server celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/server/private/include/echo_server_private.h
----------------------------------------------------------------------
diff --git a/examples/echo_service/server/private/include/echo_server_private.h b/examples/echo_service/server/private/include/echo_server_private.h
deleted file mode 100644
index c93035b..0000000
--- a/examples/echo_service/server/private/include/echo_server_private.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_server_private.h
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef ECHO_SERVER_PRIVATE_H_
-#define ECHO_SERVER_PRIVATE_H_
-
-#include "echo_server.h"
-
-echo_server_pt echoServer_create();
-void echoServer_echo(echo_server_pt server, char * text);
-void echoServer_destroy(echo_server_pt server);
-
-#endif /* ECHO_SERVER_PRIVATE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/server/private/src/echo_server.c
----------------------------------------------------------------------
diff --git a/examples/echo_service/server/private/src/echo_server.c b/examples/echo_service/server/private/src/echo_server.c
deleted file mode 100644
index 045b7b7..0000000
--- a/examples/echo_service/server/private/src/echo_server.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_server.c
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "echo_server_private.h"
-
-struct echoServer {
- char * name;
-};
-
-echo_server_pt echoServer_create() {
- echo_server_pt server = malloc(sizeof(*server));
- server->name = "MacBook Pro";
- return server;
-}
-
-void echoServer_echo(echo_server_pt server, char * text) {
- printf("Server %s says %s\n", server->name, text);
-}
-
-void echoServer_destroy(echo_server_pt server) {
- server->name = NULL;
- free(server);
- server = NULL;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/server/private/src/echo_server_activator.c
----------------------------------------------------------------------
diff --git a/examples/echo_service/server/private/src/echo_server_activator.c b/examples/echo_service/server/private/src/echo_server_activator.c
deleted file mode 100644
index e7364f9..0000000
--- a/examples/echo_service/server/private/src/echo_server_activator.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_server_activator.c
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "echo_server_private.h"
-
-struct echoActivator {
- service_registration_pt reg;
- echo_service_pt es;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- struct echoActivator * act = malloc(sizeof(*act));
- act->reg = NULL;
- *userData = act;
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
- struct echoActivator * act = (struct echoActivator *) userData;
-
- echo_service_pt es = malloc(sizeof(*es));
- echo_server_pt server = echoServer_create();
- es->server = server;
- es->echo = echoServer_echo;
-
- act->es = es;
-
- bundleContext_registerService(context, ECHO_SERVICE_NAME, es, NULL, &act->reg);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- struct echoActivator * act = (struct echoActivator *) userData;
-
- serviceRegistration_unregister(act->reg);
- act->reg = NULL;
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- struct echoActivator * act = (struct echoActivator *) userData;
- act->es->echo = NULL;
- echoServer_destroy(act->es->server);
- act->es->server = NULL;
- free(act->es);
- act->es = NULL;
- act->reg = NULL;
- free(act);
-
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/echo_service/server/public/include/echo_server.h
----------------------------------------------------------------------
diff --git a/examples/echo_service/server/public/include/echo_server.h b/examples/echo_service/server/public/include/echo_server.h
deleted file mode 100644
index 65acdf3..0000000
--- a/examples/echo_service/server/public/include/echo_server.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_server.h
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef ECHO_SERVER_H_
-#define ECHO_SERVER_H_
-
-#define ECHO_SERVICE_NAME "echo_server"
-
-typedef struct echoServer * echo_server_pt;
-
-struct echoService {
- echo_server_pt server;
- void (*echo)(echo_server_pt server, char * text);
-};
-
-typedef struct echoService * echo_service_pt;
-
-#endif /* ECHO_SERVER_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/embedding/private/src/main.c
----------------------------------------------------------------------
diff --git a/examples/embedding/private/src/main.c b/examples/embedding/private/src/main.c
index f785121..b77cb22 100644
--- a/examples/embedding/private/src/main.c
+++ b/examples/embedding/private/src/main.c
@@ -75,6 +75,7 @@ int main(void) {
((struct fooSrv*) fs2)->foo(((struct fooSrv*) fs2)->handle);
+ bundleContext_ungetService(context, ref, NULL);
bundleContext_ungetServiceReference(context, ref);
serviceRegistration_unregister(reg);
}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/hello_world/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt
index e3a5c59..cc2d436 100644
--- a/examples/hello_world/CMakeLists.txt
+++ b/examples/hello_world/CMakeLists.txt
@@ -16,7 +16,7 @@
# under the License.
if(NOT APPLE)
-#Importing and exporting libraries not (yet) work under OSX.
+#Importing and exporting libraries not (yet) work under OSX.
include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
include_directories("public/include")
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/locking/CMakeLists.txt b/examples/locking/CMakeLists.txt
deleted file mode 100644
index fee34c6..0000000
--- a/examples/locking/CMakeLists.txt
+++ /dev/null
@@ -1,34 +0,0 @@
- # Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include_directories(services)
-
-add_subdirectory(benchmark)
-add_subdirectory(math_provider)
-
-add_subdirectory(mutex_benchmark)
-#add_subdirectory(reference_benchmark)
-#add_subdirectory(start_stop_benchmark)
-#add_subdirectory(modified_bool_benchmark)
-
-
-#add_deploy("locking_example_reference" BUNDLES benchmark_runner reference_benchmark math_provider shell shell_tui log_service log_writer)
-add_deploy("locking_example_mutex" BUNDLES benchmark_runner mutex_benchmark math_provider shell shell_tui log_service log_writer)
-
-#add_deploy("locking_example_suspend" BUNDLES benchmark_runner start_stop_benchmark math_provider shell shell_tui log_service log_writer)
-#add_deploy("locking_example_rcu" BUNDLES benchmark_runner rcu_benchmark mutex_benchmark math_provider shell shell_tui log_service log_writer)
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/benchmark/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/locking/benchmark/CMakeLists.txt b/examples/locking/benchmark/CMakeLists.txt
deleted file mode 100644
index 7992c36..0000000
--- a/examples/locking/benchmark/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include_directories(private/include)
-include_directories(public/include)
-include_directories(${PROJECT_SOURCE_DIR}/framework/public/include)
-include_directories(${PROJECT_SOURCE_DIR}/utils/public/include)
-include_directories(${PROJECT_SOURCE_DIR}/shell/public/include)
-
-add_bundle(benchmark_runner
- VERSION 0.0.1
- SOURCES
- private/src/benchmark_runner_activator
-)
-
-target_link_libraries(benchmark_runner celix_framework)
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/benchmark/private/src/benchmark_runner_activator.c
----------------------------------------------------------------------
diff --git a/examples/locking/benchmark/private/src/benchmark_runner_activator.c b/examples/locking/benchmark/private/src/benchmark_runner_activator.c
deleted file mode 100644
index 09a5be3..0000000
--- a/examples/locking/benchmark/private/src/benchmark_runner_activator.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * benchmark_activator.c
- *
- * \date Feb 12, 2014
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-#include <pthread.h>
-#include <string.h>
-#include <assert.h>
-
-#include "command.h"
-
-#include "bundle_activator.h"
-#include "service_tracker.h"
-
-#include "benchmark_service.h"
-#include "frequency_service.h"
-
-static celix_status_t benchmarkRunner_addingService(void * handle, service_reference_pt reference, void **service);
-static celix_status_t benchmarkRunner_addedService(void * handle, service_reference_pt reference, void * service);
-static celix_status_t benchmarkRunner_modifiedService(void * handle, service_reference_pt reference, void * service);
-static celix_status_t benchmarkRunner_removedService(void * handle, service_reference_pt reference, void * service);
-
-static void benchmarkRunner_runBenchmark(struct activator *activator, FILE *out);
-static void benchmarkRunner_printHeader(char *name, unsigned int nrOfSamples, FILE *out);
-static void benchmarkRunner_printResult(benchmark_result_t result, double updateFreq, unsigned long elapsedTime,
- FILE *out);
-static void benchmarkRunner_printFooter(char *name, FILE *out);
-static celix_status_t benchmarkRunner_execute(void *handle, char * line, FILE *out, FILE *err);
-
-
-struct activator {
- bundle_context_pt context;
- service_tracker_customizer_pt customizer;
- service_tracker_pt tracker;
-
- pthread_mutex_t mutex;
- benchmark_service_pt benchmark;
- frequency_service_pt freqService;
-
- command_service_pt command;
- service_registration_pt reg;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- struct activator * activator = malloc(sizeof(*activator));
- activator->context=context;
- activator->customizer = NULL;
- activator->tracker= NULL;
- activator->benchmark = NULL;
- activator->freqService = NULL;
-
- *userData = activator;
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator * activator = userData;
-
- pthread_mutex_init(&activator->mutex, NULL);
-
- serviceTrackerCustomizer_create(activator, benchmarkRunner_addingService, benchmarkRunner_addedService, benchmarkRunner_modifiedService, benchmarkRunner_removedService, &activator->customizer);
-
- char filter[128];
- sprintf(filter, "(|(%s=%s)(%s=%s))", "objectClass", BENCHMARK_SERVICE_NAME, "objectClass", FREQUENCY_SERVICE_NAME);
- serviceTracker_createWithFilter(context, filter, activator->customizer, &activator->tracker);
- serviceTracker_open(activator->tracker);
-
-
- activator->reg = NULL;
- activator->command = calloc(1, sizeof(*activator->command));
- activator->command->handle = activator;
- activator->command->executeCommand = benchmarkRunner_execute;
- properties_pt props = properties_create();
- properties_set(props, OSGI_SHELL_COMMAND_NAME, "benchmark");
- properties_set(props, OSGI_SHELL_COMMAND_USAGE, "benchmark run");
- properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION, "run the available benchmark");
-
- bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, activator->command, props, &activator->reg);
-
- return status;
-}
-
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context __attribute__((unused))) {
- struct activator * activator = userData;
-
- serviceTracker_close(activator->tracker);
-
- serviceRegistration_unregister(activator->reg);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context __attribute__((unused))) {
- struct activator * activator = userData;
- free(activator);
- return CELIX_SUCCESS;
-}
-
-static celix_status_t benchmarkRunner_addingService(void * handle, service_reference_pt reference, void **service) {
- celix_status_t status;
- struct activator * activator = handle;
- status = bundleContext_getService(activator->context, reference, service);
- return status;
-
-}
-static celix_status_t benchmarkRunner_addedService(void * handle, service_reference_pt reference, void * service) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator * activator = handle;
-
- service_registration_pt registration = NULL;
- properties_pt properties = NULL;
- const char* serviceName = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- serviceRegistration_getProperties(registration, &properties);
- serviceName = properties_get(properties, "objectClass");
- if (strcmp(serviceName, BENCHMARK_SERVICE_NAME) == 0) {
- pthread_mutex_lock(&activator->mutex);
- activator->benchmark = service;
- pthread_mutex_unlock(&activator->mutex);
- } else if (strcmp(serviceName, FREQUENCY_SERVICE_NAME) == 0 ) {
- pthread_mutex_lock(&activator->mutex);
- activator->freqService = service;
- pthread_mutex_unlock(&activator->mutex);
- }
-
- return status;
-}
-static celix_status_t benchmarkRunner_modifiedService(void * handle __attribute__((unused)), service_reference_pt reference __attribute__((unused)), void * service __attribute__((unused))) {
- celix_status_t status = CELIX_SUCCESS;
- //ignore
- return status;
-}
-
-static celix_status_t benchmarkRunner_removedService(void * handle, service_reference_pt reference, void * service) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator * activator = handle;
-
- service_registration_pt registration = NULL;
- properties_pt properties = NULL;
- const char* serviceName = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- serviceRegistration_getProperties(registration, &properties);
- serviceName = properties_get(properties, "objectClass");
- if (strcmp(serviceName, BENCHMARK_SERVICE_NAME) == 0) {
- pthread_mutex_lock(&activator->mutex);
- if (activator->benchmark == service) {
- activator->benchmark = NULL;
- }
- pthread_mutex_unlock(&activator->mutex);
- } else if (strcmp(serviceName, FREQUENCY_SERVICE_NAME) == 0 ) {
- pthread_mutex_lock(&activator->mutex);
- if (activator->freqService == service) {
- activator->freqService = NULL;
- }
- pthread_mutex_unlock(&activator->mutex);
- }
-
- return status;
-}
-
-static void benchmarkRunner_runBenchmark(struct activator *activator, FILE *out) {
- int k;
- double updateFrequency;
- double measuredFrequency = 0.0;
- unsigned int measuredUpdateCounter, nrOfUpdateThreads;
- int nrOfSamples;
- benchmark_service_pt benchmarkServ;
- char *name;
- benchmark_result_t result;
- struct timeval begin,end;
- unsigned long elapsedTime;
- double sampleFactor;
-
-
- int nrOfThreadRuns = 12;
- int threads[] = {1,2,3,4,5,6,7,8,16,32,64,128};
-
- nrOfSamples = 100 * 1000;
- updateFrequency = 1000;
- nrOfUpdateThreads = 100;
-
- benchmarkServ = activator->benchmark;
- name = benchmarkServ->name(benchmarkServ->handler);
- sampleFactor = benchmarkServ->getSampleFactor(benchmarkServ->handler);
-
- pthread_mutex_lock(&activator->mutex);
- if (activator->freqService != NULL) {
- activator->freqService->setFrequency(activator->freqService->handle, updateFrequency);
- activator->freqService->setNrOfThreads(activator->freqService->handle, nrOfUpdateThreads);
- activator->freqService->setBenchmarkName(activator->freqService->handle, name);
- }
-
- usleep(1000);
- benchmarkRunner_printHeader(name, nrOfSamples * (int)sampleFactor, out);
- for (k = 0 ; k < nrOfThreadRuns ; k +=1) {
- if (activator->freqService != NULL) {
- activator->freqService->resetCounter(activator->freqService->handle);
-
- }
- gettimeofday(&begin, NULL);
- result = benchmarkServ->run(benchmarkServ->handler, threads[k], nrOfSamples * sampleFactor);
- gettimeofday(&end, NULL);
- elapsedTime = ((end.tv_sec - begin.tv_sec) * 1000000) + (end.tv_usec - begin.tv_usec);
- if (activator->freqService != NULL) {
- measuredUpdateCounter = activator->freqService->getCounter(activator->freqService->handle);
- measuredFrequency = ((double)(measuredUpdateCounter) / elapsedTime * 1000000);
- }
- benchmarkRunner_printResult(result, measuredFrequency, elapsedTime, out);
- }
- benchmarkRunner_printFooter(name, out);
-
- pthread_mutex_unlock(&activator->mutex);
-}
-
-static void benchmarkRunner_printHeader(char *name, unsigned int nrOfSamples, FILE *out) {
- fprintf(out, "---%35s---------------------------------------------------------------------------------------\n", name);
- fprintf(out, "-------samples: %10i---------------------------------------------------------------------------------------------------\n", nrOfSamples);
-}
-
-static void benchmarkRunner_printResult(benchmark_result_t result, double updateFreq, unsigned long elapsedTime,
- FILE *out) {
- fprintf(out, "| threads %5i | ", result.nrOfThreads);
- fprintf(out, "average call time: %10.2f nanoseconds | ", result.averageCallTimeInNanoseconds);
- fprintf(out, "frequency calls is %10.5f MHz | ", result.callFrequencyInMhz);
- fprintf(out, "update freq ~ %8.2f Hz | ", updateFreq);
- fprintf(out, "elapsed time is %8.5f seconds | ", ((double)elapsedTime) / 1000000);
- if (result.skips > 0 ) {
- fprintf(out, "Warning skipped %i calls", result.skips);
- }
- fprintf(out, "\n");
-}
-
-static void benchmarkRunner_printFooter(char *name __attribute__((unused)), FILE *out) {
- fprintf(out, "-----------------------------------------------------------------------------------------------------------------------------\n\n\n");
-}
-
-static celix_status_t benchmarkRunner_execute(void *handle, char * line, FILE *out, FILE *err) {
- struct activator * activator = handle;
- char *savePtr;
- char *token = NULL;
- token = strtok_r(line, " ", &savePtr); //command name
- assert(strcmp(token, "benchmark") == 0);
- token = strtok_r(NULL, " ", &savePtr); //sub command
- if (strcmp("run", token) == 0) {
- token = strtok_r(NULL, " ", &savePtr); //possible nr of time to run
- int times = 1;
- int i;
- if (token != NULL) {
- times = atoi(token);
- }
- for (i = 0; i < times; i += 1) {
- fprintf(out, "running benchmark %i of %i\n", i+1, times);
- benchmarkRunner_runBenchmark(activator, out);
- }
- } else {
- fprintf(err, "Unknown subcommand '%s'\n", token);
- }
-
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/benchmark/public/include/benchmark.h
----------------------------------------------------------------------
diff --git a/examples/locking/benchmark/public/include/benchmark.h b/examples/locking/benchmark/public/include/benchmark.h
deleted file mode 100644
index 788444d..0000000
--- a/examples/locking/benchmark/public/include/benchmark.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-#ifndef CONSUMER_H_
-#define CONSUMER_H_
-
-#include "celix_errno.h"
-
-#include "benchmark_result.h"
-#include "math_service.h"
-
-typedef struct benchmark *benchmark_pt; //ADT
-
-celix_status_t benchmark_create(benchmark_pt *benchmark);
-celix_status_t benchmark_destroy(benchmark_pt benchmark);
-
-benchmark_result_t benchmark_run(benchmark_pt benchmark, int nrOfThreads, int nrOfSamples);
-char * benchmark_getName(benchmark_pt benchmark);
-double benchmark_getSampleFactor(benchmark_pt benchmark);
-
-celix_status_t benchmark_addMathService(benchmark_pt benchmark, math_service_pt mathService);
-celix_status_t benchmark_removeMathService(benchmark_pt benchmark, math_service_pt mathService);
-
-
-#endif /* CONSUMER_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/benchmark/public/include/benchmark_result.h
----------------------------------------------------------------------
diff --git a/examples/locking/benchmark/public/include/benchmark_result.h b/examples/locking/benchmark/public/include/benchmark_result.h
deleted file mode 100644
index 636b9d1..0000000
--- a/examples/locking/benchmark/public/include/benchmark_result.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-#ifndef BENCHMARK_RESULT_H_
-#define BENCHMARK_RESULT_H_
-
-typedef struct benchmark_result {
- unsigned int nrOfThreads;
- unsigned int nrOfsamples;
- unsigned int requestedNrOfSamples;
- unsigned int result;
- unsigned int skips;
- double averageCallTimeInNanoseconds;
- double callFrequencyInMhz;
-} benchmark_result_t;
-
-#endif /* BENCHMARK_RESULT_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/benchmark/public/src/benchmark_activator.c
----------------------------------------------------------------------
diff --git a/examples/locking/benchmark/public/src/benchmark_activator.c b/examples/locking/benchmark/public/src/benchmark_activator.c
deleted file mode 100644
index ffd9621..0000000
--- a/examples/locking/benchmark/public/src/benchmark_activator.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_server_activator.c
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "service_registration.h"
-#include "service_tracker.h"
-
-#include "math_service.h"
-#include "benchmark.h"
-#include "benchmark_service.h"
-#include "frequency_service.h"
-
-static celix_status_t addedService(void * handle, service_reference_pt reference, void * service);
-static celix_status_t removedService(void * handle, service_reference_pt reference, void * service);
-
-struct activator {
- bundle_context_pt context;
- benchmark_pt benchmark;
- benchmark_service_pt mathService;
- service_tracker_customizer_pt customizer;
- service_tracker_pt tracker;
- service_registration_pt registration;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- struct activator * activator = malloc(sizeof(*activator));
- activator->context=context;
- activator->benchmark=NULL;
- activator->mathService = NULL;
- activator->customizer = NULL;
- activator->tracker=NULL;
- activator->registration = NULL;
-
- *userData = activator;
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator * activator = userData;
-
- status = benchmark_create(&activator->benchmark);
- serviceTrackerCustomizer_create(activator, NULL, addedService, NULL, removedService, &activator->customizer);
-
- char filter[128];
- sprintf(filter, "(&(objectClass=%s)(benchmark=%s))", MATH_SERVICE_NAME, benchmark_getName(activator->benchmark));
-
- serviceTracker_createWithFilter(context, filter, activator->customizer, &activator->tracker);
- serviceTracker_open(activator->tracker);
-
- activator->mathService = malloc(sizeof(*activator->mathService));
- activator->mathService->handler = (void *)activator->benchmark;
- activator->mathService->name=(void *)benchmark_getName;
- activator->mathService->getSampleFactor=(void *)benchmark_getSampleFactor;
- activator->mathService->run=(void *)benchmark_run;
-
- status = bundleContext_registerService(activator->context, BENCHMARK_SERVICE_NAME, activator->mathService, NULL, &activator->registration);
-
- return status;
-}
-
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- struct activator * activator = userData;
-
- serviceTracker_close(activator->tracker);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- struct activator * activator = userData;
-
- benchmark_destroy(activator->benchmark);
- activator->benchmark=NULL;
-
- return CELIX_SUCCESS;
-}
-
-static celix_status_t addedService(void * handle, service_reference_pt reference, void * service) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator * activator = handle;
- benchmark_addMathService(activator->benchmark, service);
- return status;
-}
-
-static celix_status_t removedService(void * handle, service_reference_pt reference, void * service) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator * activator = handle;
- benchmark_removeMathService(activator->benchmark, service);
- return status;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/consumer.c
----------------------------------------------------------------------
diff --git a/examples/locking/consumer.c b/examples/locking/consumer.c
deleted file mode 100644
index b73549e..0000000
--- a/examples/locking/consumer.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * consumer.c
- *
- * \date Feb 3, 2014
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#include "consumer.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include <urcu.h>
-
-#include "math_service.h"
-#include "frequency_service.h"
-
-#define FREELIST_LENGTH 16
-
-typedef union service_counter service_counter_t;
-
-union service_counter {
- volatile struct {
- volatile u_int32_t counter; //TODO FIXME assuming little endian!!
- volatile u_int32_t position;
- math_service_pt math; // not accesible by raw
- } info; //TODO rename data
- volatile u_int64_t data; //TODO rename raw
-};
-
-struct consumer {
- math_service_pt math;
- frequency_service_pt frequencyService;
- locking_type_t currentLockingType;
- pthread_mutex_t mutex;
- pthread_rwlock_t rw_lock;
- service_counter_t *counters[FREELIST_LENGTH];
- service_counter_t *current;
-};
-
-typedef struct run_info {
- consumer_pt consumer;
- volatile locking_type_t type;
- int nrOfsamples;
- int result;
- uint skips;
- uint updateCounter;
- struct timeval begin;
- struct timeval end;
-} run_info_t;
-
-static void * consumer_reference_run(run_info_t *info);
-static void * consumer_no_locking_run(run_info_t *info);
-static void * consumer_mutex_run(run_info_t *info);
-static void * consumer_rcu_run(run_info_t *info);
-static void * consumer_reference_counting_run(run_info_t *info);
-static void * consumer_rw_lock_run(run_info_t *info);
-
-static int consumer_reference_calc(int arg1, int arg2);
-
-celix_status_t consumer_create(consumer_pt *result) {
- consumer_pt consumer = malloc(sizeof(*consumer));
- consumer->math = NULL;
- consumer->frequencyService = NULL;
- consumer->currentLockingType=LOCKING_TYPE_NO_LOCKING;
-
-
- service_counter_t *new = malloc(sizeof(service_counter_t));
- new->info.position = 0;
- new->info.counter = 0;
- new->info.math = NULL;
-
- int i;
- for (i = 0; i < FREELIST_LENGTH; i+=1) {
- consumer->counters[i] = NULL;
- }
- consumer->current = new;
- consumer->counters[0] = new;
-
- pthread_mutex_init(&consumer->mutex, NULL);
- pthread_rwlock_init(&consumer->rw_lock, NULL);
-
- rcu_init();
-
- (*result) = consumer;
- return CELIX_SUCCESS;
-}
-
-celix_status_t consumer_destroy(consumer_pt consumer) {
- pthread_mutex_destroy(&consumer->mutex);
- pthread_rwlock_destroy(&consumer->rw_lock);
- free(consumer);
- return CELIX_SUCCESS;
-}
-
-void consumer_setFrequencyService(consumer_pt consumer, frequency_service_pt freqServ) {
- consumer->frequencyService=freqServ;
-}
-
-void consumer_runBenchmark(consumer_pt consumer, locking_type_t type, int nrOfThreads, int nrOfSamples) {
- pthread_t threads[nrOfThreads];
- run_info_t info[nrOfThreads];
- int elapsedTime, skips, counter;
- double callTime, callFreq, updateFreq;
- int i;
-
- consumer->currentLockingType=type;
- usleep(1000);
-
- //init
- for (i = 0; i< nrOfThreads; i += 1) {
- info[i].consumer = consumer;
- info[i].nrOfsamples=nrOfSamples;
- info[i].result = rand();
- info[i].skips = 0;
- info[i].updateCounter = 0;
- }
- elapsedTime = 0;
- skips = 0;
-
- //start threads
- info->consumer->frequencyService->resetCounter(info->consumer->frequencyService->handler);
- for (i = 0; i < nrOfThreads; i += 1) {
- if (type == LOCKING_TYPE_NO_LOCKING) {
- pthread_create(&threads[i], NULL, (void *)consumer_no_locking_run, &info[i]);
- } else if (type == LOCKING_TYPE_MUTEX) {
- pthread_create(&threads[i], NULL, (void *)consumer_mutex_run, &info[i]);
- } else if (type == LOCKING_TYPE_REFERENCE) {
- pthread_create(&threads[i], NULL, (void *)consumer_reference_run, &info[i]);
- } else if (type == LOCKING_TYPE_RCU) {
- pthread_create(&threads[i], NULL, (void *)consumer_rcu_run, &info[i]);
- } else if (type == LOCKING_TYPE_REFERENCE_COUNTER) {
- pthread_create(&threads[i], NULL, (void *)consumer_reference_counting_run, &info[i]);
- } else if (type == LOCKING_TYPE_RW_LOCK) {
- pthread_create(&threads[i], NULL, (void *)consumer_rw_lock_run, &info[i]);
- } else {
- printf ("unknown type\n");
- return;
- }
- }
-
- //join and print result
-
- for (i = 0; i < nrOfThreads; i +=1 ) {
- pthread_join(threads[i], NULL);
- elapsedTime += ((info[i].end.tv_sec - info[i].begin.tv_sec) * 1000000) + (info[i].end.tv_usec - info[i].begin.tv_usec);
- skips += info[i].skips;
- counter += info[i].updateCounter;
- }
- counter = info->consumer->frequencyService->getCounter(info->consumer->frequencyService->handler);
- callTime = ((double)elapsedTime * 1000) / (nrOfSamples * nrOfThreads);
- callFreq = ((double)(nrOfSamples * nrOfThreads) / elapsedTime);
- updateFreq = ((double)counter * 1000000) / elapsedTime;
- printf("| threads %5i | ", nrOfThreads);
- printf("average call time: % 10.2f nanoseconds | ", callTime);
- printf("frequency calls is % 10.5f MHz | ", callFreq);
- printf("update freq ~ % 8.2f Hz | ", updateFreq);
- printf("\n");
-
- if (skips > 0) {
- printf("WARNING skips is %i\n", skips);
- }
-}
-
-celix_status_t consumer_addMathService(consumer_pt consumer, math_service_pt mathService) {
- if (consumer->currentLockingType == LOCKING_TYPE_MUTEX) {
- pthread_mutex_lock(&consumer->mutex);
- consumer->math = mathService;
- pthread_mutex_unlock(&consumer->mutex);
- } else if (consumer->currentLockingType == LOCKING_TYPE_RCU) {
- consumer->math = mathService;
- synchronize_rcu();
- } else if (consumer->currentLockingType == LOCKING_TYPE_RW_LOCK) {
- pthread_rwlock_wrlock(&consumer->rw_lock);
- consumer->math = mathService;
- pthread_rwlock_unlock(&consumer->rw_lock);
- } else { //no locking
- consumer->math = mathService;
- }
-
- //always update for reference counter
-// service_counter_t *new = malloc(sizeof(service_counter_t));
-// new->info.position = 0;
-// new->info.counter = 0;
-// new->info.math = mathService;
-// int found = false;
-// int pos;
-// for (pos = 0; !found && pos < FREELIST_LENGTH; pos += 1) {
-// found = __sync_bool_compare_and_swap(&(consumer->counters[pos]), NULL, new);
-// if (found) {
-// new->info.position = pos;
-// break;
-// }
-// }
-//
-// if (!found) {
-// printf("Cannot find free spot!!!!, will use 0\n");
-// consumer->counters[0] = new;
-// }
-//
-// int changed = false;
-// service_counter_t *old;
-// while (!changed) {
-// old = consumer->current;
-// changed = __sync_bool_compare_and_swap(&consumer->current, old, new);
-// }
-//
-// while (old->info.counter != 0) {usleep(10);}
-// consumer->counters[old->info.position] = NULL;
-// free(old);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t consumer_removeMathService(consumer_pt consumer, math_service_pt mathService) {
- if (consumer->currentLockingType == LOCKING_TYPE_NO_LOCKING) {
- __sync_val_compare_and_swap(&consumer->math, mathService, NULL);
- } else if (consumer->currentLockingType == LOCKING_TYPE_MUTEX) {
- pthread_mutex_lock(&consumer->mutex);
- if (consumer->math == mathService) {
- consumer->math = NULL;
- }
- pthread_mutex_unlock(&consumer->mutex);
- } else if (consumer->currentLockingType == LOCKING_TYPE_RCU) {
- uatomic_cmpxchg(&consumer->math, mathService, NULL);
- } else if (consumer->currentLockingType == LOCKING_TYPE_REFERENCE_COUNTER) {
- //TODO DONT KNOWN IGNORE FOR NOW
- }
- return CELIX_SUCCESS;
-}
-
-static void * consumer_reference_run(run_info_t *info) {
- int i;
-
- gettimeofday(&info->begin, NULL);
- for (i = 0; i < info->nrOfsamples; i += 1) {
- info->result = consumer_reference_calc(info->result, i);
- }
- gettimeofday(&info->end, NULL);
- return NULL;
-}
-
-static void * consumer_no_locking_run(run_info_t *info) {
- int i;
-
- gettimeofday(&info->begin, NULL);
- for (i = 0; i < info->nrOfsamples; i += 1) {
- if (info->consumer->math != NULL) {
- info->result = info->consumer->math->calc(info->result, i);
- } else {
- info->skips +=1; //should not happen
- }
- }
- gettimeofday(&info->end, NULL);
- return NULL;
-}
-
-static void * consumer_mutex_run(run_info_t *info) {
- int i;
-
- gettimeofday(&info->begin, NULL);
- for (i = 0; i < info->nrOfsamples; i += 1) {
- pthread_mutex_lock(&info->consumer->mutex);
- if (info->consumer->math != NULL) {
- info->result = info->consumer->math->calc(info->result, i);
- } else {
- info->skips += 1; //should not happen
- }
- pthread_mutex_unlock(&info->consumer->mutex);
- }
- gettimeofday(&info->end, NULL);
- return NULL;
-}
-
-static void * consumer_rw_lock_run(run_info_t *info) {
- int i;
- consumer_pt cons = info->consumer;
- int result = info->result;
- pthread_rwlock_t *lock = &cons->rw_lock;
- int nrOfsamples = info->nrOfsamples;
-
- gettimeofday(&info->begin, NULL);
- for (i = 0; i < nrOfsamples; i += 1) {
- pthread_rwlock_rdlock(lock);
- if (cons->math != NULL) {
- result = cons->math->calc(result, i);
- } else {
- info->skips += 1; //should not happen
- }
- pthread_rwlock_unlock(lock);
- }
- gettimeofday(&info->end, NULL);
- info->result = result;
- return NULL;
-}
-
-static void * consumer_rcu_run(run_info_t *info) {
- rcu_register_thread();
- int i;
- math_service_pt service;
-
- gettimeofday(&info->begin, NULL);
- for (i = 0; i < info->nrOfsamples; i += 1) {
- rcu_read_lock();
- if (info->consumer->math != NULL) {
- info->result = info->consumer->math->calc(info->result, i);
- } else {
- info->skips +=1; //should not happen
- }
- rcu_read_unlock();
- }
- gettimeofday(&info->end, NULL);
- rcu_unregister_thread();
- return NULL;
-}
-
-static void * consumer_reference_counting_run(run_info_t *info) {
- int i;
- service_counter_t posAndCount;
-
- gettimeofday(&info->begin, NULL);
- for (i = 0; i < info->nrOfsamples; i += 1) {
- posAndCount.data = __sync_add_and_fetch((u_int64_t *)&info->consumer->current->data, 1);
- volatile service_counter_t *serv = (volatile void *)info->consumer->counters[posAndCount.info.position];
- if (serv->info.math != NULL) {
- info->result = serv->info.math->calc(info->result, i);
- } else {
- info->skips += 1;
- }
- __sync_sub_and_fetch((u_int64_t *)&serv->data, -1);
-
- //not service_counter will not be deleted...but can we still find it??? is info->consumer->serviceCounter still te same?
- //change write to swap compare and then only changing the pointer is the counter is null?? not possible.. can compare counter , but not change pointer
-
- //IDEA create a list with service_counter based on a id (number) this number is 32bit long and put a counter + id in a 64bit value.
- //use this value to atomic increment and return value and use the id to retrieve the actual pointer. the value can be stored in the heap.
- //A list with id is used to retrieve a pointer to the service. If the value is null the slot is available this can be check with
- //compare_and_swap while looping through the list. The list can be extended when the end is reached and then a next list pointer can
- //be used. This can also be a linked list and the limitation is the max 32bit uint value (of 16bits for 32bit platforms).
- }
-
- gettimeofday(&info->end, NULL);
- return NULL;
-}
-
-//NOTE: copy implementation of the math_service->calc function, for reference.
-static int consumer_reference_calc(int arg1, int arg2) {
- return arg1 * arg2 + arg2;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/math_provider/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/locking/math_provider/CMakeLists.txt b/examples/locking/math_provider/CMakeLists.txt
deleted file mode 100644
index de83d7e..0000000
--- a/examples/locking/math_provider/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include_directories(public/include)
-include_directories(../benchmark/public/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
-include_directories(private/include)
-
-add_bundle(math_provider
- VERSION 0.0.1
- SOURCES
- private/src/provider_activator
- private/src/math_component
-)
-
-target_link_libraries(math_provider celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/math_provider/private/include/math_component.h
----------------------------------------------------------------------
diff --git a/examples/locking/math_provider/private/include/math_component.h b/examples/locking/math_provider/private/include/math_component.h
deleted file mode 100644
index b2b1510..0000000
--- a/examples/locking/math_provider/private/include/math_component.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-#ifndef MATH_COMPONENT_H_
-#define MATH_COMPONENT_H_
-
-#include "celix_errno.h"
-
-typedef struct math_component *math_component_pt;
-
-celix_status_t mathComponent_create(math_component_pt *math);
-celix_status_t mathComponent_destroy(math_component_pt math);
-
-int mathComponent_calc(math_component_pt math, int arg1, int arg2);
-
-
-#endif /* MATH_COMPONENT_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/math_provider/private/src/math_component.c
----------------------------------------------------------------------
diff --git a/examples/locking/math_provider/private/src/math_component.c b/examples/locking/math_provider/private/src/math_component.c
deleted file mode 100644
index bc83c8e..0000000
--- a/examples/locking/math_provider/private/src/math_component.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-#include <stdlib.h>
-#include "math_component.h"
-
-struct math_component {
- //emtpy
-};
-
-celix_status_t mathComponent_create(math_component_pt *math) {
- (*math) = calloc(1, sizeof(struct math_component));
- return CELIX_SUCCESS;
-}
-
-celix_status_t mathComponent_destroy(math_component_pt math) {
- free(math);
- return CELIX_SUCCESS;
-}
-
-int mathComponent_calc(math_component_pt math __attribute__((unused)), int arg1, int arg2) {
- return arg1 * arg2 + arg2;
-}
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/math_provider/private/src/provider_activator.c
----------------------------------------------------------------------
diff --git a/examples/locking/math_provider/private/src/provider_activator.c b/examples/locking/math_provider/private/src/provider_activator.c
deleted file mode 100644
index 58069d0..0000000
--- a/examples/locking/math_provider/private/src/provider_activator.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_server_activator.c
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <pthread.h>
-#include <signal.h>
-
-
-
-#include "bundle_activator.h"
-
-#include "math_service.h"
-#include "frequency_service.h"
-#include "math_component.h"
-
-typedef struct activator {
- bundle_context_pt context;
- bool isRunning;
-
- frequency_service_pt freqService;
- service_registration_pt freqRegistration;
-
- math_component_pt math;
- math_service_pt mathService;
- char *benchmarkName;
- service_registration_pt registration;
-
- double updateFrequency;
- unsigned int nrOfThreads;
- pthread_t *threads;
-
-
- unsigned int counter;
-} activator_t;
-
-static int calc(int arg1, int arg2) __attribute__((unused));
-static void* run(void *data);
-static void setFrequency(activator_t *activator, double freq);
-static void setNrOfThreads(activator_t *activator, unsigned int nrOfThreads);
-static void resetCounter(activator_t *activator);
-static void stopThreads(activator_t *activator);
-static void startThreads(activator_t *activator, unsigned int nrOfThreads);
-static unsigned int getCounter(activator_t *activator);
-static void setBenchmarkName(activator_t *activator, char *benchmark);
-static math_service_pt registerMath(activator_t *activator, service_registration_pt *reg);
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- activator_t * activator = malloc(sizeof(*activator));
- activator->context = context;
- activator->benchmarkName = NULL;
- activator->freqService = NULL;
- activator->registration = NULL;
- activator->freqRegistration = NULL;
- activator->updateFrequency = 0;
- activator->nrOfThreads = 0;
- activator->math = NULL;
-
- mathComponent_create(&activator->math);
-
- *userData = activator;
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context __attribute__((unused))) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator * activator = userData;
-
- activator->isRunning = true;
- activator->mathService = malloc(sizeof(*activator->mathService));
- activator->mathService->handle = activator->math;
- activator->mathService->calc = (void *)mathComponent_calc;
- bundleContext_registerService(activator->context, MATH_SERVICE_NAME, activator->mathService, NULL, &activator->registration);
-
- activator->freqService = malloc(sizeof(*activator->freqService));
- activator->freqService->handle = (void *)activator;
- activator->freqService->setFrequency = (void *)setFrequency;
- activator->freqService->resetCounter = (void *)resetCounter;
- activator->freqService->getCounter = (void *)getCounter;
- activator->freqService->setBenchmarkName = (void *)setBenchmarkName;
- activator->freqService->setNrOfThreads = (void *)setNrOfThreads;
- bundleContext_registerService(activator->context, FREQUENCY_SERVICE_NAME, activator->freqService, NULL, &activator->freqRegistration);
-
- startThreads(activator, activator->nrOfThreads);
-
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context __attribute__((unused))) {
- struct activator * activator = userData;
-
- printf("Stopping service registration thread\n");
- stopThreads(activator);
-
- //TODO deregister service & freqService
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context __attribute__((unused))) {
- struct echoActivator * activator = userData;
-
- //TODO free service & freqService struct
-
- free(activator);
-
- return CELIX_SUCCESS;
-}
-
-static int calc(int arg1, int arg2) {
- return arg1 * arg2 + arg2;
-}
-
-static void stopThreads(activator_t *activator) {
- //cancel and join threads
- activator->isRunning = false;
- if (activator->threads != NULL) {
- for (int i = 0 ; i < activator->nrOfThreads ; i += 1) {
- pthread_kill(activator->threads[i], SIGUSR1);
- pthread_join(activator->threads[i], NULL);
- }
- }
-}
-
-static void startThreads(activator_t *activator, unsigned int nrOfThreads) {
- activator->isRunning = true;
- activator->threads = malloc(sizeof(pthread_t) * nrOfThreads);
- for (int i = 0 ; i < nrOfThreads ; i += 1) {
- pthread_create(&activator->threads[i], NULL, (void *)run, activator);
- }
- activator->nrOfThreads = nrOfThreads;
-}
-
-static void* run(void *data) {
- activator_t *activator = data;
-
- service_registration_pt currentReg = NULL;
- service_registration_pt prevReg = NULL;
- math_service_pt current = NULL;
- math_service_pt prev = NULL;
-
- while (activator->isRunning) {
- unsigned int delayInMicroseconds = activator->updateFrequency == 0 ? 0 : (1000 * 1000) / activator->updateFrequency;
- if (delayInMicroseconds > 0) {
- prevReg = currentReg;
- prev = current;
-
- currentReg = NULL;
- current = registerMath(activator, ¤tReg);
-
- if (prevReg != NULL) {
- serviceRegistration_unregister(prevReg);
- free(prev);
- }
- }
- usleep(delayInMicroseconds > 0 ? delayInMicroseconds : 1000000);
- }
-
- return NULL;
-}
-
-static math_service_pt registerMath(activator_t *activator, service_registration_pt *reg) {
- math_service_pt serv = NULL;
- serv = malloc(sizeof(*activator->mathService));
- serv->handle = activator->math;
- serv->calc = (void *)mathComponent_calc;
- properties_pt props = properties_create();
- if (activator->benchmarkName != NULL) { //TODO FIXME race condition
- properties_set(props, "benchmark", activator->benchmarkName);
- }
- bundleContext_registerService(activator->context, MATH_SERVICE_NAME,
- serv, props, reg);
- activator->counter += 1;
- return serv;
-}
-
-static void setBenchmarkName(activator_t *activator, char *benchmark) {
- char *old = activator->benchmarkName;
- activator->benchmarkName = strdup(benchmark);
- free(old);
- if (activator->updateFrequency == 0) {
- service_registration_pt reg = NULL;
- registerMath(activator, ®); //TODO service will not be cleaned up !
- }
-}
-
-static void setFrequency(activator_t *activator, double freq) {
- printf("Setting frequency to %f\n", freq);
- activator->updateFrequency = freq;
-}
-
-static void setNrOfThreads(activator_t *activator, unsigned int nrOfThreads) {
- printf("Setting nr of update Threads to %d\n", nrOfThreads);
- stopThreads(activator);
- startThreads(activator, nrOfThreads);
-}
-
-static void resetCounter(activator_t *activator) {
- activator->counter = 0;
-}
-
-static unsigned int getCounter(activator_t *activator) {
- return activator->counter;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/modified_bool_benchmark/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/locking/modified_bool_benchmark/CMakeLists.txt b/examples/locking/modified_bool_benchmark/CMakeLists.txt
deleted file mode 100644
index 4f3d002..0000000
--- a/examples/locking/modified_bool_benchmark/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_bundle(modified_bool_benchmark SOURCES
- ../benchmark/public/src/benchmark_activator
- private/src/modified_bool_benchmark
-)
-
-include_directories(public/include)
-include_directories(../benchmark/public/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
-target_link_libraries(modified_bool_benchmark celix_framework)
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/modified_bool_benchmark/private/src/modified_bool_benchmark.c
----------------------------------------------------------------------
diff --git a/examples/locking/modified_bool_benchmark/private/src/modified_bool_benchmark.c b/examples/locking/modified_bool_benchmark/private/src/modified_bool_benchmark.c
deleted file mode 100644
index cdf8815..0000000
--- a/examples/locking/modified_bool_benchmark/private/src/modified_bool_benchmark.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <pthread.h>
-
-#include "array_list.h"
-
-#include "benchmark.h"
-#include "math_service.h"
-
-static const char * const BENCHMARK_NAME = "MODIFIED_BIT";
-static const double SAMPLE_FACTOR = 1;
-static const useconds_t SLEEP_TIME = 10;
-
-typedef struct thread_info {
- benchmark_pt benchmark;
- unsigned int result;
- struct timeval begin;
- struct timeval end;
- int skips;
- bool isModified;
- bool isUpdated;
-} thread_info_t;
-
-struct benchmark {
- pthread_mutex_t mutex;
- math_service_pt math;
- int nrOfSamples;
- int nrOfThreads;
- thread_info_t *threads;
-};
-
-static void benchmark_thread(thread_info_t *info);
-
-celix_status_t benchmark_create(benchmark_pt *benchmark) {
- (*benchmark) = malloc(sizeof(struct benchmark));
- (*benchmark)->math = NULL;
- pthread_mutex_init(&(*benchmark)->mutex, NULL);
- return CELIX_SUCCESS;
-}
-
-celix_status_t benchmark_destroy(benchmark_pt benchmark) {
- //free threads array
- free(benchmark);
- return CELIX_SUCCESS;
-}
-
-benchmark_result_t benchmark_run(benchmark_pt benchmark, int nrOfThreads, int nrOfSamples) {
- int i;
- pthread_t threads[nrOfThreads];
- thread_info_t infos[nrOfThreads];
- benchmark_result_t result;
- unsigned long elapsedTime = 0;
-
- benchmark->threads = infos;
- benchmark->nrOfSamples = nrOfSamples;
- benchmark->nrOfThreads = nrOfThreads;
-
- result.skips =0;
- pthread_mutex_lock(&benchmark->mutex);
- for (i = 0 ; i < nrOfThreads ; i += 1) {
- infos[i].benchmark = benchmark;
- infos[i].skips = 0;
- infos[i].result = rand();
- infos[i].isUpdated = false;
- infos[i].isModified = false;
- pthread_create(&threads[i], NULL, (void *)benchmark_thread, &infos[i]);
- }
- pthread_mutex_unlock(&benchmark->mutex);
-
- for (i = 0; i < nrOfThreads ; i += 1) {
- pthread_join(threads[i], NULL);
- elapsedTime += ((infos[i].end.tv_sec - infos[i].begin.tv_sec) * 1000000) + (infos[i].end.tv_usec - infos[i].begin.tv_usec);
- result.skips += infos[i].skips;
- }
-
- result.averageCallTimeInNanoseconds = ((double)elapsedTime * 1000) / (nrOfSamples * nrOfThreads);
- result.callFrequencyInMhz = ((double)(nrOfSamples * nrOfThreads) / elapsedTime);
- result.nrOfThreads = nrOfThreads;
- result.nrOfsamples = nrOfSamples;
-
- return result;
-}
-
-static void benchmark_thread(thread_info_t *info) {
- int i = 0;
-
- math_service_pt local = info->benchmark->math;
- int nrOfSamples = info->benchmark->nrOfSamples;
-
- gettimeofday(&info->begin, NULL);
- while (i < nrOfSamples) {
- if (!info->isModified) {
- if (local != NULL) {
- info->result = local->calc(local->handle, info->result, i);
- } else {
- info->skips += 1; //should not happen
- }
- i += 1;
- } else {
- local = info->benchmark->math;
- info->isModified = false;
- }
- }
- gettimeofday(&info->end, NULL);
-
-}
-
-char * benchmark_getName(benchmark_pt benchmark) {
- return (char *)BENCHMARK_NAME;
-}
-
-celix_status_t benchmark_addMathService(benchmark_pt benchmark, math_service_pt mathService) {
- int i;
-
- pthread_mutex_lock(&benchmark->mutex);
- benchmark->math = mathService;
- pthread_mutex_unlock(&benchmark->mutex);
-
- //inform threads to update servicd
- for (i = 0 ; i < benchmark->nrOfSamples ; i += 1) {
- benchmark->threads[i].isModified = true;
- }
-
- //Wait till al thread are not in a modified state, e.g. update to date mathService and not using the old service
- for (i = 0; i < benchmark->nrOfThreads ; i += 1) {
- if (benchmark->threads[i].isModified) {
- usleep(SLEEP_TIME);
- }
- }
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t benchmark_removeMathService(benchmark_pt benchmark, math_service_pt mathService) {
- pthread_mutex_lock(&benchmark->mutex);
- if (benchmark->math == mathService) {
- benchmark->math = NULL;
- }
- pthread_mutex_unlock(&benchmark->mutex);
-
- //inform threads to update servicd
- int i;
- for (i = 0 ; i < benchmark->nrOfThreads ; i += 1) {
- benchmark->threads[i].isModified = true;
- }
-
- //Wait till al thread are not in a modified state, e.g. update to date mathService and not using the old service
- for (i = 0; i < benchmark->nrOfThreads ; i += 1) {
- if (benchmark->threads[i].isModified) {
- usleep(SLEEP_TIME);
- }
- }
-
-
- return CELIX_SUCCESS;
-}
-
-double benchmark_getSampleFactor(benchmark_pt benchmark) {
- return SAMPLE_FACTOR;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/mutex_benchmark/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/locking/mutex_benchmark/CMakeLists.txt b/examples/locking/mutex_benchmark/CMakeLists.txt
deleted file mode 100644
index 71ab71d..0000000
--- a/examples/locking/mutex_benchmark/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include_directories(public/include)
-include_directories(../benchmark/public/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
-
-add_bundle(mutex_benchmark
- VERSION 0.0.1
- SOURCES
- ../benchmark/public/src/benchmark_activator
- private/src/mutex_benchmark
-)
-
-target_link_libraries(mutex_benchmark celix_framework)
-
[5/8] celix git commit: CELIX-282: Removes superfluous examples.
Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
deleted file mode 100644
index f82b572..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <apr_general.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "simple_shape.h"
-#include "paint_frame.h"
-#include "service_tracker.h"
-#include "service_reference.h"
-#include "service_registration.h"
-
-struct paintFrameActivatorData {
- service_registration_pt reg;
- apr_pool_t *pool;
- service_tracker_pt tracker;
- bundle_context_pt context;
- paint_frame_pt paint_frame;
-};
-celix_status_t addingServ(void * handle, service_reference_pt ref, void **service);
-celix_status_t addedServ(void * handle, service_reference_pt reference, void * service);
-celix_status_t modifiedServ(void * handle, service_reference_pt reference, void * service);
-celix_status_t removedServ(void * handle, service_reference_pt reference, void * service);
-
-typedef struct paintFrameActivatorData *greeting_activator_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- celix_status_t status = CELIX_SUCCESS;
- apr_pool_t *pool;
- greeting_activator_pt activator;
- service_tracker_customizer_pt cust = NULL;
- printf("Paint_frame create\n");
- status = bundleContext_getMemoryPool(context, &pool);
- if (status == CELIX_SUCCESS) {
- *userData = apr_palloc(pool, sizeof(struct paintFrameActivatorData));
- activator = *userData;
- activator->reg = NULL;
- activator->pool = pool;
- activator->context = context;
- activator->paint_frame = NULL;
- activator->tracker = NULL;
- status = paintFrame_create(context, pool, &activator->paint_frame);
-
- serviceTrackerCustomizer_create(pool, activator, addingServ,
- addedServ, modifiedServ, removedServ, &cust);
-
- serviceTracker_create(pool, context, SIMPLE_SHAPE_SERVICE_NAME, cust, &activator->tracker);
- serviceTracker_open(activator->tracker);
-
- }
- return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
- struct paintFrameActivatorData * act = (struct paintFrameActivatorData *) userData;
- celix_status_t status = CELIX_SUCCESS;
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- struct paintFrameActivatorData * act = (struct paintFrameActivatorData *) userData;
- serviceTracker_close(act->tracker);
- paintFrame_exit(act->paint_frame);
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- struct paintFrameActivatorData * act = (struct paintFrameActivatorData *) userData;
- return CELIX_SUCCESS;
-}
-
-celix_status_t addingServ(void * handle, service_reference_pt ref, void **service) {
- struct paintFrameActivatorData * data = (struct paintFrameActivatorData *) handle;
- bundleContext_getService(data->context, ref, service);
- return CELIX_SUCCESS;
-}
-
-celix_status_t addedServ(void * handle, service_reference_pt ref, void * service) {
- struct paintFrameActivatorData * data = (struct paintFrameActivatorData *) handle;
- service_registration_pt reg = NULL;
- properties_pt props = NULL;
- char * serviceName = NULL;
- serviceReference_getServiceRegistration(ref, ®);
- serviceRegistration_getProperties(reg, &props);
- serviceName = properties_get(props, "name");
- paintFrame_addShape(data->paint_frame, data->context, service);
- return CELIX_SUCCESS;
- }
-
-celix_status_t modifiedServ(void * handle, service_reference_pt ref, void * service) {
- struct paintFrameActivatorData * data = (struct paintFrameActivatorData *) handle;
- service_registration_pt reg = NULL;
- properties_pt props = NULL;
- char * serviceName = NULL;
- serviceReference_getServiceRegistration(ref, ®);
- serviceRegistration_getProperties(reg, &props);
- serviceName = properties_get(props, "name");
- return CELIX_SUCCESS;
-}
-
-celix_status_t removedServ(void * handle, service_reference_pt ref, void * service) {
- struct paintFrameActivatorData * data = (struct paintFrameActivatorData *) handle;
- service_registration_pt reg = NULL;
- properties_pt props = NULL;
- char * serviceName = NULL;
- serviceReference_getServiceRegistration(ref, ®);
- serviceRegistration_getProperties(reg, &props);
- serviceName = properties_get(props, "name");
- paintFrame_removeShape(data->paint_frame, service);
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/private/src/default_shape.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/default_shape.c b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/default_shape.c
deleted file mode 100644
index e3d45b5..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/default_shape.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * default_shape.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-#include <stdio.h>
-#include <string.h>
-#include <celixbool.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include "bundle_context.h"
-#include "bundle.h"
-#include "hash_map.h"
-#include "simple_shape.h"
-#include "default_shape.h"
-#define DEFAULT_FILE "underc.png"
-
-void defaultShape_draw(simple_shape_pt shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y);
-
-simple_shape_pt defaultShape_create(bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- bundle_pt bundle;
- apr_pool_t *pool;
- simple_shape_pt shape = (simple_shape_pt) malloc(sizeof(*shape));
- bundleContext_getBundle(context, &bundle);
- bundleContext_getMemoryPool(context, &pool);
- shape->icon_path = NULL;
- status = bundle_getEntry(bundle, DEFAULT_FILE, pool, &shape->icon_path);
- shape->simpleShape_draw = defaultShape_draw;
- if (status == CELIX_SUCCESS){
- // no error
- } else {
- printf("Could not find resource %s\n", DEFAULT_FILE);
- }
- return shape;
-}
-
-void defaultShape_draw(simple_shape_pt shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y){
- GdkRectangle update_rect;
- GdkPixbuf *curr_pix_buf;
- GError *gerror = NULL;
- gsize rd = 0, wr = 0;
- if (shape->icon_path == NULL) {
- printf("error message: icon path unknown\n");
- } else {
- gchar *gfn = g_locale_to_utf8(shape->icon_path, strlen(shape->icon_path), &rd, &wr, &gerror);
- curr_pix_buf = gdk_pixbuf_new_from_file(gfn, &gerror);
- if(!curr_pix_buf) {
- g_printerr("error message: %s\n", (gchar *) gerror->message);
- }
- update_rect.x = x - 5;
- update_rect.y = y - 5;
- update_rect.width = gdk_pixbuf_get_width(curr_pix_buf);
- update_rect.height = gdk_pixbuf_get_height(curr_pix_buf);
- gdk_pixbuf_render_to_drawable(
- curr_pix_buf,
- pixMap,
- gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
- 0, 0,
- update_rect.x, update_rect.y,
- update_rect.width,
- update_rect.height,
- GDK_RGB_DITHER_NONE,
- 0, 0);
- gtk_widget_queue_draw_area (widget,
- update_rect.x, update_rect.y,
- update_rect.width, update_rect.height);
- }
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
deleted file mode 100644
index 1c56311..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * paint_frame.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-/*
- * This class represents the main application class, which is a JFrame subclass
- * that manages a toolbar of shapes and a drawing canvas. This class does not
- * directly interact with the underlying OSGi framework; instead, it is injected
- * with the available <tt>SimpleShape</tt> instances to eliminate any
- * dependencies on the OSGi application programming interfaces.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <gtk/gtk.h>
-#include <string.h>
-#include <celixbool.h>
-#include <glib.h>
-#include <gdk/gdk.h>
-#include "bundle_context.h"
-#include "bundle.h"
-#include "utils.h"
-#include "hash_map.h"
-#include "simple_shape.h"
-#include "linked_list_iterator.h"
-#include "linked_list.h"
-#include "paint_frame.h"
-#include "shape_component.h"
-#include "default_shape.h"
-#include "celix_errno.h"
-
-static paint_frame_pt this = NULL;
-
-struct shape_info {
- char *name;
- simple_shape_pt shape;
- GtkWidget *button;
-};
-
-typedef struct shape_info *shape_info_pt;
-static celix_status_t paintFrame_redraw(paint_frame_pt frame, GdkModifierType state);
-static celix_status_t paintFrame_show(paint_frame_pt frame);
-static void paintFrame_destroy(GtkWidget *widget, gpointer data);
-static void paintFrame_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data);
-static void paintFrame_configure(GtkWidget *widget, GdkEventConfigure *event, gpointer data);
-static void paintFrame_buttonClicked(GtkWidget *button, gpointer data);
-static gboolean paintFrame_mousePressed( GtkWidget *widget, GdkEventButton *event, gpointer data);
-static gpointer paintFrame_gtkmain(gpointer a_data);
-static void paintFrame_destroyWidgets(paint_frame_pt frame);
-
-/**
- * Default constructor that populates the main window.
- **/
-celix_status_t paintFrame_create(bundle_context_pt context, apr_pool_t *pool, paint_frame_pt *frame) {
- celix_status_t status = CELIX_SUCCESS;
- apr_pool_t *mypool = NULL;
- apr_pool_create(&mypool, pool);
- this = malloc(sizeof(*this));
- if (!this) {
- this = NULL;
- status = CELIX_ENOMEM;
- } else {
- char *builderFile;
- bundle_pt bundle;
- GError *error = NULL;
- *frame = this;
-
-
- (*frame)->showing = false;
- (*frame)->pool = mypool;
- (*frame)->pixMap = NULL;
- (*frame)->m_selected = NULL;
- (*frame)->context = context;
- (*frame)->m_shapes = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
- (*frame)->m_defaultShape = defaultShape_create((*frame)->context);
- linkedList_create((*frame)->pool, &(*frame)->m_shapeComponents);
-
-
- status = bundleContext_getBundle(context, &bundle);
- if (status == CELIX_SUCCESS) {
- status = bundle_getEntry(bundle, "gtktest.glade", mypool, &builderFile);
- if (status == CELIX_SUCCESS) {
- (*frame)->file = builderFile;
-
- gdk_threads_init();
- gtk_init(NULL, NULL);
-
- if( g_thread_supported()) {
- // (*frame)->main = g_thread_new("main", paintFrame_gtkmain, (*frame));
- (*frame)->main = g_thread_create(paintFrame_gtkmain, (*frame), TRUE, &error);
- if ((*frame)->main == NULL){
- g_printerr ("Failed to create thread: %s\n", error->message);
- status = CELIX_BUNDLE_EXCEPTION;
- }
- } else {
- g_printerr("g_thread NOT supported\n");
- }
- }
- }
- }
-
- return status;
-}
-
-celix_status_t paintFrame_exit(paint_frame_pt frame) {
- frame->showing = false;
-
- paintFrame_destroyWidgets(frame);
-
- gdk_threads_enter();
-
- gtk_main_quit();
-
- gdk_threads_leave();
-
- g_thread_join(frame->main);
-
- return CELIX_SUCCESS;
-}
-
-static celix_status_t shapeInfo_create(paint_frame_pt frame, char* name, GtkWidget *button, simple_shape_pt shape, shape_info_pt *info){
- *info = malloc(sizeof(**info));
- (*info)->shape = shape;
- (*info)->name = name;
- (*info)->button = button;
- return CELIX_SUCCESS;
-}
-static celix_status_t paintFrame_show(paint_frame_pt frame) {
- gtk_widget_show(frame->drawingArea);
- gtk_widget_show(frame->toolbar);
- gtk_widget_show(frame->window);
-
- return CELIX_SUCCESS;
-}
-
-/**
- * Injects an available <tt>SimpleShape</tt> into the drawing frame.
- *
- * @param name The name of the injected <tt>SimpleShape</tt>.
- * @param icon The icon associated with the injected <tt>SimpleShape</tt>.
- * @param shape The injected <tt>SimpleShape</tt> instance.
- **/
-celix_status_t paintFrame_addShape(paint_frame_pt frame, bundle_context_pt context, simple_shape_pt shape) {
- celix_status_t status = CELIX_SUCCESS;
- GError *gerror = NULL;
- GtkWidget *button = NULL;
- GtkWidget *im = NULL;
-
- gdk_threads_enter();
-
- button = gtk_button_new();
- gtk_widget_set_name((GtkWidget *) button, shape->name);
- im = gtk_image_new_from_file(shape->icon_path);
- gtk_button_set_image((GtkButton *) button, im);
- gtk_toolbar_append_widget((GtkToolbar *) frame->toolbar, (GtkWidget *) button, "", "");
- g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (paintFrame_buttonClicked), frame);
- gtk_widget_show(button);
- if (hashMap_get(frame->m_shapes, shape->name) == NULL) {
- shape_info_pt info = NULL;
- shapeInfo_create(frame, shape->name, button, shape, &info);
- hashMap_put(frame->m_shapes, shape->name, info);
- }
- paintFrame_redraw(frame, 0);
- paintFrame_show(frame);
- gdk_threads_leave();
-
- return status;
-}
-
-/**
- * Removes a no longer available <tt>SimpleShape</tt> from the drawing frame.
- *
- * @param name The name of the <tt>SimpleShape</tt> to remove.
- **/
-celix_status_t paintFrame_removeShape(paint_frame_pt frame, simple_shape_pt sshape) {
- celix_status_t status = CELIX_SUCCESS;
- shape_info_pt shape = NULL;
- gdk_threads_enter();
- shape = (shape_info_pt) hashMap_remove(this->m_shapes, sshape->name);
- if (shape != NULL) {
- this->m_selected = NULL;
- gtk_widget_destroy(GTK_WIDGET(shape->button));
- gtk_widget_show_all(this->toolbar);
- paintFrame_redraw(this, 0);
- paintFrame_show(this);
- }
- gdk_threads_leave();
-
- return status;
-}
-
-/**
- * Retrieves the available <tt>SimpleShape</tt> associated with the given
- * name.
- *
- * @param name The name of the <tt>SimpleShape</tt> to retrieve.
- * @return The corresponding <tt>SimpleShape</tt> instance if available or
- * <tt>null</tt>.
- **/
-simple_shape_pt paintFrame_getShape(paint_frame_pt frame, char *name) {
- shape_info_pt info = (shape_info_pt) hashMap_get(frame->m_shapes, name);
- if (info == NULL) {
- return frame->m_defaultShape;
- } else {
- return info->shape;
- }
-}
-
-static void paintFrame_destroy(GtkWidget *widget, gpointer data) {
- paint_frame_pt frame = data;
- bundle_pt bundle = NULL;
-
- frame->showing = false;
-
-// bundleContext_getBundleById(frame->context, 0, &bundle);
-// bundle_stop(bundle, 0);
-}
-
-static void paintFrame_destroyWidgets(paint_frame_pt frame) {
- gdk_threads_enter();
-
- if (frame->pixMap != NULL) {
- gdk_pixmap_unref(frame->pixMap);
- }
- if (frame->toolbar != NULL) {
- gtk_widget_destroy(frame->toolbar);
- }
- if (frame->drawingArea != NULL) {
- gtk_widget_destroy(frame->drawingArea);
- }
- if (frame->window != NULL) {
- gtk_widget_destroy(frame->window);
- }
-
- frame->pixMap = NULL;
- frame->toolbar = NULL;
- frame->window = NULL;
- frame->drawingArea = NULL;
-
- gdk_threads_leave();
-}
-
-static void paintFrame_configure(GtkWidget *widget, GdkEventConfigure *event, gpointer data) {
- paint_frame_pt frame = data;
- GtkAllocation allocation;
-
- if (frame->pixMap != NULL) {
- gdk_pixmap_unref(frame->pixMap);
- }
-
- gtk_widget_get_allocation(widget, &allocation);
- frame->pixMap = gdk_pixmap_new(gtk_widget_get_window(widget), allocation.width, allocation.height, -1);
- paintFrame_redraw(frame, 0);
-}
-
-static void paintFrame_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
- paint_frame_pt frame = data;
- gdk_draw_pixmap(gtk_widget_get_window(widget),
- gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
- frame->pixMap, event->area.x, event->area.y, event->area.x,
- event->area.y, event->area.width, event->area.height);
-}
-
-static void paintFrame_buttonClicked(GtkWidget *button, gpointer data) {
- paint_frame_pt frame = data;
- frame->m_selected = (char *) gtk_widget_get_name(button);
-}
-
-static gboolean paintFrame_mousePressed( GtkWidget *widget, GdkEventButton *event, gpointer data) {
- paint_frame_pt frame = data;
- if (event->button == 1 && frame->pixMap != NULL) {
- if (frame->m_selected == NULL){
- printf("no button selected yet\n");
- } else {
- shape_component_pt sc = shapeComponent_create(frame, paintFrame_getShape(frame, frame->m_selected), event->x, event->y);
- linkedList_addFirst(frame->m_shapeComponents, sc);
- (*sc->shapeComponent_paintComponent)(sc, frame, frame->pixMap, widget);
- }
- }
- return TRUE;
-}
-
-static celix_status_t paintFrame_redraw(paint_frame_pt frame, GdkModifierType state) {
- if (frame->pixMap != NULL && frame->showing) {
- GdkRectangle update_rect;
- GtkAllocation allocation;
- linked_list_iterator_pt it = NULL;
-
- update_rect.x = 0;
- update_rect.y = 0;
- gtk_widget_get_allocation(frame->drawingArea, &allocation);
- update_rect.width = allocation.width;
- update_rect.height = allocation.height;
- gdk_draw_rectangle (this->pixMap,
- gtk_widget_get_style(frame->drawingArea)->white_gc,
- TRUE,
- update_rect.x, update_rect.y,
- update_rect.width, update_rect.height);
- gtk_widget_draw(frame->drawingArea, &update_rect);
- it = linkedListIterator_create(this->m_shapeComponents, 0);
- while (linkedListIterator_hasNext(it)) {
- shape_component_pt sc = linkedListIterator_next(it);
- (*sc->shapeComponent_paintComponent)(sc, this, this->pixMap, frame->drawingArea);
- }
- }
-
- return CELIX_SUCCESS;
-}
-
-static gpointer paintFrame_gtkmain(gpointer a_data) {
- GtkBuilder *builder;
- paint_frame_pt frame = (paint_frame_pt) a_data;
-
- gdk_threads_enter();
- builder = gtk_builder_new();
- gtk_builder_add_from_file(builder, frame->file, NULL);
-
- frame->window = GTK_WIDGET(gtk_builder_get_object (builder, "window1"));
- frame->toolbar = GTK_WIDGET(gtk_builder_get_object (builder, "toolbar1"));
- frame->drawingArea = GTK_WIDGET(gtk_builder_get_object (builder, "drawingarea1"));
- g_object_unref(G_OBJECT(builder));
-
- gtk_window_set_title(GTK_WINDOW(frame->window), "OSGi in Action, Paint-Example");
-
- gtk_widget_set_events (frame->drawingArea, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
-
- g_signal_connect(G_OBJECT(frame->window), "destroy", G_CALLBACK(paintFrame_destroy), frame);
- g_signal_connect(G_OBJECT(frame->drawingArea), "expose_event", G_CALLBACK(paintFrame_expose), frame);
- g_signal_connect(G_OBJECT(frame->drawingArea), "configure_event", G_CALLBACK(paintFrame_configure), frame);
- g_signal_connect(G_OBJECT(frame->drawingArea), "button_press_event", G_CALLBACK(paintFrame_mousePressed), frame);
-
-
- paintFrame_show(frame);
- frame->showing = true;
-
- gtk_main();
- gdk_threads_leave();
-
- return NULL;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/private/src/shape_component.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/shape_component.c b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/shape_component.c
deleted file mode 100644
index db8d274..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/shape_component.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * shape_component.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <stdio.h>
-#include <string.h>
-#include <celixbool.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include "bundle_context.h"
-#include "utils.h"
-#include "linked_list.h"
-#include "hash_map.h"
-#include "simple_shape.h"
-#include "shape_component.h"
-
-static const int BOX = 54;
-
-extern void shapeComponent_paintComponent(shape_component_pt shapeComponent, paint_frame_pt frame,
- GdkPixmap *pixMap, GtkWidget *widget);
-
-shape_component_pt shapeComponent_create(paint_frame_pt frame, simple_shape_pt sshape,
- gdouble x, gdouble y) {
- shape_component_pt shape = malloc(sizeof(*shape));
- shape->m_frame = frame;
- shape->shapeName = strdup(sshape->name);
- shape->x = x - BOX /2;
- shape->y = y - BOX /2;
- shape->w = BOX;
- shape->h = BOX;
- /* methods */
- shape->shapeComponent_paintComponent = shapeComponent_paintComponent;
- return shape;
-}
-
-void shapeComponent_paintComponent(shape_component_pt shapeComponent, paint_frame_pt frame,
- GdkPixmap *pixMap, GtkWidget *widget) {
- simple_shape_pt shape = paintFrame_getShape(frame, shapeComponent->shapeName);
- if (shape == NULL) {
- g_printerr("cannot find shape %s\n", shapeComponent->shapeName);
- } else {
- (*shape->simpleShape_draw)(shape, pixMap, widget,
- shapeComponent->x, shapeComponent->y);
- }
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/private/src/underc.png
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/underc.png b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/underc.png
deleted file mode 100644
index 425cdb9..0000000
Binary files a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/underc.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/simple/public/include/simple_shape.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/simple/public/include/simple_shape.h b/examples/osgi-in-action/chapter04-paint-example/simple/public/include/simple_shape.h
deleted file mode 100644
index 6385b54..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/simple/public/include/simple_shape.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * simple_shape.h
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#ifndef SIMPLE_SHAPE_H_
-#define SIMPLE_SHAPE_H_
-
-#include <gdk/gdk.h>
-
-struct simple_shape {
- char *icon_path;
- char *name;
- void (*simpleShape_draw) (struct simple_shape *shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y);
-};
-
-typedef struct simple_shape *simple_shape_pt;
-
-#define SIMPLE_SHAPE_SERVICE_NAME "simple_shape"
-
-
-#endif /* SIMPLE_SHAPE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/square/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/square/CMakeLists.txt b/examples/osgi-in-action/chapter04-paint-example/square/CMakeLists.txt
deleted file mode 100644
index df87ee4..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/square/CMakeLists.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-INCLUDE(FindPkgConfig)
-pkg_search_module (GLIB REQUIRED glib-2.0)
-pkg_search_module (GTHR REQUIRED gthread-2.0)
-pkg_search_module (GTK REQUIRED gtk+-2.0)
-include_directories(
- private/include
- ../simple/public/include
-)
-include_directories(${GTK_INCLUDE_DIRS})
-include_directories(${GLIB_INCLUDE_DIRS})
-include_directories(${GTHR_INCLUDE_DIRS})
-
-link_directories(${GTK_LIBRARY_DIRS})
-link_directories(${GLIB_LIBRARY_DIRS})
-link_directories(${GTHR_LIBRARY_DIRS})
-
-add_bundle(square VERSION 0.0.1 SOURCES
- private/src/activator
- private/src/square_shape
-
- private/include/square_shape.h
- FILES
- private/src/square.png
-)
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-target_link_libraries(square celix_framework ${GLIB_LIBRARIES} ${GTK_LIBRARIES} ${GTHR_LIBRARIES})
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/square/private/include/square_shape.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/square/private/include/square_shape.h b/examples/osgi-in-action/chapter04-paint-example/square/private/include/square_shape.h
deleted file mode 100644
index 35c4be1..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/square/private/include/square_shape.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * square_shape.h
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#ifndef SQUARE_SHAPE_H_
-#define SQUARE_SHAPE_H_
-
-extern simple_shape_pt squareShape_create(bundle_context_pt context);
-
-#endif /* SQUARE_SHAPE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/square/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/square/private/src/activator.c b/examples/osgi-in-action/chapter04-paint-example/square/private/src/activator.c
deleted file mode 100644
index 96ca227..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/square/private/src/activator.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <apr_general.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "simple_shape.h"
-#include "square_shape.h"
-#include "simple_shape.h"
-
-struct squareActivator {
- service_registration_pt reg;
- apr_pool_t *pool;
-};
-
-typedef struct squareActivator *greeting_activator_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- apr_pool_t *pool;
- greeting_activator_pt activator;
- celix_status_t status = bundleContext_getMemoryPool(context, &pool);
- if (status == CELIX_SUCCESS) {
- *userData = apr_palloc(pool, sizeof(struct squareActivator));
- activator = *userData;
- activator->reg = NULL;
- activator->pool = pool;
- printf("Square created\n");
- }
- return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
- struct squareActivator * act = (struct squareActivator *) userData;
- celix_status_t status = CELIX_SUCCESS;
- simple_shape_pt es = squareShape_create(ctx);
- properties_pt props = properties_create();
- properties_set(props, "name", "square");
- status = bundleContext_registerService(ctx, SIMPLE_SHAPE_SERVICE_NAME, es, props, &act->reg);
- printf("Square start\n");
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/square/private/src/square.png
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/square/private/src/square.png b/examples/osgi-in-action/chapter04-paint-example/square/private/src/square.png
deleted file mode 100644
index 3f24cfc..0000000
Binary files a/examples/osgi-in-action/chapter04-paint-example/square/private/src/square.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/square/private/src/square_shape.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/square/private/src/square_shape.c b/examples/osgi-in-action/chapter04-paint-example/square/private/src/square_shape.c
deleted file mode 100644
index 41c6e83..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/square/private/src/square_shape.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * square_shape.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <string.h>
-#include <celixbool.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include "bundle_context.h"
-#include "bundle.h"
-#include "hash_map.h"
-#include "simple_shape.h"
-#include "square_shape.h"
-#define SQUARE_FILE "square.png"
-
-void squareShape_draw(simple_shape_pt shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y);
-
-simple_shape_pt squareShape_create(bundle_context_pt context) {
- bundle_pt bundle;
- apr_pool_t *pool;
- simple_shape_pt shape = (simple_shape_pt) malloc(sizeof(*shape));
- celix_status_t status = CELIX_SUCCESS;
- bundleContext_getBundle(context, &bundle);
- bundleContext_getMemoryPool(context, &pool);
- shape->name = "Square";
- shape->icon_path = NULL;
- status = bundle_getEntry(bundle, SQUARE_FILE, pool, &shape->icon_path);
- shape->simpleShape_draw = squareShape_draw;
- if (status == CELIX_SUCCESS) {
- // no error
- } else {
- printf("Could not find resource %s\n", SQUARE_FILE);
- }
- return shape;
-}
-
-void squareShape_draw(simple_shape_pt shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y){
- GdkRectangle update_rect;
- GdkPixbuf *curr_pix_buf;
- GError *gerror = NULL;
- gsize rd = 0, wr = 0;
- if (shape->icon_path == NULL){
- printf("no icon path\n");
- } else {
- gchar *gfn = g_locale_to_utf8(shape->icon_path, strlen(shape->icon_path), &rd, &wr, &gerror);
- curr_pix_buf = gdk_pixbuf_new_from_file(gfn, &gerror);
- if(!curr_pix_buf) {
- g_printerr("error message: %s\n", (gchar *) gerror->message);
- }
- update_rect.x = x - 5;
- update_rect.y = y - 5;
- update_rect.width = gdk_pixbuf_get_width(curr_pix_buf);
- update_rect.height = gdk_pixbuf_get_height(curr_pix_buf);
- gdk_pixbuf_render_to_drawable(
- curr_pix_buf,
- pixMap,
- gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
- 0, 0,
- update_rect.x, update_rect.y,
- update_rect.width,
- update_rect.height,
- GDK_RGB_DITHER_NONE,
- 0, 0);
- gtk_widget_queue_draw_area (widget,
- update_rect.x, update_rect.y,
- update_rect.width, update_rect.height);
- }
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/triangle/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/triangle/CMakeLists.txt b/examples/osgi-in-action/chapter04-paint-example/triangle/CMakeLists.txt
deleted file mode 100644
index ff069b3..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/triangle/CMakeLists.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-INCLUDE(FindPkgConfig)
-pkg_search_module (GLIB REQUIRED glib-2.0)
-pkg_search_module (GTHR REQUIRED gthread-2.0)
-pkg_search_module (GTK REQUIRED gtk+-2.0)
-include_directories(
- private/include
- ../simple/public/include
-)
-include_directories(${GTK_INCLUDE_DIRS})
-include_directories(${GLIB_INCLUDE_DIRS})
-include_directories(${GTHR_INCLUDE_DIRS})
-
-link_directories(${GTK_LIBRARY_DIRS})
-link_directories(${GLIB_LIBRARY_DIRS})
-link_directories(${GTHR_LIBRARY_DIRS})
-
-add_bundle(triangle VERSION 0.0.1 SOURCES
- private/src/activator
- private/src/triangle_shape
-
- private/include/triangle_shape.h
- FILES
- private/src/triangle.png
-)
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-target_link_libraries(triangle celix_framework ${GLIB_LIBRARIES} ${GTK_LIBRARIES} ${GTHR_LIBRARIES})
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/triangle/private/include/triangle_shape.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/triangle/private/include/triangle_shape.h b/examples/osgi-in-action/chapter04-paint-example/triangle/private/include/triangle_shape.h
deleted file mode 100644
index 02b924c..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/triangle/private/include/triangle_shape.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * triangle_shape.h
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef TRIANGLE_SHAPE_H_
-#define TRIANGLE_SHAPE_H_
-
-extern simple_shape_pt triangleShape_create(bundle_context_pt ctx);
-
-#endif /* TRIANGLE_SHAPE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/activator.c b/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/activator.c
deleted file mode 100644
index 49875ac..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/activator.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <apr_general.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "simple_shape.h"
-#include "triangle_shape.h"
-#include "simple_shape.h"
-
-struct greetingActivator {
- service_registration_pt reg;
- apr_pool_t *pool;
-};
-
-typedef struct greetingActivator *greeting_activator_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- apr_pool_t *pool;
- greeting_activator_pt activator;
- celix_status_t status = bundleContext_getMemoryPool(context, &pool);
- if (status == CELIX_SUCCESS) {
- *userData = apr_palloc(pool, sizeof(struct greetingActivator));
- activator = *userData;
- activator->reg = NULL;
- activator->pool = pool;
- }
- printf("Triangle created %d\n", status);
- return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
- struct greetingActivator * act = (struct greetingActivator *) userData;
- celix_status_t status = CELIX_SUCCESS;
- simple_shape_pt es = triangleShape_create(ctx);
- properties_pt props = properties_create();
- properties_set(props, "name", "triangle");
- status = bundleContext_registerService(ctx, SIMPLE_SHAPE_SERVICE_NAME, es, props, &act->reg);
- printf("Triangle activated %d\n", status);
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle.png
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle.png b/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle.png
deleted file mode 100644
index 46a5288..0000000
Binary files a/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle_shape.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle_shape.c b/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle_shape.c
deleted file mode 100644
index 71fca10..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle_shape.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * triangle_shape.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-#include <stdio.h>
-#include <string.h>
-#include <celixbool.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include "bundle_context.h"
-#include "bundle.h"
-#include "hash_map.h"
-#include "simple_shape.h"
-#include "triangle_shape.h"
-#define TRIANGLE_FILE "triangle.png"
-
-void triangleShape_draw(simple_shape_pt shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y);
-
-simple_shape_pt triangleShape_create(bundle_context_pt context) {
- bundle_pt bundle;
- apr_pool_t *pool;
- simple_shape_pt shape = (simple_shape_pt) malloc(sizeof(*shape));
- celix_status_t status = CELIX_SUCCESS;
- bundleContext_getBundle(context, &bundle);
- bundleContext_getMemoryPool(context, &pool);
- shape->name = "Triangle";
- shape->icon_path = NULL;
- status = bundle_getEntry(bundle, TRIANGLE_FILE, pool, &shape->icon_path);
- shape->simpleShape_draw = triangleShape_draw;
- if (status == CELIX_SUCCESS){
- // no error
- } else {
- printf("Could not find resource %s\n", TRIANGLE_FILE);
- }
- return shape;
-}
-
-void triangleShape_draw(simple_shape_pt shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y){
- GdkRectangle update_rect;
- GdkPixbuf *curr_pix_buf;
- GError *gerror = NULL;
- gsize rd = 0, wr = 0;
- if (shape->icon_path == NULL) {
- printf("error message: icon path unknown\n");
- } else {
- gchar *gfn = g_locale_to_utf8(shape->icon_path, strlen(shape->icon_path), &rd, &wr, &gerror);
- curr_pix_buf = gdk_pixbuf_new_from_file(gfn, &gerror);
- if(!curr_pix_buf) {
- g_printerr("error message: %s\n", (gchar *) gerror->message);
- }
- update_rect.x = x - 5;
- update_rect.y = y - 5;
- update_rect.width = gdk_pixbuf_get_width(curr_pix_buf);
- update_rect.height = gdk_pixbuf_get_height(curr_pix_buf);
- gdk_pixbuf_render_to_drawable(
- curr_pix_buf,
- pixMap,
- gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
- 0, 0,
- update_rect.x, update_rect.y,
- update_rect.width,
- update_rect.height,
- GDK_RGB_DITHER_NONE,
- 0, 0);
- gtk_widget_queue_draw_area (widget,
- update_rect.x, update_rect.y,
- update_rect.width, update_rect.height);
- }
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/CMakeLists.txt b/examples/producer_consumer/CMakeLists.txt
deleted file mode 100644
index 5e07a12..0000000
--- a/examples/producer_consumer/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_subdirectory(database)
-add_subdirectory(producer)
-add_subdirectory(consumer)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/consumer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/consumer/CMakeLists.txt b/examples/producer_consumer/consumer/CMakeLists.txt
deleted file mode 100644
index 2803af7..0000000
--- a/examples/producer_consumer/consumer/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/examples/producer_consumer/database/public/include")
-
-add_bundle(consumer
- VERSION 1.0.0
- SOURCES
- private/src/activator.c
-)
-
-target_link_libraries(consumer celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/consumer/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/consumer/private/src/activator.c b/examples/producer_consumer/consumer/private/src/activator.c
deleted file mode 100644
index 0e58856..0000000
--- a/examples/producer_consumer/consumer/private/src/activator.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * activator.c
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-
-#include <unistd.h>
-
-#include <sys/time.h>
-
-#include <bundle_activator.h>
-#include <service_tracker.h>
-#include <constants.h>
-
-#include <array_list.h>
-
-#include "reader_service.h"
-#include "writer_service.h"
-#include "data.h"
-
-struct activator {
- service_tracker_pt readerTracker;
- service_tracker_pt writerTracker;
- array_list_pt readerServices;
- array_list_pt writerServices;
- bool running;
- celix_thread_t worker;
-};
-
-celix_status_t readerServiceAdded(void *handle, service_reference_pt reference, void *service);
-celix_status_t readerServiceRemoved(void *handle, service_reference_pt reference, void *service);
-
-celix_status_t writerServiceAdded(void *handle, service_reference_pt reference, void *service);
-celix_status_t writerServiceRemoved(void *handle, service_reference_pt reference, void *service);
-
-void *retrieveData(void *handle);
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- celix_status_t status = CELIX_SUCCESS;
- *userData = calloc(1, sizeof(struct activator));
- if (*userData) {
- ((struct activator *) *userData)->readerTracker = NULL;
- ((struct activator *) *userData)->writerTracker = NULL;
- ((struct activator *) *userData)->readerServices = NULL;
- ((struct activator *) *userData)->writerServices = NULL;
- ((struct activator *) *userData)->running = false;
- ((struct activator *) *userData)->worker = celix_thread_default;
- } 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;
-
- // create list for services
- arrayList_create(&activator->readerServices);
- arrayList_create(&activator->writerServices);
-
- // start the thread
- activator->running = true;
- status = celixThread_create(&activator->worker, NULL, retrieveData, activator);
-
- if (status == CELIX_SUCCESS) {
- service_tracker_customizer_pt readerCustomizer = NULL;
- service_tracker_customizer_pt writerCustomizer = NULL;
- serviceTrackerCustomizer_create(userData, NULL, readerServiceAdded, NULL, readerServiceRemoved, &readerCustomizer);
- serviceTrackerCustomizer_create(userData, NULL, writerServiceAdded, NULL, writerServiceRemoved, &writerCustomizer);
-
- serviceTracker_create(context, WRITER_SERVICE_NAME, writerCustomizer, &activator->writerTracker);
- serviceTracker_open(activator->writerTracker);
-
- serviceTracker_create(context, READER_SERVICE_NAME, readerCustomizer, &activator->readerTracker);
- serviceTracker_open(activator->readerTracker);
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
-
- // stop the thread
- activator->running = false;
-
- celixThread_join(activator->worker, NULL);
-
- serviceTracker_close(activator->readerTracker);
- serviceTracker_close(activator->writerTracker);
-
- serviceTracker_destroy(activator->readerTracker);
- serviceTracker_destroy(activator->writerTracker);
-
- // destroy the list of services
- arrayList_destroy(activator->readerServices);
- arrayList_destroy(activator->writerServices);
-
- return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
-
- free(activator);
-
- return status;
-}
-
-celix_status_t readerServiceAdded(void *handle, service_reference_pt reference, void *service) {
- struct activator *activator = handle;
- arrayList_add(activator->readerServices, service);
- printf("Consumer: Reader Service Added.\n");
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t readerServiceRemoved(void *handle, service_reference_pt reference, void *service) {
- struct activator *activator = handle;
- arrayList_removeElement(activator->readerServices, service);
- printf("Consumer: Reader Service Removed.\n");
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t writerServiceAdded(void *handle, service_reference_pt reference, void *service) {
- struct activator *activator = handle;
- arrayList_add(activator->writerServices, service);
- printf("Consumer: Writer Service Added.\n");
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t writerServiceRemoved(void *handle, service_reference_pt reference, void *service) {
- struct activator *activator = handle;
- arrayList_removeElement(activator->writerServices, service);
- printf("Consumer: Writer Service Removed.\n");
-
- return CELIX_SUCCESS;
-}
-
-void *retrieveData(void *handle) {
- struct activator *activator = handle;
-
- while (activator->running) {
- int i;
- for (i = 0; i < arrayList_size(activator->readerServices); i++) {
- reader_service_pt service = arrayList_get(activator->readerServices, i);
- data_pt retrievedData = NULL;
-
- if (service->readerService_getNextData(service->handler, &retrievedData) == CELIX_SUCCESS) {
- printf(" Data #%d received.", retrievedData->id);
-
- writer_service_pt writerService = arrayList_get(activator->writerServices, 0);
- if (writerService && writerService->writerService_removeData(writerService->handler, &retrievedData) == CELIX_SUCCESS) {
- printf(" and removed\n");
- }
-
- } else {
- printf(" No data available\n");
- sleep(5);
- }
-
- }
-
- }
-
- return NULL;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/CMakeLists.txt b/examples/producer_consumer/database/CMakeLists.txt
deleted file mode 100644
index 40b8b35..0000000
--- a/examples/producer_consumer/database/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/examples/producer_consumer/database/private/include")
-include_directories("${PROJECT_SOURCE_DIR}/examples/producer_consumer/database/public/include")
-
-add_bundle(database
- VERSION 1.0.0
- SOURCES private/src/activator
- private/src/writer
- private/src/reader
-)
-
-target_link_libraries(database celix_framework)
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/private/include/reader_service_impl.h
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/private/include/reader_service_impl.h b/examples/producer_consumer/database/private/include/reader_service_impl.h
deleted file mode 100644
index 6db7195..0000000
--- a/examples/producer_consumer/database/private/include/reader_service_impl.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * reader_service_impl.h
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-
-#ifndef READER_SERVICE_IMPL_H_
-#define READER_SERVICE_IMPL_H_
-
-#include "data.h"
-#include "database.h"
-
-celix_status_t readerService_getFirstData(database_handler_pt, data_pt firstData);
-celix_status_t readerService_getNextData(database_handler_pt, data_pt* nextData);
-
-#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/private/include/writer_service_impl.h
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/private/include/writer_service_impl.h b/examples/producer_consumer/database/private/include/writer_service_impl.h
deleted file mode 100644
index 1933892..0000000
--- a/examples/producer_consumer/database/private/include/writer_service_impl.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * writer_service_impl.h
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-
-#ifndef WRITER_SERVICE_IMPL_H_
-#define WRITER_SERVICE_IMPL_H_
-
-#include "data.h"
-#include "database.h"
-
-celix_status_t writerService_storeData(database_handler_pt, data_pt data);
-celix_status_t writerService_removeData(database_handler_pt, data_pt* data);
-
-
-#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/private/src/activator.c b/examples/producer_consumer/database/private/src/activator.c
deleted file mode 100644
index 3d866e1..0000000
--- a/examples/producer_consumer/database/private/src/activator.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * activator.c
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <sys/time.h>
-
-#include <bundle_activator.h>
-#include <service_tracker.h>
-#include <constants.h>
-
-#include <array_list.h>
-#include <pthread.h>
-
-#include "reader_service.h"
-#include "reader_service_impl.h"
-#include "writer_service.h"
-#include "writer_service_impl.h"
-
-#include "database.h"
-
-struct activator {
- database_handler_pt databaseHandler;
-
- service_registration_pt readerRegistration;
- service_registration_pt writerRegistration;
-
- reader_service_pt readerService;
- writer_service_pt writerService;
-};
-
-
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- celix_status_t status = CELIX_SUCCESS;
-
- *userData = calloc (1, sizeof(struct activator));
-
- if (*userData) {
- ((struct activator *) *userData)->readerService = NULL;
- ((struct activator *) *userData)->writerService = NULL;
- ((struct activator *) *userData)->databaseHandler = NULL;
-
- } else {
- status = CELIX_ENOMEM;
- }
- return status;
-}
-
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_ENOMEM;
- struct activator *activator = userData;
- reader_service_pt readerService = calloc(1, sizeof(struct reader_service));
- writer_service_pt writerService = calloc(1, sizeof(struct writer_service));
- database_handler_pt databaseHandler = calloc(1, sizeof(struct database_handler));
-
- if (readerService && writerService && databaseHandler)
- {
- status = celixThreadMutex_create(&databaseHandler->lock, NULL);
-
- if (status == CELIX_SUCCESS)
- {
- arrayList_create(&databaseHandler->data);
- databaseHandler->dataIndex = 0;
-
- readerService->handler = databaseHandler;
- readerService->readerService_getFirstData = readerService_getFirstData;
- readerService->readerService_getNextData = readerService_getNextData;
-
- writerService->handler = databaseHandler;
- writerService->writerService_storeData = writerService_storeData;
- writerService->writerService_removeData = writerService_removeData;
-
- activator->readerService = readerService;
- activator->writerService = writerService;
-
- status = bundleContext_registerService(context, READER_SERVICE_NAME, activator->readerService, NULL, &activator->readerRegistration);
-
- if (status == CELIX_SUCCESS){
- status = bundleContext_registerService(context, WRITER_SERVICE_NAME, activator->writerService, NULL, &activator->writerRegistration);
- }
- }
- }
-
- if(status != CELIX_SUCCESS){
- if(readerService!=NULL){
- free(readerService);
- }
- if(writerService!=NULL){
- free(writerService);
- }
- if(databaseHandler!=NULL){
- free(databaseHandler);
- }
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
-
- serviceRegistration_unregister(activator->readerRegistration);
- serviceRegistration_unregister(activator->writerRegistration);
-
- return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator *activator = userData;
-
- database_handler_pt dbh = (database_handler_pt)activator->writerService->handler;
- if(dbh != NULL){
- celixThreadMutex_destroy(&dbh->lock);
- if(dbh->data != NULL){
- arrayList_destroy(dbh->data);
- }
- free(dbh);
- activator->writerService->handler=NULL;
- }
-
- free(activator->readerService);
- free(activator->writerService);
- free(activator);
-
- return status;
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/private/src/reader.c
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/private/src/reader.c b/examples/producer_consumer/database/private/src/reader.c
deleted file mode 100644
index c28cd7b..0000000
--- a/examples/producer_consumer/database/private/src/reader.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * reader.c
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-
-#include <pthread.h>
-
-#include "array_list.h"
-#include "celix_errno.h"
-#include "data.h"
-#include "database.h"
-#include "reader_service.h"
-
-
-celix_status_t readerService_getFirstData(database_handler_pt handler, __attribute__((unused)) data_pt firstData)
-{
- celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-
- celixThreadMutex_lock(&handler->lock);
-
- if (arrayList_remove(handler->data, 0) != NULL)
- {
- handler->dataIndex--;
- status = CELIX_SUCCESS;
- }
-
- celixThreadMutex_unlock(&handler->lock);
-
- return status;
-}
-
-
-celix_status_t readerService_getNextData(database_handler_pt handler, data_pt* nextData)
-{
- celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-
- celixThreadMutex_lock(&handler->lock);
-
- if (((*nextData) = (data_pt) arrayList_get(handler->data, handler->dataIndex)) != NULL)
- {
- handler->dataIndex++;
- status = CELIX_SUCCESS;
- }
-
- celixThreadMutex_unlock(&handler->lock);
-
- return status;
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/private/src/writer.c
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/private/src/writer.c b/examples/producer_consumer/database/private/src/writer.c
deleted file mode 100644
index cce12fa..0000000
--- a/examples/producer_consumer/database/private/src/writer.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * writer.c
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-
-#include <stdlib.h>
-#include <pthread.h>
-
-#include "array_list.h"
-#include "celix_errno.h"
-#include "data.h"
-#include "database.h"
-
-#include "writer_service.h"
-
-celix_status_t writerService_storeData(database_handler_pt handler, data_pt newData)
-{
- celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-
- celixThreadMutex_lock(&handler->lock);
-
- if ( arrayList_add(handler->data, newData) == true)
- status = CELIX_SUCCESS;
-
- celixThreadMutex_unlock(&handler->lock);
- return status;
-}
-
-
-celix_status_t writerService_removeData(database_handler_pt handler, data_pt* newData)
-{
- celix_status_t status = CELIX_BUNDLE_EXCEPTION;
-
- celixThreadMutex_lock(&handler->lock);
-
- if ( arrayList_removeElement(handler->data, *newData) == true)
- status = CELIX_SUCCESS;
-
- free(*newData);
-
- celixThreadMutex_unlock(&handler->lock);
- return status;
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/public/include/data.h
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/public/include/data.h b/examples/producer_consumer/database/public/include/data.h
deleted file mode 100644
index d5bd059..0000000
--- a/examples/producer_consumer/database/public/include/data.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * data.h
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef _DATA_H_
-#define _DATA_H_
-
-struct data {
- int id;
- char description[100];
-};
-
-typedef struct data* data_pt;
-
-#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/public/include/database.h
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/public/include/database.h b/examples/producer_consumer/database/public/include/database.h
deleted file mode 100644
index 054fac0..0000000
--- a/examples/producer_consumer/database/public/include/database.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * database.h
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-
-#ifndef _DATABASE_H_
-#define _DATABASE_H_
-
-#include "array_list.h"
-#include "celix_threads.h"
-
-struct database_handler {
- celix_thread_mutex_t lock;
- array_list_pt data;
- int dataIndex;
-};
-
-typedef struct database_handler* database_handler_pt;
-
-#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/public/include/reader_service.h
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/public/include/reader_service.h b/examples/producer_consumer/database/public/include/reader_service.h
deleted file mode 100644
index e27e843..0000000
--- a/examples/producer_consumer/database/public/include/reader_service.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * reader_service.h
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-
-#ifndef READER_SERVICE_H_
-#define READER_SERVICE_H_
-
-#include "celix_errno.h"
-#include "data.h"
-#include "database.h"
-
-#define READER_SERVICE_NAME "service.database.reader"
-
-
-struct reader_service {
- database_handler_pt handler;
- celix_status_t (*readerService_getFirstData)(database_handler_pt handle, data_pt firstData);
- celix_status_t (*readerService_getNextData)(database_handler_pt handle, data_pt* nextData);
-};
-
-typedef struct reader_service* reader_service_pt;
-
-
-
-#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/database/public/include/writer_service.h
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/public/include/writer_service.h b/examples/producer_consumer/database/public/include/writer_service.h
deleted file mode 100644
index 936bbbb..0000000
--- a/examples/producer_consumer/database/public/include/writer_service.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*
- * writer_service.h
- *
- * \date 16 Feb 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-
-
-#ifndef WRITER_SERVICE_H_
-#define WRITER_SERVICE_H_
-
-#include "celix_errno.h"
-#include "data.h"
-#include "database.h"
-
-#define WRITER_SERVICE_NAME "service.database.writer"
-
-struct writer_service {
- void *handler;
- celix_status_t (*writerService_storeData)(database_handler_pt handle, data_pt data);
- celix_status_t (*writerService_removeData)(database_handler_pt handle, data_pt* data);
-};
-
-typedef struct writer_service* writer_service_pt;
-
-#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/producer_consumer/producer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/producer/CMakeLists.txt b/examples/producer_consumer/producer/CMakeLists.txt
deleted file mode 100644
index 83ba7d4..0000000
--- a/examples/producer_consumer/producer/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/examples/producer_consumer/database/public/include")
-
-add_bundle(producer
- VERSION 1.0.0
- SOURCES
- private/src/activator.c
-)
-
-target_link_libraries(producer celix_framework)
\ No newline at end of file
[6/8] celix git commit: CELIX-282: Removes superfluous examples.
Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
----------------------------------------------------------------------
diff --git a/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c b/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
deleted file mode 100644
index 02470b3..0000000
--- a/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <math.h>
-
-#include "benchmark.h"
-
-static const char * const BENCHMARK_NAME = "MUTEX";
-static const double SAMPLE_FACTOR = 1;
-
-struct benchmark {
- pthread_mutex_t mutex;
- math_service_pt math;
-};
-
-typedef struct thread_info {
- benchmark_pt benchmark;
- int nrOfSamples;
- unsigned int result;
- struct timeval begin;
- struct timeval end;
- unsigned int skips;
-} thread_info_t;
-
-static void benchmark_thread(thread_info_t *info);
-
-celix_status_t benchmark_create(benchmark_pt *benchmark) {
- (*benchmark) = malloc(sizeof(struct benchmark));
- (*benchmark)->math = NULL;
- pthread_mutex_init(&(*benchmark)->mutex, NULL);
- return CELIX_SUCCESS;
-}
-
-celix_status_t benchmark_destroy(benchmark_pt benchmark) {
- free(benchmark);
- return CELIX_SUCCESS;
-}
-
-benchmark_result_t benchmark_run(benchmark_pt benchmark, int nrOfThreads, int nrOfSamples) {
- int i;
- pthread_t threads[nrOfThreads];
- thread_info_t infos[nrOfThreads];
- benchmark_result_t result;
- memset(&result,0,sizeof(benchmark_result_t));
- unsigned long elapsedTime = 0;
-
- result.skips =0;
-
- for (i = 0 ; i < nrOfThreads ; i += 1) {
- infos[i].benchmark = benchmark;
- infos[i].nrOfSamples = nrOfSamples;
- infos[i].skips = 0;
- infos[i].result = rand();
- pthread_create(&threads[i], NULL, (void *)benchmark_thread, &infos[i]);
- }
-
- for (i = 0; i < nrOfThreads ; i += 1) {
- pthread_join(threads[i], NULL);
- elapsedTime += ((infos[i].end.tv_sec - infos[i].begin.tv_sec) * 1000000) + (infos[i].end.tv_usec - infos[i].begin.tv_usec);
- result.skips += infos[i].skips;
- }
-
- unsigned int actualSamples = (nrOfSamples * nrOfThreads) - result.skips;
- if(elapsedTime != 0){
- result.averageCallTimeInNanoseconds = actualSamples == 0 ? NAN : ((double)elapsedTime * 1000) / (nrOfSamples * nrOfThreads);
- result.callFrequencyInMhz = ((double)(actualSamples * nrOfThreads) / elapsedTime);
- }
- result.nrOfThreads = nrOfThreads;
- result.nrOfsamples = actualSamples;
- result.requestedNrOfSamples = (nrOfSamples * nrOfThreads);
-
- return result;
-}
-
-static void benchmark_thread(thread_info_t *info) {
- int i;
-
- gettimeofday(&info->begin, NULL);
- for (i = 0; i < info->nrOfSamples; i += 1) {
- pthread_mutex_lock(&info->benchmark->mutex);
- if (info->benchmark->math != NULL) {
- info->result = info->benchmark->math->calc(info->benchmark->math->handle, info->result, i);
- } else {
- info->skips += 1; //should not happen
- }
- pthread_mutex_unlock(&info->benchmark->mutex);
- }
- gettimeofday(&info->end, NULL);
-
-}
-
-char * benchmark_getName(benchmark_pt benchmark) {
- return (char *)BENCHMARK_NAME;
-}
-
-celix_status_t benchmark_addMathService(benchmark_pt benchmark, math_service_pt mathService) {
- pthread_mutex_lock(&benchmark->mutex);
- benchmark->math = mathService;
- pthread_mutex_unlock(&benchmark->mutex);
- return CELIX_SUCCESS;
-}
-
-celix_status_t benchmark_removeMathService(benchmark_pt benchmark, math_service_pt mathService) {
- pthread_mutex_lock(&benchmark->mutex);
- if (benchmark->math == mathService) {
- benchmark->math = NULL;
- }
- pthread_mutex_unlock(&benchmark->mutex);
- return CELIX_SUCCESS;
-
-}
-
-double benchmark_getSampleFactor(benchmark_pt benchmark) {
- return SAMPLE_FACTOR;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/reference_benchmark/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/locking/reference_benchmark/CMakeLists.txt b/examples/locking/reference_benchmark/CMakeLists.txt
deleted file mode 100644
index 017d195..0000000
--- a/examples/locking/reference_benchmark/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_bundle(reference_benchmark SOURCES
- ../benchmark/public/src/benchmark_activator
- private/src/reference_benchmark
-)
-
-include_directories(public/include)
-include_directories(../benchmark/public/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
-target_link_libraries(reference_benchmark celix_framework)
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/reference_benchmark/private/src/reference_benchmark.c
----------------------------------------------------------------------
diff --git a/examples/locking/reference_benchmark/private/src/reference_benchmark.c b/examples/locking/reference_benchmark/private/src/reference_benchmark.c
deleted file mode 100644
index 0cc0c33..0000000
--- a/examples/locking/reference_benchmark/private/src/reference_benchmark.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-#include "benchmark.h"
-
-static const char * const BENCHMARK_NAME = "REFERENCE";
-static const double SAMPLE_FACTOR = 100;
-
-typedef struct thread_info {
- benchmark_pt benchmark;
- int nrOfSamples;
- unsigned int result;
- struct timeval begin;
- struct timeval end;
- int skips;
-} thread_info_t;
-
-static void benchmark_thread(thread_info_t *info);
-static int benchmark_calc(int arg1, int arg2);
-
-celix_status_t benchmark_create(benchmark_pt *benchmark) {
- //do nothing
- return CELIX_SUCCESS;
-}
-
-celix_status_t benchmark_destroy(benchmark_pt benchmark) {
- //do nothing
- return CELIX_SUCCESS;
-}
-
-benchmark_result_t benchmark_run(benchmark_pt benchmark, int nrOfThreads, int nrOfSamples) {
- int i;
- pthread_t threads[nrOfThreads];
- thread_info_t infos[nrOfThreads];
- benchmark_result_t result;
- unsigned long elapsedTime = 0;
-
- result.skips =0;
-
- for (i = 0 ; i < nrOfThreads ; i += 1) {
- infos[i].benchmark = benchmark;
- infos[i].nrOfSamples = nrOfSamples;
- infos[i].skips = 0;
- infos[i].result = rand();
- pthread_create(&threads[i], NULL, (void *)benchmark_thread, &infos[i]);
- }
-
- for (i = 0; i < nrOfThreads ; i += 1) {
- pthread_join(threads[i], NULL);
- elapsedTime += ((infos[i].end.tv_sec - infos[i].begin.tv_sec) * 1000000) + (infos[i].end.tv_usec - infos[i].begin.tv_usec);
- result.skips += infos[i].skips;
- }
-
- result.averageCallTimeInNanoseconds = elapsedTime;
- result.averageCallTimeInNanoseconds *= 1000;
- result.averageCallTimeInNanoseconds /= nrOfSamples;
- result.averageCallTimeInNanoseconds /= nrOfThreads;
- result.callFrequencyInMhz = ((double)(nrOfSamples * nrOfThreads) / elapsedTime);
- result.nrOfThreads = nrOfThreads;
- result.nrOfsamples = nrOfSamples;
-
- return result;
-}
-
-static void benchmark_thread(thread_info_t *info) {
- int i;
-
- int result = info->result;
- struct timeval *begin = &info->begin;
- struct timeval *end = &info->end;
- int nrOFSamples = info->nrOfSamples;
-
-
- gettimeofday(begin, NULL);
- for (i = 0; i < nrOFSamples; i += 1) {
- result = benchmark_calc(result, i);
- }
- gettimeofday(end, NULL);
-
- info->result = result;
-}
-
-char * benchmark_getName(benchmark_pt benchmark) {
- return (char *)BENCHMARK_NAME;
-}
-
-celix_status_t benchmark_addMathService(benchmark_pt benchmark, math_service_pt mathService) {
- //ignore service is not used
- return CELIX_SUCCESS;
-}
-
-celix_status_t benchmark_removeMathService(benchmark_pt benchmark, math_service_pt mathService) {
- //ignore service is not used
- return CELIX_SUCCESS;
-
-}
-
-/*
- * Same implementation as the math_service. This function is used a reference.
- */
-static int benchmark_calc(int arg1, int arg2) {
- return arg1 * arg2 + arg2;
-}
-
-double benchmark_getSampleFactor(benchmark_pt benchmark) {
- return SAMPLE_FACTOR;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/services/benchmark_service.h
----------------------------------------------------------------------
diff --git a/examples/locking/services/benchmark_service.h b/examples/locking/services/benchmark_service.h
deleted file mode 100644
index d0a1a9c..0000000
--- a/examples/locking/services/benchmark_service.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-#ifndef BENCHMARK_SERVICE_H_
-#define BENCHMARK_SERVICE_H_
-
-#include "benchmark_result.h"
-
-typedef struct benchmark_service *benchmark_service_pt;
-
-typedef struct benchmark_handler *benchmark_handler_pt; //ADT
-
-#define BENCHMARK_SERVICE_NAME "benchmark_service"
-
-struct benchmark_service {
- benchmark_handler_pt handler;
-
- benchmark_result_t (*run)(benchmark_handler_pt handler, int nrOfThreads, int nrOfSamples);
- char * (*name)(benchmark_handler_pt handler);
- double (*getSampleFactor)(benchmark_handler_pt benchmark);
-};
-
-#endif /* BENCHMARK_SERVICE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/services/frequency_service.h
----------------------------------------------------------------------
diff --git a/examples/locking/services/frequency_service.h b/examples/locking/services/frequency_service.h
deleted file mode 100644
index 8f4ad12..0000000
--- a/examples/locking/services/frequency_service.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * frequence_service.h
- *
- * \date Feb 4, 2014
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-//TODO change to math provider service ???
-
-#ifndef FREQUENCY_SERVICE_H
-#define FREQUENCY_SERVICE_H
-
-#define FREQUENCY_SERVICE_NAME "frequency_service"
-
-typedef struct frequency_hander frequence_handler_t;
-
-struct frequency_service {
- frequence_handler_t *handle;
- void (*setFrequency)(frequence_handler_t *handle, double freq);
- void (*resetCounter)(frequence_handler_t *handle);
- unsigned int (*getCounter)(frequence_handler_t *handle);
- void (*setBenchmarkName)(frequence_handler_t *handle, char *name);
- void (*setNrOfThreads)(frequence_handler_t *handle, unsigned int nrOfThreads);
-};
-
-typedef struct frequency_service * frequency_service_pt;
-
-#endif /* FREQUENCY_SERVICE_H */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/services/math_service.h
----------------------------------------------------------------------
diff --git a/examples/locking/services/math_service.h b/examples/locking/services/math_service.h
deleted file mode 100644
index 23de461..0000000
--- a/examples/locking/services/math_service.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * echo_server.h
- *
- * \date Sep 21, 2010
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef MATH_SERVICE_H
-#define MATH_SERVICE_H
-
-#define MATH_SERVICE_NAME "math_service"
-
-
-struct math_service {
- void *handle;
- int (*calc)(void *handle, int arg1, int arg2);
-};
-
-typedef struct math_service *math_service_pt;
-
-#endif /* MATH_SERVICE_H */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/start_stop_benchmark/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/locking/start_stop_benchmark/CMakeLists.txt b/examples/locking/start_stop_benchmark/CMakeLists.txt
deleted file mode 100644
index ec88166..0000000
--- a/examples/locking/start_stop_benchmark/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_bundle(start_stop_benchmark SOURCES
- ../benchmark/public/src/benchmark_activator
- private/src/start_stop_benchmark
-)
-
-include_directories(public/include)
-include_directories(../benchmark/public/include)
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
-target_link_libraries(start_stop_benchmark celix_framework)
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/locking/start_stop_benchmark/private/src/start_stop_benchmark.c
----------------------------------------------------------------------
diff --git a/examples/locking/start_stop_benchmark/private/src/start_stop_benchmark.c b/examples/locking/start_stop_benchmark/private/src/start_stop_benchmark.c
deleted file mode 100644
index b86af52..0000000
--- a/examples/locking/start_stop_benchmark/private/src/start_stop_benchmark.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <stdio.h>
-
-#include "benchmark.h"
-
-static const char * const BENCHMARK_NAME = "INTR_CONT";
-static const double SAMPLE_FACTOR = 100;
-static const __useconds_t WAIT_TIME = 1; //100 * 1000;
-
-typedef enum benchmark_state {
- BENCHMARK_STATE_INTERRUPTED,
- BENCHMARK_STATE_RUNNING
-} benchmark_state_t;
-
-struct benchmark {
- int nrOfThreads;
- pthread_mutex_t mutex; //write protect for state
- math_service_pt math;
- benchmark_state_t state;
- int threadsRunning;
-};
-
-typedef struct thread_info {
- benchmark_pt benchmark;
- int nrOfSamples;
- unsigned int result;
- struct timeval begin;
- struct timeval end;
- int skips;
-} thread_info_t;
-
-static void benchmark_thread(thread_info_t *info);
-static void benchmark_runSamples(thread_info_t *info, int *i, volatile benchmark_state_t *state);
-static void benchmark_interrupt(benchmark_pt benchmark);
-static void benchmark_continue(benchmark_pt benchmark);
-
-celix_status_t benchmark_create(benchmark_pt *benchmark) {
- (*benchmark) = malloc(sizeof(struct benchmark));
- (*benchmark)->math = NULL;
- (*benchmark)->state = BENCHMARK_STATE_INTERRUPTED;
- (*benchmark)->nrOfThreads = 0;
- (*benchmark)->threadsRunning = 0;
-
- pthread_mutex_init(&(*benchmark)->mutex, NULL);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t benchmark_destroy(benchmark_pt benchmark) {
- free(benchmark);
-
- return CELIX_SUCCESS;
-}
-
-benchmark_result_t benchmark_run(benchmark_pt benchmark, int nrOfThreads, int nrOfSamples) {
- int i;
- pthread_t threads[nrOfThreads];
- thread_info_t infos[nrOfThreads];
- int isThreadRunning[nrOfThreads];
- benchmark_result_t result;
- unsigned long elapsedTime = 0;
- result.skips =0;
-
- for (i = 0 ; i < nrOfThreads ; i += 1) {
- infos[i].benchmark = benchmark;
- infos[i].nrOfSamples = nrOfSamples;
- infos[i].skips = 0;
- infos[i].result = rand();
- pthread_create(&threads[i], NULL, (void *)benchmark_thread, &infos[i]);
- }
-
- benchmark->nrOfThreads = nrOfThreads;
-
- for (i = 0; i < nrOfThreads ; i += 1) {
- pthread_join(threads[i], NULL);
- elapsedTime += ((infos[i].end.tv_sec - infos[i].begin.tv_sec) * 1000000) + (infos[i].end.tv_usec - infos[i].begin.tv_usec);
- result.skips += infos[i].skips;
- }
-
- benchmark->nrOfThreads = 0;
-
- result.averageCallTimeInNanoseconds = elapsedTime;
- result.averageCallTimeInNanoseconds *= 1000;
- result.averageCallTimeInNanoseconds /= nrOfSamples;
- result.averageCallTimeInNanoseconds /= nrOfThreads;
- result.callFrequencyInMhz = ((double)(nrOfSamples * nrOfThreads) / elapsedTime);
- result.nrOfThreads = nrOfThreads;
- result.nrOfsamples = nrOfSamples;
-
- return result;
-}
-
-static void benchmark_thread(thread_info_t *info) {
- int i = 0;
-
- gettimeofday(&info->begin, NULL);
- while (i < info->nrOfSamples) {
- if (info->benchmark->state == BENCHMARK_STATE_RUNNING ) {
- //TODO race condition?? or not because of the mutex on changing the state
- __sync_add_and_fetch(&info->benchmark->threadsRunning, 1);
- benchmark_runSamples(info, &i, &info->benchmark->state);
- __sync_sub_and_fetch(&info->benchmark->threadsRunning, 1);
- } else {
- usleep(WAIT_TIME);
- }
- }
- gettimeofday(&info->end, NULL);
-
-}
-
-static void benchmark_runSamples(thread_info_t *info, int *i, volatile benchmark_state_t *state) {
- int nrOfSamples = info->nrOfSamples;
- unsigned int result = info->result;
- math_service_pt math = info->benchmark->math;
-
- for (; *i < nrOfSamples && *state == BENCHMARK_STATE_RUNNING; *i += 1) {
- result = math->calc(math->handle, result, *i);
- }
-
- info->result = result;
-}
-
-char * benchmark_getName(benchmark_pt benchmark) {
- return (char *)BENCHMARK_NAME;
-}
-
-static void benchmark_continue(benchmark_pt benchmark) {
- benchmark->state = BENCHMARK_STATE_RUNNING;
- unsigned long waitTime = 0;
- while (benchmark->threadsRunning < benchmark->nrOfThreads) {
- usleep(WAIT_TIME);
- waitTime += WAIT_TIME;
- if (waitTime > 1000 * 1000 * 2) {
- printf("still waiting to stop, running threads are %i\n",
- benchmark->threadsRunning);
- }
- }
-}
-
-static void benchmark_interrupt(benchmark_pt benchmark) {
- int i = 0;
- unsigned long waitTime = 0;
- if (benchmark->state == BENCHMARK_STATE_RUNNING) {
- benchmark->state = BENCHMARK_STATE_INTERRUPTED;
- while (benchmark->threadsRunning > 0) {
- usleep(WAIT_TIME);
- waitTime += WAIT_TIME;
- if (waitTime > 1000 * 1000 * 2) {
- printf("still waiting to stop, running threads are %i\n",
- benchmark->threadsRunning);
- }
- }
- }
-}
-
-celix_status_t benchmark_addMathService(benchmark_pt benchmark, math_service_pt mathService) {
- pthread_mutex_lock(&benchmark->mutex);
- benchmark_interrupt(benchmark);
- benchmark->math = mathService;
- benchmark_continue(benchmark);
- pthread_mutex_unlock(&benchmark->mutex);
- return CELIX_SUCCESS;
-}
-
-celix_status_t benchmark_removeMathService(benchmark_pt benchmark, math_service_pt mathService) {
- pthread_mutex_lock(&benchmark->mutex);
- if (benchmark->math == mathService) {
- benchmark_interrupt(benchmark);
- benchmark->math = NULL;
- benchmark_continue(benchmark);
- }
- pthread_mutex_unlock(&benchmark->mutex);
- return CELIX_SUCCESS;
-
-}
-
-double benchmark_getSampleFactor(benchmark_pt benchmark) {
- return SAMPLE_FACTOR;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/mongoose/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/mongoose/CMakeLists.txt b/examples/mongoose/CMakeLists.txt
index 8a71ac1..f4250ef 100644
--- a/examples/mongoose/CMakeLists.txt
+++ b/examples/mongoose/CMakeLists.txt
@@ -38,3 +38,5 @@ add_bundle(mongoose
bundle_files(mongoose ${CMAKE_CURRENT_LIST_DIR}/root)
target_link_libraries(mongoose celix_framework mongooselib ${LIBS})
+
+add_deploy("mongoose_deploy" BUNDLES shell shell_tui log_service mongoose)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/CMakeLists.txt b/examples/osgi-in-action/chapter01-greeting-example/CMakeLists.txt
deleted file mode 100644
index 5434968..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_subdirectory(greeting)
-add_subdirectory(client)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/README.TXT
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/README.TXT b/examples/osgi-in-action/chapter01-greeting-example/README.TXT
deleted file mode 100644
index 1e4f7ef..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/README.TXT
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-The example activates the bundles `chapter01-greeting-example` and `chapter01-greeting-example-client`.
-The activator of the client bundle (client.c) tries to find the greeting service, but may fail at start-up,
-because it is activated before the greeting service is installed.
-
-When the text 'Greetings' does not appear, stop and start the `chapter01-greeting-example-client` bundle.
-Now the `chapter01-greeting-example` is already installed and the text `Greetings` does appear after the
-restart of the client bundle.
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt b/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt
deleted file mode 100644
index 4639292..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/client/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_bundle(chapter01-greeting-example-client VERSION 0.0.1 SOURCES private/src/client)
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("../greeting/public/include")
-target_link_libraries(chapter01-greeting-example-client celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/client/private/src/client.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/client/private/src/client.c b/examples/osgi-in-action/chapter01-greeting-example/client/private/src/client.c
deleted file mode 100644
index dfae0ce..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/client/private/src/client.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * client.c
- *
- * \date Sep 29, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "bundle_activator.h"
-#include "greeting_service.h"
-
-
-celix_status_t bundleActivator_create(bundle_context_pt __attribute__((unused)) context, void **userData) {
- *userData = NULL;
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void __attribute__((unused)) * userData, bundle_context_pt ctx) {
- service_reference_pt ref = NULL;
- celix_status_t status = bundleContext_getServiceReference(ctx, (char *) GREETING_SERVICE_NAME, &ref);
- if (status == CELIX_SUCCESS) {
- if (ref == NULL) {
- printf("Greeting service reference not available\n");
- } else {
- greeting_service_pt greeting = NULL;
- bundleContext_getService(ctx, ref, (void *) &greeting);
- if (greeting == NULL){
- printf("Greeting service not available\n");
- } else {
- bool result;
- (*greeting->greeting_sayHello)(greeting->instance);
- bundleContext_ungetService(ctx, ref, &result);
- }
- }
- }
- return status;
-}
-
-celix_status_t bundleActivator_stop(void __attribute__((unused)) * userData, bundle_context_pt __attribute__((unused)) context) {
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void __attribute__((unused)) * userData, bundle_context_pt __attribute__((unused)) context) {
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt b/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt
deleted file mode 100644
index 625cbda..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/greeting/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_bundle(chapter01-greeting-example VERSION 0.0.1 SOURCES
- private/src/activator
- private/src/greeting_impl
-
- private/include/greeting_impl.h
-)
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("public/include")
-include_directories("private/include")
-target_link_libraries(chapter01-greeting-example celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/greeting/private/include/greeting_impl.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/greeting/private/include/greeting_impl.h b/examples/osgi-in-action/chapter01-greeting-example/greeting/private/include/greeting_impl.h
deleted file mode 100644
index 8ea2091..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/greeting/private/include/greeting_impl.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * greeting_impl.h
- *
- * \date Sep 29, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#ifndef GREETING_IMPL_H_
-#define GREETING_IMPL_H_
-
-#include "greeting_service.h"
-
-struct greeting {
- char *name;
-};
-
-extern void greeting_sayHello(greeting_pt instance);
-
-
-#endif /* GREETING_IMPL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c b/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c
deleted file mode 100644
index d5b0b3f..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- * \date Sep 29, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "bundle_activator.h"
-#include "greeting_impl.h"
-
-struct greetingActivator {
- service_registration_pt reg;
- greeting_service_pt greetingService;
-};
-
-typedef struct greetingActivator *greeting_activator_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt __attribute__((unused)) context, void **userData) {
- celix_status_t status = CELIX_SUCCESS;
- greeting_activator_pt activator;
- *userData = calloc(1, sizeof(struct greetingActivator));
- if (*userData) {
- activator = *userData;
- activator->reg = NULL;
- } else {
- status = CELIX_ENOMEM;
- }
- return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
- celix_status_t status;
-
- greeting_activator_pt act = (greeting_activator_pt) userData;
-
- act->greetingService = calloc(1, sizeof(*act->greetingService));
-
- if (act->greetingService) {
- act->greetingService->instance = calloc(1, sizeof(*act->greetingService->instance));
- if (act->greetingService->instance) {
- act->greetingService->instance->name = GREETING_SERVICE_NAME;
- act->greetingService->greeting_sayHello = greeting_sayHello;
-
- status = bundleContext_registerService(context, GREETING_SERVICE_NAME, act->greetingService, NULL, &act->reg);
- } else {
- status = CELIX_ENOMEM;
- }
- } else {
- status = CELIX_ENOMEM;
- }
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt __attribute__((unused)) context) {
- celix_status_t status = CELIX_SUCCESS;
-
- greeting_activator_pt act = (greeting_activator_pt) userData;
-
- serviceRegistration_unregister(act->reg);
- act->reg = NULL;
-
- free(act->greetingService->instance);
- free(act->greetingService);
-
- return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt __attribute__((unused)) context) {
- free(userData);
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/greeting_impl.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/greeting_impl.c b/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/greeting_impl.c
deleted file mode 100644
index abe60cc..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/greeting_impl.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * greeting_impl.c
- *
- * \date Sep 29, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdio.h>
-#include "greeting_impl.h"
-
-void greeting_sayHello(greeting_pt instance){
- printf("Greetings from %s\n", instance->name);
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter01-greeting-example/greeting/public/include/greeting_service.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter01-greeting-example/greeting/public/include/greeting_service.h b/examples/osgi-in-action/chapter01-greeting-example/greeting/public/include/greeting_service.h
deleted file mode 100644
index 9b528ef..0000000
--- a/examples/osgi-in-action/chapter01-greeting-example/greeting/public/include/greeting_service.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * greeting_service.h
- *
- * \date Sep 29, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#ifndef GREETING_H_
-#define GREETING_H_
-
-#define GREETING_SERVICE_NAME "greeting-service"
-
-typedef struct greeting *greeting_pt;
-typedef struct greeting_service *greeting_service_pt;
-
-struct greeting_service {
- greeting_pt instance;
- void (*greeting_sayHello)(greeting_pt instance);
-};
-
-#endif /* GREETING_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt b/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt
deleted file mode 100644
index 2e68124..0000000
--- a/examples/osgi-in-action/chapter04-correct-listener/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-SET(BUNDLE_SYMBOLICNAME "apache_celix_examples_chapter04_correct_listener")
-add_bundle(chapter04-correct-listener VERSION 0.0.1 SOURCES private/src/listener_example)
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-target_link_libraries(chapter04-correct-listener celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-correct-listener/README.TXT
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-correct-listener/README.TXT b/examples/osgi-in-action/chapter04-correct-listener/README.TXT
deleted file mode 100644
index 355d1ad..0000000
--- a/examples/osgi-in-action/chapter04-correct-listener/README.TXT
+++ /dev/null
@@ -1,23 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-In the log server a listener registers when the log_service bundle is stopped and
-started by means of the serviceChanged() routine. This routine maintains the set of log
-services in the variable m_logServiceRefs. The function getLogService() returns the
-current LOG_SERVICE, if it is active or NULL.
-Starting and stopping the log_service bundle shows that the logServiceTest thread
-correctly recognizes the non-availability of the log_services, when stopped.
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c b/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
deleted file mode 100644
index 5ee35a3..0000000
--- a/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * listener_example.c
- *
- * \date Sep 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "bundle_activator.h"
-#include "log_service.h"
-
-struct listenerActivator {
- bundle_context_pt context;
- service_listener_pt listener;
-
- celix_thread_t logger;
- celix_thread_mutex_t logServiceReferencesLock;
-
- array_list_pt logServiceReferences;
-
- bool running;
-};
-
-void listenerExample_serviceChanged(service_listener_pt listener, service_event_pt event);
-celix_status_t listenerExample_getLogService(struct listenerActivator *activator, log_service_pt *service);
-
-static void* listenerExample_logger(void* data);
-
-celix_status_t listenerExample_alternativeLog(struct listenerActivator *activator, char *message);
-
-static celix_status_t ref_equals(const void *a, const void *b, bool *equals) {
- return serviceReference_equals((void*)a, (void*)b, equals);
-}
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- celix_status_t status = CELIX_SUCCESS;
-
- *userData = calloc(1, sizeof(struct listenerActivator));
- if (!*userData) {
- status = CELIX_ENOMEM;
- } else {
- struct listenerActivator *activator = (*userData);
- activator->context = context;
- activator->listener = NULL;
- activator->logServiceReferences = NULL;
- arrayList_createWithEquals(ref_equals, &activator->logServiceReferences);
- activator->running = false;
-
- status = celixThreadMutex_create(&activator->logServiceReferencesLock, NULL);
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct listenerActivator *activator = userData;
-
- service_listener_pt listener = calloc(1, sizeof(*listener));
- if (!listener) {
- status = CELIX_ENOMEM;
- } else {
- char filter[30];
- array_list_pt logServices = NULL;
- sprintf(filter, "(objectClass=%s)", OSGI_LOGSERVICE_NAME);
-
- listener->handle = activator;
- listener->serviceChanged = (void *) listenerExample_serviceChanged;
- status = bundleContext_addServiceListener(context, listener, filter);
- if (status == CELIX_SUCCESS) {
- activator->listener = listener;
- }
-
- status = bundleContext_getServiceReferences(context, NULL, filter, &logServices);
- if (status == CELIX_SUCCESS) {
- int i;
- for (i = 0; i < arrayList_size(logServices); i++) {
- service_reference_pt logService = (service_reference_pt) arrayList_get(logServices, i);
- service_event_pt event = calloc(1, sizeof(*event));
- event->reference = logService;
- event->type = OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED;
-
- listenerExample_serviceChanged(listener, event);
- free(event);
- }
- arrayList_destroy(logServices);
- }
-
- activator->running = true;
-
- status = celixThread_create(&activator->logger, NULL, listenerExample_logger, activator);
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct listenerActivator *activator = userData;
-
- activator->running = false;
- celixThread_join(activator->logger, NULL);
-
- bundleContext_removeServiceListener(context, activator->listener);
-
- return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct listenerActivator *activator = userData;
- arrayList_destroy(activator->logServiceReferences);
- return status;
-}
-
-void listenerExample_serviceChanged(service_listener_pt listener, service_event_pt event) {
- struct listenerActivator *activator = listener->handle;
- celixThreadMutex_lock(&activator->logServiceReferencesLock);
-
- switch (event->type) {
- case OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED:
- arrayList_add(activator->logServiceReferences, event->reference);
- break;
-// case MODIFIED:
-// // only the service metadata has changed, so no need to do anything here
-// break;
- case OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING:
- arrayList_removeElement(activator->logServiceReferences, event->reference);
- break;
- default:
- break;
- }
-
- celixThreadMutex_unlock(&activator->logServiceReferencesLock);
-}
-
-celix_status_t listenerExample_getLogService(struct listenerActivator *activator, log_service_pt *service) {
- celix_status_t status = CELIX_SUCCESS;
-
- celixThreadMutex_lock(&activator->logServiceReferencesLock);
-
- if (arrayList_size(activator->logServiceReferences) > 0) {
- service_reference_pt reference = arrayList_get(activator->logServiceReferences, 0);
- status = bundleContext_getService(activator->context, reference, (void *) service);
- }
- celixThreadMutex_unlock(&activator->logServiceReferencesLock);
-
- return status;
-}
-
-static void* listenerExample_logger(void* data) {
- struct listenerActivator *activator = data;
-
- while (activator->running) {
- log_service_pt logService = NULL;
- listenerExample_getLogService(activator, &logService);
- if (logService != NULL) {
- (*(logService->log))(logService->logger, OSGI_LOGSERVICE_INFO, "ping");
- } else {
- listenerExample_alternativeLog(activator, "No LogService available. Printing to standard out.");
- }
-
- sleep(5);
- }
-
- return NULL;
-}
-
-celix_status_t listenerExample_alternativeLog(struct listenerActivator *activator, char *message) {
- celix_status_t status = CELIX_SUCCESS;
-
- printf("%s\n", message);
-
- return status;
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt b/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt
deleted file mode 100644
index abbb3cf..0000000
--- a/examples/osgi-in-action/chapter04-correct-lookup/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_bundle(chapter04-correct-lookup VERSION 0.0.1 SOURCES private/src/activator)
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-target_link_libraries(chapter04-correct-lookup celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c b/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
deleted file mode 100644
index 19cf093..0000000
--- a/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- * \date Sep 29, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "bundle_activator.h"
-#include "log_service.h"
-
-typedef log_service_pt LOG_SERVICE;
-
-struct threadData {
- char * service;
- int threadId;
- bundle_context_pt m_context;
- bool running;
-};
-
-typedef struct threadData *thread_data_pt;
-
-static celix_thread_t m_logTestThread;
-
-//*******************************************************************************
-// function prototypes
-//*******************************************************************************
-void startTestThread(thread_data_pt data);
-void stopTestThread();
-void pauseTestThread();
-void alternativeLog(char *message, thread_data_pt data);
-//*******************************************************************************
-// global functions
-//*******************************************************************************
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- celix_status_t status = CELIX_SUCCESS;
-
- *userData = calloc(1, sizeof(struct threadData));
-
- if ((*userData)==NULL) {
- status = CELIX_ENOMEM;
- } else {
- ((thread_data_pt) (*userData))->service = "chapter04-correct-lookup";
- ((thread_data_pt) (*userData))->threadId = 0;
- ((thread_data_pt) (*userData))->m_context = context;
- ((thread_data_pt) (*userData))->running = false;
- }
-
- return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-
- thread_data_pt thread_data = (thread_data_pt) userData;
-
- thread_data->m_context = context;
- thread_data->running = true;
-
- startTestThread(thread_data);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-
- thread_data_pt thread_data = (thread_data_pt) userData;
-
- thread_data->running = false;
-
- stopTestThread();
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-
- free(userData);
-
- return CELIX_SUCCESS;
-}
-
-//------------------------------------------------------------------------------------------
-// The rest of this is just support code, not meant to show any particular best practices
-//------------------------------------------------------------------------------------------
-
-// Test LogService by periodically sending a message
-
-static void* LogServiceTest(void* argument) {
- celix_status_t status = CELIX_SUCCESS;
- thread_data_pt data = (thread_data_pt) argument;
- bundle_context_pt m_context = data ->m_context;
-
- while (data->running == true) {
- service_reference_pt logServiceRef = NULL;
- // lookup the current "best" LogService each time, just before we need to use it
- status = bundleContext_getServiceReference(m_context, (char *) OSGI_LOGSERVICE_NAME, &logServiceRef);
- // if the service reference is null then we know there's no log service available
- if (status == CELIX_SUCCESS && logServiceRef != NULL) {
- void *log = NULL;
- LOG_SERVICE logService = NULL;
- bundleContext_getService(m_context, logServiceRef, &log);
- logService = (LOG_SERVICE) log;
- // if the dereferenced instance is null then we know the service has been removed
- if (logService != NULL) {
- (*(logService->log))(logService->logger, OSGI_LOGSERVICE_INFO, "ping");
- } else {
- alternativeLog("LogService has gone", data);
- }
- } else {
- alternativeLog("LogService has gone", data);
- }
- pauseTestThread();
- }
-
- return NULL;
-}
-
-void startTestThread(thread_data_pt data) {
- // start separate worker thread to run the actual tests, managed by the bundle lifecycle
- data->threadId++;
-
- celixThread_create(&m_logTestThread, NULL, LogServiceTest, data);
-}
-
-void stopTestThread() {
- celixThread_join(m_logTestThread, NULL);
-}
-
-void pauseTestThread() {
- // sleep for a bit
- sleep(5);
-}
-
-void alternativeLog(char *message, thread_data_pt data) {
- // this provides similar style debug logging output for when the LogService disappears
- celix_status_t status = CELIX_SUCCESS;
- bundle_pt bundle = NULL;
- char tid[20], bid[20];
- long bundleId;
- if (data->m_context != NULL) {
- status = bundleContext_getBundle(data->m_context, &bundle);
- if (status == CELIX_SUCCESS) {
- status = bundle_getBundleId(bundle, &bundleId);
- if (status == CELIX_SUCCESS) {
- sprintf(tid, "thread=%d", data->threadId);
- sprintf(bid, "bundle=%ld", bundleId);
- printf("<--> %s, %s : %s\n", tid, bid, message);
- } else {
- printf("%s:%s:%d:getBundleId failed: %s\n", __FILE__, __FUNCTION__, __LINE__, message);
- }
- } else {
- printf("%s:%s:%d:getBundle failed: %s\n", __FILE__, __FUNCTION__, __LINE__, message);
- }
- } else {
- printf("%s:%s:%d:bundle context NULL: %s\n", __FILE__, __FUNCTION__, __LINE__, message);
- }
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/CMakeLists.txt b/examples/osgi-in-action/chapter04-paint-example/CMakeLists.txt
deleted file mode 100644
index 23537c3..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-if(NOT ${WITH_APR})
- message(FATAL_ERROR "Paint example requires APR, enable WITH_APR option.")
-endif()
-find_package(PkgConfig)
-if(PKG_CONFIG_EXECUTABLE)
- add_subdirectory(circle)
- add_subdirectory(paint)
- add_subdirectory(square)
- add_subdirectory(triangle)
-
- add_deploy("chapter04-paint-example" BUNDLES chapter04-paint-example circle square triangle shell shell_tui log_service log_writer)
-else(PKG_CONFIG_EXECUTABLE)
- MESSAGE("No GTK found, not building the Paint Example")
-endif(PKG_CONFIG_EXECUTABLE)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/circle/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/circle/CMakeLists.txt b/examples/osgi-in-action/chapter04-paint-example/circle/CMakeLists.txt
deleted file mode 100644
index 5769ac9..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/circle/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-INCLUDE(FindPkgConfig)
-pkg_search_module (GLIB REQUIRED glib-2.0)
-pkg_search_module (GTHR REQUIRED gthread-2.0)
-pkg_search_module (GTK REQUIRED gtk+-2.0)
-include_directories(
- private/include
- ../simple/public/include
-)
-include_directories(${GTK_INCLUDE_DIRS})
-include_directories(${GLIB_INCLUDE_DIRS})
-include_directories(${GTHR_INCLUDE_DIRS})
-
-link_directories(${GTK_LIBRARY_DIRS})
-link_directories(${GLIB_LIBRARY_DIRS})
-link_directories(${GTHR_LIBRARY_DIRS})
-
-add_bundle(circle VERSION 0.0.1 SOURCES
- private/src/activator
- private/src/circle_shape
-
- private/include/circle_shape.h
- FILES
- private/src/circle.png
-)
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-target_link_libraries(circle celix_framework ${GLIB_LIBRARIES} ${GTK_LIBRARIES} ${GTHR_LIBRARIES})
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/circle/private/include/circle_shape.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/circle/private/include/circle_shape.h b/examples/osgi-in-action/chapter04-paint-example/circle/private/include/circle_shape.h
deleted file mode 100644
index e16c57d..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/circle/private/include/circle_shape.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * circle_shape.h
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#ifndef CIRCLE_SHAPE_H_
-#define CIRCLE_SHAPE_H_
-
-#include "celix_errno.h"
-
-celix_status_t circleShape_create(bundle_context_pt context, simple_shape_pt *shape);
-
-#endif /* CIRCLE_SHAPE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/circle/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/circle/private/src/activator.c b/examples/osgi-in-action/chapter04-paint-example/circle/private/src/activator.c
deleted file mode 100644
index a99396f..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/circle/private/src/activator.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <apr_general.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-
-#include "service_registration.h"
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "simple_shape.h"
-#include "circle_shape.h"
-#include "simple_shape.h"
-
-struct activator {
- service_registration_pt reg;
- apr_pool_t *pool;
-};
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- apr_pool_t *pool;
- struct activator *activator;
- celix_status_t status = bundleContext_getMemoryPool(context, &pool);
- if (status == CELIX_SUCCESS) {
- *userData = apr_palloc(pool, sizeof(struct activator));
- activator = *userData;
- activator->reg = NULL;
- activator->pool = pool;
- }
- return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
- struct activator * act = (struct activator *) userData;
- celix_status_t status = CELIX_SUCCESS;
- simple_shape_pt es = NULL;
- properties_pt props = NULL;
-
- circleShape_create(ctx, &es);
- props = properties_create();
- properties_set(props, "name", "circle");
- status = bundleContext_registerService(ctx, SIMPLE_SHAPE_SERVICE_NAME, es, props, &act->reg);
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- celix_status_t status = CELIX_SUCCESS;
- struct activator * act = (struct activator *) userData;
-
- status = serviceRegistration_unregister(act->reg);
-
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle.png
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle.png b/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle.png
deleted file mode 100644
index 3d4887e..0000000
Binary files a/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle_shape.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle_shape.c b/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle_shape.c
deleted file mode 100644
index 5104b5f..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle_shape.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * circle_shape.c
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <string.h>
-#include <celixbool.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-#include "bundle_context.h"
-#include "bundle.h"
-#include "hash_map.h"
-#include "simple_shape.h"
-#include "circle_shape.h"
-
-#define CIRCLE_FILE "circle.png"
-
-void circleShape_draw(simple_shape_pt shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y);
-
-celix_status_t circleShape_create(bundle_context_pt context, simple_shape_pt *shape) {
- celix_status_t status = CELIX_SUCCESS;
-
- bundle_pt bundle;
- apr_pool_t *pool;
-
- if (*shape != NULL || context == NULL) {
- status = CELIX_ILLEGAL_ARGUMENT;
- } else {
- status = bundleContext_getBundle(context, &bundle);
- if (status == CELIX_SUCCESS) {
- status = bundleContext_getMemoryPool(context, &pool);
- if (status == CELIX_SUCCESS) {
- *shape = (simple_shape_pt) apr_palloc(pool, sizeof(**shape));
- if (!*shape) {
- status = CELIX_ENOMEM;
- } else {
- celix_status_t status = CELIX_SUCCESS;
- (*shape)->name = "Circle";
- (*shape)->icon_path = NULL;
- status = bundle_getEntry(bundle, CIRCLE_FILE, pool, &(*shape)->icon_path);
- if (status == CELIX_SUCCESS) {
- (*shape)->simpleShape_draw = circleShape_draw;
- } else {
- printf("Could not find resource %s\n", CIRCLE_FILE);
- }
- }
- }
- }
- }
- return status;
-}
-
-void circleShape_draw(simple_shape_pt shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x, gdouble y){
- GdkRectangle update_rect;
- GError *gerror = NULL;
- gsize rd = 0, wr = 0;
- if (shape->icon_path == NULL) {
- printf("error message: icon path unknown\n");
- } else {
- gchar *gfn = g_locale_to_utf8(shape->icon_path, strlen(shape->icon_path), &rd, &wr, &gerror);
- GdkPixbuf*curr_pix_buf = gdk_pixbuf_new_from_file(gfn, &gerror);
- if(!curr_pix_buf) {
- g_printerr("error message: %s\n", (gchar *) gerror->message);
- }
- update_rect.x = x - 5;
- update_rect.y = y - 5;
- update_rect.width = gdk_pixbuf_get_width(curr_pix_buf);
- update_rect.height = gdk_pixbuf_get_height(curr_pix_buf);
- gdk_pixbuf_render_to_drawable(
- curr_pix_buf,
- pixMap,
- gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
- 0, 0,
- update_rect.x, update_rect.y,
- update_rect.width,
- update_rect.height,
- GDK_RGB_DITHER_NONE,
- 0, 0);
- gtk_widget_queue_draw_area (widget,
- update_rect.x, update_rect.y,
- update_rect.width, update_rect.height);
- }
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/CMakeLists.txt b/examples/osgi-in-action/chapter04-paint-example/paint/CMakeLists.txt
deleted file mode 100644
index 6caa87f..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-INCLUDE(FindPkgConfig)
-pkg_search_module (GLIB REQUIRED glib-2.0)
-pkg_search_module (GTHR REQUIRED gthread-2.0)
-pkg_search_module (GTK REQUIRED gtk+-2.0)
-pkg_search_module (GMODULE REQUIRED gmodule-2.0)
-include_directories(
- private/include
- ../simple/public/include
-)
-
-include_directories(${GTK_INCLUDE_DIRS})
-include_directories(${GLIB_INCLUDE_DIRS})
-include_directories(${GTHR_INCLUDE_DIRS})
-include_directories(${GMODULE_INCLUDE_DIRS})
-
-link_directories(${GTK_LIBRARY_DIRS})
-link_directories(${GLIB_LIBRARY_DIRS})
-link_directories(${GTHR_LIBRARY_DIRS})
-link_directories(${GMODULE_LIBRARY_DIRS})
-
-add_bundle(chapter04-paint-example VERSION 0.0.1 SOURCES
- private/src/activator
- private/src/default_shape
- private/src/shape_component
- private/src/paint_frame
-
- private/include/default_shape.h
- private/include/paint_frame.h
- private/include/shape_component.h
- FILES
- private/src/underc.png gtktest.glade
-)
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-target_link_libraries(chapter04-paint-example celix_framework ${MODULE_LIBRARIES} ${GLIB_LIBRARIES} ${GTK_LIBRARIES} ${GTHR_LIBRARIES})
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/gtktest.glade
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/gtktest.glade b/examples/osgi-in-action/chapter04-paint-example/paint/gtktest.glade
deleted file mode 100644
index 9a5e7d5..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/gtktest.glade
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
--->
-<interface>
- <requires lib="gtk+" version="2.24"/>
- <!-- interface-naming-policy project-wide -->
- <object class="GtkWindow" id="window1">
- <property name="width_request">600</property>
- <property name="height_request">400</property>
- <property name="can_focus">False</property>
- <signal name="destroy" handler="on_window1_destroy" swapped="no"/>
- <child>
- <object class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkToolbar" id="toolbar1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkDrawingArea" id="drawingarea1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property>
- <signal name="button-press-event" handler="newFrame_mousePressed" after="yes" swapped="no"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
-</interface>
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/private/include/default_shape.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/include/default_shape.h b/examples/osgi-in-action/chapter04-paint-example/paint/private/include/default_shape.h
deleted file mode 100644
index b249074..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/include/default_shape.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * default_shape.h
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#ifndef DEFAULT_SHAPE_H_
-#define DEFAULT_SHAPE_H_
-
-extern simple_shape_pt defaultShape_create(bundle_context_pt context);
-
-#endif /* DEFAULT_SHAPE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/private/include/paint_frame.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/include/paint_frame.h b/examples/osgi-in-action/chapter04-paint-example/paint/private/include/paint_frame.h
deleted file mode 100644
index df3c73c..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/include/paint_frame.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * paint_frame.h
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef PAINT_FRAME_H_
-#define PAINT_FRAME_H_
-
-#define PAINT_FRAME_SERVICE_NAME "paint"
-
-struct paint_frame {
- apr_pool_t *pool;
- GtkWidget *window;
- GtkWidget *drawingArea;
- GtkWidget *toolbar;
- GdkPixmap *pixMap;
- bool showing;
-
- char *m_selected;
- hash_map_pt m_shapes;
- simple_shape_pt m_defaultShape;
- linked_list_pt m_shapeComponents;
- bundle_context_pt context;
- GThread *main;
- char *file;
-};
-
-
-typedef struct paint_frame *paint_frame_pt;
-celix_status_t paintFrame_create(bundle_context_pt context, apr_pool_t *pool, paint_frame_pt *frame);
-celix_status_t paintFrame_exit(paint_frame_pt frame);
-
-simple_shape_pt paintFrame_getShape(paint_frame_pt frame, char *name);
-celix_status_t paintFrame_addShape(paint_frame_pt frame, bundle_context_pt context, simple_shape_pt shape);
-celix_status_t paintFrame_removeShape(paint_frame_pt frame, simple_shape_pt sshape);
-
-
-#endif /* PAINT_FRAME_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/505f6a84/examples/osgi-in-action/chapter04-paint-example/paint/private/include/shape_component.h
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/include/shape_component.h b/examples/osgi-in-action/chapter04-paint-example/paint/private/include/shape_component.h
deleted file mode 100644
index 782467d..0000000
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/include/shape_component.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * shape_component.h
- *
- * \date Aug 22, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef SHAPE_COMPONENT_H_
-#define SHAPE_COMPONENT_H_
-
-#include "paint_frame.h"
-
-typedef struct shape_component *shape_component_pt;
-
-struct shape_component {
- char *shapeName;
- paint_frame_pt m_frame;
- gdouble x, y, w, h;
- void (*shapeComponent_paintComponent)(shape_component_pt shapeComponent, paint_frame_pt frame,
- GdkPixmap *pixMap, GtkWidget *widget);
-};
-
-extern shape_component_pt shapeComponent_create(paint_frame_pt frame, simple_shape_pt sshape,
- gdouble x, gdouble y);
-
-#endif /* SHAPE_COMPONENT_H_ */
[2/8] celix git commit: CELIX-282: Disable importing/exporting
libraries example for OSX.
Posted by pn...@apache.org.
CELIX-282: Disable importing/exporting libraries example for OSX.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/24894196
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/24894196
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/24894196
Branch: refs/heads/develop
Commit: 24894196b959da980a1b6798299af572e9be2782
Parents: 2c74cc3
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Sat Oct 15 16:37:15 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Sat Oct 15 16:37:15 2016 +0200
----------------------------------------------------------------------
examples/hello_world/CMakeLists.txt | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/24894196/examples/hello_world/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt
index 04c79ed..e3a5c59 100644
--- a/examples/hello_world/CMakeLists.txt
+++ b/examples/hello_world/CMakeLists.txt
@@ -15,6 +15,9 @@
# specific language governing permissions and limitations
# under the License.
+if(NOT APPLE)
+#Importing and exporting libraries not (yet) work under OSX.
+
include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
include_directories("public/include")
@@ -36,7 +39,7 @@ add_bundle(hello
IMPORT_LIBRARIES hello_test2lib
)
-add_bundle(hello_import
+add_bundle(hello_export
VERSION "1.0"
NO_ACTIVATOR
EXPORT_LIBRARIES hello_test2lib
@@ -54,5 +57,7 @@ add_deploy(helloworld_byref
add_deploy(helloworld_withcopy
GROUP hello
COPY #Ensures that bundles are copied in the deploy location
- BUNDLES hello_import hello shell shell_tui
+ BUNDLES hello_export hello shell shell_tui
)
+
+endif()
\ No newline at end of file