Question

seems like i am missing a basic concept, but even after hours of reading i'm somehow stuck right now.

given the following Setup: EE7 on Glassfish 4, Arquillian (pseudo) Code:

Multiple Implementations for an Interface:

public interface Activity {
    public void doFoo();
}

@Stateless
public class StockActivity implements Activity {
    @Override
    public void doFoo(){
        ...
    }
}


@Stateless
public class OrderActivity implements Activity {
    @Override
    public void doFoo(){
        ...
    }

    public void doSomeOtherStuff(){
        ...
    }   
}

Selection within the business-code like

@Any
@Inject
Instance<Activity> activities;

So far, everything works fine...but now i want to call the doSomeOtherStuff-method in an Arquillian-Test, which is not defined on the interface. I just can't figure out a way to retrieve an instance of the OrderActivity Bean

(i'd like to avoid the introduction of "hardcoded" specific qualifiers, since they would only be used for Tests. Also the specific implementations live in their own projects and get packaged per customer, so i also can't use one 'enumifed' Qualifier.)

Any Ideas?

Was it helpful?

Solution

okay, got it myself. For reference, here's the solution:

because 'Activity' is the only implemented interface (and is not java.io.Serializable/Externalizable or from the javax.ejb package), the container assumes its the only local business interface. To expose the no-interface view, the beans have to be explicitly annotated with @LocalBean

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top