private boolean isModelClass ( String classname , Bundle bundle ) { LOGGER . debug ( "Check if class '{}' is a model class" , classname ) ; Class < ? > clazz ; try { clazz = bundle . loadClass ( classname ) ; } catch ( ClassNotFoundException e ) { LOGGER . warn ( "Bundle could not load its own class: '{}' bundle: '{}'" , classname , bundle . getSymbolicName ( ) ) ; LOGGER . debug ( "Exact error: " , e ) ; return false ; } catch ( NoClassDefFoundError e ) { // ignore since this happens if bundle have optional imports return false ; } catch ( Error e ) { // if this catch clause is reached, then the bundle which caused this error need to be checked. There // is something wrong with the setup of the bundle (e.g. double import of a library of different versions) LOGGER . warn ( "Error while loading class: '{}' in bundle: '{}'" , classname , bundle . getSymbolicName ( ) ) ; LOGGER . debug ( "Exact error: " , e ) ; return false ; } return clazz . isAnnotationPresent ( Model . class ) ; }
Returns true if the class with the given class name contained in the given bundle is a model and false if not or the class couldn t be loaded .