use of io.joynr.provider.SubscriptionPublisher in project joynr by bmwcarit.
the class SubscriptionPublisherProducer method getSubscriptionPublisher.
@Produces
@io.joynr.jeeintegration.api.SubscriptionPublisher
public SubscriptionPublisher getSubscriptionPublisher(InjectionPoint injectionPoint) {
logger.info("Looking for subscription publisher for: " + injectionPoint);
logger.info("Type is: " + injectionPoint.getType());
logger.info("Member is: " + injectionPoint.getMember());
logger.info("Annotated is: " + injectionPoint.getAnnotated());
Class beanClass = injectionPoint.getBean() == null ? injectionPoint.getMember().getDeclaringClass() : injectionPoint.getBean().getBeanClass();
logger.info("Bean class is: " + beanClass);
if (!subscriptionPublishers.containsKey(beanClass)) {
Class subscriptionPublisherClass = (Class) injectionPoint.getAnnotated().getBaseType();
SubscriptionPublisher newSubscriptionPublisher = (SubscriptionPublisher) Proxy.newProxyInstance(subscriptionPublisherClass.getClassLoader(), new Class[] { subscriptionPublisherClass }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
throw new IllegalStateException("No subscription publisher set for " + subscriptionPublisherClass + " on " + beanClass);
}
});
subscriptionPublishers.putIfAbsent(beanClass, newSubscriptionPublisher);
}
return subscriptionPublishers.get(beanClass);
}
use of io.joynr.provider.SubscriptionPublisher in project joynr by bmwcarit.
the class SubscriptionPublisherInjectionWrapper method createInvocationHandler.
public static SubscriptionPublisherInjectionWrapper createInvocationHandler(Bean<?> bean, BeanManager beanManager) {
logger.trace("Called with {} and {}", bean, beanManager);
SubscriptionPublisherProducer subscriptionPublisherProducer = getSubscriptionPublisherProducerReference(beanManager);
Class proxiedInterface = SubscriptionPublisherInjection.class;
Class subscriptionPublisherClass = null;
Class beanClass = bean.getBeanClass();
for (InjectionPoint injectionPoint : bean.getInjectionPoints()) {
if (!injectionPoint.getQualifiers().contains(SUBSCRIPTION_PUBLISHER_ANNOTATION_LITERAL)) {
continue;
}
Type baseType = injectionPoint.getAnnotated().getBaseType();
if (baseType instanceof Class && SubscriptionPublisher.class.isAssignableFrom((Class) baseType)) {
subscriptionPublisherClass = (Class) baseType;
break;
}
}
logger.debug("Found injector {} and publisher {} classes.", proxiedInterface, subscriptionPublisherClass);
if (subscriptionPublisherClass == null || proxiedInterface == null) {
throw new JoynrIllegalStateException("Cannot create subscription publisher injection wrapper proxy for bean which doesn't inject a concrete SubscriptionPublisher.");
}
return new SubscriptionPublisherInjectionWrapper(proxiedInterface, subscriptionPublisherClass, subscriptionPublisherProducer, beanClass);
}
Aggregations