sk.stefan.projekt.trial.ABapp.java Source code

Java tutorial

Introduction

Here is the source code for sk.stefan.projekt.trial.ABapp.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sk.stefan.projekt.trial;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author stefan
 */
public class ABapp {

    private ABfactory abFactory;

    public static void main(String[] args) throws Exception {

        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
                "classpath:/context/TrialContext.xml");

        ABapp aba = (ABapp) ctx.getBean("abApp");

        aba.tryFactory();

    }

    private void tryFactory() {
        //        A a1 = abFactory.aFactoryMet("q1", "ahoj A");
        //        A a2 = abFactory.aFactoryMet("q1", "ahoj A");
        A a1 = abFactory.aFactoryMet();
        A a2 = abFactory.aFactoryMet();

        a1.setMsg("kokosko!");
        //        B b1 = abFactory.bFactoryMet("q2", "ahoj B");

        System.out.println("A1: *" + a1.getMsg() + "*");
        System.out.println("A2: *" + a2.getMsg() + "*");

        //        System.out.println("B: *" + b1.getMsg() +"*");

    }

    //    **********************   
    //    GETTERS AND SETTERS:
    //    **********************

    public ABfactory getAbFactory() {
        return abFactory;
    }

    public void setAbFactory(ABfactory abFactory) {
        this.abFactory = abFactory;
    }

}