Want more features on Pastebin? Sign Up, it's FREE!
Guest

Seam3JMSExtension

By: a guest on Jan 20th, 2011  |  syntax: Java  |  size: 1.42 KB  |  views: 49  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Interface:
  2.  
  3. public void mapLongsToTopic(@Observes Long id, @JmsDestination(jndiName="jms/LongT") Topic t);
  4.  
  5. code in extension:
  6.  
  7.             try{
  8.                 for(AnnotatedParameter<?> ap : m.getParameters()) {
  9.                     if(ap.getBaseType() instanceof Class) {
  10.                         Class<?> clazz = (Class<?>)ap.getBaseType();
  11.                         if(Destination.class.isAssignableFrom(clazz)) {
  12.                             d.add(resolveDestination(bm,ap));
  13.                         } else if (ap.isAnnotationPresent(Observes.class)){
  14.                             type = ap.getBaseType();
  15.                             qualifiers.addAll(getQualifiersFrom(ap.getAnnotations()));
  16.                         }
  17.                     }
  18.                 }
  19.             } catch (Exception e) {
  20.                 log.warn("Exception mapping for method "+m.getJavaMember().getDeclaringClass()+"."+m.getJavaMember().getName()+", ",e);
  21.             }
  22.  
  23. public static Destination resolveDestination(BeanManager bm, AnnotatedParameter<?> ap)
  24.     {
  25.         Set<Annotation> qs = getQualifiersFrom(ap.getAnnotations());
  26.         Set<Bean<?>> beans = bm.getBeans(ap.getBaseType(), qs.toArray(new Annotation[]{}));
  27.         Bean<?> bean = bm.resolve(beans);
  28.         CreationalContext<?> context = bm.createCreationalContext(bean);
  29.         Object ref = bm.getReference(bean, ap.getBaseType(), context);
  30.         return (Destination)ref;
  31.     }
clone this paste RAW Paste Data