001: /**
002: * Copyright (C) 2001-2005 France Telecom R&D
003: */package org.objectweb.speedo.jmx.mbeans;
004:
005: import java.util.Arrays;
006: import java.util.Collection;
007: import java.util.Map;
008:
009: import org.objectweb.jorm.api.PMapper;
010: import org.objectweb.perseus.pool.api.Pool;
011: import org.objectweb.perseus.pool.api.PoolAttributes;
012: import org.objectweb.speedo.AbstractSpeedo;
013: import org.objectweb.speedo.api.SpeedoProperties;
014: import org.objectweb.speedo.mapper.api.JormFactory;
015: import org.objectweb.speedo.mapper.api.JormFactoryAttributes;
016: import org.objectweb.speedo.pm.jdo.api.JDOPOManagerFactoryItf;
017:
018: /**
019: *
020: *
021: * @author chassase
022: */
023: public class PMF implements PMFMBean {
024:
025: private JDOPOManagerFactoryItf pmf;
026: private PMapper mapper;
027: private JormFactory jf;
028: private JormFactoryAttributes jfa;
029: private PoolAttributes pa;
030: private Pool pool;
031:
032: public PMF(PoolAttributes pa, Pool pool,
033: JDOPOManagerFactoryItf pmf, PMapper mapper, JormFactory jf,
034: JormFactoryAttributes jfa) {
035: this .pa = pa;
036: this .pool = pool;
037: this .pmf = pmf;
038: this .mapper = mapper;
039: this .jf = jf;
040: this .jfa = jfa;
041: }
042:
043: public int getPool_Of_PM_MaxSize() {
044: return pa.getMaxSize();
045: }
046:
047: public void setPool_Of_PM_MaxSize(int arg0) throws Exception {
048: pa.setMaxSize(arg0);
049: }
050:
051: public int getPool_Of_PM_MinSize() {
052: return pa.getMinSize();
053: }
054:
055: public void setPool_Of_PM_MinSize(int arg0) throws Exception {
056: pa.setMinSize(arg0);
057: }
058:
059: public long getPool_Of_PM_Timeout() {
060: return pa.getTimeout();
061: }
062:
063: public void setPool_Of_PM_Timeout(long arg0) {
064: pa.setTimeout(arg0);
065: }
066:
067: public long getPool_Of_PM_TTL() {
068: return pa.getTTL();
069: }
070:
071: public void setPool_Of_PM_TTL(long arg0) {
072: pa.setTTL(arg0);
073: }
074:
075: public int getPool_Of_PM_Current_Size() {
076: return pool.getSize();
077: }
078:
079: public int getPool_Of_PM_Current_Free_Number() {
080: return pool.getFreeResourceNumber();
081: }
082:
083: public int getPool_Of_PM_Current_Used_Number() {
084: return pool.getUsedResourceNumber();
085: }
086:
087: public boolean getTransaction_RetainValues() {
088: return pmf.getRetainValues();
089: }
090:
091: public void setTransaction_RetainValues(boolean rv) {
092: pmf.setRetainValues(rv);
093: }
094:
095: public boolean getTransaction_RestoreValues() {
096: return pmf.getRestoreValues();
097: }
098:
099: public void setTransaction_RestoreValues(boolean rv) {
100: pmf.setRestoreValues(rv);
101: }
102:
103: public boolean getTransaction_MultiThread() {
104: return pmf.getMultithreaded();
105: }
106:
107: public void setTransaction_MultiThread(boolean mt) {
108: pmf.setMultithreaded(mt);
109: }
110:
111: public boolean getIsOpen() {
112: return !pmf.isClosed();
113: }
114:
115: public String getMappingStructure() {
116: return AbstractSpeedo.getMappingStructureString(jf
117: .getMappingStructureRule());
118: }
119:
120: public boolean getDebug() {
121: return Boolean
122: .valueOf(
123: pmf.getProperties().getProperty(
124: SpeedoProperties.DEBUG)).booleanValue();
125: }
126:
127: public void setDebug(boolean d) {
128: pmf.getProperties().setProperty(SpeedoProperties.DEBUG,
129: Boolean.TRUE.toString());
130: }
131:
132: public Collection getPersistentClasseNames() {
133: return Arrays.asList(mapper.getMappedClasses());
134: }
135:
136: public void clean() {
137: try {
138: pmf.clean();
139: } catch (Exception e) {
140: e.printStackTrace();
141: }
142: }
143:
144: public Map getProperties() {
145: return jfa.getSpeedoProperties();
146: }
147:
148: public void setProperty(String name, String value) {
149: jfa.setSpeedoProperty(new String[] { name, value });
150: }
151:
152: }
|