Return-Path: X-Original-To: apmail-karaf-commits-archive@minotaur.apache.org Delivered-To: apmail-karaf-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0FA7F105F5 for ; Tue, 25 Mar 2014 11:54:40 +0000 (UTC) Received: (qmail 58771 invoked by uid 500); 25 Mar 2014 11:54:39 -0000 Delivered-To: apmail-karaf-commits-archive@karaf.apache.org Received: (qmail 58709 invoked by uid 500); 25 Mar 2014 11:54:39 -0000 Mailing-List: contact commits-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@karaf.apache.org Delivered-To: mailing list commits@karaf.apache.org Received: (qmail 58566 invoked by uid 99); 25 Mar 2014 11:54:33 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Mar 2014 11:54:33 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D726C8BBDF8; Tue, 25 Mar 2014 11:54:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gnodet@apache.org To: commits@karaf.apache.org Date: Tue, 25 Mar 2014 11:54:33 -0000 Message-Id: <19c8c81fcbd644948d2943baf6947e1e@git.apache.org> In-Reply-To: <4f505ecab0e443759b0efb91b6d0c4e4@git.apache.org> References: <4f505ecab0e443759b0efb91b6d0c4e4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] git commit: [KARAF-2833] Make wrapper/core independent of blueprint [KARAF-2833] Make wrapper/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/adea26ef Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/adea26ef Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/adea26ef Branch: refs/heads/master Commit: adea26ef783fe75349d3b8df429c31b330b742d6 Parents: d48f0fe Author: Guillaume Nodet Authored: Tue Mar 25 11:31:43 2014 +0100 Committer: Guillaume Nodet Committed: Tue Mar 25 11:31:43 2014 +0100 ---------------------------------------------------------------------- .../standard/src/main/feature/feature.xml | 1 - wrapper/core/pom.xml | 4 + .../karaf/wrapper/internal/osgi/Activator.java | 82 ++++++++++++++++++++ .../OSGI-INF/blueprint/wrapper-core.xml | 39 ---------- 4 files changed, 86 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/adea26ef/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 e5af831..932fa72 100644 --- a/assemblies/features/standard/src/main/feature/feature.xml +++ b/assemblies/features/standard/src/main/feature/feature.xml @@ -97,7 +97,6 @@ - aries-blueprint mvn:org.apache.karaf.wrapper/org.apache.karaf.wrapper.core/${project.version} mvn:org.apache.karaf.wrapper/org.apache.karaf.wrapper.command/${project.version} http://git-wip-us.apache.org/repos/asf/karaf/blob/adea26ef/wrapper/core/pom.xml ---------------------------------------------------------------------- diff --git a/wrapper/core/pom.xml b/wrapper/core/pom.xml index 961525c..7da4e0d 100644 --- a/wrapper/core/pom.xml +++ b/wrapper/core/pom.xml @@ -104,6 +104,7 @@ org.apache.karaf.wrapper.internal, + org.apache.karaf.wrapper.internal.osgi, org.apache.karaf.wrapper.management.internal, org.tanukisoftware.wrapper*, org.apache.karaf.main* @@ -114,6 +115,9 @@ !org.apache.karaf.info, * + + org.apache.karaf.wrapper.internal.osgi.Activator + http://git-wip-us.apache.org/repos/asf/karaf/blob/adea26ef/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/osgi/Activator.java b/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/osgi/Activator.java new file mode 100644 index 0000000..8832533 --- /dev/null +++ b/wrapper/core/src/main/java/org/apache/karaf/wrapper/internal/osgi/Activator.java @@ -0,0 +1,82 @@ +/* + * 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.wrapper.internal.osgi; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import javax.management.NotCompliantMBeanException; + +import org.apache.karaf.wrapper.WrapperService; +import org.apache.karaf.wrapper.internal.WrapperServiceImpl; +import org.apache.karaf.wrapper.management.internal.WrapperMBeanImpl; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Activator implements BundleActivator { + + private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class); + + ServiceRegistration serviceRegistration; + ServiceRegistration mbeanRegistration; + + @Override + public void start(BundleContext context) throws Exception { + WrapperService wrapperService = new WrapperServiceImpl(); + serviceRegistration = context.registerService(WrapperService.class, wrapperService, null); + + try { + WrapperMBeanImpl wrapperMBean = new WrapperMBeanImpl(); + wrapperMBean.setWrapperService(wrapperService); + Hashtable props = new Hashtable(); + props.put("jmx.objectname", "org.apache.karaf:type=wrapper,name=" + System.getProperty("karaf.name")); + mbeanRegistration = context.registerService( + getInterfaceNames(wrapperMBean), + wrapperMBean, + props + ); + } catch (NotCompliantMBeanException e) { + LOGGER.warn("Error creating Wrapper mbean", e); + } + } + + @Override + public void stop(BundleContext context) throws Exception { + serviceRegistration.unregister(); + mbeanRegistration.unregister(); + } + + private String[] getInterfaceNames(Object object) { + List names = new ArrayList(); + 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 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/adea26ef/wrapper/core/src/main/resources/OSGI-INF/blueprint/wrapper-core.xml ---------------------------------------------------------------------- diff --git a/wrapper/core/src/main/resources/OSGI-INF/blueprint/wrapper-core.xml b/wrapper/core/src/main/resources/OSGI-INF/blueprint/wrapper-core.xml deleted file mode 100644 index 058b381..0000000 --- a/wrapper/core/src/main/resources/OSGI-INF/blueprint/wrapper-core.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file