Package fr.imag.adele.apam

Examples of fr.imag.adele.apam.ResolutionException


      /*
       * If no exception is specified throw ResolutionException
       */
      String exceptionName = relToResolve.getMissingException();
      if (exceptionName == null) {
        throw new ResolutionException();
      }

      /*
       * Try to find the component declaring the relation that specified
       * the Exception to throw
       *
       * TODO BUG : the class should be loaded using the bundle context of
       * the component where the relation is declared. This can be either
       * the specification, or the implementation of the source component,
       * or a composite in the case of contextual dependencies. The
       * current implementation may not handle every case.
       *
       * The best solution is to modify relationDeclaration to load the
       * exception class, but this is not possible at compile time, so we
       * can not change the signature of
       * relationDeclaration.getMissingException.
       *
       * A possible solution is to move this method to relationDeclaration
       * and make it work only at runtime, but we need to consider merge
       * of contextual dependencies and use the correct bundle context.
       *
       * Evaluate changes to relationDeclaration, relation,
       * CoreMetadataParser and computeEffectiverelation
       */
      Component declaringComponent = source;
      while (declaringComponent != null) {

        RelationDeclaration declaration = declaringComponent.getDeclaration().getRelation(relToResolve.getName());
        if (declaration != null && declaration.getMissingException() != null && declaration.getMissingException().equals(exceptionName)) {
          break;
        }

        declaringComponent = declaringComponent.getGroup();
      }

      if (declaringComponent == null && source instanceof Instance) {
        declaringComponent = ((Instance) source).getComposite().getCompType();
      }

      if (declaringComponent == null) {
        throw new ResolutionException();
      }

      /*
       * throw the specified exception
       */

      Class<?> exceptionClass = declaringComponent.getApformComponent().getBundle().loadClass(exceptionName);
      Exception exception = Exception.class.cast(exceptionClass.newInstance());

      FailedResolutionManager.<RuntimeException> doThrow(exception);

    } catch (ClassNotFoundException e) {
      throw new ResolutionException(e);
    } catch (InstantiationException e) {
      throw new ResolutionException(e);
    } catch (IllegalAccessException e) {
      throw new ResolutionException(e);
    }

  }
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.ResolutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.