You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/03/24 17:32:19 UTC
[21/24] git commit: [KARAF-2833] Make service/core independent of
blueprint
[KARAF-2833] Make service/core independent of blueprint
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/a1e5d4f5
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/a1e5d4f5
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/a1e5d4f5
Branch: refs/heads/master
Commit: a1e5d4f59d47b18eea29b673e969fea27d897053
Parents: b355415
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Sat Mar 22 16:29:37 2014 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Mon Mar 24 17:30:13 2014 +0100
----------------------------------------------------------------------
.../standard/src/main/feature/feature.xml | 1 -
service/core/pom.xml | 8 ++-
.../service/core/internal/osgi/Activator.java | 65 ++++++++++++++++++++
.../resources/OSGI-INF/blueprint/blueprint.xml | 30 ---------
4 files changed, 71 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/a1e5d4f5/assemblies/features/standard/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/standard/src/main/feature/feature.xml b/assemblies/features/standard/src/main/feature/feature.xml
index 80c14f8..8df6409 100644
--- a/assemblies/features/standard/src/main/feature/feature.xml
+++ b/assemblies/features/standard/src/main/feature/feature.xml
@@ -173,7 +173,6 @@
</feature>
<feature name="service" description="Provide Service support" version="${project.version}">
- <feature version="${project.version}">aries-blueprint</feature>
<bundle start-level="30" start="true">mvn:org.apache.karaf.service/org.apache.karaf.service.core/${project.version}</bundle>
<bundle start-level="30" start="true">mvn:org.apache.karaf.service/org.apache.karaf.service.command/${project.version}</bundle>
</feature>
http://git-wip-us.apache.org/repos/asf/karaf/blob/a1e5d4f5/service/core/pom.xml
----------------------------------------------------------------------
diff --git a/service/core/pom.xml b/service/core/pom.xml
index 7cc7e1e..66ee92b 100644
--- a/service/core/pom.xml
+++ b/service/core/pom.xml
@@ -68,11 +68,15 @@
<configuration>
<instructions>
<Export-Package>
- org.apache.karaf.service.core
+ org.apache.karaf.service.core;-noimport:=true
</Export-Package>
<Private-Package>
- org.apache.karaf.service.core.internal
+ org.apache.karaf.service.core.internal,
+ org.apache.karaf.service.core.internal.osgi
</Private-Package>
+ <Bundle-Activator>
+ org.apache.karaf.service.core.internal.osgi.Activator
+ </Bundle-Activator>
</instructions>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/karaf/blob/a1e5d4f5/service/core/src/main/java/org/apache/karaf/service/core/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/service/core/src/main/java/org/apache/karaf/service/core/internal/osgi/Activator.java b/service/core/src/main/java/org/apache/karaf/service/core/internal/osgi/Activator.java
new file mode 100644
index 0000000..25b9e30
--- /dev/null
+++ b/service/core/src/main/java/org/apache/karaf/service/core/internal/osgi/Activator.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+package org.apache.karaf.service.core.internal.osgi;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.karaf.service.core.internal.ServicesMBeanImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+
+ private ServiceRegistration mbeanRegistration;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ ServicesMBeanImpl mbean = new ServicesMBeanImpl();
+ mbean.setBundleContext(context);
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put("jmx.objectname", "org.apache.karaf:type=service,name=" + System.getProperty("karaf.name"));
+ mbeanRegistration = context.registerService(
+ getInterfaceNames(mbean),
+ mbean,
+ props
+ );
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ mbeanRegistration.unregister();
+ }
+
+ private String[] getInterfaceNames(Object object) {
+ List<String> names = new ArrayList<String>();
+ for (Class cl = object.getClass(); cl != Object.class; cl = cl.getSuperclass()) {
+ addSuperInterfaces(names, cl);
+ }
+ return names.toArray(new String[names.size()]);
+ }
+
+ private void addSuperInterfaces(List<String> names, Class clazz) {
+ for (Class cl : clazz.getInterfaces()) {
+ names.add(cl.getName());
+ addSuperInterfaces(names, cl);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/a1e5d4f5/service/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/service/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/service/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
deleted file mode 100644
index d022432..0000000
--- a/service/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
- <ext:property-placeholder/>
-
- <bean id="servicesMBean" class="org.apache.karaf.service.core.internal.ServicesMBeanImpl">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </bean>
-
- <service ref="servicesMBean" auto-export="interfaces">
- <service-properties>
- <entry key="jmx.objectname" value="org.apache.karaf:type=service,name=${karaf.name}"/>
- </service-properties>
- </service>
-
-</blueprint>
\ No newline at end of file