コード例 #1
0
  @SuppressWarnings("unchecked")
  public static <T> Maybe<Class<T>> tryLoadFromClasspath(String typeName, ManagementContext mgmt) {
    Class<T> clazz;
    try {
      clazz = (Class<T>) mgmt.getCatalog().getRootClassLoader().loadClass(typeName);
    } catch (ClassNotFoundException e) {
      LOG.debug("Class {} not found on classpath", typeName);
      return Maybe.absent(new Throwable("Could not find " + typeName + " on classpath"));
    }

    return Maybe.<Class<T>>of(clazz);
  }
コード例 #2
0
 @SuppressWarnings("unchecked")
 public static <T extends Entity> Maybe<Class<T>> tryLoadEntityFromCatalogue(
     String entityTypeName, ManagementContext mgmt) {
   try {
     return (Maybe<Class<T>>)
         (Maybe<?>)
             Maybe.<Class<? extends Entity>>of(
                 mgmt.getCatalog().loadClassByType(entityTypeName, Entity.class));
   } catch (NoSuchElementException e) {
     LOG.debug("Class {} not found in catalogue classpath", entityTypeName);
     return Maybe.absent();
   }
 }
コード例 #3
0
 /** Returns the CAMP platform associated with a management context, if there is one. */
 public static Maybe<CampPlatform> getCampPlatform(ManagementContext mgmt) {
   CampPlatform result = mgmt.getConfig().getConfig(BrooklynServerConfig.CAMP_PLATFORM);
   if (result != null) return Maybe.of(result);
   return Maybe.absent("No CAMP Platform is registered with this Brooklyn management context.");
 }