You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2014/10/01 11:52:00 UTC
svn commit: r1628664 - in /celix/trunk/scr: ./ scr/ scr/META-INF/
scr/private/ scr/private/include/ scr/private/src/ test/ test/META-INF/
Author: abroekhuis
Date: Wed Oct 1 09:51:59 2014
New Revision: 1628664
URL: http://svn.apache.org/r1628664
Log:
Added scr code
Added:
celix/trunk/scr/
celix/trunk/scr/CMakeLists.txt
celix/trunk/scr/scr/
celix/trunk/scr/scr/CMakeLists.txt
celix/trunk/scr/scr/META-INF/
celix/trunk/scr/scr/META-INF/MANIFEST.MF
celix/trunk/scr/scr/private/
celix/trunk/scr/scr/private/include/
celix/trunk/scr/scr/private/include/component_metadata.h
celix/trunk/scr/scr/private/include/reference_metadata.h
celix/trunk/scr/scr/private/include/service_metadata.h
celix/trunk/scr/scr/private/include/xml_parser_impl.h
celix/trunk/scr/scr/private/src/
celix/trunk/scr/scr/private/src/component_metadata.c
celix/trunk/scr/scr/private/src/component_registry.c
celix/trunk/scr/scr/private/src/reference_metadata.c
celix/trunk/scr/scr/private/src/service_metadata.c
celix/trunk/scr/scr/private/src/xml_parser.c
celix/trunk/scr/scr/scr.c
celix/trunk/scr/test/
celix/trunk/scr/test/CMakeLists.txt
celix/trunk/scr/test/META-INF/
celix/trunk/scr/test/META-INF/MANIFEST.MF
celix/trunk/scr/test/test.c
celix/trunk/scr/test/test.xml
Added: celix/trunk/scr/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/scr/CMakeLists.txt?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/CMakeLists.txt (added)
+++ celix/trunk/scr/CMakeLists.txt Wed Oct 1 09:51:59 2014
@@ -0,0 +1,24 @@
+# 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.
+celix_subproject(SCR "Option to build the SCR static library" OFF DEPS LAUNCHER FRAMEWORK SHELL SHELL_TUI)
+if (SCR)
+ add_subdirectory(scr)
+ add_subdirectory(test)
+
+ deploy(scr-test BUNDLES shell shell_tui scr_test scr)
+endif (SCR)
+
\ No newline at end of file
Added: celix/trunk/scr/scr/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/CMakeLists.txt?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/CMakeLists.txt (added)
+++ celix/trunk/scr/scr/CMakeLists.txt Wed Oct 1 09:51:59 2014
@@ -0,0 +1,31 @@
+# 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(FindLibXml2)
+include_directories(${LIBXML2_INCLUDE_DIR})
+
+bundle(scr SOURCES
+ scr.c
+ private/src/xml_parser.c
+ private/src/component_metadata.c
+ private/src/service_metadata.c
+ private/src/reference_metadata.c
+ )
+include_directories("public/include")
+include_directories("private/include")
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+target_link_libraries(scr celix_framework ${LIBXML2_LIBRARIES})
Added: celix/trunk/scr/scr/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/META-INF/MANIFEST.MF?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/META-INF/MANIFEST.MF (added)
+++ celix/trunk/scr/scr/META-INF/MANIFEST.MF Wed Oct 1 09:51:59 2014
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: scr
+Bundle-Version: 1.0.0
+library: scr
Added: celix/trunk/scr/scr/private/include/component_metadata.h
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/include/component_metadata.h?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/include/component_metadata.h (added)
+++ celix/trunk/scr/scr/private/include/component_metadata.h Wed Oct 1 09:51:59 2014
@@ -0,0 +1,61 @@
+/*
+ * component.h
+ *
+ * Created on: Jun 26, 2012
+ * Author: alexander
+ */
+
+#ifndef COMPONENT_METADATA_H_
+#define COMPONENT_METADATA_H_
+
+#include <stdbool.h>
+
+#include <celix_errno.h>
+
+#include "service_metadata.h"
+#include "reference_metadata.h"
+
+typedef struct component *component_t;
+
+celix_status_t component_create(apr_pool_t *pool, component_t *component);
+
+celix_status_t component_getName(component_t component, char **name);
+celix_status_t component_setName(component_t component, char *name);
+
+celix_status_t component_isEnabled(component_t component, bool *enabled);
+celix_status_t component_setEnabled(component_t component, bool enabled);
+
+celix_status_t component_isImmediate(component_t component, bool *immediate);
+celix_status_t component_setImmediate(component_t component, bool immediate);
+
+celix_status_t component_getFactoryIdentifier(component_t component, char **factoryIdentifier);
+celix_status_t component_setFactoryIdentifier(component_t component, char *factoryIdentifier);
+
+celix_status_t component_getConfigurationPolicy(component_t component, char **configurationPolicy);
+celix_status_t component_setConfigurationPolicy(component_t component, char *configurationPolicy);
+
+celix_status_t component_getActivate(component_t component, char **activate);
+celix_status_t component_setActivate(component_t component, char *activate);
+
+celix_status_t component_getActivate(component_t component, char **activate);
+celix_status_t component_setActivate(component_t component, char *activate);
+
+celix_status_t component_getActivate(component_t component, char **activate);
+celix_status_t component_setActivate(component_t component, char *activate);
+
+celix_status_t component_getDeactivate(component_t component, char **deactivate);
+celix_status_t component_setDeactivate(component_t component, char *deactivate);
+
+celix_status_t component_getModified(component_t component, char **modified);
+celix_status_t component_setModified(component_t component, char *modified);
+
+celix_status_t component_getImplementationClassName(component_t component, char **implementationClassName);
+celix_status_t component_setImplementationClassName(component_t component, char *implementationClassName);
+
+celix_status_t componentMetadata_getService(component_t component, service_t *service);
+celix_status_t componentMetadata_setService(component_t component, service_t service);
+
+celix_status_t componentMetadata_getDependencies(component_t component, reference_metadata_t *reference[], int *size);
+celix_status_t componentMetadata_addDependency(component_t component, reference_metadata_t reference);
+
+#endif /* COMPONENT_METADATA_H_ */
Added: celix/trunk/scr/scr/private/include/reference_metadata.h
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/include/reference_metadata.h?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/include/reference_metadata.h (added)
+++ celix/trunk/scr/scr/private/include/reference_metadata.h Wed Oct 1 09:51:59 2014
@@ -0,0 +1,46 @@
+/*
+ * reference_metadata.h
+ *
+ * Created on: Jun 28, 2012
+ * Author: alexander
+ */
+
+#ifndef REFERENCE_METADATA_H_
+#define REFERENCE_METADATA_H_
+
+#include <stdbool.h>
+#include <apr_general.h>
+
+#include <celix_errno.h>
+
+typedef struct reference_metadata *reference_metadata_t;
+
+celix_status_t referenceMetadata_create(apr_pool_t *pool, reference_metadata_t *reference);
+
+celix_status_t referenceMetadata_setName(reference_metadata_t reference, char *name);
+celix_status_t referenceMetadata_getName(reference_metadata_t reference, char **name);
+
+celix_status_t referenceMetadata_setInterface(reference_metadata_t reference, char *interface);
+celix_status_t referenceMetadata_getInterface(reference_metadata_t reference, char **interface);
+
+celix_status_t referenceMetadata_setCardinality(reference_metadata_t reference, char *cardinality);
+celix_status_t referenceMetadata_getCardinality(reference_metadata_t reference, char **cardinality);
+
+celix_status_t referenceMetadata_setPolicy(reference_metadata_t reference, char *policy);
+celix_status_t referenceMetadata_getPolicy(reference_metadata_t reference, char **policy);
+
+celix_status_t referenceMetadata_setTarget(reference_metadata_t reference, char *target);
+celix_status_t referenceMetadata_getTarget(reference_metadata_t reference, char **target);
+
+celix_status_t referenceMetadata_setBind(reference_metadata_t reference, char *bind);
+celix_status_t referenceMetadata_getBind(reference_metadata_t reference, char **bind);
+
+celix_status_t referenceMetadata_setUpdated(reference_metadata_t reference, char *updated);
+celix_status_t referenceMetadata_getUpdated(reference_metadata_t reference, char **updated);
+
+celix_status_t referenceMetadata_setUnbind(reference_metadata_t reference, char *unbind);
+celix_status_t referenceMetadata_getUnbind(reference_metadata_t reference, char **unbind);
+
+
+
+#endif /* REFERENCE_METADATA_H_ */
Added: celix/trunk/scr/scr/private/include/service_metadata.h
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/include/service_metadata.h?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/include/service_metadata.h (added)
+++ celix/trunk/scr/scr/private/include/service_metadata.h Wed Oct 1 09:51:59 2014
@@ -0,0 +1,26 @@
+/*
+ * service.h
+ *
+ * Created on: Jun 28, 2012
+ * Author: alexander
+ */
+
+#ifndef SERVICE_METADATA_H_
+#define SERVICE_METADATA_H_
+
+#include <stdbool.h>
+#include <apr_general.h>
+
+#include <celix_errno.h>
+
+typedef struct service *service_t;
+
+celix_status_t service_create(apr_pool_t *pool, service_t *component);
+
+celix_status_t serviceMetadata_setServiceFactory(service_t currentService, bool serviceFactory);
+celix_status_t serviceMetadata_isServiceFactory(service_t currentService, bool *serviceFactory);
+
+celix_status_t serviceMetadata_addProvide(service_t service, char *provide);
+celix_status_t serviceMetadata_getProvides(service_t service, char **provides[], int *size);
+
+#endif /* SERVICE_METADATA_H_ */
Added: celix/trunk/scr/scr/private/include/xml_parser_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/include/xml_parser_impl.h?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/include/xml_parser_impl.h (added)
+++ celix/trunk/scr/scr/private/include/xml_parser_impl.h Wed Oct 1 09:51:59 2014
@@ -0,0 +1,18 @@
+/*
+ * xml_parser_impl.h
+ *
+ * Created on: Jun 27, 2012
+ * Author: alexander
+ */
+
+#ifndef XML_PARSER_IMPL_H_
+#define XML_PARSER_IMPL_H_
+
+#include "component_metadata.h"
+
+typedef struct xml_parser *xml_parser_t;
+
+celix_status_t xmlParser_create(apr_pool_t *pool, xml_parser_t *parser);
+celix_status_t xmlParser_parseComponent(xml_parser_t parser, char *componentEntry, component_t *component);
+
+#endif /* XML_PARSER_IMPL_H_ */
Added: celix/trunk/scr/scr/private/src/component_metadata.c
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/src/component_metadata.c?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/src/component_metadata.c (added)
+++ celix/trunk/scr/scr/private/src/component_metadata.c Wed Oct 1 09:51:59 2014
@@ -0,0 +1,169 @@
+/*
+ * component.c
+ *
+ * Created on: Jun 27, 2012
+ * Author: alexander
+ */
+#include <stdlib.h>
+
+#include <array_list.h>
+
+#include "component_metadata.h"
+
+struct component {
+ apr_pool_t *pool;
+
+ char *name;
+ bool enabled;
+ bool immediate;
+ char *factoryIdentifier;
+ char *configurationPolicy;
+ char *activate;
+ char *deactivate;
+ char *modified;
+
+ char *implementationClassName;
+
+ service_t service;
+
+ ARRAY_LIST references;
+};
+
+celix_status_t component_create(apr_pool_t *pool, component_t *component) {
+ *component = malloc(sizeof(**component));
+ (*component)->pool = pool;
+
+ (*component)->name = NULL;
+ (*component)->enabled = true;
+ (*component)->immediate = false;
+ (*component)->factoryIdentifier = NULL;
+ (*component)->configurationPolicy = NULL;
+ (*component)->activate = NULL;
+ (*component)->deactivate = NULL;
+ (*component)->modified = NULL;
+
+ (*component)->implementationClassName = NULL;
+
+ (*component)->service = NULL;
+
+ arrayList_create(pool, &(*component)->references);
+
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_getName(component_t component, char **name) {
+ *name = component->name;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setName(component_t component, char *name) {
+ component->name = name;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_isEnabled(component_t component, bool *enabled) {
+ *enabled = component->enabled;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setEnabled(component_t component, bool enabled) {
+ component->enabled = enabled;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_isImmediate(component_t component, bool *immediate) {
+ *immediate = component->immediate;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setImmediate(component_t component, bool immediate) {
+ component->enabled = immediate;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_getFactoryIdentifier(component_t component, char **factoryIdentifier) {
+ *factoryIdentifier = component->factoryIdentifier;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setFactoryIdentifier(component_t component, char *factoryIdentifier) {
+ component->factoryIdentifier = factoryIdentifier;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_getConfigurationPolicy(component_t component, char **configurationPolicy) {
+ *configurationPolicy = component->configurationPolicy;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setConfigurationPolicy(component_t component, char *configurationPolicy) {
+ component->configurationPolicy = configurationPolicy;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_getActivate(component_t component, char **activate) {
+ *activate = component->activate;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setActivate(component_t component, char *activate) {
+ component->activate = activate;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_getDeactivate(component_t component, char **deactivate) {
+ *deactivate = component->deactivate;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setDeactivate(component_t component, char *deactivate) {
+ component->deactivate = deactivate;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_getModified(component_t component, char **modified) {
+ *modified = component->modified;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setModified(component_t component, char *modified) {
+ component->modified = modified;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_getImplementationClassName(component_t component, char **implementationClassName) {
+ *implementationClassName = component->implementationClassName;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t component_setImplementationClassName(component_t component, char *implementationClassName) {
+ component->implementationClassName = implementationClassName;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t componentMetadata_getService(component_t component, service_t *service) {
+ *service = component->service;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t componentMetadata_setService(component_t component, service_t service) {
+ component->service = service;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t componentMetadata_getDependencies(component_t component, reference_metadata_t *references[], int *size) {
+ *size = arrayList_size(component->references);
+ reference_metadata_t *referencesA = malloc(*size * sizeof(*referencesA));
+ int i;
+ for (i = 0; i < *size; i++) {
+ reference_metadata_t ref = arrayList_get(component->references, i);
+ referencesA[i] = ref;
+ }
+ *references = referencesA;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t componentMetadata_addDependency(component_t component, reference_metadata_t reference) {
+ arrayList_add(component->references, reference);
+ return CELIX_SUCCESS;
+}
Added: celix/trunk/scr/scr/private/src/component_registry.c
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/src/component_registry.c?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/src/component_registry.c (added)
+++ celix/trunk/scr/scr/private/src/component_registry.c Wed Oct 1 09:51:59 2014
@@ -0,0 +1,30 @@
+/**
+ *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.
+ */
+/*
+ * component_registry.c
+ *
+ * \date Nov 15, 2012
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+
+
+
Added: celix/trunk/scr/scr/private/src/reference_metadata.c
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/src/reference_metadata.c?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/src/reference_metadata.c (added)
+++ celix/trunk/scr/scr/private/src/reference_metadata.c Wed Oct 1 09:51:59 2014
@@ -0,0 +1,109 @@
+/*
+ * reference_metadata.c
+ *
+ * Created on: Jun 28, 2012
+ * Author: alexander
+ */
+#include <stdlib.h>
+
+#include "reference_metadata.h"
+
+struct reference_metadata {
+ char *name;
+ char *interface;
+ char *cardinality;
+ char *policy;
+ char *target;
+ char *bind;
+ char *updated;
+ char *unbind;
+};
+
+celix_status_t referenceMetadata_create(apr_pool_t *pool, reference_metadata_t *reference) {
+ *reference = apr_palloc(pool, sizeof(**reference));
+ (*reference)->name = NULL;
+
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_setName(reference_metadata_t reference, char *name) {
+ reference->name = name;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_getName(reference_metadata_t reference, char **name) {
+ *name = reference->name;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_setInterface(reference_metadata_t reference, char *interface) {
+ reference->interface = interface;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_getInterface(reference_metadata_t reference, char **interface) {
+ *interface = reference->interface;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_setCardinality(reference_metadata_t reference, char *cardinality) {
+ reference->cardinality = cardinality;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_getCardinality(reference_metadata_t reference, char **cardinality) {
+ *cardinality = reference->cardinality;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_setPolicy(reference_metadata_t reference, char *policy) {
+ reference->policy = policy;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_getPolicy(reference_metadata_t reference, char **policy) {
+ *policy = reference->policy;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_setTarget(reference_metadata_t reference, char *target) {
+ reference->target = target;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_getTarget(reference_metadata_t reference, char **target) {
+ *target = reference->target;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_setBind(reference_metadata_t reference, char *bind) {
+ reference->bind = bind;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_getBind(reference_metadata_t reference, char **bind) {
+ *bind = reference->bind;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_setUpdated(reference_metadata_t reference, char *updated) {
+ reference->updated = updated;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_getUpdated(reference_metadata_t reference, char **updated) {
+ *updated = reference->updated;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_setUnbind(reference_metadata_t reference, char *unbind) {
+ reference->unbind = unbind;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t referenceMetadata_getUnbind(reference_metadata_t reference, char **unbind) {
+ *unbind = reference->unbind;
+ return CELIX_SUCCESS;
+}
+
+
Added: celix/trunk/scr/scr/private/src/service_metadata.c
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/src/service_metadata.c?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/src/service_metadata.c (added)
+++ celix/trunk/scr/scr/private/src/service_metadata.c Wed Oct 1 09:51:59 2014
@@ -0,0 +1,53 @@
+/*
+ * service.c
+ *
+ * Created on: Jun 28, 2012
+ * Author: alexander
+ */
+#include <stdlib.h>
+
+#include "array_list.h"
+
+#include "service_metadata.h"
+
+struct service {
+ bool serviceFactory;
+
+ ARRAY_LIST provides;
+
+};
+
+celix_status_t service_create(apr_pool_t *pool, service_t *service) {
+ *service = malloc(sizeof(**service));
+ (*service)->serviceFactory = false;
+ arrayList_create(pool, &(*service)->provides);
+
+ return CELIX_SUCCESS;
+}
+
+celix_status_t serviceMetadata_setServiceFactory(service_t currentService, bool serviceFactory) {
+ currentService->serviceFactory = serviceFactory;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t serviceMetadata_isServiceFactory(service_t currentService, bool *serviceFactory) {
+ *serviceFactory = currentService->serviceFactory;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t serviceMetadata_addProvide(service_t service, char *provide) {
+ arrayList_add(service->provides, provide);
+ return CELIX_SUCCESS;
+}
+
+celix_status_t serviceMetadata_getProvides(service_t service, char **provides[], int *size) {
+ *size = arrayList_size(service->provides);
+ char **providesA = malloc(*size * sizeof(*providesA));
+ int i;
+ for (i = 0; i < *size; i++) {
+ providesA[i] = arrayList_get(service->provides, i);
+ }
+
+ *provides = providesA;
+ return CELIX_SUCCESS;
+}
Added: celix/trunk/scr/scr/private/src/xml_parser.c
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/private/src/xml_parser.c?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/private/src/xml_parser.c (added)
+++ celix/trunk/scr/scr/private/src/xml_parser.c Wed Oct 1 09:51:59 2014
@@ -0,0 +1,201 @@
+/*
+ * XmlParser.c
+ *
+ * Created on: Jun 27, 2012
+ * Author: alexander
+ */
+#include <stdbool.h>
+
+#include <apr_general.h>
+
+#include <celix_errno.h>
+
+#include <libxml/xmlreader.h>
+
+#include "xml_parser_impl.h"
+#include "service_metadata.h"
+
+struct xml_parser {
+ apr_pool_t *pool;
+};
+
+celix_status_t xmlParser_create(apr_pool_t *pool, xml_parser_t *parser) {
+ *parser = apr_palloc(pool, sizeof(**parser));
+ (*parser)->pool = pool;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t xmlParser_parseComponent(xml_parser_t parser, char *componentEntry, component_t *component) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ xmlTextReaderPtr reader = xmlReaderForFile(componentEntry, NULL, 0);
+ if (reader != NULL) {
+ bool pendingProperty = false;
+ component_t currentComponent;
+ service_t currentService;
+ int read = xmlTextReaderRead(reader);
+ while (read == 1) {
+ int type = xmlTextReaderNodeType(reader);
+ if (type == 1) {
+ pendingProperty = false;
+ const char *localname = xmlTextReaderConstLocalName(reader);
+ if (strcmp(localname, "component") == 0) {
+ printf("Component:\n");
+
+ component_create(parser->pool, ¤tComponent);
+
+ char *name = xmlTextReaderGetAttribute(reader, "name");
+ char *enabled = xmlTextReaderGetAttribute(reader, "enabled");
+ char *immediate = xmlTextReaderGetAttribute(reader, "immediate");
+ char *factory = xmlTextReaderGetAttribute(reader, "factory");
+ char *configurationPolicy = xmlTextReaderGetAttribute(reader, "configuration-policy");
+ char *activate = xmlTextReaderGetAttribute(reader, "activate");
+ char *deactivate = xmlTextReaderGetAttribute(reader, "deactivate");
+ char *modified = xmlTextReaderGetAttribute(reader, "modified");
+ if (name != NULL) {
+ printf("\tName: %s\n", name);
+ component_setName(currentComponent, name);
+ }
+ if (enabled != NULL) {
+ printf("\tEnabled: %s\n", enabled);
+ component_setEnabled(currentComponent, strcmp("true", enabled) == 0);
+ }
+ if (immediate != NULL) {
+ printf("\tImmediate: %s\n", immediate);
+ component_setEnabled(currentComponent, strcmp("true", enabled) == 0);
+ }
+ if (factory != NULL) {
+ printf("\tFactory: %s\n", factory);
+ component_setFactoryIdentifier(currentComponent, factory);
+ }
+ if (configurationPolicy != NULL) {
+ printf("\tConfiguration policy: %s\n", configurationPolicy);
+ component_setConfigurationPolicy(currentComponent, configurationPolicy);
+ }
+ if (activate != NULL) {
+ printf("\tActivate: %s\n", activate);
+ component_setActivate(currentComponent, activate);
+ }
+ if (deactivate != NULL) {
+ printf("\tDeactivate: %s\n", deactivate);
+ component_setDeactivate(currentComponent, deactivate);
+ }
+ if (modified != NULL) {
+ printf("\tModified: %s\n", modified);
+ component_setModified(currentComponent, modified);
+ }
+
+ // components.add(currentComponent);
+
+ } else if (strcmp(localname, "implementation") == 0) {
+ printf("Implementation:\n");
+ char *class = xmlTextReaderGetAttribute(reader, "class");
+ printf("\tClass: %s\n", class);
+ component_setImplementationClassName(currentComponent, class);
+ } else if (strcmp(localname, "property") == 0) {
+ printf("Property:\n");
+ char *name = xmlTextReaderGetAttribute(reader, "name");
+ char *value = xmlTextReaderGetAttribute(reader, "value");
+ printf("\tName: %s\n", name);
+ if (value != NULL) {
+ printf("\tValue: %s\n", value);
+ } else {
+ pendingProperty = true;
+ }
+ } else if (strcmp(localname, "properties") == 0) {
+ printf("Properties:\n");
+ } else if (strcmp(localname, "service") == 0) {
+ printf("Service:\n");
+
+ service_create(parser->pool, ¤tService);
+
+ char *serviceFactory = xmlTextReaderGetAttribute(reader, "servicefactory");
+ if (serviceFactory != NULL) {
+ printf("\tService factory: %s\n", serviceFactory);
+ serviceMetadata_setServiceFactory(currentService, strcmp("true", serviceFactory) == 0);
+ }
+
+ componentMetadata_setService(currentComponent, currentService);
+ } else if (strcmp(localname, "provide") == 0) {
+ printf("Provide:\n");
+ char *interface = xmlTextReaderGetAttribute(reader, "interface");
+ printf("\tInterface: %s\n", interface);
+ serviceMetadata_addProvide(currentService, interface);
+ } else if (strcmp(localname, "reference") == 0) {
+ printf("Reference:\n");
+ reference_metadata_t reference;
+ referenceMetadata_create(parser->pool, &reference);
+
+ char *name = xmlTextReaderGetAttribute(reader, "name");
+ char *interface = xmlTextReaderGetAttribute(reader, "interface");
+ char *cardinality = xmlTextReaderGetAttribute(reader, "cardinality");
+ char *policy = xmlTextReaderGetAttribute(reader, "policy");
+ char *target = xmlTextReaderGetAttribute(reader, "target");
+ char *bind = xmlTextReaderGetAttribute(reader, "bind");
+ char *updated = xmlTextReaderGetAttribute(reader, "updated");
+ char *unbind = xmlTextReaderGetAttribute(reader, "unbind");
+
+ if (name != NULL) {
+ printf("\tName: %s\n", name);
+ referenceMetadata_setName(reference, name);
+ }
+ printf("\tInterface: %s\n", interface);
+ referenceMetadata_setInterface(reference, interface);
+ if (cardinality != NULL) {
+ printf("\tCardinality: %s\n", cardinality);
+ referenceMetadata_setCardinality(reference, cardinality);
+ }
+ if (policy != NULL) {
+ printf("\tPolicy: %s\n", policy);
+ referenceMetadata_setPolicy(reference, policy);
+ }
+ if (target != NULL) {
+ printf("\tCardinality: %s\n", target);
+ referenceMetadata_setCardinality(reference, cardinality);
+ }
+ if (bind != NULL) {
+ printf("\tBind: %s\n", bind);
+ referenceMetadata_setBind(reference, bind);
+ }
+ if (updated != NULL) {
+ printf("\tUpdated: %s\n", updated);
+ referenceMetadata_setUpdated(reference, updated);
+ }
+ if (unbind != NULL) {
+ printf("\tUnbind: %s\n", unbind);
+ referenceMetadata_setUnbind(reference, unbind);
+ }
+
+ componentMetadata_addDependency(currentComponent, reference);
+ } else {
+ printf("Unsupported element:\n");
+ }
+ } else if (type == 3) {
+ if (pendingProperty) {
+ const char *value = xmlTextReaderConstValue(reader);
+ if (value != NULL) {
+ printf("\tValue text: %s\n", value);
+ pendingProperty = false;
+ }
+ }
+ }
+
+ read = xmlTextReaderRead(reader);
+ }
+ if (currentComponent != NULL) {
+ reference_metadata_t *refs;
+ int size;
+ componentMetadata_getDependencies(currentComponent, &refs, &size);
+ int i;
+ for (i = 0; i < size; i++) {
+ reference_metadata_t ref = refs[i];
+ char *in = NULL;
+ referenceMetadata_getInterface(ref, &in);
+ printf("AS: %s\n", in);
+ }
+ printf("ASD\n");
+ }
+ }
+
+ return CELIX_SUCCESS;
+}
Added: celix/trunk/scr/scr/scr.c
URL: http://svn.apache.org/viewvc/celix/trunk/scr/scr/scr.c?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/scr/scr.c (added)
+++ celix/trunk/scr/scr/scr.c Wed Oct 1 09:51:59 2014
@@ -0,0 +1,147 @@
+/*
+ * scr.c
+ *
+ * Created on: Jun 25, 2012
+ * Author: alexander
+ */
+
+#include <stdio.h>
+#include <dlfcn.h>
+
+#include <libxml/xmlreader.h>
+
+#include <bundle_activator.h>
+
+#include "xml_parser_impl.h"
+
+struct component {
+ char *name;
+};
+
+celix_status_t scr_bundleChanged(void *listener, bundle_event_t event);
+
+celix_status_t scrParser_processComponent(xmlTextReaderPtr reader) {
+
+
+ return CELIX_SUCCESS;
+}
+
+static void
+processNode(xmlTextReaderPtr reader) {
+ const xmlChar *name, *value;
+
+ name = xmlTextReaderConstLocalName(reader);
+
+ if (name == NULL)
+ name = BAD_CAST "--";
+
+ if (strcmp(name, "component") == 0) {
+ char *att = xmlTextReaderGetAttribute(reader, "name");
+ printf("Handle cmp: %s\n", att);
+ }
+
+ value = xmlTextReaderConstValue(reader);
+
+ printf("%d %d %s %d %d",
+ xmlTextReaderDepth(reader),
+ xmlTextReaderNodeType(reader),
+ name,
+ xmlTextReaderIsEmptyElement(reader),
+ xmlTextReaderHasValue(reader));
+ if (value == NULL)
+ printf("\n");
+ else {
+ if (xmlStrlen(value) > 40)
+ printf(" %.40s...\n", value);
+ else
+ printf(" %s\n", value);
+ }
+}
+
+celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData) {
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+ ARRAY_LIST bundles = NULL;
+ bundleContext_getBundles(context, &bundles);
+
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(context, &pool);
+
+ xml_parser_t parser = NULL;
+ xmlParser_create(pool, &parser);
+
+ int size;
+ size = arrayList_size(bundles);
+ int i;
+ for (i = 0; i < size; i++) {
+ MANIFEST man = NULL;
+ BUNDLE bundle = arrayList_get(bundles, i);
+ bundle_getManifest(bundle, &man);
+ if (man != NULL) {
+ char *sc = manifest_getValue(man, "Service-Component");
+ if (sc != NULL) {
+ printf("SC: %s\n", sc);
+ char *path = NULL;
+ bundle_getEntry(bundle, sc, pool, &path);
+
+
+ xmlParser_parseComponent(parser, path, NULL);
+
+// xmlTextReaderPtr reader;
+// int ret;
+//
+// reader = xmlReaderForFile(path, NULL, 0);
+// if (reader != NULL) {
+// ret = xmlTextReaderRead(reader);
+// while (ret == 1) {
+// processNode(reader);
+// ret = xmlTextReaderRead(reader);
+// }
+// xmlFreeTextReader(reader);
+// if (ret != 0) {
+// fprintf(stderr, "%s : failed to parse\n", path);
+// }
+// } else {
+// fprintf(stderr, "Unable to open %s\n", path);
+// }
+//
+
+ void *handle = bundle_getHandle(bundle);
+
+ void (*start)(void * userData, BUNDLE_CONTEXT context);
+ start = dlsym(bundle_getHandle(bundle), "bundleActivator_start");
+
+ void (*activate)();
+ activate = dlsym(handle, "activate");
+ activate();
+
+ void *type;
+ type = dlsym(handle, "service_t");
+ }
+ }
+ }
+
+ bundle_listener_t listener = apr_palloc(pool, sizeof(*listener));
+ listener->pool = pool;
+ listener->bundleChanged = scr_bundleChanged;
+ listener->handle = parser;
+
+ bundleContext_addBundleListener(context, listener);
+
+ return CELIX_SUCCESS;
+}
+
+celix_status_t scr_bundleChanged(void *listener, bundle_event_t event) {
+ printf("BUNDLE CHANGED\n");
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
+ return CELIX_SUCCESS;
+}
Added: celix/trunk/scr/test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/scr/test/CMakeLists.txt?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/test/CMakeLists.txt (added)
+++ celix/trunk/scr/test/CMakeLists.txt Wed Oct 1 09:51:59 2014
@@ -0,0 +1,27 @@
+# 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_HEADERS("Service-Component: test.xml")
+
+bundle(scr_test SOURCES
+ test.c
+ FILES test.xml
+ )
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+target_link_libraries(scr_test celix_framework)
+
+
Added: celix/trunk/scr/test/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/celix/trunk/scr/test/META-INF/MANIFEST.MF?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/test/META-INF/MANIFEST.MF (added)
+++ celix/trunk/scr/test/META-INF/MANIFEST.MF Wed Oct 1 09:51:59 2014
@@ -0,0 +1,4 @@
+Bundle-SymbolicName: scr_test
+Bundle-Version: 1.0.0
+Service-Component: test.xml
+library: scr_test
Added: celix/trunk/scr/test/test.c
URL: http://svn.apache.org/viewvc/celix/trunk/scr/test/test.c?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/test/test.c (added)
+++ celix/trunk/scr/test/test.c Wed Oct 1 09:51:59 2014
@@ -0,0 +1,36 @@
+/*
+ * scr.c
+ *
+ * Created on: Jun 25, 2012
+ * Author: alexander
+ */
+
+#include <stdio.h>
+
+#include <bundle_activator.h>
+
+struct service {
+ char *a;
+};
+
+typedef struct service *service_t;
+
+celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData) {
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
+ return CELIX_SUCCESS;
+}
+
+void activate() {
+ printf("Activate!\n");
+}
Added: celix/trunk/scr/test/test.xml
URL: http://svn.apache.org/viewvc/celix/trunk/scr/test/test.xml?rev=1628664&view=auto
==============================================================================
--- celix/trunk/scr/test/test.xml (added)
+++ celix/trunk/scr/test/test.xml Wed Oct 1 09:51:59 2014
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component enabled="true" name="example.activator" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+ <implementation class="{componentName}_{createName}">
+ <!--
+ class points to the constructor function of the component.
+ It's signature has to be: celix_status_t {compontenName_create}(void **instance);
+ In this function {instance} is a return pointer to some data object representing the instance of the component.
+ This pointer will be supplied as first argument to all calls made to the component.
+ -->
+ </implementation>
+ <property name="{propName}">{textValue}</property>
+ <service>
+ <provide interface="{ServiceName1}" getter="{componentName}_{serviceGetter}"/>
+ <provide interface="{ServiceName2}" getter="{componentName}_{serviceGetter}"/>
+ <provide interface="{ServiceName3}" getter="{componentName}_{serviceGetter}"/>
+ <provide interface="{ServiceName4}" getter="{componentName}_{serviceGetter}"/>
+ <!--
+ This is where we have a problem. Within Celix a service isn't simply an interface that can be registered.
+ The user has to create a struct instance with function pointers.
+ A possible solution is to let the user implement a function which return this struct instance.
+ -->
+ </service>
+ <reference
+ name="{ReferenceName}"
+ interface="{ServiceName1}"
+ target="{someFilter}"
+ bind="{componentName}_{bindName}"
+ unbind="myComponent_{unbindName}"/>
+ <reference
+ name="{ReferenceName}"
+ interface="{ServiceName2}"
+ target="{someFilter}"
+ bind="{componentName}_{bindName}"
+ unbind="myComponent_{unbindName}"/>
+ <reference
+ name="{ReferenceName}"
+ interface="{ServiceName3}"
+ target="{someFilter}"
+ bind="{componentName}_{bindName}"
+ unbind="myComponent_{unbindName}"/>
+</scr:component>
+
\ No newline at end of file