-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CELIX-352: Added support for an framework extender path to load descr…
…iptors from the framework bundle.
- Loading branch information
Showing
8 changed files
with
170 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
remote_services/remote_service_admin_dfi/rsa/private/include/dfi_utils.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
#ifndef DFI_UTILS_H_ | ||
#define DFI_UTILS_H_ | ||
|
||
#include "bundle.h" | ||
#include "bundle_context.h" | ||
#include <stdio.h> | ||
#include "celix_errno.h" | ||
|
||
|
||
celix_status_t dfi_findDescriptor(bundle_context_pt context, bundle_pt bundle, const char *name, FILE **out); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
remote_services/remote_service_admin_dfi/rsa/private/src/dfi_utils.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
*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 "dfi_utils.h" | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
static celix_status_t dfi_findFileForFramework(bundle_context_pt context, const char *fileName, FILE **out) { | ||
celix_status_t status; | ||
|
||
char cwd[1024]; | ||
char *extPath = NULL; | ||
char path[1024]; | ||
|
||
status = bundleContext_getProperty(context, "CELIX_FRAMEWORK_EXTENDER_PATH", &extPath); | ||
if (status != CELIX_SUCCESS || extPath == NULL) { | ||
getcwd(cwd, sizeof(cwd)); | ||
extPath = cwd; | ||
if (extPath == NULL) { | ||
status = CELIX_FILE_IO_EXCEPTION; | ||
} | ||
} | ||
|
||
snprintf(path, sizeof(path), "%s/%s", extPath, fileName); | ||
|
||
if (status == CELIX_SUCCESS) { | ||
FILE *df = fopen(path, "r"); | ||
if (df == NULL) { | ||
status = CELIX_FILE_IO_EXCEPTION; | ||
} else { | ||
*out = df; | ||
} | ||
} | ||
|
||
return status; | ||
} | ||
|
||
static celix_status_t dfi_findFileForBundle(bundle_pt bundle, const char *fileName, FILE **out) { | ||
celix_status_t status; | ||
|
||
char *path = NULL; | ||
char metaInfFileName[128]; | ||
snprintf(metaInfFileName, sizeof(metaInfFileName), "META-INF/descriptors/%s", fileName); | ||
|
||
status = bundle_getEntry(bundle, (char *)fileName, &path); | ||
|
||
if (status != CELIX_SUCCESS || path == NULL) { | ||
status = bundle_getEntry(bundle, metaInfFileName, &path); | ||
} | ||
|
||
if (status == CELIX_SUCCESS && path != NULL) { | ||
FILE *df = fopen(path, "r"); | ||
if (df == NULL) { | ||
status = CELIX_FILE_IO_EXCEPTION; | ||
} else { | ||
*out = df; | ||
} | ||
|
||
free(path); | ||
} | ||
return status; | ||
} | ||
|
||
celix_status_t dfi_findDescriptor(bundle_context_pt context, bundle_pt bundle, const char *name, FILE **out) { | ||
celix_status_t status; | ||
char fileName[128]; | ||
|
||
snprintf(fileName, 128, "%s.descriptor", name); | ||
|
||
long id; | ||
status = bundle_getBundleId(bundle, &id); | ||
|
||
if (status == CELIX_SUCCESS) { | ||
if (id == 0) { | ||
//framework bundle | ||
status = dfi_findFileForFramework(context, fileName, out); | ||
} else { | ||
//normal bundle | ||
status = dfi_findFileForBundle(bundle, fileName, out); | ||
} | ||
} | ||
|
||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters