Java Code Examples for org.apache.brooklyn.api.mgmt.ManagementContext#getApplications()

The following examples show how to use org.apache.brooklyn.api.mgmt.ManagementContext#getApplications() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractBlueprintTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
protected Application rebind(RebindOptions options) throws Exception {
    ManagementContext origMgmt = mgmt;
    ManagementContext newMgmt = createNewManagementContext();
    Collection<Application> origApps = origMgmt.getApplications();
    
    options = RebindOptions.create(options);
    if (options.classLoader == null) options.classLoader(classLoader);
    if (options.mementoDir == null) options.mementoDir(mementoDir);
    if (options.origManagementContext == null) options.origManagementContext(origMgmt);
    if (options.newManagementContext == null) options.newManagementContext(newMgmt);
    
    for (Application origApp : origApps) {
        RebindTestUtils.stopPersistence(origApp);
    }
    
    mgmt = options.newManagementContext;
    Application newApp = RebindTestUtils.rebind(options);
    return newApp;
}
 
Example 2
Source File: RebindTestUtils.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
/**
 * Walks the contents of a ManagementContext, to create a corresponding memento.
 */
protected static BrooklynMemento newBrooklynMemento(ManagementContext managementContext) {
    BrooklynMementoImpl.Builder builder = BrooklynMementoImpl.builder();
            
    for (Application app : managementContext.getApplications()) {
        builder.applicationId(app.getId());
    }
    for (Entity entity : managementContext.getEntityManager().getEntities()) {
        builder.entity(((EntityInternal)entity).getRebindSupport().getMemento());
    }
    for (Location location : managementContext.getLocationManager().getLocations()) {
        builder.location(((LocationInternal)location).getRebindSupport().getMemento());
        if (location.getParent() == null) {
            builder.topLevelLocationId(location.getId());
        }
    }

    BrooklynMemento result = builder.build();
    MementoValidators.validateMemento(result);
    return result;
}
 
Example 3
Source File: EntityFunctions.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
/** @deprecated since 0.9.0 kept only to allow conversion of non-static inner classes */
@SuppressWarnings("unused") @Deprecated 
private static Supplier<Collection<Application>> applicationsOld(final ManagementContext mgmt) {
    // TODO PERSISTENCE WORKAROUND
    class AppsSupplier implements Supplier<Collection<Application>> {
        @Override
        public Collection<Application> get() {
            return mgmt.getApplications();
        }
    }
    return new AppsSupplier();
}