Ard Schrijvers pushed to branch master at cms-community / hippo-site-toolkit
Commits: 3f845c7f by Ard Schrijvers at 2017-06-13T17:36:03+02:00 HSTTWO-4043 Add a ComponentSupplier that can return a 'lazy' bean via a Supplier This can be used by downstream projects to via spring wiring get a supplier for a spring bean that is part of an HST spring addon - - - - - 1 changed file: - + commons/src/main/java/org/hippoecm/hst/core/container/ComponentSupplier.java Changes: ===================================== commons/src/main/java/org/hippoecm/hst/core/container/ComponentSupplier.java ===================================== --- /dev/null +++ b/commons/src/main/java/org/hippoecm/hst/core/container/ComponentSupplier.java @@ -0,0 +1,39 @@ +/* + * Copyright 2017 Hippo B.V. (http://www.onehippo.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.hippoecm.hst.core.container; + +import java.util.function.Supplier; + +import static org.hippoecm.hst.site.HstServices.getComponentManager; + +public class ComponentSupplier<T> implements Supplier{ + + private String name; + private String[] addonModuleNames; + + public void setName(final String name) { + this.name = name; + } + + public void setAddonModuleNames(final String[] addonModuleNames) { + this.addonModuleNames = addonModuleNames; + } + + public T get() { + return getComponentManager().getComponent(name, addonModuleNames); + } + +} View it on GitLab: https://code.onehippo.org/cms-community/hippo-site-toolkit/commit/3f845c7f811260c2b76ac27bf73b6b3471c1333b
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn