-
Notifications
You must be signed in to change notification settings - Fork 28
/
core.xml
71 lines (69 loc) · 3.86 KB
/
core.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?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.
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<!-- Build the bootstrapper -->
<bean id="sampleresourceBootstrapperFactory" class="org.opennaas.extensions.sampleresource.repository.SampleResourceBootstrapperFactory"/>
<!-- Workaround for https://issues.apache.org/jira/browse/ARIES-796:
Resolve and inject entityManagerFactory and get the entityManager using code in ResourceDescriptorRepository.
Obtained entityManager is not container managed, then.
Given unit MUST already be registered as an OSGi service for this to work. -->
<reference id="entityManagerFactory" interface="javax.persistence.EntityManagerFactory" filter="(osgi.unit.name=ResourceCore)"/>
<bean id="resourceDescriptorRepository"
class="org.opennaas.core.resources.descriptor.ResourceDescriptorRepository"
init-method="initializeEntityManager" destroy-method="close">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="sampleresourceRepository" class="org.opennaas.extensions.sampleresource.repository.SampleResourceRepository" init-method="init">
<argument value="sampleresource"/>
<property name="resourceDescriptorRepository" ref="resourceDescriptorRepository"/>
<property name="resourceBootstrapperFactory" ref="sampleresourceBootstrapperFactory"/>
</bean>
<!-- Get capability factories from the OSGi registry -->
<reference-list id="capabilityFactory" interface="org.opennaas.core.resources.capability.ICapabilityFactory" availability="optional">
<reference-listener ref="sampleresourceRepository" bind-method="capabilityFactoryAdded" unbind-method="capabilityFactoryDeleted"/>
</reference-list>
<service ref="sampleresourceRepository" interface="org.opennaas.core.resources.IResourceRepository">
<service-properties>
<entry key="type" value="sampleresource"/>
<entry key="version" value="1.0.0"/>
</service-properties>
</service>
<!-- Factory that creates protocol capabilities -->
<bean id="exampleCapabilityFactory" class="org.opennaas.extensions.sampleresource.capability.example.ExampleCapabilityFactory">
<property name="type" value="example"/>
</bean>
<!-- Command completers -->
<reference id="resourceNameCompleter" interface="org.apache.karaf.shell.console.Completer" filter="(completer.name=resourceNameCompleter)"/>
<!-- Register the Service as an OSGi Service -->
<service ref="exampleCapabilityFactory" interface="org.opennaas.core.resources.capability.ICapabilityFactory">
<service-properties>
<!-- TODO it is necessary to use two parameters to get capability -->
<entry key="capability" value="example"/>
<entry key="capability.model" value="dummy"/>
<entry key="capability.version" value="1.0"/>
</service-properties>
</service>
<!-- Provide commands to the Karaf shell -->
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name="example/sayHello">
<action class="org.opennaas.extensions.sampleresource.capability.example.shell.ExampleCommand"/>
<completers>
<ref component-id="resourceNameCompleter"/>
<null/>
</completers>
</command>
</command-bundle>
</blueprint>