net.gvcc.jgoffice.system.factories.DBNavigatorBarFactory.java Source code

Java tutorial

Introduction

Here is the source code for net.gvcc.jgoffice.system.factories.DBNavigatorBarFactory.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 net.gvcc.jgoffice.system.factories;

import com.vaadin.server.VaadinSession;
import net.gvcc.jgoffice.dbnavigatorbar.DbNavigatorBar;

/**
 *
 * @author ernst_sgv
 */
public class DBNavigatorBarFactory {
    private final static String SESSION_SCOPED_VALUE_ID1 = "sessionDBNavBarComponent";

    private DBNavigatorBarFactory() {
    }

    public static DbNavigatorBar getInstance() {

        if (VaadinSession.getCurrent().getAttribute(SESSION_SCOPED_VALUE_ID1) == null) {
            try {
                VaadinSession.getCurrent().lock();
                VaadinSession.getCurrent().setAttribute(SESSION_SCOPED_VALUE_ID1, new DbNavigatorBar());

            } finally {
                VaadinSession.getCurrent().unlock();
            }
        }

        return (DbNavigatorBar) VaadinSession.getCurrent().getAttribute(SESSION_SCOPED_VALUE_ID1);
    }
}