Exemple #1
0
 /*
  * It may in theory happen that an app calls BeanManager.createAnnotatedType() for a previously unknown class on node1 and then
  * stores this annotated type in session. On node2, this annotated type is not know. We'll try to load it.
  */
 private SlimAnnotatedType<?> tryToLoadUnknownBackedAnnotatedType() {
   if (identifier.getSuffix() != null || identifier.isModified()) {
     return null; // this is not a backed annotated type
   }
   // first, obtain the BeanManager for a given BDA
   final BeanManagerImpl manager =
       Container.instance(identifier).getBeanManager(identifier.getBdaId());
   if (manager == null) {
     return null;
   }
   // second, try to load the class
   final ResourceLoader resourceLoader = manager.getServices().get(ResourceLoader.class);
   Class<?> clazz = null;
   try {
     clazz = resourceLoader.classForName(identifier.getClassName());
   } catch (ResourceLoadingException e) {
     MetadataLogger.LOG.catchingDebug(e);
     return null;
   }
   // finally, try to load the annotated type
   try {
     return manager
         .getServices()
         .get(ClassTransformer.class)
         .getBackedAnnotatedType(clazz, identifier.getBdaId());
   } catch (ResourceLoadingException e) {
     MetadataLogger.LOG.catchingDebug(e);
     return null;
   }
 }
Exemple #2
0
 public Metadata<Class<? extends T>> apply(Metadata<String> from) {
   String location = from.getLocation();
   try {
     return new MetadataImpl<Class<? extends T>>(
         Reflections.<Class<? extends T>>cast(resourceLoader.classForName(from.getValue())),
         location);
   } catch (ResourceLoadingException e) {
     throw new ResourceLoadingException(
         e.getMessage() + "; location: " + location, e.getCause());
   } catch (Exception e) {
     throw new ResourceLoadingException(e.getMessage() + "; location: " + location, e);
   }
 }