📄 serverbean.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.session;
import java.util.*;
import java.sql.*;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import org.apache.log4j.Logger;
import org.compiere.interfaces.*;
import org.compiere.Compiere;
import org.compiere.util.Log;
import org.compiere.acct.AcctServer;
import org.compiere.model.MWindowVO;
/**
* Compiere Server Bean
*
* @ejb:bean name="compiere/Server"
* display-name="Compiere Server Session Bean"
* type="Stateful"
* transaction-type="Bean"
* jndi-name="ejb/compiere/Server"
*
* @ejb:ejb-ref ejb-name="compiere/Server"
* ref-name="compiere/Server"
*
* @author Jorg Janke
* @version $Id: ServerBean.java,v 1.6 2002/11/18 06:10:49 jjanke Exp $
*/
public class ServerBean implements SessionBean
{
/** Context */
private SessionContext m_Context;
/** Logging */
private transient Logger log = Logger.getLogger(getClass());
//
private static int s_no = 0;
private int m_no = 0;
//
private int m_windowCount = 0;
private int m_postCount = 0;
private int m_processCount = 0;
/**
* Get and create Window Model Value Object
* @ejb:interface-method view-type="remote"
*
* @param ctx Environment Properties
* @param WindowNo number of this window
* @param AD_Window_ID the internal number of the window, if not 0, AD_Menu_ID is ignored
* @param AD_Menu_ID ine internal menu number, used when AD_Window_ID is 0
* @return initialized Window Model
* @throws RemoteException
*/
public MWindowVO getWindowVO (Properties ctx, int WindowNo, int AD_Window_ID, int AD_Menu_ID)
throws RemoteException
{
log.info ("getWindowVO[" + m_no + "] Window=" + AD_Window_ID);
MWindowVO vo = MWindowVO.create(ctx, WindowNo, AD_Window_ID, AD_Menu_ID);
m_windowCount++;
return vo;
} // getWindowVO
/**
* Post Immediate
* @ejb:interface-method view-type="remote"
*
* @param AD_Table_ID Table ID of Document
* @param AD_Client_ID Client ID of Document
* @param Record_ID Record ID of this document
* @param force force posting
* @return true, if success
* @throws RemoteException
*/
public boolean postImmediate (int AD_Table_ID, int AD_Client_ID,
int Record_ID, boolean force)
throws RemoteException
{
log.info ("postImmediate[" + m_no + "] Table=" + AD_Table_ID + ", Record=" + Record_ID);
m_postCount++;
return AcctServer.postImmediate(AD_Table_ID, AD_Client_ID, Record_ID, force);
} // postImmediate
/**
* Process class on Server
* @ejb:interface-method view-type="remote"
*
* @param className class name
* @param ctx context
* @param AD_PInstance_ID instance
* @param Record_ID record
* @param Name Process Name
* @return true if success
* @throws RemoteException
*/
public boolean process (String className, Properties ctx, String Name,
int AD_PInstance_ID, int Record_ID)
throws RemoteException
{
log.info ("process[" + m_no + "]" + AD_PInstance_ID);
m_processCount++;
return false;
} // process
/*************************************************************************/
/**
* Describes the instance and its content for debugging purpose
* @ejb:interface-method view-type="remote"
* @return Debugging information about the instance and its content
*/
public String getStatus()
{
StringBuffer sb = new StringBuffer("ServerBean[No=");
sb.append(m_no)
.append(",WindowCount=").append(m_windowCount)
.append(",PostCount=").append(m_postCount)
.append(",ProcessCount=").append(m_processCount)
.append("]");
return sb.toString();
} // getStatus
/**
* String Representation
* @return info
*/
public String toString()
{
return getStatus();
} // toString
/*************************************************************************/
/**
* Create the Session Bean
* @throws CreateException
* @ejb:create-method view-type="remote"
*/
public void ejbCreate() throws CreateException
{
m_no = ++s_no;
log.info ("ejbCreate [" + m_no + "]");
try
{
org.compiere.Compiere.startupServer(new InitialContext());
}
catch (Exception ex)
{
log.error("ejbCreate", ex);
// throw new CreateException ();
}
} // ejbCreate
// -------------------------------------------------------------------------
// Framework Callbacks
// -------------------------------------------------------------------------
public void setSessionContext (SessionContext aContext) throws EJBException
{
m_Context = aContext;
}
public void ejbActivate() throws EJBException
{
if (log == null)
log = Logger.getLogger(getClass());
log.debug("ejbActivate");
}
public void ejbPassivate() throws EJBException
{
log.debug("ejbPassivate");
}
public void ejbRemove() throws EJBException
{
log.debug("ejbRemove");
}
} // ServerBean
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -