/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.framework.sample;

import java.lang.reflect.Method;

import org.jfox.framework.Component;
import org.jfox.framework.ComponentContext;
import org.jfox.framework.Registry;
import org.jfox.framework.extra.InstantiatingInterceptable;
import org.jfox.framework.extra.MethodInterceptable;

/**
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class AComponent implements Component, InstantiatingInterceptable, MethodInterceptable, SampleComponent {
    private String name = "Hello,World";

    public AComponent() {
    }

    public AComponent(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setComponent(Component tc) {
        System.out.println(AComponent.class.getName() + "'s class loader: " + this.getClass().getClassLoader());
        System.out.println(BComponent.class.getName() + "'s class loader: " + tc.getClass().getClassLoader());
    }

    public Component afterInstantiate(Component theComp, Registry registry) {
        System.out.println("Component " + AComponent.class.getName() + " instantiated.");
        return theComp;
    }

    public void preInvoke(Method method, Object[] params) {
        System.out.println("preInvoke " + method.getName());
    }

    public Object postInvoke(Method method, Object result) {
        System.out.println("postInvoke " + method.getName());
        return result;
    }

    public void setComponentContext(ComponentContext ctx) {

    }


    public static void main(String[] args) {

    }
}

