Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 521FF76BE for ; Thu, 6 Oct 2011 15:39:55 +0000 (UTC) Received: (qmail 80501 invoked by uid 500); 6 Oct 2011 15:39:55 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 80450 invoked by uid 500); 6 Oct 2011 15:39:55 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 80442 invoked by uid 99); 6 Oct 2011 15:39:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Oct 2011 15:39:54 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Oct 2011 15:39:52 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 67D392ACA2D for ; Thu, 6 Oct 2011 15:39:30 +0000 (UTC) Date: Thu, 6 Oct 2011 15:39:30 +0000 (UTC) From: "Robert Lillack (Updated) (JIRA)" To: dev@felix.apache.org Message-ID: <2036047400.3791.1317915570426.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1391186153.65310.1307093627322.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (FELIX-2981) Unable to remove configuration properties using iPOJO's configuration handler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/FELIX-2981?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Robert Lillack updated FELIX-2981: ---------------------------------- Attachment: felix-2981-2.patch > Unable to remove configuration properties using iPOJO's configuration handler > ----------------------------------------------------------------------------- > > Key: FELIX-2981 > URL: https://issues.apache.org/jira/browse/FELIX-2981 > Project: Felix > Issue Type: Bug > Components: iPOJO > Affects Versions: iPOJO-1.8.0 > Environment: * Apache Felix Bundle Repository (1.6.0) > * Apache Felix Configuration Admin Service (1.2.8) > * Apache Felix Gogo Runtime (0.8.0) > * Apache Felix iPOJO (1.8.0) > * Apache Felix iPOJO Annotations (1.8.0) > * iPOJO Metadata (1.4.0) > * Apache Felix Preferences Service (1.0.4) > Reporter: Robert Lillack > Assignee: Clement Escoffier > Priority: Minor > Fix For: ipojo-core-1.8.2 > > Attachments: felix-2981-2.patch, felix-2981.patch > > > Hi, > using iPOJO's _very nice_ OSGi Configuration Admin integration I sadly seem unable to remove any properties from a configuration to "reset" this property back to it's default value. Comparing the following two classes---one using iPOJO the other one directly implementing the ManagedService interface ... > @Component(managedservice = "example1") > @Instantiate > public class Example1 { > > @Property > private String key; > > @Updated > private void updated() { > System.out.format("example1 = %s\n", key); > } > } > @Component > @Instantiate > public class Example2 implements ManagedService { > BundleContext ctx; > > public Example2(BundleContext c) { > ctx = c; > } > > @Validate > public void start() { > ctx.registerService(ManagedService.class.getName(), this, getDefaults()); > } > private Hashtable getDefaults() { > Hashtable defaults = new Hashtable(); > defaults.put(Constants.SERVICE_PID, "example2"); > return defaults; > } > @Override > public void updated(Dictionary properties) throws ConfigurationException { > System.out.format("example2 = %s\n", properties == null ? null : properties.get("key")); > } > } > ... with the code setting the properties looking like this ... > public void set(String value) throws Exception { > setProperty("example1", value); > setProperty("example2", value); > } > > public void unset() throws Exception { > setProperty("example1", null); > setProperty("example2", null); > } > > private void setProperty(String srv, String value) throws IOException { > Configuration cfg = configAdmin.getConfiguration(srv, null); > Dictionary p = cfg.getProperties(); > if (p == null) { > p = new Properties(); > } > > if (value == null) { > p.remove("key"); > } else { > p.put("key", value); > } > cfg.update(p); > } > ... these are the results after calling set("qsdasdasd") followed by unset(): > example1 = qsdasdasd > example2 = qsdasdasd > example1 = qsdasdasd > example2 = null > Am I using iPOJO the wrong way here? Thanks! -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira