coreexample.BaseAppConfig.java Source code

Java tutorial

Introduction

Here is the source code for coreexample.BaseAppConfig.java

Source

/*
 * Copyright 2012 Eng Kam Hon (kamhon@gmail.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 coreexample;

import java.util.Locale;

import net.kamhon.ieagle.aop.AppDetailsBaseAdvice;
import net.kamhon.ieagle.dao.HibernateDao;

import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@Configuration
public abstract class BaseAppConfig {
    @Autowired
    protected Environment env;

    @Bean
    public Locale systemLocale() {
        return new Locale("en", "US");
    }

    @Bean
    public AppDetailsBaseAdvice appDetailsBaseAdvice() {
        return new DummyAppDetailsBaseAdvice();
    }

    @Bean
    public ExampleDao exampleDao() {
        return new ExampleDaoImpl();
    }

    @Bean
    public ProxyFactoryBean genericDao() {
        ProxyFactoryBean proxy = new ProxyFactoryBean();
        proxy.setTarget(new HibernateDao<Object>());
        proxy.setInterceptorNames(new String[] { "appDetailsBaseAdvice" });
        return proxy;
    }

}