felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jago de Vreede (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (FELIX-4384) Difference between inner class and normal class service
Date Wed, 15 Jan 2014 05:49:21 GMT

     [ https://issues.apache.org/jira/browse/FELIX-4384?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jago de Vreede updated FELIX-4384:
----------------------------------

    Description: 
Given the following code:
package org.example;

import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.BundleContext;

public class Activator extends DependencyActivatorBase {
    @Override
    public synchronized void init(BundleContext context, DependencyManager manager) throws
Exception {
        manager.add(createComponent()
            .setInterface(A.class.getName(), null)
            .setImplementation(A.class)
            .add(createServiceDependency().setService(S.class).setRequired(true)));
        
        manager.add(createComponent()
            .setInterface(S.class.getName(), null)
            .setImplementation(S1.class));
    }

    @Override
    public synchronized void destroy(BundleContext context, DependencyManager manager) throws
Exception {}
    
    interface S {}
    class A {}
    class S1 implements S {}
}

dm will print out:
g! dm
[8] mytest
 [0] org.example.Activator$A unregistered
    org.example.Activator$S service required unavailable
 [1] org.example.Activator$S registered


But when the class S1 is promoted to a real class, dm will print out:
g! dm
[8] mytest
 [0] org.example.Activator$A registered
    org.example.Activator$S service required available
 [1] org.example.Activator$S registered

So the service class S1 is not available if its an inner class but is available if its a normal
class.

  was:
Given the following code:
{code}package org.example;

import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.BundleContext;

public class Activator extends DependencyActivatorBase {
    @Override
    public synchronized void init(BundleContext context, DependencyManager manager) throws
Exception {
        manager.add(createComponent()
            .setInterface(A.class.getName(), null)
            .setImplementation(A.class)
            .add(createServiceDependency().setService(S.class).setRequired(true)));
        
        manager.add(createComponent()
            .setInterface(S.class.getName(), null)
            .setImplementation(S1.class));
    }

    @Override
    public synchronized void destroy(BundleContext context, DependencyManager manager) throws
Exception {}
    
    interface S {}
    class A {}
    class S1 implements S {}
}{code}

dm will print out:
{quote}
g! dm
[8] mytest
 [0] org.example.Activator$A unregistered
    org.example.Activator$S service required unavailable
 [1] org.example.Activator$S registered
{quote}

But when the class S1 is promoted to a real class, dm will print out:
{quote}
g! dm
[8] mytest
 [0] org.example.Activator$A registered
    org.example.Activator$S service required available
 [1] org.example.Activator$S registered
{quote}

So the service class S1 is not available if its an inner class but is available if its a normal
class.


> Difference between inner class and normal class service
> -------------------------------------------------------
>
>                 Key: FELIX-4384
>                 URL: https://issues.apache.org/jira/browse/FELIX-4384
>             Project: Felix
>          Issue Type: Bug
>          Components: Dependency Manager
>    Affects Versions: dependencymanager-3.1.0
>            Reporter: Jago de Vreede
>            Priority: Minor
>
> Given the following code:
> package org.example;
> import org.apache.felix.dm.DependencyActivatorBase;
> import org.apache.felix.dm.DependencyManager;
> import org.osgi.framework.BundleContext;
> public class Activator extends DependencyActivatorBase {
>     @Override
>     public synchronized void init(BundleContext context, DependencyManager manager) throws
Exception {
>         manager.add(createComponent()
>             .setInterface(A.class.getName(), null)
>             .setImplementation(A.class)
>             .add(createServiceDependency().setService(S.class).setRequired(true)));
>         
>         manager.add(createComponent()
>             .setInterface(S.class.getName(), null)
>             .setImplementation(S1.class));
>     }
>     @Override
>     public synchronized void destroy(BundleContext context, DependencyManager manager)
throws Exception {}
>     
>     interface S {}
>     class A {}
>     class S1 implements S {}
> }
> dm will print out:
> g! dm
> [8] mytest
>  [0] org.example.Activator$A unregistered
>     org.example.Activator$S service required unavailable
>  [1] org.example.Activator$S registered
> But when the class S1 is promoted to a real class, dm will print out:
> g! dm
> [8] mytest
>  [0] org.example.Activator$A registered
>     org.example.Activator$S service required available
>  [1] org.example.Activator$S registered
> So the service class S1 is not available if its an inner class but is available if its
a normal class.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message