/*
 * 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 sikd.sikd5.coba;

import javax.inject.Named;

import java.io.Serializable;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.naming.Context;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;
import org.omnifaces.cdi.ViewScoped;

import sikd.sikd5.sikd5bean.util.PropertiesLoader;
import sikd.sikd5.sikd5bean.util.ServerUtil;
import sikd.sikd5.sikd5bean.util.SikdSessionUtil;
import sikd.sikd5.sikd5ejb.session.PerkiraanBelanjaSessionBean;
import sikd.sikd5.sikd5ejb.session.PerkiraanBelanjaSessionBeanRemote;
import sikd.sikd5.sikd5ejb.session.PosisiKasSessionBean;


/**
 *
 * @author agus
 */

@ManagedBean
@ViewScoped
public class CobaMb implements Serializable {

    /**
     * Creates a new instance of CobaMb
     */
   public void init(){
       
   }
    public void coba() throws Exception{
        String fileName = System.getProperty("jboss.server.config.dir");//wildfly
//        String fileName = System.getProperty("com.sun.aas.instanceRoot");//glassfish
//        System.out.println("....................................");
        System.out.println(fileName);
//        Properties prop = PropertiesLoader.loadPropertiesGlassfish("sikd.properties");
        PerkiraanBelanjaSessionBeanRemote service;
            try {
            Context context = ServerUtil.getOfficeContextV3();
            service = (PerkiraanBelanjaSessionBeanRemote) context.lookup(SikdSessionUtil.PERKIRAAN_BELANJA_SESSION);
            
            System.out.println("Hasilnya aacc: " + service.getInfoPengiriman("",(short)1,(short)1));
        } catch (Exception ex) {
            Logger.getLogger(CobaMb.class.getName()).log(Level.SEVERE, null, ex);
        }
            
    }
    public void coba2(){
       PosisiKasSessionBean service;
            try {
            Context context = ServerUtil.getOfficeContextV3();
            service = (PosisiKasSessionBean) context.lookup(SikdSessionUtil.POSISI_KAS_SESSION);
            
            System.out.println("Hasilnya bb: " + service.getInfoPengiriman("", (short) 0,(short) 0));
        } catch (Exception ex) {
            Logger.getLogger(CobaMb.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
                
}
