Package org.mapache.business

Source Code of org.mapache.business.BlogController

package org.mapache.business;

import java.util.Date;
import java.util.List;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.mapache.business.blog.Blog;
import org.mapache.business.blog.BlogManager;
import org.mapache.business.category.Category;
import org.mapache.business.category.CategoryManager;
import org.mapache.business.reply.RSSReply;
import org.mapache.business.reply.Reply;
import org.mapache.business.reply.ReplyManager;
import org.mapache.business.topic.Topic;
import org.mapache.business.topic.TopicManager;

public class BlogController {
    private BlogManager _blogManager;
    private TopicManager _topicManager;
    private CategoryManager _categoryManager;
    private ReplyManager _replyManager;
    private static BlogController _instance;
   
    private BlogController() {
        ExecutorService service = Executors.newFixedThreadPool(1);
        Runnable a = new Runnable(){
        public void run(){
          long max = 0;
          while(true){
                        Date start = new Date();
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            // TODO
                        }
                        Date end = new Date();
                        System.out.println("Memory used: "+(end.getTime()-start.getTime())+" milliseconds.");
          }
                    }};
                          
        //service.execute(a);
    }
   
    public static BlogController getInstance(){
        if(_instance==null)
            _instance = new BlogController();
        return _instance;
    }
    private CategoryManager getCategoryManager() {
        if(_categoryManager==null){
            _categoryManager = new CategoryManager();
        }
        return _categoryManager;
    }
    private TopicManager getTopicManager(){
        if(_topicManager==null){
            _topicManager = new TopicManager();
        }
        return _topicManager;
    }
    private ReplyManager getReplyManager(){
        if(_replyManager == null){
            _replyManager = new ReplyManager();
        }
        return _replyManager;
    }
    private BlogManager getBlogManager(){
        if(_blogManager == null){
            _blogManager = new BlogManager();
        }
        return _blogManager;
    }
    public List<Blog> loadBlogs() throws MapacheException {
        return getBlogManager().loadAllBlogs_visitor();
    }
    public List<Topic> loadTopics(Blog _blog,Category _category) throws MapacheException {
        return getTopicManager().loadAllTopics_visitor(_blog,_category);
    }
    public Blog loadBlogByBlogID(int blogID) throws MapacheException {
        return getBlogManager().loadBlogByBlogID(blogID);
    }
    public List<Category> loadCategoriesOfBlog(Blog blog) throws MapacheException {
        return getCategoryManager().loadCategoriesOfBlog(blog);
    }

    public Category loadCategoryByCategoryId(int categoryID) throws MapacheException {
        return getCategoryManager().loadCategoryByCategoryId(categoryID);
    }
    public Topic loadTopicByTopicID(int topicID) throws MapacheException{
        return getTopicManager().loadTopicByTopicID(topicID);
    }

    public List<Reply> loadRepliesOfTopic(Topic _topic) throws MapacheException{
        if(_topic.getTopicID()==-1){
            return getReplyManager().loadAllReplies();
        }
        else{
            return getReplyManager().loadRepliesOfTopic(_topic);
        }
    }
    public void createReply(Reply newReply, int topicID) throws MapacheException{
        getReplyManager().createReply(newReply,topicID);
    }
    public Category loadCategoryByCategoryName(String name) throws MapacheException{
        return getCategoryManager().loadCategoryByCategoryName(name);
    }
    public Topic loadTopicByTopicTitle(String title) throws MapacheException{
        return getTopicManager().loadTopicByTopicTitle(title);
    }
    public List<RSSReply> loadReplies_feed() throws MapacheException {
        return getReplyManager().loadReplies_feed();
    }

    public Blog loadBlogByBlogName_visitor(String string) throws MapacheException{
        return getBlogManager().loadBlogByBlogName_visitor(string);
    }


    public List<Topic> loadTopicsBySearch(String[] params) throws MapacheException{
        return getTopicManager().loadTopicsBySearch(params);
    }
}
TOP

Related Classes of org.mapache.business.BlogController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.