com.learning.mocks.account.DefaultAccountManager2.java Source code

Java tutorial

Introduction

Here is the source code for com.learning.mocks.account.DefaultAccountManager2.java

Source

/* 
 * ========================================================================
 * 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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 com.learning.mocks.account;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.learning.mocks.configurations.Configuration;
import com.learning.mocks.configurations.DefaultConfiguration;

/**
 * Refactored architecture. We now pass the Configuration and Log objects to the constructor and use them for our own logic.
 * 
 * @version $Id: DefaultAccountManager2.java 508 2009-08-16 18:05:18Z paranoid12 $
 */
public class DefaultAccountManager2 implements AccountManager {
    /**
     * Logger instance.
     */
    private Log logger;

    /**
     * Configuration to use.
     */
    private Configuration configuration;

    /**
     * Constructor with no parameters.
     */
    public DefaultAccountManager2() {
        this(LogFactory.getLog(DefaultAccountManager2.class), new DefaultConfiguration("technical"));
    }

    /**
     * Constructor with logger and configration parameters.
     * 
     * @param logger
     * @param configuration
     */
    public DefaultAccountManager2(Log logger, Configuration configuration) {
        this.logger = logger;
        this.configuration = configuration;
    }

    /**
     * Finds an account for user with the given userID.
     * 
     * @param
     */
    public Account findAccountForUser(String userId) {
        this.logger.debug("Getting account for user [" + userId + "]");
        this.configuration.getSQL("FIND_ACCOUNT_FOR_USER");

        // Some code logic to load a user account using JDBC
        // []
        return null;
    }

    /**
     * Updates the given account.
     */
    public void updateAccount(Account account) {
        // Perform database access here
    }
}