[Mc4j-cvs] mc4j/src/org/mc4j/console/dashboard/match BeanObjectNameRegexCondition.java,1.1,1.2 Match
Brought to you by:
ghinkl
From: Greg H. <gh...@us...> - 2006-04-12 19:14:38
|
Update of /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/match In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20162/src/org/mc4j/console/dashboard/match Modified Files: MatchExecutor.java DashboardMatch.java ServerAttributeCondition.java BeanCondition.java BeanMatch.java BeanObjectNameCondition.java Added Files: BeanObjectNameRegexCondition.java Log Message: Merging EMS into head for the 2.0 release work Index: BeanCondition.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/match/BeanCondition.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BeanCondition.java 5 Oct 2004 05:16:00 -0000 1.2 --- BeanCondition.java 12 Apr 2006 19:14:01 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- import org.mc4j.console.bean.MBeanNode; + import org.mc4j.ems.connection.bean.EmsBean; import org.w3c.dom.Element; *************** *** 29,33 **** public void initializeCondition(Element rootElement); ! public boolean testCondition(MBeanNode node); --- 30,34 ---- public void initializeCondition(Element rootElement); ! public boolean testCondition(EmsBean node); Index: DashboardMatch.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/match/DashboardMatch.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DashboardMatch.java 5 Oct 2004 05:16:00 -0000 1.2 --- DashboardMatch.java 12 Apr 2006 19:14:01 -0000 1.3 *************** *** 32,36 **** public static final String TYPE_BEAN = "Bean"; ! private List beanMatchList = new ArrayList(); --- 32,36 ---- public static final String TYPE_BEAN = "Bean"; ! private List<BeanMatch> beanMatchList = new ArrayList<BeanMatch>(); *************** *** 59,67 **** } ! public List getBeanMatchList() { return beanMatchList; } ! public void setBeanMatchList(List beanMatchList) { this.beanMatchList = beanMatchList; } --- 59,67 ---- } ! public List<BeanMatch> getBeanMatchList() { return beanMatchList; } ! public void setBeanMatchList(List<BeanMatch> beanMatchList) { this.beanMatchList = beanMatchList; } Index: MatchExecutor.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/match/MatchExecutor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MatchExecutor.java 5 Oct 2004 05:16:00 -0000 1.3 --- MatchExecutor.java 12 Apr 2006 19:14:01 -0000 1.4 *************** *** 17,32 **** package org.mc4j.console.dashboard.match; - import java.util.ArrayList; - import java.util.Hashtable; - import java.util.Iterator; - import java.util.List; - import java.util.Map; - - import org.mc4j.console.bean.MBeanNode; import org.mc4j.console.connection.ConnectionNode; import org.mc4j.console.dashboard.Dashboard; import org.mc4j.console.dashboard.context.ContextHelper; /** * @author Greg Hinkle (gh...@us...), Apr 5, 2004 * @version $Revision$($Author$ / $Date$) --- 17,30 ---- package org.mc4j.console.dashboard.match; import org.mc4j.console.connection.ConnectionNode; import org.mc4j.console.dashboard.Dashboard; import org.mc4j.console.dashboard.context.ContextHelper; + import org.mc4j.ems.connection.bean.EmsBean; + + import java.util.*; /** + * Matches dashboards against the list of currently known beans + * * @author Greg Hinkle (gh...@us...), Apr 5, 2004 * @version $Revision$($Author$ / $Date$) *************** *** 48,52 **** ! public boolean matchSingle(Dashboard dashboard, MBeanNode mBeanNode) { DashboardMatch dashboardMatch = dashboard.getDashboardMatch(); --- 46,50 ---- ! public boolean matchSingle(Dashboard dashboard, EmsBean bean) { DashboardMatch dashboardMatch = dashboard.getDashboardMatch(); *************** *** 58,73 **** BeanMatch beanMatch = (BeanMatch) beanMatchList.get(0); ! List conditionList = beanMatch.getConditionList(); ! if (beanConditionListMatch(conditionList, mBeanNode)) { ! dashboard.putContext(beanMatch.getId(), mBeanNode); ! // For single types, experimenting with placing their object name attributes in context ! Hashtable objectNameProps = mBeanNode.getObjectName().getKeyPropertyList(); ! for(Iterator iterator2 = objectNameProps.entrySet().iterator(); iterator2.hasNext(); ) { ! Map.Entry entry = (Map.Entry) iterator2.next(); ! String key = (String)entry.getKey(); ! String value = (String)entry.getValue(); dashboard.putContext(key, value); } --- 56,71 ---- BeanMatch beanMatch = (BeanMatch) beanMatchList.get(0); ! List<BeanCondition> conditionList = beanMatch.getConditionList(); ! if (beanConditionListMatch(conditionList, bean)) { ! dashboard.putContext(beanMatch.getId(), bean); ! beanMatch.addMatchedBean(bean); ! // For single types, experimenting with placing their object name attributes in context ! Map<String, String> objectNameProps = bean.getBeanName().getKeyProperties(); ! for (Map.Entry<String, String> entry : objectNameProps.entrySet()) { ! String key = (String) entry.getKey(); ! String value = (String) entry.getValue(); dashboard.putContext(key, value); } *************** *** 76,80 **** String newName = null; try { ! newName = (String) ContextHelper.getValue(currentName,dashboard.getContextStarter()); } catch (Exception e) { // This is ok, just assume its not a context lookup --- 74,78 ---- String newName = null; try { ! newName = (String) ContextHelper.getValue(currentName, dashboard.getContextStarter()); } catch (Exception e) { // This is ok, just assume its not a context lookup *************** *** 85,89 **** return true; ! } } return false; --- 83,87 ---- return true; ! } } return false; *************** *** 91,105 **** /** - * * @param dashboard * @param connectionNode * @return null if no matches are found, otherwise a list of dashboards with the ! * associated bindings. */ ! public List matchGlobalDashboards(Dashboard dashboard, ConnectionNode connectionNode) { ! List matches = new ArrayList(); DashboardMatch dashboardMatch = dashboard.getDashboardMatch(); List mbeanNodes = connectionNode.getMBeanList(); boolean allBeansMatched = true; --- 89,103 ---- /** * @param dashboard * @param connectionNode * @return null if no matches are found, otherwise a list of dashboards with the ! * associated bindings. */ ! public List<Dashboard> matchGlobalDashboards(Dashboard dashboard, ConnectionNode connectionNode) { ! List<Dashboard> matches = new ArrayList<Dashboard>(); DashboardMatch dashboardMatch = dashboard.getDashboardMatch(); List mbeanNodes = connectionNode.getMBeanList(); + SortedSet<EmsBean> beans = connectionNode.getEmsConnection().getBeans(); boolean allBeansMatched = true; *************** *** 107,124 **** if (DashboardMatch.TYPE_GLOBAL.equals(dashboardMatch.getType())) { ! List beanMatchList = dashboardMatch.getBeanMatchList(); ! for (Iterator iterator = beanMatchList.iterator(); iterator.hasNext();) { ! BeanMatch beanMatch = (BeanMatch) iterator.next(); ! List conditionList = beanMatch.getConditionList(); boolean beanMatched = false; if (BeanMatch.TYPE_MULTIPLE.equals(beanMatch.getType())) { ! List matchedBeanList = new ArrayList(); ! for (Iterator iterator1 = mbeanNodes.iterator(); iterator1.hasNext();) { ! MBeanNode mBeanNode = (MBeanNode) iterator1.next(); ! if (beanConditionListMatch(conditionList, mBeanNode)) { ! matchedBeanList.add(mBeanNode); beanMatched = true; } --- 105,124 ---- if (DashboardMatch.TYPE_GLOBAL.equals(dashboardMatch.getType())) { ! List<BeanMatch> beanMatchList = dashboardMatch.getBeanMatchList(); ! for (BeanMatch beanMatch : beanMatchList) { ! List<BeanCondition> conditionList = beanMatch.getConditionList(); boolean beanMatched = false; if (BeanMatch.TYPE_MULTIPLE.equals(beanMatch.getType())) { ! List<EmsBean> matchedBeanList = new ArrayList<EmsBean>(); ! // for (Iterator iterator1 = mbeanNodes.iterator(); iterator1.hasNext();) { ! // MBeanNode mBeanNode = (MBeanNode) iterator1.next(); ! for (EmsBean bean : beans) { ! ! if (beanConditionListMatch(conditionList, bean)) { ! matchedBeanList.add(bean); ! beanMatch.addMatchedBean(bean); beanMatched = true; } *************** *** 128,145 **** } else if (BeanMatch.TYPE_SINGLE.equals(beanMatch.getType())) { ! for (Iterator iterator1 = mbeanNodes.iterator(); iterator1.hasNext();) { ! MBeanNode mBeanNode = (MBeanNode) iterator1.next(); ! if (beanConditionListMatch(conditionList, mBeanNode)) { ! dashboard.putContext(beanMatch.getId(), mBeanNode); beanMatched = true; // For single types, experimenting with placing their object name attributes in context ! Hashtable objectNameProps = mBeanNode.getObjectName().getKeyPropertyList(); ! for(Iterator iterator2 = objectNameProps.entrySet().iterator(); iterator2.hasNext(); ) { ! Map.Entry entry = (Map.Entry) iterator2.next(); ! String key = (String)entry.getKey(); ! String value = (String)entry.getValue(); dashboard.putContext(key, value); } --- 128,144 ---- } else if (BeanMatch.TYPE_SINGLE.equals(beanMatch.getType())) { ! for (EmsBean bean : beans) { ! if (beanConditionListMatch(conditionList, bean)) { ! dashboard.putContext(beanMatch.getId(), bean); beanMatched = true; // For single types, experimenting with placing their object name attributes in context ! Map<String, String> objectNameProps = bean.getBeanName().getKeyProperties(); ! for (Map.Entry<String, String> entry : objectNameProps.entrySet()) { ! String key = entry.getKey(); ! String value = entry.getValue(); dashboard.putContext(key, value); + beanMatch.addMatchedBean(bean); } *************** *** 165,180 **** } - /** - * Test all conditions. * @param conditionList ! * @param mBeanNode ! * @return */ ! protected boolean beanConditionListMatch(List conditionList, MBeanNode mBeanNode) { boolean match = true; ! for (Iterator iterator = conditionList.iterator(); iterator.hasNext();) { ! BeanCondition beanCondition = (BeanCondition) iterator.next(); ! if (!beanCondition.testCondition(mBeanNode)) match = false; } --- 164,176 ---- } /** * @param conditionList ! * @param bean */ ! protected boolean beanConditionListMatch(List<BeanCondition> conditionList, EmsBean bean) { boolean match = true; ! ! for (BeanCondition beanCondition : conditionList) { ! if (!beanCondition.testCondition(bean)) match = false; } Index: BeanObjectNameCondition.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/match/BeanObjectNameCondition.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BeanObjectNameCondition.java 5 Oct 2004 05:16:00 -0000 1.2 --- BeanObjectNameCondition.java 12 Apr 2006 19:14:01 -0000 1.3 *************** *** 17,27 **** package org.mc4j.console.dashboard.match; ! import org.openide.ErrorManager; ! import org.openide.windows.IOProvider; ! ! import org.mc4j.console.bean.MBeanNode; ! ! import org.apache.regexp.RE; ! import org.apache.regexp.RESyntaxException; /** --- 17,21 ---- package org.mc4j.console.dashboard.match; ! import org.mc4j.ems.connection.bean.EmsBean; /** *************** *** 30,40 **** */ public class BeanObjectNameCondition extends AbstractBeanCondition { - private String filter; - private RE nameFilter; public String[] getConditionAttributes() { ! return new String[] { "filter" }; --- 24,32 ---- */ public class BeanObjectNameCondition extends AbstractBeanCondition { private String filter; public String[] getConditionAttributes() { ! return new String[]{ "filter" }; *************** *** 47,69 **** public void setFilter(String filter) { this.filter = filter; ! try { ! this.nameFilter = new RE(filter); ! //REUtil.createRE(filter); ! } catch (RESyntaxException rese) { ! ErrorManager.getDefault().notify(rese); ! IOProvider.getDefault().getStdOut().println( ! "Invalid dashboard matching regular expression [" + filter + ! "] in dashboard."); ! } ! } ! public boolean testCondition(MBeanNode node) { ! String cName = node.getObjectName().getCanonicalName(); ! ! if (this.nameFilter != null) { ! return this.nameFilter.match(cName); } else { return true; --- 39,50 ---- public void setFilter(String filter) { this.filter = filter; ! // TODO Check valid Filter } ! public boolean testCondition(EmsBean bean) { ! if (filter != null) { ! return bean.getBeanName().apply(filter); } else { return true; Index: BeanMatch.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/match/BeanMatch.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BeanMatch.java 5 Oct 2004 05:16:00 -0000 1.2 --- BeanMatch.java 12 Apr 2006 19:14:01 -0000 1.3 *************** *** 17,20 **** --- 17,22 ---- package org.mc4j.console.dashboard.match; + import org.mc4j.ems.connection.bean.EmsBean; + import java.util.List; import java.util.ArrayList; *************** *** 32,36 **** private String type; ! private List conditionList = new ArrayList(); public String getId() { --- 34,40 ---- private String type; ! private List<BeanCondition> conditionList = new ArrayList<BeanCondition>(); ! ! private List<EmsBean> matchedBeans = new ArrayList<EmsBean>(); public String getId() { *************** *** 54,62 **** } ! public List getConditionList() { return conditionList; } ! public void setConditionList(List conditionList) { this.conditionList = conditionList; } --- 58,66 ---- } ! public List<BeanCondition> getConditionList() { return conditionList; } ! public void setConditionList(List<BeanCondition> conditionList) { this.conditionList = conditionList; } *************** *** 65,67 **** --- 69,79 ---- this.conditionList.add(beanCondition); } + + public void addMatchedBean(EmsBean bean) { + this.matchedBeans.add(bean); + } + + public List<EmsBean> getMatchedBeans() { + return matchedBeans; + } } --- NEW FILE: BeanObjectNameRegexCondition.java --- /* * Copyright 2002-2004 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.mc4j.console.dashboard.match; import org.mc4j.ems.connection.bean.EmsBean; import org.openide.ErrorManager; import org.openide.windows.IOProvider; import java.util.regex.Pattern; /** * @author Greg Hinkle (gh...@us...), Apr 5, 2004 * @version $Revision: 1.2 $($Author: ghinkl $ / $Date: 2006/04/12 19:14:01 $) */ public class BeanObjectNameRegexCondition extends AbstractBeanCondition { private String filter; private Pattern nameFilter; public String[] getConditionAttributes() { return new String[] { "filter" }; } public String getFilter() { return filter; } public void setFilter(String filter) { this.filter = filter; try { this.nameFilter = Pattern.compile(filter); //REUtil.createRE(filter); } catch (Exception rese) { ErrorManager.getDefault().notify(rese); IOProvider.getDefault().getStdOut().println( "Invalid dashboard matching regular expression [" + filter + "] in dashboard."); } } public boolean testCondition(EmsBean bean) { String cName = bean.getBeanName().getCanonicalName(); if (this.nameFilter != null) { return this.nameFilter.matcher(cName).find(); } else { return true; } } } Index: ServerAttributeCondition.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/dashboard/match/ServerAttributeCondition.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ServerAttributeCondition.java 5 Oct 2004 05:35:41 -0000 1.4 --- ServerAttributeCondition.java 12 Apr 2006 19:14:01 -0000 1.5 *************** *** 18,21 **** --- 18,22 ---- import org.mc4j.console.bean.MBeanNode; + import org.mc4j.ems.connection.bean.EmsBean; /** *************** *** 39,43 **** } ! public boolean testCondition(MBeanNode node) { // TODO GH: Fixme return true; //serverType.equals(node.getConnectionNode().getgetConnectionType()); --- 40,44 ---- } ! public boolean testCondition(EmsBean bean) { // TODO GH: Fixme return true; //serverType.equals(node.getConnectionNode().getgetConnectionType()); |