Skip to content

Always getting the same instance. (Does single() mean singleton?).  #80

@mcculls

Description

@mcculls

Originally reported on Google Code with ID 82

When using peaberry, I always get the same instance of an object. 
I don't specify the binding as being a Singleton Scope or use the @Singleton annotation

on the class. The binding is however annotated (with @Server). 

How do I get a unique instance? (A non-singleton). 
Am I using Peaberry wrongly? 

Bundle1: 
--------
Module1: 

bind(export(IDataProvider.class)).annotatedWith(Server.class)
                .toProvider(service(ServerCDODataProvider.class).export());

Activator1: 

@Inject
@Server
Export<IDataProvider> dataProvider;

.... start(BundleContext ctx){

createInjector(osgiModule(ctx), new Module1()).injectMembers(); 



Bundle2:
-------
Module2: 
        bind(IDataProvider.class).annotatedWith(Server.class).toProvider(
                service(IDataProvider.class).single());

ConsumerClass1: 

@Inject
@Server
IDataProvider provider1


ConsumerClass2: 
@Inject
@Server
IDataProvider provider2

provider1 == provider2 => true






Reported by bouhier.c on 2013-06-07 08:50:22

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions