Java Code Examples for org.apache.brooklyn.core.entity.EntityInternal#getManagementContext()

The following examples show how to use org.apache.brooklyn.core.entity.EntityInternal#getManagementContext() . 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: AbstractManagementContext.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
public BrooklynClassLoadingContext apply(@Nullable Object input) {
    if (input instanceof EntityInternal) {
        EntityInternal internal = (EntityInternal)input;
        String inputCatalogItemId = internal.getCatalogItemId();
        if(inputCatalogItemId != null) {
            RegisteredType item = internal.getManagementContext().getTypeRegistry().get(internal.getCatalogItemId());

            if (item != null) {
                final List<String> searchPath = internal.getCatalogItemIdSearchPath();
                final ManagementContext managementContext = internal.getManagementContext();
                BrooklynClassLoadingContextSequential seqLoader =
                    new BrooklynClassLoadingContextSequential(managementContext);
                seqLoader.add(newClassLoadingContextForCatalogItems(managementContext, inputCatalogItemId, searchPath));
                JavaBrooklynClassLoadingContext entityLoader =
                    JavaBrooklynClassLoadingContext.create(input.getClass().getClassLoader());
                seqLoader.add(entityLoader);
                return seqLoader;
            } else {
                log.error("Can't find catalog item " + internal.getCatalogItemId() +
                        " used for instantiating entity " + internal +
                        ". Falling back to application classpath.");
            }
        }
        return apply(internal.getManagementSupport());
    }
    
    if (input instanceof EntityManagementSupport)
        return apply(((EntityManagementSupport)input).getManagementContext());
    if (input instanceof ManagementContext)
        return JavaBrooklynClassLoadingContext.create((ManagementContext) input);
    return null;
}
 
Example 2
Source File: TemplateProcessor.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
protected EntityConfigTemplateModel(EntityInternal entity) {
    this.entity = checkNotNull(entity, "entity");
    this.mgmt = entity.getManagementContext();
}
 
Example 3
Source File: TemplateProcessor.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
protected EntityAndMapTemplateModel(EntityInternal entity, Map<String,? extends Object> extraSubstitutions) {
    this.entity = entity;
    this.driver = null;
    this.mgmt = entity.getManagementContext();
    this.extraSubstitutionsModel = new DotSplittingTemplateModel(extraSubstitutions);
}