X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=wicket%2Fjoe%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fwicket%2Finject%2FComponentInstantiationInjector.java;fp=wicket%2Fjoe%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fwicket%2Finject%2FComponentInstantiationInjector.java;h=d361ebc3c7e864771ce4e584a3cb7334cde66542;hb=faef41a7706fe470b864efde1713c2d72998c7ad;hp=0000000000000000000000000000000000000000;hpb=845506d261bba75452e9d65191e486705015b603;p=utils diff --git a/wicket/joe/src/main/java/org/wamblee/wicket/inject/ComponentInstantiationInjector.java b/wicket/joe/src/main/java/org/wamblee/wicket/inject/ComponentInstantiationInjector.java new file mode 100644 index 00000000..d361ebc3 --- /dev/null +++ b/wicket/joe/src/main/java/org/wamblee/wicket/inject/ComponentInstantiationInjector.java @@ -0,0 +1,48 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * 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.wamblee.wicket.inject; + +import org.apache.wicket.Component; +import org.apache.wicket.application.IComponentInstantiationListener; +import org.wamblee.inject.InjectorFactoryBuilder; +import org.wamblee.inject.SimpleInjector; + +/** + * Component instantiation listener that injects references into a component + * using the injector mini-framework. Together with an implementation of the + * mini-framework, Contexts and Depenency Injection support can be provided. + * + * + * @author Erik Brakkee + */ +public class ComponentInstantiationInjector implements + IComponentInstantiationListener { + + private SimpleInjector injector; + + /** + * Constructs the component instantiation listener. + */ + public ComponentInstantiationInjector() { + injector = new SimpleInjector(InjectorFactoryBuilder.getInjectorFactory()); + } + + @Override + public void onInstantiation(Component aComponent) { + injector.inject(aComponent); + } + +}