From jbosscache-commits at lists.jboss.org Fri Jun 27 19:06:38 2008 Content-Type: multipart/mixed; boundary="===============2152579704290833135==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r6114 - in pojo/tags/2.2.0.CR5/src: test/java/org/jboss/cache/pojo/demo and 1 other directory. Date: Fri, 27 Jun 2008 19:06:38 -0400 Message-ID: --===============2152579704290833135== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: jason.greene(a)jboss.com Date: 2008-06-27 19:06:37 -0400 (Fri, 27 Jun 2008) New Revision: 6114 Added: pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/CacheModelDe= legate.java pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheGU= I.java pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheMo= delDelegate.java pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheVi= ew.java Modified: pojo/tags/2.2.0.CR5/src/main/release/build.xml pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheGUI= .java pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheMod= elDelegate.java pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheVie= w.java Log: Merge 6113 Modified: pojo/tags/2.2.0.CR5/src/main/release/build.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR5/src/main/release/build.xml 2008-06-27 23:05:26 UTC = (rev 6113) +++ pojo/tags/2.2.0.CR5/src/main/release/build.xml 2008-06-27 23:06:37 UTC = (rev 6114) @@ -147,6 +147,8 @@ + + = Copied: pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/CacheMo= delDelegate.java (from rev 6113, pojo/trunk/src/test/java/org/jboss/cache/p= ojo/demo/CacheModelDelegate.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/CacheModelD= elegate.java (rev 0) +++ pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/CacheModelD= elegate.java 2008-06-27 23:06:37 UTC (rev 6114) @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.pojo.demo; + +import org.jboss.cache.Cache; + +/** + * Delegate that hides cache model details for the demo GUI + * + * @author Galder Zamarren= o + */ +public interface CacheModelDelegate +{ + /** + * Sets the cache instance that will be used by users to interact with = the real cache via the beanshell console. + * + * @param cache either PojoCache or Cache instance + */ + void setCacheShellVariable(Object cache); + + /** + * Gets the cache instance that will be used by users to interact with = the real cache via the beanshell console. + * + * @return either PojoCache or Cache instance + */ + Object getCacheShellVariable(); + + /** + * Gets the Cache instance that the GUI will use to populate the fiels = in the GUI. + * + * @return returns an instance of Cache + */ + Cache getGenericCache(); +} Copied: pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCa= cheGUI.java (from rev 6113, pojo/trunk/src/test/java/org/jboss/cache/pojo/d= emo/JBossCacheGUI.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheG= UI.java (rev 0) +++ pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheG= UI.java 2008-06-27 23:06:37 UTC (rev 6114) @@ -0,0 +1,1237 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.pojo.demo; + +import bsh.EvalError; +import bsh.Interpreter; +import bsh.util.JConsole; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.Fqn; +import org.jboss.cache.Node; +import org.jboss.cache.lock.TimeoutException; +import org.jboss.cache.notifications.annotation.CacheListener; +import org.jboss.cache.notifications.annotation.NodeCreated; +import org.jboss.cache.notifications.annotation.NodeEvicted; +import org.jboss.cache.notifications.annotation.NodeLoaded; +import org.jboss.cache.notifications.annotation.NodeModified; +import org.jboss.cache.notifications.annotation.NodeRemoved; +import org.jboss.cache.notifications.annotation.ViewChanged; +import org.jboss.cache.notifications.event.NodeEvent; +import org.jboss.cache.notifications.event.NodeModifiedEvent; +import org.jboss.cache.notifications.event.ViewChangedEvent; +import org.jboss.cache.util.CachePrinter; +import org.jgroups.Address; + +import javax.swing.*; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.Vector; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; + +/** + * JBossCache GUI for the demo + * + * @author Manik Surtani (manik(a)jbo= ss.org) + * @author Galder Zamarren= o + */ +(a)CacheListener +public class JBossCacheGUI extends JFrame implements WindowListener, TreeS= electionListener, TableModelListener +{ + private static final long serialVersionUID =3D -1242167331988194987L; + + private transient CacheModelDelegate cacheModelDelegate; + private transient Cache cache; + private DefaultTreeModel tree_model =3D null; + private transient Log log =3D LogFactory.getLog(getClass()); + private JTree jtree =3D null; + private DefaultTableModel tableModel =3D new DefaultTableModel(); + private JTable table =3D new JTable(tableModel); + private JBossCacheGUI.DisplayNode myNodeRoot =3D new JBossCacheGUI.Disp= layNode(Fqn.SEPARATOR); + private transient Node root; + private transient Node selected_node =3D null; + private JPanel tablePanel =3D null; + private JPopupMenu operationsPopup =3D null, dataModificationsPopup =3D= null; + private static final int KEY_COL_WIDTH =3D 20; + private static final int VAL_COL_WIDTH =3D 300; + private TransactionManager tx_mgr =3D null; + private transient Transaction tx =3D null; + private JPanel mainPanel; + private List
membership =3D new LinkedList
(); + private Address coordinator =3D null; + private boolean useConsole =3D false; + JConsole bshConsole; + + /** + * Run any work that happens in this interface in a separate thread. T= his is good practise. Unless there's a + * resource-managemenet requirement, such as in an application server, = newCachedThreadPool is a good option as it + * provides better queuing performance. + */ + private transient Executor executor; + + public JBossCacheGUI(CacheModelDelegate cacheDelegate, boolean useConso= le) throws Exception + { + executor =3D Executors.newCachedThreadPool(); + + addNotify(); + this.useConsole =3D useConsole; + tree_model =3D new DefaultTreeModel(new JBossCacheGUI.DisplayNode(Fq= n.ROOT.toString())); + jtree =3D new JTree(tree_model); + jtree.setDoubleBuffered(true); + jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE= _TREE_SELECTION); + + JScrollPane scroll_pane =3D new JScrollPane(jtree); + mainPanel =3D new JPanel(); + mainPanel.setLayout(new BorderLayout()); + mainPanel.add(scroll_pane, BorderLayout.CENTER); + + addWindowListener(this); + + tableModel.setColumnIdentifiers(new String[]{"Name", "Value"}); + tableModel.addTableModelListener(this); + + // add a mouse listener to the table model for delete and insert ro= ws. + MouseListener dataMouseListener =3D new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + if (rightClick(e.getModifiers())) + { + dataModificationsPopup.show(e.getComponent(), e.getX(), e.g= etY()); + } + } + }; + + setTableColumnWidths(); + + tablePanel =3D new JPanel(); + tablePanel.setLayout(new BorderLayout()); + tablePanel.add(table.getTableHeader(), BorderLayout.NORTH); + tablePanel.add(table, BorderLayout.CENTER); + + table.addMouseListener(dataMouseListener); + + mainPanel.add(tablePanel, BorderLayout.SOUTH); + JSplitPane contentPanel =3D null; + if (useConsole) + { + String welcomeMessage =3D getWelcomeMessage(); + + bshConsole =3D new JConsole(); + Interpreter interpreter =3D new Interpreter(bshConsole); + + configureInterpreter(interpreter, cacheDelegate); + + interpreter.println(welcomeMessage); + interpreter.setShowResults(!interpreter.getShowResults());// show= () in beanShell + System.setOut(bshConsole.getOut()); + System.setErr(bshConsole.getErr()); + Thread t =3D new Thread(interpreter); + t.start(); + + contentPanel =3D new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainPa= nel, bshConsole); + getContentPane().add(contentPanel); + } + else + { + getContentPane().add(mainPanel); + } + + jtree.addTreeSelectionListener(this);// REVISIT + + MouseListener ml =3D new MouseAdapter() + { + public void mouseClicked(final MouseEvent e) + { + if (log.isTraceEnabled()) + { + log.trace("clicked GUI"); + } + + final int selRow =3D jtree.getRowForLocation(e.getX(), e.getY(= )); + final TreePath selPath =3D jtree.getPathForLocation(e.getX(), = e.getY()); + if (selRow !=3D -1) + { + if (log.isTraceEnabled()) + { + log.trace("clicked on node in GUI"); + } + + Runnable r =3D new Runnable() + { + public void run() + { + try + { + selected_node =3D getNode(selPath.getPath()); + jtree.setSelectionPath(selPath); + + if (rightClick(e.getModifiers())) + { + operationsPopup.show(e.getComponent(), e.getX()= , e.getY()); + } + } + catch (TimeoutException te) + { + String message =3D "Unable to update GUI due to a = timeout trying to acquire lock on a node." + + "This might be due to clicking on a node whi= ch is currently locked by an ongoing " + + "transaction: "; + printAndLogStacktrace(message, te); + } + catch (Exception e) + { + printAndLogStacktrace("Updating GUI failed: ", e); + } + } + }; + executor.execute(r); + } + } + }; + + jtree.addMouseListener(ml); + + createMenus(); + setLocation(50, 50); + setSize(getInsets().left + getInsets().right + 800, getInsets().top = + getInsets().bottom + 800); + + // make sure we set the cache BEFORE initialising this!! + setCacheModelDelegate(cacheDelegate); + init(); + setVisible(true); + tree_model.setRoot(myNodeRoot); + tree_model.reload(); + + if (useConsole) + { + //has to be called after setVisible() otherwise no effect + contentPanel.setDividerLocation(0.65); + } + } + + public void setCacheModelDelegate(final CacheModelDelegate cacheModelDe= legate) + { + this.cacheModelDelegate =3D cacheModelDelegate; + if (this.cacheModelDelegate !=3D null) + { + this.cache =3D this.cacheModelDelegate.getGenericCache(); + Runtime.getRuntime().addShutdownHook( + new Thread() + { + public void run() + { + cache.stop(); + } + }); + + cache.addCacheListener(this); + root =3D cache.getRoot(); + setTitle("JBoss Cache GUI: Local Address=3D" + getLocalAddress()); + tx_mgr =3D cache.getConfiguration().getRuntimeConfig().getTransac= tionManager(); + populateTree(); + } + else + { + setTitle("Cache undefined"); + if (tree_model !=3D null) + { + myNodeRoot =3D new JBossCacheGUI.DisplayNode(Fqn.SEPARATOR); + tree_model.setRoot(myNodeRoot); + tree_model.reload(); + + } + if (tableModel !=3D null) + { + clearTable(); + } + } + } + + /** + * Checks whether a click event is considered a "right-click" + * + * @param modifiers mouse event mods + * @return true if deemed a right click + */ + private boolean rightClick(int modifiers) + { + // the simple right click case + if (modifiers =3D=3D InputEvent.BUTTON3_MASK) return true; + // more complex on Mac OS X where a ctrl-click is deemed the same as= a right click + return modifiers =3D=3D InputEvent.BUTTON1_MASK + InputEvent.CTRL_MA= SK; + } + + public void windowClosed(WindowEvent event) + { + } + + public void windowDeiconified(WindowEvent event) + { + } + + public void windowIconified(WindowEvent event) + { + } + + public void windowActivated(WindowEvent event) + { + } + + public void windowDeactivated(WindowEvent event) + { + } + + public void windowOpened(WindowEvent event) + { + } + + public void windowClosing(WindowEvent event) + { + stopGui(); + } + + + public void tableChanged(TableModelEvent evt) + { + if (log.isTraceEnabled()) + { + log.trace("table contents changed, event type is: " + evt.getType= ()); + } + + int row, col; + String key, val; + + if (evt.getType() =3D=3D TableModelEvent.UPDATE) + { + row =3D evt.getFirstRow(); + col =3D evt.getColumn(); + + key =3D (String) tableModel.getValueAt(row, col =3D=3D 0 ? 0 : co= l - 1); + val =3D (String) tableModel.getValueAt(row, col =3D=3D 0 ? 1 : co= l); + + if (key !=3D null && val !=3D null && !isPlaceHolder(key) && !isP= laceHolder(val)) + { + try + { + if (log.isTraceEnabled()) + { + log.trace("updating node: " + selected_node + " with new= values [k=3D" + key + ",v=3D" + val + "]"); + } + + selected_node.put(key, val); + Map data =3D selected_node.getData(); + populateTable(data); + } + catch (Exception e) + { + printAndLogStacktrace("Changing table failed: ", e); + } + } + } + } + + + public void valueChanged(final TreeSelectionEvent evt) + { + if (log.isTraceEnabled()) + { + log.trace("node was selected in GUI: " + evt.getPath()); + } + + Runnable r =3D new Runnable() + { + public void run() + { + try + { + Map data; + selected_node =3D getNode(evt.getPath().getPath()); + if (selected_node !=3D null) + { + data =3D selected_node.getData(); + if (data !=3D null) + { + mainPanel.add(tablePanel, BorderLayout.SOUTH); + populateTable(data); + validate(); + } + else + { + clearTable(); + mainPanel.remove(tablePanel); + validate(); + } + } + } + catch (TimeoutException te) + { + String message =3D "Unable to update GUI due to a timeout t= rying to acquire lock on a node." + + "This might be due to clicking on a node which is cur= rently locked by an ongoing " + + "transaction: "; + printAndLogStacktrace(message, te); + } + catch (Exception e) + { + printAndLogStacktrace("Updating GUI failed: ", e); + } + } + }; + executor.execute(r); + } + + protected DefaultTableModel getTableModel() + { + return tableModel; + } + + protected String getWelcomeMessage() + { + return "Welcome to the BeanShell console.\n\n" + + "This console gives you a direct shell interface to the GUI ab= ove and allows you to manipulate the cache directly. " + + "Some of the variables initialised in this shell session are:\= n\n" + + "// an instance of org.jboss.cache\n" + + " Cache cache;\n" + + "// a reference to the root node\n" + + " Node root;\n" + + "// the transaction manager registered with the cache\n" + + " TransactionManager transactionManager;\n"; + } + + protected void configureInterpreter(Interpreter interpreter, CacheModel= Delegate cacheDelegate) throws EvalError + { + interpreter.getNameSpace().importPackage("org.jboss.cache"); + interpreter.getNameSpace().importPackage("org.jboss.cache.transactio= n"); + interpreter.set("cache", cacheDelegate.getGenericCache()); + interpreter.set("root", cacheDelegate.getGenericCache().getRoot()); + interpreter.set("transactionManager", cacheDelegate.getGenericCache(= ).getConfiguration().getRuntimeConfig().getTransactionManager()); + } + + /* ------------------ CacheListener interface ------------ */ + + @NodeCreated + @NodeLoaded + public void nodeCreated(NodeEvent e) + { + /* Updating the GUI upon node creation should be done sequentially t= o avoid concurrency issues when + adding multiple nodes at the same time, for example for PojoCache, w= here attaching a pojo creates several nodes. + Creating several visual nodes in paralell and trying to scroll to th= em is not a thread safe operation */ + if (e.isPre()) + { + JBossCacheGUI.DisplayNode n; + + n =3D myNodeRoot.add(e.getFqn()); + if (n !=3D null) + { + tree_model.setRoot(myNodeRoot); + tree_model.reload(); + jtree.scrollPathToVisible(new TreePath(n.getPath())); + } + } + } + + @NodeModified + public void nodeModified(final NodeModifiedEvent e) + { + Runnable r =3D new Runnable() + { + public void run() + { + if (e.isPre() && selected_node !=3D null && selected_node.getF= qn().equals(e.getFqn()))//&& !isLocal) + { + clearTable(); + Node n =3D root.getChild(e.getFqn()); + if (n !=3D null) + { + populateTable(n.getData()); + } + } + } + }; + executor.execute(r); + } + + @NodeRemoved + @NodeEvicted + public void nodeRemoved(final NodeEvent e) + { + if (log.isTraceEnabled()) + { + log.trace("node removed, updating GUI"); + } + + Runnable r =3D new Runnable() + { + public void run() + { + if (e.isPre()) + { + JBossCacheGUI.DisplayNode n; + + n =3D myNodeRoot.findNode(e.getFqn()); + if (n !=3D null) + { + n.removeAllChildren(); + n.removeFromParent(); + tree_model.setRoot(myNodeRoot); + tree_model.reload(); + } + } + } + }; + executor.execute(r); + } + + @ViewChanged + public void viewChange(final ViewChangedEvent e) + { + Runnable r =3D new Runnable() + { + public void run() + { + List
mbrship; + if (e.getNewView() !=3D null && (mbrship =3D e.getNewView().ge= tMembers()) !=3D null) + { + membership.clear(); + membership.addAll(mbrship); + coordinator =3D mbrship.get(0); + } + } + }; + executor.execute(r); + } + + /* ---------------- End of CacheListener interface -------- */ + + /*----------------- Runnable implementation to make View change calles = in AWT Thread ---*/ + + public void run() + { + + } + + /* ----------------------------- Private Methods ----------------------= ------------ */ + + /** + * Fetches all data from underlying cache model and display it graphica= lly + */ + private void init() + { + List
mbrship; + + mbrship =3D getMembers(); + if (mbrship !=3D null && mbrship.size() > 0) + { + membership.clear(); + membership.addAll(mbrship); + coordinator =3D mbrship.get(0); + } + } + + + /** + * Fetches all data from underlying cache model and display it graphica= lly + */ + private void populateTree() + { + addGuiNode(Fqn.ROOT); + } + + + /** + * Recursively adds GUI nodes starting from fqn + */ + private void addGuiNode(Fqn fqn) + { + Set children; + + if (fqn =3D=3D null) return; + + // 1 . Add myself + myNodeRoot.add(fqn); + + // 2. Then add my children + children =3D cache.getRoot().getChild(fqn).getChildrenNames(); + if (children !=3D null) + { + for (Object child_name : children) + { + addGuiNode(Fqn.fromRelativeElements(fqn, (String) child_name)); + } + } + } + + + private Node getNode(Object[] path) + { + Fqn fqnToPath; + if (path.length =3D=3D 0) fqnToPath =3D Fqn.ROOT; + List elements =3D convertMyNodeArrayToStringArray(path); + fqnToPath =3D Fqn.fromList(elements); + if (root.hasChild(fqnToPath)) + { + return root.getChild(fqnToPath); + } + else + { + /* No implicit creation, otherwise removing GUI selected nodes wi= ll be recreated */ + return null; + } + } + + private List convertMyNodeArrayToStringArray(Object[] path) + { + List list =3D new LinkedList(); + for (Object o : path) + { + JBossCacheGUI.DisplayNode n =3D (JBossCacheGUI.DisplayNode) o; + if (!n.name.equals(Fqn.SEPARATOR)) list.add(n.name); + } + return list; + } + + protected void clearTable() + { + int num_rows =3D table.getRowCount(); + + if (num_rows > 0) + { + for (int i =3D 0; i < num_rows; i++) + { + tableModel.removeRow(0); + } + tableModel.fireTableRowsDeleted(0, num_rows - 1); + repaint(); + } + } + + + protected void populateTable(Map data) + { + String key; + String val; + int num_rows; + clearTable(); + if (data =3D=3D null) return; + num_rows =3D data.size(); + + if (num_rows > 0) + { + // sort this according to the natural sort order of keys + TreeMap sortedMap =3D new TreeMap= (data); + + for (Map.Entry entry : sortedMap.entrySet()) + { + key =3D entry.getKey(); + val =3D entry.getValue(); + tableModel.addRow(new Object[]{key, val}); + } + tableModel.fireTableRowsInserted(0, num_rows - 1); + validate(); + } + } + + private void setTableColumnWidths() + { + table.sizeColumnsToFit(JTable.AUTO_RESIZE_NEXT_COLUMN); + TableColumn column; + column =3D table.getColumnModel().getColumn(0); + column.setMinWidth(KEY_COL_WIDTH); + column.setPreferredWidth(KEY_COL_WIDTH); + column =3D table.getColumnModel().getColumn(1); + column.setPreferredWidth(VAL_COL_WIDTH); + } + + private void createMenus() + { + JMenuBar menubar =3D new JMenuBar(); + JMenu operationsMenu =3D new JMenu("Operations"); + JBossCacheGUI.AddNodeAction addNode =3D new JBossCacheGUI.AddNodeAct= ion(); + addNode.putValue(AbstractAction.NAME, "Add to this node"); + JBossCacheGUI.LoadAction load_action =3D new JBossCacheGUI.LoadActio= n(); + load_action.putValue(AbstractAction.NAME, "Load from the CacheLoader= "); + JBossCacheGUI.RemoveNodeAction removeNode =3D new JBossCacheGUI.Remo= veNodeAction(); + removeNode.putValue(AbstractAction.NAME, "Remove this node"); + JBossCacheGUI.EvictAction evict_action =3D new JBossCacheGUI.EvictAc= tion(); + evict_action.putValue(AbstractAction.NAME, "Evict from the Cache"); + JBossCacheGUI.AddModifyDataForNodeAction addModAction =3D new JBossC= acheGUI.AddModifyDataForNodeAction(); + addModAction.putValue(AbstractAction.NAME, "Add/Modify data"); + JBossCacheGUI.PrintLockInfoAction print_locks =3D new JBossCacheGUI.= PrintLockInfoAction(); + print_locks.putValue(AbstractAction.NAME, "Print lock information" += (useConsole ? "" : " (stdout)")); + JBossCacheGUI.ExitAction exitAction =3D new JBossCacheGUI.ExitAction= (); + exitAction.putValue(AbstractAction.NAME, "Exit"); + JBossCacheGUI.StartTransaction start_tx =3D new JBossCacheGUI.StartT= ransaction(); + start_tx.putValue(AbstractAction.NAME, "Start TX"); + JBossCacheGUI.CommitTransaction commit_tx =3D new JBossCacheGUI.Comm= itTransaction(); + commit_tx.putValue(AbstractAction.NAME, "Commit TX"); + JBossCacheGUI.RollbackTransaction rollback_tx =3D new JBossCacheGUI.= RollbackTransaction(); + rollback_tx.putValue(AbstractAction.NAME, "Rollback TX"); + + operationsMenu.add(addNode); + operationsMenu.add(load_action); + operationsMenu.add(removeNode); + operationsMenu.add(evict_action); + operationsMenu.add(addModAction); + operationsMenu.add(print_locks); + operationsMenu.add(start_tx); + operationsMenu.add(commit_tx); + operationsMenu.add(rollback_tx); + operationsMenu.add(exitAction); + menubar.add(operationsMenu); + setJMenuBar(menubar); + + operationsPopup =3D new JPopupMenu(); + operationsPopup.add(addNode); + operationsPopup.add(load_action); + operationsPopup.add(evict_action); + operationsPopup.add(removeNode); + operationsPopup.add(addModAction); + + JBossCacheGUI.InsertRowAction insertRow =3D new JBossCacheGUI.Insert= RowAction(); + insertRow.putValue(AbstractAction.NAME, "Insert New Row"); + JBossCacheGUI.RemoveLastRowAction removeLastRow =3D new JBossCacheGU= I.RemoveLastRowAction(); + removeLastRow.putValue(AbstractAction.NAME, "Remove Last Row"); + + dataModificationsPopup =3D new JPopupMenu(); + dataModificationsPopup.add(insertRow); + dataModificationsPopup.add(removeLastRow); + } + + private Object getLocalAddress() + { + try + { + return cache.getLocalAddress(); + } + catch (Throwable t) + { + log.error("JBossCacheGUI.getLocalAddress(): ", t); + return null; + } + } + + private void load(Fqn fqn) + { + try + { + // this will cause the cache to load the relevant node from a cac= he loader. + cache.getRoot().getChild(fqn); + } + catch (Throwable t) + { + log.error("JBossCacheGUI.load(): " + t); + } + } + + private List
getMembers() + { + try + { + return new ArrayList
(cache.getMembers()); + } + catch (Throwable t) + { + log.error("TreeCacheGui.getMembers(): ", t); + return null; + } + } + + private String[] getRowPlaceHolderData() + { + Collection keys =3D extractKeys(tableModel.getDataVector()); + // try all place holders + + int count =3D 0; + String placeHolderKey =3D "{ --- Add Key --- }"; + while (keys.contains(placeHolderKey)) + { + count++; + placeHolderKey =3D "{ --- Add Key " + count + " --- }"; + } + + String placeHolderValue =3D "{ --- Add Value " + (count =3D=3D 0 ? "= " : count) + " --- }"; + return new String[]{placeHolderKey, placeHolderValue}; + } + + private boolean isPlaceHolder(String s) + { + if (s.startsWith("{ --- Add Key ") && s.endsWith(" --- }")) return t= rue; + if (s.startsWith("{ --- Add Value ") && s.endsWith(" --- }")) return= true; + return false; + } + + private Collection extractKeys(Vector v) + { + // very odd data structure. Entire table is represented as a Vector= . Each row (element in the Vector) is a Vector of 2 elements (key and valu= e) + List l =3D new LinkedList(); + for (Vector row : v) + { + // just add keys + l.add(row.get(0)); + } + return l; + } + + private void printAndLogStacktrace(String message, Throwable t) + { + t.printStackTrace(); + log.error(message, t); + } + + /* -------------------------- End of Private Methods ------------------= ------------ */ + + /*----------------------- Actions ---------------------------*/ + + class ExitAction extends AbstractAction + { + private static final long serialVersionUID =3D -5364163916172148038L; + + public void actionPerformed(ActionEvent e) + { + stopGui(); + } + } + + + void stopGui() + { + if (cache !=3D null) + { + try + { + cache.stop(); + cache.destroy(); + cache =3D null; + } + catch (Throwable t) + { + printAndLogStacktrace("Stopping and destroying cache failed: "= , t); + } + } + dispose(); + System.exit(0); + } + + + class InsertRowAction extends AbstractAction + { + private static final long serialVersionUID =3D 7084928639244438800L; + + public void actionPerformed(ActionEvent e) + { + tableModel.addRow(getRowPlaceHolderData()); + } + } + + class RemoveLastRowAction extends AbstractAction + { + private static final long serialVersionUID =3D 7084928639244438800L; + + public void actionPerformed(ActionEvent e) + { + int lastRow =3D tableModel.getRowCount() - 1; + if (lastRow > -1) + { + String keyToRemove =3D (String) tableModel.getValueAt(lastRow,= 0); + tableModel.removeRow(lastRow); + selected_node.remove(keyToRemove); + } + } + } + + + class AddNodeAction extends AbstractAction + { + private static final long serialVersionUID =3D 7084928639244438800L; + + public void actionPerformed(ActionEvent e) + { + JTextField fqnTextField =3D new JTextField(); + if (selected_node !=3D null) + { + fqnTextField.setText(selected_node.getFqn().toString()); + } + else + { + fqnTextField.setText(Fqn.SEPARATOR); + } + Object[] information =3D {"Enter fully qualified name", + fqnTextField}; + final String btnString1 =3D "OK"; + final String btnString2 =3D "Cancel"; + Object[] options =3D {btnString1, btnString2}; + int userChoice =3D JOptionPane.showOptionDialog(null, + information, + "Add DataNode", + JOptionPane.YES_NO_OPTION, + JOptionPane.PLAIN_MESSAGE, + null, + options, + options[0]); + if (userChoice =3D=3D 0) + { + String userInput =3D fqnTextField.getText(); + cache.put(Fqn.fromString(userInput), null); + } + } + } + + class LoadAction extends AbstractAction + { + private static final long serialVersionUID =3D -6998760732995584428L; + + public void actionPerformed(ActionEvent e) + { + JTextField fqnTextField =3D new JTextField(); + if (selected_node !=3D null) + { + fqnTextField.setText(selected_node.getFqn().toString()); + } + else + { + fqnTextField.setText(Fqn.SEPARATOR); + } + + Object[] information =3D {"Enter fully qualified name", + fqnTextField}; + final String btnString1 =3D "OK"; + final String btnString2 =3D "Cancel"; + Object[] options =3D {btnString1, btnString2}; + int userChoice =3D JOptionPane.showOptionDialog(null, + information, + "Load DataNode", + JOptionPane.YES_NO_OPTION, + JOptionPane.PLAIN_MESSAGE, + null, + options, + options[0]); + if (userChoice =3D=3D 0) + { + String userInput =3D fqnTextField.getText(); + load(Fqn.fromString(userInput)); + } + } + } + + class EvictAction extends AbstractAction + { + private static final long serialVersionUID =3D 6007500908549034215L; + + public void actionPerformed(ActionEvent e) + { + JTextField fqnTextField =3D new JTextField(); + if (selected_node !=3D null) + { + fqnTextField.setText(selected_node.getFqn().toString()); + } + else + { + fqnTextField.setText(Fqn.SEPARATOR); + } + Object[] information =3D {"Enter fully qualified name", + fqnTextField}; + final String btnString1 =3D "OK"; + final String btnString2 =3D "Cancel"; + Object[] options =3D {btnString1, btnString2}; + int userChoice =3D JOptionPane.showOptionDialog(null, + information, + "Evict DataNode", + JOptionPane.YES_NO_OPTION, + JOptionPane.PLAIN_MESSAGE, + null, + options, + options[0]); + if (userChoice =3D=3D 0) + { + String userInput =3D fqnTextField.getText(); + cache.evict(Fqn.fromString(userInput), true); + } + } + } + + + class StartTransaction extends AbstractAction + { + private static final long serialVersionUID =3D 7059131008813144857L; + + public void actionPerformed(ActionEvent e) + { + if (tx_mgr =3D=3D null) + { + log.error("no TransactionManager specified"); + return; + } + if (tx !=3D null) + { + log.error("transaction is already running: " + tx); + return; + } + try + { + tx_mgr.begin(); + tx =3D tx_mgr.getTransaction(); + } + catch (Throwable t) + { + printAndLogStacktrace("Creating transaction failed: ", t); + } + } + } + + class CommitTransaction extends AbstractAction + { + private static final long serialVersionUID =3D 5426108920883879873L; + + public void actionPerformed(ActionEvent e) + { + if (tx =3D=3D null) + { + log.error("transaction is not running"); + return; + } + try + { + tx.commit(); + } + catch (Throwable t) + { + printAndLogStacktrace("Commiting transaction failed: ", t); + } + finally + { + tx =3D null; + } + } + } + + class RollbackTransaction extends AbstractAction + { + private static final long serialVersionUID =3D -4836748411400541430L; + + public void actionPerformed(ActionEvent e) + { + if (tx =3D=3D null) + { + log.error("transaction is not running"); + return; + } + try + { + tx.rollback(); + } + catch (Throwable t) + { + printAndLogStacktrace("Transaction rollback failed: ", t); + } + finally + { + tx =3D null; + } + } + } + + class PrintLockInfoAction extends AbstractAction + { + private static final long serialVersionUID =3D -2171307516592250436L; + + public void actionPerformed(ActionEvent e) + { + if (bshConsole !=3D null) + { + new Thread() + { + public void run() + { + bshConsole.getOut().println("\n*** lock information ****= \n" + CachePrinter.printCacheLockingInfo(cache)); + } + }.start(); + + } + else + { + new Thread() + { + public void run() + { + System.out.println("\n*** lock information ****\n" + Cac= hePrinter.printCacheLockingInfo(cache)); + } + }.start(); + } + } + } + + class RemoveNodeAction extends AbstractAction + { + private static final long serialVersionUID =3D 3746013603940497991L; + + public void actionPerformed(ActionEvent e) + { + try + { + cache.removeNode(selected_node.getFqn()); + } + catch (Throwable t) + { + log.error("RemoveNodeAction.actionPerformed(): " + t); + } + } + } + + class AddModifyDataForNodeAction extends AbstractAction + { + private static final long serialVersionUID =3D -7656592171312920825L; + + public void actionPerformed(ActionEvent e) + { + if (log.isTraceEnabled()) + { + log.trace("node added/modified, updating GUI: " + e); + } + if (selected_node =3D=3D null) return; + + clearTable(); + Map data =3D selected_node.getData(); + if (data =3D=3D null || data.isEmpty()) + { + data =3D new HashMap(); + String[] placeHolder =3D getRowPlaceHolderData(); + data.put(placeHolder[0], placeHolder[1]); + } + + populateTable(data); + + mainPanel.add(tablePanel, BorderLayout.SOUTH); + validate(); + } + } + + + class DisplayNode extends DefaultMutableTreeNode + { + private static final long serialVersionUID =3D 4882445905140460053L; + String name =3D ""; + + + DisplayNode(String name) + { + this.name =3D name; + } + + + /** + * Adds a new node to the view. Intermediary nodes will be created i= f they don't yet exist. + * Returns the first node that was created or null if node already e= xisted + */ + public JBossCacheGUI.DisplayNode add(Fqn fqn) + { + JBossCacheGUI.DisplayNode curr, n, ret =3D null; + + if (fqn =3D=3D null) return null; + curr =3D this; + + for (String child_name : fqn.peekElements()) + { + n =3D curr.findChild(child_name); + if (n =3D=3D null) + { + n =3D new JBossCacheGUI.DisplayNode(child_name); + if (ret =3D=3D null) ret =3D n; + curr.add(n); + } + curr =3D n; + } + return ret; + } + + + /** + * Removes a node from the view. Child nodes will be removed as well + */ + public void remove() + { + removeFromParent(); + } + + + private JBossCacheGUI.DisplayNode findNode(Fqn fqn) + { + JBossCacheGUI.DisplayNode curr, n; + + if (fqn =3D=3D null) return null; + curr =3D this; + + for (String child_name : fqn.peekElements()) + { + n =3D curr.findChild(child_name); + if (n =3D=3D null) + { + return null; + } + curr =3D n; + } + return curr; + } + + + private JBossCacheGUI.DisplayNode findChild(String relative_name) + { + JBossCacheGUI.DisplayNode child; + + if (relative_name =3D=3D null || getChildCount() =3D=3D 0) + { + return null; + } + for (int i =3D 0; i < getChildCount(); i++) + { + child =3D (JBossCacheGUI.DisplayNode) getChildAt(i); + if (child.name =3D=3D null) + { + continue; + } + + if (child.name.equals(relative_name)) + { + return child; + } + } + return null; + } + + public String toString() + { + return name; + } + + } +} Copied: pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCa= cheModelDelegate.java (from rev 6113, pojo/trunk/src/test/java/org/jboss/ca= che/pojo/demo/JBossCacheModelDelegate.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheM= odelDelegate.java (rev 0) +++ pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheM= odelDelegate.java 2008-06-27 23:06:37 UTC (rev 6114) @@ -0,0 +1,34 @@ +/* + * JBoss, Home of Professional Open Source + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.cache.pojo.demo; + +import org.jboss.cache.Cache; + +/** + * Model delegate implementation for JBossCache demo + * + * @author Galder Zamarren= o + */ +public class JBossCacheModelDelegate implements CacheModelDelegate +{ + private Cache cache; + + public void setCacheShellVariable(Object cache) + { + this.cache =3D (Cache) cache; + } + + public Object getCacheShellVariable() + { + return cache; + } + + public Cache getGenericCache() + { + return cache; + } +} Copied: pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCa= cheView.java (from rev 6113, pojo/trunk/src/test/java/org/jboss/cache/pojo/= demo/JBossCacheView.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheV= iew.java (rev 0) +++ pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/JBossCacheV= iew.java 2008-06-27 23:06:37 UTC (rev 6114) @@ -0,0 +1,214 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + * Created on March 25 2003 + */ +package org.jboss.cache.pojo.demo; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jboss.cache.Cache; +import org.jboss.cache.CacheFactory; +import org.jboss.cache.DefaultCacheFactory; + + +/** + * Graphical view of a JBoss Cache instance. Think of it as a view in an = MVC model. An instance of this view + * needs to be given a reference to the model ({@link CacheModelDelegate}= ) and needs to registers as a + * {@link org.jboss.cache.CacheListener}. Changes to the cache structure a= re propagated from the model to the + * view (via the CacheListener interface), changes from the GUI (e.g. by a= user) are executed on the cache model + * which will delegate on the actual Cache instance (which, if clustered, = will broadcast the changes to all replicas). + *

+ * The view itself maintains references to the nodes, but doesn't cache an= y of the data associated with the nodes. When + * data needs to be displayed, the underlying cache will be accessed direc= tly. + * + * @author Manik Surtani + * @author Galder Zamarren= o + * @version $Revision: 5764 $ + */ +public class JBossCacheView +{ + private static Log log =3D LogFactory.getLog(JBossCacheView.class.getNa= me()); + + /** + * A reference to the Swing GUI that displays contents to the user. + */ + private JBossCacheGUI gui =3D null; + + /** + * Whether or not to use the embedded BeanShell console. + */ + private boolean useConsole =3D false; + + /** + * Cache configuration file. + */ + private String configurationFile =3D null; + + /** + * The cache model. + */ + private CacheModelDelegate cacheModelDelegate; + + /** + * Gets the configuration file + * + * @return String containing the path to the configuration file + */ + public String getConfigurationFile() + { + return configurationFile; + } + + /** + * Sets a reference to the cache model + * + * @param cacheModelDelegate cache model instance to associate with thi= s view + */ + public void setCacheModelDelegate(CacheModelDelegate cacheModelDelegate) + { + this.cacheModelDelegate =3D cacheModelDelegate; + if (gui !=3D null) gui.setCacheModelDelegate(cacheModelDelegate); + } + + /** + * Main code for the view + * + * @param args arguments passed via command line + * @throws Exception if there's any issues starting the cache demo + */ + public void doMain(String[] args) throws Exception + { + parseParameters(args); + + if (configurationFile =3D=3D null) + { + help(); + throw new Exception("Configuration file cannot be null, please sp= ecify with the -config parameter when starting!"); + } + + CacheModelDelegate cacheModelDelegate =3D createCacheDelegate(); + cacheModelDelegate.getGenericCache().start(); + setCacheModelDelegate(cacheModelDelegate); + start(); + } + + /** + * Starts the view + * + * @throws Exception + */ + public void start() throws Exception + { + if (gui =3D=3D null) + { + log.info("start(): creating the GUI"); + System.out.println("start(): creating the GUI"); + gui =3D createGUI(cacheModelDelegate, useConsole); + } + } + + protected JBossCacheGUI createGUI(CacheModelDelegate delegate, boolean = useConsole) throws Exception + { + return new JBossCacheGUI(cacheModelDelegate, useConsole); + } + + /** + * Stops the view + */ + public void stop() + { + if (gui !=3D null) + { + log.info("stop(): disposing the GUI"); + gui.stopGui(); + gui =3D null; + } + } + + /** + * Starts the view + * + * @param args valid arguments are: -console to enable using the embedd= ed beanShell console, -config [path/to/config/file] to specify a config fil= e. + */ + public static void main(String args[]) + { + try + { + JBossCacheView view =3D new JBossCacheView(); + view.doMain(args); + } + catch (Exception ex) + { + log.error("Cannot start up!!", ex); + } + } + + /** + * Parses the parameters + * + * @param args arguments passed via command line + */ + protected void parseParameters(String[] args) + { + for (int i =3D 0; i < args.length; i++) + { + if (args[i].equals("-console")) + { + useConsole =3D true; + continue; + } + if (args[i].equals("-config")) + { + configurationFile =3D args[++i]; + continue; + } + help(); + return; + } + } + + /** + * Factory method that creates the cache model delegate instance for th= is demo + * + * @return instance of CacheModelDelegate + * @throws Exception + */ + protected CacheModelDelegate createCacheDelegate() throws Exception + { + CacheFactory factory =3D new DefaultCacheFactory(); + Cache cache =3D factory.createCache(configurationFil= e, false); + CacheModelDelegate delegate =3D new JBossCacheModelDelegate(); + delegate.setCacheShellVariable(cache); + + return delegate; + } + + private static void help() + { + System.out.println("JBossCacheView [-help] " + + "[-console] " + + "[-config ]"); + + System.out.println(); + System.out.println("-console enables the embedded BeanShell console"= ); + System.out.println("-config allows you to provide a path to the conf= iguration file to use."); + System.out.println(); + System.out.println(); + } +} + + + + + + + + + + + + Modified: pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoC= acheGUI.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheGU= I.java 2008-06-27 23:05:26 UTC (rev 6113) +++ pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheGU= I.java 2008-06-27 23:06:37 UTC (rev 6114) @@ -2,8 +2,6 @@ = import bsh.EvalError; import bsh.Interpreter; -import org.jboss.cache.demo.CacheModelDelegate; -import org.jboss.cache.demo.JBossCacheGUI; import org.jboss.cache.notifications.annotation.CacheListener; = import java.util.Map; Modified: pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoC= acheModelDelegate.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheMo= delDelegate.java 2008-06-27 23:05:26 UTC (rev 6113) +++ pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheMo= delDelegate.java 2008-06-27 23:06:37 UTC (rev 6114) @@ -1,7 +1,6 @@ package org.jboss.cache.pojo.demo; = import org.jboss.cache.Cache; -import org.jboss.cache.demo.CacheModelDelegate; import org.jboss.cache.pojo.PojoCache; = /** Modified: pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoC= acheView.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheVi= ew.java 2008-06-27 23:05:26 UTC (rev 6113) +++ pojo/tags/2.2.0.CR5/src/test/java/org/jboss/cache/pojo/demo/PojoCacheVi= ew.java 2008-06-27 23:06:37 UTC (rev 6114) @@ -2,8 +2,6 @@ = import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jboss.cache.demo.CacheModelDelegate; -import org.jboss.cache.demo.JBossCacheView; import org.jboss.cache.pojo.PojoCache; import org.jboss.cache.pojo.PojoCacheFactory; = @@ -20,14 +18,18 @@ protected CacheModelDelegate createCacheDelegate() throws Exception { PojoCache pojoCache =3D PojoCacheFactory.createCache(getConfiguratio= nFile(), false); - pojoCache.getCache().getConfiguration().setFetchInMemoryState(false); - CacheModelDelegate delegate =3D new PojoCacheModelDelegate(); delegate.setCacheShellVariable(pojoCache); = return delegate; } = + @Override + protected JBossCacheGUI createGUI(CacheModelDelegate delegate, boolean = useConsole) throws Exception + { + return new PojoCacheGUI(delegate, useConsole); + } + public static void main(String args[]) { try --===============2152579704290833135==--