EntityBean.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: EntityBean.java,v 1.4 2004/12/01 13:35:34 durieuxp Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.container;
00027 
00028 import org.objectweb.jonas_ejb.container.EntityCounters;
00029 import org.objectweb.jonas_ejb.container.JEntityFactory;
00030 import org.objectweb.jonas_ejb.deployment.api.EntityDesc;
00031 
00037 public class EntityBean extends EJB {
00038 
00039     // lock policy
00040     private static final int LOCK_CONTAINER_READ_UNCOMMITTED = EntityDesc.LOCK_CONTAINER_READ_UNCOMMITTED;
00041     private static final int LOCK_CONTAINER_SERIALIZED = EntityDesc.LOCK_CONTAINER_SERIALIZED;
00042     private static final int LOCK_CONTAINER_READ_COMMITTED = EntityDesc.LOCK_CONTAINER_READ_COMMITTED;
00043     private static final int LOCK_DATABASE = EntityDesc.LOCK_DATABASE;
00044     private static final int LOCK_READ_ONLY = EntityDesc.LOCK_READ_ONLY;
00045 
00046     private String persistency;
00047 
00048     public EntityBean(String objectName, JEntityFactory factoryToManage, String persistency) {
00049         super(objectName, factoryToManage);
00050         this.persistency = persistency;
00051     }
00052 
00056     public String getPersistency() {
00057         return persistency;
00058     }
00059 
00064     public int getPassivationTimeOut() {
00065         return ejbToManage.getContainer().getSwapTime();
00066     }
00067 
00072     public void setPassivationTimeOut(int timeOut) {
00073         ejbToManage.getContainer().setSwapTime(timeOut);
00074     }
00075 
00080     public int getInactivityTimeOut() {
00081         return ((JEntityFactory) ejbToManage).getInactivityTimeout();
00082     }
00083 
00087     public boolean getShared() {
00088         return ((JEntityFactory) ejbToManage).isShared();
00089     }
00090 
00094     public int getMinPoolSize() {
00095         return ((JEntityFactory) ejbToManage).getMinPoolSize();
00096     }
00097 
00101     public int getMaxCacheSize() {
00102         return ((JEntityFactory) ejbToManage).getMaxCacheSize();
00103     }
00104 
00108     public int getPoolSize() {
00109         return ((JEntityFactory) ejbToManage).getPoolSize();
00110     }
00111 
00115     public String getLockPolicy() {
00116         int lockPolicy = ((JEntityFactory) ejbToManage).lockPolicy();
00117         String sLockPolicy = null;
00118         switch (lockPolicy) {
00119             case LOCK_CONTAINER_READ_UNCOMMITTED:
00120                 sLockPolicy = "container-read-uncommitted";
00121                 break;
00122             case LOCK_CONTAINER_SERIALIZED:
00123                 sLockPolicy = "container-serialized";
00124                 break;
00125             case LOCK_CONTAINER_READ_COMMITTED:
00126                 sLockPolicy = "container-read-committed";
00127                 break;
00128             case LOCK_DATABASE:
00129                 sLockPolicy = "database";
00130                 break;
00131             case LOCK_READ_ONLY:
00132                 sLockPolicy = "read-only";
00133                 break;
00134         }
00135         return sLockPolicy;
00136     }
00137 
00138     public boolean getPrefetch() {
00139         return ((JEntityFactory) ejbToManage).isPrefetch();
00140     }
00144     public int getCacheSize() {
00145         return ((JEntityFactory) ejbToManage).getCacheSize();
00146     }
00147 
00152     public Integer[] getEntityCounters() {
00153         EntityCounters ec = ((JEntityFactory) ejbToManage).getEntityCounters();
00154         Integer[] result = new Integer[5];
00155         result[0] = new Integer(ec.inTx);
00156         result[1] = new Integer(ec.outTx);
00157         result[2] = new Integer(ec.idle);
00158         result[3] = new Integer(ec.passive);
00159         result[4] = new Integer(ec.removed);
00160         return result;
00161     }
00162 
00166     public void synchronize() {
00167         ((JEntityFactory) ejbToManage).sync();
00168     }
00169 
00173     public void reduceCache() {
00174         ((JEntityFactory) ejbToManage).reduceCache();
00175     }
00176 }

Generated on Tue Feb 15 15:05:14 2005 for JOnAS by  doxygen 1.3.9.1